about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2015-07-31 00:04:06 -0700
committerNick Cameron <ncameron@mozilla.com>2015-09-03 10:02:36 +1200
commitfacdf2ebb1dce9400a8c8ef0d85d7d278654effb (patch)
tree3ba46bd98df35b4b5d1bc5f1ba491d14adb6f373 /src/librustdoc
parentcfd76b364cd01695517467299618ef63f1c0cc07 (diff)
downloadrust-facdf2ebb1dce9400a8c8ef0d85d7d278654effb.tar.gz
rust-facdf2ebb1dce9400a8c8ef0d85d7d278654effb.zip
Add an intital HIR and lowering step
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/clean/inline.rs23
-rw-r--r--src/librustdoc/clean/mod.rs312
-rw-r--r--src/librustdoc/core.rs15
-rw-r--r--src/librustdoc/doctree.rs119
-rw-r--r--src/librustdoc/html/format.rs29
-rw-r--r--src/librustdoc/html/render.rs17
-rw-r--r--src/librustdoc/lib.rs1
-rw-r--r--src/librustdoc/passes.rs7
-rw-r--r--src/librustdoc/test.rs9
-rw-r--r--src/librustdoc/visit_ast.rs101
10 files changed, 318 insertions, 315 deletions
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index b79c35a0963..c9af86f06db 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -13,7 +13,8 @@
 use std::collections::HashSet;
 
 use syntax::ast;
-use syntax::attr::AttrMetaMethods;
+use rustc_front::attr::AttrMetaMethods;
+use rustc_front::hir;
 
 use rustc::metadata::csearch;
 use rustc::metadata::decoder;
@@ -119,7 +120,7 @@ fn try_inline_def(cx: &DocContext, tcx: &ty::ctxt,
         name: Some(tcx.item_name(did).to_string()),
         attrs: load_attrs(cx, tcx, did),
         inner: inner,
-        visibility: Some(ast::Public),
+        visibility: Some(hir::Public),
         stability: stability::lookup(tcx, did).clean(cx),
         def_id: did,
     });
@@ -174,7 +175,7 @@ fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, did: DefId) -> clean
         decl: decl,
         generics: (&t.generics, &predicates, subst::FnSpace).clean(cx),
         unsafety: style,
-        constness: ast::Constness::NotConst,
+        constness: hir::Constness::NotConst,
         abi: abi,
     }
 }
@@ -291,7 +292,7 @@ pub fn build_impl(cx: &DocContext,
         return ret.push(clean::Item {
             inner: clean::DefaultImplItem(clean::DefaultImpl {
                 // FIXME: this should be decoded
-                unsafety: ast::Unsafety::Normal,
+                unsafety: hir::Unsafety::Normal,
                 trait_: match associated_trait.as_ref().unwrap().clean(cx) {
                     clean::TraitBound(polyt, _) => polyt.trait_,
                     clean::RegionBound(..) => unreachable!(),
@@ -300,7 +301,7 @@ pub fn build_impl(cx: &DocContext,
             source: clean::Span::empty(),
             name: None,
             attrs: attrs,
-            visibility: Some(ast::Inherited),
+            visibility: Some(hir::Inherited),
             stability: stability::lookup(tcx, did).clean(cx),
             def_id: did,
         });
@@ -335,7 +336,7 @@ pub fn build_impl(cx: &DocContext,
                 })
             }
             ty::MethodTraitItem(method) => {
-                if method.vis != ast::Public && associated_trait.is_none() {
+                if method.vis != hir::Public && associated_trait.is_none() {
                     return None
                 }
                 if method.provided_source.is_some() {
@@ -348,7 +349,7 @@ pub fn build_impl(cx: &DocContext,
                     }) => {
                         clean::MethodItem(clean::Method {
                             unsafety: unsafety,
-                            constness: ast::Constness::NotConst,
+                            constness: hir::Constness::NotConst,
                             decl: decl,
                             self_: self_,
                             generics: generics,
@@ -396,7 +397,7 @@ pub fn build_impl(cx: &DocContext,
     }
     ret.push(clean::Item {
         inner: clean::ImplItem(clean::Impl {
-            unsafety: ast::Unsafety::Normal, // FIXME: this should be decoded
+            unsafety: hir::Unsafety::Normal, // FIXME: this should be decoded
             derived: clean::detect_derived(&attrs),
             trait_: trait_,
             for_: ty.ty.clean(cx),
@@ -407,7 +408,7 @@ pub fn build_impl(cx: &DocContext,
         source: clean::Span::empty(),
         name: None,
         attrs: attrs,
-        visibility: Some(ast::Inherited),
+        visibility: Some(hir::Inherited),
         stability: stability::lookup(tcx, did).clean(cx),
         def_id: did,
     });
@@ -447,7 +448,7 @@ fn build_module(cx: &DocContext, tcx: &ty::ctxt,
                 decoder::DlDef(def::DefForeignMod(did)) => {
                     fill_in(cx, tcx, did, items);
                 }
-                decoder::DlDef(def) if vis == ast::Public => {
+                decoder::DlDef(def) if vis == hir::Public => {
                     if !visited.insert(def) { return }
                     match try_inline_def(cx, tcx, def) {
                         Some(i) => items.extend(i),
@@ -466,7 +467,7 @@ fn build_module(cx: &DocContext, tcx: &ty::ctxt,
 fn build_const(cx: &DocContext, tcx: &ty::ctxt,
                did: DefId) -> clean::Constant {
     use rustc::middle::const_eval;
-    use syntax::print::pprust;
+    use rustc_front::print::pprust;
 
     let expr = const_eval::lookup_const_by_id(tcx, did, None).unwrap_or_else(|| {
         panic!("expected lookup_const_by_id to succeed for {:?}", did);
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 9cd376f8d31..5510d3ee064 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -27,8 +27,6 @@ pub use self::FunctionRetTy::*;
 use syntax;
 use syntax::abi;
 use syntax::ast;
-use syntax::attr;
-use syntax::attr::{AttributeMethods, AttrMetaMethods};
 use syntax::codemap;
 use syntax::codemap::{DUMMY_SP, Pos, Spanned};
 use syntax::parse::token::{self, InternedString, special_idents};
@@ -44,6 +42,11 @@ use rustc::middle::subst::{self, ParamSpace, VecPerParamSpace};
 use rustc::middle::ty;
 use rustc::middle::stability;
 
+use rustc_front::hir;
+use rustc_front::attr;
+use rustc_front::attr::{AttributeMethods, AttrMetaMethods};
+use rustc_front::lowering::unlower_attribute;
+
 use std::collections::HashMap;
 use std::path::PathBuf;
 use std::rc::Rc;
@@ -140,7 +143,8 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
 
         // Figure out the name of this crate
         let input = &cx.input;
-        let name = link::find_crate_name(None, &self.attrs, input);
+        let attrs: Vec<_> = self.attrs.iter().map(|a| unlower_attribute(a)).collect();
+        let name = link::find_crate_name(None, &attrs, input);
 
         // Clean the crate, translating the entire libsyntax AST to one that is
         // understood by rustdoc.
@@ -184,7 +188,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
                     source: Span::empty(),
                     name: Some(prim.to_url_str().to_string()),
                     attrs: child.attrs.clone(),
-                    visibility: Some(ast::Public),
+                    visibility: Some(hir::Public),
                     stability: None,
                     def_id: DefId::local(prim.to_node_id()),
                     inner: PrimitiveItem(prim),
@@ -433,21 +437,21 @@ pub enum Attribute {
     NameValue(String, String)
 }
 
-impl Clean<Attribute> for ast::MetaItem {
+impl Clean<Attribute> for hir::MetaItem {
     fn clean(&self, cx: &DocContext) -> Attribute {
         match self.node {
-            ast::MetaWord(ref s) => Word(s.to_string()),
-            ast::MetaList(ref s, ref l) => {
+            hir::MetaWord(ref s) => Word(s.to_string()),
+            hir::MetaList(ref s, ref l) => {
                 List(s.to_string(), l.clean(cx))
             }
-            ast::MetaNameValue(ref s, ref v) => {
+            hir::MetaNameValue(ref s, ref v) => {
                 NameValue(s.to_string(), lit_to_string(v))
             }
         }
     }
 }
 
-impl Clean<Attribute> for ast::Attribute {
+impl Clean<Attribute> for hir::Attribute {
     fn clean(&self, cx: &DocContext) -> Attribute {
         self.with_desugared_doc(|a| a.node.value.clean(cx))
     }
@@ -471,13 +475,13 @@ impl attr::AttrMetaMethods for Attribute {
             _ => None,
         }
     }
-    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<ast::MetaItem>]> { None }
+    fn meta_item_list<'a>(&'a self) -> Option<&'a [P<hir::MetaItem>]> { None }
     fn span(&self) -> codemap::Span { unimplemented!() }
 }
 impl<'a> attr::AttrMetaMethods for &'a Attribute {
     fn name(&self) -> InternedString { (**self).name() }
     fn value_str(&self) -> Option<InternedString> { (**self).value_str() }
-    fn meta_item_list(&self) -> Option<&[P<ast::MetaItem>]> { None }
+    fn meta_item_list(&self) -> Option<&[P<hir::MetaItem>]> { None }
     fn span(&self) -> codemap::Span { unimplemented!() }
 }
 
@@ -489,7 +493,7 @@ pub struct TyParam {
     pub default: Option<Type>,
 }
 
-impl Clean<TyParam> for ast::TyParam {
+impl Clean<TyParam> for hir::TyParam {
     fn clean(&self, cx: &DocContext) -> TyParam {
         TyParam {
             name: self.ident.clean(cx),
@@ -516,12 +520,12 @@ impl<'tcx> Clean<TyParam> for ty::TypeParameterDef<'tcx> {
 #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)]
 pub enum TyParamBound {
     RegionBound(Lifetime),
-    TraitBound(PolyTrait, ast::TraitBoundModifier)
+    TraitBound(PolyTrait, hir::TraitBoundModifier)
 }
 
 impl TyParamBound {
     fn maybe_sized(cx: &DocContext) -> TyParamBound {
-        use syntax::ast::TraitBoundModifier as TBM;
+        use rustc_front::hir::TraitBoundModifier as TBM;
         let mut sized_bound = ty::BoundSized.clean(cx);
         if let TyParamBound::TraitBound(_, ref mut tbm) = sized_bound {
             *tbm = TBM::Maybe
@@ -530,7 +534,7 @@ impl TyParamBound {
     }
 
     fn is_sized_bound(&self, cx: &DocContext) -> bool {
-        use syntax::ast::TraitBoundModifier as TBM;
+        use rustc_front::hir::TraitBoundModifier as TBM;
         if let Some(tcx) = cx.tcx_opt() {
             let sized_did = match tcx.lang_items.sized_trait() {
                 Some(did) => did,
@@ -548,11 +552,11 @@ impl TyParamBound {
     }
 }
 
-impl Clean<TyParamBound> for ast::TyParamBound {
+impl Clean<TyParamBound> for hir::TyParamBound {
     fn clean(&self, cx: &DocContext) -> TyParamBound {
         match *self {
-            ast::RegionTyParamBound(lt) => RegionBound(lt.clean(cx)),
-            ast::TraitTyParamBound(ref t, modifier) => TraitBound(t.clean(cx), modifier),
+            hir::RegionTyParamBound(lt) => RegionBound(lt.clean(cx)),
+            hir::TraitTyParamBound(ref t, modifier) => TraitBound(t.clean(cx), modifier),
         }
     }
 }
@@ -666,7 +670,7 @@ impl Clean<TyParamBound> for ty::BuiltinBound {
                 is_generic: false,
             },
             lifetimes: vec![]
-        }, ast::TraitBoundModifier::None)
+        }, hir::TraitBoundModifier::None)
     }
 }
 
@@ -712,7 +716,7 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
                 is_generic: false,
             },
             lifetimes: late_bounds
-        }, ast::TraitBoundModifier::None)
+        }, hir::TraitBoundModifier::None)
     }
 }
 
@@ -723,7 +727,7 @@ impl<'tcx> Clean<Option<Vec<TyParamBound>>> for subst::Substs<'tcx> {
         v.extend(self.types.iter().map(|t| TraitBound(PolyTrait {
             trait_: t.clean(cx),
             lifetimes: vec![]
-        }, ast::TraitBoundModifier::None)));
+        }, hir::TraitBoundModifier::None)));
         if !v.is_empty() {Some(v)} else {None}
     }
 }
@@ -743,13 +747,13 @@ impl Lifetime {
     }
 }
 
-impl Clean<Lifetime> for ast::Lifetime {
+impl Clean<Lifetime> for hir::Lifetime {
     fn clean(&self, _: &DocContext) -> Lifetime {
         Lifetime(self.name.to_string())
     }
 }
 
-impl Clean<Lifetime> for ast::LifetimeDef {
+impl Clean<Lifetime> for hir::LifetimeDef {
     fn clean(&self, _: &DocContext) -> Lifetime {
         Lifetime(self.lifetime.name.to_string())
     }
@@ -786,24 +790,24 @@ pub enum WherePredicate {
     EqPredicate { lhs: Type, rhs: Type }
 }
 
-impl Clean<WherePredicate> for ast::WherePredicate {
+impl Clean<WherePredicate> for hir::WherePredicate {
     fn clean(&self, cx: &DocContext) -> WherePredicate {
         match *self {
-            ast::WherePredicate::BoundPredicate(ref wbp) => {
+            hir::WherePredicate::BoundPredicate(ref wbp) => {
                 WherePredicate::BoundPredicate {
                     ty: wbp.bounded_ty.clean(cx),
                     bounds: wbp.bounds.clean(cx)
                 }
             }
 
-            ast::WherePredicate::RegionPredicate(ref wrp) => {
+            hir::WherePredicate::RegionPredicate(ref wrp) => {
                 WherePredicate::RegionPredicate {
                     lifetime: wrp.lifetime.clean(cx),
                     bounds: wrp.bounds.clean(cx)
                 }
             }
 
-            ast::WherePredicate::EqPredicate(_) => {
+            hir::WherePredicate::EqPredicate(_) => {
                 unimplemented!() // FIXME(#20041)
             }
         }
@@ -899,7 +903,7 @@ pub struct Generics {
     pub where_predicates: Vec<WherePredicate>
 }
 
-impl Clean<Generics> for ast::Generics {
+impl Clean<Generics> for hir::Generics {
     fn clean(&self, cx: &DocContext) -> Generics {
         Generics {
             lifetimes: self.lifetimes.clean(cx),
@@ -982,17 +986,17 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics<'tcx>,
 pub struct Method {
     pub generics: Generics,
     pub self_: SelfTy,
-    pub unsafety: ast::Unsafety,
-    pub constness: ast::Constness,
+    pub unsafety: hir::Unsafety,
+    pub constness: hir::Constness,
     pub decl: FnDecl,
     pub abi: abi::Abi
 }
 
-impl Clean<Method> for ast::MethodSig {
+impl Clean<Method> for hir::MethodSig {
     fn clean(&self, cx: &DocContext) -> Method {
         let all_inputs = &self.decl.inputs;
         let inputs = match self.explicit_self.node {
-            ast::SelfStatic => &**all_inputs,
+            hir::SelfStatic => &**all_inputs,
             _ => &all_inputs[1..]
         };
         let decl = FnDecl {
@@ -1016,17 +1020,17 @@ impl Clean<Method> for ast::MethodSig {
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct TyMethod {
-    pub unsafety: ast::Unsafety,
+    pub unsafety: hir::Unsafety,
     pub decl: FnDecl,
     pub generics: Generics,
     pub self_: SelfTy,
     pub abi: abi::Abi
 }
 
-impl Clean<TyMethod> for ast::MethodSig {
+impl Clean<TyMethod> for hir::MethodSig {
     fn clean(&self, cx: &DocContext) -> TyMethod {
         let inputs = match self.explicit_self.node {
-            ast::SelfStatic => &*self.decl.inputs,
+            hir::SelfStatic => &*self.decl.inputs,
             _ => &self.decl.inputs[1..]
         };
         let decl = FnDecl {
@@ -1055,15 +1059,15 @@ pub enum SelfTy {
     SelfExplicit(Type),
 }
 
-impl Clean<SelfTy> for ast::ExplicitSelf_ {
+impl Clean<SelfTy> for hir::ExplicitSelf_ {
     fn clean(&self, cx: &DocContext) -> SelfTy {
         match *self {
-            ast::SelfStatic => SelfStatic,
-            ast::SelfValue(_) => SelfValue,
-            ast::SelfRegion(ref lt, ref mt, _) => {
+            hir::SelfStatic => SelfStatic,
+            hir::SelfValue(_) => SelfValue,
+            hir::SelfRegion(ref lt, ref mt, _) => {
                 SelfBorrowed(lt.clean(cx), mt.clean(cx))
             }
-            ast::SelfExplicit(ref typ, _) => SelfExplicit(typ.clean(cx)),
+            hir::SelfExplicit(ref typ, _) => SelfExplicit(typ.clean(cx)),
         }
     }
 }
@@ -1072,8 +1076,8 @@ impl Clean<SelfTy> for ast::ExplicitSelf_ {
 pub struct Function {
     pub decl: FnDecl,
     pub generics: Generics,
-    pub unsafety: ast::Unsafety,
-    pub constness: ast::Constness,
+    pub unsafety: hir::Unsafety,
+    pub constness: hir::Constness,
     pub abi: abi::Abi,
 }
 
@@ -1110,7 +1114,7 @@ pub struct Arguments {
     pub values: Vec<Argument>,
 }
 
-impl Clean<FnDecl> for ast::FnDecl {
+impl Clean<FnDecl> for hir::FnDecl {
     fn clean(&self, cx: &DocContext) -> FnDecl {
         FnDecl {
             inputs: Arguments {
@@ -1167,7 +1171,7 @@ pub struct Argument {
     pub id: ast::NodeId,
 }
 
-impl Clean<Argument> for ast::Arg {
+impl Clean<Argument> for hir::Arg {
     fn clean(&self, cx: &DocContext) -> Argument {
         Argument {
             name: name_from_pat(&*self.pat),
@@ -1184,19 +1188,19 @@ pub enum FunctionRetTy {
     NoReturn
 }
 
-impl Clean<FunctionRetTy> for ast::FunctionRetTy {
+impl Clean<FunctionRetTy> for hir::FunctionRetTy {
     fn clean(&self, cx: &DocContext) -> FunctionRetTy {
         match *self {
-            ast::Return(ref typ) => Return(typ.clean(cx)),
-            ast::DefaultReturn(..) => DefaultReturn,
-            ast::NoReturn(..) => NoReturn
+            hir::Return(ref typ) => Return(typ.clean(cx)),
+            hir::DefaultReturn(..) => DefaultReturn,
+            hir::NoReturn(..) => NoReturn
         }
     }
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct Trait {
-    pub unsafety: ast::Unsafety,
+    pub unsafety: hir::Unsafety,
     pub items: Vec<Item>,
     pub generics: Generics,
     pub bounds: Vec<TyParamBound>,
@@ -1221,13 +1225,13 @@ impl Clean<Item> for doctree::Trait {
     }
 }
 
-impl Clean<Type> for ast::TraitRef {
+impl Clean<Type> for hir::TraitRef {
     fn clean(&self, cx: &DocContext) -> Type {
         resolve_type(cx, self.path.clean(cx), self.ref_id)
     }
 }
 
-impl Clean<PolyTrait> for ast::PolyTraitRef {
+impl Clean<PolyTrait> for hir::PolyTraitRef {
     fn clean(&self, cx: &DocContext) -> PolyTrait {
         PolyTrait {
             trait_: self.trait_ref.clean(cx),
@@ -1236,21 +1240,21 @@ impl Clean<PolyTrait> for ast::PolyTraitRef {
     }
 }
 
-impl Clean<Item> for ast::TraitItem {
+impl Clean<Item> for hir::TraitItem {
     fn clean(&self, cx: &DocContext) -> Item {
         let inner = match self.node {
-            ast::ConstTraitItem(ref ty, ref default) => {
+            hir::ConstTraitItem(ref ty, ref default) => {
                 AssociatedConstItem(ty.clean(cx),
                                     default.as_ref().map(|expr|
                                                          expr.span.to_src(cx)))
             }
-            ast::MethodTraitItem(ref sig, Some(_)) => {
+            hir::MethodTraitItem(ref sig, Some(_)) => {
                 MethodItem(sig.clean(cx))
             }
-            ast::MethodTraitItem(ref sig, None) => {
+            hir::MethodTraitItem(ref sig, None) => {
                 TyMethodItem(sig.clean(cx))
             }
-            ast::TypeTraitItem(ref bounds, ref default) => {
+            hir::TypeTraitItem(ref bounds, ref default) => {
                 AssociatedTypeItem(bounds.clean(cx), default.clean(cx))
             }
         };
@@ -1266,19 +1270,19 @@ impl Clean<Item> for ast::TraitItem {
     }
 }
 
-impl Clean<Item> for ast::ImplItem {
+impl Clean<Item> for hir::ImplItem {
     fn clean(&self, cx: &DocContext) -> Item {
         let inner = match self.node {
-            ast::ConstImplItem(ref ty, ref expr) => {
+            hir::ConstImplItem(ref ty, ref expr) => {
                 ConstantItem(Constant{
                     type_: ty.clean(cx),
                     expr: expr.span.to_src(cx),
                 })
             }
-            ast::MethodImplItem(ref sig, _) => {
+            hir::MethodImplItem(ref sig, _) => {
                 MethodItem(sig.clean(cx))
             }
-            ast::TypeImplItem(ref ty) => TypedefItem(Typedef {
+            hir::TypeImplItem(ref ty) => TypedefItem(Typedef {
                 type_: ty.clean(cx),
                 generics: Generics {
                     lifetimes: Vec::new(),
@@ -1286,12 +1290,6 @@ impl Clean<Item> for ast::ImplItem {
                     where_predicates: Vec::new()
                 },
             }, true),
-            ast::MacImplItem(_) => {
-                MacroItem(Macro {
-                    source: self.span.to_src(cx),
-                    imported_from: None,
-                })
-            }
         };
         Item {
             name: Some(self.ident.clean(cx)),
@@ -1308,7 +1306,7 @@ impl Clean<Item> for ast::ImplItem {
 impl<'tcx> Clean<Item> for ty::Method<'tcx> {
     fn clean(&self, cx: &DocContext) -> Item {
         let (self_, sig) = match self.explicit_self {
-            ty::StaticExplicitSelfCategory => (ast::SelfStatic.clean(cx),
+            ty::StaticExplicitSelfCategory => (hir::SelfStatic.clean(cx),
                                                self.fty.sig.clone()),
             s => {
                 let sig = ty::Binder(ty::FnSig {
@@ -1354,7 +1352,7 @@ impl<'tcx> Clean<Item> for ty::Method<'tcx> {
                 abi: self.fty.abi,
 
                 // trait methods canot (currently, at least) be const
-                constness: ast::Constness::NotConst,
+                constness: hir::Constness::NotConst,
             })
         } else {
             TyMethodItem(TyMethod {
@@ -1368,7 +1366,7 @@ impl<'tcx> Clean<Item> for ty::Method<'tcx> {
 
         Item {
             name: Some(self.name.clean(cx)),
-            visibility: Some(ast::Inherited),
+            visibility: Some(hir::Inherited),
             stability: get_stability(cx, self.def_id),
             def_id: self.def_id,
             attrs: inline::load_attrs(cx, cx.tcx(), self.def_id),
@@ -1400,7 +1398,7 @@ pub struct PolyTrait {
 /// it does not preserve mutability or boxes.
 #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)]
 pub enum Type {
-    /// structs/enums/traits (most that'd be an ast::TyPath)
+    /// structs/enums/traits (most that'd be an hir::TyPath)
     ResolvedPath {
         path: Path,
         typarams: Option<Vec<TyParamBound>>,
@@ -1568,9 +1566,9 @@ impl PrimitiveType {
     }
 }
 
-impl Clean<Type> for ast::Ty {
+impl Clean<Type> for hir::Ty {
     fn clean(&self, cx: &DocContext) -> Type {
-        use syntax::ast::*;
+        use rustc_front::hir::*;
         match self.node {
             TyPtr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)),
             TyRptr(ref l, ref m) =>
@@ -1619,9 +1617,6 @@ impl Clean<Type> for ast::Ty {
             TyTypeof(..) => {
                 panic!("Unimplemented type {:?}", self.node)
             },
-            TyMac(ref m) => {
-                cx.tcx().sess.span_bug(m.span, "unexpanded type macro found during cleaning")
-            }
         }
     }
 }
@@ -1631,18 +1626,18 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
         match self.sty {
             ty::TyBool => Primitive(Bool),
             ty::TyChar => Primitive(Char),
-            ty::TyInt(ast::TyIs) => Primitive(Isize),
-            ty::TyInt(ast::TyI8) => Primitive(I8),
-            ty::TyInt(ast::TyI16) => Primitive(I16),
-            ty::TyInt(ast::TyI32) => Primitive(I32),
-            ty::TyInt(ast::TyI64) => Primitive(I64),
-            ty::TyUint(ast::TyUs) => Primitive(Usize),
-            ty::TyUint(ast::TyU8) => Primitive(U8),
-            ty::TyUint(ast::TyU16) => Primitive(U16),
-            ty::TyUint(ast::TyU32) => Primitive(U32),
-            ty::TyUint(ast::TyU64) => Primitive(U64),
-            ty::TyFloat(ast::TyF32) => Primitive(F32),
-            ty::TyFloat(ast::TyF64) => Primitive(F64),
+            ty::TyInt(hir::TyIs) => Primitive(Isize),
+            ty::TyInt(hir::TyI8) => Primitive(I8),
+            ty::TyInt(hir::TyI16) => Primitive(I16),
+            ty::TyInt(hir::TyI32) => Primitive(I32),
+            ty::TyInt(hir::TyI64) => Primitive(I64),
+            ty::TyUint(hir::TyUs) => Primitive(Usize),
+            ty::TyUint(hir::TyU8) => Primitive(U8),
+            ty::TyUint(hir::TyU16) => Primitive(U16),
+            ty::TyUint(hir::TyU32) => Primitive(U32),
+            ty::TyUint(hir::TyU64) => Primitive(U64),
+            ty::TyFloat(hir::TyF32) => Primitive(F32),
+            ty::TyFloat(hir::TyF64) => Primitive(F64),
             ty::TyStr => Primitive(Str),
             ty::TyBox(t) => {
                 let box_did = cx.tcx_opt().and_then(|tcx| {
@@ -1723,11 +1718,11 @@ pub enum StructField {
     TypedStructField(Type),
 }
 
-impl Clean<Item> for ast::StructField {
+impl Clean<Item> for hir::StructField {
     fn clean(&self, cx: &DocContext) -> Item {
         let (name, vis) = match self.node.kind {
-            ast::NamedField(id, vis) => (Some(id), vis),
-            ast::UnnamedField(vis) => (None, vis)
+            hir::NamedField(id, vis) => (Some(id), vis),
+            hir::UnnamedField(vis) => (None, vis)
         };
         Item {
             name: name.clean(cx),
@@ -1766,9 +1761,9 @@ impl<'tcx> Clean<Item> for ty::FieldDefData<'tcx, 'static> {
     }
 }
 
-pub type Visibility = ast::Visibility;
+pub type Visibility = hir::Visibility;
 
-impl Clean<Option<Visibility>> for ast::Visibility {
+impl Clean<Option<Visibility>> for hir::Visibility {
     fn clean(&self, _: &DocContext) -> Option<Visibility> {
         Some(*self)
     }
@@ -1811,7 +1806,7 @@ pub struct VariantStruct {
     pub fields_stripped: bool,
 }
 
-impl Clean<VariantStruct> for syntax::ast::StructDef {
+impl Clean<VariantStruct> for ::rustc_front::hir::StructDef {
     fn clean(&self, cx: &DocContext) -> VariantStruct {
         VariantStruct {
             struct_type: doctree::struct_type_from_def(self),
@@ -1886,7 +1881,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
                             source: Span::empty(),
                             name: Some(field.name.clean(cx)),
                             attrs: Vec::new(),
-                            visibility: Some(ast::Public),
+                            visibility: Some(hir::Public),
                             // FIXME: this is not accurate, we need an id for
                             //        the specific field but we're using the id
                             //        for the whole variant. Thus we read the
@@ -1908,7 +1903,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
             name: Some(self.name.clean(cx)),
             attrs: inline::load_attrs(cx, cx.tcx(), self.did),
             source: Span::empty(),
-            visibility: Some(ast::Public),
+            visibility: Some(hir::Public),
             def_id: self.did,
             inner: VariantItem(Variant { kind: kind }),
             stability: get_stability(cx, self.did),
@@ -1923,17 +1918,17 @@ pub enum VariantKind {
     StructVariant(VariantStruct),
 }
 
-impl Clean<VariantKind> for ast::VariantKind {
+impl Clean<VariantKind> for hir::VariantKind {
     fn clean(&self, cx: &DocContext) -> VariantKind {
         match self {
-            &ast::TupleVariantKind(ref args) => {
+            &hir::TupleVariantKind(ref args) => {
                 if args.is_empty() {
                     CLikeVariant
                 } else {
                     TupleVariant(args.iter().map(|x| x.ty.clean(cx)).collect())
                 }
             },
-            &ast::StructVariantKind(ref sd) => StructVariant(sd.clean(cx)),
+            &hir::StructVariantKind(ref sd) => StructVariant(sd.clean(cx)),
         }
     }
 }
@@ -1999,7 +1994,7 @@ impl Path {
     }
 }
 
-impl Clean<Path> for ast::Path {
+impl Clean<Path> for hir::Path {
     fn clean(&self, cx: &DocContext) -> Path {
         Path {
             global: self.global,
@@ -2021,10 +2016,10 @@ pub enum PathParameters {
     }
 }
 
-impl Clean<PathParameters> for ast::PathParameters {
+impl Clean<PathParameters> for hir::PathParameters {
     fn clean(&self, cx: &DocContext) -> PathParameters {
         match *self {
-            ast::AngleBracketedParameters(ref data) => {
+            hir::AngleBracketedParameters(ref data) => {
                 PathParameters::AngleBracketed {
                     lifetimes: data.lifetimes.clean(cx),
                     types: data.types.clean(cx),
@@ -2032,7 +2027,7 @@ impl Clean<PathParameters> for ast::PathParameters {
                 }
             }
 
-            ast::ParenthesizedParameters(ref data) => {
+            hir::ParenthesizedParameters(ref data) => {
                 PathParameters::Parenthesized {
                     inputs: data.inputs.clean(cx),
                     output: data.output.clean(cx)
@@ -2048,7 +2043,7 @@ pub struct PathSegment {
     pub params: PathParameters
 }
 
-impl Clean<PathSegment> for ast::PathSegment {
+impl Clean<PathSegment> for hir::PathSegment {
     fn clean(&self, cx: &DocContext) -> PathSegment {
         PathSegment {
             name: self.identifier.clean(cx),
@@ -2057,7 +2052,7 @@ impl Clean<PathSegment> for ast::PathSegment {
     }
 }
 
-fn path_to_string(p: &ast::Path) -> String {
+fn path_to_string(p: &hir::Path) -> String {
     let mut s = String::new();
     let mut first = true;
     for i in p.segments.iter().map(|x| x.identifier.name.as_str()) {
@@ -2108,13 +2103,13 @@ impl Clean<Item> for doctree::Typedef {
 
 #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)]
 pub struct BareFunctionDecl {
-    pub unsafety: ast::Unsafety,
+    pub unsafety: hir::Unsafety,
     pub generics: Generics,
     pub decl: FnDecl,
     pub abi: String,
 }
 
-impl Clean<BareFunctionDecl> for ast::BareFnTy {
+impl Clean<BareFunctionDecl> for hir::BareFnTy {
     fn clean(&self, cx: &DocContext) -> BareFunctionDecl {
         BareFunctionDecl {
             unsafety: self.unsafety,
@@ -2187,11 +2182,11 @@ pub enum Mutability {
     Immutable,
 }
 
-impl Clean<Mutability> for ast::Mutability {
+impl Clean<Mutability> for hir::Mutability {
     fn clean(&self, _: &DocContext) -> Mutability {
         match self {
-            &ast::MutMutable => Mutable,
-            &ast::MutImmutable => Immutable,
+            &hir::MutMutable => Mutable,
+            &hir::MutImmutable => Immutable,
         }
     }
 }
@@ -2202,18 +2197,18 @@ pub enum ImplPolarity {
     Negative,
 }
 
-impl Clean<ImplPolarity> for ast::ImplPolarity {
+impl Clean<ImplPolarity> for hir::ImplPolarity {
     fn clean(&self, _: &DocContext) -> ImplPolarity {
         match self {
-            &ast::ImplPolarity::Positive => ImplPolarity::Positive,
-            &ast::ImplPolarity::Negative => ImplPolarity::Negative,
+            &hir::ImplPolarity::Positive => ImplPolarity::Positive,
+            &hir::ImplPolarity::Negative => ImplPolarity::Negative,
         }
     }
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct Impl {
-    pub unsafety: ast::Unsafety,
+    pub unsafety: hir::Unsafety,
     pub generics: Generics,
     pub trait_: Option<Type>,
     pub for_: Type,
@@ -2316,7 +2311,7 @@ fn build_deref_target_impls(cx: &DocContext,
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct DefaultImpl {
-    pub unsafety: ast::Unsafety,
+    pub unsafety: hir::Unsafety,
     pub trait_: Type,
 }
 
@@ -2327,7 +2322,7 @@ impl Clean<Item> for doctree::DefaultImpl {
             attrs: self.attrs.clean(cx),
             source: self.whence.clean(cx),
             def_id: DefId::local(self.id),
-            visibility: Some(ast::Public),
+            visibility: Some(hir::Public),
             stability: None,
             inner: DefaultImplItem(DefaultImpl {
                 unsafety: self.unsafety,
@@ -2356,17 +2351,17 @@ impl Clean<Vec<Item>> for doctree::Import {
         // We consider inlining the documentation of `pub use` statements, but we
         // forcefully don't inline if this is not public or if the
         // #[doc(no_inline)] attribute is present.
-        let denied = self.vis != ast::Public || self.attrs.iter().any(|a| {
+        let denied = self.vis != hir::Public || self.attrs.iter().any(|a| {
             &a.name()[..] == "doc" && match a.meta_item_list() {
                 Some(l) => attr::contains_name(l, "no_inline"),
                 None => false,
             }
         });
         let (mut ret, inner) = match self.node {
-            ast::ViewPathGlob(ref p) => {
+            hir::ViewPathGlob(ref p) => {
                 (vec![], GlobImport(resolve_use_source(cx, p.clean(cx), self.id)))
             }
-            ast::ViewPathList(ref p, ref list) => {
+            hir::ViewPathList(ref p, ref list) => {
                 // Attempt to inline all reexported items, but be sure
                 // to keep any non-inlineable reexports so they can be
                 // listed in the documentation.
@@ -2393,7 +2388,7 @@ impl Clean<Vec<Item>> for doctree::Import {
                 (ret, ImportList(resolve_use_source(cx, p.clean(cx), self.id),
                                  remaining))
             }
-            ast::ViewPathSimple(i, ref p) => {
+            hir::ViewPathSimple(i, ref p) => {
                 if !denied {
                     match inline::try_inline(cx, self.id, Some(i)) {
                         Some(items) => return items,
@@ -2440,15 +2435,15 @@ pub struct ViewListIdent {
     pub source: Option<DefId>,
 }
 
-impl Clean<ViewListIdent> for ast::PathListItem {
+impl Clean<ViewListIdent> for hir::PathListItem {
     fn clean(&self, cx: &DocContext) -> ViewListIdent {
         match self.node {
-            ast::PathListIdent { id, name, rename } => ViewListIdent {
+            hir::PathListIdent { id, name, rename } => ViewListIdent {
                 name: name.clean(cx),
                 rename: rename.map(|r| r.clean(cx)),
                 source: resolve_def(cx, id)
             },
-            ast::PathListMod { id, rename } => ViewListIdent {
+            hir::PathListMod { id, rename } => ViewListIdent {
                 name: "self".to_string(),
                 rename: rename.map(|r| r.clean(cx)),
                 source: resolve_def(cx, id)
@@ -2457,7 +2452,7 @@ impl Clean<ViewListIdent> for ast::PathListItem {
     }
 }
 
-impl Clean<Vec<Item>> for ast::ForeignMod {
+impl Clean<Vec<Item>> for hir::ForeignMod {
     fn clean(&self, cx: &DocContext) -> Vec<Item> {
         let mut items = self.items.clean(cx);
         for item in &mut items {
@@ -2470,19 +2465,19 @@ impl Clean<Vec<Item>> for ast::ForeignMod {
     }
 }
 
-impl Clean<Item> for ast::ForeignItem {
+impl Clean<Item> for hir::ForeignItem {
     fn clean(&self, cx: &DocContext) -> Item {
         let inner = match self.node {
-            ast::ForeignItemFn(ref decl, ref generics) => {
+            hir::ForeignItemFn(ref decl, ref generics) => {
                 ForeignFunctionItem(Function {
                     decl: decl.clean(cx),
                     generics: generics.clean(cx),
-                    unsafety: ast::Unsafety::Unsafe,
+                    unsafety: hir::Unsafety::Unsafe,
                     abi: abi::Rust,
-                    constness: ast::Constness::NotConst,
+                    constness: hir::Constness::NotConst,
                 })
             }
-            ast::ForeignItemStatic(ref ty, mutbl) => {
+            hir::ForeignItemStatic(ref ty, mutbl) => {
                 ForeignStaticItem(Static {
                     type_: ty.clean(cx),
                     mutability: if mutbl {Mutable} else {Immutable},
@@ -2520,11 +2515,11 @@ impl ToSource for syntax::codemap::Span {
     }
 }
 
-fn lit_to_string(lit: &ast::Lit) -> String {
+fn lit_to_string(lit: &hir::Lit) -> String {
     match lit.node {
-        ast::LitStr(ref st, _) => st.to_string(),
-        ast::LitBinary(ref data) => format!("{:?}", data),
-        ast::LitByte(b) => {
+        hir::LitStr(ref st, _) => st.to_string(),
+        hir::LitBinary(ref data) => format!("{:?}", data),
+        hir::LitByte(b) => {
             let mut res = String::from("b'");
             for c in (b as char).escape_default() {
                 res.push(c);
@@ -2532,16 +2527,16 @@ fn lit_to_string(lit: &ast::Lit) -> String {
             res.push('\'');
             res
         },
-        ast::LitChar(c) => format!("'{}'", c),
-        ast::LitInt(i, _t) => i.to_string(),
-        ast::LitFloat(ref f, _t) => f.to_string(),
-        ast::LitFloatUnsuffixed(ref f) => f.to_string(),
-        ast::LitBool(b) => b.to_string(),
+        hir::LitChar(c) => format!("'{}'", c),
+        hir::LitInt(i, _t) => i.to_string(),
+        hir::LitFloat(ref f, _t) => f.to_string(),
+        hir::LitFloatUnsuffixed(ref f) => f.to_string(),
+        hir::LitBool(b) => b.to_string(),
     }
 }
 
-fn name_from_pat(p: &ast::Pat) -> String {
-    use syntax::ast::*;
+fn name_from_pat(p: &hir::Pat) -> String {
+    use rustc_front::hir::*;
     debug!("Trying to get a name from pattern: {:?}", p);
 
     match p.node {
@@ -2576,11 +2571,6 @@ fn name_from_pat(p: &ast::Pat) -> String {
             let end = end.iter().map(|p| name_from_pat(&**p));
             format!("[{}]", begin.chain(mid).chain(end).collect::<Vec<_>>().join(", "))
         },
-        PatMac(..) => {
-            warn!("can't document the name of a function argument \
-                   produced by a pattern macro");
-            "(argument produced by macro)".to_string()
-        }
     }
 }
 
@@ -2601,21 +2591,21 @@ fn resolve_type(cx: &DocContext,
 
     let is_generic = match def {
         def::DefPrimTy(p) => match p {
-            ast::TyStr => return Primitive(Str),
-            ast::TyBool => return Primitive(Bool),
-            ast::TyChar => return Primitive(Char),
-            ast::TyInt(ast::TyIs) => return Primitive(Isize),
-            ast::TyInt(ast::TyI8) => return Primitive(I8),
-            ast::TyInt(ast::TyI16) => return Primitive(I16),
-            ast::TyInt(ast::TyI32) => return Primitive(I32),
-            ast::TyInt(ast::TyI64) => return Primitive(I64),
-            ast::TyUint(ast::TyUs) => return Primitive(Usize),
-            ast::TyUint(ast::TyU8) => return Primitive(U8),
-            ast::TyUint(ast::TyU16) => return Primitive(U16),
-            ast::TyUint(ast::TyU32) => return Primitive(U32),
-            ast::TyUint(ast::TyU64) => return Primitive(U64),
-            ast::TyFloat(ast::TyF32) => return Primitive(F32),
-            ast::TyFloat(ast::TyF64) => return Primitive(F64),
+            hir::TyStr => return Primitive(Str),
+            hir::TyBool => return Primitive(Bool),
+            hir::TyChar => return Primitive(Char),
+            hir::TyInt(hir::TyIs) => return Primitive(Isize),
+            hir::TyInt(hir::TyI8) => return Primitive(I8),
+            hir::TyInt(hir::TyI16) => return Primitive(I16),
+            hir::TyInt(hir::TyI32) => return Primitive(I32),
+            hir::TyInt(hir::TyI64) => return Primitive(I64),
+            hir::TyUint(hir::TyUs) => return Primitive(Usize),
+            hir::TyUint(hir::TyU8) => return Primitive(U8),
+            hir::TyUint(hir::TyU16) => return Primitive(U16),
+            hir::TyUint(hir::TyU32) => return Primitive(U32),
+            hir::TyUint(hir::TyU64) => return Primitive(U64),
+            hir::TyFloat(hir::TyF32) => return Primitive(F32),
+            hir::TyFloat(hir::TyF64) => return Primitive(F64),
         },
         def::DefSelfTy(..) if path.segments.len() == 1 => {
             return Generic(special_idents::type_self.name.to_string());
@@ -2677,7 +2667,7 @@ impl Clean<Item> for doctree::Macro {
             name: Some(format!("{}!", self.name.clean(cx))),
             attrs: self.attrs.clean(cx),
             source: self.whence.clean(cx),
-            visibility: ast::Public.clean(cx),
+            visibility: hir::Public.clean(cx),
             stability: self.stab.clean(cx),
             def_id: DefId::local(self.id),
             inner: MacroItem(Macro {
@@ -2849,7 +2839,7 @@ pub struct TypeBinding {
     pub ty: Type
 }
 
-impl Clean<TypeBinding> for ast::TypeBinding {
+impl Clean<TypeBinding> for hir::TypeBinding {
     fn clean(&self, cx: &DocContext) -> TypeBinding {
         TypeBinding {
             name: self.ident.clean(cx),
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 89b87eb73d6..63468dd55f8 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -14,10 +14,12 @@ use rustc_driver::{driver, target_features};
 use rustc::session::{self, config};
 use rustc::middle::def_id::DefId;
 use rustc::middle::{privacy, ty};
-use rustc::ast_map;
+use rustc::front::map as hir_map;
 use rustc::lint;
 use rustc_trans::back::link;
 use rustc_resolve as resolve;
+use rustc_front::lowering::lower_crate;
+use rustc_front::hir;
 
 use syntax::{ast, codemap, diagnostic};
 use syntax::feature_gate::UnstableFeatures;
@@ -42,7 +44,7 @@ pub type ExternalPaths = RefCell<Option<HashMap<DefId,
                                                 (Vec<String>, clean::TypeKind)>>>;
 
 pub struct DocContext<'a, 'tcx: 'a> {
-    pub krate: &'tcx ast::Crate,
+    pub krate: &'tcx hir::Crate,
     pub maybe_typed: MaybeTyped<'a, 'tcx>,
     pub input: Input,
     pub external_paths: ExternalPaths,
@@ -131,12 +133,15 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
     let krate = driver::phase_2_configure_and_expand(&sess, krate, &name, None)
                     .expect("phase_2_configure_and_expand aborted in rustdoc!");
 
-    let mut forest = ast_map::Forest::new(krate);
+    let krate = driver::assign_node_ids(&sess, krate);
+    // Lower ast -> hir.
+    let mut hir_forest = hir_map::Forest::new(lower_crate(&krate));
     let arenas = ty::CtxtArenas::new();
-    let ast_map = driver::assign_node_ids_and_map(&sess, &mut forest);
+    let hir_map = driver::make_map(&sess, &mut hir_forest);
 
     driver::phase_3_run_analysis_passes(sess,
-                                        ast_map,
+                                        hir_map,
+                                        &krate,
                                         &arenas,
                                         name,
                                         resolve::MakeGlobMap::No,
diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs
index cadd43ec6bf..5140cca03ea 100644
--- a/src/librustdoc/doctree.rs
+++ b/src/librustdoc/doctree.rs
@@ -17,13 +17,14 @@ use syntax;
 use syntax::codemap::Span;
 use syntax::abi;
 use syntax::ast;
-use syntax::attr;
 use syntax::ast::{Ident, NodeId};
 use syntax::ptr::P;
+use rustc_front::hir;
+use rustc_front::attr;
 
 pub struct Module {
     pub name: Option<Ident>,
-    pub attrs: Vec<ast::Attribute>,
+    pub attrs: Vec<hir::Attribute>,
     pub where_outer: Span,
     pub where_inner: Span,
     pub extern_crates: Vec<ExternCrate>,
@@ -37,11 +38,11 @@ pub struct Module {
     pub statics: Vec<Static>,
     pub constants: Vec<Constant>,
     pub traits: Vec<Trait>,
-    pub vis: ast::Visibility,
+    pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
     pub impls: Vec<Impl>,
     pub def_traits: Vec<DefaultImpl>,
-    pub foreigns: Vec<ast::ForeignMod>,
+    pub foreigns: Vec<hir::ForeignMod>,
     pub macros: Vec<Macro>,
     pub is_crate: bool,
 }
@@ -51,7 +52,7 @@ impl Module {
         Module {
             name       : name,
             id: 0,
-            vis: ast::Inherited,
+            vis: hir::Inherited,
             stab: None,
             where_outer: syntax::codemap::DUMMY_SP,
             where_inner: syntax::codemap::DUMMY_SP,
@@ -89,27 +90,27 @@ pub enum StructType {
 
 pub enum TypeBound {
     RegionBound,
-    TraitBound(ast::TraitRef)
+    TraitBound(hir::TraitRef)
 }
 
 pub struct Struct {
-    pub vis: ast::Visibility,
+    pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
     pub id: NodeId,
     pub struct_type: StructType,
     pub name: Ident,
-    pub generics: ast::Generics,
-    pub attrs: Vec<ast::Attribute>,
-    pub fields: Vec<ast::StructField>,
+    pub generics: hir::Generics,
+    pub attrs: Vec<hir::Attribute>,
+    pub fields: Vec<hir::StructField>,
     pub whence: Span,
 }
 
 pub struct Enum {
-    pub vis: ast::Visibility,
+    pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
     pub variants: Vec<Variant>,
-    pub generics: ast::Generics,
-    pub attrs: Vec<ast::Attribute>,
+    pub generics: hir::Generics,
+    pub attrs: Vec<hir::Attribute>,
     pub id: NodeId,
     pub whence: Span,
     pub name: Ident,
@@ -117,102 +118,102 @@ pub struct Enum {
 
 pub struct Variant {
     pub name: Ident,
-    pub attrs: Vec<ast::Attribute>,
-    pub kind: ast::VariantKind,
+    pub attrs: Vec<hir::Attribute>,
+    pub kind: hir::VariantKind,
     pub id: ast::NodeId,
-    pub vis: ast::Visibility,
+    pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
     pub whence: Span,
 }
 
 pub struct Function {
-    pub decl: ast::FnDecl,
-    pub attrs: Vec<ast::Attribute>,
+    pub decl: hir::FnDecl,
+    pub attrs: Vec<hir::Attribute>,
     pub id: NodeId,
     pub name: Ident,
-    pub vis: ast::Visibility,
+    pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
-    pub unsafety: ast::Unsafety,
-    pub constness: ast::Constness,
+    pub unsafety: hir::Unsafety,
+    pub constness: hir::Constness,
     pub whence: Span,
-    pub generics: ast::Generics,
+    pub generics: hir::Generics,
     pub abi: abi::Abi,
 }
 
 pub struct Typedef {
-    pub ty: P<ast::Ty>,
-    pub gen: ast::Generics,
+    pub ty: P<hir::Ty>,
+    pub gen: hir::Generics,
     pub name: Ident,
     pub id: ast::NodeId,
-    pub attrs: Vec<ast::Attribute>,
+    pub attrs: Vec<hir::Attribute>,
     pub whence: Span,
-    pub vis: ast::Visibility,
+    pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
 }
 
 #[derive(Debug)]
 pub struct Static {
-    pub type_: P<ast::Ty>,
-    pub mutability: ast::Mutability,
-    pub expr: P<ast::Expr>,
+    pub type_: P<hir::Ty>,
+    pub mutability: hir::Mutability,
+    pub expr: P<hir::Expr>,
     pub name: Ident,
-    pub attrs: Vec<ast::Attribute>,
-    pub vis: ast::Visibility,
+    pub attrs: Vec<hir::Attribute>,
+    pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
     pub id: ast::NodeId,
     pub whence: Span,
 }
 
 pub struct Constant {
-    pub type_: P<ast::Ty>,
-    pub expr: P<ast::Expr>,
+    pub type_: P<hir::Ty>,
+    pub expr: P<hir::Expr>,
     pub name: Ident,
-    pub attrs: Vec<ast::Attribute>,
-    pub vis: ast::Visibility,
+    pub attrs: Vec<hir::Attribute>,
+    pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
     pub id: ast::NodeId,
     pub whence: Span,
 }
 
 pub struct Trait {
-    pub unsafety: ast::Unsafety,
+    pub unsafety: hir::Unsafety,
     pub name: Ident,
-    pub items: Vec<P<ast::TraitItem>>, //should be TraitItem
-    pub generics: ast::Generics,
-    pub bounds: Vec<ast::TyParamBound>,
-    pub attrs: Vec<ast::Attribute>,
+    pub items: Vec<P<hir::TraitItem>>, //should be TraitItem
+    pub generics: hir::Generics,
+    pub bounds: Vec<hir::TyParamBound>,
+    pub attrs: Vec<hir::Attribute>,
     pub id: ast::NodeId,
     pub whence: Span,
-    pub vis: ast::Visibility,
+    pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
 }
 
 pub struct Impl {
-    pub unsafety: ast::Unsafety,
-    pub polarity: ast::ImplPolarity,
-    pub generics: ast::Generics,
-    pub trait_: Option<ast::TraitRef>,
-    pub for_: P<ast::Ty>,
-    pub items: Vec<P<ast::ImplItem>>,
-    pub attrs: Vec<ast::Attribute>,
+    pub unsafety: hir::Unsafety,
+    pub polarity: hir::ImplPolarity,
+    pub generics: hir::Generics,
+    pub trait_: Option<hir::TraitRef>,
+    pub for_: P<hir::Ty>,
+    pub items: Vec<P<hir::ImplItem>>,
+    pub attrs: Vec<hir::Attribute>,
     pub whence: Span,
-    pub vis: ast::Visibility,
+    pub vis: hir::Visibility,
     pub stab: Option<attr::Stability>,
     pub id: ast::NodeId,
 }
 
 pub struct DefaultImpl {
-    pub unsafety: ast::Unsafety,
-    pub trait_: ast::TraitRef,
+    pub unsafety: hir::Unsafety,
+    pub trait_: hir::TraitRef,
     pub id: ast::NodeId,
-    pub attrs: Vec<ast::Attribute>,
+    pub attrs: Vec<hir::Attribute>,
     pub whence: Span,
 }
 
 pub struct Macro {
     pub name: Ident,
     pub id: ast::NodeId,
-    pub attrs: Vec<ast::Attribute>,
+    pub attrs: Vec<hir::Attribute>,
     pub whence: Span,
     pub stab: Option<attr::Stability>,
     pub imported_from: Option<Ident>,
@@ -221,20 +222,20 @@ pub struct Macro {
 pub struct ExternCrate {
     pub name: Ident,
     pub path: Option<String>,
-    pub vis: ast::Visibility,
-    pub attrs: Vec<ast::Attribute>,
+    pub vis: hir::Visibility,
+    pub attrs: Vec<hir::Attribute>,
     pub whence: Span,
 }
 
 pub struct Import {
     pub id: NodeId,
-    pub vis: ast::Visibility,
-    pub attrs: Vec<ast::Attribute>,
-    pub node: ast::ViewPath_,
+    pub vis: hir::Visibility,
+    pub attrs: Vec<hir::Attribute>,
+    pub node: hir::ViewPath_,
     pub whence: Span,
 }
 
-pub fn struct_type_from_def(sd: &ast::StructDef) -> StructType {
+pub fn struct_type_from_def(sd: &hir::StructDef) -> StructType {
     if sd.ctor_id.is_some() {
         // We are in a tuple-struct
         match sd.fields.len() {
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index bad36ecd054..947ae3abd8d 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -21,6 +21,7 @@ use std::iter::repeat;
 use rustc::middle::def_id::{DefId, LOCAL_CRATE};
 use syntax::abi::Abi;
 use syntax::ast;
+use rustc_front::hir;
 
 use clean;
 use html::item_type::ItemType;
@@ -30,15 +31,15 @@ use html::render::{cache, CURRENT_LOCATION_KEY};
 /// Helper to render an optional visibility with a space after it (if the
 /// visibility is preset)
 #[derive(Copy, Clone)]
-pub struct VisSpace(pub Option<ast::Visibility>);
+pub struct VisSpace(pub Option<hir::Visibility>);
 /// Similarly to VisSpace, this structure is used to render a function style with a
 /// space after it.
 #[derive(Copy, Clone)]
-pub struct UnsafetySpace(pub ast::Unsafety);
+pub struct UnsafetySpace(pub hir::Unsafety);
 /// Similarly to VisSpace, this structure is used to render a function constness
 /// with a space after it.
 #[derive(Copy, Clone)]
-pub struct ConstnessSpace(pub ast::Constness);
+pub struct ConstnessSpace(pub hir::Constness);
 /// Wrapper struct for properly emitting a method declaration.
 pub struct Method<'a>(pub &'a clean::SelfTy, pub &'a clean::FnDecl);
 /// Similar to VisSpace, but used for mutability
@@ -56,19 +57,19 @@ pub struct CommaSep<'a, T: 'a>(pub &'a [T]);
 pub struct AbiSpace(pub Abi);
 
 impl VisSpace {
-    pub fn get(&self) -> Option<ast::Visibility> {
+    pub fn get(&self) -> Option<hir::Visibility> {
         let VisSpace(v) = *self; v
     }
 }
 
 impl UnsafetySpace {
-    pub fn get(&self) -> ast::Unsafety {
+    pub fn get(&self) -> hir::Unsafety {
         let UnsafetySpace(v) = *self; v
     }
 }
 
 impl ConstnessSpace {
-    pub fn get(&self) -> ast::Constness {
+    pub fn get(&self) -> hir::Constness {
         let ConstnessSpace(v) = *self; v
     }
 }
@@ -201,8 +202,8 @@ impl fmt::Display for clean::TyParamBound {
             }
             clean::TraitBound(ref ty, modifier) => {
                 let modifier_str = match modifier {
-                    ast::TraitBoundModifier::None => "",
-                    ast::TraitBoundModifier::Maybe => "?",
+                    hir::TraitBoundModifier::None => "",
+                    hir::TraitBoundModifier::Maybe => "?",
                 };
                 write!(f, "{}{}", modifier_str, *ty)
             }
@@ -618,8 +619,8 @@ impl<'a> fmt::Display for Method<'a> {
 impl fmt::Display for VisSpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.get() {
-            Some(ast::Public) => write!(f, "pub "),
-            Some(ast::Inherited) | None => Ok(())
+            Some(hir::Public) => write!(f, "pub "),
+            Some(hir::Inherited) | None => Ok(())
         }
     }
 }
@@ -627,8 +628,8 @@ impl fmt::Display for VisSpace {
 impl fmt::Display for UnsafetySpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.get() {
-            ast::Unsafety::Unsafe => write!(f, "unsafe "),
-            ast::Unsafety::Normal => Ok(())
+            hir::Unsafety::Unsafe => write!(f, "unsafe "),
+            hir::Unsafety::Normal => Ok(())
         }
     }
 }
@@ -636,8 +637,8 @@ impl fmt::Display for UnsafetySpace {
 impl fmt::Display for ConstnessSpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.get() {
-            ast::Constness::Const => write!(f, "const "),
-            ast::Constness::NotConst => Ok(())
+            hir::Constness::Const => write!(f, "const "),
+            hir::Constness::NotConst => Ok(())
         }
     }
 }
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index e2248b1204e..86b268001a6 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -52,9 +52,10 @@ use std::sync::Arc;
 use externalfiles::ExternalHtml;
 
 use serialize::json::{self, ToJson};
-use syntax::{abi, ast, attr};
+use syntax::{abi, ast};
 use rustc::middle::def_id::{DefId, LOCAL_CRATE};
 use rustc::util::nodemap::NodeSet;
+use rustc_front::{hir, attr};
 
 use clean::{self, SelfTy};
 use doctree;
@@ -858,7 +859,7 @@ impl DocFolder for Cache {
         let orig_privmod = match item.inner {
             clean::ModuleItem(..) => {
                 let prev = self.privmod;
-                self.privmod = prev || (self.remove_priv && item.visibility != Some(ast::Public));
+                self.privmod = prev || (self.remove_priv && item.visibility != Some(hir::Public));
                 prev
             }
             _ => self.privmod,
@@ -1327,10 +1328,10 @@ impl Context {
             clean::ModuleItem(ref m) => {
                 (m.items.is_empty() &&
                  it.doc_value().is_none() &&
-                 it.visibility != Some(ast::Public)) ||
-                (self.passes.contains("strip-private") && it.visibility != Some(ast::Public))
+                 it.visibility != Some(hir::Public)) ||
+                (self.passes.contains("strip-private") && it.visibility != Some(hir::Public))
             }
-            clean::PrimitiveItem(..) => it.visibility != Some(ast::Public),
+            clean::PrimitiveItem(..) => it.visibility != Some(hir::Public),
             _ => false,
         }
     }
@@ -1975,8 +1976,8 @@ fn render_assoc_item(w: &mut fmt::Formatter, meth: &clean::Item,
                      link: AssocItemLink) -> fmt::Result {
     fn method(w: &mut fmt::Formatter,
               it: &clean::Item,
-              unsafety: ast::Unsafety,
-              constness: ast::Constness,
+              unsafety: hir::Unsafety,
+              constness: hir::Constness,
               abi: abi::Abi,
               g: &clean::Generics,
               selfty: &clean::SelfTy,
@@ -2009,7 +2010,7 @@ fn render_assoc_item(w: &mut fmt::Formatter, meth: &clean::Item,
     }
     match meth.inner {
         clean::TyMethodItem(ref m) => {
-            method(w, meth, m.unsafety, ast::Constness::NotConst,
+            method(w, meth, m.unsafety, hir::Constness::NotConst,
                    m.abi, &m.generics, &m.self_, &m.decl, link)
         }
         clean::MethodItem(ref m) => {
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 933f9cab7f7..efe5a73fad2 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -43,6 +43,7 @@ extern crate rustc_driver;
 extern crate rustc_resolve;
 extern crate rustc_lint;
 extern crate rustc_back;
+extern crate rustc_front;
 extern crate serialize;
 extern crate syntax;
 extern crate test as testing;
diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs
index 3d255977cb5..c11d9b8e31d 100644
--- a/src/librustdoc/passes.rs
+++ b/src/librustdoc/passes.rs
@@ -14,6 +14,7 @@ use std::cmp;
 use std::string::String;
 use std::usize;
 use syntax::ast;
+use rustc_front::hir;
 
 use clean;
 use clean::Item;
@@ -135,7 +136,7 @@ impl<'a> fold::DocFolder for Stripper<'a> {
                         return None;
                     }
                     // Traits are in exported_items even when they're totally private.
-                    if i.is_trait() && i.visibility != Some(ast::Public) {
+                    if i.is_trait() && i.visibility != Some(hir::Public) {
                         return None;
                     }
                 }
@@ -149,13 +150,13 @@ impl<'a> fold::DocFolder for Stripper<'a> {
             }
 
             clean::ExternCrateItem(..) | clean::ImportItem(_) => {
-                if i.visibility != Some(ast::Public) {
+                if i.visibility != Some(hir::Public) {
                     return None
                 }
             }
 
             clean::StructFieldItem(..) => {
-                if i.visibility != Some(ast::Public) {
+                if i.visibility != Some(hir::Public) {
                     return Some(clean::Item {
                         inner: clean::StructFieldItem(clean::HiddenStructField),
                         ..i
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs
index 3ce2922c4c9..95215cf2d5c 100644
--- a/src/librustdoc/test.rs
+++ b/src/librustdoc/test.rs
@@ -25,6 +25,7 @@ use rustc_lint;
 use rustc::session::{self, config};
 use rustc::session::config::get_unstable_features_setting;
 use rustc::session::search_paths::{SearchPaths, PathKind};
+use rustc_front::lowering::lower_crate;
 use rustc_back::tempdir::TempDir;
 use rustc_driver::{driver, Compilation};
 use syntax::codemap::CodeMap;
@@ -80,6 +81,8 @@ pub fn run(input: &str,
     let krate = driver::phase_2_configure_and_expand(&sess, krate,
                                                      "rustdoc-test", None)
         .expect("phase_2_configure_and_expand aborted in rustdoc!");
+    let krate = driver::assign_node_ids(&sess, krate);
+    let krate = lower_crate(&krate);
 
     let opts = scrape_test_config(&krate);
 
@@ -120,9 +123,9 @@ pub fn run(input: &str,
 }
 
 // Look for #![doc(test(no_crate_inject))], used by crates in the std facade
-fn scrape_test_config(krate: &::syntax::ast::Crate) -> TestOptions {
-    use syntax::attr::AttrMetaMethods;
-    use syntax::print::pprust;
+fn scrape_test_config(krate: &::rustc_front::hir::Crate) -> TestOptions {
+    use rustc_front::attr::AttrMetaMethods;
+    use rustc_front::print::pprust;
 
     let mut opts = TestOptions {
         no_crate_inject: false,
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index e7bbe943952..978b572ac93 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -16,14 +16,16 @@ use std::mem;
 
 use syntax::abi;
 use syntax::ast;
-use syntax::attr;
-use syntax::attr::AttrMetaMethods;
 use syntax::codemap::Span;
 
-use rustc::ast_map;
+use rustc::front::map as hir_map;
 use rustc::middle::def_id::DefId;
 use rustc::middle::stability;
 
+use rustc_front::attr;
+use rustc_front::attr::AttrMetaMethods;
+use rustc_front::hir;
+
 use core;
 use doctree::*;
 
@@ -37,7 +39,7 @@ use doctree::*;
 
 pub struct RustdocVisitor<'a, 'tcx: 'a> {
     pub module: Module,
-    pub attrs: Vec<ast::Attribute>,
+    pub attrs: Vec<hir::Attribute>,
     pub cx: &'a core::DocContext<'a, 'tcx>,
     pub analysis: Option<&'a core::CrateAnalysis>,
     view_item_stack: HashSet<ast::NodeId>,
@@ -65,12 +67,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
             |tcx| stability::lookup(tcx, DefId::local(id)).map(|x| x.clone()))
     }
 
-    pub fn visit(&mut self, krate: &ast::Crate) {
+    pub fn visit(&mut self, krate: &hir::Crate) {
         self.attrs = krate.attrs.clone();
 
         self.module = self.visit_mod_contents(krate.span,
                                               krate.attrs.clone(),
-                                              ast::Public,
+                                              hir::Public,
                                               ast::CRATE_NODE_ID,
                                               &krate.module,
                                               None);
@@ -80,9 +82,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
         self.module.is_crate = true;
     }
 
-    pub fn visit_struct_def(&mut self, item: &ast::Item,
-                            name: ast::Ident, sd: &ast::StructDef,
-                            generics: &ast::Generics) -> Struct {
+    pub fn visit_struct_def(&mut self, item: &hir::Item,
+                            name: ast::Ident, sd: &hir::StructDef,
+                            generics: &hir::Generics) -> Struct {
         debug!("Visiting struct");
         let struct_type = struct_type_from_def(&*sd);
         Struct {
@@ -98,9 +100,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
         }
     }
 
-    pub fn visit_enum_def(&mut self, it: &ast::Item,
-                          name: ast::Ident, def: &ast::EnumDef,
-                          params: &ast::Generics) -> Enum {
+    pub fn visit_enum_def(&mut self, it: &hir::Item,
+                          name: ast::Ident, def: &hir::EnumDef,
+                          params: &hir::Generics) -> Enum {
         debug!("Visiting enum");
         Enum {
             name: name,
@@ -122,12 +124,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
         }
     }
 
-    pub fn visit_fn(&mut self, item: &ast::Item,
-                    name: ast::Ident, fd: &ast::FnDecl,
-                    unsafety: &ast::Unsafety,
-                    constness: ast::Constness,
+    pub fn visit_fn(&mut self, item: &hir::Item,
+                    name: ast::Ident, fd: &hir::FnDecl,
+                    unsafety: &hir::Unsafety,
+                    constness: hir::Constness,
                     abi: &abi::Abi,
-                    gen: &ast::Generics) -> Function {
+                    gen: &hir::Generics) -> Function {
         debug!("Visiting fn");
         Function {
             id: item.id,
@@ -144,9 +146,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
         }
     }
 
-    pub fn visit_mod_contents(&mut self, span: Span, attrs: Vec<ast::Attribute> ,
-                              vis: ast::Visibility, id: ast::NodeId,
-                              m: &ast::Mod,
+    pub fn visit_mod_contents(&mut self, span: Span, attrs: Vec<hir::Attribute> ,
+                              vis: hir::Visibility, id: ast::NodeId,
+                              m: &hir::Mod,
                               name: Option<ast::Ident>) -> Module {
         let mut om = Module::new(name);
         om.where_outer = span;
@@ -161,37 +163,37 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
         om
     }
 
-    fn visit_view_path(&mut self, path: ast::ViewPath_,
+    fn visit_view_path(&mut self, path: hir::ViewPath_,
                        om: &mut Module,
                        id: ast::NodeId,
-                       please_inline: bool) -> Option<ast::ViewPath_> {
+                       please_inline: bool) -> Option<hir::ViewPath_> {
         match path {
-            ast::ViewPathSimple(dst, base) => {
+            hir::ViewPathSimple(dst, base) => {
                 if self.resolve_id(id, Some(dst), false, om, please_inline) {
                     None
                 } else {
-                    Some(ast::ViewPathSimple(dst, base))
+                    Some(hir::ViewPathSimple(dst, base))
                 }
             }
-            ast::ViewPathList(p, paths) => {
+            hir::ViewPathList(p, paths) => {
                 let mine = paths.into_iter().filter(|path| {
                     !self.resolve_id(path.node.id(), None, false, om,
                                      please_inline)
-                }).collect::<Vec<ast::PathListItem>>();
+                }).collect::<Vec<hir::PathListItem>>();
 
                 if mine.is_empty() {
                     None
                 } else {
-                    Some(ast::ViewPathList(p, mine))
+                    Some(hir::ViewPathList(p, mine))
                 }
             }
 
             // these are feature gated anyway
-            ast::ViewPathGlob(base) => {
+            hir::ViewPathGlob(base) => {
                 if self.resolve_id(id, None, true, om, please_inline) {
                     None
                 } else {
-                    Some(ast::ViewPathGlob(base))
+                    Some(hir::ViewPathGlob(base))
                 }
             }
         }
@@ -215,16 +217,16 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
         if !self.view_item_stack.insert(def.node) { return false }
 
         let ret = match tcx.map.get(def.node) {
-            ast_map::NodeItem(it) => {
+            hir_map::NodeItem(it) => {
                 if glob {
                     let prev = mem::replace(&mut self.inlining_from_glob, true);
                     match it.node {
-                        ast::ItemMod(ref m) => {
+                        hir::ItemMod(ref m) => {
                             for i in &m.items {
                                 self.visit_item(&**i, None, om);
                             }
                         }
-                        ast::ItemEnum(..) => {}
+                        hir::ItemEnum(..) => {}
                         _ => { panic!("glob not mapped to a module or enum"); }
                     }
                     self.inlining_from_glob = prev;
@@ -239,12 +241,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
         return ret;
     }
 
-    pub fn visit_item(&mut self, item: &ast::Item,
+    pub fn visit_item(&mut self, item: &hir::Item,
                       renamed: Option<ast::Ident>, om: &mut Module) {
         debug!("Visiting item {:?}", item);
         let name = renamed.unwrap_or(item.ident);
         match item.node {
-            ast::ItemExternCrate(ref p) => {
+            hir::ItemExternCrate(ref p) => {
                 let path = match *p {
                     None => None,
                     Some(x) => Some(x.to_string()),
@@ -257,9 +259,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                     whence: item.span,
                 })
             }
-            ast::ItemUse(ref vpath) => {
+            hir::ItemUse(ref vpath) => {
                 let node = vpath.node.clone();
-                let node = if item.vis == ast::Public {
+                let node = if item.vis == hir::Public {
                     let please_inline = item.attrs.iter().any(|item| {
                         match item.meta_item_list() {
                             Some(list) => {
@@ -283,7 +285,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                     whence: item.span,
                 });
             }
-            ast::ItemMod(ref m) => {
+            hir::ItemMod(ref m) => {
                 om.mods.push(self.visit_mod_contents(item.span,
                                                      item.attrs.clone(),
                                                      item.vis,
@@ -291,14 +293,14 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                                                      m,
                                                      Some(name)));
             },
-            ast::ItemEnum(ref ed, ref gen) =>
+            hir::ItemEnum(ref ed, ref gen) =>
                 om.enums.push(self.visit_enum_def(item, name, ed, gen)),
-            ast::ItemStruct(ref sd, ref gen) =>
+            hir::ItemStruct(ref sd, ref gen) =>
                 om.structs.push(self.visit_struct_def(item, name, &**sd, gen)),
-            ast::ItemFn(ref fd, ref unsafety, constness, ref abi, ref gen, _) =>
+            hir::ItemFn(ref fd, ref unsafety, constness, ref abi, ref gen, _) =>
                 om.fns.push(self.visit_fn(item, name, &**fd, unsafety,
                                           constness, abi, gen)),
-            ast::ItemTy(ref ty, ref gen) => {
+            hir::ItemTy(ref ty, ref gen) => {
                 let t = Typedef {
                     ty: ty.clone(),
                     gen: gen.clone(),
@@ -311,7 +313,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                 };
                 om.typedefs.push(t);
             },
-            ast::ItemStatic(ref ty, ref mut_, ref exp) => {
+            hir::ItemStatic(ref ty, ref mut_, ref exp) => {
                 let s = Static {
                     type_: ty.clone(),
                     mutability: mut_.clone(),
@@ -325,7 +327,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                 };
                 om.statics.push(s);
             },
-            ast::ItemConst(ref ty, ref exp) => {
+            hir::ItemConst(ref ty, ref exp) => {
                 let s = Constant {
                     type_: ty.clone(),
                     expr: exp.clone(),
@@ -338,7 +340,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                 };
                 om.constants.push(s);
             },
-            ast::ItemTrait(unsafety, ref gen, ref b, ref items) => {
+            hir::ItemTrait(unsafety, ref gen, ref b, ref items) => {
                 let t = Trait {
                     unsafety: unsafety,
                     name: name,
@@ -353,7 +355,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                 };
                 om.traits.push(t);
             },
-            ast::ItemImpl(unsafety, polarity, ref gen, ref tr, ref ty, ref items) => {
+            hir::ItemImpl(unsafety, polarity, ref gen, ref tr, ref ty, ref items) => {
                 let i = Impl {
                     unsafety: unsafety,
                     polarity: polarity,
@@ -373,7 +375,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                     om.impls.push(i);
                 }
             },
-            ast::ItemDefaultImpl(unsafety, ref trait_ref) => {
+            hir::ItemDefaultImpl(unsafety, ref trait_ref) => {
                 let i = DefaultImpl {
                     unsafety: unsafety,
                     trait_: trait_ref.clone(),
@@ -386,17 +388,14 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                     om.def_traits.push(i);
                 }
             }
-            ast::ItemForeignMod(ref fm) => {
+            hir::ItemForeignMod(ref fm) => {
                 om.foreigns.push(fm.clone());
             }
-            ast::ItemMac(_) => {
-                panic!("rustdoc: macros should be gone, after expansion");
-            }
         }
     }
 
     // convert each exported_macro into a doc item
-    fn visit_macro(&self, def: &ast::MacroDef) -> Macro {
+    fn visit_macro(&self, def: &hir::MacroDef) -> Macro {
         Macro {
             id: def.id,
             attrs: def.attrs.clone(),