@@ -1336,7 +1336,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1336
1336
let mut is_redundant = true ;
1337
1337
1338
1338
let mut redundant_span = PerNS { value_ns : None , type_ns : None , macro_ns : None } ;
1339
-
1340
1339
self . per_ns ( |this, ns| {
1341
1340
if is_redundant && let Ok ( binding) = source_bindings[ ns] . get ( ) {
1342
1341
if binding. res ( ) == Res :: Err {
@@ -1368,12 +1367,24 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1368
1367
let mut redundant_spans: Vec < _ > = redundant_span. present_items ( ) . collect ( ) ;
1369
1368
redundant_spans. sort ( ) ;
1370
1369
redundant_spans. dedup ( ) ;
1370
+ let is_preload = self . extern_prelude_get ( target, false ) ;
1371
+ let ( msg, diag) = if is_preload. is_some ( ) {
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
+ } ;
1371
1382
self . lint_buffer . buffer_lint_with_diagnostic (
1372
1383
UNUSED_IMPORTS ,
1373
1384
id,
1374
1385
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 ,
1377
1388
) ;
1378
1389
}
1379
1390
}
0 commit comments