Skip to content

Commit efc0bea

Browse files
committed
item_like_imports: Treat private imports like private items.
1 parent 5ba22c0 commit efc0bea

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/librustc_resolve/resolve_imports.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ impl<'a> Resolver<'a> {
167167
_ => return Failed(None), // This happens when there is a cycle of imports
168168
};
169169

170+
let new_import_semantics = self.new_import_semantics;
170171
let is_disallowed_private_import = |binding: &NameBinding| {
171-
!allow_private_imports && binding.vis != ty::Visibility::Public && binding.is_import()
172+
!new_import_semantics && !allow_private_imports && // disallowed
173+
binding.vis != ty::Visibility::Public && binding.is_import() // non-`pub` import
172174
};
173175

174176
if let Some(span) = record_used {

src/test/run-pass/imports.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2016 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+
#![feature(item_like_imports)]
12+
#![allow(unused)]
13+
14+
// Like other items, private imports can be imported and used non-lexically in paths.
15+
mod a {
16+
use a as foo;
17+
use self::foo::foo as bar;
18+
19+
mod b {
20+
use super::bar;
21+
}
22+
}
23+
24+
fn main() {}

0 commit comments

Comments
 (0)