Skip to content

Commit a64efc7

Browse files
committed
Avoid a useless clone of UserTypeProjection
1 parent bf3bb5f commit a64efc7

File tree

2 files changed

+4
-7
lines changed
  • compiler
    • rustc_middle/src/mir
    • rustc_mir_build/src/builder/matches

2 files changed

+4
-7
lines changed

Diff for: compiler/rustc_middle/src/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1516,8 +1516,8 @@ impl<'tcx> UserTypeProjections {
15161516
self.contents.iter().map(|&(ref user_type, _span)| user_type)
15171517
}
15181518

1519-
pub fn push_projection(mut self, user_ty: &UserTypeProjection, span: Span) -> Self {
1520-
self.contents.push((user_ty.clone(), span));
1519+
pub fn push_user_type(mut self, base_user_ty: UserTypeAnnotationIndex, span: Span) -> Self {
1520+
self.contents.push((UserTypeProjection { base: base_user_ty, projs: vec![] }, span));
15211521
self
15221522
}
15231523

Diff for: compiler/rustc_mir_build/src/builder/matches/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -926,12 +926,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
926926
// Note that the variance doesn't apply here, as we are tracking the effect
927927
// of `user_ty` on any bindings contained with subpattern.
928928

929-
let projection = UserTypeProjection {
930-
base: self.canonical_user_type_annotations.push(annotation.clone()),
931-
projs: Vec::new(),
932-
};
929+
let base_user_ty = self.canonical_user_type_annotations.push(annotation.clone());
933930
let subpattern_user_ty =
934-
pattern_user_ty.push_projection(&projection, annotation.span);
931+
pattern_user_ty.push_user_type(base_user_ty, annotation.span);
935932
self.visit_primary_bindings(subpattern, subpattern_user_ty, f)
936933
}
937934

0 commit comments

Comments
 (0)