Skip to content

Commit 09f6b44

Browse files
committed
Simplify some code in rustdoc's simplify
1 parent c015927 commit 09f6b44

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/librustdoc/clean/simplify.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
3535
match ty {
3636
clean::Generic(s) => params.entry(s).or_default()
3737
.extend(bounds),
38-
t => tybounds.push((t, ty_bounds(bounds))),
38+
t => tybounds.push((t, bounds)),
3939
}
4040
}
4141
WP::RegionPredicate { lifetime, bounds } => {
@@ -45,11 +45,6 @@ pub fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
4545
}
4646
}
4747

48-
// Simplify the type parameter bounds on all the generics
49-
let mut params = params.into_iter().map(|(k, v)| {
50-
(k, ty_bounds(v))
51-
}).collect::<BTreeMap<_, _>>();
52-
5348
// Look for equality predicates on associated types that can be merged into
5449
// general bound predicates
5550
equalities.retain(|&(ref lhs, ref rhs)| {
@@ -73,7 +68,7 @@ pub fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
7368
// And finally, let's reassemble everything
7469
let mut clauses = Vec::new();
7570
clauses.extend(lifetimes.into_iter().map(|(lt, bounds)| {
76-
WP::RegionPredicate { lifetime: lt, bounds: bounds }
71+
WP::RegionPredicate { lifetime: lt, bounds }
7772
}));
7873
clauses.extend(params.into_iter().map(|(k, v)| {
7974
WP::BoundPredicate {
@@ -82,10 +77,10 @@ pub fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
8277
}
8378
}));
8479
clauses.extend(tybounds.into_iter().map(|(ty, bounds)| {
85-
WP::BoundPredicate { ty: ty, bounds: bounds }
80+
WP::BoundPredicate { ty, bounds }
8681
}));
8782
clauses.extend(equalities.into_iter().map(|(lhs, rhs)| {
88-
WP::EqPredicate { lhs: lhs, rhs: rhs }
83+
WP::EqPredicate { lhs, rhs }
8984
}));
9085
clauses
9186
}
@@ -137,18 +132,14 @@ pub fn ty_params(mut params: Vec<clean::GenericParamDef>) -> Vec<clean::GenericP
137132
for param in &mut params {
138133
match param.kind {
139134
clean::GenericParamDefKind::Type { ref mut bounds, .. } => {
140-
*bounds = ty_bounds(mem::take(bounds));
135+
*bounds = mem::take(bounds);
141136
}
142137
_ => panic!("expected only type parameters"),
143138
}
144139
}
145140
params
146141
}
147142

148-
fn ty_bounds(bounds: Vec<clean::GenericBound>) -> Vec<clean::GenericBound> {
149-
bounds
150-
}
151-
152143
fn trait_is_same_or_supertrait(cx: &DocContext<'_>, child: DefId,
153144
trait_: DefId) -> bool {
154145
if child == trait_ {

0 commit comments

Comments
 (0)