1
Fork 0

Rename typarams to param_names

Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
This commit is contained in:
varkor 2019-03-13 23:37:02 +00:00
parent 0f88167f89
commit ec6f983e24
6 changed files with 37 additions and 37 deletions

View file

@ -591,12 +591,12 @@ impl<'a> State<'a> {
self.s.word(";")?; self.s.word(";")?;
self.end()?; // end the outer cbox 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.head("")?;
self.print_fn(decl, self.print_fn(decl,
header, header,
Some(item.ident.name), Some(item.ident.name),
typarams, param_names,
&item.vis, &item.vis,
&[], &[],
Some(body))?; Some(body))?;

View file

@ -435,7 +435,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
let new_ty = match &poly_trait.trait_ { let new_ty = match &poly_trait.trait_ {
&Type::ResolvedPath { &Type::ResolvedPath {
ref path, ref path,
ref typarams, ref param_names,
ref did, ref did,
ref is_generic, ref is_generic,
} => { } => {
@ -469,7 +469,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
Type::ResolvedPath { Type::ResolvedPath {
path: new_path, path: new_path,
typarams: typarams.clone(), param_names: param_names.clone(),
did: did.clone(), did: did.clone(),
is_generic: *is_generic, is_generic: *is_generic,
} }
@ -669,7 +669,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
match **trait_ { match **trait_ {
Type::ResolvedPath { Type::ResolvedPath {
path: ref trait_path, path: ref trait_path,
ref typarams, ref param_names,
ref did, ref did,
ref is_generic, ref is_generic,
} => { } => {
@ -724,7 +724,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
PolyTrait { PolyTrait {
trait_: Type::ResolvedPath { trait_: Type::ResolvedPath {
path: new_trait_path, path: new_trait_path,
typarams: typarams.clone(), param_names: param_names.clone(),
did: did.clone(), did: did.clone(),
is_generic: *is_generic, is_generic: *is_generic,
}, },

View file

@ -1176,7 +1176,7 @@ impl<'a, 'tcx> Clean<GenericBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>
PolyTrait { PolyTrait {
trait_: ResolvedPath { trait_: ResolvedPath {
path, path,
typarams: None, param_names: None,
did: trait_ref.def_id, did: trait_ref.def_id,
is_generic: false, is_generic: false,
}, },
@ -2244,7 +2244,7 @@ pub enum Type {
/// Structs/enums/traits (most that'd be an `hir::TyKind::Path`). /// Structs/enums/traits (most that'd be an `hir::TyKind::Path`).
ResolvedPath { ResolvedPath {
path: Path, path: Path,
typarams: Option<Vec<GenericBound>>, param_names: Option<Vec<GenericBound>>,
did: DefId, did: DefId,
/// `true` if is a `T::Name` path for associated types. /// `true` if is a `T::Name` path for associated types.
is_generic: bool, is_generic: bool,
@ -2706,7 +2706,7 @@ impl Clean<Type> for hir::Ty {
} }
TyKind::TraitObject(ref bounds, ref lifetime) => { TyKind::TraitObject(ref bounds, ref lifetime) => {
match bounds[0].clean(cx).trait_ { 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<self::GenericBound> = bounds[1..].iter().map(|bound| { let mut bounds: Vec<self::GenericBound> = bounds[1..].iter().map(|bound| {
self::GenericBound::TraitBound(bound.clean(cx), self::GenericBound::TraitBound(bound.clean(cx),
hir::TraitBoundModifier::None) hir::TraitBoundModifier::None)
@ -2714,7 +2714,7 @@ impl Clean<Type> for hir::Ty {
if !lifetime.is_elided() { if !lifetime.is_elided() {
bounds.push(self::GenericBound::Outlives(lifetime.clean(cx))); 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 _ => Infer // shouldn't happen
} }
@ -2781,7 +2781,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
None, false, vec![], substs); None, false, vec![], substs);
ResolvedPath { ResolvedPath {
path, path,
typarams: None, param_names: None,
did, did,
is_generic: false, is_generic: false,
} }
@ -2792,7 +2792,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
None, false, vec![], InternalSubsts::empty()); None, false, vec![], InternalSubsts::empty());
ResolvedPath { ResolvedPath {
path: path, path: path,
typarams: None, param_names: None,
did: did, did: did,
is_generic: false, is_generic: false,
} }
@ -2813,8 +2813,8 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
inline::record_extern_fqn(cx, did, TypeKind::Trait); inline::record_extern_fqn(cx, did, TypeKind::Trait);
let mut typarams = vec![]; let mut param_names = vec![];
reg.clean(cx).map(|b| typarams.push(GenericBound::Outlives(b))); reg.clean(cx).map(|b| param_names.push(GenericBound::Outlives(b)));
for did in dids { for did in dids {
let empty = cx.tcx.intern_substs(&[]); let empty = cx.tcx.intern_substs(&[]);
let path = external_path(cx, &cx.tcx.item_name(did).as_str(), let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
@ -2823,13 +2823,13 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
let bound = GenericBound::TraitBound(PolyTrait { let bound = GenericBound::TraitBound(PolyTrait {
trait_: ResolvedPath { trait_: ResolvedPath {
path, path,
typarams: None, param_names: None,
did, did,
is_generic: false, is_generic: false,
}, },
generic_params: Vec::new(), generic_params: Vec::new(),
}, hir::TraitBoundModifier::None); }, hir::TraitBoundModifier::None);
typarams.push(bound); param_names.push(bound);
} }
let mut bindings = vec![]; let mut bindings = vec![];
@ -2844,7 +2844,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
false, bindings, substs); false, bindings, substs);
ResolvedPath { ResolvedPath {
path, path,
typarams: Some(typarams), param_names: Some(param_names),
did, did,
is_generic: false, is_generic: false,
} }
@ -3294,8 +3294,8 @@ impl Clean<PathSegment> for hir::PathSegment {
fn strip_type(ty: Type) -> Type { fn strip_type(ty: Type) -> Type {
match ty { match ty {
Type::ResolvedPath { path, typarams, did, is_generic } => { Type::ResolvedPath { path, param_names, did, is_generic } => {
Type::ResolvedPath { path: strip_path(&path), typarams, did, is_generic } Type::ResolvedPath { path: strip_path(&path), param_names, did, is_generic }
} }
Type::Tuple(inner_tys) => { Type::Tuple(inner_tys) => {
Type::Tuple(inner_tys.iter().map(|t| strip_type(t.clone())).collect()) Type::Tuple(inner_tys.iter().map(|t| strip_type(t.clone())).collect())
@ -3955,7 +3955,7 @@ fn resolve_type(cx: &DocContext<'_>,
_ => false, _ => false,
}; };
let did = register_def(&*cx, path.def); 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 { pub fn register_def(cx: &DocContext<'_>, def: Def) -> DefId {
@ -4381,9 +4381,9 @@ impl From<GenericBound> for SimpleBound {
match bound.clone() { match bound.clone() {
GenericBound::Outlives(l) => SimpleBound::Outlives(l), GenericBound::Outlives(l) => SimpleBound::Outlives(l),
GenericBound::TraitBound(t, mod_) => match t.trait_ { GenericBound::TraitBound(t, mod_) => match t.trait_ {
Type::ResolvedPath { path, typarams, .. } => { Type::ResolvedPath { path, param_names, .. } => {
SimpleBound::TraitBound(path.segments, SimpleBound::TraitBound(path.segments,
typarams param_names
.map_or_else(|| Vec::new(), |v| v.iter() .map_or_else(|| Vec::new(), |v| v.iter()
.map(|p| SimpleBound::from(p.clone())) .map(|p| SimpleBound::from(p.clone()))
.collect()), .collect()),

View file

@ -521,8 +521,8 @@ fn primitive_link(f: &mut fmt::Formatter<'_>,
/// Helper to render type parameters /// Helper to render type parameters
fn tybounds(w: &mut fmt::Formatter<'_>, fn tybounds(w: &mut fmt::Formatter<'_>,
typarams: &Option<Vec<clean::GenericBound>>) -> fmt::Result { param_names: &Option<Vec<clean::GenericBound>>) -> fmt::Result {
match *typarams { match *param_names {
Some(ref params) => { Some(ref params) => {
for param in params { for param in params {
write!(w, " + ")?; write!(w, " + ")?;
@ -559,13 +559,13 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) ->
clean::Generic(ref name) => { clean::Generic(ref name) => {
f.write_str(name) f.write_str(name)
} }
clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => { clean::ResolvedPath{ did, ref param_names, ref path, is_generic } => {
if typarams.is_some() { if param_names.is_some() {
f.write_str("dyn ")?; f.write_str("dyn ")?;
} }
// Paths like T::Output and Self::Output should be rendered with all segments // Paths like T::Output and Self::Output should be rendered with all segments
resolved_path(f, did, path, is_generic, use_absolute)?; resolved_path(f, did, path, is_generic, use_absolute)?;
tybounds(f, typarams) tybounds(f, param_names)
} }
clean::Infer => write!(f, "_"), clean::Infer => write!(f, "_"),
clean::Primitive(prim) => primitive_link(f, prim, prim.as_str()), 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)?; write!(f, "{}{}{}(", amp, lt, m)?;
fmt_type(&ty, f, use_absolute)?; fmt_type(&ty, f, use_absolute)?;
write!(f, ")") 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 // the ugliness comes from inlining across crates where
// everything comes in as a fully resolved QPath (hard to // everything comes in as a fully resolved QPath (hard to
// look at). // look at).
box clean::ResolvedPath { did, ref typarams, .. } => { box clean::ResolvedPath { did, ref param_names, .. } => {
match href(did) { match href(did) {
Some((ref url, _, ref path)) if !f.alternate() => { Some((ref url, _, ref path)) if !f.alternate() => {
write!(f, write!(f,
@ -731,8 +731,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) ->
_ => write!(f, "{}", name)?, _ => write!(f, "{}", name)?,
} }
// FIXME: `typarams` are not rendered, and this seems bad? // FIXME: `param_names` are not rendered, and this seems bad?
drop(typarams); drop(param_names);
Ok(()) Ok(())
} }
_ => { _ => {
@ -771,7 +771,7 @@ fn fmt_impl(i: &clean::Impl,
fmt::Display::fmt(ty, f)?; fmt::Display::fmt(ty, f)?;
} else { } else {
match *ty { 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(); let last = path.segments.last().unwrap();
fmt::Display::fmt(&last.name, f)?; fmt::Display::fmt(&last.name, f)?;
fmt::Display::fmt(&last.args, f)?; fmt::Display::fmt(&last.args, f)?;

View file

@ -271,7 +271,7 @@ pub struct Cache {
/// Mapping of typaram ids to the name of the type parameter. This is used /// 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 /// when pretty-printing a type (so pretty-printing doesn't have to
/// painfully maintain a context like this) /// painfully maintain a context like this)
pub typarams: FxHashMap<DefId, String>, pub param_names: FxHashMap<DefId, String>,
/// Maps a type ID to all known implementations for that type. This is only /// 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 /// 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, deref_mut_trait_did,
owned_box_did, owned_box_did,
masked_crates: mem::replace(&mut krate.masked_crates, Default::default()), masked_crates: mem::replace(&mut krate.masked_crates, Default::default()),
typarams: external_typarams, param_names: external_param_names,
aliases: Default::default(), aliases: Default::default(),
}; };
@ -1751,7 +1751,7 @@ impl<'a> Cache {
clean::GenericParamDefKind::Lifetime => {} clean::GenericParamDefKind::Lifetime => {}
clean::GenericParamDefKind::Type { did, .. } | clean::GenericParamDefKind::Type { did, .. } |
clean::GenericParamDefKind::Const { did, .. } => { clean::GenericParamDefKind::Const { did, .. } => {
self.typarams.insert(did, param.name.clone()); self.param_names.insert(did, param.name.clone());
} }
} }
} }

View file

@ -1263,13 +1263,13 @@ impl<'a> State<'a> {
self.s.word(";")?; self.s.word(";")?;
self.end()?; // end the outer cbox 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.head("")?;
self.print_fn( self.print_fn(
decl, decl,
header, header,
Some(item.ident), Some(item.ident),
typarams, param_names,
&item.vis &item.vis
)?; )?;
self.s.word(" ")?; self.s.word(" ")?;