Skip to content

Commit 24bc544

Browse files
committed
Auto merge of #53509 - petrochenkov:wildregr, r=alexcrichton
resolve: Reject some inaccessible candidates sooner during import resolution This allows import resolution to progress in cases like #53140 Fixes #53140
2 parents 786ccc3 + 7b47fd7 commit 24bc544

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/librustc_resolve/resolve_imports.rs

+5
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
296296
};
297297
match self.resolve_ident_in_module(module, ident, ns, false, path_span) {
298298
Err(Determined) => continue,
299+
Ok(binding)
300+
if !self.is_accessible_from(binding.vis, single_import.parent) => continue,
299301
Ok(_) | Err(Undetermined) => return Err(Undetermined),
300302
}
301303
}
@@ -365,8 +367,11 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> {
365367
path_span,
366368
);
367369
self.current_module = orig_current_module;
370+
368371
match result {
369372
Err(Determined) => continue,
373+
Ok(binding)
374+
if !self.is_accessible_from(binding.vis, glob_import.parent) => continue,
370375
Ok(_) | Err(Undetermined) => return Err(Undetermined),
371376
}
372377
}

src/test/ui/imports/issue-53140.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
13+
mod m {
14+
pub struct S(u8);
15+
16+
use S as Z;
17+
}
18+
19+
use m::*;
20+
21+
fn main() {}

0 commit comments

Comments
 (0)