diff options
Diffstat (limited to 'compiler/rustc_resolve/src/diagnostics.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/diagnostics.rs | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 57f23200e79..0d744238eeb 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -6,7 +6,7 @@ use rustc_ast::{MetaItemKind, NestedMetaItem}; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{ - pluralize, report_ambiguity_error, struct_span_err, Applicability, DiagCtxt, Diagnostic, + pluralize, report_ambiguity_error, struct_span_code_err, Applicability, DiagCtxt, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan, SuggestionStyle, }; use rustc_feature::BUILTIN_ATTRIBUTES; @@ -153,7 +153,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { BuiltinLintDiagnostics::AmbiguousGlobImports { diag }, ); } else { - let mut err = struct_span_err!(self.dcx(), diag.span, E0659, "{}", &diag.msg); + let mut err = struct_span_code_err!(self.dcx(), diag.span, E0659, "{}", &diag.msg); report_ambiguity_error(&mut err, diag); err.emit(); } @@ -254,15 +254,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let msg = format!("the name `{name}` is defined multiple times"); let mut err = match (old_binding.is_extern_crate(), new_binding.is_extern_crate()) { - (true, true) => struct_span_err!(self.dcx(), span, E0259, "{}", msg), + (true, true) => struct_span_code_err!(self.dcx(), span, E0259, "{}", msg), (true, _) | (_, true) => match new_binding.is_import() && old_binding.is_import() { - true => struct_span_err!(self.dcx(), span, E0254, "{}", msg), - false => struct_span_err!(self.dcx(), span, E0260, "{}", msg), + true => struct_span_code_err!(self.dcx(), span, E0254, "{}", msg), + false => struct_span_code_err!(self.dcx(), span, E0260, "{}", msg), }, _ => match (old_binding.is_import_user_facing(), new_binding.is_import_user_facing()) { - (false, false) => struct_span_err!(self.dcx(), span, E0428, "{}", msg), - (true, true) => struct_span_err!(self.dcx(), span, E0252, "{}", msg), - _ => struct_span_err!(self.dcx(), span, E0255, "{}", msg), + (false, false) => struct_span_code_err!(self.dcx(), span, E0428, "{}", msg), + (true, true) => struct_span_code_err!(self.dcx(), span, E0252, "{}", msg), + _ => struct_span_code_err!(self.dcx(), span, E0255, "{}", msg), }, }; @@ -659,7 +659,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let origin_sp = origin.iter().copied().collect::<Vec<_>>(); let msp = MultiSpan::from_spans(target_sp.clone()); - let mut err = struct_span_err!( + let mut err = struct_span_code_err!( self.dcx(), msp, E0408, @@ -788,7 +788,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } ResolutionError::FailedToResolve { last_segment, label, suggestion, module } => { let mut err = - struct_span_err!(self.dcx(), span, E0433, "failed to resolve: {}", &label); + struct_span_code_err!(self.dcx(), span, E0433, "failed to resolve: {}", &label); err.span_label(span, label); if let Some((suggestions, msg, applicability)) = suggestion { @@ -950,9 +950,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { "item `{name}` is an associated {kind}, which doesn't match its trait `{trait_path}`", ), ) - .code_mv(code) - .span_label_mv(span, "does not match trait") - .span_label_mv(trait_item_span, "item in trait") + .with_code(code) + .with_span_label(span, "does not match trait") + .with_span_label(trait_item_span, "item in trait") } ResolutionError::TraitImplDuplicate { name, trait_item_span, old_span } => self .dcx() @@ -1702,8 +1702,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // Print the primary message. let descr = get_descr(binding); - let mut err = - struct_span_err!(self.dcx(), ident.span, E0603, "{} `{}` is private", descr, ident); + let mut err = struct_span_code_err!( + self.dcx(), + ident.span, + E0603, + "{} `{}` is private", + descr, + ident + ); err.span_label(ident.span, format!("private {descr}")); let mut not_publicly_reexported = false; |
