Skip to content

Commit da75aaf

Browse files
authored
Rollup merge of #123744 - compiler-errors:redundant-due-to-glob, r=petrochenkov
Silence `unused_imports` for redundant imports Quick fix for #121708 (comment) r? `@petrochenkov` cc `@joshtriplett` I think this is right, would like confirmation. I also think it's weird that we're using `=` to assign to `is_redundant` but using `per_ns` for the actual spans. Seems like this could be weirdly order dependent, but that's unrelated to this change.
2 parents ec91d71 + 0db2a40 commit da75aaf

26 files changed

+43
-275
lines changed

compiler/rustc_resolve/src/imports.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,13 +1391,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13911391
let mut redundant_spans: Vec<_> = redundant_span.present_items().collect();
13921392
redundant_spans.sort();
13931393
redundant_spans.dedup();
1394+
/* FIXME(unused_imports): Add this back as a new lint
13941395
self.lint_buffer.buffer_lint_with_diagnostic(
13951396
UNUSED_IMPORTS,
13961397
id,
13971398
import.span,
13981399
format!("the item `{source}` is imported redundantly"),
13991400
BuiltinLintDiag::RedundantImport(redundant_spans, source),
14001401
);
1402+
*/
14011403
return true;
14021404
}
14031405

compiler/rustc_resolve/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ enum ImplTraitContext {
177177

178178
/// Used for tracking import use types which will be used for redundant import checking.
179179
/// ### Used::Scope Example
180-
/// ```rust,compile_fail
180+
/// ```rust,ignore (redundant_imports)
181181
/// #![deny(unused_imports)]
182182
/// use std::mem::drop;
183183
/// fn main() {
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1+
//@ check-pass
12
// Check that we detect imports that are redundant due to the extern prelude
23
// and that we emit a reasonable diagnostic.
34
// issue: rust-lang/rust#121915
4-
//~^^^ NOTE the item `aux_issue_121915` is already defined by the extern prelude
55

66
// See also the discussion in <https://github.com/rust-lang/rust/pull/122954>.
77

88
//@ compile-flags: --extern aux_issue_121915 --edition 2018
99
//@ aux-build: aux-issue-121915.rs
1010

1111
#[deny(unused_imports)]
12-
//~^ NOTE the lint level is defined here
1312
fn main() {
1413
use aux_issue_121915;
15-
//~^ ERROR the item `aux_issue_121915` is imported redundantly
14+
//FIXME(unused_imports): ~^ ERROR the item `aux_issue_121915` is imported redundantly
1615
aux_issue_121915::item();
1716
}

tests/ui/imports/redundant-import-extern-prelude.stderr

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ check-pass
12
//@ compile-flags: --extern aux_issue_121915 --edition 2015
23
//@ aux-build: aux-issue-121915.rs
34

@@ -6,6 +7,6 @@ extern crate aux_issue_121915;
67
#[deny(unused_imports)]
78
fn main() {
89
use aux_issue_121915;
9-
//~^ ERROR the item `aux_issue_121915` is imported redundantly
10+
//FIXME(unused_imports): ~^ ERROR the item `aux_issue_121915` is imported redundantly
1011
aux_issue_121915::item();
1112
}

tests/ui/imports/redundant-import-issue-121915-2015.stderr

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
//@ check-pass
12
// Check that we detect imports (of built-in attributes) that are redundant due to
23
// the language prelude and that we emit a reasonable diagnostic.
3-
//~^^ NOTE the item `allow` is already defined by the extern prelude
44

55
// Note that we use the term "extern prelude" in the label even though "language prelude"
66
// would be more correct. However, it's not worth special-casing this.
@@ -10,9 +10,8 @@
1010
//@ edition: 2018
1111

1212
#![deny(unused_imports)]
13-
//~^ NOTE the lint level is defined here
1413

15-
use allow; //~ ERROR the item `allow` is imported redundantly
14+
use allow; //FIXME(unused_imports): ~ ERROR the item `allow` is imported redundantly
1615

1716
#[allow(unused)]
1817
fn main() {}

tests/ui/imports/redundant-import-lang-prelude-attr.stderr

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/ui/imports/redundant-import-lang-prelude.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1+
//@ check-pass
12
// Check that we detect imports that are redundant due to the language prelude
23
// and that we emit a reasonable diagnostic.
3-
//~^^ NOTE the item `u8` is already defined by the extern prelude
44

55
// Note that we use the term "extern prelude" in the label even though "language prelude"
66
// would be more correct. However, it's not worth special-casing this.
77

88
// See also the discussion in <https://github.com/rust-lang/rust/pull/122954>.
99

1010
#![deny(unused_imports)]
11-
//~^ NOTE the lint level is defined here
1211

1312
use std::primitive::u8;
14-
//~^ ERROR the item `u8` is imported redundantly
13+
//FIXME(unused_imports): ~^ ERROR the item `u8` is imported redundantly
1514

1615
const _: u8 = 0;
1716

tests/ui/imports/redundant-import-lang-prelude.stderr

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)