Skip to content

Commit

Permalink
don't alloc Path and mutate it inplace
Browse files Browse the repository at this point in the history
  • Loading branch information
klensy committed Dec 12, 2021
1 parent 58457bb commit 8869dbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
.and_then(|trait_| {
ty_to_traits
.get(&ty)
.map(|bounds| bounds.contains(&strip_path_generics(trait_.clone())))
.map(|bounds| bounds.contains(&strip_path_generics(trait_)))
})
.unwrap_or(false)
{
Expand Down
15 changes: 5 additions & 10 deletions src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,12 @@ pub(super) fn external_path(
}

/// Remove the generic arguments from a path.
crate fn strip_path_generics(path: Path) -> Path {
let segments = path
.segments
.iter()
.map(|s| PathSegment {
name: s.name,
args: GenericArgs::AngleBracketed { args: vec![], bindings: vec![] },
})
.collect();
crate fn strip_path_generics(mut path: Path) -> Path {
for ps in path.segments.iter_mut() {
ps.args = GenericArgs::AngleBracketed { args: vec![], bindings: vec![] }
}

Path { res: path.res, segments }
path
}

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

0 comments on commit 8869dbc

Please sign in to comment.