Skip to content

Commit

Permalink
resolve: Reject some inaccessible candidates sooner during import res…
Browse files Browse the repository at this point in the history
…olution

This allows import resolution to progress in cases like #53140
  • Loading branch information
petrochenkov authored and pietroalbini committed Aug 25, 2018
1 parent d0026ee commit 7832643
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ impl<'a> Resolver<'a> {
};
match self.resolve_ident_in_module(module, ident, ns, false, path_span) {
Err(Determined) => continue,
Ok(binding)
if !self.is_accessible_from(binding.vis, single_import.parent) => continue,
Ok(_) | Err(Undetermined) => return Err(Undetermined),
}
}
Expand Down Expand Up @@ -255,8 +257,11 @@ impl<'a> Resolver<'a> {
module, ident, ns, false, false, path_span,
);
self.current_module = orig_current_module;

match result {
Err(Determined) => continue,
Ok(binding)
if !self.is_accessible_from(binding.vis, glob_import.parent) => continue,
Ok(_) | Err(Undetermined) => return Err(Undetermined),
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/test/ui/imports/issue-53140.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-pass

mod m {
pub struct S(u8);

use S as Z;
}

use m::*;

fn main() {}

0 comments on commit 7832643

Please sign in to comment.