Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6f6620b
Rename "cyclone" to "apple-a7" per changes in upstream LLVM
trevyn Jun 7, 2020
95c4899
Added an example where explicitly dropping a lock is necessary/a good…
poliorcetics Jun 7, 2020
9c8f881
Improved the example to work with mutable data, providing a reason fo…
poliorcetics Jun 7, 2020
fdef1a5
Simply use drop instead of std::mem::drop
poliorcetics Jun 8, 2020
496818c
Add methods to go from a nul-terminated Vec<u8> to a CString, checked…
poliorcetics Jun 8, 2020
b03164e
Move to unstable, linking the issue
poliorcetics Jun 9, 2020
1312d30
Remove a lot of unecessary/duplicated comments
poliorcetics Jun 9, 2020
88ea7e5
Use min_specialization in the remaining rustc crates
matthewjasper Jun 1, 2020
c29b3fa
On recursive ADT, provide indirection structured suggestion
estebank May 29, 2020
7cde07e
review comments: only suggest one substitution
estebank May 31, 2020
03552ec
fix rebase
estebank Jun 10, 2020
7f3bb39
Add a TryFrom<Vec<u8>> impl that mirror from_vec_with_nul
poliorcetics Jun 10, 2020
6b95526
Fix the link in the TryFrom impl
poliorcetics Jun 11, 2020
871513d
make miri memory TyCtxtAt a TyCtxt
RalfJung Jun 1, 2020
dc6ffae
make miri InterpCx TyCtxtAt a TyCtxt, and separately remember the roo…
RalfJung Jun 1, 2020
0ac6fd0
fix const_prop spans and re-bless tests
RalfJung Jun 1, 2020
32b01c7
avoid computing cur_span all the time
RalfJung Jun 11, 2020
c0aef6d
Remove vestigial CI job msvc-aux.
ehuss Jun 12, 2020
8b20928
Stabilize Option::zip
tesuji Jun 13, 2020
c45231c
Revert heterogeneous SocketAddr PartialEq impls
dtolnay Jun 13, 2020
6049650
avoid computing precise span for const_eval query
RalfJung Jun 13, 2020
c6512fd
run const_eval_raw with root_span
RalfJung Jun 13, 2020
f747073
Apply suggestions from code review
poliorcetics Jun 13, 2020
34b3ff0
Clarify the scope-related explanation
poliorcetics Jun 13, 2020
c010e71
Rewrap comments in Mutex example
dtolnay Jun 13, 2020
204c236
Add test for comparing SocketAddr with inferred right-hand side
dtolnay Jun 13, 2020
71d41d9
add TcpListener support for HermitCore
stlankes Jun 13, 2020
c99116a
remove unused function
stlankes Jun 13, 2020
fd86a84
use latest interface to HermitCore
stlankes Jun 13, 2020
2210abe
keep root_span and tcx together
RalfJung Jun 14, 2020
5f4eb27
Removing the TryFrom impl
poliorcetics Jun 14, 2020
685f066
Add a new error type for the new method
poliorcetics Jun 14, 2020
47cc5cc
Update to use the new error type and correctly compile the doc tests
poliorcetics Jun 14, 2020
d221ffc
simplify conversion to IpAddr::V6
stlankes Jun 14, 2020
9d596b5
changes to pass the format check
stlankes Jun 15, 2020
810ba39
remove obsolete line
stlankes Jun 15, 2020
aa53a03
Revert "changes to pass the format check"
stlankes Jun 15, 2020
9c9f21f
Revert "simplify conversion to IpAddr::V6"
stlankes Jun 15, 2020
6c983a7
use Ipv6Addr::from to build the IPv6 address
stlankes Jun 15, 2020
a8e3746
add comment about the usage of Arc
stlankes Jun 15, 2020
76f1581
remove obsolete , to pass the format check
stlankes Jun 15, 2020
eef9356
Rollup merge of #72707 - matthewjasper:rustc_min_spec, r=oli-obk
RalfJung Jun 15, 2020
d97e8ca
Rollup merge of #72740 - estebank:recursive-indirection, r=matthewjasper
RalfJung Jun 15, 2020
f9c8a67
Rollup merge of #72879 - RalfJung:miri-tctx-at, r=oli-obk
RalfJung Jun 15, 2020
89eb74d
Rollup merge of #72938 - lzutao:stabilize_option_zip, r=dtolnay
RalfJung Jun 15, 2020
3440957
Rollup merge of #73086 - trevyn:apple-a7, r=nikic
RalfJung Jun 15, 2020
7c8b941
Rollup merge of #73104 - poliorcetics:explicit-mutex-drop-example, r=…
RalfJung Jun 15, 2020
ec6fe42
Rollup merge of #73139 - poliorcetics:cstring-from-vec-with-nul, r=dt…
RalfJung Jun 15, 2020
fb75d4a
Rollup merge of #73296 - ehuss:remove-msvc-aux, r=Mark-Simulacrum
RalfJung Jun 15, 2020
202499f
Rollup merge of #73304 - dtolnay:socketeq, r=Mark-Simulacrum
RalfJung Jun 15, 2020
54bd077
Rollup merge of #73331 - hermitcore:listen, r=kennytm
RalfJung Jun 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make miri InterpCx TyCtxtAt a TyCtxt, and separately remember the roo…
…t span of the evaluation
  • Loading branch information
RalfJung committed Jun 12, 2020
commit dc6ffaebd5b56793f86443a0a50c06f025321198
1 change: 1 addition & 0 deletions src/librustc_middle/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ impl<'tcx> ty::TyS<'tcx> {
/// optimization as well as the rules around static values. Note
/// that the `Freeze` trait is not exposed to end users and is
/// effectively an implementation detail.
// FIXME: use `TyCtxtAt` instead of separate `Span`.
pub fn is_freeze(
&'tcx self,
tcx: TyCtxt<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/const_eval/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ pub fn error_to_const_error<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>(
) -> ConstEvalErr<'tcx> {
error.print_backtrace();
let stacktrace = ecx.generate_stacktrace();
ConstEvalErr { error: error.kind, stacktrace, span: ecx.tcx.span }
ConstEvalErr { error: error.kind, stacktrace, span: ecx.cur_span() }
}
21 changes: 11 additions & 10 deletions src/librustc_mir/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
body: &'mir mir::Body<'tcx>,
) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
debug!("eval_body_using_ecx: {:?}, {:?}", cid, ecx.param_env);
let tcx = ecx.tcx.tcx;
let tcx = ecx.tcx;
let layout = ecx.layout_of(body.return_ty().subst(tcx, cid.instance.substs))?;
assert!(!layout.is_unsized());
let ret = ecx.allocate(layout, MemoryKind::Stack);
Expand Down Expand Up @@ -81,13 +81,14 @@ fn eval_body_using_ecx<'mir, 'tcx>(
/// parameter. These bounds are passed to `mk_eval_cx` via the `ParamEnv` argument.
pub(super) fn mk_eval_cx<'mir, 'tcx>(
tcx: TyCtxt<'tcx>,
span: Span,
root_span: Span,
param_env: ty::ParamEnv<'tcx>,
can_access_statics: bool,
) -> CompileTimeEvalContext<'mir, 'tcx> {
debug!("mk_eval_cx: {:?}", param_env);
InterpCx::new(
tcx.at(span),
tcx,
root_span,
param_env,
CompileTimeInterpreter::new(tcx.sess.const_eval_limit()),
MemoryExtra { can_access_statics },
Expand Down Expand Up @@ -163,7 +164,7 @@ pub(super) fn op_to_const<'tcx>(
0,
),
};
let len = b.to_machine_usize(&ecx.tcx.tcx).unwrap();
let len = b.to_machine_usize(ecx).unwrap();
let start = start.try_into().unwrap();
let len: usize = len.try_into().unwrap();
ConstValue::Slice { data, start, end: start + len }
Expand Down Expand Up @@ -213,7 +214,7 @@ fn validate_and_turn_into_const<'tcx>(

val.map_err(|error| {
let err = error_to_const_error(&ecx, error);
err.struct_error(ecx.tcx, "it is undefined behavior to use this value", |mut diag| {
err.struct_error(ecx.tcx_at(), "it is undefined behavior to use this value", |mut diag| {
diag.note(note_on_undefined_behavior_error());
diag.emit();
})
Expand Down Expand Up @@ -299,9 +300,9 @@ pub fn const_eval_raw_provider<'tcx>(

let is_static = tcx.is_static(def_id);

let span = tcx.def_span(cid.instance.def_id());
let mut ecx = InterpCx::new(
tcx.at(span),
tcx,
tcx.def_span(cid.instance.def_id()),
key.param_env,
CompileTimeInterpreter::new(tcx.sess.const_eval_limit()),
MemoryExtra { can_access_statics: is_static },
Expand All @@ -316,7 +317,7 @@ pub fn const_eval_raw_provider<'tcx>(
if is_static {
// Ensure that if the above error was either `TooGeneric` or `Reported`
// an error must be reported.
let v = err.report_as_error(ecx.tcx, "could not evaluate static initializer");
let v = err.report_as_error(ecx.tcx_at(), "could not evaluate static initializer");

// If this is `Reveal:All`, then we need to make sure an error is reported but if
// this is `Reveal::UserFacing`, then it's expected that we could get a
Expand Down Expand Up @@ -372,13 +373,13 @@ pub fn const_eval_raw_provider<'tcx>(
// anything else (array lengths, enum initializers, constant patterns) are
// reported as hard errors
} else {
err.report_as_error(ecx.tcx, "evaluation of constant value failed")
err.report_as_error(ecx.tcx_at(), "evaluation of constant value failed")
}
}
}
} else {
// use of broken constant from other crate
err.report_as_error(ecx.tcx, "could not evaluate constant")
err.report_as_error(ecx.tcx_at(), "could not evaluate constant")
}
})
}
8 changes: 4 additions & 4 deletions src/librustc_mir/interpret/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}

let instance = ty::Instance::resolve_for_fn_ptr(
*self.tcx,
self.tcx,
self.param_env,
def_id,
substs,
Expand Down Expand Up @@ -91,7 +91,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}

let instance = ty::Instance::resolve_closure(
*self.tcx,
self.tcx,
def_id,
substs,
ty::ClosureKind::FnOnce,
Expand Down Expand Up @@ -140,7 +140,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// Handle cast from a univariant (ZST) enum.
match src.layout.variants {
Variants::Single { index } => {
if let Some(discr) = src.layout.ty.discriminant_for_variant(*self.tcx, index) {
if let Some(discr) = src.layout.ty.discriminant_for_variant(self.tcx, index) {
assert!(src.layout.is_zst());
let discr_layout = self.layout_of(discr.ty)?;
return Ok(self.cast_from_scalar(discr.val, discr_layout, cast_ty).into());
Expand Down Expand Up @@ -270,7 +270,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// u64 cast is from usize to u64, which is always good
let val = Immediate::new_slice(
ptr,
length.eval_usize(self.tcx.tcx, self.param_env),
length.eval_usize(self.tcx, self.param_env),
self,
);
self.write_immediate(val, dest)
Expand Down
60 changes: 38 additions & 22 deletions src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ pub struct InterpCx<'mir, 'tcx, M: Machine<'mir, 'tcx>> {
pub machine: M,

/// The results of the type checker, from rustc.
pub tcx: TyCtxtAt<'tcx>,
pub tcx: TyCtxt<'tcx>,

/// The span of the "root" of the evaluation, i.e., the const
/// we are evaluating (if this is CTFE).
pub(super) root_span: Span,

/// Bounds in scope for polymorphic evaluations.
pub(crate) param_env: ty::ParamEnv<'tcx>,
Expand Down Expand Up @@ -196,7 +200,7 @@ where
{
#[inline]
fn tcx(&self) -> TyCtxt<'tcx> {
*self.tcx
self.tcx
}
}

Expand All @@ -209,13 +213,13 @@ where
}
}

impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpCx<'mir, 'tcx, M> {
impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> LayoutOf for InterpCx<'mir, 'tcx, M> {
type Ty = Ty<'tcx>;
type TyAndLayout = InterpResult<'tcx, TyAndLayout<'tcx>>;

#[inline]
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
self.tcx
self.tcx_at()
.layout_of(self.param_env.and(ty))
.map_err(|layout| err_inval!(Layout(layout)).into())
}
Expand Down Expand Up @@ -292,23 +296,35 @@ pub(super) fn from_known_layout<'tcx>(

impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
pub fn new(
tcx: TyCtxtAt<'tcx>,
tcx: TyCtxt<'tcx>,
root_span: Span,
param_env: ty::ParamEnv<'tcx>,
machine: M,
memory_extra: M::MemoryExtra,
) -> Self {
InterpCx {
machine,
tcx,
root_span,
param_env,
memory: Memory::new(*tcx, memory_extra),
memory: Memory::new(tcx, memory_extra),
vtables: FxHashMap::default(),
}
}

#[inline(always)]
pub fn set_span(&mut self, span: Span) {
self.tcx.span = span;
pub fn cur_span(&self) -> Span {
self
.stack()
.last()
.and_then(|f| f.current_source_info())
.map(|si| si.span)
.unwrap_or(self.root_span)
}

#[inline(always)]
pub fn tcx_at(&self) -> TyCtxtAt<'tcx> {
self.tcx.at(self.cur_span())
}

#[inline(always)]
Expand Down Expand Up @@ -386,12 +402,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {

#[inline]
pub fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
ty.is_sized(self.tcx, self.param_env)
ty.is_sized(self.tcx_at(), self.param_env)
}

#[inline]
pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool {
ty.is_freeze(*self.tcx, self.param_env, DUMMY_SP)
ty.is_freeze(self.tcx, self.param_env, self.cur_span())
}

pub fn load_mir(
Expand All @@ -402,20 +418,20 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// do not continue if typeck errors occurred (can only occur in local crate)
let did = instance.def_id();
if let Some(did) = did.as_local() {
if self.tcx.has_typeck_tables(did) {
if let Some(error_reported) = self.tcx.typeck_tables_of(did).tainted_by_errors {
if self.tcx_at().has_typeck_tables(did) {
if let Some(error_reported) = self.tcx_at().typeck_tables_of(did).tainted_by_errors {
throw_inval!(TypeckError(error_reported))
}
}
}
trace!("load mir(instance={:?}, promoted={:?})", instance, promoted);
if let Some(promoted) = promoted {
return Ok(&self.tcx.promoted_mir(did)[promoted]);
return Ok(&self.tcx_at().promoted_mir(did)[promoted]);
}
match instance {
ty::InstanceDef::Item(def_id) => {
if self.tcx.is_mir_available(did) {
Ok(self.tcx.optimized_mir(did))
if self.tcx_at().is_mir_available(did) {
Ok(self.tcx_at().optimized_mir(did))
} else {
throw_unsup!(NoMirFor(def_id))
}
Expand Down Expand Up @@ -456,7 +472,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
trace!("resolve: {:?}, {:#?}", def_id, substs);
trace!("param_env: {:#?}", self.param_env);
trace!("substs: {:#?}", substs);
match ty::Instance::resolve(*self.tcx, self.param_env, def_id, substs) {
match ty::Instance::resolve(self.tcx, self.param_env, def_id, substs) {
Ok(Some(instance)) => Ok(instance),
Ok(None) => throw_inval!(TooGeneric),

Expand All @@ -475,7 +491,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// have to support that case (mostly by skipping all caching).
match frame.locals.get(local).and_then(|state| state.layout.get()) {
None => {
let layout = from_known_layout(self.tcx, layout, || {
let layout = from_known_layout(self.tcx_at(), layout, || {
let local_ty = frame.body.local_decls[local].ty;
let local_ty =
self.subst_from_frame_and_normalize_erasing_regions(frame, local_ty);
Expand Down Expand Up @@ -560,7 +576,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let size = size.align_to(align);

// Check if this brought us over the size limit.
if size.bytes() >= self.tcx.data_layout().obj_size_bound() {
if size.bytes() >= self.tcx.data_layout.obj_size_bound() {
throw_ub!(InvalidMeta("total size is bigger than largest supported object"));
}
Ok(Some((size, align)))
Expand All @@ -576,7 +592,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let elem = layout.field(self, 0)?;

// Make sure the slice is not too big.
let size = elem.size.checked_mul(len, &*self.tcx).ok_or_else(|| {
let size = elem.size.checked_mul(len, self).ok_or_else(|| {
err_ub!(InvalidMeta("slice is bigger than largest supported object"))
})?;
Ok(Some((size, elem.align.abi)))
Expand Down Expand Up @@ -627,7 +643,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let mut locals = IndexVec::from_elem(dummy, &body.local_decls);

// Now mark those locals as dead that we do not want to initialize
match self.tcx.def_kind(instance.def_id()) {
match self.tcx_at().def_kind(instance.def_id()) {
// statics and constants don't have `Storage*` statements, no need to look for them
//
// FIXME: The above is likely untrue. See
Expand Down Expand Up @@ -842,7 +858,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
} else {
self.param_env
};
let val = self.tcx.const_eval_global_id(param_env, gid, Some(self.tcx.span))?;
let val = self.tcx.const_eval_global_id(param_env, gid, Some(self.cur_span()))?;

// Even though `ecx.const_eval` is called from `eval_const_to_op` we can never have a
// recursion deeper than one level, because the `tcx.const_eval` above is guaranteed to not
Expand Down Expand Up @@ -873,7 +889,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// FIXME: We can hit delay_span_bug if this is an invalid const, interning finds
// that problem, but we never run validation to show an error. Can we ensure
// this does not happen?
let val = self.tcx.const_eval_raw(param_env.and(gid))?;
let val = self.tcx_at().const_eval_raw(param_env.and(gid))?;
self.raw_const_to_mplace(val)
}

Expand Down
18 changes: 9 additions & 9 deletions src/librustc_mir/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>(
// in the value the dangling reference lies.
// The `delay_span_bug` ensures that we don't forget such a check in validation.
if tcx.get_global_alloc(alloc_id).is_none() {
tcx.sess.delay_span_bug(ecx.tcx.span, "tried to intern dangling pointer");
tcx.sess.delay_span_bug(ecx.root_span, "tried to intern dangling pointer");
}
// treat dangling pointers like other statics
// just to stop trying to recurse into them
Expand All @@ -111,7 +111,7 @@ fn intern_shallow<'rt, 'mir, 'tcx, M: CompileTimeMachine<'mir, 'tcx>>(
if let InternMode::Static(mutability) = mode {
// For this, we need to take into account `UnsafeCell`. When `ty` is `None`, we assume
// no interior mutability.
let frozen = ty.map_or(true, |ty| ty.is_freeze(ecx.tcx.tcx, ecx.param_env, ecx.tcx.span));
let frozen = ty.map_or(true, |ty| ty.is_freeze(ecx.tcx, ecx.param_env, ecx.root_span));
// For statics, allocation mutability is the combination of the place mutability and
// the type mutability.
// The entire allocation needs to be mutable if it contains an `UnsafeCell` anywhere.
Expand Down Expand Up @@ -174,7 +174,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
// they caused. It also helps us to find cases where const-checking
// failed to prevent an `UnsafeCell` (but as `ignore_interior_mut_in_const`
// shows that part is not airtight).
mutable_memory_in_const(self.ecx.tcx, "`UnsafeCell`");
mutable_memory_in_const(self.ecx.tcx_at(), "`UnsafeCell`");
}
// We are crossing over an `UnsafeCell`, we can mutate again. This means that
// References we encounter inside here are interned as pointing to mutable
Expand All @@ -192,7 +192,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
fn visit_value(&mut self, mplace: MPlaceTy<'tcx>) -> InterpResult<'tcx> {
// Handle Reference types, as these are the only relocations supported by const eval.
// Raw pointers (and boxes) are handled by the `leftover_relocations` logic.
let tcx = self.ecx.tcx;
let tcx = self.ecx.tcx.at(self.ecx.root_span);
let ty = mplace.layout.ty;
if let ty::Ref(_, referenced_ty, ref_mutability) = ty.kind {
let value = self.ecx.read_immediate(mplace.into())?;
Expand Down Expand Up @@ -254,7 +254,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: CompileTimeMachine<'mir, 'tcx>> ValueVisitor<'mir
if ref_mutability == Mutability::Mut {
match referenced_ty.kind {
ty::Array(_, n)
if n.eval_usize(tcx.tcx, self.ecx.param_env) == 0 => {}
if n.eval_usize(self.ecx.tcx, self.ecx.param_env) == 0 => {}
ty::Slice(_)
if mplace.meta.unwrap_meta().to_machine_usize(self.ecx)?
== 0 => {}
Expand Down Expand Up @@ -358,7 +358,7 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
Ok(()) => {}
Err(error) => {
ecx.tcx.sess.delay_span_bug(
ecx.tcx.span,
ecx.root_span,
"error during interning should later cause validation failure",
);
// Some errors shouldn't come up because creating them causes
Expand Down Expand Up @@ -407,7 +407,7 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
// such as `const CONST_RAW: *const Vec<i32> = &Vec::new() as *const _;`.
ecx.tcx
.sess
.span_err(ecx.tcx.span, "untyped pointers are not allowed in constant");
.span_err(ecx.root_span, "untyped pointers are not allowed in constant");
// For better errors later, mark the allocation as immutable.
alloc.mutability = Mutability::Not;
}
Expand All @@ -422,11 +422,11 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx>>(
} else if ecx.memory.dead_alloc_map.contains_key(&alloc_id) {
// Codegen does not like dangling pointers, and generally `tcx` assumes that
// all allocations referenced anywhere actually exist. So, make sure we error here.
ecx.tcx.sess.span_err(ecx.tcx.span, "encountered dangling pointer in final constant");
ecx.tcx.sess.span_err(ecx.root_span, "encountered dangling pointer in final constant");
} else if ecx.tcx.get_global_alloc(alloc_id).is_none() {
// We have hit an `AllocId` that is neither in local or global memory and isn't
// marked as dangling by local memory. That should be impossible.
span_bug!(ecx.tcx.span, "encountered unknown alloc id {:?}", alloc_id);
span_bug!(ecx.root_span, "encountered unknown alloc id {:?}", alloc_id);
}
}
}
Loading