Skip to content

Commit

Permalink
Auto merge of #31716 - jseyfried:fix_privacy_for_def_err, r=nrc
Browse files Browse the repository at this point in the history
Fixes #31714
  • Loading branch information
bors committed Feb 19, 2016
2 parents 8842e28 + 08b9097 commit 917db28
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ impl<'a> NameBinding<'a> {

fn def_and_lp(&self) -> (Def, LastPrivate) {
let def = self.def().unwrap();
if let Def::Err = def { return (def, LastMod(AllPublic)) }
(def, LastMod(if self.is_public() { AllPublic } else { DependsOn(def.def_id()) }))
}

Expand Down
2 changes: 2 additions & 0 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
kind: NameBindingKind::Def(Def::Err),
span: None,
});
let dummy_binding =
self.resolver.new_name_binding(e.import_directive.import(dummy_binding));

let _ = e.source_module.try_define_child(target, ValueNS, dummy_binding);
let _ = e.source_module.try_define_child(target, TypeNS, dummy_binding);
Expand Down
7 changes: 6 additions & 1 deletion src/test/compile-fail/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@ use zed::baz;

mod zed {
pub fn bar() { println!("bar"); }
use foo; //~ ERROR unresolved import
}

fn main() {
zed::foo(); //~ ERROR unresolved name
bar();
}
fn main() { bar(); }

0 comments on commit 917db28

Please sign in to comment.