diff options
| author | bors <bors@rust-lang.org> | 2021-12-16 15:18:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-12-16 15:18:08 +0000 |
| commit | 1d01550f7ea9fce1cf625128fefc73b9da3c1508 (patch) | |
| tree | 7a0eeb9785986e469b64b8a55bbf683068f1db4d | |
| parent | f8402169aaa12e7bbb9630796a8caec90a3055ca (diff) | |
| parent | 8869dbc2a096c03414a2b872465ca2b0bbe65bbc (diff) | |
| download | rust-1d01550f7ea9fce1cf625128fefc73b9da3c1508.tar.gz rust-1d01550f7ea9fce1cf625128fefc73b9da3c1508.zip | |
Auto merge of #91833 - klensy:rd-minus-alloc, r=jyn514
rustdoc: don't clone already owned `Path` and modify it inplace
| -rw-r--r-- | src/librustdoc/clean/auto_trait.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/clean/utils.rs | 15 |
2 files changed, 6 insertions, 11 deletions
diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 7b66ff7d411..09692d27e8f 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -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) { diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 19b309d6a30..7f7be246367 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -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 { |
