Skip to content

Rollup of 7 pull requests #126671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jun 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
012a458
Suggest removing unused tuple fields if they are the last fields
May 13, 2024
6b84d75
Add tests
Nadrieril Mar 3, 2024
e74b30e
Tweak simple or-pattern expansion
Nadrieril Mar 20, 2024
5fe2ca6
Always set `otherwise_block`s
Nadrieril Mar 3, 2024
764f086
Use `otherwise_block` for or-pattern shortcutting
Nadrieril Mar 4, 2024
ce374fc
Factor out `finalize_or_candidate`
Nadrieril Mar 20, 2024
7b764be
Expand or-candidates mixed with candidates above
Nadrieril Mar 20, 2024
af10880
Make async drop code more consistent with regular drop code
zetanumbers Jun 17, 2024
1a8eae1
Apply suggestions from oli-obk's review
zetanumbers Jun 18, 2024
de473a5
Test that opaque types can't have themselves as a hidden type with in…
oli-obk Apr 11, 2024
83cb760
run_make_support nm implementation + bin-emit-no-symbols rmake rewrite
Oneirical May 30, 2024
c1597f9
try implementing suggestions
Oneirical Jun 5, 2024
977d3f6
use llvm_readobj in run-make test instead of nm
Oneirical Jun 18, 2024
1299aef
Make pretty printing for `f16` and `f128` consistent
tgross35 Jun 19, 2024
2126c1d
rustc_type_ir: Omit some struct fields from Debug output
fmease Jun 19, 2024
f03bd96
Rollup merge of #123782 - oli-obk:equal_tait_args, r=compiler-errors
fmease Jun 19, 2024
96144c9
Rollup merge of #124580 - gurry:124556-suggest-remove-tuple-field, r=…
fmease Jun 19, 2024
1139111
Rollup merge of #125787 - Oneirical:infinite-test-a-novel, r=jieyouxu
fmease Jun 19, 2024
e111e99
Rollup merge of #126553 - Nadrieril:expand-or-pat-into-above, r=matth…
fmease Jun 19, 2024
ef062ea
Rollup merge of #126594 - zetanumbers:fix-cross-crate-async-drop-glue…
fmease Jun 19, 2024
2bc0cf2
Rollup merge of #126654 - tgross35:f16-f128-pretty-print, r=jackh726
fmease Jun 19, 2024
b980f6d
Rollup merge of #126656 - fmease:skip-debug-for-_, r=compiler-errors
fmease Jun 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tweak simple or-pattern expansion
  • Loading branch information
Nadrieril committed Jun 16, 2024
commit e74b30e3a9f75f8854fb04a6f9b528077c5e9ec5
37 changes: 21 additions & 16 deletions compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1364,9 +1364,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
otherwise_block: BasicBlock,
candidates: &mut [&mut Candidate<'pat, 'tcx>],
) {
let mut split_or_candidate = false;
for candidate in &mut *candidates {
if let [MatchPair { test_case: TestCase::Or { .. }, .. }] = &*candidate.match_pairs {
let expand_or_pats = candidates.iter().any(|candidate| {
matches!(&*candidate.match_pairs, [MatchPair { test_case: TestCase::Or { .. }, .. }])
});

ensure_sufficient_stack(|| {
if expand_or_pats {
// Split a candidate in which the only match-pair is an or-pattern into multiple
// candidates. This is so that
//
Expand All @@ -1376,30 +1379,32 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// }
//
// only generates a single switch.
let match_pair = candidate.match_pairs.pop().unwrap();
self.create_or_subcandidates(candidate, match_pair);
split_or_candidate = true;
}
}

ensure_sufficient_stack(|| {
if split_or_candidate {
// At least one of the candidates has been split into subcandidates.
// We need to change the candidate list to include those.
let mut new_candidates = Vec::new();
for candidate in candidates.iter_mut() {
candidate.visit_leaves(|leaf_candidate| new_candidates.push(leaf_candidate));
if let [MatchPair { test_case: TestCase::Or { .. }, .. }] =
&*candidate.match_pairs
{
let match_pair = candidate.match_pairs.pop().unwrap();
self.create_or_subcandidates(candidate, match_pair);
for subcandidate in candidate.subcandidates.iter_mut() {
new_candidates.push(subcandidate);
}
} else {
new_candidates.push(candidate);
}
}
self.match_candidates(
span,
scrutinee_span,
start_block,
otherwise_block,
&mut *new_candidates,
new_candidates.as_mut_slice(),
);

for candidate in candidates {
self.merge_trivial_subcandidates(candidate);
if !candidate.subcandidates.is_empty() {
self.merge_trivial_subcandidates(candidate);
}
}
} else {
self.match_simplified_candidates(
Expand Down