diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2025-02-16 21:49:33 +1100 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2025-02-20 20:31:06 +1100 |
| commit | a64efc72d0811732bbbe9b6d8b678bdebd1848a2 (patch) | |
| tree | 30342999597877da20da02a3427be70fac0078f3 | |
| parent | bf3bb5fd37b5dcf54a723c8559bba6718630095b (diff) | |
| download | rust-a64efc72d0811732bbbe9b6d8b678bdebd1848a2.tar.gz rust-a64efc72d0811732bbbe9b6d8b678bdebd1848a2.zip | |
Avoid a useless clone of `UserTypeProjection`
| -rw-r--r-- | compiler/rustc_middle/src/mir/mod.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/builder/matches/mod.rs | 7 |
2 files changed, 4 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index ff493fa65a6..d74a917f33c 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -1516,8 +1516,8 @@ impl<'tcx> UserTypeProjections { self.contents.iter().map(|&(ref user_type, _span)| user_type) } - pub fn push_projection(mut self, user_ty: &UserTypeProjection, span: Span) -> Self { - self.contents.push((user_ty.clone(), span)); + pub fn push_user_type(mut self, base_user_ty: UserTypeAnnotationIndex, span: Span) -> Self { + self.contents.push((UserTypeProjection { base: base_user_ty, projs: vec![] }, span)); self } diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index ed577f7adeb..f551f0ceeda 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -926,12 +926,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Note that the variance doesn't apply here, as we are tracking the effect // of `user_ty` on any bindings contained with subpattern. - let projection = UserTypeProjection { - base: self.canonical_user_type_annotations.push(annotation.clone()), - projs: Vec::new(), - }; + let base_user_ty = self.canonical_user_type_annotations.push(annotation.clone()); let subpattern_user_ty = - pattern_user_ty.push_projection(&projection, annotation.span); + pattern_user_ty.push_user_type(base_user_ty, annotation.span); self.visit_primary_bindings(subpattern, subpattern_user_ty, f) } |
