Skip to content

Commit 4497d34

Browse files
committed
Remove extern crate rustc_middle from rustc_const_eval.
This requires exporting the interpreter macros so they can be used with `use crate::interpret::*`.
1 parent f12e935 commit 4497d34

32 files changed

+101
-48
lines changed

compiler/rustc_const_eval/src/const_eval/dummy_machine.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
use crate::interpret::{self, HasStaticRootDefId, ImmTy, Immediate, InterpCx, PointerArithmetic};
1+
use crate::interpret::{
2+
self, throw_machine_stop, HasStaticRootDefId, ImmTy, Immediate, InterpCx, PointerArithmetic,
3+
};
24
use rustc_middle::mir::interpret::{AllocId, ConstAllocation, InterpResult};
35
use rustc_middle::mir::*;
46
use rustc_middle::query::TyCtxtAt;
57
use rustc_middle::ty;
68
use rustc_middle::ty::layout::TyAndLayout;
9+
use rustc_middle::{bug, span_bug};
710
use rustc_span::def_id::DefId;
811

912
/// Macro for machine-specific `InterpError` without allocation.

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use rustc_span::{Span, Symbol};
1111

1212
use super::CompileTimeInterpreter;
1313
use crate::errors::{self, FrameNote, ReportErrorExt};
14+
use crate::interpret::{err_inval, err_machine_stop};
1415
use crate::interpret::{ErrorHandled, Frame, InterpError, InterpErrorInfo, MachineStopType};
1516

1617
/// The CTFE machine has some custom error kinds.

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::sync::atomic::Ordering::Relaxed;
33
use either::{Left, Right};
44

55
use rustc_hir::def::DefKind;
6+
use rustc_middle::bug;
67
use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo};
78
use rustc_middle::mir::{self, ConstAlloc, ConstValue};
89
use rustc_middle::query::TyCtxtAt;
@@ -24,7 +25,7 @@ use crate::interpret::{
2425
InternKind, InterpCx, InterpError, InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking,
2526
StackPopCleanup,
2627
};
27-
use crate::interpret::{eval_nullary_intrinsic, InternResult};
28+
use crate::interpret::{eval_nullary_intrinsic, throw_exhaust, InternResult};
2829
use crate::CTRL_C_RECEIVED;
2930

3031
// Returns a pointer to where the result lives

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_hir::def::DefKind;
1010
use rustc_hir::def_id::DefId;
1111
use rustc_hir::def_id::LocalDefId;
1212
use rustc_hir::LangItem;
13+
use rustc_middle::bug;
1314
use rustc_middle::mir;
1415
use rustc_middle::mir::AssertMessage;
1516
use rustc_middle::query::TyCtxtAt;
@@ -24,8 +25,9 @@ use rustc_target::spec::abi::Abi as CallAbi;
2425
use crate::errors::{LongRunning, LongRunningWarn};
2526
use crate::fluent_generated as fluent;
2627
use crate::interpret::{
27-
self, compile_time_machine, AllocId, AllocRange, ConstAllocation, CtfeProvenance, FnArg, FnVal,
28-
Frame, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, PointerArithmetic, Scalar,
28+
self, compile_time_machine, err_ub, throw_exhaust, throw_inval, throw_ub_custom,
29+
throw_unsup_format, AllocId, AllocRange, ConstAllocation, CtfeProvenance, FnArg, FnVal, Frame,
30+
ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, PointerArithmetic, Scalar,
2931
};
3032

3133
use super::error::*;

compiler/rustc_const_eval/src/const_eval/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Not in interpret to make sure we do not use private implementation details
22

3+
use rustc_middle::bug;
34
use rustc_middle::mir;
45
use rustc_middle::mir::interpret::InterpErrorInfo;
56
use rustc_middle::query::{Key, TyCtxtAt};

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use rustc_data_structures::stack::ensure_sufficient_stack;
2+
use rustc_middle::bug;
23
use rustc_middle::mir;
34
use rustc_middle::mir::interpret::{EvalToValTreeResult, GlobalId};
45
use rustc_middle::ty::layout::{LayoutCx, LayoutOf, TyAndLayout};

compiler/rustc_const_eval/src/interpret/cast.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ use rustc_middle::mir::CastKind;
77
use rustc_middle::ty::adjustment::PointerCoercion;
88
use rustc_middle::ty::layout::{IntegerExt, LayoutOf, TyAndLayout};
99
use rustc_middle::ty::{self, FloatTy, Ty};
10+
use rustc_middle::{bug, span_bug};
1011
use rustc_target::abi::Integer;
1112
use rustc_type_ir::TyKind::*;
1213

1314
use super::{
14-
util::ensure_monomorphic_enough, FnVal, ImmTy, Immediate, InterpCx, Machine, OpTy, PlaceTy,
15+
err_inval, throw_ub, throw_ub_custom, util::ensure_monomorphic_enough, FnVal, ImmTy, Immediate,
16+
InterpCx, Machine, OpTy, PlaceTy,
1517
};
1618

1719
use crate::fluent_generated as fluent;

compiler/rustc_const_eval/src/interpret/discriminant.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
//! Functions for reading and writing discriminants of multi-variant layouts (enums and coroutines).
22
33
use rustc_middle::mir;
4+
use rustc_middle::span_bug;
45
use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt};
56
use rustc_middle::ty::{self, ScalarInt, Ty};
67
use rustc_target::abi::{self, TagEncoding};
78
use rustc_target::abi::{VariantIdx, Variants};
89

9-
use super::{ImmTy, InterpCx, InterpResult, Machine, Readable, Scalar, Writeable};
10+
use super::{
11+
err_ub, throw_ub, ImmTy, InterpCx, InterpResult, Machine, Readable, Scalar, Writeable,
12+
};
1013

1114
impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
1215
/// Writes the discriminant of the given variant.

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ use rustc_middle::ty::layout::{
1717
TyAndLayout,
1818
};
1919
use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt, TypeFoldable, Variance};
20+
use rustc_middle::{bug, span_bug};
2021
use rustc_mir_dataflow::storage::always_storage_live_locals;
2122
use rustc_session::Limit;
2223
use rustc_span::Span;
2324
use rustc_target::abi::{call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout};
2425

2526
use super::{
26-
GlobalId, Immediate, InterpErrorInfo, InterpResult, MPlaceTy, Machine, MemPlace, MemPlaceMeta,
27-
Memory, MemoryKind, OpTy, Operand, Place, PlaceTy, Pointer, PointerArithmetic, Projectable,
28-
Provenance, Scalar, StackPopJump,
27+
err_inval, throw_inval, throw_ub, throw_ub_custom, throw_unsup, GlobalId, Immediate,
28+
InterpErrorInfo, InterpResult, MPlaceTy, Machine, MemPlace, MemPlaceMeta, Memory, MemoryKind,
29+
OpTy, Operand, Place, PlaceTy, Pointer, PointerArithmetic, Projectable, Provenance, Scalar,
30+
StackPopJump,
2931
};
3032
use crate::errors;
3133
use crate::util;

compiler/rustc_const_eval/src/interpret/intern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_middle::ty::layout::TyAndLayout;
2424
use rustc_span::def_id::LocalDefId;
2525
use rustc_span::sym;
2626

27-
use super::{AllocId, Allocation, InterpCx, MPlaceTy, Machine, MemoryKind, PlaceTy};
27+
use super::{err_ub, AllocId, Allocation, InterpCx, MPlaceTy, Machine, MemoryKind, PlaceTy};
2828
use crate::const_eval;
2929
use crate::errors::NestedStaticInThreadLocal;
3030

0 commit comments

Comments
 (0)