diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-02-27 18:33:03 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-03-01 00:11:56 +1100 |
| commit | 859277dfdb481c35824acdcea30fb72628fb1073 (patch) | |
| tree | e47d1d54549d38cb08c7da3b8c2d7da02ef05993 /src/libsyntax | |
| parent | 31e9c947a3303b4b785f9a7f130b00c625456326 (diff) | |
| download | rust-859277dfdb481c35824acdcea30fb72628fb1073.tar.gz rust-859277dfdb481c35824acdcea30fb72628fb1073.zip | |
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
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/visit.rs | 13 |
1 files changed, 8 insertions, 5 deletions
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<E: Clone, V: Visitor<E>>(visitor: &mut V, } } -fn walk_trait_ref<E: Clone, V: Visitor<E>>(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<E: Clone, V: Visitor<E>>(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<E: Clone, V: Visitor<E>>(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<E: Clone, V: Visitor<E>>(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 => {} } |
