Skip to content

Commit cafc458

Browse files
committed
Auto merge of #91510 - camelid:two-cleanups, r=GuillaumeGomez
rustdoc: Cleanup two things in `clean::types` Explanations are in the individual commits.
2 parents 6c189bc + 51ca2cc commit cafc458

File tree

3 files changed

+14
-33
lines changed

3 files changed

+14
-33
lines changed

Diff for: src/librustdoc/clean/types.rs

-19
Original file line numberDiff line numberDiff line change
@@ -1207,10 +1207,6 @@ impl GenericBound {
12071207
crate struct Lifetime(pub Symbol);
12081208

12091209
impl Lifetime {
1210-
crate fn get_ref(&self) -> SymbolStr {
1211-
self.0.as_str()
1212-
}
1213-
12141210
crate fn statik() -> Lifetime {
12151211
Lifetime(kw::StaticLifetime)
12161212
}
@@ -1248,17 +1244,6 @@ impl GenericParamDefKind {
12481244
crate fn is_type(&self) -> bool {
12491245
matches!(self, GenericParamDefKind::Type { .. })
12501246
}
1251-
1252-
// FIXME(eddyb) this either returns the default of a type parameter, or the
1253-
// type of a `const` parameter. It seems that the intention is to *visit*
1254-
// any embedded types, but `get_type` seems to be the wrong name for that.
1255-
crate fn get_type(&self) -> Option<Type> {
1256-
match self {
1257-
GenericParamDefKind::Type { default, .. } => default.as_deref().cloned(),
1258-
GenericParamDefKind::Const { ty, .. } => Some((&**ty).clone()),
1259-
GenericParamDefKind::Lifetime { .. } => None,
1260-
}
1261-
}
12621247
}
12631248

12641249
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
@@ -1283,10 +1268,6 @@ impl GenericParamDef {
12831268
self.kind.is_type()
12841269
}
12851270

1286-
crate fn get_type(&self) -> Option<Type> {
1287-
self.kind.get_type()
1288-
}
1289-
12901271
crate fn get_bounds(&self) -> Option<&[GenericBound]> {
12911272
match self.kind {
12921273
GenericParamDefKind::Type { ref bounds, .. } => Some(bounds),

Diff for: src/librustdoc/html/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ crate fn print_where_clause<'a, 'tcx: 'a>(
346346

347347
impl clean::Lifetime {
348348
crate fn print(&self) -> impl fmt::Display + '_ {
349-
self.get_ref()
349+
self.0.as_str()
350350
}
351351
}
352352

Diff for: 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)