X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftools%2Fmiri%2Fsrc%2Fdiagnostics.rs;h=035c0e6423381fb3f1a3c63ccb2b79add3a6152b;hb=d26c88c75231ab90b522fb061383f8e0156f1f20;hp=d9f40b55cd6efff2cbd2b7cd206210e1bdd5ec9e;hpb=d1184ae58d8791f424cab2101b1c67f176423e75;p=rust.git diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs index d9f40b55cd6..035c0e64233 100644 --- a/src/tools/miri/src/diagnostics.rs +++ b/src/tools/miri/src/diagnostics.rs @@ -69,8 +69,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { DataRace { ptr, op1, op2 } => write!( f, - "Data race detected between {} on {} and {} on {} at {:?}", - op1.action, op1.thread_info, op2.action, op2.thread_info, ptr, + "Data race detected between (1) {} on {} and (2) {} on {} at {ptr:?}. (2) just happened here", + op1.action, op1.thread_info, op2.action, op2.thread_info ), } } @@ -222,10 +222,9 @@ pub fn report_error<'tcx, 'mir>( vec![(Some(*span), format!("the `{link_name}` symbol is defined here"))], Int2PtrWithStrictProvenance => vec![(None, format!("use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead"))], - DataRace { ptr: _, op1, op2 } => + DataRace { op1, .. } => vec![ - (Some(op1.span), format!("The {} on {} is here", op1.action, op1.thread_info)), - (Some(op2.span), format!("The {} on {} is here", op2.action, op2.thread_info)), + (Some(op1.span), format!("and (1) occurred earlier here")), (None, format!("this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior")), (None, format!("see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information")), ], @@ -363,9 +362,11 @@ fn report_msg<'tcx>( } // Show note and help messages. + let mut extra_span = false; for (span_data, note) in ¬es { if let Some(span_data) = span_data { err.span_note(span_data.span(), note); + extra_span = true; } else { err.note(note); } @@ -373,13 +374,14 @@ fn report_msg<'tcx>( for (span_data, help) in &helps { if let Some(span_data) = span_data { err.span_help(span_data.span(), help); + extra_span = true; } else { err.help(help); } } if notes.len() + helps.len() > 0 { // Add visual separator before backtrace. - err.note("BACKTRACE:"); + err.note(if extra_span { "BACKTRACE (of the first span):" } else { "BACKTRACE:" }); } // Add backtrace for (idx, frame_info) in stacktrace.iter().enumerate() {