Skip to content

Commit

Permalink
add test for ICE "raw ptr comparison should already be caught in the …
Browse files Browse the repository at this point in the history
…trait system" rust-lang#105047

Fixes rust-lang#105047
  • Loading branch information
matthiaskrgr authored and RenjiSann committed Mar 25, 2024
1 parent 2b4ca91 commit 612a385
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/ui/raw-ref-op/const-eval-compare-ice-105047.rs
Original file line number Diff line number Diff line change
@@ -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() {}
31 changes: 31 additions & 0 deletions tests/ui/raw-ref-op/const-eval-compare-ice-105047.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 612a385

Please sign in to comment.