diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 7b66ff7d41136..09692d27e8fbe 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 19b309d6a30c8..7f7be246367aa 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 {