Skip to content

Commit 0173266

Browse files
authored
Merge pull request #4613 from RalfJung/rustup
Rustup
2 parents 0aefe34 + b6d7b17 commit 0173266

File tree

13 files changed

+35
-31
lines changed

13 files changed

+35
-31
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
29b7717de23f3969ceeb5bef5b01d9223f807655
1+
42b384ec0dfcd528d99a4db0a337d9188a9eecaa

src/borrow_tracker/stacked_borrows/diagnostics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl AllocHistory {
221221
pub fn new(id: AllocId, item: Item, machine: &MiriMachine<'_>) -> Self {
222222
Self {
223223
id,
224-
root: (item, machine.current_span()),
224+
root: (item, machine.current_user_relevant_span()),
225225
creations: SmallVec::new(),
226226
invalidations: SmallVec::new(),
227227
protectors: SmallVec::new(),
@@ -269,11 +269,11 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
269269
};
270270
self.history
271271
.creations
272-
.push(Creation { retag: op.clone(), span: self.machine.current_span() });
272+
.push(Creation { retag: op.clone(), span: self.machine.current_user_relevant_span() });
273273
}
274274

275275
pub fn log_invalidation(&mut self, tag: BorTag) {
276-
let mut span = self.machine.current_span();
276+
let mut span = self.machine.current_user_relevant_span();
277277
let (range, cause) = match &self.operation {
278278
Operation::Retag(RetagOp { info, range, permission, .. }) => {
279279
if info.cause == RetagCause::FnEntry {
@@ -298,7 +298,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
298298
};
299299
self.history
300300
.protectors
301-
.push(Protection { tag: op.new_tag, span: self.machine.current_span() });
301+
.push(Protection { tag: op.new_tag, span: self.machine.current_user_relevant_span() });
302302
}
303303

304304
pub fn get_logs_relevant_to(

src/borrow_tracker/tree_borrows/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'tcx> Tree {
3333
machine: &MiriMachine<'tcx>,
3434
) -> Self {
3535
let tag = state.root_ptr_tag(id, machine); // Fresh tag for the root
36-
let span = machine.current_span();
36+
let span = machine.current_user_relevant_span();
3737
Tree::new(tag, size, span)
3838
}
3939

@@ -61,7 +61,7 @@ impl<'tcx> Tree {
6161
ProvenanceExtra::Wildcard => return interp_ok(()),
6262
};
6363
let global = machine.borrow_tracker.as_ref().unwrap();
64-
let span = machine.current_span();
64+
let span = machine.current_user_relevant_span();
6565
self.perform_access(
6666
tag,
6767
Some((range, access_kind, diagnostics::AccessCause::Explicit(access_kind))),
@@ -86,7 +86,7 @@ impl<'tcx> Tree {
8686
ProvenanceExtra::Wildcard => return interp_ok(()),
8787
};
8888
let global = machine.borrow_tracker.as_ref().unwrap();
89-
let span = machine.current_span();
89+
let span = machine.current_user_relevant_span();
9090
self.dealloc(tag, alloc_range(Size::ZERO, size), global, alloc_id, span)
9191
}
9292

@@ -107,7 +107,7 @@ impl<'tcx> Tree {
107107
tag: BorTag,
108108
alloc_id: AllocId, // diagnostics
109109
) -> InterpResult<'tcx> {
110-
let span = machine.current_span();
110+
let span = machine.current_user_relevant_span();
111111
// `None` makes it the magic on-protector-end operation
112112
self.perform_access(tag, None, global, alloc_id, span)
113113
}
@@ -360,7 +360,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
360360
Some((range_in_alloc, AccessKind::Read, diagnostics::AccessCause::Reborrow)),
361361
this.machine.borrow_tracker.as_ref().unwrap(),
362362
alloc_id,
363-
this.machine.current_span(),
363+
this.machine.current_user_relevant_span(),
364364
)?;
365365

366366
// Also inform the data race model (but only if any bytes are actually affected).
@@ -386,7 +386,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
386386
inside_perms,
387387
new_perm.outside_perm,
388388
protected,
389-
this.machine.current_span(),
389+
this.machine.current_user_relevant_span(),
390390
)?;
391391
drop(tree_borrows);
392392

src/concurrency/data_race.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ impl VClockAlloc {
12081208
ty: Option<Ty<'_>>,
12091209
machine: &MiriMachine<'_>,
12101210
) -> InterpResult<'tcx> {
1211-
let current_span = machine.current_span();
1211+
let current_span = machine.current_user_relevant_span();
12121212
let global = machine.data_race.as_vclocks_ref().unwrap();
12131213
if !global.race_detecting() {
12141214
return interp_ok(());
@@ -1250,7 +1250,7 @@ impl VClockAlloc {
12501250
ty: Option<Ty<'_>>,
12511251
machine: &mut MiriMachine<'_>,
12521252
) -> InterpResult<'tcx> {
1253-
let current_span = machine.current_span();
1253+
let current_span = machine.current_user_relevant_span();
12541254
let global = machine.data_race.as_vclocks_mut().unwrap();
12551255
if !global.race_detecting() {
12561256
return interp_ok(());
@@ -1304,7 +1304,7 @@ impl Default for LocalClocks {
13041304

13051305
impl FrameState {
13061306
pub fn local_write(&self, local: mir::Local, storage_live: bool, machine: &MiriMachine<'_>) {
1307-
let current_span = machine.current_span();
1307+
let current_span = machine.current_user_relevant_span();
13081308
let global = machine.data_race.as_vclocks_ref().unwrap();
13091309
if !global.race_detecting() {
13101310
return;
@@ -1334,7 +1334,7 @@ impl FrameState {
13341334
}
13351335

13361336
pub fn local_read(&self, local: mir::Local, machine: &MiriMachine<'_>) {
1337-
let current_span = machine.current_span();
1337+
let current_span = machine.current_user_relevant_span();
13381338
let global = machine.data_race.as_vclocks_ref().unwrap();
13391339
if !global.race_detecting() {
13401340
return;
@@ -1573,7 +1573,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
15731573
size.bytes()
15741574
);
15751575

1576-
let current_span = this.machine.current_span();
1576+
let current_span = this.machine.current_user_relevant_span();
15771577
// Perform the atomic operation.
15781578
data_race.maybe_perform_sync_operation(
15791579
&this.machine.threads,
@@ -1827,7 +1827,7 @@ impl GlobalState {
18271827
machine: &MiriMachine<'tcx>,
18281828
atomic: AtomicFenceOrd,
18291829
) -> InterpResult<'tcx> {
1830-
let current_span = machine.current_span();
1830+
let current_span = machine.current_user_relevant_span();
18311831
self.maybe_perform_sync_operation(&machine.threads, current_span, |index, mut clocks| {
18321832
trace!("Atomic fence on {:?} with ordering {:?}", index, atomic);
18331833

@@ -1915,7 +1915,7 @@ impl GlobalState {
19151915
callback: impl FnOnce(&VClock) -> R,
19161916
) -> R {
19171917
let thread = threads.active_thread();
1918-
let span = threads.active_thread_ref().current_span();
1918+
let span = threads.active_thread_ref().current_user_relevant_span();
19191919
let (index, mut clocks) = self.thread_state_mut(thread);
19201920
let r = callback(&clocks.clock);
19211921
// Increment the clock, so that all following events cannot be confused with anything that

src/concurrency/genmc/helper.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ pub(super) fn emit_warning<'tcx>(
3737
cache: &WarningCache,
3838
diagnostic: impl FnOnce() -> NonHaltingDiagnostic,
3939
) {
40-
let span = ecx.machine.current_span();
40+
// FIXME: This is not the right span to use (it's always inside the local crates so if the same
41+
// operation is invoked from multiple places it will warn multiple times). `cur_span` is not
42+
// right either though (we should honor `#[track_caller]`). Ultimately what we want is "the
43+
// primary span the warning would point at".
44+
let span = ecx.machine.current_user_relevant_span();
4145
if cache.read().unwrap().contains(&span) {
4246
return;
4347
}

src/concurrency/thread.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<'tcx> Thread<'tcx> {
263263
self.top_user_relevant_frame.or_else(|| self.stack.len().checked_sub(1))
264264
}
265265

266-
pub fn current_span(&self) -> Span {
266+
pub fn current_user_relevant_span(&self) -> Span {
267267
self.top_user_relevant_frame()
268268
.map(|frame_idx| self.stack[frame_idx].current_span())
269269
.unwrap_or(rustc_span::DUMMY_SP)
@@ -867,7 +867,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
867867
let mut state = tls::TlsDtorsState::default();
868868
Box::new(move |m| state.on_stack_empty(m))
869869
});
870-
let current_span = this.machine.current_span();
870+
let current_span = this.machine.current_user_relevant_span();
871871
match &mut this.machine.data_race {
872872
GlobalDataRaceHandler::None => {}
873873
GlobalDataRaceHandler::Vclocks(data_race) =>

src/helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,8 +1128,8 @@ impl<'tcx> MiriMachine<'tcx> {
11281128
/// `#[track_caller]`.
11291129
/// This function is backed by a cache, and can be assumed to be very fast.
11301130
/// It will work even when the stack is empty.
1131-
pub fn current_span(&self) -> Span {
1132-
self.threads.active_thread_ref().current_span()
1131+
pub fn current_user_relevant_span(&self) -> Span {
1132+
self.threads.active_thread_ref().current_user_relevant_span()
11331133
}
11341134

11351135
/// Returns the span of the *caller* of the current operation, again

src/machine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ impl<'tcx> MiriMachine<'tcx> {
919919
&ecx.machine.threads,
920920
size,
921921
kind,
922-
ecx.machine.current_span(),
922+
ecx.machine.current_user_relevant_span(),
923923
),
924924
data_race.weak_memory.then(weak_memory::AllocState::new_allocation),
925925
),
@@ -943,7 +943,7 @@ impl<'tcx> MiriMachine<'tcx> {
943943
ecx.machine
944944
.allocation_spans
945945
.borrow_mut()
946-
.insert(id, (ecx.machine.current_span(), None));
946+
.insert(id, (ecx.machine.current_user_relevant_span(), None));
947947
}
948948

949949
interp_ok(AllocExtra { borrow_tracker, data_race, backtrace, sync: FxHashMap::default() })
@@ -1566,7 +1566,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
15661566
}
15671567
if let Some((_, deallocated_at)) = machine.allocation_spans.borrow_mut().get_mut(&alloc_id)
15681568
{
1569-
*deallocated_at = Some(machine.current_span());
1569+
*deallocated_at = Some(machine.current_user_relevant_span());
15701570
}
15711571
machine.free_alloc_id(alloc_id, size, align, kind);
15721572
interp_ok(())

tests/genmc/pass/std/arc.check_count.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LL | intrinsics::atomic_cxchgweak::<T, { AO::Relaxed }, { AO::Re
1212
= note: inside closure at RUSTLIB/std/src/thread/current.rs:LL:CC
1313
= 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
1414
= note: inside `std::thread::current::id::get_or_init` at RUSTLIB/std/src/thread/current.rs:LL:CC
15-
= note: inside `std::thread::current::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
15+
= note: inside `std::thread::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
1616
= note: inside `std::rt::init` at RUSTLIB/std/src/rt.rs:LL:CC
1717
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
1818
= 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

tests/genmc/pass/std/arc.try_upgrade.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LL | intrinsics::atomic_cxchgweak::<T, { AO::Relaxed }, { AO::Re
1212
= note: inside closure at RUSTLIB/std/src/thread/current.rs:LL:CC
1313
= 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
1414
= note: inside `std::thread::current::id::get_or_init` at RUSTLIB/std/src/thread/current.rs:LL:CC
15-
= note: inside `std::thread::current::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
15+
= note: inside `std::thread::current_id` at RUSTLIB/std/src/thread/current.rs:LL:CC
1616
= note: inside `std::rt::init` at RUSTLIB/std/src/rt.rs:LL:CC
1717
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
1818
= 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

0 commit comments

Comments
 (0)