diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-09-24 13:53:09 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-09-25 14:27:43 -0700 |
| commit | e7fa081c18880a78c968a402367289a550bd5cb1 (patch) | |
| tree | 00ecd334a847624b4807adddcf3ac74f93c7d68b | |
| parent | f648690234ddbf4a8f91b7997a13ce72a8b36958 (diff) | |
| download | rust-e7fa081c18880a78c968a402367289a550bd5cb1.tar.gz rust-e7fa081c18880a78c968a402367289a550bd5cb1.zip | |
rustdoc: Reduce ambiguity with clean::Type
The "Unresolved" variant could be completely removed becuase it turns out that the interim state only very briefly lives.
| -rw-r--r-- | src/librustdoc/clean.rs | 36 | ||||
| -rw-r--r-- | src/librustdoc/passes.rs | 2 |
2 files changed, 16 insertions, 22 deletions
diff --git a/src/librustdoc/clean.rs b/src/librustdoc/clean.rs index 291476c1390..ae7cbf76bcc 100644 --- a/src/librustdoc/clean.rs +++ b/src/librustdoc/clean.rs @@ -471,8 +471,7 @@ impl Clean<Item> for doctree::Trait { impl Clean<Type> for ast::trait_ref { fn clean(&self) -> Type { - let t = Unresolved(self.path.clean(), None, self.ref_id); - resolve_type(&t) + resolve_type(self.path.clean(), None, self.ref_id) } } @@ -517,9 +516,6 @@ impl Clean<TraitMethod> for ast::trait_method { /// it does not preserve mutability or boxes. #[deriving(Clone, Encodable, Decodable)] pub enum Type { - /// Most types start out as "Unresolved". It serves as an intermediate stage between cleaning - /// and type resolution. - Unresolved(Path, Option<~[TyParamBound]>, ast::NodeId), /// structs/enums/traits (anything that'd be an ast::ty_path) ResolvedPath { path: Path, typarams: Option<~[TyParamBound]>, id: ast::NodeId }, /// Reference to an item in an external crate (fully qualified path) @@ -558,25 +554,25 @@ impl Clean<Type> for ast::Ty { debug!("cleaning type `%?`", self); let codemap = local_data::get(super::ctxtkey, |x| *x.unwrap()).sess.codemap; debug!("span corresponds to `%s`", codemap.span_to_str(self.span)); - let t = match self.node { + match self.node { ty_nil => Unit, - ty_ptr(ref m) => RawPointer(m.mutbl.clean(), ~resolve_type(&m.ty.clean())), + ty_ptr(ref m) => RawPointer(m.mutbl.clean(), ~m.ty.clean()), ty_rptr(ref l, ref m) => BorrowedRef {lifetime: l.clean(), mutability: m.mutbl.clean(), - type_: ~resolve_type(&m.ty.clean())}, - ty_box(ref m) => Managed(m.mutbl.clean(), ~resolve_type(&m.ty.clean())), - ty_uniq(ref m) => Unique(~resolve_type(&m.ty.clean())), - ty_vec(ref m) => Vector(~resolve_type(&m.ty.clean())), - ty_fixed_length_vec(ref m, ref e) => FixedVector(~resolve_type(&m.ty.clean()), + type_: ~m.ty.clean()}, + ty_box(ref m) => Managed(m.mutbl.clean(), ~m.ty.clean()), + ty_uniq(ref m) => Unique(~m.ty.clean()), + ty_vec(ref m) => Vector(~m.ty.clean()), + ty_fixed_length_vec(ref m, ref e) => FixedVector(~m.ty.clean(), e.span.to_src()), - ty_tup(ref tys) => Tuple(tys.iter().map(|x| resolve_type(&x.clean())).collect()), - ty_path(ref p, ref tpbs, id) => Unresolved(p.clean(), tpbs.clean(), id), + ty_tup(ref tys) => Tuple(tys.iter().map(|x| x.clean()).collect()), + ty_path(ref p, ref tpbs, id) => + resolve_type(p.clean(), tpbs.clean(), id), ty_closure(ref c) => Closure(~c.clean()), ty_bare_fn(ref barefn) => BareFunction(~barefn.clean()), ty_bot => Bottom, ref x => fail!("Unimplemented type %?", x), - }; - resolve_type(&t) + } } } @@ -1039,14 +1035,10 @@ fn remove_comment_tags(s: &str) -> ~str { } /// Given a Type, resolve it using the def_map -fn resolve_type(t: &Type) -> Type { +fn resolve_type(path: Path, tpbs: Option<~[TyParamBound]>, + id: ast::NodeId) -> Type { use syntax::ast::*; - let (path, tpbs, id) = match t { - &Unresolved(ref path, ref tbps, id) => (path, tbps, id), - _ => return (*t).clone(), - }; - let dm = local_data::get(super::ctxtkey, |x| *x.unwrap()).tycx.def_map; debug!("searching for %? in defmap", id); let d = match dm.find(&id) { diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index 8376fa52882..4c83954f43c 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -11,6 +11,8 @@ use std::num; use std::uint; +use syntax::ast; + use clean; use clean::Item; use plugins; |
