@@ -1336,7 +1336,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13361336 let mut is_redundant = true ;
13371337
13381338 let mut redundant_span = PerNS { value_ns : None , type_ns : None , macro_ns : None } ;
1339-
13401339 self . per_ns ( |this, ns| {
13411340 if is_redundant && let Ok ( binding) = source_bindings[ ns] . get ( ) {
13421341 if binding. res ( ) == Res :: Err {
@@ -1368,12 +1367,24 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13681367 let mut redundant_spans: Vec < _ > = redundant_span. present_items ( ) . collect ( ) ;
13691368 redundant_spans. sort ( ) ;
13701369 redundant_spans. dedup ( ) ;
1370+ let is_preload = self . extern_prelude_get ( target, false ) . is_some ( ) ;
1371+ let ( msg, diag) = if is_preload {
1372+ (
1373+ "already exists in the extern prelude" ,
1374+ BuiltinLintDiagnostics :: RedundantImportRemove ( import. use_span ) ,
1375+ )
1376+ } else {
1377+ (
1378+ "imported redundantly" ,
1379+ BuiltinLintDiagnostics :: RedundantImport ( redundant_spans, source) ,
1380+ )
1381+ } ;
13711382 self . lint_buffer . buffer_lint_with_diagnostic (
13721383 UNUSED_IMPORTS ,
13731384 id,
13741385 import. span ,
1375- format ! ( "the item `{source}` is imported redundantly " ) ,
1376- BuiltinLintDiagnostics :: RedundantImport ( redundant_spans , source ) ,
1386+ format ! ( "the item `{source}` is {msg} " ) ,
1387+ diag ,
13771388 ) ;
13781389 }
13791390 }
0 commit comments