]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/clean/mod.rs
Auto merge of #57760 - dlrobertson:varargs1, r=alexreg
[rust.git] / src / librustdoc / clean / mod.rs
index ea9034ae3a1e02718949aad9576bcef90c42f3a9..53dcc258c690b592495010d0e2046700d03f48c3 100644 (file)
@@ -20,7 +20,7 @@
 use rustc::hir::{self, GenericArg, HirVec};
 use rustc::hir::def::{self, Def, CtorKind};
 use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{InternalSubsts, SubstsRef};
 use rustc::ty::{self, TyCtxt, Region, RegionVid, Ty, AdtKind};
 use rustc::ty::fold::TypeFolder;
 use rustc::ty::layout::VariantIdx;
 
 use parking_lot::ReentrantMutex;
 
-use core::{self, DocContext};
-use doctree;
-use visit_ast;
-use html::render::{cache, ExternalLocation};
-use html::item_type::ItemType;
+use crate::core::{self, DocContext};
+use crate::doctree;
+use crate::visit_ast;
+use crate::html::render::{cache, ExternalLocation};
+use crate::html::item_type::ItemType;
+
 
 use self::cfg::Cfg;
 use self::auto_trait::AutoTraitFinder;
 const FN_OUTPUT_NAME: &'static str = "Output";
 
 // extract the stability index for a node from tcx, if possible
-fn get_stability(cx: &DocContext, def_id: DefId) -> Option<Stability> {
+fn get_stability(cx: &DocContext<'_, '_, '_>, def_id: DefId) -> Option<Stability> {
     cx.tcx.lookup_stability(def_id).clean(cx)
 }
 
-fn get_deprecation(cx: &DocContext, def_id: DefId) -> Option<Deprecation> {
+fn get_deprecation(cx: &DocContext<'_, '_, '_>, def_id: DefId) -> Option<Deprecation> {
     cx.tcx.lookup_deprecation(def_id).clean(cx)
 }
 
 pub trait Clean<T> {
-    fn clean(&self, cx: &DocContext) -> T;
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> T;
 }
 
 impl<T: Clean<U>, U> Clean<Vec<U>> for [T] {
-    fn clean(&self, cx: &DocContext) -> Vec<U> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<U> {
         self.iter().map(|x| x.clean(cx)).collect()
     }
 }
 
 impl<T: Clean<U>, U, V: Idx> Clean<IndexVec<V, U>> for IndexVec<V, T> {
-    fn clean(&self, cx: &DocContext) -> IndexVec<V, U> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> IndexVec<V, U> {
         self.iter().map(|x| x.clean(cx)).collect()
     }
 }
 
 impl<T: Clean<U>, U> Clean<U> for P<T> {
-    fn clean(&self, cx: &DocContext) -> U {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> U {
         (**self).clean(cx)
     }
 }
 
 impl<T: Clean<U>, U> Clean<U> for Rc<T> {
-    fn clean(&self, cx: &DocContext) -> U {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> U {
         (**self).clean(cx)
     }
 }
 
 impl<T: Clean<U>, U> Clean<Option<U>> for Option<T> {
-    fn clean(&self, cx: &DocContext) -> Option<U> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<U> {
         self.as_ref().map(|v| v.clean(cx))
     }
 }
 
 impl<T, U> Clean<U> for ty::Binder<T> where T: Clean<U> {
-    fn clean(&self, cx: &DocContext) -> U {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> U {
         self.skip_binder().clean(cx)
     }
 }
 
 impl<T: Clean<U>, U> Clean<Vec<U>> for P<[T]> {
-    fn clean(&self, cx: &DocContext) -> Vec<U> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<U> {
         self.iter().map(|x| x.clean(cx)).collect()
     }
 }
@@ -139,8 +140,8 @@ pub struct Crate {
 }
 
 impl<'a, 'tcx, 'rcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx, 'rcx> {
-    fn clean(&self, cx: &DocContext) -> Crate {
-        use ::visit_lib::LibEmbargoVisitor;
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Crate {
+        use crate::visit_lib::LibEmbargoVisitor;
 
         {
             let mut r = cx.renderinfo.borrow_mut();
@@ -233,7 +234,7 @@ pub struct ExternalCrate {
 }
 
 impl Clean<ExternalCrate> for CrateNum {
-    fn clean(&self, cx: &DocContext) -> ExternalCrate {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> ExternalCrate {
         let root = DefId { krate: *self, index: CRATE_DEF_INDEX };
         let krate_span = cx.tcx.def_span(root);
         let krate_src = cx.sess().source_map().span_to_filename(krate_span);
@@ -365,7 +366,7 @@ pub struct Item {
 }
 
 impl fmt::Debug for Item {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
 
         let fake = MAX_DEF_ID.with(|m| m.borrow().get(&self.def_id.krate)
                                    .map(|id| self.def_id >= *id).unwrap_or(false));
@@ -581,7 +582,7 @@ pub struct Module {
 }
 
 impl Clean<Item> for doctree::Module {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         let name = if self.name.is_some() {
             self.name.expect("No name provided").clean(cx)
         } else {
@@ -949,7 +950,8 @@ pub fn collapsed_doc_value(&self) -> Option<String> {
     ///
     /// Cache must be populated before call
     pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> {
-        use html::format::href;
+        use crate::html::format::href;
+
         self.links.iter().filter_map(|&(ref s, did, ref fragment)| {
             match did {
                 Some(did) => {
@@ -974,11 +976,13 @@ pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> {
                                 "https://doc.rust-lang.org/nightly",
                         };
                         // This is a primitive so the url is done "by hand".
+                        let tail = fragment.find('#').unwrap_or_else(|| fragment.len());
                         Some((s.clone(),
-                              format!("{}{}std/primitive.{}.html",
+                              format!("{}{}std/primitive.{}.html{}",
                                       url,
                                       if !url.ends_with('/') { "/" } else { "" },
-                                      fragment)))
+                                      &fragment[..tail],
+                                      &fragment[tail..])))
                     } else {
                         panic!("This isn't a primitive?!");
                     }
@@ -1019,7 +1023,7 @@ fn lists<'a>(&'a self, name: &'a str) -> ListAttributesIter<'a> {
 }
 
 impl Clean<Attributes> for [ast::Attribute] {
-    fn clean(&self, cx: &DocContext) -> Attributes {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Attributes {
         Attributes::from_ast(cx.sess().diagnostic(), self)
     }
 }
@@ -1031,7 +1035,7 @@ pub enum GenericBound {
 }
 
 impl GenericBound {
-    fn maybe_sized(cx: &DocContext) -> GenericBound {
+    fn maybe_sized(cx: &DocContext<'_, '_, '_>) -> GenericBound {
         let did = cx.tcx.require_lang_item(lang_items::SizedTraitLangItem);
         let empty = cx.tcx.intern_substs(&[]);
         let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
@@ -1048,7 +1052,7 @@ fn maybe_sized(cx: &DocContext) -> GenericBound {
         }, hir::TraitBoundModifier::Maybe)
     }
 
-    fn is_sized_bound(&self, cx: &DocContext) -> bool {
+    fn is_sized_bound(&self, cx: &DocContext<'_, '_, '_>) -> bool {
         use rustc::hir::TraitBoundModifier as TBM;
         if let GenericBound::TraitBound(PolyTrait { ref trait_, .. }, TBM::None) = *self {
             if trait_.def_id() == cx.tcx.lang_items().sized_trait() {
@@ -1074,7 +1078,7 @@ fn get_trait_type(&self) -> Option<Type> {
 }
 
 impl Clean<GenericBound> for hir::GenericBound {
-    fn clean(&self, cx: &DocContext) -> GenericBound {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericBound {
         match *self {
             hir::GenericBound::Outlives(lt) => GenericBound::Outlives(lt.clean(cx)),
             hir::GenericBound::Trait(ref t, modifier) => {
@@ -1084,8 +1088,8 @@ fn clean(&self, cx: &DocContext) -> GenericBound {
     }
 }
 
-fn external_generic_args(cx: &DocContext, trait_did: Option<DefId>, has_self: bool,
-                        bindings: Vec<TypeBinding>, substs: &Substs) -> GenericArgs {
+fn external_generic_args(cx: &DocContext<'_, '_, '_>, trait_did: Option<DefId>, has_self: bool,
+                        bindings: Vec<TypeBinding>, substs: SubstsRef<'_>) -> GenericArgs {
     let lifetimes = substs.regions().filter_map(|v| v.clean(cx)).collect();
     let types = substs.types().skip(has_self as usize).collect::<Vec<_>>();
 
@@ -1126,8 +1130,8 @@ fn external_generic_args(cx: &DocContext, trait_did: Option<DefId>, has_self: bo
 
 // trait_did should be set to a trait's DefId if called on a TraitRef, in order to sugar
 // from Fn<(A, B,), C> to Fn(A, B) -> C
-fn external_path(cx: &DocContext, name: &str, trait_did: Option<DefId>, has_self: bool,
-                 bindings: Vec<TypeBinding>, substs: &Substs) -> Path {
+fn external_path(cx: &DocContext<'_, '_, '_>, name: &str, trait_did: Option<DefId>, has_self: bool,
+                 bindings: Vec<TypeBinding>, substs: SubstsRef<'_>) -> Path {
     Path {
         global: false,
         def: Def::Err,
@@ -1139,7 +1143,7 @@ fn external_path(cx: &DocContext, name: &str, trait_did: Option<DefId>, has_self
 }
 
 impl<'a, 'tcx> Clean<GenericBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>) {
-    fn clean(&self, cx: &DocContext) -> GenericBound {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericBound {
         let (trait_ref, ref bounds) = *self;
         inline::record_extern_fqn(cx, trait_ref.def_id, TypeKind::Trait);
         let path = external_path(cx, &cx.tcx.item_name(trait_ref.def_id).as_str(),
@@ -1183,13 +1187,13 @@ fn clean(&self, cx: &DocContext) -> GenericBound {
 }
 
 impl<'tcx> Clean<GenericBound> for ty::TraitRef<'tcx> {
-    fn clean(&self, cx: &DocContext) -> GenericBound {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericBound {
         (self, vec![]).clean(cx)
     }
 }
 
-impl<'tcx> Clean<Option<Vec<GenericBound>>> for Substs<'tcx> {
-    fn clean(&self, cx: &DocContext) -> Option<Vec<GenericBound>> {
+impl<'tcx> Clean<Option<Vec<GenericBound>>> for InternalSubsts<'tcx> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<Vec<GenericBound>> {
         let mut v = Vec::new();
         v.extend(self.regions().filter_map(|r| r.clean(cx)).map(GenericBound::Outlives));
         v.extend(self.types().map(|t| GenericBound::TraitBound(PolyTrait {
@@ -1216,8 +1220,8 @@ pub fn statik() -> Lifetime {
 }
 
 impl Clean<Lifetime> for hir::Lifetime {
-    fn clean(&self, cx: &DocContext) -> Lifetime {
-        if self.id != ast::DUMMY_NODE_ID {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Lifetime {
+        if self.hir_id != hir::DUMMY_HIR_ID {
             let def = cx.tcx.named_region(self.hir_id);
             match def {
                 Some(rl::Region::EarlyBound(_, node_id, _)) |
@@ -1235,7 +1239,7 @@ fn clean(&self, cx: &DocContext) -> Lifetime {
 }
 
 impl Clean<Lifetime> for hir::GenericParam {
-    fn clean(&self, _: &DocContext) -> Lifetime {
+    fn clean(&self, _: &DocContext<'_, '_, '_>) -> Lifetime {
         match self.kind {
             hir::GenericParamKind::Lifetime { .. } => {
                 if self.bounds.len() > 0 {
@@ -1259,7 +1263,7 @@ fn clean(&self, _: &DocContext) -> Lifetime {
 }
 
 impl Clean<Constant> for hir::ConstArg {
-    fn clean(&self, cx: &DocContext) -> Constant {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Constant {
         Constant {
             type_: cx.tcx.type_of(cx.tcx.hir().body_owner_def_id(self.value.body)).clean(cx),
             expr: print_const_expr(cx, self.value.body),
@@ -1268,13 +1272,13 @@ fn clean(&self, cx: &DocContext) -> Constant {
 }
 
 impl<'tcx> Clean<Lifetime> for ty::GenericParamDef {
-    fn clean(&self, _cx: &DocContext) -> Lifetime {
+    fn clean(&self, _cx: &DocContext<'_, '_, '_>) -> Lifetime {
         Lifetime(self.name.to_string())
     }
 }
 
 impl Clean<Option<Lifetime>> for ty::RegionKind {
-    fn clean(&self, cx: &DocContext) -> Option<Lifetime> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<Lifetime> {
         match *self {
             ty::ReStatic => Some(Lifetime::statik()),
             ty::ReLateBound(_, ty::BrNamed(_, name)) => Some(Lifetime(name.to_string())),
@@ -1303,7 +1307,7 @@ pub enum WherePredicate {
 }
 
 impl Clean<WherePredicate> for hir::WherePredicate {
-    fn clean(&self, cx: &DocContext) -> WherePredicate {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> WherePredicate {
         match *self {
             hir::WherePredicate::BoundPredicate(ref wbp) => {
                 WherePredicate::BoundPredicate {
@@ -1330,7 +1334,7 @@ fn clean(&self, cx: &DocContext) -> WherePredicate {
 }
 
 impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
-    fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<WherePredicate> {
         use rustc::ty::Predicate;
 
         match *self {
@@ -1349,7 +1353,7 @@ fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
 }
 
 impl<'a> Clean<WherePredicate> for ty::TraitPredicate<'a> {
-    fn clean(&self, cx: &DocContext) -> WherePredicate {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> WherePredicate {
         WherePredicate::BoundPredicate {
             ty: self.trait_ref.self_ty().clean(cx),
             bounds: vec![self.trait_ref.clean(cx)]
@@ -1358,7 +1362,7 @@ fn clean(&self, cx: &DocContext) -> WherePredicate {
 }
 
 impl<'tcx> Clean<WherePredicate> for ty::SubtypePredicate<'tcx> {
-    fn clean(&self, _cx: &DocContext) -> WherePredicate {
+    fn clean(&self, _cx: &DocContext<'_, '_, '_>) -> WherePredicate {
         panic!("subtype predicates are an internal rustc artifact \
                 and should not be seen by rustdoc")
     }
@@ -1367,7 +1371,7 @@ fn clean(&self, _cx: &DocContext) -> WherePredicate {
 impl<'tcx> Clean<Option<WherePredicate>> for
     ty::OutlivesPredicate<ty::Region<'tcx>,ty::Region<'tcx>> {
 
-    fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<WherePredicate> {
         let ty::OutlivesPredicate(ref a, ref b) = *self;
 
         match (a, b) {
@@ -1385,7 +1389,7 @@ fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
 }
 
 impl<'tcx> Clean<Option<WherePredicate>> for ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>> {
-    fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<WherePredicate> {
         let ty::OutlivesPredicate(ref ty, ref lt) = *self;
 
         match lt {
@@ -1401,7 +1405,7 @@ fn clean(&self, cx: &DocContext) -> Option<WherePredicate> {
 }
 
 impl<'tcx> Clean<WherePredicate> for ty::ProjectionPredicate<'tcx> {
-    fn clean(&self, cx: &DocContext) -> WherePredicate {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> WherePredicate {
         WherePredicate::EqPredicate {
             lhs: self.projection_ty.clean(cx),
             rhs: self.ty.clean(cx)
@@ -1410,7 +1414,7 @@ fn clean(&self, cx: &DocContext) -> WherePredicate {
 }
 
 impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
-    fn clean(&self, cx: &DocContext) -> Type {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
         let trait_ = match self.trait_ref(cx.tcx).clean(cx) {
             GenericBound::TraitBound(t, _) => t.trait_,
             GenericBound::Outlives(_) => panic!("cleaning a trait got a lifetime"),
@@ -1458,7 +1462,7 @@ pub fn is_synthetic_type_param(&self) -> bool {
 }
 
 impl<'tcx> Clean<GenericParamDef> for ty::GenericParamDef {
-    fn clean(&self, cx: &DocContext) -> GenericParamDef {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericParamDef {
         let (name, kind) = match self.kind {
             ty::GenericParamDefKind::Lifetime => {
                 (self.name.to_string(), GenericParamDefKind::Lifetime)
@@ -1488,7 +1492,7 @@ fn clean(&self, cx: &DocContext) -> GenericParamDef {
 }
 
 impl Clean<GenericParamDef> for hir::GenericParam {
-    fn clean(&self, cx: &DocContext) -> GenericParamDef {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericParamDef {
         let (name, kind) = match self.kind {
             hir::GenericParamKind::Lifetime { .. } => {
                 let name = if self.bounds.len() > 0 {
@@ -1509,7 +1513,7 @@ fn clean(&self, cx: &DocContext) -> GenericParamDef {
             }
             hir::GenericParamKind::Type { ref default, synthetic } => {
                 (self.name.ident().name.clean(cx), GenericParamDefKind::Type {
-                    did: cx.tcx.hir().local_def_id(self.id),
+                    did: cx.tcx.hir().local_def_id_from_hir_id(self.hir_id),
                     bounds: self.bounds.clean(cx),
                     default: default.clean(cx),
                     synthetic: synthetic,
@@ -1517,7 +1521,7 @@ fn clean(&self, cx: &DocContext) -> GenericParamDef {
             }
             hir::GenericParamKind::Const { ref ty } => {
                 (self.name.ident().name.clean(cx), GenericParamDefKind::Const {
-                    did: cx.tcx.hir().local_def_id(self.id),
+                    did: cx.tcx.hir().local_def_id_from_hir_id(self.hir_id),
                     ty: ty.clean(cx),
                 })
             }
@@ -1538,7 +1542,7 @@ pub struct Generics {
 }
 
 impl Clean<Generics> for hir::Generics {
-    fn clean(&self, cx: &DocContext) -> Generics {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Generics {
         // Synthetic type-parameters are inserted after normal ones.
         // In order for normal parameters to be able to refer to synthetic ones,
         // scans them first.
@@ -1608,7 +1612,7 @@ fn is_impl_trait(param: &hir::GenericParam) -> bool {
 
 impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
                                     &'a Lrc<ty::GenericPredicates<'tcx>>) {
-    fn clean(&self, cx: &DocContext) -> Generics {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Generics {
         use self::WherePredicate as WP;
 
         let (gens, preds) = *self;
@@ -1689,7 +1693,7 @@ pub struct Method {
 }
 
 impl<'a> Clean<Method> for (&'a hir::MethodSig, &'a hir::Generics, hir::BodyId) {
-    fn clean(&self, cx: &DocContext) -> Method {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Method {
         let (generics, decl) = enter_impl_trait(cx, || {
             (self.1.clean(cx), (&*self.0.decl, self.2).clean(cx))
         });
@@ -1716,7 +1720,7 @@ pub struct Function {
 }
 
 impl Clean<Item> for doctree::Function {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         let (generics, decl) = enter_impl_trait(cx, || {
             (self.generics.clean(cx), (&self.decl, self.body).clean(cx))
         });
@@ -1748,7 +1752,6 @@ fn clean(&self, cx: &DocContext) -> Item {
 pub struct FnDecl {
     pub inputs: Arguments,
     pub output: FunctionRetTy,
-    pub variadic: bool,
     pub attrs: Attributes,
 }
 
@@ -1788,7 +1791,7 @@ pub struct Arguments {
 }
 
 impl<'a> Clean<Arguments> for (&'a [hir::Ty], &'a [ast::Ident]) {
-    fn clean(&self, cx: &DocContext) -> Arguments {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Arguments {
         Arguments {
             values: self.0.iter().enumerate().map(|(i, ty)| {
                 let mut name = self.1.get(i).map(|ident| ident.to_string())
@@ -1806,7 +1809,7 @@ fn clean(&self, cx: &DocContext) -> Arguments {
 }
 
 impl<'a> Clean<Arguments> for (&'a [hir::Ty], hir::BodyId) {
-    fn clean(&self, cx: &DocContext) -> Arguments {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Arguments {
         let body = cx.tcx.hir().body(self.1);
 
         Arguments {
@@ -1823,18 +1826,17 @@ fn clean(&self, cx: &DocContext) -> Arguments {
 impl<'a, A: Copy> Clean<FnDecl> for (&'a hir::FnDecl, A)
     where (&'a [hir::Ty], A): Clean<Arguments>
 {
-    fn clean(&self, cx: &DocContext) -> FnDecl {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> FnDecl {
         FnDecl {
             inputs: (&self.0.inputs[..], self.1).clean(cx),
             output: self.0.output.clean(cx),
-            variadic: self.0.variadic,
             attrs: Attributes::default()
         }
     }
 }
 
 impl<'a, 'tcx> Clean<FnDecl> for (DefId, ty::PolyFnSig<'tcx>) {
-    fn clean(&self, cx: &DocContext) -> FnDecl {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> FnDecl {
         let (did, sig) = *self;
         let mut names = if cx.tcx.hir().as_local_node_id(did).is_some() {
             vec![].into_iter()
@@ -1845,7 +1847,6 @@ fn clean(&self, cx: &DocContext) -> FnDecl {
         FnDecl {
             output: Return(sig.skip_binder().output().clean(cx)),
             attrs: Attributes::default(),
-            variadic: sig.skip_binder().variadic,
             inputs: Arguments {
                 values: sig.skip_binder().inputs().iter().map(|t| {
                     Argument {
@@ -1895,7 +1896,7 @@ pub enum FunctionRetTy {
 }
 
 impl Clean<FunctionRetTy> for hir::FunctionRetTy {
-    fn clean(&self, cx: &DocContext) -> FunctionRetTy {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> FunctionRetTy {
         match *self {
             hir::Return(ref typ) => Return(typ.clean(cx)),
             hir::DefaultReturn(..) => DefaultReturn,
@@ -1924,7 +1925,7 @@ pub struct Trait {
 }
 
 impl Clean<Item> for doctree::Trait {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         let attrs = self.attrs.clean(cx);
         let is_spotlight = attrs.has_doc_flag("spotlight");
         Item {
@@ -1955,7 +1956,7 @@ pub struct TraitAlias {
 }
 
 impl Clean<Item> for doctree::TraitAlias {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         let attrs = self.attrs.clean(cx);
         Item {
             name: Some(self.name.clean(cx)),
@@ -1974,7 +1975,7 @@ fn clean(&self, cx: &DocContext) -> Item {
 }
 
 impl Clean<bool> for hir::IsAuto {
-    fn clean(&self, _: &DocContext) -> bool {
+    fn clean(&self, _: &DocContext<'_, '_, '_>) -> bool {
         match *self {
             hir::IsAuto::Yes => true,
             hir::IsAuto::No => false,
@@ -1983,13 +1984,13 @@ fn clean(&self, _: &DocContext) -> bool {
 }
 
 impl Clean<Type> for hir::TraitRef {
-    fn clean(&self, cx: &DocContext) -> Type {
-        resolve_type(cx, self.path.clean(cx), self.ref_id)
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
+        resolve_type(cx, self.path.clean(cx), self.hir_ref_id)
     }
 }
 
 impl Clean<PolyTrait> for hir::PolyTraitRef {
-    fn clean(&self, cx: &DocContext) -> PolyTrait {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> PolyTrait {
         PolyTrait {
             trait_: self.trait_ref.clean(cx),
             generic_params: self.bound_generic_params.clean(cx)
@@ -1998,7 +1999,7 @@ fn clean(&self, cx: &DocContext) -> PolyTrait {
 }
 
 impl Clean<Item> for hir::TraitItem {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         let inner = match self.node {
             hir::TraitItemKind::Const(ref ty, default) => {
                 AssociatedConstItem(ty.clean(cx),
@@ -2035,7 +2036,7 @@ fn clean(&self, cx: &DocContext) -> Item {
 }
 
 impl Clean<Item> for hir::ImplItem {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         let inner = match self.node {
             hir::ImplItemKind::Const(ref ty, expr) => {
                 AssociatedConstItem(ty.clean(cx),
@@ -2067,7 +2068,7 @@ fn clean(&self, cx: &DocContext) -> Item {
 }
 
 impl<'tcx> Clean<Item> for ty::AssociatedItem {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         let inner = match self.kind {
             ty::AssociatedKind::Const => {
                 let ty = cx.tcx.type_of(self.def_id);
@@ -2248,6 +2249,7 @@ pub enum Type {
     Slice(Box<Type>),
     Array(Box<Type>, String),
     Never,
+    CVarArgs,
     Unique(Box<Type>),
     RawPointer(Mutability, Box<Type>),
     BorrowedRef {
@@ -2286,6 +2288,7 @@ pub enum PrimitiveType {
     Reference,
     Fn,
     Never,
+    CVarArgs,
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Copy, Debug)]
@@ -2385,7 +2388,7 @@ impl GetDefId for Type {
     fn def_id(&self) -> Option<DefId> {
         match *self {
             ResolvedPath { did, .. } => Some(did),
-            Primitive(p) => ::html::render::cache().primitive_locations.get(&p).cloned(),
+            Primitive(p) => crate::html::render::cache().primitive_locations.get(&p).cloned(),
             BorrowedRef { type_: box Generic(..), .. } =>
                 Primitive(PrimitiveType::Reference).def_id(),
             BorrowedRef { ref type_, .. } => type_.def_id(),
@@ -2465,6 +2468,7 @@ pub fn as_str(&self) -> &'static str {
             Reference => "reference",
             Fn => "fn",
             Never => "never",
+            CVarArgs => "...",
         }
     }
 
@@ -2509,11 +2513,12 @@ fn from(float_ty: ast::FloatTy) -> PrimitiveType {
 }
 
 impl Clean<Type> for hir::Ty {
-    fn clean(&self, cx: &DocContext) -> Type {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
         use rustc::hir::*;
 
         match self.node {
             TyKind::Never => Never,
+            TyKind::CVarArgs(_) => CVarArgs,
             TyKind::Ptr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)),
             TyKind::Rptr(ref l, ref m) => {
                 let lifetime = if l.is_elided() {
@@ -2528,7 +2533,7 @@ fn clean(&self, cx: &DocContext) -> Type {
             TyKind::Array(ref ty, ref length) => {
                 let def_id = cx.tcx.hir().local_def_id(length.id);
                 let param_env = cx.tcx.param_env(def_id);
-                let substs = Substs::identity_for_item(cx.tcx, def_id);
+                let substs = InternalSubsts::identity_for_item(cx.tcx, def_id);
                 let cid = GlobalId {
                     instance: ty::Instance::new(def_id, substs),
                     promoted: None
@@ -2562,9 +2567,9 @@ fn clean(&self, cx: &DocContext) -> Type {
                 let mut alias = None;
                 if let Def::TyAlias(def_id) = path.def {
                     // Substitute private type aliases
-                    if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) {
+                    if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(def_id) {
                         if !cx.renderinfo.borrow().access_levels.is_exported(def_id) {
-                            alias = Some(&cx.tcx.hir().expect_item(node_id).node);
+                            alias = Some(&cx.tcx.hir().expect_item_by_hir_id(hir_id).node);
                         }
                     }
                 };
@@ -2595,7 +2600,7 @@ fn clean(&self, cx: &DocContext) -> Type {
                                     if let Some(lt) = lifetime.cloned() {
                                         if !lt.is_elided() {
                                             let lt_def_id =
-                                                cx.tcx.hir().local_def_id(param.id);
+                                                cx.tcx.hir().local_def_id_from_hir_id(param.hir_id);
                                             lt_substs.insert(lt_def_id, lt.clean(cx));
                                         }
                                     }
@@ -2603,7 +2608,8 @@ fn clean(&self, cx: &DocContext) -> Type {
                                 }
                                 hir::GenericParamKind::Type { ref default, .. } => {
                                     let ty_param_def =
-                                        Def::TyParam(cx.tcx.hir().local_def_id(param.id));
+                                        Def::TyParam(
+                                            cx.tcx.hir().local_def_id_from_hir_id(param.hir_id));
                                     let mut j = 0;
                                     let type_ = generic_args.args.iter().find_map(|arg| {
                                         match arg {
@@ -2627,7 +2633,8 @@ fn clean(&self, cx: &DocContext) -> Type {
                                 }
                                 hir::GenericParamKind::Const { .. } => {
                                     let const_param_def =
-                                        Def::ConstParam(cx.tcx.hir().local_def_id(param.id));
+                                        Def::ConstParam(
+                                            cx.tcx.hir().local_def_id_from_hir_id(param.hir_id));
                                     let mut j = 0;
                                     let const_ = generic_args.args.iter().find_map(|arg| {
                                         match arg {
@@ -2652,7 +2659,7 @@ fn clean(&self, cx: &DocContext) -> Type {
                     });
                     return cx.enter_alias(ty_substs, lt_substs, const_substs, || ty.clean(cx));
                 }
-                resolve_type(cx, path.clean(cx), self.id)
+                resolve_type(cx, path.clean(cx), self.hir_id)
             }
             TyKind::Path(hir::QPath::Resolved(Some(ref qself), ref p)) => {
                 let mut segments: Vec<_> = p.segments.clone().into();
@@ -2665,7 +2672,7 @@ fn clean(&self, cx: &DocContext) -> Type {
                 Type::QPath {
                     name: p.segments.last().expect("segments were empty").ident.name.clean(cx),
                     self_type: box qself.clean(cx),
-                    trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
+                    trait_: box resolve_type(cx, trait_path.clean(cx), self.hir_id)
                 }
             }
             TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => {
@@ -2682,7 +2689,7 @@ fn clean(&self, cx: &DocContext) -> Type {
                 Type::QPath {
                     name: segment.ident.name.clean(cx),
                     self_type: box qself.clean(cx),
-                    trait_: box resolve_type(cx, trait_path.clean(cx), self.id)
+                    trait_: box resolve_type(cx, trait_path.clean(cx), self.hir_id)
                 }
             }
             TyKind::TraitObject(ref bounds, ref lifetime) => {
@@ -2708,7 +2715,7 @@ fn clean(&self, cx: &DocContext) -> Type {
 }
 
 impl<'tcx> Clean<Type> for Ty<'tcx> {
-    fn clean(&self, cx: &DocContext) -> Type {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
         match self.sty {
             ty::Never => Never,
             ty::Bool => Primitive(PrimitiveType::Bool),
@@ -2770,7 +2777,7 @@ fn clean(&self, cx: &DocContext) -> Type {
             ty::Foreign(did) => {
                 inline::record_extern_fqn(cx, did, TypeKind::Foreign);
                 let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
-                                         None, false, vec![], Substs::empty());
+                                         None, false, vec![], InternalSubsts::empty());
                 ResolvedPath {
                     path: path,
                     typarams: None,
@@ -2903,7 +2910,7 @@ fn clean(&self, cx: &DocContext) -> Type {
 }
 
 impl Clean<Item> for hir::StructField {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         Item {
             name: Some(self.ident.name).clean(cx),
             attrs: self.attrs.clean(cx),
@@ -2918,7 +2925,7 @@ fn clean(&self, cx: &DocContext) -> Item {
 }
 
 impl<'tcx> Clean<Item> for ty::FieldDef {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         Item {
             name: Some(self.ident.name).clean(cx),
             attrs: cx.tcx.get_attrs(self.did).clean(cx),
@@ -2941,7 +2948,7 @@ pub enum Visibility {
 }
 
 impl Clean<Option<Visibility>> for hir::Visibility {
-    fn clean(&self, cx: &DocContext) -> Option<Visibility> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<Visibility> {
         Some(match self.node {
             hir::VisibilityKind::Public => Visibility::Public,
             hir::VisibilityKind::Inherited => Visibility::Inherited,
@@ -2956,7 +2963,7 @@ fn clean(&self, cx: &DocContext) -> Option<Visibility> {
 }
 
 impl Clean<Option<Visibility>> for ty::Visibility {
-    fn clean(&self, _: &DocContext) -> Option<Visibility> {
+    fn clean(&self, _: &DocContext<'_, '_, '_>) -> Option<Visibility> {
         Some(if *self == ty::Visibility::Public { Public } else { Inherited })
     }
 }
@@ -2978,7 +2985,7 @@ pub struct Union {
 }
 
 impl Clean<Item> for doctree::Struct {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         Item {
             name: Some(self.name.clean(cx)),
             attrs: self.attrs.clean(cx),
@@ -2998,7 +3005,7 @@ fn clean(&self, cx: &DocContext) -> Item {
 }
 
 impl Clean<Item> for doctree::Union {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         Item {
             name: Some(self.name.clean(cx)),
             attrs: self.attrs.clean(cx),
@@ -3028,7 +3035,7 @@ pub struct VariantStruct {
 }
 
 impl Clean<VariantStruct> for ::rustc::hir::VariantData {
-    fn clean(&self, cx: &DocContext) -> VariantStruct {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> VariantStruct {
         VariantStruct {
             struct_type: doctree::struct_type_from_def(self),
             fields: self.fields().iter().map(|x| x.clean(cx)).collect(),
@@ -3045,7 +3052,7 @@ pub struct Enum {
 }
 
 impl Clean<Item> for doctree::Enum {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         Item {
             name: Some(self.name.clean(cx)),
             attrs: self.attrs.clean(cx),
@@ -3069,7 +3076,7 @@ pub struct Variant {
 }
 
 impl Clean<Item> for doctree::Variant {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         Item {
             name: Some(self.name.clean(cx)),
             attrs: self.attrs.clean(cx),
@@ -3086,7 +3093,7 @@ fn clean(&self, cx: &DocContext) -> Item {
 }
 
 impl<'tcx> Clean<Item> for ty::VariantDef {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         let kind = match self.ctor_kind {
             CtorKind::Const => VariantKind::CLike,
             CtorKind::Fn => {
@@ -3134,7 +3141,7 @@ pub enum VariantKind {
 }
 
 impl Clean<VariantKind> for hir::VariantData {
-    fn clean(&self, cx: &DocContext) -> VariantKind {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> VariantKind {
         if self.is_struct() {
             VariantKind::Struct(self.clean(cx))
         } else if self.is_unit() {
@@ -3165,7 +3172,7 @@ pub fn empty() -> Span {
 }
 
 impl Clean<Span> for syntax_pos::Span {
-    fn clean(&self, cx: &DocContext) -> Span {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Span {
         if self.is_dummy() {
             return Span::empty();
         }
@@ -3198,7 +3205,7 @@ pub fn last_name(&self) -> &str {
 }
 
 impl Clean<Path> for hir::Path {
-    fn clean(&self, cx: &DocContext) -> Path {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Path {
         Path {
             global: self.is_global(),
             def: self.def,
@@ -3221,7 +3228,7 @@ pub enum GenericArgs {
 }
 
 impl Clean<GenericArgs> for hir::GenericArgs {
-    fn clean(&self, cx: &DocContext) -> GenericArgs {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericArgs {
         if self.parenthesized {
             let output = self.bindings[0].ty.clean(cx);
             GenericArgs::Parenthesized {
@@ -3263,7 +3270,7 @@ pub struct PathSegment {
 }
 
 impl Clean<PathSegment> for hir::PathSegment {
-    fn clean(&self, cx: &DocContext) -> PathSegment {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> PathSegment {
         PathSegment {
             name: self.ident.name.clean(cx),
             args: self.with_generic_args(|generic_args| generic_args.clean(cx))
@@ -3335,21 +3342,21 @@ fn qpath_to_string(p: &hir::QPath) -> String {
 
 impl Clean<String> for Ident {
     #[inline]
-    fn clean(&self, cx: &DocContext) -> String {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> String {
         self.name.clean(cx)
     }
 }
 
 impl Clean<String> for ast::Name {
     #[inline]
-    fn clean(&self, _: &DocContext) -> String {
+    fn clean(&self, _: &DocContext<'_, '_, '_>) -> String {
         self.to_string()
     }
 }
 
 impl Clean<String> for InternedString {
     #[inline]
-    fn clean(&self, _: &DocContext) -> String {
+    fn clean(&self, _: &DocContext<'_, '_, '_>) -> String {
         self.to_string()
     }
 }
@@ -3361,7 +3368,7 @@ pub struct Typedef {
 }
 
 impl Clean<Item> for doctree::Typedef {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         Item {
             name: Some(self.name.clean(cx)),
             attrs: self.attrs.clean(cx),
@@ -3385,7 +3392,7 @@ pub struct Existential {
 }
 
 impl Clean<Item> for doctree::Existential {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         Item {
             name: Some(self.name.clean(cx)),
             attrs: self.attrs.clean(cx),
@@ -3411,7 +3418,7 @@ pub struct BareFunctionDecl {
 }
 
 impl Clean<BareFunctionDecl> for hir::BareFnTy {
-    fn clean(&self, cx: &DocContext) -> BareFunctionDecl {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> BareFunctionDecl {
         let (generic_params, decl) = enter_impl_trait(cx, || {
             (self.generic_params.clean(cx), (&*self.decl, &self.arg_names[..]).clean(cx))
         });
@@ -3435,7 +3442,7 @@ pub struct Static {
 }
 
 impl Clean<Item> for doctree::Static {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         debug!("cleaning static {}: {:?}", self.name.clean(cx), self);
         Item {
             name: Some(self.name.clean(cx)),
@@ -3461,7 +3468,7 @@ pub struct Constant {
 }
 
 impl Clean<Item> for doctree::Constant {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         Item {
             name: Some(self.name.clean(cx)),
             attrs: self.attrs.clean(cx),
@@ -3485,7 +3492,7 @@ pub enum Mutability {
 }
 
 impl Clean<Mutability> for hir::Mutability {
-    fn clean(&self, _: &DocContext) -> Mutability {
+    fn clean(&self, _: &DocContext<'_, '_, '_>) -> Mutability {
         match self {
             &hir::MutMutable => Mutable,
             &hir::MutImmutable => Immutable,
@@ -3500,7 +3507,7 @@ pub enum ImplPolarity {
 }
 
 impl Clean<ImplPolarity> for hir::ImplPolarity {
-    fn clean(&self, _: &DocContext) -> ImplPolarity {
+    fn clean(&self, _: &DocContext<'_, '_, '_>) -> ImplPolarity {
         match self {
             &hir::ImplPolarity::Positive => ImplPolarity::Positive,
             &hir::ImplPolarity::Negative => ImplPolarity::Negative,
@@ -3521,30 +3528,44 @@ pub struct Impl {
     pub blanket_impl: Option<Type>,
 }
 
-pub fn get_auto_traits_with_node_id(cx: &DocContext, id: ast::NodeId, name: String) -> Vec<Item> {
+pub fn get_auto_traits_with_node_id(
+    cx: &DocContext<'_, '_, '_>,
+    id: ast::NodeId,
+    name: String
+) -> Vec<Item> {
     let finder = AutoTraitFinder::new(cx);
     finder.get_with_node_id(id, name)
 }
 
-pub fn get_auto_traits_with_def_id(cx: &DocContext, id: DefId) -> Vec<Item> {
+pub fn get_auto_traits_with_def_id(
+    cx: &DocContext<'_, '_, '_>,
+    id: DefId
+) -> Vec<Item> {
     let finder = AutoTraitFinder::new(cx);
 
     finder.get_with_def_id(id)
 }
 
-pub fn get_blanket_impls_with_node_id(cx: &DocContext, id: ast::NodeId, name: String) -> Vec<Item> {
+pub fn get_blanket_impls_with_node_id(
+    cx: &DocContext<'_, '_, '_>,
+    id: ast::NodeId,
+    name: String
+) -> Vec<Item> {
     let finder = BlanketImplFinder::new(cx);
     finder.get_with_node_id(id, name)
 }
 
-pub fn get_blanket_impls_with_def_id(cx: &DocContext, id: DefId) -> Vec<Item> {
+pub fn get_blanket_impls_with_def_id(
+    cx: &DocContext<'_, '_, '_>,
+    id: DefId
+) -> Vec<Item> {
     let finder = BlanketImplFinder::new(cx);
 
     finder.get_with_def_id(id)
 }
 
 impl Clean<Vec<Item>> for doctree::Impl {
-    fn clean(&self, cx: &DocContext) -> Vec<Item> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<Item> {
         let mut ret = Vec::new();
         let trait_ = self.trait_.clean(cx);
         let items = self.items.clean(cx);
@@ -3586,7 +3607,7 @@ fn clean(&self, cx: &DocContext) -> Vec<Item> {
     }
 }
 
-fn build_deref_target_impls(cx: &DocContext,
+fn build_deref_target_impls(cx: &DocContext<'_, '_, '_>,
                             items: &[Item],
                             ret: &mut Vec<Item>) {
     use self::PrimitiveType::*;
@@ -3634,6 +3655,7 @@ fn build_deref_target_impls(cx: &DocContext,
             Reference => None,
             Fn => None,
             Never => None,
+            CVarArgs => tcx.lang_items().va_list(),
         };
         if let Some(did) = did {
             if !did.is_local() {
@@ -3644,7 +3666,7 @@ fn build_deref_target_impls(cx: &DocContext,
 }
 
 impl Clean<Vec<Item>> for doctree::ExternCrate {
-    fn clean(&self, cx: &DocContext) -> Vec<Item> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<Item> {
 
         let please_inline = self.vis.node.is_pub() && self.attrs.iter().any(|a| {
             a.name() == "doc" && match a.meta_item_list() {
@@ -3680,7 +3702,7 @@ fn clean(&self, cx: &DocContext) -> Vec<Item> {
 }
 
 impl Clean<Vec<Item>> for doctree::Import {
-    fn clean(&self, cx: &DocContext) -> Vec<Item> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<Item> {
         // 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.
@@ -3754,7 +3776,7 @@ pub struct ImportSource {
 }
 
 impl Clean<Vec<Item>> for hir::ForeignMod {
-    fn clean(&self, cx: &DocContext) -> Vec<Item> {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Vec<Item> {
         let mut items = self.items.clean(cx);
         for item in &mut items {
             if let ForeignFunctionItem(ref mut f) = item.inner {
@@ -3766,7 +3788,7 @@ fn clean(&self, cx: &DocContext) -> Vec<Item> {
 }
 
 impl Clean<Item> for hir::ForeignItem {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         let inner = match self.node {
             hir::ForeignItemKind::Fn(ref decl, ref names, ref generics) => {
                 let (generics, decl) = enter_impl_trait(cx, || {
@@ -3811,11 +3833,11 @@ fn clean(&self, cx: &DocContext) -> Item {
 // Utilities
 
 pub trait ToSource {
-    fn to_src(&self, cx: &DocContext) -> String;
+    fn to_src(&self, cx: &DocContext<'_, '_, '_>) -> String;
 }
 
 impl ToSource for syntax_pos::Span {
-    fn to_src(&self, cx: &DocContext) -> String {
+    fn to_src(&self, cx: &DocContext<'_, '_, '_>) -> String {
         debug!("converting span {:?} to snippet", self.clean(cx));
         let sn = match cx.sess().source_map().span_to_snippet(*self) {
             Ok(x) => x,
@@ -3862,7 +3884,7 @@ fn name_from_pat(p: &hir::Pat) -> String {
     }
 }
 
-fn print_const(cx: &DocContext, n: ty::LazyConst) -> String {
+fn print_const(cx: &DocContext<'_, '_, '_>, n: ty::LazyConst<'_>) -> String {
     match n {
         ty::LazyConst::Unevaluated(def_id, _) => {
             if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) {
@@ -3884,15 +3906,15 @@ fn print_const(cx: &DocContext, n: ty::LazyConst) -> String {
     }
 }
 
-fn print_const_expr(cx: &DocContext, body: hir::BodyId) -> String {
+fn print_const_expr(cx: &DocContext<'_, '_, '_>, body: hir::BodyId) -> String {
     cx.tcx.hir().hir_to_pretty_string(body.hir_id)
 }
 
 /// Given a type Path, resolve it to a Type using the TyCtxt
-fn resolve_type(cx: &DocContext,
+fn resolve_type(cx: &DocContext<'_, '_, '_>,
                 path: Path,
-                id: ast::NodeId) -> Type {
-    if id == ast::DUMMY_NODE_ID {
+                id: hir::HirId) -> Type {
+    if id == hir::DUMMY_HIR_ID {
         debug!("resolve_type({:?})", path);
     } else {
         debug!("resolve_type({:?},{:?})", path, id);
@@ -3920,7 +3942,7 @@ fn resolve_type(cx: &DocContext,
     ResolvedPath { path: path, typarams: None, did: did, is_generic: is_generic }
 }
 
-pub fn register_def(cx: &DocContext, def: Def) -> DefId {
+pub fn register_def(cx: &DocContext<'_, '_, '_>, def: Def) -> DefId {
     debug!("register_def({:?})", def);
 
     let (did, kind) = match def {
@@ -3955,7 +3977,7 @@ pub fn register_def(cx: &DocContext, def: Def) -> DefId {
     did
 }
 
-fn resolve_use_source(cx: &DocContext, path: Path) -> ImportSource {
+fn resolve_use_source(cx: &DocContext<'_, '_, '_>, path: Path) -> ImportSource {
     ImportSource {
         did: if path.def.opt_def_id().is_none() {
             None
@@ -3973,7 +3995,7 @@ pub struct Macro {
 }
 
 impl Clean<Item> for doctree::Macro {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         let name = self.name.clean(cx);
         Item {
             name: Some(name.clone()),
@@ -4002,7 +4024,7 @@ pub struct ProcMacro {
 }
 
 impl Clean<Item> for doctree::ProcMacro {
-    fn clean(&self, cx: &DocContext) -> Item {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
         Item {
             name: Some(self.name.clean(cx)),
             attrs: self.attrs.clean(cx),
@@ -4036,7 +4058,7 @@ pub struct Deprecation {
 }
 
 impl Clean<Stability> for attr::Stability {
-    fn clean(&self, _: &DocContext) -> Stability {
+    fn clean(&self, _: &DocContext<'_, '_, '_>) -> Stability {
         Stability {
             level: stability::StabilityLevel::from_attr_level(&self.level),
             feature: Some(self.feature.to_string()).filter(|f| !f.is_empty()),
@@ -4063,13 +4085,13 @@ fn clean(&self, _: &DocContext) -> Stability {
 }
 
 impl<'a> Clean<Stability> for &'a attr::Stability {
-    fn clean(&self, dc: &DocContext) -> Stability {
+    fn clean(&self, dc: &DocContext<'_, '_, '_>) -> Stability {
         (**self).clean(dc)
     }
 }
 
 impl Clean<Deprecation> for attr::Deprecation {
-    fn clean(&self, _: &DocContext) -> Deprecation {
+    fn clean(&self, _: &DocContext<'_, '_, '_>) -> Deprecation {
         Deprecation {
             since: self.since.map(|s| s.to_string()).filter(|s| !s.is_empty()),
             note: self.note.map(|n| n.to_string()).filter(|n| !n.is_empty()),
@@ -4085,7 +4107,7 @@ pub struct TypeBinding {
 }
 
 impl Clean<TypeBinding> for hir::TypeBinding {
-    fn clean(&self, cx: &DocContext) -> TypeBinding {
+    fn clean(&self, cx: &DocContext<'_, '_, '_>) -> TypeBinding {
         TypeBinding {
             name: self.ident.name.clean(cx),
             ty: self.ty.clean(cx)
@@ -4093,7 +4115,11 @@ fn clean(&self, cx: &DocContext) -> TypeBinding {
     }
 }
 
-pub fn def_id_to_path(cx: &DocContext, did: DefId, name: Option<String>) -> Vec<String> {
+pub fn def_id_to_path(
+    cx: &DocContext<'_, '_, '_>,
+    did: DefId,
+    name: Option<String>
+) -> Vec<String> {
     let crate_name = name.unwrap_or_else(|| cx.tcx.crate_name(did.krate).to_string());
     let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| {
         // extern blocks have an empty name
@@ -4107,7 +4133,7 @@ pub fn def_id_to_path(cx: &DocContext, did: DefId, name: Option<String>) -> Vec<
     once(crate_name).chain(relative).collect()
 }
 
-pub fn enter_impl_trait<F, R>(cx: &DocContext, f: F) -> R
+pub fn enter_impl_trait<F, R>(cx: &DocContext<'_, '_, '_>, f: F) -> R
 where
     F: FnOnce() -> R,
 {
@@ -4120,7 +4146,7 @@ pub fn enter_impl_trait<F, R>(cx: &DocContext, f: F) -> R
 
 // Start of code copied from rust-clippy
 
-pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
+pub fn path_to_def_local(tcx: &TyCtxt<'_, '_, '_>, path: &[&str]) -> Option<DefId> {
     let krate = tcx.hir().krate();
     let mut items = krate.module.item_ids.clone();
     let mut path_it = path.iter().peekable();
@@ -4145,7 +4171,7 @@ pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
     }
 }
 
-pub fn path_to_def(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
+pub fn path_to_def(tcx: &TyCtxt<'_, '_, '_>, path: &[&str]) -> Option<DefId> {
     let crates = tcx.crates();
 
     let krate = crates
@@ -4182,7 +4208,7 @@ pub fn path_to_def(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
     }
 }
 
-pub fn get_path_for_type<F>(tcx: TyCtxt, def_id: DefId, def_ctor: F) -> hir::Path
+pub fn get_path_for_type<F>(tcx: TyCtxt<'_, '_, '_>, def_id: DefId, def_ctor: F) -> hir::Path
 where F: Fn(DefId) -> Def {
     #[derive(Debug)]
     struct AbsolutePathBuffer {