diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 85ca3b05d12..8e5f7c57690 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -888,7 +888,7 @@ fn visit_expr(&mut self, expr: &ast::Expr) { struct type?!"), } } - ast::ExprPath(..) => { + ast::ExprPath(_) | ast::ExprQPath(_) => { let guard = |&: did: ast::DefId| { let fields = ty::lookup_struct_fields(self.tcx, did); let any_priv = fields.iter().any(|f| { diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 466bd608736..8d62c5e1ca0 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -999,7 +999,7 @@ fn build_reduced_graph_for_external_crate_def(&mut self, root: &Rc, def_like: DefLike, name: Name, - visibility: Visibility) { + def_visibility: Visibility) { match def_like { DlDef(def) => { // Add the new child item, if necessary. @@ -1027,7 +1027,7 @@ fn build_reduced_graph_for_external_crate_def(&mut self, DUMMY_SP); self.handle_external_def(def, - visibility, + def_visibility, &*child_name_bindings, token::get_name(name).get(), name, @@ -1106,7 +1106,7 @@ fn build_reduced_graph_for_external_crate_def(&mut self, let def = DefFn(method_info.def_id, false); // NB: not IMPORTABLE - let modifiers = if visibility == ast::Public { + let modifiers = if method_info.vis == ast::Public { PUBLIC } else { DefModifiers::empty() diff --git a/src/test/auxiliary/issue-21202.rs b/src/test/auxiliary/issue-21202.rs new file mode 100644 index 00000000000..afdbf78aa82 --- /dev/null +++ b/src/test/auxiliary/issue-21202.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod A { + pub struct Foo; + impl Foo { + fn foo(&self) { } + } +} diff --git a/src/test/compile-fail/issue-21202.rs b/src/test/compile-fail/issue-21202.rs new file mode 100644 index 00000000000..5c1de6dfc55 --- /dev/null +++ b/src/test/compile-fail/issue-21202.rs @@ -0,0 +1,25 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-21202.rs + +extern crate "issue-21202" as crate1; + +use crate1::A; + +mod B { + use crate1::A::Foo; + fn bar(f: Foo) { + Foo::foo(&f); + //~^ ERROR: function `foo` is private + } +} + +fn main() { }