Skip to content

Commit 51ca2cc

Browse files
committed
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.
1 parent a97f175 commit 51ca2cc

File tree

2 files changed

+13
-28
lines changed

2 files changed

+13
-28
lines changed

src/librustdoc/clean/types.rs

-15
Original file line numberDiff line numberDiff line change
@@ -1244,17 +1244,6 @@ impl GenericParamDefKind {
12441244
crate fn is_type(&self) -> bool {
12451245
matches!(self, GenericParamDefKind::Type { .. })
12461246
}
1247-
1248-
// FIXME(eddyb) this either returns the default of a type parameter, or the
1249-
// type of a `const` parameter. It seems that the intention is to *visit*
1250-
// any embedded types, but `get_type` seems to be the wrong name for that.
1251-
crate fn get_type(&self) -> Option<Type> {
1252-
match self {
1253-
GenericParamDefKind::Type { default, .. } => default.as_deref().cloned(),
1254-
GenericParamDefKind::Const { ty, .. } => Some((&**ty).clone()),
1255-
GenericParamDefKind::Lifetime { .. } => None,
1256-
}
1257-
}
12581247
}
12591248

12601249
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
@@ -1279,10 +1268,6 @@ impl GenericParamDef {
12791268
self.kind.is_type()
12801269
}
12811270

1282-
crate fn get_type(&self) -> Option<Type> {
1283-
self.kind.get_type()
1284-
}
1285-
12861271
crate fn get_bounds(&self) -> Option<&[GenericBound]> {
12871272
match self.kind {
12881273
GenericParamDefKind::Type { ref bounds, .. } => Some(bounds),

src/librustdoc/html/render/cache.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -347,19 +347,19 @@ crate fn get_real_types<'tcx>(
347347
let bounds = where_pred.get_bounds().unwrap_or_else(|| &[]);
348348
for bound in bounds.iter() {
349349
if let GenericBound::TraitBound(poly_trait, _) = bound {
350-
for x in poly_trait.generic_params.iter() {
351-
if !x.is_type() {
352-
continue;
353-
}
354-
if let Some(ty) = x.get_type() {
355-
get_real_types(
356-
generics,
357-
&ty,
358-
tcx,
359-
recurse + 1,
360-
&mut ty_generics,
361-
cache,
362-
);
350+
for param_def in poly_trait.generic_params.iter() {
351+
match &param_def.kind {
352+
clean::GenericParamDefKind::Type { default: Some(ty), .. } => {
353+
get_real_types(
354+
generics,
355+
ty,
356+
tcx,
357+
recurse + 1,
358+
&mut ty_generics,
359+
cache,
360+
)
361+
}
362+
_ => {}
363363
}
364364
}
365365
}

0 commit comments

Comments
 (0)