Skip to content

Commit aab3762

Browse files
authored
Unrolled build for #157713
Rollup merge of #157713 - petrochenkov:regr197unused, r=oli-obk resolve: Remove exported imports from `maybe_unused_trait_imports` If an import is visible from outside of the crate, then it's effectively used and shouldn't be reported by any kinds of unused import lints. Fixes #157420.
2 parents b30f3df + b4a1fc7 commit aab3762

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

compiler/rustc_resolve/src/check_unused.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl<'a, 'ra, 'tcx> UnusedImportCheckVisitor<'a, 'ra, 'tcx> {
105105
let def_id = self.r.owner_def_id(id);
106106
if self.r.effective_visibilities.is_exported(def_id) {
107107
self.check_import_as_underscore(use_tree, id);
108+
self.r.maybe_unused_trait_imports.swap_remove(&def_id);
108109
return;
109110
}
110111

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ check-pass
2+
//@ edition: 2018..
3+
4+
#![crate_type = "lib"] // needed to enable doc link collection
5+
#![warn(unused_imports)]
6+
7+
pub use inner::*;
8+
use crate::outer::*;
9+
10+
mod outer {
11+
pub mod inner {
12+
pub trait Trait {} // must be a trait
13+
}
14+
15+
pub use inner::*;
16+
}
17+
18+
/// [A::assoc] // needed to force collection of traits in scope, without filter on assoc item name
19+
pub struct A;

0 commit comments

Comments
 (0)