Rename typarams to param_names
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
This commit is contained in:
parent
0f88167f89
commit
ec6f983e24
6 changed files with 37 additions and 37 deletions
|
@ -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))?;
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -1176,7 +1176,7 @@ impl<'a, 'tcx> Clean<GenericBound> for (&'a ty::TraitRef<'tcx>, Vec<TypeBinding>
|
|||
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<Vec<GenericBound>>,
|
||||
param_names: Option<Vec<GenericBound>>,
|
||||
did: DefId,
|
||||
/// `true` if is a `T::Name` path for associated types.
|
||||
is_generic: bool,
|
||||
|
@ -2706,7 +2706,7 @@ impl Clean<Type> 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<self::GenericBound> = bounds[1..].iter().map(|bound| {
|
||||
self::GenericBound::TraitBound(bound.clean(cx),
|
||||
hir::TraitBoundModifier::None)
|
||||
|
@ -2714,7 +2714,7 @@ impl Clean<Type> 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<Type> 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<Type> 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<Type> 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<Type> 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<Type> 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<PathSegment> 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<GenericBound> 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()),
|
||||
|
|
|
@ -521,8 +521,8 @@ fn primitive_link(f: &mut fmt::Formatter<'_>,
|
|||
|
||||
/// Helper to render type parameters
|
||||
fn tybounds(w: &mut fmt::Formatter<'_>,
|
||||
typarams: &Option<Vec<clean::GenericBound>>) -> fmt::Result {
|
||||
match *typarams {
|
||||
param_names: &Option<Vec<clean::GenericBound>>) -> 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)?;
|
||||
|
|
|
@ -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<DefId, String>,
|
||||
pub param_names: FxHashMap<DefId, String>,
|
||||
|
||||
/// 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(" ")?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue