about summary refs log tree commit diff
path: root/src/librustdoc/clean
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-08-27 21:46:52 -0400
committerNiko Matsakis <niko@alum.mit.edu>2014-08-27 21:46:52 -0400
commit1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f (patch)
tree552fabade603ab0d148a49ae3cf1abd3f399740a /src/librustdoc/clean
parent3ee047ae1ffab454270bc1859b3beef3556ef8f9 (diff)
downloadrust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.tar.gz
rust-1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f.zip
Implement generalized object and type parameter bounds (Fixes #16462)
Diffstat (limited to 'src/librustdoc/clean')
-rw-r--r--src/librustdoc/clean/inline.rs12
-rw-r--r--src/librustdoc/clean/mod.rs33
2 files changed, 22 insertions, 23 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 445672fcdc4..ee1b51683c2 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -159,18 +159,12 @@ pub fn build_external_trait(tcx: &ty::ctxt, did: ast::DefId) -> clean::Trait {
             clean::RequiredMethod(trait_item)
         }
     });
-    let supertraits = ty::trait_supertraits(tcx, did);
-    let mut parents = supertraits.iter().map(|i| {
-        match i.clean() {
-            clean::TraitBound(ty) => ty,
-            clean::RegionBound => unreachable!()
-        }
-    });
-
+    let trait_def = ty::lookup_trait_def(tcx, did);
+    let bounds = trait_def.bounds.clean();
     clean::Trait {
         generics: (&def.generics, subst::TypeSpace).clean(),
         items: items.collect(),
-        parents: parents.collect()
+        bounds: bounds,
     }
 }
 
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index dc2c0d1d083..af4df81f996 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -481,15 +481,14 @@ impl Clean<TyParam> for ty::TypeParameterDef {
 
 #[deriving(Clone, Encodable, Decodable, PartialEq)]
 pub enum TyParamBound {
-    RegionBound,
+    RegionBound, // FIXME(#16518) -- need to include name of actual region
     TraitBound(Type)
 }
 
 impl Clean<TyParamBound> for ast::TyParamBound {
     fn clean(&self) -> TyParamBound {
         match *self {
-            ast::StaticRegionTyParamBound => RegionBound,
-            ast::OtherRegionTyParamBound(_) => RegionBound,
+            ast::RegionTyParamBound(_) => RegionBound,
             ast::UnboxedFnTyParamBound(_) => {
                 // FIXME(pcwalton): Wrong.
                 RegionBound
@@ -499,6 +498,16 @@ impl Clean<TyParamBound> for ast::TyParamBound {
     }
 }
 
+impl Clean<Vec<TyParamBound>> for ty::ExistentialBounds {
+    fn clean(&self) -> Vec<TyParamBound> {
+        let mut vec = vec!(RegionBound);
+        for bb in self.builtin_bounds.iter() {
+            vec.push(bb.clean());
+        }
+        vec
+    }
+}
+
 fn external_path(name: &str, substs: &subst::Substs) -> Path {
     let lifetimes = substs.regions().get_slice(subst::TypeSpace)
                     .iter()
@@ -525,7 +534,6 @@ impl Clean<TyParamBound> for ty::BuiltinBound {
         };
         let empty = subst::Substs::empty();
         let (did, path) = match *self {
-            ty::BoundStatic => return RegionBound,
             ty::BoundSend =>
                 (tcx.lang_items.send_trait().unwrap(),
                  external_path("Send", &empty)),
@@ -810,10 +818,7 @@ impl Clean<ClosureDecl> for ast::ClosureTy {
             decl: self.decl.clean(),
             onceness: self.onceness,
             fn_style: self.fn_style,
-            bounds: match self.bounds {
-                Some(ref x) => x.clean(),
-                None        => Vec::new()
-            },
+            bounds: self.bounds.clean()
         }
     }
 }
@@ -909,7 +914,7 @@ impl Clean<RetStyle> for ast::RetStyle {
 pub struct Trait {
     pub items: Vec<TraitItem>,
     pub generics: Generics,
-    pub parents: Vec<Type>,
+    pub bounds: Vec<TyParamBound>,
 }
 
 impl Clean<Item> for doctree::Trait {
@@ -924,7 +929,7 @@ impl Clean<Item> for doctree::Trait {
             inner: TraitItem(Trait {
                 items: self.items.clean(),
                 generics: self.generics.clean(),
-                parents: self.parents.clean(),
+                bounds: self.bounds.clean(),
             }),
         }
     }
@@ -1060,7 +1065,7 @@ pub enum Type {
     Self(ast::DefId),
     /// Primitives are just the fixed-size numeric types (plus int/uint/float), and char.
     Primitive(Primitive),
-    Closure(Box<ClosureDecl>, Option<Lifetime>),
+    Closure(Box<ClosureDecl>),
     Proc(Box<ClosureDecl>),
     /// extern "ABI" fn
     BareFunction(Box<BareFunctionDecl>),
@@ -1208,7 +1213,7 @@ impl Clean<Type> for ast::Ty {
                              tpbs.clean().map(|x| x),
                              id)
             }
-            TyClosure(ref c, region) => Closure(box c.clean(), region.clean()),
+            TyClosure(ref c) => Closure(box c.clean()),
             TyProc(ref c) => Proc(box c.clean()),
             TyBareFn(ref barefn) => BareFunction(box barefn.clean()),
             TyParen(ref ty) => ty.clean(),
@@ -1273,11 +1278,11 @@ impl Clean<Type> for ty::t {
                     decl: (ast_util::local_def(0), &fty.sig).clean(),
                     onceness: fty.onceness,
                     fn_style: fty.fn_style,
-                    bounds: fty.bounds.iter().map(|i| i.clean()).collect(),
+                    bounds: fty.bounds.clean(),
                 };
                 match fty.store {
                     ty::UniqTraitStore => Proc(decl),
-                    ty::RegionTraitStore(ref r, _) => Closure(decl, r.clean()),
+                    ty::RegionTraitStore(..) => Closure(decl),
                 }
             }
             ty::ty_struct(did, ref substs) |