Skip to content

Commit 8869dbc

Browse files
committed
don't alloc Path and mutate it inplace
1 parent 58457bb commit 8869dbc

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
505505
.and_then(|trait_| {
506506
ty_to_traits
507507
.get(&ty)
508-
.map(|bounds| bounds.contains(&strip_path_generics(trait_.clone())))
508+
.map(|bounds| bounds.contains(&strip_path_generics(trait_)))
509509
})
510510
.unwrap_or(false)
511511
{

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

+5-10
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,12 @@ pub(super) fn external_path(
141141
}
142142

143143
/// Remove the generic arguments from a path.
144-
crate fn strip_path_generics(path: Path) -> Path {
145-
let segments = path
146-
.segments
147-
.iter()
148-
.map(|s| PathSegment {
149-
name: s.name,
150-
args: GenericArgs::AngleBracketed { args: vec![], bindings: vec![] },
151-
})
152-
.collect();
144+
crate fn strip_path_generics(mut path: Path) -> Path {
145+
for ps in path.segments.iter_mut() {
146+
ps.args = GenericArgs::AngleBracketed { args: vec![], bindings: vec![] }
147+
}
153148

154-
Path { res: path.res, segments }
149+
path
155150
}
156151

157152
crate fn qpath_to_string(p: &hir::QPath<'_>) -> String {

0 commit comments

Comments
 (0)