1
Fork 0

Auto merge of #91833 - klensy:rd-minus-alloc, r=jyn514

rustdoc: don't clone already owned `Path` and modify it inplace
This commit is contained in:
bors 2021-12-16 15:18:08 +00:00
commit 1d01550f7e
2 changed files with 6 additions and 11 deletions

View file

@ -505,7 +505,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
.and_then(|trait_| { .and_then(|trait_| {
ty_to_traits ty_to_traits
.get(&ty) .get(&ty)
.map(|bounds| bounds.contains(&strip_path_generics(trait_.clone()))) .map(|bounds| bounds.contains(&strip_path_generics(trait_)))
}) })
.unwrap_or(false) .unwrap_or(false)
{ {

View file

@ -141,17 +141,12 @@ pub(super) fn external_path(
} }
/// Remove the generic arguments from a path. /// Remove the generic arguments from a path.
crate fn strip_path_generics(path: Path) -> Path { crate fn strip_path_generics(mut path: Path) -> Path {
let segments = path for ps in path.segments.iter_mut() {
.segments ps.args = GenericArgs::AngleBracketed { args: vec![], bindings: vec![] }
.iter() }
.map(|s| PathSegment {
name: s.name,
args: GenericArgs::AngleBracketed { args: vec![], bindings: vec![] },
})
.collect();
Path { res: path.res, segments } path
} }
crate fn qpath_to_string(p: &hir::QPath<'_>) -> String { crate fn qpath_to_string(p: &hir::QPath<'_>) -> String {