Skip to content

Commit f1f287f

Browse files
committed
add test for ICE "raw ptr comparison should already be caught in the trait system" #105047
Fixes #105047
1 parent e54bff7 commit f1f287f

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// issue: rust-lang/rust#105047
2+
// ICE raw ptr comparison should already be caught in the trait systems
3+
4+
#![feature(raw_ref_op)]
5+
6+
const RCZ: *const i32 = &raw const *&0;
7+
8+
const fn f() {
9+
if let RCZ = &raw const *&0 { }
10+
//~^ WARN function pointers and raw pointers not derived from integers in patterns
11+
//~^^ ERROR pointers cannot be reliably compared during const eval
12+
//~^^^ WARN this was previously accepted by the compiler but is being phased out
13+
}
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
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.
2+
--> $DIR/const-eval-compare-ice-105047.rs:9:12
3+
|
4+
LL | if let RCZ = &raw const *&0 { }
5+
| ^^^
6+
|
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
9+
= note: `#[warn(pointer_structural_match)]` on by default
10+
11+
error: pointers cannot be reliably compared during const eval
12+
--> $DIR/const-eval-compare-ice-105047.rs:9:12
13+
|
14+
LL | if let RCZ = &raw const *&0 { }
15+
| ^^^
16+
|
17+
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information
18+
19+
error: aborting due to 1 previous error; 1 warning emitted
20+
21+
Future incompatibility report: Future breakage diagnostic:
22+
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.
23+
--> $DIR/const-eval-compare-ice-105047.rs:9:12
24+
|
25+
LL | if let RCZ = &raw const *&0 { }
26+
| ^^^
27+
|
28+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
29+
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
30+
= note: `#[warn(pointer_structural_match)]` on by default
31+

0 commit comments

Comments
 (0)