]> 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 03dff108770413c0959f4c24fbf8d6eb3a468bfc..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;
@@ -1089,7 +1089,7 @@ 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 {
+                        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<_>>();
 
@@ -1131,7 +1131,7 @@ fn external_generic_args(cx: &DocContext<'_, '_, '_>, trait_did: Option<DefId>,
 // 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 {
+                 bindings: Vec<TypeBinding>, substs: SubstsRef<'_>) -> Path {
     Path {
         global: false,
         def: Def::Err,
@@ -1192,7 +1192,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericBound {
     }
 }
 
-impl<'tcx> Clean<Option<Vec<GenericBound>>> for Substs<'tcx> {
+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));
@@ -1221,7 +1221,7 @@ pub fn statik() -> Lifetime {
 
 impl Clean<Lifetime> for hir::Lifetime {
     fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Lifetime {
-        if self.id != ast::DUMMY_NODE_ID {
+        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, _)) |
@@ -1513,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,
@@ -1521,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),
                 })
             }
@@ -1752,7 +1752,6 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
 pub struct FnDecl {
     pub inputs: Arguments,
     pub output: FunctionRetTy,
-    pub variadic: bool,
     pub attrs: Attributes,
 }
 
@@ -1831,7 +1830,6 @@ 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()
         }
     }
@@ -1849,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 {
@@ -1988,7 +1985,7 @@ 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)
+        resolve_type(cx, self.path.clean(cx), self.hir_ref_id)
     }
 }
 
@@ -2252,6 +2249,7 @@ pub enum Type {
     Slice(Box<Type>),
     Array(Box<Type>, String),
     Never,
+    CVarArgs,
     Unique(Box<Type>),
     RawPointer(Mutability, Box<Type>),
     BorrowedRef {
@@ -2290,6 +2288,7 @@ pub enum PrimitiveType {
     Reference,
     Fn,
     Never,
+    CVarArgs,
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Copy, Debug)]
@@ -2469,6 +2468,7 @@ pub fn as_str(&self) -> &'static str {
             Reference => "reference",
             Fn => "fn",
             Never => "never",
+            CVarArgs => "...",
         }
     }
 
@@ -2518,6 +2518,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
 
         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() {
@@ -2532,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
@@ -2599,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));
                                         }
                                     }
@@ -2607,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 {
@@ -2631,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 {
@@ -2656,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();
@@ -2669,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)) => {
@@ -2686,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) => {
@@ -2774,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,
@@ -3652,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() {
@@ -3909,8 +3913,8 @@ fn print_const_expr(cx: &DocContext<'_, '_, '_>, body: hir::BodyId) -> String {
 /// Given a type Path, resolve it to a Type using the TyCtxt
 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);