Remove single-use GenericParamDef::get_type
function
Rationale: * The name was confusing. * It was only used in one place. * That place didn't actually need all the functionality of `get_type`; rather, removing `get_type` makes that code clearer.
This commit is contained in:
parent
a97f175350
commit
51ca2cc6af
2 changed files with 13 additions and 28 deletions
|
@ -1244,17 +1244,6 @@ impl GenericParamDefKind {
|
|||
crate fn is_type(&self) -> bool {
|
||||
matches!(self, GenericParamDefKind::Type { .. })
|
||||
}
|
||||
|
||||
// FIXME(eddyb) this either returns the default of a type parameter, or the
|
||||
// type of a `const` parameter. It seems that the intention is to *visit*
|
||||
// any embedded types, but `get_type` seems to be the wrong name for that.
|
||||
crate fn get_type(&self) -> Option<Type> {
|
||||
match self {
|
||||
GenericParamDefKind::Type { default, .. } => default.as_deref().cloned(),
|
||||
GenericParamDefKind::Const { ty, .. } => Some((&**ty).clone()),
|
||||
GenericParamDefKind::Lifetime { .. } => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||
|
@ -1279,10 +1268,6 @@ impl GenericParamDef {
|
|||
self.kind.is_type()
|
||||
}
|
||||
|
||||
crate fn get_type(&self) -> Option<Type> {
|
||||
self.kind.get_type()
|
||||
}
|
||||
|
||||
crate fn get_bounds(&self) -> Option<&[GenericBound]> {
|
||||
match self.kind {
|
||||
GenericParamDefKind::Type { ref bounds, .. } => Some(bounds),
|
||||
|
|
|
@ -347,19 +347,19 @@ crate fn get_real_types<'tcx>(
|
|||
let bounds = where_pred.get_bounds().unwrap_or_else(|| &[]);
|
||||
for bound in bounds.iter() {
|
||||
if let GenericBound::TraitBound(poly_trait, _) = bound {
|
||||
for x in poly_trait.generic_params.iter() {
|
||||
if !x.is_type() {
|
||||
continue;
|
||||
}
|
||||
if let Some(ty) = x.get_type() {
|
||||
get_real_types(
|
||||
generics,
|
||||
&ty,
|
||||
tcx,
|
||||
recurse + 1,
|
||||
&mut ty_generics,
|
||||
cache,
|
||||
);
|
||||
for param_def in poly_trait.generic_params.iter() {
|
||||
match ¶m_def.kind {
|
||||
clean::GenericParamDefKind::Type { default: Some(ty), .. } => {
|
||||
get_real_types(
|
||||
generics,
|
||||
ty,
|
||||
tcx,
|
||||
recurse + 1,
|
||||
&mut ty_generics,
|
||||
cache,
|
||||
)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue