Use chaining for DiagnosticBuilder construction and emit.

To avoid the use of a mutable local variable, and because it reads more
nicely.
This commit is contained in:
Nicholas Nethercote 2024-01-03 17:03:10 +11:00
parent 589591efde
commit bd4e623485
22 changed files with 193 additions and 183 deletions

View file

@ -495,16 +495,16 @@ impl<'tcx> Visitor<'tcx> for EmitIgnoredResolutionErrors<'tcx> {
.intersperse("::")
.collect::<String>()
);
let mut err = rustc_errors::struct_span_err!(
rustc_errors::struct_span_err!(
self.tcx.dcx(),
path.span,
E0433,
"failed to resolve: {label}",
);
err.span_label(path.span, label);
err.note("this error was originally ignored because you are running `rustdoc`");
err.note("try running again with `rustc` or `cargo check` and you may get a more detailed error");
err.emit();
)
.span_label_mv(path.span, label)
.note_mv("this error was originally ignored because you are running `rustdoc`")
.note_mv("try running again with `rustc` or `cargo check` and you may get a more detailed error")
.emit();
}
// We could have an outer resolution that succeeded,
// but with generic parameters that failed.