1
Fork 0

Tweak ptr in pattern error

Conform to error style guide.
This commit is contained in:
Esteban Küber 2024-11-20 03:00:58 +00:00
parent cc492edc9d
commit c0f00086f8
8 changed files with 109 additions and 54 deletions

View file

@ -274,7 +274,9 @@ mir_build_non_partial_eq_match =
mir_build_pattern_not_covered = refutable pattern in {$origin}
.pattern_ty = the matched value is of type `{$pattern_ty}`
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.
mir_build_pointer_pattern = function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
.label = can't be used in patterns
.note = see https://github.com/rust-lang/rust/issues/70861 for details
mir_build_privately_uninhabited = pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future

View file

@ -916,8 +916,10 @@ pub(crate) struct NaNPattern {
#[derive(Diagnostic)]
#[diag(mir_build_pointer_pattern)]
#[note]
pub(crate) struct PointerPattern {
#[primary_span]
#[label]
pub(crate) span: Span,
}

View file

@ -18,7 +18,6 @@ const ALLOWLIST: &[&str] = &[
"const_eval_validation_failure_note",
"driver_impl_ice",
"incremental_corrupt_file",
"mir_build_pointer_pattern",
];
fn check_period(filename: &str, contents: &str, bad: &mut bool) {

View file

@ -1,38 +1,46 @@
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
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:9:9
|
LL | const C: *const u8 = &0;
| ------------------ constant defined here
...
LL | C => {}
| ^
| ^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:16:9
|
LL | const C_INNER: (*const u8, u8) = (C, 0);
| ------------------------------ constant defined here
...
LL | C_INNER => {}
| ^^^^^^^
| ^^^^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:27:9
|
LL | const D: *const [u8; 4] = b"abcd";
| ----------------------- constant defined here
...
LL | D => {}
| ^
| ^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/issue-34784-match-on-non-int-raw-ptr.rs:32:9
|
LL | const STR: *const str = "abcd";
| --------------------- constant defined here
...
LL | STR => {}
| ^^^
| ^^^ can't be used in patterns
|
= note: see https://github.com/rust-lang/rust/issues/70861 for details
error: aborting due to 4 previous errors

View file

@ -1,20 +1,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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/issue-44333.rs:15:9
|
LL | const FOO: Func = foo;
| --------------- constant defined here
...
LL | FOO => println!("foo"),
| ^^^
| ^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/issue-44333.rs:16:9
|
LL | const BAR: Func = bar;
| --------------- constant defined here
...
LL | BAR => println!("bar"),
| ^^^
| ^^^ can't be used in patterns
|
= note: see https://github.com/rust-lang/rust/issues/70861 for details
error: aborting due to 2 previous errors

View file

@ -1,74 +1,90 @@
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
--> $DIR/consts-opaque.rs:96:9
|
LL | const QUUX: Quux = quux;
| ---------------- constant defined here
...
LL | QUUX => {}
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/consts-opaque.rs:97:9
|
LL | const QUUX: Quux = quux;
| ---------------- constant defined here
...
LL | QUUX => {}
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/consts-opaque.rs:106:9
|
LL | const WRAPQUUX: Wrap<Quux> = Wrap(quux);
| -------------------------- constant defined here
...
LL | WRAPQUUX => {}
| ^^^^^^^^
| ^^^^^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/consts-opaque.rs:107:9
|
LL | const WRAPQUUX: Wrap<Quux> = Wrap(quux);
| -------------------------- constant defined here
...
LL | WRAPQUUX => {}
| ^^^^^^^^
| ^^^^^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/consts-opaque.rs:113:9
|
LL | const WRAPQUUX: Wrap<Quux> = Wrap(quux);
| -------------------------- constant defined here
...
LL | WRAPQUUX => {}
| ^^^^^^^^
| ^^^^^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/consts-opaque.rs:121:9
|
LL | const WRAPQUUX: Wrap<Quux> = Wrap(quux);
| -------------------------- constant defined here
...
LL | WRAPQUUX => {}
| ^^^^^^^^
| ^^^^^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/consts-opaque.rs:132:9
|
LL | const WHOKNOWSQUUX: WhoKnows<Quux> = WhoKnows::Yay(quux);
| ---------------------------------- constant defined here
...
LL | WHOKNOWSQUUX => {}
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/consts-opaque.rs:134:9
|
LL | const WHOKNOWSQUUX: WhoKnows<Quux> = WhoKnows::Yay(quux);
| ---------------------------------- constant defined here
...
LL | WHOKNOWSQUUX => {}
| ^^^^^^^^^^^^
| ^^^^^^^^^^^^ can't be used in patterns
|
= note: see https://github.com/rust-lang/rust/issues/70861 for details
error: unreachable pattern
--> $DIR/consts-opaque.rs:48:9

View file

@ -1,92 +1,112 @@
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
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:41:14
|
LL | const CFN1: Wrap<fn()> = Wrap(trivial);
| ---------------------- constant defined here
...
LL | Wrap(CFN1) => count += 1,
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:49:14
|
LL | const CFN2: Wrap<fn(SM)> = Wrap(sm_to);
| ------------------------ constant defined here
...
LL | Wrap(CFN2) => count += 1,
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:57:14
|
LL | const CFN3: Wrap<fn() -> SM> = Wrap(to_sm);
| ---------------------------- constant defined here
...
LL | Wrap(CFN3) => count += 1,
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:65:14
|
LL | const CFN4: Wrap<fn(NotSM)> = Wrap(not_sm_to);
| --------------------------- constant defined here
...
LL | Wrap(CFN4) => count += 1,
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:73:14
|
LL | const CFN5: Wrap<fn() -> NotSM> = Wrap(to_not_sm);
| ------------------------------- constant defined here
...
LL | Wrap(CFN5) => count += 1,
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:81:14
|
LL | const CFN6: Wrap<fn(&SM)> = Wrap(r_sm_to);
| ------------------------- constant defined here
...
LL | Wrap(CFN6) => count += 1,
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:89:14
|
LL | const CFN7: Wrap<fn(&()) -> &SM> = Wrap(r_to_r_sm);
| -------------------------------- constant defined here
...
LL | Wrap(CFN7) => count += 1,
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:97:14
|
LL | const CFN8: Wrap<fn(&NotSM)> = Wrap(r_not_sm_to);
| ---------------------------- constant defined here
...
LL | Wrap(CFN8) => count += 1,
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:105:14
|
LL | const CFN9: Wrap<fn(&()) -> &NotSM> = Wrap(r_to_r_not_sm);
| ----------------------------------- constant defined here
...
LL | Wrap(CFN9) => count += 1,
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/fn-ptr-is-not-structurally-matchable.rs:127:9
|
LL | const CFOO: Foo = Foo {
| --------------- constant defined here
...
LL | CFOO => count += 1,
| ^^^^
| ^^^^ can't be used in patterns
|
= note: see https://github.com/rust-lang/rust/issues/70861 for details
error: aborting due to 10 previous errors

View file

@ -1,20 +1,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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/issue-63479-match-fnptr.rs:32:7
|
LL | const TEST: Fn = my_fn;
| -------------- constant defined here
...
LL | B(TEST) => println!("matched"),
| ^^^^
| ^^^^ can't be used in patterns
|
= note: 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.
error: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon
--> $DIR/issue-63479-match-fnptr.rs:37:5
|
LL | const TEST2: (Fn, u8) = (TEST, 0);
| --------------------- constant defined here
...
LL | TEST2 => println!("matched"),
| ^^^^^
| ^^^^^ can't be used in patterns
|
= note: see https://github.com/rust-lang/rust/issues/70861 for details
error: aborting due to 2 previous errors