From 859277dfdb481c35824acdcea30fb72628fb1073 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 27 Feb 2014 18:33:03 +1100 Subject: rustc: implement a lint for publicly visible private types. These are types that are in exported type signatures, but are not exported themselves, e.g. struct Foo { ... } pub fn bar() -> Foo { ... } will warn about the Foo. Such types are not listed in documentation, and cannot be named outside the crate in which they are declared, which is very user-unfriendly. cc #10573 --- src/libsyntax/visit.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 248ba593c1f..39989977d69 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -193,9 +193,11 @@ fn walk_explicit_self>(visitor: &mut V, } } -fn walk_trait_ref>(visitor: &mut V, - trait_ref: &TraitRef, - env: E) { +/// Like with walk_method_helper this doesn't correspond to a method +/// in Visitor, and so it gets a _helper suffix. +pub fn walk_trait_ref_helper>(visitor: &mut V, + trait_ref: &TraitRef, + env: E) { visitor.visit_path(&trait_ref.path, trait_ref.ref_id, env) } @@ -239,7 +241,8 @@ pub fn walk_item>(visitor: &mut V, item: &Item, env: E) ref methods) => { visitor.visit_generics(type_parameters, env.clone()); match *trait_reference { - Some(ref trait_reference) => walk_trait_ref(visitor, trait_reference, env.clone()), + Some(ref trait_reference) => walk_trait_ref_helper(visitor, + trait_reference, env.clone()), None => () } visitor.visit_ty(typ, env.clone()); @@ -459,7 +462,7 @@ pub fn walk_ty_param_bounds>(visitor: &mut V, for bound in bounds.iter() { match *bound { TraitTyParamBound(ref typ) => { - walk_trait_ref(visitor, typ, env.clone()) + walk_trait_ref_helper(visitor, typ, env.clone()) } RegionTyParamBound => {} } -- cgit 1.4.1-3-g733a5