mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
```
error: constant of non-structural type `partial_eq::S` in a pattern
--> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:16:18
|
LL | struct S;
| -------- `partial_eq::S` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
...
LL | const C: S = S;
| ---------- constant defined here
...
LL | Some(C) => {}
| ^ constant of non-structural type
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
--> $DIR/suggest_equality_comparison_instead_of_pattern_matching.rs:5:5
|
LL | impl PartialEq<S> for S {
| ^^^^^^^^^^^^^^^^^^^^^^^
help: add a condition to the match arm checking for equality
|
LL - Some(C) => {}
LL + Some(binding) if binding == C => {}
|
```
224 lines
11 KiB
Plaintext
224 lines
11 KiB
Plaintext
error: constant of non-structural type `NoDerive` in a pattern
|
|
--> $DIR/reject_non_structural.rs:60:36
|
|
|
|
|
LL | struct NoDerive;
|
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
|
...
|
|
LL | const ENUM: Derive<NoDerive> = Derive::Some(NoDerive);
|
|
| ---------------------------- constant defined here
|
|
LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
|
| ^^^^ constant of non-structural type
|
|
|
|
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
--> $DIR/reject_non_structural.rs:32:1
|
|
|
|
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: add a condition to the match arm checking for equality
|
|
|
|
|
LL - match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
|
LL + match Derive::Some(NoDerive) { binding if binding == ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
|
|
|
|
|
|
error: constant of non-structural type `NoDerive` in a pattern
|
|
--> $DIR/reject_non_structural.rs:65:28
|
|
|
|
|
LL | struct NoDerive;
|
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
|
...
|
|
LL | const FIELD: OND = TrivialEq(Some(NoDerive)).0;
|
|
| ---------------- constant defined here
|
|
LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
|
| ^^^^^ constant of non-structural type
|
|
|
|
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
--> $DIR/reject_non_structural.rs:32:1
|
|
|
|
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: add a condition to the match arm checking for equality
|
|
|
|
|
LL - match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
|
LL + match Some(NoDerive) { binding if binding == FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
|
|
|
|
|
|
error: constant of non-structural type `NoDerive` in a pattern
|
|
--> $DIR/reject_non_structural.rs:71:27
|
|
|
|
|
LL | struct NoDerive;
|
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
|
...
|
|
LL | const INDIRECT: OND = NO_DERIVE_SOME;
|
|
| ------------------- constant defined here
|
|
LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
|
| ^^^^^^^^ constant of non-structural type
|
|
|
|
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
--> $DIR/reject_non_structural.rs:32:1
|
|
|
|
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: add a condition to the match arm checking for equality
|
|
|
|
|
LL - match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
|
LL + match Some(NoDerive) {binding if binding == INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
|
|
|
|
|
|
error: constant of non-structural type `NoDerive` in a pattern
|
|
--> $DIR/reject_non_structural.rs:76:36
|
|
|
|
|
LL | struct NoDerive;
|
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
|
...
|
|
LL | const TUPLE: (OND, OND) = (None, Some(NoDerive));
|
|
| ----------------------- constant defined here
|
|
LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
|
| ^^^^^ constant of non-structural type
|
|
|
|
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
--> $DIR/reject_non_structural.rs:32:1
|
|
|
|
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: add a condition to the match arm checking for equality
|
|
|
|
|
LL - match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
|
LL + match (None, Some(NoDerive)) { binding if binding == TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
|
|
|
|
|
|
error: constant of non-structural type `NoDerive` in a pattern
|
|
--> $DIR/reject_non_structural.rs:81:28
|
|
|
|
|
LL | struct NoDerive;
|
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
|
...
|
|
LL | const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND);
|
|
| -------------------------- constant defined here
|
|
LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
|
| ^^^^^^^^^^^^^^^ constant of non-structural type
|
|
|
|
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
--> $DIR/reject_non_structural.rs:32:1
|
|
|
|
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: add a condition to the match arm checking for equality
|
|
|
|
|
LL - match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
|
LL + match Some(NoDerive) { binding if binding == TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
|
|
|
|
|
|
error: constant of non-structural type `NoDerive` in a pattern
|
|
--> $DIR/reject_non_structural.rs:86:36
|
|
|
|
|
LL | struct NoDerive;
|
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
|
...
|
|
LL | const ARRAY: [OND; 2] = [None, Some(NoDerive)];
|
|
| --------------------- constant defined here
|
|
LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
|
| ^^^^^ constant of non-structural type
|
|
|
|
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
--> $DIR/reject_non_structural.rs:32:1
|
|
|
|
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: add a condition to the match arm checking for equality
|
|
|
|
|
LL - match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
|
LL + match [None, Some(NoDerive)] { binding if binding == ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
|
|
|
|
|
|
error: constant of non-structural type `NoDerive` in a pattern
|
|
--> $DIR/reject_non_structural.rs:91:33
|
|
|
|
|
LL | struct NoDerive;
|
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
|
...
|
|
LL | const REPEAT: [OND; 2] = [Some(NoDerive); 2];
|
|
| ---------------------- constant defined here
|
|
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
|
| ^^^^^^ constant of non-structural type
|
|
|
|
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
--> $DIR/reject_non_structural.rs:32:1
|
|
|
|
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: add a condition to the match arm checking for equality
|
|
|
|
|
LL - match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
|
LL + match [Some(NoDerive); 2] { binding if binding == REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
|
|
|
|
|
|
error: constant of non-structural type `NoDerive` in a pattern
|
|
--> $DIR/reject_non_structural.rs:97:28
|
|
|
|
|
LL | struct NoDerive;
|
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
|
...
|
|
LL | trait Trait: Sized { const ASSOC: Option<Self>; }
|
|
| ------------------ ------------------------- constant defined here
|
|
LL | impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
|
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
|
| ^^^^^^^^^^^^^^^ constant of non-structural type
|
|
|
|
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
--> $DIR/reject_non_structural.rs:32:1
|
|
|
|
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: add a condition to the match arm checking for equality
|
|
|
|
|
LL - match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
|
LL + match Some(NoDerive) { binding if binding == NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
|
|
|
|
|
|
error: constant of non-structural type `NoDerive` in a pattern
|
|
--> $DIR/reject_non_structural.rs:102:28
|
|
|
|
|
LL | struct NoDerive;
|
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
|
...
|
|
LL | const BLOCK: OND = { NoDerive; Some(NoDerive) };
|
|
| ---------------- constant defined here
|
|
LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
|
| ^^^^^ constant of non-structural type
|
|
|
|
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
--> $DIR/reject_non_structural.rs:32:1
|
|
|
|
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: add a condition to the match arm checking for equality
|
|
|
|
|
LL - match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
|
LL + match Some(NoDerive) { binding if binding == BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
|
|
|
|
|
|
error: constant of non-structural type `NoDerive` in a pattern
|
|
--> $DIR/reject_non_structural.rs:107:29
|
|
|
|
|
LL | struct NoDerive;
|
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
|
...
|
|
LL | const ADDR_OF: &OND = &Some(NoDerive);
|
|
| ------------------- constant defined here
|
|
LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
|
| ^^^^^^^ constant of non-structural type
|
|
|
|
|
note: the `PartialEq` trait must be derived, manual `impl`s are not sufficient; see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
--> $DIR/reject_non_structural.rs:32:1
|
|
|
|
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
help: add a condition to the match arm checking for equality
|
|
|
|
|
LL - match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
|
LL + match &Some(NoDerive) { binding if binding == ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
|
|
|
|
|
|
error: aborting due to 10 previous errors
|
|
|