You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwco
patterns: reject raw pointers that are not just integers
Matching against `0 as *const i32` is fine, matching against `&42 as *const i32` is not.
This extends the existing check against function pointers and wide pointers: we now uniformly reject all these pointer types during valtree construction, and then later lint because of that. See [here](#116930 (comment)) for some more explanation and context.
Also fixes#116929.
Cc `@oli-obk` `@lcnr`
Copy file name to clipboardexpand all lines: compiler/rustc_mir_build/messages.ftl
+1-1
Original file line number
Diff line number
Diff line change
@@ -247,7 +247,7 @@ mir_build_overlapping_range_endpoints = multiple patterns overlap on their endpo
247
247
mir_build_pattern_not_covered = refutable pattern in {$origin}
248
248
.pattern_ty = the matched value is of type `{$pattern_ty}`
249
249
250
-
mir_build_pointer_pattern = function pointers and unsized pointers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
250
+
mir_build_pointer_pattern = 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.
251
251
252
252
mir_build_privately_uninhabited = pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future
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/match-edge-cases_1.rs:29:13
3
+
|
4
+
LL | NUMBER_POINTER => (),
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 #62411 <https://github.com/rust-lang/rust/issues/70861>
9
+
= note: `#[warn(pointer_structural_match)]` on by default
error: 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.
error: 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.
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
22
+
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
23
+
24
+
error: 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.
Copy file name to clipboardexpand all lines: tests/ui/consts/const_in_pattern/issue-44333.stderr
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
warning: function pointers and unsized pointers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
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
2
--> $DIR/issue-44333.rs:19:9
3
3
|
4
4
LL | FOO => println!("foo"),
@@ -12,7 +12,7 @@ note: the lint level is defined here
12
12
LL | #![warn(pointer_structural_match)]
13
13
| ^^^^^^^^^^^^^^^^^^^^^^^^
14
14
15
-
warning: function pointers and unsized pointers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
15
+
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.
0 commit comments