Skip to content

Commit 5026465

Browse files
committed
refactor valtree_to_match_pair for readability
1 parent e494f9a commit 5026465

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

compiler/rustc_mir_build/src/builder/matches/match_pair.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
157157
elem_ty: Ty<'tcx>,
158158
) -> MatchPairTree<'pat, 'tcx> {
159159
let tcx = self.tcx;
160-
tracing::warn!("source pattern type: {:?}", src_pat_ty);
161160
let (const_ty, pat_ty) = match src_pat_ty.kind() {
162-
// wait is source path the wrong thing to care about?
163161
ty::Slice(_) => (
164162
Ty::new_imm_ref(
165163
tcx,
@@ -174,24 +172,21 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
174172
tcx.lifetimes.re_erased,
175173
Ty::new_array(tcx, elem_ty, subslice_len),
176174
),
177-
Ty::new_array(tcx, elem_ty, subslice_len), // WRONG TYPE with too short array len for the move
175+
Ty::new_array(tcx, elem_ty, subslice_len),
178176
),
179-
_ => todo!(),
177+
_ => unreachable!(),
180178
};
181179

182-
tracing::warn!("const and new pattern type: {:?}, {:?}", const_ty, pat_ty);
183-
184-
let r#const = ty::Const::new(tcx, ty::ConstKind::Value(const_ty, valtree));
185-
let r#const2 = Const::Ty(const_ty, r#const);
180+
let ty_cost = ty::Const::new(tcx, ty::ConstKind::Value(const_ty, valtree));
181+
let value = Const::Ty(const_ty, r#ty_cost);
182+
let test_case = TestCase::Constant { value };
186183

187184
let pattern = tcx.arena.alloc(Pat {
188185
ty: pat_ty,
189186
span,
190-
kind: PatKind::Constant { value: Const::Ty(const_ty, r#const) },
187+
kind: PatKind::Constant { value },
191188
});
192189

193-
let test_case = TestCase::Constant { value: r#const2 };
194-
195190
MatchPairTree {
196191
place: Some(place.to_place(self)),
197192
test_case,

0 commit comments

Comments
 (0)