Don't treat associated types specially in def_privacy

Improve trait privacy error message
This commit is contained in:
Jeffrey Seyfried 2016-02-26 20:31:00 +00:00
parent 32f251cc1c
commit d908ff1759
2 changed files with 7 additions and 13 deletions

View File

@ -615,16 +615,10 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
// decision solely based on the privacy of the method
// invocation.
Some(ast_map::NodeImplItem(ii)) => {
match ii.node {
hir::ImplItemKind::Const(..) |
hir::ImplItemKind::Method(..) => {
let imp = self.tcx.map.get_parent_did(node_id);
match self.tcx.impl_trait_ref(imp) {
Some(..) => hir::Public,
_ => ii.vis
}
}
hir::ImplItemKind::Type(_) => hir::Public,
_ => ii.vis,
}
}
Some(ast_map::NodeTraitItem(_)) => hir::Public,
@ -804,8 +798,8 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
// Trait methods are always all public. The only controlling factor
// is whether the trait itself is accessible or not.
ty::TraitContainer(trait_def_id) => {
self.report_error(self.ensure_public(span, trait_def_id,
None, "source trait"));
let msg = format!("source trait `{}`", self.tcx.item_path_str(trait_def_id));
self.report_error(self.ensure_public(span, trait_def_id, None, &msg));
}
}
}

View File

@ -20,7 +20,7 @@ struct S;
impl m::Pub for S {}
fn g<T: m::Pub>(arg: T) {
arg.f(); //~ ERROR: source trait is private
arg.f(); //~ ERROR: source trait `m::Priv` is private
}
fn main() {