Merge pull request #4613 from RalfJung/rustup

Rustup
This commit is contained in:
Ralf Jung 2025-10-02 07:50:43 +00:00 committed by GitHub
commit d3bb22fe4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 35 additions and 31 deletions

View file

@ -1 +1 @@
29b7717de23f3969ceeb5bef5b01d9223f807655
42b384ec0dfcd528d99a4db0a337d9188a9eecaa

View file

@ -221,7 +221,7 @@ impl AllocHistory {
pub fn new(id: AllocId, item: Item, machine: &MiriMachine<'_>) -> Self {
Self {
id,
root: (item, machine.current_span()),
root: (item, machine.current_user_relevant_span()),
creations: SmallVec::new(),
invalidations: SmallVec::new(),
protectors: SmallVec::new(),
@ -269,11 +269,11 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
};
self.history
.creations
.push(Creation { retag: op.clone(), span: self.machine.current_span() });
.push(Creation { retag: op.clone(), span: self.machine.current_user_relevant_span() });
}
pub fn log_invalidation(&mut self, tag: BorTag) {
let mut span = self.machine.current_span();
let mut span = self.machine.current_user_relevant_span();
let (range, cause) = match &self.operation {
Operation::Retag(RetagOp { info, range, permission, .. }) => {
if info.cause == RetagCause::FnEntry {
@ -298,7 +298,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
};
self.history
.protectors
.push(Protection { tag: op.new_tag, span: self.machine.current_span() });
.push(Protection { tag: op.new_tag, span: self.machine.current_user_relevant_span() });
}
pub fn get_logs_relevant_to(

View file

@ -33,7 +33,7 @@ impl<'tcx> Tree {
machine: &MiriMachine<'tcx>,
) -> Self {
let tag = state.root_ptr_tag(id, machine); // Fresh tag for the root
let span = machine.current_span();
let span = machine.current_user_relevant_span();
Tree::new(tag, size, span)
}
@ -61,7 +61,7 @@ impl<'tcx> Tree {
ProvenanceExtra::Wildcard => return interp_ok(()),
};
let global = machine.borrow_tracker.as_ref().unwrap();
let span = machine.current_span();
let span = machine.current_user_relevant_span();
self.perform_access(
tag,
Some((range, access_kind, diagnostics::AccessCause::Explicit(access_kind))),
@ -86,7 +86,7 @@ impl<'tcx> Tree {
ProvenanceExtra::Wildcard => return interp_ok(()),
};
let global = machine.borrow_tracker.as_ref().unwrap();
let span = machine.current_span();
let span = machine.current_user_relevant_span();
self.dealloc(tag, alloc_range(Size::ZERO, size), global, alloc_id, span)
}
@ -107,7 +107,7 @@ impl<'tcx> Tree {
tag: BorTag,
alloc_id: AllocId, // diagnostics
) -> InterpResult<'tcx> {
let span = machine.current_span();
let span = machine.current_user_relevant_span();
// `None` makes it the magic on-protector-end operation
self.perform_access(tag, None, global, alloc_id, span)
}
@ -360,7 +360,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
Some((range_in_alloc, AccessKind::Read, diagnostics::AccessCause::Reborrow)),
this.machine.borrow_tracker.as_ref().unwrap(),
alloc_id,
this.machine.current_span(),
this.machine.current_user_relevant_span(),
)?;
// Also inform the data race model (but only if any bytes are actually affected).
@ -386,7 +386,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
inside_perms,
new_perm.outside_perm,
protected,
this.machine.current_span(),
this.machine.current_user_relevant_span(),
)?;
drop(tree_borrows);

View file

@ -1208,7 +1208,7 @@ impl VClockAlloc {
ty: Option<Ty<'_>>,
machine: &MiriMachine<'_>,
) -> InterpResult<'tcx> {
let current_span = machine.current_span();
let current_span = machine.current_user_relevant_span();
let global = machine.data_race.as_vclocks_ref().unwrap();
if !global.race_detecting() {
return interp_ok(());
@ -1250,7 +1250,7 @@ impl VClockAlloc {
ty: Option<Ty<'_>>,
machine: &mut MiriMachine<'_>,
) -> InterpResult<'tcx> {
let current_span = machine.current_span();
let current_span = machine.current_user_relevant_span();
let global = machine.data_race.as_vclocks_mut().unwrap();
if !global.race_detecting() {
return interp_ok(());
@ -1304,7 +1304,7 @@ impl Default for LocalClocks {
impl FrameState {
pub fn local_write(&self, local: mir::Local, storage_live: bool, machine: &MiriMachine<'_>) {
let current_span = machine.current_span();
let current_span = machine.current_user_relevant_span();
let global = machine.data_race.as_vclocks_ref().unwrap();
if !global.race_detecting() {
return;
@ -1334,7 +1334,7 @@ impl FrameState {
}
pub fn local_read(&self, local: mir::Local, machine: &MiriMachine<'_>) {
let current_span = machine.current_span();
let current_span = machine.current_user_relevant_span();
let global = machine.data_race.as_vclocks_ref().unwrap();
if !global.race_detecting() {
return;
@ -1573,7 +1573,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
size.bytes()
);
let current_span = this.machine.current_span();
let current_span = this.machine.current_user_relevant_span();
// Perform the atomic operation.
data_race.maybe_perform_sync_operation(
&this.machine.threads,
@ -1827,7 +1827,7 @@ impl GlobalState {
machine: &MiriMachine<'tcx>,
atomic: AtomicFenceOrd,
) -> InterpResult<'tcx> {
let current_span = machine.current_span();
let current_span = machine.current_user_relevant_span();
self.maybe_perform_sync_operation(&machine.threads, current_span, |index, mut clocks| {
trace!("Atomic fence on {:?} with ordering {:?}", index, atomic);
@ -1915,7 +1915,7 @@ impl GlobalState {
callback: impl FnOnce(&VClock) -> R,
) -> R {
let thread = threads.active_thread();
let span = threads.active_thread_ref().current_span();
let span = threads.active_thread_ref().current_user_relevant_span();
let (index, mut clocks) = self.thread_state_mut(thread);
let r = callback(&clocks.clock);
// Increment the clock, so that all following events cannot be confused with anything that

View file

@ -37,7 +37,11 @@ pub(super) fn emit_warning<'tcx>(
cache: &WarningCache,
diagnostic: impl FnOnce() -> NonHaltingDiagnostic,
) {
let span = ecx.machine.current_span();
// FIXME: This is not the right span to use (it's always inside the local crates so if the same
// operation is invoked from multiple places it will warn multiple times). `cur_span` is not
// right either though (we should honor `#[track_caller]`). Ultimately what we want is "the
// primary span the warning would point at".
let span = ecx.machine.current_user_relevant_span();
if cache.read().unwrap().contains(&span) {
return;
}

View file

@ -263,7 +263,7 @@ impl<'tcx> Thread<'tcx> {
self.top_user_relevant_frame.or_else(|| self.stack.len().checked_sub(1))
}
pub fn current_span(&self) -> Span {
pub fn current_user_relevant_span(&self) -> Span {
self.top_user_relevant_frame()
.map(|frame_idx| self.stack[frame_idx].current_span())
.unwrap_or(rustc_span::DUMMY_SP)
@ -867,7 +867,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let mut state = tls::TlsDtorsState::default();
Box::new(move |m| state.on_stack_empty(m))
});
let current_span = this.machine.current_span();
let current_span = this.machine.current_user_relevant_span();
match &mut this.machine.data_race {
GlobalDataRaceHandler::None => {}
GlobalDataRaceHandler::Vclocks(data_race) =>

View file

@ -1128,8 +1128,8 @@ impl<'tcx> MiriMachine<'tcx> {
/// `#[track_caller]`.
/// This function is backed by a cache, and can be assumed to be very fast.
/// It will work even when the stack is empty.
pub fn current_span(&self) -> Span {
self.threads.active_thread_ref().current_span()
pub fn current_user_relevant_span(&self) -> Span {
self.threads.active_thread_ref().current_user_relevant_span()
}
/// Returns the span of the *caller* of the current operation, again

View file

@ -919,7 +919,7 @@ impl<'tcx> MiriMachine<'tcx> {
&ecx.machine.threads,
size,
kind,
ecx.machine.current_span(),
ecx.machine.current_user_relevant_span(),
),
data_race.weak_memory.then(weak_memory::AllocState::new_allocation),
),
@ -943,7 +943,7 @@ impl<'tcx> MiriMachine<'tcx> {
ecx.machine
.allocation_spans
.borrow_mut()
.insert(id, (ecx.machine.current_span(), None));
.insert(id, (ecx.machine.current_user_relevant_span(), None));
}
interp_ok(AllocExtra { borrow_tracker, data_race, backtrace, sync: FxHashMap::default() })
@ -1566,7 +1566,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
}
if let Some((_, deallocated_at)) = machine.allocation_spans.borrow_mut().get_mut(&alloc_id)
{
*deallocated_at = Some(machine.current_span());
*deallocated_at = Some(machine.current_user_relevant_span());
}
machine.free_alloc_id(alloc_id, size, align, kind);
interp_ok(())

View file

@ -12,7 +12,7 @@ LL | intrinsics::atomic_cxchgweak::<T, { AO::Relaxed }, { AO::Re
= note: inside closure at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::option::Option::<std::thread::ThreadId>::unwrap_or_else::<{closure@std::thread::current::id::get_or_init::{closure#0}}>` at RUSTLIB/core/src/option.rs:LL:CC
= note: inside `std::thread::current::id::get_or_init` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::thread::current::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::thread::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::rt::init` at RUSTLIB/std/src/rt.rs:LL:CC
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
= note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC

View file

@ -12,7 +12,7 @@ LL | intrinsics::atomic_cxchgweak::<T, { AO::Relaxed }, { AO::Re
= note: inside closure at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::option::Option::<std::thread::ThreadId>::unwrap_or_else::<{closure@std::thread::current::id::get_or_init::{closure#0}}>` at RUSTLIB/core/src/option.rs:LL:CC
= note: inside `std::thread::current::id::get_or_init` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::thread::current::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::thread::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::rt::init` at RUSTLIB/std/src/rt.rs:LL:CC
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
= note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC

View file

@ -12,7 +12,7 @@ LL | intrinsics::atomic_cxchgweak::<T, { AO::Relaxed }, { AO::Re
= note: inside closure at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::option::Option::<std::thread::ThreadId>::unwrap_or_else::<{closure@std::thread::current::id::get_or_init::{closure#0}}>` at RUSTLIB/core/src/option.rs:LL:CC
= note: inside `std::thread::current::id::get_or_init` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::thread::current::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::thread::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::rt::init` at RUSTLIB/std/src/rt.rs:LL:CC
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
= note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC

View file

@ -12,7 +12,7 @@ LL | intrinsics::atomic_cxchgweak::<T, { AO::Relaxed }, { AO::Re
= note: inside closure at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::option::Option::<std::thread::ThreadId>::unwrap_or_else::<{closure@std::thread::current::id::get_or_init::{closure#0}}>` at RUSTLIB/core/src/option.rs:LL:CC
= note: inside `std::thread::current::id::get_or_init` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::thread::current::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::thread::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::rt::init` at RUSTLIB/std/src/rt.rs:LL:CC
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
= note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC

View file

@ -12,7 +12,7 @@ LL | intrinsics::atomic_cxchgweak::<T, { AO::Relaxed }, { AO::Re
= note: inside closure at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::option::Option::<std::thread::ThreadId>::unwrap_or_else::<{closure@std::thread::current::id::get_or_init::{closure#0}}>` at RUSTLIB/core/src/option.rs:LL:CC
= note: inside `std::thread::current::id::get_or_init` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::thread::current::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::thread::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
= note: inside `std::rt::init` at RUSTLIB/std/src/rt.rs:LL:CC
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
= note: inside `std::panicking::catch_unwind::do_call::<{closure@std::rt::lang_start_internal::{closure#0}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC