-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #119274 - RalfJung:raw-ptr-pattern-ice, r=compiler-errors
fix ICE when using raw ptr in a pattern Fixes #119270
- Loading branch information
Showing
3 changed files
with
34 additions
and
1 deletion.
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
19 changes: 19 additions & 0 deletions
19
tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs
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,19 @@ | ||
// run-pass | ||
// Eventually this will be rejected (when the future-compat lints are turned into hard errors), and | ||
// then this test can be removed. But meanwhile we should ensure that this works and does not ICE. | ||
struct NoDerive(i32); | ||
|
||
#[derive(PartialEq)] | ||
struct WrapEmbedded(*const NoDerive); | ||
|
||
const WRAP_UNSAFE_EMBEDDED: &&WrapEmbedded = &&WrapEmbedded(std::ptr::null()); | ||
|
||
fn main() { | ||
let b = match WRAP_UNSAFE_EMBEDDED { | ||
WRAP_UNSAFE_EMBEDDED => true, | ||
//~^ WARN: must be annotated with `#[derive(PartialEq, Eq)]` | ||
//~| previously accepted | ||
_ => false, | ||
}; | ||
assert!(b); | ||
} |
14 changes: 14 additions & 0 deletions
14
tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.stderr
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,14 @@ | ||
warning: to use a constant of type `WrapEmbedded` in a pattern, `WrapEmbedded` must be annotated with `#[derive(PartialEq, Eq)]` | ||
--> $DIR/null-raw-ptr-issue-119270.rs:13:9 | ||
| | ||
LL | WRAP_UNSAFE_EMBEDDED => true, | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> | ||
= note: the traits must be derived, manual `impl`s are not sufficient | ||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details | ||
= note: `#[warn(indirect_structural_match)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|