Fix leaking immediate children and types via glob imports
This commit is contained in:
parent
94a07b6e4a
commit
f2837fa3f5
2 changed files with 18 additions and 6 deletions
|
@ -622,6 +622,19 @@ pub impl NameBindings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn defined_in_public_namespace(namespace: Namespace) -> bool {
|
||||||
|
match namespace {
|
||||||
|
TypeNS => match self.type_def {
|
||||||
|
Some(def) => def.privacy != Private,
|
||||||
|
None => false
|
||||||
|
},
|
||||||
|
ValueNS => match self.value_def {
|
||||||
|
Some(def) => def.privacy != Private,
|
||||||
|
None => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn def_for_namespace(namespace: Namespace) -> Option<def> {
|
fn def_for_namespace(namespace: Namespace) -> Option<def> {
|
||||||
match namespace {
|
match namespace {
|
||||||
TypeNS => {
|
TypeNS => {
|
||||||
|
@ -2538,7 +2551,6 @@ pub impl Resolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
debug!("(resolving glob import) writing resolution `%s` in `%s` \
|
debug!("(resolving glob import) writing resolution `%s` in `%s` \
|
||||||
to `%s`, privacy=%?",
|
to `%s`, privacy=%?",
|
||||||
*self.session.str_of(ident),
|
*self.session.str_of(ident),
|
||||||
|
@ -2547,12 +2559,12 @@ pub impl Resolver {
|
||||||
dest_import_resolution.privacy);
|
dest_import_resolution.privacy);
|
||||||
|
|
||||||
// Merge the child item into the import resolution.
|
// Merge the child item into the import resolution.
|
||||||
if (*name_bindings).defined_in_namespace(ValueNS) {
|
if (*name_bindings).defined_in_public_namespace(ValueNS) {
|
||||||
debug!("(resolving glob import) ... for value target");
|
debug!("(resolving glob import) ... for value target");
|
||||||
dest_import_resolution.value_target =
|
dest_import_resolution.value_target =
|
||||||
Some(Target(containing_module, name_bindings));
|
Some(Target(containing_module, name_bindings));
|
||||||
}
|
}
|
||||||
if (*name_bindings).defined_in_namespace(TypeNS) {
|
if (*name_bindings).defined_in_public_namespace(TypeNS) {
|
||||||
debug!("(resolving glob import) ... for type target");
|
debug!("(resolving glob import) ... for type target");
|
||||||
dest_import_resolution.type_target =
|
dest_import_resolution.type_target =
|
||||||
Some(Target(containing_module, name_bindings));
|
Some(Target(containing_module, name_bindings));
|
||||||
|
|
|
@ -23,8 +23,8 @@ mod a {
|
||||||
}
|
}
|
||||||
pub mod sub {
|
pub mod sub {
|
||||||
use a::b::*;
|
use a::b::*;
|
||||||
fn sub() -> bar { foo(); 1 } //~ ERROR: unresolved name: foo
|
fn sub() -> bar { foo(); 1 } //~ ERROR: unresolved name: `foo`
|
||||||
//~^ ERROR: unresolved name: bar
|
//~^ ERROR: use of undeclared type name `bar`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,6 @@ mod m1 {
|
||||||
use m1::*;
|
use m1::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
foo(); //~ ERROR: unresolved name: foo
|
foo(); //~ ERROR: unresolved name: `foo`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue