forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#116042 - Nadrieril:linear-pass-take-2, r=<try>
[Experiment] Rewrite exhaustiveness in one pass Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness. This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this. I had started the experiment in rust-lang#111720 but I can't reopen it. r? `@ghost`
- Loading branch information
Showing
45 changed files
with
1,605 additions
and
1,373 deletions.
There are no files selected for viewing
834 changes: 400 additions & 434 deletions
834
compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Large diffs are not rendered by default.
Oops, something went wrong.
212 changes: 75 additions & 137 deletions
212
compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
Large diffs are not rendered by default.
Oops, something went wrong.
874 changes: 503 additions & 371 deletions
874
compiler/rustc_mir_build/src/thir/pattern/usefulness.rs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![feature(if_let_guard, let_chains)] | ||
|
||
fn main() { | ||
let mut x = Some(String::new()); | ||
let ref mut y @ ref mut z = x; | ||
//~^ ERROR: mutable more than once | ||
let Some(ref mut y @ ref mut z) = x else { return }; | ||
//~^ ERROR: mutable more than once | ||
if let Some(ref mut y @ ref mut z) = x {} | ||
//~^ ERROR: mutable more than once | ||
if let Some(ref mut y @ ref mut z) = x && true {} | ||
//~^ ERROR: mutable more than once | ||
while let Some(ref mut y @ ref mut z) = x {} | ||
//~^ ERROR: mutable more than once | ||
while let Some(ref mut y @ ref mut z) = x && true {} | ||
//~^ ERROR: mutable more than once | ||
match x { | ||
ref mut y @ ref mut z => {} //~ ERROR: mutable more than once | ||
} | ||
match () { | ||
() if let Some(ref mut y @ ref mut z) = x => {} //~ ERROR: mutable more than once | ||
_ => {} | ||
} | ||
} |
Oops, something went wrong.