summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2014-11-06 00:05:53 -0800
committerSteven Fackler <sfackler@gmail.com>2014-11-17 07:35:51 -0800
commit3dcd2157403163789aaf21a9ab3c4d30a7c6494d (patch)
tree30cc4a448fe8380ae7107c6ea9b534a725adaec8 /src/libsyntax
parent0047dbe59c41b951d34ce6324f3a8c0e15d523e9 (diff)
downloadrust-3dcd2157403163789aaf21a9ab3c4d30a7c6494d.tar.gz
rust-3dcd2157403163789aaf21a9ab3c4d30a7c6494d.zip
Switch to purely namespaced enums
This breaks code that referred to variant names in the same namespace as
their enum. Reexport the variants in the old location or alter code to
refer to the new locations:

```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
=>
```
pub use self::Foo::{A, B};

pub enum Foo {
    A,
    B
}

fn main() {
    let a = A;
}
```
or
```
pub enum Foo {
    A,
    B
}

fn main() {
    let a = Foo::A;
}
```

[breaking-change]
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/abi.rs5
-rw-r--r--src/libsyntax/ast.rs49
-rw-r--r--src/libsyntax/ast_map/blocks.rs2
-rw-r--r--src/libsyntax/ast_map/mod.rs4
-rw-r--r--src/libsyntax/attr.rs5
-rw-r--r--src/libsyntax/codemap.rs2
-rw-r--r--src/libsyntax/diagnostic.rs5
-rw-r--r--src/libsyntax/ext/asm.rs1
-rw-r--r--src/libsyntax/ext/base.rs2
-rw-r--r--src/libsyntax/ext/deriving/clone.rs13
-rw-r--r--src/libsyntax/ext/deriving/cmp/ord.rs2
-rw-r--r--src/libsyntax/ext/deriving/decodable.rs20
-rw-r--r--src/libsyntax/ext/deriving/generic/mod.rs47
-rw-r--r--src/libsyntax/ext/deriving/generic/ty.rs3
-rw-r--r--src/libsyntax/ext/deriving/primitive.rs3
-rw-r--r--src/libsyntax/ext/deriving/rand.rs17
-rw-r--r--src/libsyntax/ext/expand.rs1
-rw-r--r--src/libsyntax/ext/format.rs4
-rw-r--r--src/libsyntax/ext/mtwt.rs3
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs3
-rw-r--r--src/libsyntax/ext/tt/transcribe.rs1
-rw-r--r--src/libsyntax/feature_gate.rs1
-rw-r--r--src/libsyntax/parse/lexer/comments.rs2
-rw-r--r--src/libsyntax/parse/obsolete.rs2
-rw-r--r--src/libsyntax/parse/parser.rs3
-rw-r--r--src/libsyntax/parse/token.rs7
-rw-r--r--src/libsyntax/print/pp.rs4
-rw-r--r--src/libsyntax/print/pprust.rs2
-rw-r--r--src/libsyntax/test.rs16
-rw-r--r--src/libsyntax/util/small_vector.rs2
-rw-r--r--src/libsyntax/visit.rs2
31 files changed, 180 insertions, 53 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs
index 912755d0ea0..87693f39bbd 100644
--- a/src/libsyntax/abi.rs
+++ b/src/libsyntax/abi.rs
@@ -8,6 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+pub use self::Os::*;
+pub use self::Abi::*;
+pub use self::Architecture::*;
+pub use self::AbiArchitecture::*;
+
 use std::fmt;
 
 #[deriving(PartialEq)]
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 593d5811553..0cb80d4c153 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -10,6 +10,55 @@
 
 // The Rust abstract syntax tree.
 
+pub use self::AsmDialect::*;
+pub use self::AttrStyle::*;
+pub use self::BindingMode::*;
+pub use self::BinOp::*;
+pub use self::BlockCheckMode::*;
+pub use self::CaptureClause::*;
+pub use self::Decl_::*;
+pub use self::ExplicitSelf_::*;
+pub use self::Expr_::*;
+pub use self::FloatTy::*;
+pub use self::FnStyle::*;
+pub use self::FunctionRetTy::*;
+pub use self::ForeignItem_::*;
+pub use self::ImplItem::*;
+pub use self::InlinedItem::*;
+pub use self::IntTy::*;
+pub use self::Item_::*;
+pub use self::KleeneOp::*;
+pub use self::Lit_::*;
+pub use self::LitIntType::*;
+pub use self::LocalSource::*;
+pub use self::Mac_::*;
+pub use self::MatchSource::*;
+pub use self::MetaItem_::*;
+pub use self::Method_::*;
+pub use self::Mutability::*;
+pub use self::Onceness::*;
+pub use self::Pat_::*;
+pub use self::PathListItem_::*;
+pub use self::PatWildKind::*;
+pub use self::PrimTy::*;
+pub use self::Sign::*;
+pub use self::Stmt_::*;
+pub use self::StrStyle::*;
+pub use self::StructFieldKind::*;
+pub use self::TokenTree::*;
+pub use self::TraitItem::*;
+pub use self::Ty_::*;
+pub use self::TyParamBound::*;
+pub use self::UintTy::*;
+pub use self::UnboxedClosureKind::*;
+pub use self::UnOp::*;
+pub use self::UnsafeSource::*;
+pub use self::VariantKind::*;
+pub use self::ViewItem_::*;
+pub use self::ViewPath_::*;
+pub use self::Visibility::*;
+pub use self::PathParameters::*;
+
 use codemap::{Span, Spanned, DUMMY_SP, ExpnId};
 use abi::Abi;
 use ast_util;
diff --git a/src/libsyntax/ast_map/blocks.rs b/src/libsyntax/ast_map/blocks.rs
index 187d94d1fa7..a35ee3ab1d0 100644
--- a/src/libsyntax/ast_map/blocks.rs
+++ b/src/libsyntax/ast_map/blocks.rs
@@ -21,6 +21,8 @@
 //! nested within a uniquely determined `FnLike`), and users can ask
 //! for the `Code` associated with a particular NodeId.
 
+pub use self::Code::*;
+
 use abi;
 use ast::{Block, FnDecl, NodeId};
 use ast;
diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs
index d65be4c45e8..2a2ad9fd664 100644
--- a/src/libsyntax/ast_map/mod.rs
+++ b/src/libsyntax/ast_map/mod.rs
@@ -8,6 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+pub use self::Node::*;
+pub use self::PathElem::*;
+use self::MapEntry::*;
+
 use abi;
 use ast::*;
 use ast_util;
diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs
index 148d986399d..12a3bd89901 100644
--- a/src/libsyntax/attr.rs
+++ b/src/libsyntax/attr.rs
@@ -10,6 +10,11 @@
 
 // Functions dealing with attributes and meta items
 
+pub use self::InlineAttr::*;
+pub use self::StabilityLevel::*;
+pub use self::ReprAttr::*;
+pub use self::IntType::*;
+
 use ast;
 use ast::{AttrId, Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList};
 use codemap::{Span, Spanned, spanned, dummy_spanned};
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 7d303644020..7d849ddf1c1 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -23,6 +23,8 @@ source code snippets, etc.
 
 */
 
+pub use self::MacroFormat::*;
+
 use serialize::{Encodable, Decodable, Encoder, Decoder};
 use std::cell::RefCell;
 use std::rc::Rc;
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs
index e24aa0f0b95..ff600fcc7c2 100644
--- a/src/libsyntax/diagnostic.rs
+++ b/src/libsyntax/diagnostic.rs
@@ -8,6 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+pub use self::Level::*;
+pub use self::RenderSpan::*;
+pub use self::ColorConfig::*;
+use self::Destination::*;
+
 use codemap::{Pos, Span};
 use codemap;
 use diagnostics;
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs
index d57d6e52d7f..8027d9bfd8a 100644
--- a/src/libsyntax/ext/asm.rs
+++ b/src/libsyntax/ext/asm.rs
@@ -11,6 +11,7 @@
 /*
  * Inline assembly support.
  */
+use self::State::*;
 
 use ast;
 use codemap;
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 0c7a3cf4a6c..9292825ffe8 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+pub use self::SyntaxExtension::*;
+
 use ast;
 use ast::Name;
 use codemap;
diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs
index e653c8aebf4..fccc67bf220 100644
--- a/src/libsyntax/ext/deriving/clone.rs
+++ b/src/libsyntax/ext/deriving/clone.rs
@@ -52,7 +52,7 @@ fn cs_clone(
     name: &str,
     cx: &mut ExtCtxt, trait_span: Span,
     substr: &Substructure) -> P<Expr> {
-    let ctor_ident;
+    let ctor_path;
     let all_fields;
     let fn_path = vec![
         cx.ident_of("std"),
@@ -68,11 +68,11 @@ fn cs_clone(
 
     match *substr.fields {
         Struct(ref af) => {
-            ctor_ident = substr.type_ident;
+            ctor_path = cx.path(trait_span, vec![substr.type_ident]);
             all_fields = af;
         }
         EnumMatching(_, variant, ref af) => {
-            ctor_ident = variant.node.name;
+            ctor_path = cx.path(trait_span, vec![substr.type_ident, variant.node.name]);
             all_fields = af;
         },
         EnumNonMatchingCollapsed (..) => {
@@ -91,7 +91,8 @@ fn cs_clone(
     if all_fields.len() >= 1 && all_fields[0].name.is_none() {
         // enum-like
         let subcalls = all_fields.iter().map(subcall).collect();
-        cx.expr_call_ident(trait_span, ctor_ident, subcalls)
+        let path = cx.expr_path(ctor_path);
+        cx.expr_call(trait_span, path, subcalls)
     } else {
         // struct-like
         let fields = all_fields.iter().map(|field| {
@@ -109,9 +110,9 @@ fn cs_clone(
 
         if fields.is_empty() {
             // no fields, so construct like `None`
-            cx.expr_ident(trait_span, ctor_ident)
+            cx.expr_path(ctor_path)
         } else {
-            cx.expr_struct_ident(trait_span, ctor_ident, fields)
+            cx.expr_struct(trait_span, ctor_path, fields)
         }
     }
 }
diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs
index cd44dde7004..98345e1dd67 100644
--- a/src/libsyntax/ext/deriving/cmp/ord.rs
+++ b/src/libsyntax/ext/deriving/cmp/ord.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+pub use self::OrderingOp::*;
+
 use ast;
 use ast::{MetaItem, Item, Expr};
 use codemap::Span;
diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs
index 9e4dbf930db..d0a03658386 100644
--- a/src/libsyntax/ext/deriving/decodable.rs
+++ b/src/libsyntax/ext/deriving/decodable.rs
@@ -13,7 +13,8 @@ The compiler code necessary for `#[deriving(Decodable)]`. See
 encodable.rs for more.
 */
 
-use ast::{MetaItem, Item, Expr, MutMutable, Ident};
+use ast;
+use ast::{MetaItem, Item, Expr, MutMutable};
 use codemap::Span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
@@ -82,9 +83,10 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
             };
             let read_struct_field = cx.ident_of("read_struct_field");
 
+            let path = cx.path_ident(trait_span, substr.type_ident);
             let result = decode_static_fields(cx,
                                               trait_span,
-                                              substr.type_ident,
+                                              path,
                                               summary,
                                               |cx, span, name, field| {
                 cx.expr_try(span,
@@ -113,9 +115,10 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
             for (i, &(name, v_span, ref parts)) in fields.iter().enumerate() {
                 variants.push(cx.expr_str(v_span, token::get_ident(name)));
 
+                let path = cx.path(trait_span, vec![substr.type_ident, name]);
                 let decoded = decode_static_fields(cx,
                                                    v_span,
-                                                   name,
+                                                   path,
                                                    parts,
                                                    |cx, span, _, field| {
                     let idx = cx.expr_uint(span, field);
@@ -153,18 +156,19 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
 }
 
 /// Create a decoder for a single enum variant/struct:
-/// - `outer_pat_ident` is the name of this enum variant/struct
+/// - `outer_pat_path` is the path to this enum variant/struct
 /// - `getarg` should retrieve the `uint`-th field with name `@str`.
 fn decode_static_fields(cx: &mut ExtCtxt,
                         trait_span: Span,
-                        outer_pat_ident: Ident,
+                        outer_pat_path: ast::Path,
                         fields: &StaticFields,
                         getarg: |&mut ExtCtxt, Span, InternedString, uint| -> P<Expr>)
                         -> P<Expr> {
     match *fields {
         Unnamed(ref fields) => {
+            let path_expr = cx.expr_path(outer_pat_path);
             if fields.is_empty() {
-                cx.expr_ident(trait_span, outer_pat_ident)
+                path_expr
             } else {
                 let fields = fields.iter().enumerate().map(|(i, &span)| {
                     getarg(cx, span,
@@ -173,7 +177,7 @@ fn decode_static_fields(cx: &mut ExtCtxt,
                            i)
                 }).collect();
 
-                cx.expr_call_ident(trait_span, outer_pat_ident, fields)
+                cx.expr_call(trait_span, path_expr, fields)
             }
         }
         Named(ref fields) => {
@@ -182,7 +186,7 @@ fn decode_static_fields(cx: &mut ExtCtxt,
                 let arg = getarg(cx, span, token::get_ident(name), i);
                 cx.field_imm(span, name, arg)
             }).collect();
-            cx.expr_struct_ident(trait_span, outer_pat_ident, fields)
+            cx.expr_struct(trait_span, outer_pat_path, fields)
         }
     }
 }
diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs
index 4be299994fd..dccc12e406b 100644
--- a/src/libsyntax/ext/deriving/generic/mod.rs
+++ b/src/libsyntax/ext/deriving/generic/mod.rs
@@ -180,6 +180,10 @@
 //!                                    Named(~[(<ident of x>, <span of x>)]))])
 //! ```
 
+pub use self::StaticFields::*;
+pub use self::SubstructureFields::*;
+use self::StructType::*;
+
 use std::cell::RefCell;
 use std::vec;
 
@@ -192,7 +196,7 @@ use attr;
 use attr::AttrMetaMethods;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
-use codemap;
+use codemap::{mod, DUMMY_SP};
 use codemap::Span;
 use fold::MoveMap;
 use owned_slice::OwnedSlice;
@@ -543,12 +547,12 @@ impl<'a> TraitDef<'a> {
     }
 }
 
-fn variant_to_pat(cx: &mut ExtCtxt, sp: Span, variant: &ast::Variant)
+fn variant_to_pat(cx: &mut ExtCtxt, sp: Span, enum_ident: ast::Ident, variant: &ast::Variant)
                   -> P<ast::Pat> {
-    let ident = cx.path_ident(sp, variant.node.name);
+    let path = cx.path(sp, vec![enum_ident, variant.node.name]);
     cx.pat(sp, match variant.node.kind {
-        ast::TupleVariantKind(..) => ast::PatEnum(ident, None),
-        ast::StructVariantKind(..) => ast::PatStruct(ident, Vec::new(), true),
+        ast::TupleVariantKind(..) => ast::PatEnum(path, None),
+        ast::StructVariantKind(..) => ast::PatStruct(path, Vec::new(), true),
     })
 }
 
@@ -714,9 +718,10 @@ impl<'a> MethodDef<'a> {
                                  // [fields of next Self arg], [etc]]
         let mut patterns = Vec::new();
         for i in range(0u, self_args.len()) {
+            let struct_path= cx.path(DUMMY_SP, vec!( type_ident ));
             let (pat, ident_expr) =
                 trait_.create_struct_pattern(cx,
-                                             type_ident,
+                                             struct_path,
                                              struct_def,
                                              format!("__self_{}",
                                                      i).as_slice(),
@@ -900,7 +905,8 @@ impl<'a> MethodDef<'a> {
         let mut match_arms: Vec<ast::Arm> = variants.iter().enumerate()
             .map(|(index, variant)| {
                 let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| {
-                    let (p, idents) = trait_.create_enum_variant_pattern(cx, &**variant,
+                    let (p, idents) = trait_.create_enum_variant_pattern(cx, type_ident,
+                                                                         &**variant,
                                                                          self_arg_name,
                                                                          ast::MutImmutable);
                     (cx.pat(sp, ast::PatRegion(p)), idents)
@@ -996,7 +1002,7 @@ impl<'a> MethodDef<'a> {
         if variants.len() > 1 && self_args.len() > 1 {
             let arms: Vec<ast::Arm> = variants.iter().enumerate()
                 .map(|(index, variant)| {
-                    let pat = variant_to_pat(cx, sp, &**variant);
+                    let pat = variant_to_pat(cx, sp, type_ident, &**variant);
                     let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyU));
                     cx.arm(sp, vec![pat], cx.expr_lit(sp, lit))
                 }).collect();
@@ -1199,20 +1205,15 @@ impl<'a> TraitDef<'a> {
 
     fn create_struct_pattern(&self,
                              cx: &mut ExtCtxt,
-                             struct_ident: Ident,
+                             struct_path: ast::Path,
                              struct_def: &StructDef,
                              prefix: &str,
                              mutbl: ast::Mutability)
                              -> (P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>)>) {
         if struct_def.fields.is_empty() {
-            return (
-                cx.pat_ident_binding_mode(
-                    self.span, struct_ident, ast::BindByValue(ast::MutImmutable)),
-                Vec::new());
+            return (cx.pat_enum(self.span, struct_path, vec![]), vec![]);
         }
 
-        let matching_path = cx.path(self.span, vec!( struct_ident ));
-
         let mut paths = Vec::new();
         let mut ident_expr = Vec::new();
         let mut struct_type = Unknown;
@@ -1253,9 +1254,9 @@ impl<'a> TraitDef<'a> {
                     node: ast::FieldPat { ident: id.unwrap(), pat: pat, is_shorthand: false },
                 }
             }).collect();
-            cx.pat_struct(self.span, matching_path, field_pats)
+            cx.pat_struct(self.span, struct_path, field_pats)
         } else {
-            cx.pat_enum(self.span, matching_path, subpats)
+            cx.pat_enum(self.span, struct_path, subpats)
         };
 
         (pattern, ident_expr)
@@ -1263,21 +1264,19 @@ impl<'a> TraitDef<'a> {
 
     fn create_enum_variant_pattern(&self,
                                    cx: &mut ExtCtxt,
+                                   enum_ident: ast::Ident,
                                    variant: &ast::Variant,
                                    prefix: &str,
                                    mutbl: ast::Mutability)
         -> (P<ast::Pat>, Vec<(Span, Option<Ident>, P<Expr>)>) {
         let variant_ident = variant.node.name;
+        let variant_path = cx.path(variant.span, vec![enum_ident, variant_ident]);
         match variant.node.kind {
             ast::TupleVariantKind(ref variant_args) => {
                 if variant_args.is_empty() {
-                    return (cx.pat_ident_binding_mode(variant.span, variant_ident,
-                                                          ast::BindByValue(ast::MutImmutable)),
-                            Vec::new());
+                    return (cx.pat_enum(variant.span, variant_path, vec![]), vec![]);
                 }
 
-                let matching_path = cx.path_ident(variant.span, variant_ident);
-
                 let mut paths = Vec::new();
                 let mut ident_expr = Vec::new();
                 for (i, va) in variant_args.iter().enumerate() {
@@ -1292,11 +1291,11 @@ impl<'a> TraitDef<'a> {
 
                 let subpats = self.create_subpatterns(cx, paths, mutbl);
 
-                (cx.pat_enum(variant.span, matching_path, subpats),
+                (cx.pat_enum(variant.span, variant_path, subpats),
                  ident_expr)
             }
             ast::StructVariantKind(ref struct_def) => {
-                self.create_struct_pattern(cx, variant_ident, &**struct_def,
+                self.create_struct_pattern(cx, variant_path, &**struct_def,
                                            prefix, mutbl)
             }
         }
diff --git a/src/libsyntax/ext/deriving/generic/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs
index 8b46769d633..700ada8b4ad 100644
--- a/src/libsyntax/ext/deriving/generic/ty.rs
+++ b/src/libsyntax/ext/deriving/generic/ty.rs
@@ -13,6 +13,9 @@ A mini version of ast::Ty, which is easier to use, and features an
 explicit `Self` type to use when specifying impls to be derived.
 */
 
+pub use self::PtrTy::*;
+pub use self::Ty::*;
+
 use ast;
 use ast::{Expr,Generics,Ident};
 use ext::base::ExtCtxt;
diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs
index 044a2812c00..cd2d98b70f1 100644
--- a/src/libsyntax/ext/deriving/primitive.rs
+++ b/src/libsyntax/ext/deriving/primitive.rs
@@ -102,7 +102,8 @@ fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure
                         let span = variant.span;
 
                         // expr for `$n == $variant as $name`
-                        let variant = cx.expr_ident(span, variant.node.name);
+                        let path = cx.path(span, vec![substr.type_ident, variant.node.name]);
+                        let variant = cx.expr_path(path);
                         let ty = cx.ty_ident(span, cx.ident_of(name));
                         let cast = cx.expr_cast(span, variant.clone(), ty);
                         let guard = cx.expr_binary(span, ast::BiEq, n.clone(), cast);
diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs
index 584645bb306..8ad8436906b 100644
--- a/src/libsyntax/ext/deriving/rand.rs
+++ b/src/libsyntax/ext/deriving/rand.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use ast;
-use ast::{MetaItem, Item, Expr, Ident};
+use ast::{MetaItem, Item, Expr};
 use codemap::Span;
 use ext::base::ExtCtxt;
 use ext::build::{AstBuilder};
@@ -72,7 +72,8 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
 
     return match *substr.fields {
         StaticStruct(_, ref summary) => {
-            rand_thing(cx, trait_span, substr.type_ident, summary, rand_call)
+            let path = cx.path_ident(trait_span, substr.type_ident);
+            rand_thing(cx, trait_span, path, summary, rand_call)
         }
         StaticEnum(_, ref variants) => {
             if variants.is_empty() {
@@ -115,7 +116,8 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
                 let i_expr = cx.expr_uint(v_span, i);
                 let pat = cx.pat_lit(v_span, i_expr);
 
-                let thing = rand_thing(cx, v_span, ident, summary, |cx, sp| rand_call(cx, sp));
+                let path = cx.path(v_span, vec![substr.type_ident, ident]);
+                let thing = rand_thing(cx, v_span, path, summary, |cx, sp| rand_call(cx, sp));
                 cx.arm(v_span, vec!( pat ), thing)
             }).collect::<Vec<ast::Arm> >();
 
@@ -132,17 +134,18 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
 
     fn rand_thing(cx: &mut ExtCtxt,
                   trait_span: Span,
-                  ctor_ident: Ident,
+                  ctor_path: ast::Path,
                   summary: &StaticFields,
                   rand_call: |&mut ExtCtxt, Span| -> P<Expr>)
                   -> P<Expr> {
+        let path = cx.expr_path(ctor_path.clone());
         match *summary {
             Unnamed(ref fields) => {
                 if fields.is_empty() {
-                    cx.expr_ident(trait_span, ctor_ident)
+                    path
                 } else {
                     let exprs = fields.iter().map(|span| rand_call(cx, *span)).collect();
-                    cx.expr_call_ident(trait_span, ctor_ident, exprs)
+                    cx.expr_call(trait_span, path, exprs)
                 }
             }
             Named(ref fields) => {
@@ -150,7 +153,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
                     let e = rand_call(cx, span);
                     cx.field_imm(span, ident, e)
                 }).collect();
-                cx.expr_struct_ident(trait_span, ctor_ident, rand_fields)
+                cx.expr_struct(trait_span, ctor_path, rand_fields)
             }
         }
     }
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index fa69495fa42..081456bebe1 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -7,6 +7,7 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
+use self::Either::*;
 
 use ast::{Block, Crate, DeclLocal, ExprMac, PatMac};
 use ast::{Local, Ident, MacInvocTT};
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs
index d4248a2c77d..9a9724de8fb 100644
--- a/src/libsyntax/ext/format.rs
+++ b/src/libsyntax/ext/format.rs
@@ -8,6 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+pub use self::Invocation::*;
+use self::ArgumentType::*;
+use self::Position::*;
+
 use ast;
 use codemap::{Span, respan};
 use ext::base::*;
diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs
index 15fe7fc42b2..b50a4690e42 100644
--- a/src/libsyntax/ext/mtwt.rs
+++ b/src/libsyntax/ext/mtwt.rs
@@ -15,6 +15,8 @@
 //! and definition contexts*. J. Funct. Program. 22, 2 (March 2012), 181-216.
 //! DOI=10.1017/S0956796812000093 http://dx.doi.org/10.1017/S0956796812000093
 
+pub use self::SyntaxContext_::*;
+
 use ast::{Ident, Mrk, Name, SyntaxContext};
 
 use std::cell::RefCell;
@@ -278,6 +280,7 @@ fn xor_push(marks: &mut Vec<Mrk>, mark: Mrk) {
 
 #[cfg(test)]
 mod tests {
+    use self::TestSC::*;
     use ast::{EMPTY_CTXT, Ident, Mrk, Name, SyntaxContext};
     use super::{resolve, xor_push, apply_mark_internal, new_sctable_internal};
     use super::{apply_rename_internal, apply_renames, marksof_internal, resolve_internal};
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 1f0b6672594..b4cd9779ae2 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -76,6 +76,9 @@
 //! Remaining input: ``
 //! eof: [a $( a )* a b ยท]
 
+pub use self::NamedMatch::*;
+pub use self::ParseResult::*;
+use self::TokenTreeOrTokenTreeVec::*;
 
 use ast;
 use ast::{TokenTree, Ident};
diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs
index 3cb861aac20..99799fecb78 100644
--- a/src/libsyntax/ext/tt/transcribe.rs
+++ b/src/libsyntax/ext/tt/transcribe.rs
@@ -7,6 +7,7 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
+use self::LockstepIterSize::*;
 
 use ast;
 use ast::{TokenTree, TtDelimited, TtToken, TtSequence, Ident};
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs
index 019d2315c1a..0178566fb06 100644
--- a/src/libsyntax/feature_gate.rs
+++ b/src/libsyntax/feature_gate.rs
@@ -17,6 +17,7 @@
 //!
 //! Features are enabled in programs via the crate-level attributes of
 //! `#![feature(...)]` with a comma-separated list of features.
+use self::Status::*;
 
 use abi::RustIntrinsic;
 use ast::NodeId;
diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs
index 5a7679570bf..b62d2d744c9 100644
--- a/src/libsyntax/parse/lexer/comments.rs
+++ b/src/libsyntax/parse/lexer/comments.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+pub use self::CommentStyle::*;
+
 use ast;
 use codemap::{BytePos, CharPos, CodeMap, Pos};
 use diagnostic;
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs
index 1b2ab3c235d..e2dee607c69 100644
--- a/src/libsyntax/parse/obsolete.rs
+++ b/src/libsyntax/parse/obsolete.rs
@@ -17,6 +17,8 @@ Obsolete syntax that becomes too hard to parse can be
 removed.
 */
 
+pub use self::ObsoleteSyntax::*;
+
 use ast::{Expr, ExprTup};
 use codemap::Span;
 use parse::parser;
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 50e3483fb15..5c95c369f94 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -10,6 +10,9 @@
 
 #![macro_escape]
 
+pub use self::PathParsingMode::*;
+use self::ItemOrViewItem::*;
+
 use abi;
 use ast::{AssociatedType, BareFnTy, ClosureTy};
 use ast::{RegionTyParamBound, TraitTyParamBound};
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index f501a5831d2..298328d73ef 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -8,6 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+pub use self::BinOpToken::*;
+pub use self::Nonterminal::*;
+pub use self::DelimToken::*;
+pub use self::IdentStyle::*;
+pub use self::Token::*;
+
 use ast;
 use ext::mtwt;
 use ptr::P;
@@ -418,6 +424,7 @@ macro_rules! declare_special_idents_and_keywords {(
      * the language and may not appear as identifiers.
      */
     pub mod keywords {
+        pub use self::Keyword::*;
         use ast;
 
         pub enum Keyword {
diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs
index 5523f85aceb..7ab3d5dbcd1 100644
--- a/src/libsyntax/print/pp.rs
+++ b/src/libsyntax/print/pp.rs
@@ -59,6 +59,10 @@
 //! line (which it can't) and so naturally place the content on its own line to
 //! avoid combining it with other lines and making matters even worse.
 
+pub use self::PrintStackBreak::*;
+pub use self::Breaks::*;
+pub use self::Token::*;
+
 use std::io;
 use std::string;
 
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 7025555ab40..390a5cc68d3 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+pub use self::AnnNode::*;
+
 use abi;
 use ast::{FnUnboxedClosureKind, FnMutUnboxedClosureKind};
 use ast::{FnOnceUnboxedClosureKind};
diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs
index 8b6d752d484..f21a3185d6d 100644
--- a/src/libsyntax/test.rs
+++ b/src/libsyntax/test.rs
@@ -12,6 +12,7 @@
 
 #![allow(dead_code)]
 #![allow(unused_imports)]
+use self::HasTestSignature::*;
 
 use std::slice;
 use std::mem;
@@ -276,16 +277,17 @@ fn strip_test_functions(krate: ast::Crate) -> ast::Crate {
     })
 }
 
+#[deriving(PartialEq)]
+enum HasTestSignature {
+    Yes,
+    No,
+    NotEvenAFunction,
+}
+
+
 fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
     let has_test_attr = attr::contains_name(i.attrs.as_slice(), "test");
 
-    #[deriving(PartialEq)]
-    enum HasTestSignature {
-        Yes,
-        No,
-        NotEvenAFunction,
-    }
-
     fn has_test_signature(i: &ast::Item) -> HasTestSignature {
         match &i.node {
           &ast::ItemFn(ref decl, _, _, ref generics, _) => {
diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs
index 8aba0014e97..c4b3288d44d 100644
--- a/src/libsyntax/util/small_vector.rs
+++ b/src/libsyntax/util/small_vector.rs
@@ -7,6 +7,8 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
+use self::SmallVectorRepr::*;
+use self::MoveItemsRepr::*;
 
 use std::mem;
 use std::slice;
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index f30a4325eb8..2960c28a8b7 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -23,6 +23,8 @@
 //! instance, a walker looking for item names in a module will miss all of
 //! those that are created by the expansion of a macro.
 
+pub use self::FnKind::*;
+
 use abi::Abi;
 use ast::*;
 use ast;