diff options
| author | Ralf Jung <post@ralfj.de> | 2022-09-20 08:37:36 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-09-20 08:41:44 +0200 |
| commit | 7687b7e510d68ca4dfb9e6fa93d748c0450fa779 (patch) | |
| tree | ea6e8aef7a628d09959f5d54cb9b15cbb60976ff | |
| parent | 5ca1f85a2d2c81866250373b912b1a5938517d24 (diff) | |
| download | rust-7687b7e510d68ca4dfb9e6fa93d748c0450fa779.tar.gz rust-7687b7e510d68ca4dfb9e6fa93d748c0450fa779.zip | |
rustup, fmt
| -rw-r--r-- | rust-version | 2 | ||||
| -rw-r--r-- | src/concurrency/sync.rs | 5 | ||||
| -rw-r--r-- | src/concurrency/thread.rs | 5 | ||||
| -rw-r--r-- | src/diagnostics.rs | 73 | ||||
| -rw-r--r-- | src/eval.rs | 3 | ||||
| -rw-r--r-- | src/lib.rs | 8 | ||||
| -rw-r--r-- | src/stacked_borrows/diagnostics.rs | 4 | ||||
| -rw-r--r-- | src/stacked_borrows/mod.rs | 3 |
8 files changed, 62 insertions, 41 deletions
diff --git a/rust-version b/rust-version index af94ff9ea6b..78b9a110aa7 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -2019147c5642c08cdb9ad4cacd97dd1fa4ffa701 +acb8934fd57b3c2740c4abac0a5728c2c9b1423b diff --git a/src/concurrency/sync.rs b/src/concurrency/sync.rs index 5aab98c304a..d301ced8511 100644 --- a/src/concurrency/sync.rs +++ b/src/concurrency/sync.rs @@ -322,10 +322,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { /// otherwise returns the value from the closure fn rwlock_get_or_create<F>(&mut self, existing: F) -> InterpResult<'tcx, RwLockId> where - F: FnOnce( - &mut MiriInterpCx<'mir, 'tcx>, - RwLockId, - ) -> InterpResult<'tcx, Option<RwLockId>>, + F: FnOnce(&mut MiriInterpCx<'mir, 'tcx>, RwLockId) -> InterpResult<'tcx, Option<RwLockId>>, { let this = self.eval_context_mut(); let next_index = this.machine.threads.sync.rwlocks.next_index(); diff --git a/src/concurrency/thread.rs b/src/concurrency/thread.rs index 75eec863f39..f1a3d19fb4c 100644 --- a/src/concurrency/thread.rs +++ b/src/concurrency/thread.rs @@ -32,8 +32,9 @@ pub enum SchedulingAction { /// Timeout callbacks can be created by synchronization primitives to tell the /// scheduler that they should be called once some period of time passes. -type TimeoutCallback<'mir, 'tcx> = - Box<dyn FnOnce(&mut InterpCx<'mir, 'tcx, MiriMachine<'mir, 'tcx>>) -> InterpResult<'tcx> + 'tcx>; +type TimeoutCallback<'mir, 'tcx> = Box< + dyn FnOnce(&mut InterpCx<'mir, 'tcx, MiriMachine<'mir, 'tcx>>) -> InterpResult<'tcx> + 'tcx, +>; /// A thread identifier. #[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)] diff --git a/src/diagnostics.rs b/src/diagnostics.rs index b762c7622e3..868c85c04a8 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -109,7 +109,8 @@ fn prune_stacktrace<'tcx>( if has_local_frame { // Remove all frames marked with `caller_location` -- that attribute indicates we // usually want to point at the caller, not them. - stacktrace.retain(|frame| !frame.instance.def.requires_caller_location(machine.tcx)); + stacktrace + .retain(|frame| !frame.instance.def.requires_caller_location(machine.tcx)); // This is part of the logic that `std` uses to select the relevant part of a // backtrace. But here, we only look for __rust_begin_short_backtrace, not @@ -371,12 +372,12 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { pub fn emit_diagnostic(&self, e: NonHaltingDiagnostic) { use NonHaltingDiagnostic::*; - let stacktrace = MiriInterpCx::generate_stacktrace_from_stack(self.threads.active_thread_stack()); + let stacktrace = + MiriInterpCx::generate_stacktrace_from_stack(self.threads.active_thread_stack()); let (stacktrace, _was_pruned) = prune_stacktrace(stacktrace, self); let (title, diag_level) = match e { - RejectedIsolatedOp(_) => - ("operation rejected by isolation", DiagLevel::Warning), + RejectedIsolatedOp(_) => ("operation rejected by isolation", DiagLevel::Warning), Int2Ptr { .. } => ("integer-to-pointer cast", DiagLevel::Warning), CreatedPointerTag(..) | PoppedPointerTag(..) @@ -384,43 +385,35 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { | CreatedAlloc(..) | FreedAlloc(..) | ProgressReport { .. } - | WeakMemoryOutdatedLoad => - ("tracking was triggered", DiagLevel::Note), + | WeakMemoryOutdatedLoad => ("tracking was triggered", DiagLevel::Note), }; let msg = match e { - CreatedPointerTag(tag, None) => - format!("created tag {tag:?}"), + CreatedPointerTag(tag, None) => format!("created tag {tag:?}"), CreatedPointerTag(tag, Some((alloc_id, range))) => format!("created tag {tag:?} at {alloc_id:?}{range:?}"), PoppedPointerTag(item, tag) => match tag { - None => - format!( - "popped tracked tag for item {item:?} due to deallocation", - ), + None => format!("popped tracked tag for item {item:?} due to deallocation",), Some((tag, access)) => { format!( "popped tracked tag for item {item:?} due to {access:?} access for {tag:?}", ) } }, - CreatedCallId(id) => - format!("function call with id {id}"), + CreatedCallId(id) => format!("function call with id {id}"), CreatedAlloc(AllocId(id), size, align, kind) => format!( "created {kind} allocation of {size} bytes (alignment {align} bytes) with id {id}", size = size.bytes(), align = align.bytes(), ), - FreedAlloc(AllocId(id)) => - format!("freed allocation with id {id}"), + FreedAlloc(AllocId(id)) => format!("freed allocation with id {id}"), RejectedIsolatedOp(ref op) => format!("{op} was made to return an error due to isolation"), ProgressReport { .. } => format!("progress report: current operation being executed is here"), - Int2Ptr { .. } => - format!("integer-to-pointer cast"), + Int2Ptr { .. } => format!("integer-to-pointer cast"), WeakMemoryOutdatedLoad => format!("weak memory emulation: outdated value returned from load"), }; @@ -429,9 +422,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { ProgressReport { block_count } => { // It is important that each progress report is slightly different, since // identical diagnostics are being deduplicated. - vec![ - (None, format!("so far, {block_count} basic blocks have been executed")), - ] + vec![(None, format!("so far, {block_count} basic blocks have been executed"))] } _ => vec![], }; @@ -439,12 +430,40 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { let helps = match e { Int2Ptr { details: true } => vec![ - (None, format!("This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`,")), - (None, format!("which means that Miri might miss pointer bugs in this program.")), - (None, format!("See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation.")), - (None, format!("To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead.")), - (None, format!("You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics.")), - (None, format!("Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning.")), + ( + None, + format!( + "This program is using integer-to-pointer casts or (equivalently) `ptr::from_exposed_addr`," + ), + ), + ( + None, + format!("which means that Miri might miss pointer bugs in this program."), + ), + ( + None, + format!( + "See https://doc.rust-lang.org/nightly/std/ptr/fn.from_exposed_addr.html for more details on that operation." + ), + ), + ( + None, + format!( + "To ensure that Miri does not miss bugs in your program, use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead." + ), + ), + ( + None, + format!( + "You can then pass the `-Zmiri-strict-provenance` flag to Miri, to ensure you are not relying on `from_exposed_addr` semantics." + ), + ), + ( + None, + format!( + "Alternatively, the `-Zmiri-permissive-provenance` flag disables this warning." + ), + ), ], _ => vec![], }; diff --git a/src/eval.rs b/src/eval.rs index 57d80a2ad82..22bbe4f816c 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -180,7 +180,8 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( entry_id: DefId, entry_type: EntryFnType, config: &MiriConfig, -) -> InterpResult<'tcx, (InterpCx<'mir, 'tcx, MiriMachine<'mir, 'tcx>>, MPlaceTy<'tcx, Provenance>)> { +) -> InterpResult<'tcx, (InterpCx<'mir, 'tcx, MiriMachine<'mir, 'tcx>>, MPlaceTy<'tcx, Provenance>)> +{ let param_env = ty::ParamEnv::reveal_all(); let layout_cx = LayoutCx { tcx, param_env }; let mut ecx = InterpCx::new( diff --git a/src/lib.rs b/src/lib.rs index 7fbe71d573e..6006d6c89db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,8 +94,8 @@ pub use crate::concurrency::{ }, }; pub use crate::diagnostics::{ - report_error, EvalContextExt as DiagnosticsEvalContextExt, - NonHaltingDiagnostic, TerminationInfo, + report_error, EvalContextExt as DiagnosticsEvalContextExt, NonHaltingDiagnostic, + TerminationInfo, }; pub use crate::eval::{ create_ecx, eval_entry, AlignmentCheck, BacktraceStyle, IsolatedOp, MiriConfig, RejectOpWith, @@ -103,8 +103,8 @@ pub use crate::eval::{ pub use crate::helpers::{CurrentSpan, EvalContextExt as HelpersEvalContextExt}; pub use crate::intptrcast::ProvenanceMode; pub use crate::machine::{ - AllocExtra, MiriMachine, FrameData, MiriInterpCx, MiriInterpCxExt, MiriMemoryKind, - Provenance, ProvenanceExtra, NUM_CPUS, PAGE_SIZE, STACK_ADDR, STACK_SIZE, + AllocExtra, FrameData, MiriInterpCx, MiriInterpCxExt, MiriMachine, MiriMemoryKind, Provenance, + ProvenanceExtra, NUM_CPUS, PAGE_SIZE, STACK_ADDR, STACK_SIZE, }; pub use crate::mono_hash_map::MonoHashMap; pub use crate::operator::EvalContextExt as OperatorEvalContextExt; diff --git a/src/stacked_borrows/diagnostics.rs b/src/stacked_borrows/diagnostics.rs index 7148c489090..0d76ed4e308 100644 --- a/src/stacked_borrows/diagnostics.rs +++ b/src/stacked_borrows/diagnostics.rs @@ -471,7 +471,9 @@ impl<'span, 'history, 'ecx, 'mir, 'tcx> DiagnosticCx<'span, 'history, 'ecx, 'mir Some((orig_tag, kind)) } }; - self.current_span.machine().emit_diagnostic(NonHaltingDiagnostic::PoppedPointerTag(*item, summary)); + self.current_span + .machine() + .emit_diagnostic(NonHaltingDiagnostic::PoppedPointerTag(*item, summary)); } } diff --git a/src/stacked_borrows/mod.rs b/src/stacked_borrows/mod.rs index 9b9fd5655aa..f7f4b1357f1 100644 --- a/src/stacked_borrows/mod.rs +++ b/src/stacked_borrows/mod.rs @@ -572,7 +572,8 @@ impl Stacks { // not through a pointer). That is, whenever we directly write to a local, this will pop // everything else off the stack, invalidating all previous pointers, // and in particular, *all* raw pointers. - MemoryKind::Stack => (extra.base_ptr_tag(id, current_span.machine()), Permission::Unique), + MemoryKind::Stack => + (extra.base_ptr_tag(id, current_span.machine()), Permission::Unique), // Everything else is shared by default. _ => (extra.base_ptr_tag(id, current_span.machine()), Permission::SharedReadWrite), }; |
