diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 608bc7dffd9c..b90d5b40bec6 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -736,12 +736,18 @@ fn lint_ambiguously_glob_imported_traits( let trait_name = self.tcx.item_name(pick.item.container_id(self.tcx)); let import_span = self.tcx.hir_span_if_local(pick.import_ids[0].to_def_id()).unwrap(); - self.tcx.node_lint(AMBIGUOUS_GLOB_IMPORTED_TRAITS, segment.hir_id, |diag| { - diag.primary_message(format!("Use of ambiguously glob imported trait `{trait_name}`")) + self.tcx.emit_node_lint( + AMBIGUOUS_GLOB_IMPORTED_TRAITS, + segment.hir_id, + rustc_errors::DiagDecorator(|diag| { + diag.primary_message(format!( + "Use of ambiguously glob imported trait `{trait_name}`" + )) .span(segment.ident.span) .span_label(import_span, format!("`{trait_name}` imported ambiguously here")) .help(format!("Import `{trait_name}` explicitly")); - }); + }), + ); } fn upcast( diff --git a/tests/ui/imports/ambiguous-trait-in-scope.stderr b/tests/ui/imports/ambiguous-trait-in-scope.stderr index cac1f4bb73fb..9360e104bf24 100644 --- a/tests/ui/imports/ambiguous-trait-in-scope.stderr +++ b/tests/ui/imports/ambiguous-trait-in-scope.stderr @@ -7,9 +7,9 @@ LL | use m2::*; LL | 0u8.method1(); | ^^^^^^^ | + = help: Import `Trait` explicitly = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #147992 - = help: Import `Trait` explicitly = note: `#[warn(ambiguous_glob_imported_traits)]` (part of `#[warn(future_incompatible)]`) on by default error[E0599]: no method named `method2` found for type `u8` in the current scope @@ -49,9 +49,9 @@ LL | use m2::*; LL | 0u8.method2(); | ^^^^^^^ | + = help: Import `Trait` explicitly = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #147992 - = help: Import `Trait` explicitly warning: Use of ambiguously glob imported trait `Trait` --> $DIR/ambiguous-trait-in-scope.rs:49:9 @@ -62,9 +62,9 @@ LL | use m2_reexport::*; LL | 0u8.method1(); | ^^^^^^^ | + = help: Import `Trait` explicitly = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #147992 - = help: Import `Trait` explicitly error[E0599]: no method named `method2` found for type `u8` in the current scope --> $DIR/ambiguous-trait-in-scope.rs:51:9 @@ -88,9 +88,9 @@ LL | use ambig_reexport::*; LL | 0u8.method1(); | ^^^^^^^ | + = help: Import `Trait` explicitly = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #147992 - = help: Import `Trait` explicitly error[E0599]: no method named `method2` found for type `u8` in the current scope --> $DIR/ambiguous-trait-in-scope.rs:58:9 @@ -115,9 +115,9 @@ LL | use external::m2::*; LL | 0u8.method1(); | ^^^^^^^ | + = help: Import `Trait` explicitly = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #147992 - = help: Import `Trait` explicitly error[E0599]: no method named `method2` found for type `u8` in the current scope --> $DIR/ambiguous-trait-in-scope.rs:66:9 @@ -142,9 +142,9 @@ LL | use external::m2_reexport::*; LL | 0u8.method1(); | ^^^^^^^ | + = help: Import `Trait` explicitly = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #147992 - = help: Import `Trait` explicitly error[E0599]: no method named `method2` found for type `u8` in the current scope --> $DIR/ambiguous-trait-in-scope.rs:74:9 @@ -168,9 +168,9 @@ LL | use external::ambig_reexport::*; LL | 0u8.method1(); | ^^^^^^^ | + = help: Import `Trait` explicitly = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #147992 - = help: Import `Trait` explicitly error[E0599]: no method named `method2` found for type `u8` in the current scope --> $DIR/ambiguous-trait-in-scope.rs:81:9