-
Notifications
You must be signed in to change notification settings - Fork 13k
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 #56540 - oli-obk:less_const_hackery, r=varkor
Don't depend on `Allocation` sizes for pattern length And generally be more explicit about shortcomings of the implementation cc @RalfJung
- Loading branch information
Showing
10 changed files
with
318 additions
and
89 deletions.
There are no files selected for viewing
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,13 @@ | ||
// failure-status: 101 | ||
|
||
// This is a repro test for an ICE in our pattern handling of constants. | ||
|
||
const FOO: &&&u32 = &&&42; | ||
|
||
fn main() { | ||
match unimplemented!() { | ||
&&&42 => {}, | ||
FOO => {}, | ||
_ => {}, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,24 +1,31 @@ | ||
// compile-pass | ||
#![deny(unreachable_patterns)] | ||
|
||
fn main() { | ||
let s = &[0x00; 4][..]; //Slice of any value | ||
const MAGIC_TEST: &[u32] = &[4, 5, 6, 7]; //Const slice to pattern match with | ||
match s { | ||
MAGIC_TEST => (), | ||
[0x00, 0x00, 0x00, 0x00] => (), | ||
[4, 5, 6, 7] => (), // this should warn | ||
[4, 5, 6, 7] => (), //~ ERROR unreachable pattern | ||
_ => (), | ||
} | ||
match s { | ||
[0x00, 0x00, 0x00, 0x00] => (), | ||
MAGIC_TEST => (), | ||
[4, 5, 6, 7] => (), // this should warn | ||
[4, 5, 6, 7] => (), //~ ERROR unreachable pattern | ||
_ => (), | ||
} | ||
match s { | ||
[0x00, 0x00, 0x00, 0x00] => (), | ||
[4, 5, 6, 7] => (), | ||
MAGIC_TEST => (), // this should warn | ||
MAGIC_TEST => (), // FIXME(oli-obk): this should warn, but currently does not | ||
_ => (), | ||
} | ||
const FOO: [u32; 1] = [4]; | ||
match [99] { | ||
[0x00] => (), | ||
[4] => (), | ||
FOO => (), //~ ERROR unreachable pattern | ||
_ => (), | ||
} | ||
} |
Oops, something went wrong.