Auto merge of #119751 - nnethercote:error-api-fixes, r=oli-obk

Diagnostic API fixes

Some improvements to diagnostic APIs: improve some naming, use shortcuts in more places, and add a couple of missing methods.

r? `@compiler-errors`
This commit is contained in:
bors 2024-01-10 18:03:53 +00:00
commit a2d9d73e60
135 changed files with 766 additions and 756 deletions

View file

@ -109,7 +109,7 @@ impl Msrv {
if let Some(duplicate) = msrv_attrs.last() {
sess.dcx()
.struct_span_err(duplicate.span, "`clippy::msrv` is defined multiple times")
.span_note_mv(msrv_attr.span, "first definition found here")
.with_span_note(msrv_attr.span, "first definition found here")
.emit();
}

View file

@ -136,7 +136,7 @@ pub fn get_unique_attr<'a>(
if let Some(duplicate) = unique_attr {
sess.dcx()
.struct_span_err(attr.span, format!("`{name}` is defined multiple times"))
.span_note_mv(duplicate.span, "first definition found here")
.with_span_note(duplicate.span, "first definition found here")
.emit();
} else {
unique_attr = Some(attr);

View file

@ -499,14 +499,12 @@ pub fn report_msg<'tcx>(
err.note(if extra_span { "BACKTRACE (of the first span):" } else { "BACKTRACE:" });
}
let (mut err, handler) = err.into_diagnostic().unwrap();
// Add backtrace
for (idx, frame_info) in stacktrace.iter().enumerate() {
let is_local = machine.is_local(frame_info);
// No span for non-local frames and the first frame (which is the error site).
if is_local && idx > 0 {
err.eager_subdiagnostic(handler, frame_info.as_note(machine.tcx));
err.eager_subdiagnostic(err.dcx, frame_info.as_note(machine.tcx));
} else {
let sm = sess.source_map();
let span = sm.span_to_embeddable_string(frame_info.span);
@ -514,7 +512,7 @@ pub fn report_msg<'tcx>(
}
}
handler.emit_diagnostic(err);
err.emit();
}
impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {