Skip to content
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

Rollup of 9 pull requests #130163

Closed
wants to merge 36 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1d42d6a
Revert warning empty patterns as unreachable
Nadrieril Aug 28, 2024
46115fd
fix ICE in CMSE type validation
folkertdev Sep 6, 2024
a6c6eda
Remove now redundant check in symlink_hard_link test
madsmtm Sep 7, 2024
6af470e
Reduce visibilities, and add `warn(unreachable_pub)`.
nnethercote Aug 27, 2024
cd9fd27
Factor out some more repetitive code.
nnethercote Aug 28, 2024
a6735e4
Add an explicit ignore message for "up-to-date" tests
Zalathar Sep 9, 2024
ec6fe4e
Streamline `AbortUnwindingCalls`.
nnethercote Aug 28, 2024
cc09ab3
Simplify `verify_candidate_branch`.
nnethercote Aug 29, 2024
181fbd5
Use `let`/`else` to de-indent `ElaborateBoxDerefs::run_pass`.
nnethercote Sep 8, 2024
4f2588f
Remove an unnecessary `continue`.
nnethercote Aug 30, 2024
9cf90b9
Remove some unnecessary dereferences.
nnethercote Aug 30, 2024
7adde3f
Make `CallSite` non-`Copy`.
nnethercote Aug 30, 2024
751c8b4
Use `LocalDecls` in a couple of places.
nnethercote Aug 30, 2024
5445953
Improve consistency in `LowerIntrinsics`.
nnethercote Sep 3, 2024
acccb39
Print a helpful message if any tests were skipped for being up-to-date
Zalathar Sep 9, 2024
3fe7dd6
Remove unnecessary lifetimes in dataflow structs.
nnethercote Sep 5, 2024
bed91f5
Remove unnecessary lifetime in `PlaceCollector`.
nnethercote Sep 6, 2024
1aafeb2
Remove unnecessary lifetime from `OperandCollector`.
nnethercote Sep 6, 2024
28a6dc4
Rename some lifetimes.
nnethercote Sep 6, 2024
dc62f07
Remove `Gatherer`.
nnethercote Sep 6, 2024
0b032f8
Remove `Elaborator`.
nnethercote Sep 6, 2024
5c35027
Remove unnecessary lifetime from `StorageConflictVisitor`.
nnethercote Sep 6, 2024
0f8efb3
Fix ICE caused by missing span in a region error
gurry Sep 9, 2024
e186cc6
do `PolyFnSig` -> `FnSig` conversion later
folkertdev Sep 9, 2024
19b8f9e
use verbose flag as a default value for `rust.verbose-tests`
onur-ozkan Sep 9, 2024
bc70fa2
Stabilize `char::MIN`
okaneco Sep 9, 2024
13ea104
update `rust.verbose-tests` doc in `config.example.toml`
onur-ozkan Sep 9, 2024
59fe4e9
Rollup merge of #129103 - Nadrieril:dont-warn-empty-unreachable, r=co…
matthiaskrgr Sep 9, 2024
1c4c089
Rollup merge of #129929 - nnethercote:rustc_mir_transform-cleanups-2,…
matthiaskrgr Sep 9, 2024
4b41fa6
Rollup merge of #130022 - nnethercote:dataflow-borrowck-lifetimes, r=…
matthiaskrgr Sep 9, 2024
58c8e12
Rollup merge of #130064 - folkertdev:fix-issue-129983, r=compiler-errors
matthiaskrgr Sep 9, 2024
d2f98de
Rollup merge of #130067 - madsmtm:clean-up-fs-test, r=ChrisDenton
matthiaskrgr Sep 9, 2024
c50de21
Rollup merge of #130131 - Zalathar:up-to-date, r=Kobzol
matthiaskrgr Sep 9, 2024
45e315d
Rollup merge of #130137 - gurry:master, r=cjgillot
matthiaskrgr Sep 9, 2024
76247b0
Rollup merge of #130153 - onur-ozkan:verbose-to-verbose-tests, r=Kobzol
matthiaskrgr Sep 9, 2024
f5cc9c8
Rollup merge of #130154 - okaneco:stabilize_char_min, r=cuviper
matthiaskrgr Sep 9, 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
Simplify verify_candidate_branch.
Let chains are perfect for this kind of function.
  • Loading branch information
nnethercote committed Sep 9, 2024
commit cc09ab3c7510548ab5bcc23ca2e9e9517cd6acdf
60 changes: 23 additions & 37 deletions compiler/rustc_mir_transform/src/early_otherwise_branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,42 +310,28 @@ fn verify_candidate_branch<'tcx>(
) -> bool {
// In order for the optimization to be correct, the branch must...
// ...have exactly one statement
let [statement] = branch.statements.as_slice() else {
return false;
};
// ...assign the discriminant of `place` in that statement
let StatementKind::Assign(boxed) = &statement.kind else { return false };
let (discr_place, Rvalue::Discriminant(from_place)) = &**boxed else { return false };
if *from_place != place {
return false;
}
// ...make that assignment to a local
if discr_place.projection.len() != 0 {
return false;
}
// ...terminate on a `SwitchInt` that invalidates that local
let TerminatorKind::SwitchInt { discr: switch_op, targets, .. } = &branch.terminator().kind
else {
return false;
};
if *switch_op != Operand::Move(*discr_place) {
return false;
}
// ...fall through to `destination` if the switch misses
if destination != targets.otherwise() {
return false;
}
// ...have a branch for value `value`
let mut iter = targets.iter();
let Some((target_value, _)) = iter.next() else {
return false;
};
if target_value != value {
return false;
}
// ...and have no more branches
if let Some(_) = iter.next() {
return false;
if let [statement] = branch.statements.as_slice()
// ...assign the discriminant of `place` in that statement
&& let StatementKind::Assign(boxed) = &statement.kind
&& let (discr_place, Rvalue::Discriminant(from_place)) = &**boxed
&& *from_place == place
// ...make that assignment to a local
&& discr_place.projection.is_empty()
// ...terminate on a `SwitchInt` that invalidates that local
&& let TerminatorKind::SwitchInt { discr: switch_op, targets, .. } =
&branch.terminator().kind
&& *switch_op == Operand::Move(*discr_place)
// ...fall through to `destination` if the switch misses
&& destination == targets.otherwise()
// ...have a branch for value `value`
&& let mut iter = targets.iter()
&& let Some((target_value, _)) = iter.next()
&& target_value == value
// ...and have no more branches
&& iter.next().is_none()
{
true
} else {
false
}
true
}