diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-23 12:24:40 +0100 |
|---|---|---|
| committer | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-23 12:24:40 +0100 |
| commit | f1f287fadb91451b116ff00a2f8b9c32c5e1571b (patch) | |
| tree | 491d1c7750889996695290ccbf6baaa7af35a72b | |
| parent | e54bff71091e7c3a16c96e2f79328eb73815d7cd (diff) | |
| download | rust-f1f287fadb91451b116ff00a2f8b9c32c5e1571b.tar.gz rust-f1f287fadb91451b116ff00a2f8b9c32c5e1571b.zip | |
add test for ICE "raw ptr comparison should already be caught in the trait system" #105047
Fixes #105047
| -rw-r--r-- | tests/ui/raw-ref-op/const-eval-compare-ice-105047.rs | 15 | ||||
| -rw-r--r-- | tests/ui/raw-ref-op/const-eval-compare-ice-105047.stderr | 31 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/ui/raw-ref-op/const-eval-compare-ice-105047.rs b/tests/ui/raw-ref-op/const-eval-compare-ice-105047.rs new file mode 100644 index 00000000000..0a736a5a8e2 --- /dev/null +++ b/tests/ui/raw-ref-op/const-eval-compare-ice-105047.rs @@ -0,0 +1,15 @@ +// issue: rust-lang/rust#105047 +// ICE raw ptr comparison should already be caught in the trait systems + +#![feature(raw_ref_op)] + +const RCZ: *const i32 = &raw const *&0; + +const fn f() { + if let RCZ = &raw const *&0 { } + //~^ WARN function pointers and raw pointers not derived from integers in patterns + //~^^ ERROR pointers cannot be reliably compared during const eval + //~^^^ WARN this was previously accepted by the compiler but is being phased out +} + +fn main() {} diff --git a/tests/ui/raw-ref-op/const-eval-compare-ice-105047.stderr b/tests/ui/raw-ref-op/const-eval-compare-ice-105047.stderr new file mode 100644 index 00000000000..9c472cda244 --- /dev/null +++ b/tests/ui/raw-ref-op/const-eval-compare-ice-105047.stderr @@ -0,0 +1,31 @@ +warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. + --> $DIR/const-eval-compare-ice-105047.rs:9:12 + | +LL | if let RCZ = &raw const *&0 { } + | ^^^ + | + = 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 #120362 <https://github.com/rust-lang/rust/issues/120362> + = note: `#[warn(pointer_structural_match)]` on by default + +error: pointers cannot be reliably compared during const eval + --> $DIR/const-eval-compare-ice-105047.rs:9:12 + | +LL | if let RCZ = &raw const *&0 { } + | ^^^ + | + = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information + +error: aborting due to 1 previous error; 1 warning emitted + +Future incompatibility report: Future breakage diagnostic: +warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details. + --> $DIR/const-eval-compare-ice-105047.rs:9:12 + | +LL | if let RCZ = &raw const *&0 { } + | ^^^ + | + = 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 #120362 <https://github.com/rust-lang/rust/issues/120362> + = note: `#[warn(pointer_structural_match)]` on by default + |
