Skip to content

Commit 9a5bbd7

Browse files
committed
rustc: Fix shadowing private import with reexport
The reexport didn't switch the privacy, so the reexport was actually considered private, erroneously failing to resolve imports later on. Closes rust-lang#14082
1 parent 6a2b3d1 commit 9a5bbd7

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/librustc/middle/resolve.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2050,7 +2050,8 @@ impl<'a> Resolver<'a> {
20502050
while module.resolved_import_count.get() < import_count {
20512051
let import_index = module.resolved_import_count.get();
20522052
let import_directive = imports.get(import_index);
2053-
match self.resolve_import_for_module(module.clone(), import_directive) {
2053+
match self.resolve_import_for_module(module.clone(),
2054+
import_directive) {
20542055
Failed => {
20552056
// We presumably emitted an error. Continue.
20562057
let msg = format!("failed to resolve import `{}`",
@@ -2402,6 +2403,7 @@ impl<'a> Resolver<'a> {
24022403
import_resolution.value_target = Some(Target::new(target_module.clone(),
24032404
name_bindings.clone()));
24042405
import_resolution.value_id = directive.id;
2406+
import_resolution.is_public = directive.is_public;
24052407
value_used_public = name_bindings.defined_in_public_namespace(ValueNS);
24062408
}
24072409
UnboundResult => { /* Continue. */ }
@@ -2416,6 +2418,7 @@ impl<'a> Resolver<'a> {
24162418
import_resolution.type_target =
24172419
Some(Target::new(target_module.clone(), name_bindings.clone()));
24182420
import_resolution.type_id = directive.id;
2421+
import_resolution.is_public = directive.is_public;
24192422
type_used_public = name_bindings.defined_in_public_namespace(TypeNS);
24202423
}
24212424
UnboundResult => { /* Continue. */ }

src/test/run-pass/issue-14082.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014 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(globs)]
12+
#![allow(unused_imports, dead_code)]
13+
14+
use foo::GC;
15+
16+
mod foo {
17+
use d::*;
18+
pub use m::GC; // this should shadow d::GC
19+
}
20+
21+
mod m {
22+
pub struct GC;
23+
}
24+
25+
mod d {
26+
pub struct GC;
27+
}
28+
29+
fn main() {}

0 commit comments

Comments
 (0)