From ec6f983e243ed7988be4eebd356181be7b1f5525 Mon Sep 17 00:00:00 2001 From: varkor Date: Wed, 13 Mar 2019 23:37:02 +0000 Subject: [PATCH] Rename typarams to param_names Co-Authored-By: Gabriel Smith --- src/librustc/hir/print.rs | 4 ++-- src/librustdoc/clean/auto_trait.rs | 8 ++++---- src/librustdoc/clean/mod.rs | 32 +++++++++++++++--------------- src/librustdoc/html/format.rs | 20 +++++++++---------- src/librustdoc/html/render.rs | 6 +++--- src/libsyntax/print/pprust.rs | 4 ++-- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 54a21f2ed5c2..bff4190ae792 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -591,12 +591,12 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - hir::ItemKind::Fn(ref decl, header, ref typarams, body) => { + hir::ItemKind::Fn(ref decl, header, ref param_names, body) => { self.head("")?; self.print_fn(decl, header, Some(item.ident.name), - typarams, + param_names, &item.vis, &[], Some(body))?; diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 20fa6009b310..23b5794fb1ee 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -435,7 +435,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { let new_ty = match &poly_trait.trait_ { &Type::ResolvedPath { ref path, - ref typarams, + ref param_names, ref did, ref is_generic, } => { @@ -469,7 +469,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { Type::ResolvedPath { path: new_path, - typarams: typarams.clone(), + param_names: param_names.clone(), did: did.clone(), is_generic: *is_generic, } @@ -669,7 +669,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { match **trait_ { Type::ResolvedPath { path: ref trait_path, - ref typarams, + ref param_names, ref did, ref is_generic, } => { @@ -724,7 +724,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { PolyTrait { trait_: Type::ResolvedPath { path: new_trait_path, - typarams: typarams.clone(), + param_names: param_names.clone(), did: did.clone(), is_generic: *is_generic, }, diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c51c8027de64..6739873c6044 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1176,7 +1176,7 @@ impl<'a, 'tcx> Clean for (&'a ty::TraitRef<'tcx>, Vec PolyTrait { trait_: ResolvedPath { path, - typarams: None, + param_names: None, did: trait_ref.def_id, is_generic: false, }, @@ -2244,7 +2244,7 @@ pub enum Type { /// Structs/enums/traits (most that'd be an `hir::TyKind::Path`). ResolvedPath { path: Path, - typarams: Option>, + param_names: Option>, did: DefId, /// `true` if is a `T::Name` path for associated types. is_generic: bool, @@ -2706,7 +2706,7 @@ impl Clean for hir::Ty { } TyKind::TraitObject(ref bounds, ref lifetime) => { match bounds[0].clean(cx).trait_ { - ResolvedPath { path, typarams: None, did, is_generic } => { + ResolvedPath { path, param_names: None, did, is_generic } => { let mut bounds: Vec = bounds[1..].iter().map(|bound| { self::GenericBound::TraitBound(bound.clean(cx), hir::TraitBoundModifier::None) @@ -2714,7 +2714,7 @@ impl Clean for hir::Ty { if !lifetime.is_elided() { bounds.push(self::GenericBound::Outlives(lifetime.clean(cx))); } - ResolvedPath { path, typarams: Some(bounds), did, is_generic, } + ResolvedPath { path, param_names: Some(bounds), did, is_generic, } } _ => Infer // shouldn't happen } @@ -2781,7 +2781,7 @@ impl<'tcx> Clean for Ty<'tcx> { None, false, vec![], substs); ResolvedPath { path, - typarams: None, + param_names: None, did, is_generic: false, } @@ -2792,7 +2792,7 @@ impl<'tcx> Clean for Ty<'tcx> { None, false, vec![], InternalSubsts::empty()); ResolvedPath { path: path, - typarams: None, + param_names: None, did: did, is_generic: false, } @@ -2813,8 +2813,8 @@ impl<'tcx> Clean for Ty<'tcx> { inline::record_extern_fqn(cx, did, TypeKind::Trait); - let mut typarams = vec![]; - reg.clean(cx).map(|b| typarams.push(GenericBound::Outlives(b))); + let mut param_names = vec![]; + reg.clean(cx).map(|b| param_names.push(GenericBound::Outlives(b))); for did in dids { let empty = cx.tcx.intern_substs(&[]); let path = external_path(cx, &cx.tcx.item_name(did).as_str(), @@ -2823,13 +2823,13 @@ impl<'tcx> Clean for Ty<'tcx> { let bound = GenericBound::TraitBound(PolyTrait { trait_: ResolvedPath { path, - typarams: None, + param_names: None, did, is_generic: false, }, generic_params: Vec::new(), }, hir::TraitBoundModifier::None); - typarams.push(bound); + param_names.push(bound); } let mut bindings = vec![]; @@ -2844,7 +2844,7 @@ impl<'tcx> Clean for Ty<'tcx> { false, bindings, substs); ResolvedPath { path, - typarams: Some(typarams), + param_names: Some(param_names), did, is_generic: false, } @@ -3294,8 +3294,8 @@ impl Clean for hir::PathSegment { fn strip_type(ty: Type) -> Type { match ty { - Type::ResolvedPath { path, typarams, did, is_generic } => { - Type::ResolvedPath { path: strip_path(&path), typarams, did, is_generic } + Type::ResolvedPath { path, param_names, did, is_generic } => { + Type::ResolvedPath { path: strip_path(&path), param_names, did, is_generic } } Type::Tuple(inner_tys) => { Type::Tuple(inner_tys.iter().map(|t| strip_type(t.clone())).collect()) @@ -3955,7 +3955,7 @@ fn resolve_type(cx: &DocContext<'_>, _ => false, }; let did = register_def(&*cx, path.def); - ResolvedPath { path: path, typarams: None, did: did, is_generic: is_generic } + ResolvedPath { path: path, param_names: None, did: did, is_generic: is_generic } } pub fn register_def(cx: &DocContext<'_>, def: Def) -> DefId { @@ -4381,9 +4381,9 @@ impl From for SimpleBound { match bound.clone() { GenericBound::Outlives(l) => SimpleBound::Outlives(l), GenericBound::TraitBound(t, mod_) => match t.trait_ { - Type::ResolvedPath { path, typarams, .. } => { + Type::ResolvedPath { path, param_names, .. } => { SimpleBound::TraitBound(path.segments, - typarams + param_names .map_or_else(|| Vec::new(), |v| v.iter() .map(|p| SimpleBound::from(p.clone())) .collect()), diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index d204a179ca62..36257914d192 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -521,8 +521,8 @@ fn primitive_link(f: &mut fmt::Formatter<'_>, /// Helper to render type parameters fn tybounds(w: &mut fmt::Formatter<'_>, - typarams: &Option>) -> fmt::Result { - match *typarams { + param_names: &Option>) -> fmt::Result { + match *param_names { Some(ref params) => { for param in params { write!(w, " + ")?; @@ -559,13 +559,13 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> clean::Generic(ref name) => { f.write_str(name) } - clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => { - if typarams.is_some() { + clean::ResolvedPath{ did, ref param_names, ref path, is_generic } => { + if param_names.is_some() { f.write_str("dyn ")?; } // Paths like T::Output and Self::Output should be rendered with all segments resolved_path(f, did, path, is_generic, use_absolute)?; - tybounds(f, typarams) + tybounds(f, param_names) } clean::Infer => write!(f, "_"), clean::Primitive(prim) => primitive_link(f, prim, prim.as_str()), @@ -663,7 +663,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> } } } - clean::ResolvedPath { typarams: Some(ref v), .. } if !v.is_empty() => { + clean::ResolvedPath { param_names: Some(ref v), .. } if !v.is_empty() => { write!(f, "{}{}{}(", amp, lt, m)?; fmt_type(&ty, f, use_absolute)?; write!(f, ")") @@ -717,7 +717,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> // the ugliness comes from inlining across crates where // everything comes in as a fully resolved QPath (hard to // look at). - box clean::ResolvedPath { did, ref typarams, .. } => { + box clean::ResolvedPath { did, ref param_names, .. } => { match href(did) { Some((ref url, _, ref path)) if !f.alternate() => { write!(f, @@ -731,8 +731,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) -> _ => write!(f, "{}", name)?, } - // FIXME: `typarams` are not rendered, and this seems bad? - drop(typarams); + // FIXME: `param_names` are not rendered, and this seems bad? + drop(param_names); Ok(()) } _ => { @@ -771,7 +771,7 @@ fn fmt_impl(i: &clean::Impl, fmt::Display::fmt(ty, f)?; } else { match *ty { - clean::ResolvedPath { typarams: None, ref path, is_generic: false, .. } => { + clean::ResolvedPath { param_names: None, ref path, is_generic: false, .. } => { let last = path.segments.last().unwrap(); fmt::Display::fmt(&last.name, f)?; fmt::Display::fmt(&last.args, f)?; diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index b3a816d17f56..b1c4a8fc1afb 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -271,7 +271,7 @@ pub struct Cache { /// Mapping of typaram ids to the name of the type parameter. This is used /// when pretty-printing a type (so pretty-printing doesn't have to /// painfully maintain a context like this) - pub typarams: FxHashMap, + pub param_names: FxHashMap, /// Maps a type ID to all known implementations for that type. This is only /// recognized for intra-crate `ResolvedPath` types, and is used to print @@ -635,7 +635,7 @@ pub fn run(mut krate: clean::Crate, deref_mut_trait_did, owned_box_did, masked_crates: mem::replace(&mut krate.masked_crates, Default::default()), - typarams: external_typarams, + param_names: external_param_names, aliases: Default::default(), }; @@ -1751,7 +1751,7 @@ impl<'a> Cache { clean::GenericParamDefKind::Lifetime => {} clean::GenericParamDefKind::Type { did, .. } | clean::GenericParamDefKind::Const { did, .. } => { - self.typarams.insert(did, param.name.clone()); + self.param_names.insert(did, param.name.clone()); } } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index e04e127ccf15..07df14ddc722 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1263,13 +1263,13 @@ impl<'a> State<'a> { self.s.word(";")?; self.end()?; // end the outer cbox } - ast::ItemKind::Fn(ref decl, header, ref typarams, ref body) => { + ast::ItemKind::Fn(ref decl, header, ref param_names, ref body) => { self.head("")?; self.print_fn( decl, header, Some(item.ident), - typarams, + param_names, &item.vis )?; self.s.word(" ")?;