turn pointer_structural_match into a hard error

This commit is contained in:
Ralf Jung 2024-05-03 15:49:10 +02:00
parent 179a6a08b1
commit cbd682beeb
23 changed files with 131 additions and 811 deletions

View File

@ -544,6 +544,11 @@ fn register_builtins(store: &mut LintStore) {
"converted into hard error, see RFC #3535 \
<https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
);
store.register_removed(
"pointer_structural_match",
"converted into hard error, see RFC #3535 \
<https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
);
}
fn register_internals(store: &mut LintStore) {

View File

@ -74,7 +74,6 @@ declare_lint_pass! {
ORDER_DEPENDENT_TRAIT_OBJECTS,
OVERLAPPING_RANGE_ENDPOINTS,
PATTERNS_IN_FNS_WITHOUT_BODY,
POINTER_STRUCTURAL_MATCH,
PRIVATE_BOUNDS,
PRIVATE_INTERFACES,
PROC_MACRO_BACK_COMPAT,
@ -2371,45 +2370,6 @@ declare_lint! {
report_in_external_macro
}
declare_lint! {
/// The `pointer_structural_match` lint detects pointers used in patterns whose behaviour
/// cannot be relied upon across compiler versions and optimization levels.
///
/// ### Example
///
/// ```rust,compile_fail
/// #![deny(pointer_structural_match)]
/// fn foo(a: usize, b: usize) -> usize { a + b }
/// const FOO: fn(usize, usize) -> usize = foo;
/// fn main() {
/// match FOO {
/// FOO => {},
/// _ => {},
/// }
/// }
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// Previous versions of Rust allowed function pointers and all raw pointers in patterns.
/// While these work in many cases as expected by users, it is possible that due to
/// optimizations pointers are "not equal to themselves" or pointers to different functions
/// compare as equal during runtime. This is because LLVM optimizations can deduplicate
/// functions if their bodies are the same, thus also making pointers to these functions point
/// to the same location. Additionally functions may get duplicated if they are instantiated
/// in different crates and not deduplicated again via LTO. Pointer identity for memory
/// created by `const` is similarly unreliable.
pub POINTER_STRUCTURAL_MATCH,
Warn,
"pointers are not structural-match",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
reference: "issue #120362 <https://github.com/rust-lang/rust/issues/120362>",
};
}
declare_lint! {
/// The `ambiguous_associated_items` lint detects ambiguity between
/// [associated items] and [enum variants].

View File

@ -788,9 +788,12 @@ pub struct NaNPattern {
pub span: Span,
}
#[derive(LintDiagnostic)]
#[derive(Diagnostic)]
#[diag(mir_build_pointer_pattern)]
pub struct PointerPattern;
pub struct PointerPattern {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(mir_build_non_empty_never_pattern)]

View File

@ -6,7 +6,6 @@ use rustc_infer::traits::Obligation;
use rustc_middle::mir;
use rustc_middle::thir::{FieldPat, Pat, PatKind};
use rustc_middle::ty::{self, Ty, TyCtxt, ValTree};
use rustc_session::lint;
use rustc_span::{ErrorGuaranteed, Span};
use rustc_target::abi::{FieldIdx, VariantIdx};
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
@ -189,12 +188,9 @@ impl<'tcx> ConstToPat<'tcx> {
} else if !have_valtree {
// The only way valtree construction can fail without the structural match
// checker finding a violation is if there is a pointer somewhere.
self.tcx().emit_node_span_lint(
lint::builtin::POINTER_STRUCTURAL_MATCH,
self.id,
self.span,
PointerPattern,
);
let e = self.tcx().dcx().emit_err(PointerPattern { span: self.span });
let kind = PatKind::Error(e);
return Box::new(Pat { span: self.span, ty: cv.ty(), kind });
}
// Always check for `PartialEq` if we had no other errors yet.

View File

@ -2,8 +2,7 @@
//@ edition:2021
const PATTERN_REF: &str = "Hello World";
const NUMBER: i32 = 30;
const NUMBER_POINTER: *const i32 = &NUMBER;
const NUMBER_POINTER: *const i32 = 30 as *const i32;
pub fn edge_case_ref(event: &str) {
let _ = || {
@ -26,8 +25,7 @@ pub fn edge_case_str(event: String) {
pub fn edge_case_raw_ptr(event: *const i32) {
let _ = || {
match event {
NUMBER_POINTER => (), //~WARN behave unpredictably
//~| previously accepted
NUMBER_POINTER => (),
_ => (),
};
};

View File

@ -1,23 +0,0 @@
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/match-edge-cases_1.rs:29:13
|
LL | NUMBER_POINTER => (),
| ^^^^^^^^^^^^^^
|
= 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
warning: 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/match-edge-cases_1.rs:29:13
|
LL | NUMBER_POINTER => (),
| ^^^^^^^^^^^^^^
|
= 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

View File

@ -1,4 +1,3 @@
#![deny(pointer_structural_match)]
#![allow(dead_code)]
const C: *const u8 = &0;
@ -8,7 +7,6 @@ const C_INNER: (*const u8, u8) = (C, 0);
fn foo(x: *const u8) {
match x {
C => {} //~ERROR: behave unpredictably
//~| previously accepted
_ => {}
}
}
@ -16,7 +14,6 @@ fn foo(x: *const u8) {
fn foo2(x: *const u8) {
match (x, 1) {
C_INNER => {} //~ERROR: behave unpredictably
//~| previously accepted
_ => {}
}
}
@ -28,13 +25,11 @@ const STR: *const str = "abcd";
fn main() {
match D {
D => {} //~ERROR: behave unpredictably
//~| previously accepted
_ => {}
}
match STR {
STR => {} //~ERROR: behave unpredictably
//~| previously accepted
_ => {}
}
}

View File

@ -1,103 +1,26 @@
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.
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:10:9
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:9:9
|
LL | C => {}
| ^
|
= 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: the lint level is defined here
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:1:9
|
LL | #![deny(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
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.
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:18:9
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:16:9
|
LL | C_INNER => {}
| ^^^^^^^
|
= 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>
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.
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:30:9
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:27:9
|
LL | D => {}
| ^
|
= 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>
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.
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:36:9
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:32:9
|
LL | STR => {}
| ^^^
|
= 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>
error: aborting due to 4 previous errors
Future incompatibility report: Future breakage diagnostic:
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.
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:10:9
|
LL | C => {}
| ^
|
= 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: the lint level is defined here
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:1:9
|
LL | #![deny(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
Future breakage diagnostic:
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.
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:18:9
|
LL | C_INNER => {}
| ^^^^^^^
|
= 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: the lint level is defined here
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:1:9
|
LL | #![deny(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
Future breakage diagnostic:
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.
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:30:9
|
LL | D => {}
| ^
|
= 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: the lint level is defined here
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:1:9
|
LL | #![deny(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
Future breakage diagnostic:
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.
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:36:9
|
LL | STR => {}
| ^^^
|
= 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: the lint level is defined here
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:1:9
|
LL | #![deny(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,7 +1,3 @@
//@ run-pass
#![warn(pointer_structural_match)]
type Func = fn(usize, usize) -> usize;
fn foo(a: usize, b: usize) -> usize { a + b }
@ -16,10 +12,8 @@ const BAR: Func = bar;
fn main() {
match test(std::env::consts::ARCH.len()) {
FOO => println!("foo"), //~ WARN behave unpredictably
//~^ WARN will become a hard error
BAR => println!("bar"), //~ WARN behave unpredictably
//~^ WARN will become a hard error
FOO => println!("foo"), //~ ERROR behave unpredictably
BAR => println!("bar"), //~ ERROR behave unpredictably
_ => unreachable!(),
}
}

View File

@ -1,55 +1,14 @@
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/issue-44333.rs:19:9
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.
--> $DIR/issue-44333.rs:15:9
|
LL | FOO => println!("foo"),
| ^^^
|
= 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: the lint level is defined here
--> $DIR/issue-44333.rs:3:9
|
LL | #![warn(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
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/issue-44333.rs:21:9
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.
--> $DIR/issue-44333.rs:16:9
|
LL | BAR => println!("bar"),
| ^^^
|
= 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>
warning: 2 warnings 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/issue-44333.rs:19:9
|
LL | FOO => println!("foo"),
| ^^^
|
= 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: the lint level is defined here
--> $DIR/issue-44333.rs:3:9
|
LL | #![warn(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
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/issue-44333.rs:21:9
|
LL | BAR => println!("bar"),
| ^^^
|
= 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: the lint level is defined here
--> $DIR/issue-44333.rs:3:9
|
LL | #![warn(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -93,10 +93,8 @@ fn main() {
const QUUX: Quux = quux;
match QUUX {
QUUX => {} //~WARN behave unpredictably
//~| previously accepted
QUUX => {} //~WARN behave unpredictably
//~| previously accepted
QUUX => {} //~ERROR behave unpredictably
QUUX => {} //~ERROR behave unpredictably
_ => {}
}
@ -105,17 +103,14 @@ fn main() {
const WRAPQUUX: Wrap<Quux> = Wrap(quux);
match WRAPQUUX {
WRAPQUUX => {} //~WARN behave unpredictably
//~| previously accepted
WRAPQUUX => {} //~WARN behave unpredictably
//~| previously accepted
WRAPQUUX => {} //~ERROR behave unpredictably
WRAPQUUX => {} //~ERROR behave unpredictably
Wrap(_) => {}
}
match WRAPQUUX {
Wrap(_) => {}
WRAPQUUX => {} //~WARN behave unpredictably
//~| previously accepted
WRAPQUUX => {} //~ERROR behave unpredictably
}
match WRAPQUUX {
@ -123,9 +118,7 @@ fn main() {
}
match WRAPQUUX {
//~^ ERROR: non-exhaustive patterns: `Wrap(_)` not covered
WRAPQUUX => {} //~WARN behave unpredictably
//~| previously accepted
WRAPQUUX => {} //~ERROR behave unpredictably
}
#[derive(PartialEq, Eq)]
@ -136,11 +129,9 @@ fn main() {
const WHOKNOWSQUUX: WhoKnows<Quux> = WhoKnows::Yay(quux);
match WHOKNOWSQUUX {
WHOKNOWSQUUX => {} //~WARN behave unpredictably
//~| previously accepted
WHOKNOWSQUUX => {} //~ERROR behave unpredictably
WhoKnows::Yay(_) => {}
WHOKNOWSQUUX => {} //~WARN behave unpredictably
//~| previously accepted
WHOKNOWSQUUX => {} //~ERROR behave unpredictably
WhoKnows::Nope => {}
}
}

View File

@ -1,75 +1,50 @@
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.
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.
--> $DIR/consts-opaque.rs:96:9
|
LL | QUUX => {}
| ^^^^
|
= 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
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/consts-opaque.rs:98:9
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.
--> $DIR/consts-opaque.rs:97:9
|
LL | QUUX => {}
| ^^^^
|
= 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>
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/consts-opaque.rs:108:9
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.
--> $DIR/consts-opaque.rs:106:9
|
LL | WRAPQUUX => {}
| ^^^^^^^^
|
= 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>
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/consts-opaque.rs:110:9
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.
--> $DIR/consts-opaque.rs:107:9
|
LL | WRAPQUUX => {}
| ^^^^^^^^
|
= 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>
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/consts-opaque.rs:117:9
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.
--> $DIR/consts-opaque.rs:113:9
|
LL | WRAPQUUX => {}
| ^^^^^^^^
|
= 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>
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/consts-opaque.rs:127:9
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.
--> $DIR/consts-opaque.rs:121:9
|
LL | WRAPQUUX => {}
| ^^^^^^^^
|
= 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>
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/consts-opaque.rs:139:9
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.
--> $DIR/consts-opaque.rs:132:9
|
LL | WHOKNOWSQUUX => {}
| ^^^^^^^^^^^^
|
= 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>
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/consts-opaque.rs:142:9
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.
--> $DIR/consts-opaque.rs:134:9
|
LL | WHOKNOWSQUUX => {}
| ^^^^^^^^^^^^
|
= 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>
error: unreachable pattern
--> $DIR/consts-opaque.rs:48:9
@ -146,111 +121,5 @@ error: unreachable pattern
LL | _ => {} // should not be emitting unreachable warning
| ^
error[E0004]: non-exhaustive patterns: `Wrap(_)` not covered
--> $DIR/consts-opaque.rs:125:11
|
LL | match WRAPQUUX {
| ^^^^^^^^ pattern `Wrap(_)` not covered
|
note: `Wrap<fn(usize, usize) -> usize>` defined here
--> $DIR/consts-opaque.rs:104:12
|
LL | struct Wrap<T>(T);
| ^^^^
= note: the matched value is of type `Wrap<fn(usize, usize) -> usize>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL | WRAPQUUX => {}, Wrap(_) => todo!()
| ++++++++++++++++++++
error: aborting due to 10 previous errors; 8 warnings emitted
For more information about this error, try `rustc --explain E0004`.
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/consts-opaque.rs:96:9
|
LL | QUUX => {}
| ^^^^
|
= 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
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/consts-opaque.rs:98:9
|
LL | QUUX => {}
| ^^^^
|
= 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
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/consts-opaque.rs:108:9
|
LL | WRAPQUUX => {}
| ^^^^^^^^
|
= 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
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/consts-opaque.rs:110:9
|
LL | WRAPQUUX => {}
| ^^^^^^^^
|
= 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
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/consts-opaque.rs:117:9
|
LL | WRAPQUUX => {}
| ^^^^^^^^
|
= 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
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/consts-opaque.rs:127:9
|
LL | WRAPQUUX => {}
| ^^^^^^^^
|
= 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
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/consts-opaque.rs:139:9
|
LL | WHOKNOWSQUUX => {}
| ^^^^^^^^^^^^
|
= 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
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/consts-opaque.rs:142:9
|
LL | WHOKNOWSQUUX => {}
| ^^^^^^^^^^^^
|
= 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: aborting due to 17 previous errors

View File

@ -1,15 +0,0 @@
// 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() {}

View File

@ -1,31 +0,0 @@
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

View File

@ -1,26 +0,0 @@
// Test explores how `#[structral_match]` behaves in tandem with
// `*const` and `*mut` pointers.
//@ run-pass
#![warn(pointer_structural_match)]
struct NoDerive(#[allow(dead_code)] i32);
// This impl makes NoDerive irreflexive
// (which doesn't matter here because `<*const T>::eq` won't recur on `T`).
impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
impl Eq for NoDerive { }
#[derive(PartialEq, Eq)]
struct WrapEmbedded(*const NoDerive);
const WRAP_UNSAFE_EMBEDDED: WrapEmbedded = WrapEmbedded(std::ptr::null());
fn main() {
match WRAP_UNSAFE_EMBEDDED {
WRAP_UNSAFE_EMBEDDED => { println!("WRAP_UNSAFE_EMBEDDED correctly matched itself"); }
_ => { panic!("WRAP_UNSAFE_EMBEDDED did not match itself"); }
}
}

View File

@ -1,26 +0,0 @@
// Test explores how `#[structral_match]` behaves in tandem with
// `*const` and `*mut` pointers.
//@ run-pass
#![warn(pointer_structural_match)]
struct NoDerive(#[allow(dead_code)] i32);
// This impl makes NoDerive irreflexive
// (which doesn't matter here because `<*const T>::eq` won't recur on `T`).
impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
impl Eq for NoDerive { }
#[derive(PartialEq, Eq)]
struct WrapParam<X>(*const X);
const WRAP_UNSAFE_PARAM: WrapParam<NoDerive> = WrapParam(std::ptr::null());
fn main() {
match WRAP_UNSAFE_PARAM {
WRAP_UNSAFE_PARAM => { println!("WRAP_UNSAFE_PARAM correctly matched itself"); }
_ => { panic!("WRAP_UNSAFE_PARAM did not match itself"); }
}
}

View File

@ -1,26 +0,0 @@
// Test explores how `#[structral_match]` behaves in tandem with
// `*const` and `*mut` pointers.
//@ run-pass
#![warn(pointer_structural_match)]
struct NoDerive(#[allow(dead_code)] i32);
// This impl makes NoDerive irreflexive
// (which doesn't matter here because `<*const T>::eq` won't recur on `T`).
impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
impl Eq for NoDerive { }
#[derive(PartialEq, Eq)]
struct WrapEmbedded(*const NoDerive);
const WRAP_UNSAFE_EMBEDDED: & &WrapEmbedded = & &WrapEmbedded(std::ptr::null());
fn main() {
match WRAP_UNSAFE_EMBEDDED {
WRAP_UNSAFE_EMBEDDED => { println!("WRAP_UNSAFE_EMBEDDED correctly matched itself"); }
_ => { panic!("WRAP_UNSAFE_EMBEDDED did not match itself"); }
}
}

View File

@ -1,26 +0,0 @@
// Test explores how `#[structral_match]` behaves in tandem with
// `*const` and `*mut` pointers.
//@ run-pass
#![warn(pointer_structural_match)]
struct NoDerive(#[allow(dead_code)] i32);
// This impl makes NoDerive irreflexive
// (which doesn't matter here because `<*const T>::eq` won't recur on `T`).
impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
impl Eq for NoDerive { }
#[derive(PartialEq, Eq)]
struct WrapParam<X>(*const X);
const WRAP_UNSAFE_PARAM: & &WrapParam<NoDerive> = & &WrapParam(std::ptr::null());
fn main() {
match WRAP_UNSAFE_PARAM {
WRAP_UNSAFE_PARAM => { println!("WRAP_UNSAFE_PARAM correctly matched itself"); }
_ => { panic!("WRAP_UNSAFE_PARAM did not match itself"); }
}
}

View File

@ -1,7 +1,5 @@
//@ run-pass
// This file checks that fn ptrs are considered structurally matchable.
// See also rust-lang/rust#63479.
// This file checks that fn ptrs are *not* considered structurally matchable.
// See also rust-lang/rust#63479 and RFC 3535.
fn main() {
let mut count = 0;
@ -40,8 +38,7 @@ fn main() {
const CFN1: Wrap<fn()> = Wrap(trivial);
let input: Wrap<fn()> = Wrap(trivial);
match Wrap(input) {
Wrap(CFN1) => count += 1, //~WARN behave unpredictably
//~| previously accepted
Wrap(CFN1) => count += 1, //~ERROR behave unpredictably
Wrap(_) => {}
};
@ -49,8 +46,7 @@ fn main() {
const CFN2: Wrap<fn(SM)> = Wrap(sm_to);
let input: Wrap<fn(SM)> = Wrap(sm_to);
match Wrap(input) {
Wrap(CFN2) => count += 1, //~WARN behave unpredictably
//~| previously accepted
Wrap(CFN2) => count += 1, //~ERROR behave unpredictably
Wrap(_) => {}
};
@ -58,8 +54,7 @@ fn main() {
const CFN3: Wrap<fn() -> SM> = Wrap(to_sm);
let input: Wrap<fn() -> SM> = Wrap(to_sm);
match Wrap(input) {
Wrap(CFN3) => count += 1, //~WARN behave unpredictably
//~| previously accepted
Wrap(CFN3) => count += 1, //~ERROR behave unpredictably
Wrap(_) => {}
};
@ -67,8 +62,7 @@ fn main() {
const CFN4: Wrap<fn(NotSM)> = Wrap(not_sm_to);
let input: Wrap<fn(NotSM)> = Wrap(not_sm_to);
match Wrap(input) {
Wrap(CFN4) => count += 1, //~WARN behave unpredictably
//~| previously accepted
Wrap(CFN4) => count += 1, //~ERROR behave unpredictably
Wrap(_) => {}
};
@ -76,8 +70,7 @@ fn main() {
const CFN5: Wrap<fn() -> NotSM> = Wrap(to_not_sm);
let input: Wrap<fn() -> NotSM> = Wrap(to_not_sm);
match Wrap(input) {
Wrap(CFN5) => count += 1, //~WARN behave unpredictably
//~| previously accepted
Wrap(CFN5) => count += 1, //~ERROR behave unpredictably
Wrap(_) => {}
};
@ -85,8 +78,7 @@ fn main() {
const CFN6: Wrap<fn(&SM)> = Wrap(r_sm_to);
let input: Wrap<fn(&SM)> = Wrap(r_sm_to);
match Wrap(input) {
Wrap(CFN6) => count += 1, //~WARN behave unpredictably
//~| previously accepted
Wrap(CFN6) => count += 1, //~ERROR behave unpredictably
Wrap(_) => {}
};
@ -94,8 +86,7 @@ fn main() {
const CFN7: Wrap<fn(&()) -> &SM> = Wrap(r_to_r_sm);
let input: Wrap<fn(&()) -> &SM> = Wrap(r_to_r_sm);
match Wrap(input) {
Wrap(CFN7) => count += 1, //~WARN behave unpredictably
//~| previously accepted
Wrap(CFN7) => count += 1, //~ERROR behave unpredictably
Wrap(_) => {}
};
@ -103,8 +94,7 @@ fn main() {
const CFN8: Wrap<fn(&NotSM)> = Wrap(r_not_sm_to);
let input: Wrap<fn(&NotSM)> = Wrap(r_not_sm_to);
match Wrap(input) {
Wrap(CFN8) => count += 1, //~WARN behave unpredictably
//~| previously accepted
Wrap(CFN8) => count += 1, //~ERROR behave unpredictably
Wrap(_) => {}
};
@ -112,8 +102,7 @@ fn main() {
const CFN9: Wrap<fn(&()) -> &NotSM> = Wrap(r_to_r_not_sm);
let input: Wrap<fn(&()) -> &NotSM> = Wrap(r_to_r_not_sm);
match Wrap(input) {
Wrap(CFN9) => count += 1, //~WARN behave unpredictably
//~| previously accepted
Wrap(CFN9) => count += 1, //~ERROR behave unpredictably
Wrap(_) => {}
};
@ -135,8 +124,7 @@ fn main() {
let input = Foo { alpha: not_sm_to, beta: to_not_sm, gamma: sm_to, delta: to_sm };
match input {
CFOO => count += 1, //~WARN behave unpredictably
//~| previously accepted
CFOO => count += 1, //~ERROR behave unpredictably
Foo { .. } => {}
};

View File

@ -0,0 +1,62 @@
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.
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:41:14
|
LL | Wrap(CFN1) => count += 1,
| ^^^^
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.
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:49:14
|
LL | Wrap(CFN2) => count += 1,
| ^^^^
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.
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:57:14
|
LL | Wrap(CFN3) => count += 1,
| ^^^^
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.
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:65:14
|
LL | Wrap(CFN4) => count += 1,
| ^^^^
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.
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:73:14
|
LL | Wrap(CFN5) => count += 1,
| ^^^^
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.
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:81:14
|
LL | Wrap(CFN6) => count += 1,
| ^^^^
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.
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:89:14
|
LL | Wrap(CFN7) => count += 1,
| ^^^^
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.
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:97:14
|
LL | Wrap(CFN8) => count += 1,
| ^^^^
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.
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:105:14
|
LL | Wrap(CFN9) => count += 1,
| ^^^^
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.
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:127:9
|
LL | CFOO => count += 1,
| ^^^^
error: aborting due to 10 previous errors

View File

@ -1,203 +0,0 @@
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/fn-ptr-is-structurally-matchable.rs:43:14
|
LL | Wrap(CFN1) => count += 1,
| ^^^^
|
= 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
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/fn-ptr-is-structurally-matchable.rs:52:14
|
LL | Wrap(CFN2) => count += 1,
| ^^^^
|
= 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>
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/fn-ptr-is-structurally-matchable.rs:61:14
|
LL | Wrap(CFN3) => count += 1,
| ^^^^
|
= 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>
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/fn-ptr-is-structurally-matchable.rs:70:14
|
LL | Wrap(CFN4) => count += 1,
| ^^^^
|
= 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>
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/fn-ptr-is-structurally-matchable.rs:79:14
|
LL | Wrap(CFN5) => count += 1,
| ^^^^
|
= 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>
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/fn-ptr-is-structurally-matchable.rs:88:14
|
LL | Wrap(CFN6) => count += 1,
| ^^^^
|
= 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>
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/fn-ptr-is-structurally-matchable.rs:97:14
|
LL | Wrap(CFN7) => count += 1,
| ^^^^
|
= 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>
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/fn-ptr-is-structurally-matchable.rs:106:14
|
LL | Wrap(CFN8) => count += 1,
| ^^^^
|
= 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>
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/fn-ptr-is-structurally-matchable.rs:115:14
|
LL | Wrap(CFN9) => count += 1,
| ^^^^
|
= 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>
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/fn-ptr-is-structurally-matchable.rs:138:9
|
LL | CFOO => count += 1,
| ^^^^
|
= 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>
warning: 10 warnings 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/fn-ptr-is-structurally-matchable.rs:43:14
|
LL | Wrap(CFN1) => count += 1,
| ^^^^
|
= 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
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/fn-ptr-is-structurally-matchable.rs:52:14
|
LL | Wrap(CFN2) => count += 1,
| ^^^^
|
= 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
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/fn-ptr-is-structurally-matchable.rs:61:14
|
LL | Wrap(CFN3) => count += 1,
| ^^^^
|
= 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
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/fn-ptr-is-structurally-matchable.rs:70:14
|
LL | Wrap(CFN4) => count += 1,
| ^^^^
|
= 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
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/fn-ptr-is-structurally-matchable.rs:79:14
|
LL | Wrap(CFN5) => count += 1,
| ^^^^
|
= 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
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/fn-ptr-is-structurally-matchable.rs:88:14
|
LL | Wrap(CFN6) => count += 1,
| ^^^^
|
= 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
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/fn-ptr-is-structurally-matchable.rs:97:14
|
LL | Wrap(CFN7) => count += 1,
| ^^^^
|
= 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
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/fn-ptr-is-structurally-matchable.rs:106:14
|
LL | Wrap(CFN8) => count += 1,
| ^^^^
|
= 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
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/fn-ptr-is-structurally-matchable.rs:115:14
|
LL | Wrap(CFN9) => count += 1,
| ^^^^
|
= 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
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/fn-ptr-is-structurally-matchable.rs:138:9
|
LL | CFOO => count += 1,
| ^^^^
|
= 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

View File

@ -1,12 +1,8 @@
//@ run-pass
// The actual regression test from #63479. (Including this because my
// first draft at fn-ptr-is-structurally-matchable.rs failed to actually
// cover the case this hit; I've since expanded it accordingly, but the
// experience left me wary of leaving this regression test out.)
#![warn(pointer_structural_match)]
#[derive(Eq)]
struct A {
a: i64
@ -34,14 +30,12 @@ fn main() {
let s = B(my_fn);
match s {
B(TEST) => println!("matched"),
//~^ WARN behave unpredictably
//~| WARN this was previously accepted by the compiler but is being phased out
//~^ ERROR behave unpredictably
_ => panic!("didn't match")
};
match (s.0, 0) {
TEST2 => println!("matched"),
//~^ WARN behave unpredictably
//~| WARN this was previously accepted by the compiler but is being phased out
//~^ ERROR behave unpredictably
_ => panic!("didn't match")
}
}

View File

@ -1,55 +1,14 @@
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/issue-63479-match-fnptr.rs:36:7
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.
--> $DIR/issue-63479-match-fnptr.rs:32:7
|
LL | B(TEST) => println!("matched"),
| ^^^^
|
= 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: the lint level is defined here
--> $DIR/issue-63479-match-fnptr.rs:8:9
|
LL | #![warn(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
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/issue-63479-match-fnptr.rs:42:5
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.
--> $DIR/issue-63479-match-fnptr.rs:37:5
|
LL | TEST2 => println!("matched"),
| ^^^^^
|
= 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>
warning: 2 warnings 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/issue-63479-match-fnptr.rs:36:7
|
LL | B(TEST) => println!("matched"),
| ^^^^
|
= 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: the lint level is defined here
--> $DIR/issue-63479-match-fnptr.rs:8:9
|
LL | #![warn(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
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/issue-63479-match-fnptr.rs:42:5
|
LL | TEST2 => println!("matched"),
| ^^^^^
|
= 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: the lint level is defined here
--> $DIR/issue-63479-match-fnptr.rs:8:9
|
LL | #![warn(pointer_structural_match)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors