diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-09-11 17:07:49 +1200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-09-19 15:11:00 +1200 |
| commit | ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7 (patch) | |
| tree | 9ea529bfee7d62b85288d37b0e2bbcdd1c866e0d /src/librustdoc | |
| parent | af3889f6979647b9bd2dc5f5132d80e3e5b405a5 (diff) | |
| download | rust-ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7.tar.gz rust-ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7.zip | |
Add enum variants to the type namespace
Change to resolve and update compiler and libs for uses. [breaking-change] Enum variants are now in both the value and type namespaces. This means that if you have a variant with the same name as a type in scope in a module, you will get a name clash and thus an error. The solution is to either rename the type or the variant.
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 38 | ||||
| -rw-r--r-- | src/librustdoc/fold.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/html/format.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/html/render.rs | 10 | ||||
| -rw-r--r-- | src/librustdoc/stability_summary.rs | 4 |
5 files changed, 29 insertions, 29 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 9e05382fa55..b4d44aab239 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -99,7 +99,7 @@ pub struct Crate { pub name: String, pub module: Option<Item>, pub externs: Vec<(ast::CrateNum, ExternalCrate)>, - pub primitives: Vec<Primitive>, + pub primitives: Vec<PrimitiveType>, } impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> { @@ -147,7 +147,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> { ModuleItem(ref mut m) => m, _ => continue, }; - let prim = match Primitive::find(child.attrs.as_slice()) { + let prim = match PrimitiveType::find(child.attrs.as_slice()) { Some(prim) => prim, None => continue, }; @@ -187,7 +187,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> { pub struct ExternalCrate { pub name: String, pub attrs: Vec<Attribute>, - pub primitives: Vec<Primitive>, + pub primitives: Vec<PrimitiveType>, } impl Clean<ExternalCrate> for cstore::crate_metadata { @@ -202,7 +202,7 @@ impl Clean<ExternalCrate> for cstore::crate_metadata { _ => return }; let attrs = inline::load_attrs(cx, tcx, did); - Primitive::find(attrs.as_slice()).map(|prim| primitives.push(prim)); + PrimitiveType::find(attrs.as_slice()).map(|prim| primitives.push(prim)); }) }); ExternalCrate { @@ -316,7 +316,7 @@ pub enum ItemEnum { /// `static`s from an extern block ForeignStaticItem(Static), MacroItem(Macro), - PrimitiveItem(Primitive), + PrimitiveItem(PrimitiveType), AssociatedTypeItem, } @@ -901,7 +901,7 @@ impl Clean<RetStyle> for ast::RetStyle { #[deriving(Clone, Encodable, Decodable)] pub struct Trait { - pub items: Vec<TraitItem>, + pub items: Vec<TraitMethod>, pub generics: Generics, pub bounds: Vec<TyParamBound>, } @@ -931,13 +931,13 @@ impl Clean<Type> for ast::TraitRef { } #[deriving(Clone, Encodable, Decodable)] -pub enum TraitItem { +pub enum TraitMethod { RequiredMethod(Item), ProvidedMethod(Item), TypeTraitItem(Item), } -impl TraitItem { +impl TraitMethod { pub fn is_req(&self) -> bool { match self { &RequiredMethod(..) => true, @@ -959,8 +959,8 @@ impl TraitItem { } } -impl Clean<TraitItem> for ast::TraitItem { - fn clean(&self, cx: &DocContext) -> TraitItem { +impl Clean<TraitMethod> for ast::TraitItem { + fn clean(&self, cx: &DocContext) -> TraitMethod { match self { &ast::RequiredMethod(ref t) => RequiredMethod(t.clean(cx)), &ast::ProvidedMethod(ref t) => ProvidedMethod(t.clean(cx)), @@ -970,13 +970,13 @@ impl Clean<TraitItem> for ast::TraitItem { } #[deriving(Clone, Encodable, Decodable)] -pub enum ImplItem { +pub enum ImplMethod { MethodImplItem(Item), TypeImplItem(Item), } -impl Clean<ImplItem> for ast::ImplItem { - fn clean(&self, cx: &DocContext) -> ImplItem { +impl Clean<ImplMethod> for ast::ImplItem { + fn clean(&self, cx: &DocContext) -> ImplMethod { match self { &ast::MethodImplItem(ref t) => MethodImplItem(t.clean(cx)), &ast::TypeImplItem(ref t) => TypeImplItem(t.clean(cx)), @@ -1058,7 +1058,7 @@ pub enum Type { /// For references to self Self(ast::DefId), /// Primitives are just the fixed-size numeric types (plus int/uint/float), and char. - Primitive(Primitive), + Primitive(PrimitiveType), Closure(Box<ClosureDecl>), Proc(Box<ClosureDecl>), /// extern "ABI" fn @@ -1080,7 +1080,7 @@ pub enum Type { } #[deriving(Clone, Encodable, Decodable, PartialEq, Eq, Hash)] -pub enum Primitive { +pub enum PrimitiveType { Int, I8, I16, I32, I64, Uint, U8, U16, U32, U64, F32, F64, @@ -1104,8 +1104,8 @@ pub enum TypeKind { TypeTypedef, } -impl Primitive { - fn from_str(s: &str) -> Option<Primitive> { +impl PrimitiveType { + fn from_str(s: &str) -> Option<PrimitiveType> { match s.as_slice() { "int" => Some(Int), "i8" => Some(I8), @@ -1129,7 +1129,7 @@ impl Primitive { } } - fn find(attrs: &[Attribute]) -> Option<Primitive> { + fn find(attrs: &[Attribute]) -> Option<PrimitiveType> { for attr in attrs.iter() { let list = match *attr { List(ref k, ref l) if k.as_slice() == "doc" => l, @@ -1141,7 +1141,7 @@ impl Primitive { if k.as_slice() == "primitive" => v.as_slice(), _ => continue, }; - match Primitive::from_str(value) { + match PrimitiveType::from_str(value) { Some(p) => return Some(p), None => {} } diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index 54e9c29e11d..b771473473c 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -40,8 +40,8 @@ pub trait DocFolder { EnumItem(i) }, TraitItem(mut i) => { - fn vtrm<T: DocFolder>(this: &mut T, trm: TraitItem) - -> Option<TraitItem> { + fn vtrm<T: DocFolder>(this: &mut T, trm: TraitMethod) + -> Option<TraitMethod> { match trm { RequiredMethod(it) => { match this.fold_item(it) { diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index e526286ef46..c807c180e64 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -277,7 +277,7 @@ fn path(w: &mut fmt::Formatter, path: &clean::Path, print_all: bool, } fn primitive_link(f: &mut fmt::Formatter, - prim: clean::Primitive, + prim: clean::PrimitiveType, name: &str) -> fmt::Result { let m = cache_key.get().unwrap(); let mut needs_termination = false; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 2107854c52b..cf625d4ddfc 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -177,7 +177,7 @@ pub struct Cache { pub extern_locations: HashMap<ast::CrateNum, ExternalLocation>, /// Cache of where documentation for primitives can be found. - pub primitive_locations: HashMap<clean::Primitive, ast::CrateNum>, + pub primitive_locations: HashMap<clean::PrimitiveType, ast::CrateNum>, /// Set of definitions which have been inlined from external crates. pub inlined: HashSet<ast::DefId>, @@ -1637,7 +1637,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, _ => false, } }) - .collect::<Vec<&clean::TraitItem>>(); + .collect::<Vec<&clean::TraitMethod>>(); let provided = t.items.iter() .filter(|m| { match **m { @@ -1645,7 +1645,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, _ => false, } }) - .collect::<Vec<&clean::TraitItem>>(); + .collect::<Vec<&clean::TraitMethod>>(); if t.items.len() == 0 { try!(write!(w, "{{ }}")); @@ -1671,7 +1671,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, // Trait documentation try!(document(w, it)); - fn trait_item(w: &mut fmt::Formatter, m: &clean::TraitItem) + fn trait_item(w: &mut fmt::Formatter, m: &clean::TraitMethod) -> fmt::Result { try!(write!(w, "<h3 id='{}.{}' class='method'>{}<code>", shortty(m.item()), @@ -2180,7 +2180,7 @@ fn item_macro(w: &mut fmt::Formatter, it: &clean::Item, fn item_primitive(w: &mut fmt::Formatter, it: &clean::Item, - _p: &clean::Primitive) -> fmt::Result { + _p: &clean::PrimitiveType) -> fmt::Result { try!(document(w, it)); render_methods(w, it) } diff --git a/src/librustdoc/stability_summary.rs b/src/librustdoc/stability_summary.rs index 02dc4e9bdb6..f7d43037723 100644 --- a/src/librustdoc/stability_summary.rs +++ b/src/librustdoc/stability_summary.rs @@ -21,7 +21,7 @@ use syntax::attr::{Deprecated, Experimental, Unstable, Stable, Frozen, Locked}; use syntax::ast::Public; use clean::{Crate, Item, ModuleItem, Module, StructItem, Struct, EnumItem, Enum}; -use clean::{ImplItem, Impl, Trait, TraitItem, ProvidedMethod, RequiredMethod}; +use clean::{ImplItem, Impl, Trait, TraitItem, TraitMethod, ProvidedMethod, RequiredMethod}; use clean::{TypeTraitItem, ViewItemItem, PrimitiveItem}; #[deriving(Zero, Encodable, Decodable, PartialEq, Eq)] @@ -128,7 +128,7 @@ fn summarize_item(item: &Item) -> (Counts, Option<ModuleSummary>) { items: ref trait_items, .. }) => { - fn extract_item<'a>(trait_item: &'a TraitItem) -> &'a Item { + fn extract_item<'a>(trait_item: &'a TraitMethod) -> &'a Item { match *trait_item { ProvidedMethod(ref item) | RequiredMethod(ref item) | |
