Skip to content

Commit 041fd0c

Browse files
committed
minor cleanup
1 parent 6318af8 commit 041fd0c

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ codegen-units = 1
9595
# lto = true
9696

9797
[profile.release.package.rustc_mir_build]
98-
opt-level = 1
98+
opt-level = 0
9999
[profile.release.package.rustc_driver]
100-
opt-level = 1
100+
opt-level = 0

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
5656
((prefix.len() + suffix.len()).try_into().unwrap(), false)
5757
};
5858

59-
let mut prefix_opt = false;
60-
61-
if self.is_constant_pattern_subslice(prefix) && opt_slice.is_none() && suffix.len() == 0 {
59+
if self.subslice_work_optimizing(prefix) {
6260
let elem_ty = prefix[0].ty;
6361
let prefix_valtree = self.simplify_const_pattern_slice_into_valtree(prefix);
6462

@@ -72,10 +70,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7270
);
7371

7472
match_pairs.push(match_pair);
75-
prefix_opt = true;
76-
}
77-
78-
if !prefix_opt {
73+
} else {
7974
match_pairs.extend(prefix.iter().enumerate().map(|(idx, subpattern)| {
8075
let elem = ProjectionElem::ConstantIndex {
8176
offset: idx as u64,
@@ -108,17 +103,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
108103
}));
109104
}
110105

111-
fn is_constant_pattern_subslice(&self, subslice: &[Box<Pat<'tcx>>]) -> bool {
112-
subslice.len() > 1 && subslice.iter().all(|p| self.is_constant_pattern(p))
106+
fn subslice_work_optimizing(&self, subslice: &[Box<Pat<'tcx>>]) -> bool {
107+
slice.len() > 1 && subslice.iter().all(|p| self.is_constant_pattern(p))
113108
}
114109

115110
fn is_constant_pattern(&self, pat: &Pat<'tcx>) -> bool {
116111
if let PatKind::Constant { value } = pat.kind
117112
&& let Const::Ty(_, const_) = value
118113
&& let ty::ConstKind::Value(ty, valtree) = const_.kind()
119-
&& let ty::ValTree::Leaf(scalar) = valtree
114+
&& let ty::ValTree::Leaf(_) = valtree
120115
&& self.tcx.types.u8 == ty
121-
&& scalar.to_u8() != b'_'
122116
{
123117
true
124118
} else {

0 commit comments

Comments
 (0)