Add additional context for non-sructural type constant used in pattern
- Point at type that should derive `PartialEq` to be structural. - Point at manual `impl PartialEq`, explaining that it is not sufficient to be structural. ``` error: constant of non-structural type `MyType` in a pattern --> $DIR/const-partial_eq-fallback-ice.rs:14:12 | LL | struct MyType; | ------------- `MyType` must be annotated with `#[derive(PartialEq)]` to be usable in patterns ... LL | const CONSTANT: &&MyType = &&MyType; | ------------------------ constant defined here ... LL | if let CONSTANT = &&MyType { | ^^^^^^^^ 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/const-partial_eq-fallback-ice.rs:5:1 | LL | impl PartialEq<usize> for MyType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ```
This commit is contained in:
parent
fb2f6a44c0
commit
335d05aee5
33 changed files with 343 additions and 175 deletions
|
@ -322,12 +322,12 @@ mir_build_trailing_irrefutable_let_patterns = trailing irrefutable {$count ->
|
||||||
*[other] them
|
*[other] them
|
||||||
} into the body
|
} into the body
|
||||||
|
|
||||||
mir_build_type_not_structural =
|
mir_build_type_not_structural = constant of non-structural type `{$non_sm_ty}` in a pattern
|
||||||
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]`
|
.label = constant of non-structural type
|
||||||
|
mir_build_type_not_structural_def = `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
mir_build_type_not_structural_tip =
|
||||||
mir_build_type_not_structural_tip = the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
|
|
||||||
mir_build_unconditional_recursion = function cannot return without recursing
|
mir_build_unconditional_recursion = function cannot return without recursing
|
||||||
.label = cannot return without recursing
|
.label = cannot return without recursing
|
||||||
|
|
|
@ -882,12 +882,17 @@ pub(crate) struct UnionPattern {
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build_type_not_structural)]
|
#[diag(mir_build_type_not_structural)]
|
||||||
#[note(mir_build_type_not_structural_tip)]
|
|
||||||
#[note(mir_build_type_not_structural_more_info)]
|
|
||||||
pub(crate) struct TypeNotStructural<'tcx> {
|
pub(crate) struct TypeNotStructural<'tcx> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
#[label]
|
||||||
pub(crate) span: Span,
|
pub(crate) span: Span,
|
||||||
|
#[label(mir_build_type_not_structural_def)]
|
||||||
|
pub(crate) ty_def_span: Span,
|
||||||
pub(crate) non_sm_ty: Ty<'tcx>,
|
pub(crate) non_sm_ty: Ty<'tcx>,
|
||||||
|
#[note(mir_build_type_not_structural_tip)]
|
||||||
|
pub(crate) manual_partialeq_impl_span: Option<Span>,
|
||||||
|
#[note(mir_build_type_not_structural_more_info)]
|
||||||
|
pub(crate) manual_partialeq_impl_note: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
|
|
|
@ -254,7 +254,22 @@ impl<'tcx> ConstToPat<'tcx> {
|
||||||
// Extremely important check for all ADTs! Make sure they opted-in to be used in
|
// Extremely important check for all ADTs! Make sure they opted-in to be used in
|
||||||
// patterns.
|
// patterns.
|
||||||
debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty);
|
debug!("adt_def {:?} has !type_marked_structural for cv.ty: {:?}", adt_def, ty);
|
||||||
let err = TypeNotStructural { span, non_sm_ty: ty };
|
let ty_def_span = tcx.def_span(adt_def.did());
|
||||||
|
let mut manual_partialeq_impl_span = None;
|
||||||
|
let partial_eq_trait_id =
|
||||||
|
tcx.require_lang_item(hir::LangItem::PartialEq, Some(self.span));
|
||||||
|
tcx.for_each_relevant_impl(partial_eq_trait_id, ty, |def_id| {
|
||||||
|
if def_id.is_local() {
|
||||||
|
manual_partialeq_impl_span = Some(tcx.def_span(def_id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let err = TypeNotStructural {
|
||||||
|
span,
|
||||||
|
non_sm_ty: ty,
|
||||||
|
ty_def_span,
|
||||||
|
manual_partialeq_impl_span,
|
||||||
|
manual_partialeq_impl_note: manual_partialeq_impl_span.is_none(),
|
||||||
|
};
|
||||||
return Err(tcx.dcx().create_err(err));
|
return Err(tcx.dcx().create_err(err));
|
||||||
}
|
}
|
||||||
ty::Adt(adt_def, args) if adt_def.is_enum() => {
|
ty::Adt(adt_def, args) if adt_def.is_enum() => {
|
||||||
|
@ -269,7 +284,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
||||||
adt_def.variants()[variant_index]
|
adt_def.variants()[variant_index]
|
||||||
.fields
|
.fields
|
||||||
.iter()
|
.iter()
|
||||||
.map(|field| field.ty(self.tcx, args)),
|
.map(|field| field.ty(tcx, args)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -278,7 +293,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
||||||
assert!(!def.is_union()); // Valtree construction would never succeed for unions.
|
assert!(!def.is_union()); // Valtree construction would never succeed for unions.
|
||||||
PatKind::Leaf {
|
PatKind::Leaf {
|
||||||
subpatterns: self.field_pats(cv.unwrap_branch().iter().copied().zip(
|
subpatterns: self.field_pats(cv.unwrap_branch().iter().copied().zip(
|
||||||
def.non_enum_variant().fields.iter().map(|field| field.ty(self.tcx, args)),
|
def.non_enum_variant().fields.iter().map(|field| field.ty(tcx, args)),
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,7 +392,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
||||||
let err = InvalidPattern {
|
let err = InvalidPattern {
|
||||||
span,
|
span,
|
||||||
non_sm_ty: ty,
|
non_sm_ty: ty,
|
||||||
prefix: ty.prefix_string(self.tcx).to_string(),
|
prefix: ty.prefix_string(tcx).to_string(),
|
||||||
};
|
};
|
||||||
return Err(tcx.dcx().create_err(err));
|
return Err(tcx.dcx().create_err(err));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,15 +9,13 @@ fn main() {
|
||||||
let _ = Defaulted;
|
let _ = Defaulted;
|
||||||
match None {
|
match None {
|
||||||
consts::SOME => panic!(),
|
consts::SOME => panic!(),
|
||||||
//~^ must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `CustomEq` in a pattern
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
match None {
|
match None {
|
||||||
<Defaulted as consts::AssocConst>::SOME => panic!(),
|
<Defaulted as consts::AssocConst>::SOME => panic!(),
|
||||||
//~^ must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `CustomEq` in a pattern
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,33 @@
|
||||||
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `CustomEq` in a pattern
|
||||||
--> $DIR/cross-crate-fail.rs:11:9
|
--> $DIR/cross-crate-fail.rs:11:9
|
||||||
|
|
|
|
||||||
LL | consts::SOME => panic!(),
|
LL | consts::SOME => panic!(),
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
::: $DIR/auxiliary/consts.rs:11:1
|
::: $DIR/auxiliary/consts.rs:1:1
|
||||||
|
|
|
|
||||||
|
LL | pub struct CustomEq;
|
||||||
|
| ------------------- `CustomEq` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | pub const SOME: Option<CustomEq> = Some(CustomEq);
|
LL | pub const SOME: Option<CustomEq> = Some(CustomEq);
|
||||||
| -------------------------------- constant defined here
|
| -------------------------------- constant defined here
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `CustomEq` in a pattern
|
||||||
--> $DIR/cross-crate-fail.rs:18:9
|
--> $DIR/cross-crate-fail.rs:17:9
|
||||||
|
|
|
|
||||||
LL | <Defaulted as consts::AssocConst>::SOME => panic!(),
|
LL | <Defaulted as consts::AssocConst>::SOME => panic!(),
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
::: $DIR/auxiliary/consts.rs:15:5
|
::: $DIR/auxiliary/consts.rs:1:1
|
||||||
|
|
|
|
||||||
|
LL | pub struct CustomEq;
|
||||||
|
| ------------------- `CustomEq` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const SOME: Option<CustomEq> = Some(CustomEq);
|
LL | const SOME: Option<CustomEq> = Some(CustomEq);
|
||||||
| ---------------------------- constant defined here
|
| ---------------------------- constant defined here
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
|
@ -16,8 +16,7 @@ const BAR_BAZ: Foo = if 42 == 42 {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match Foo::Qux(NoEq) {
|
match Foo::Qux(NoEq) {
|
||||||
BAR_BAZ => panic!(),
|
BAR_BAZ => panic!(), //~ ERROR constant of non-structural type `Foo` in a pattern
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `Foo` in a pattern
|
||||||
--> $DIR/no-eq-branch-fail.rs:19:9
|
--> $DIR/no-eq-branch-fail.rs:19:9
|
||||||
|
|
|
|
||||||
|
LL | enum Foo {
|
||||||
|
| -------- `Foo` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const BAR_BAZ: Foo = if 42 == 42 {
|
LL | const BAR_BAZ: Foo = if 42 == 42 {
|
||||||
| ------------------ constant defined here
|
| ------------------ constant defined here
|
||||||
...
|
...
|
||||||
LL | BAR_BAZ => panic!(),
|
LL | BAR_BAZ => panic!(),
|
||||||
| ^^^^^^^
|
| ^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
|
@ -17,9 +17,29 @@ struct NoPartialEq;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
struct NoDerive;
|
struct NoDerive;
|
||||||
|
//~^ NOTE must be annotated with `#[derive(PartialEq)]`
|
||||||
|
//~| NOTE must be annotated with `#[derive(PartialEq)]`
|
||||||
|
//~| NOTE must be annotated with `#[derive(PartialEq)]`
|
||||||
|
//~| NOTE must be annotated with `#[derive(PartialEq)]`
|
||||||
|
//~| NOTE must be annotated with `#[derive(PartialEq)]`
|
||||||
|
//~| NOTE must be annotated with `#[derive(PartialEq)]`
|
||||||
|
//~| NOTE must be annotated with `#[derive(PartialEq)]`
|
||||||
|
//~| NOTE must be annotated with `#[derive(PartialEq)]`
|
||||||
|
//~| NOTE must be annotated with `#[derive(PartialEq)]`
|
||||||
|
//~| NOTE must be annotated with `#[derive(PartialEq)]`
|
||||||
|
|
||||||
// This impl makes `NoDerive` irreflexive.
|
// This impl makes `NoDerive` irreflexive.
|
||||||
impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
||||||
|
//~^ NOTE StructuralPartialEq.html for details
|
||||||
|
//~| NOTE StructuralPartialEq.html for details
|
||||||
|
//~| NOTE StructuralPartialEq.html for details
|
||||||
|
//~| NOTE StructuralPartialEq.html for details
|
||||||
|
//~| NOTE StructuralPartialEq.html for details
|
||||||
|
//~| NOTE StructuralPartialEq.html for details
|
||||||
|
//~| NOTE StructuralPartialEq.html for details
|
||||||
|
//~| NOTE StructuralPartialEq.html for details
|
||||||
|
//~| NOTE StructuralPartialEq.html for details
|
||||||
|
//~| NOTE StructuralPartialEq.html for details
|
||||||
|
|
||||||
impl Eq for NoDerive { }
|
impl Eq for NoDerive { }
|
||||||
|
|
||||||
|
@ -38,63 +58,53 @@ fn main() {
|
||||||
|
|
||||||
const ENUM: Derive<NoDerive> = Derive::Some(NoDerive); //~ NOTE constant defined here
|
const ENUM: Derive<NoDerive> = Derive::Some(NoDerive); //~ NOTE constant defined here
|
||||||
match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE constant of non-structural type
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
|
||||||
|
|
||||||
const FIELD: OND = TrivialEq(Some(NoDerive)).0; //~ NOTE constant defined here
|
const FIELD: OND = TrivialEq(Some(NoDerive)).0; //~ NOTE constant defined here
|
||||||
match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE constant of non-structural type
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
|
||||||
|
|
||||||
const NO_DERIVE_SOME: OND = Some(NoDerive);
|
const NO_DERIVE_SOME: OND = Some(NoDerive);
|
||||||
const INDIRECT: OND = NO_DERIVE_SOME; //~ NOTE constant defined here
|
const INDIRECT: OND = NO_DERIVE_SOME; //~ NOTE constant defined here
|
||||||
match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE constant of non-structural type
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
|
||||||
|
|
||||||
const TUPLE: (OND, OND) = (None, Some(NoDerive)); //~ NOTE constant defined here
|
const TUPLE: (OND, OND) = (None, Some(NoDerive)); //~ NOTE constant defined here
|
||||||
match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE constant of non-structural type
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
|
||||||
|
|
||||||
const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND); //~ NOTE constant defined here
|
const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND); //~ NOTE constant defined here
|
||||||
match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE constant of non-structural type
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
|
||||||
|
|
||||||
const ARRAY: [OND; 2] = [None, Some(NoDerive)]; //~ NOTE constant defined here
|
const ARRAY: [OND; 2] = [None, Some(NoDerive)]; //~ NOTE constant defined here
|
||||||
match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE constant of non-structural type
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
|
||||||
|
|
||||||
const REPEAT: [OND; 2] = [Some(NoDerive); 2]; //~ NOTE constant defined here
|
const REPEAT: [OND; 2] = [Some(NoDerive); 2]; //~ NOTE constant defined here
|
||||||
match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE constant of non-structural type
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
|
||||||
|
|
||||||
trait Trait: Sized { const ASSOC: Option<Self>; } //~ NOTE constant defined here
|
trait Trait: Sized { const ASSOC: Option<Self>; } //~ NOTE constant defined here
|
||||||
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
||||||
match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE constant of non-structural type
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
|
||||||
|
|
||||||
const BLOCK: OND = { NoDerive; Some(NoDerive) }; //~ NOTE constant defined here
|
const BLOCK: OND = { NoDerive; Some(NoDerive) }; //~ NOTE constant defined here
|
||||||
match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE constant of non-structural type
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
|
||||||
|
|
||||||
const ADDR_OF: &OND = &Some(NoDerive); //~ NOTE constant defined here
|
const ADDR_OF: &OND = &Some(NoDerive); //~ NOTE constant defined here
|
||||||
match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE constant of non-structural type
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,113 +1,173 @@
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:40:36
|
--> $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);
|
LL | const ENUM: Derive<NoDerive> = Derive::Some(NoDerive);
|
||||||
| ---------------------------- constant defined here
|
| ---------------------------- constant defined here
|
||||||
LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
||||||
| ^^^^
|
| ^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: 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 } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:46:28
|
--> $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;
|
LL | const FIELD: OND = TrivialEq(Some(NoDerive)).0;
|
||||||
| ---------------- constant defined here
|
| ---------------- constant defined here
|
||||||
LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
||||||
| ^^^^^
|
| ^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: 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 } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:53:27
|
--> $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;
|
LL | const INDIRECT: OND = NO_DERIVE_SOME;
|
||||||
| ------------------- constant defined here
|
| ------------------- constant defined here
|
||||||
LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: 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 } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:59:36
|
--> $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));
|
LL | const TUPLE: (OND, OND) = (None, Some(NoDerive));
|
||||||
| ----------------------- constant defined here
|
| ----------------------- constant defined here
|
||||||
LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
||||||
| ^^^^^
|
| ^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: 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 } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:65:28
|
--> $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);
|
LL | const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND);
|
||||||
| -------------------------- constant defined here
|
| -------------------------- constant defined here
|
||||||
LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: 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 } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:71:36
|
--> $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)];
|
LL | const ARRAY: [OND; 2] = [None, Some(NoDerive)];
|
||||||
| --------------------- constant defined here
|
| --------------------- constant defined here
|
||||||
LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
||||||
| ^^^^^
|
| ^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: 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 } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:77:33
|
--> $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];
|
LL | const REPEAT: [OND; 2] = [Some(NoDerive); 2];
|
||||||
| ---------------------- constant defined here
|
| ---------------------- constant defined here
|
||||||
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
||||||
| ^^^^^^
|
| ^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: 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 } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:84:28
|
--> $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>; }
|
LL | trait Trait: Sized { const ASSOC: Option<Self>; }
|
||||||
| ------------------ ------------------------- constant defined here
|
| ------------------ ------------------------- constant defined here
|
||||||
LL | impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
LL | impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
||||||
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: 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 } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:90:28
|
--> $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) };
|
LL | const BLOCK: OND = { NoDerive; Some(NoDerive) };
|
||||||
| ---------------- constant defined here
|
| ---------------- constant defined here
|
||||||
LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
||||||
| ^^^^^
|
| ^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: 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 } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/reject_non_structural.rs:96:29
|
--> $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);
|
LL | const ADDR_OF: &OND = &Some(NoDerive);
|
||||||
| ------------------- constant defined here
|
| ------------------- constant defined here
|
||||||
LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
||||||
| ^^^^^^^
|
| ^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: 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 } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
error: aborting due to 10 previous errors
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn main() {
|
||||||
let var = A::Field(Cow::Borrowed("bar"));
|
let var = A::Field(Cow::Borrowed("bar"));
|
||||||
|
|
||||||
match &var {
|
match &var {
|
||||||
FOO => todo!(), //~ERROR derive(PartialEq)
|
FOO => todo!(), //~ ERROR constant of non-structural type `Cow<'_, str>` in a pattern
|
||||||
_ => todo!()
|
_ => todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
error: to use a constant of type `Cow<'_, str>` in a pattern, `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `Cow<'_, str>` in a pattern
|
||||||
--> $DIR/issue-89088.rs:16:9
|
--> $DIR/issue-89088.rs:16:9
|
||||||
|
|
|
|
||||||
LL | const FOO: &A = &A::Field(Cow::Borrowed("foo"));
|
LL | const FOO: &A = &A::Field(Cow::Borrowed("foo"));
|
||||||
| ------------- constant defined here
|
| ------------- constant defined here
|
||||||
...
|
...
|
||||||
LL | FOO => todo!(),
|
LL | FOO => todo!(),
|
||||||
| ^^^
|
| ^^^ constant of non-structural type
|
||||||
|
--> $SRC_DIR/alloc/src/borrow.rs:LL:COL
|
||||||
|
|
|
||||||
|
= note: `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
|
@ -8,8 +8,7 @@ struct T;
|
||||||
fn main() {
|
fn main() {
|
||||||
const C: &S = &S;
|
const C: &S = &S;
|
||||||
match C {
|
match C {
|
||||||
C => {}
|
C => {} //~ ERROR constant of non-structural type `S` in a pattern
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
|
||||||
}
|
}
|
||||||
const K: &T = &T;
|
const K: &T = &T;
|
||||||
match K {
|
match K {
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
error: to use a constant of type `S` in a pattern, `S` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `S` in a pattern
|
||||||
--> $DIR/match_ice.rs:11:9
|
--> $DIR/match_ice.rs:11:9
|
||||||
|
|
|
|
||||||
|
LL | struct S;
|
||||||
|
| -------- `S` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const C: &S = &S;
|
LL | const C: &S = &S;
|
||||||
| ----------- constant defined here
|
| ----------- constant defined here
|
||||||
LL | match C {
|
LL | match C {
|
||||||
LL | C => {}
|
LL | C => {}
|
||||||
| ^
|
| ^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
|
@ -3,5 +3,5 @@ const CONST_STRING: String = String::new();
|
||||||
fn main() {
|
fn main() {
|
||||||
let empty_str = String::from("");
|
let empty_str = String::from("");
|
||||||
if let CONST_STRING = empty_str {}
|
if let CONST_STRING = empty_str {}
|
||||||
//~^ ERROR to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `Vec<u8>` in a pattern
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
error: to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `Vec<u8>` in a pattern
|
||||||
--> $DIR/issue-115599.rs:5:12
|
--> $DIR/issue-115599.rs:5:12
|
||||||
|
|
|
|
||||||
LL | const CONST_STRING: String = String::new();
|
LL | const CONST_STRING: String = String::new();
|
||||||
| -------------------------- constant defined here
|
| -------------------------- constant defined here
|
||||||
...
|
...
|
||||||
LL | if let CONST_STRING = empty_str {}
|
LL | if let CONST_STRING = empty_str {}
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
||||||
|
|
|
||||||
|
= note: `Vec<u8>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
|
@ -12,7 +12,7 @@ const CONSTANT: &&MyType = &&MyType;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let CONSTANT = &&MyType {
|
if let CONSTANT = &&MyType {
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `MyType` in a pattern
|
||||||
println!("did match!");
|
println!("did match!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `MyType` in a pattern
|
||||||
--> $DIR/const-partial_eq-fallback-ice.rs:14:12
|
--> $DIR/const-partial_eq-fallback-ice.rs:14:12
|
||||||
|
|
|
|
||||||
|
LL | struct MyType;
|
||||||
|
| ------------- `MyType` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const CONSTANT: &&MyType = &&MyType;
|
LL | const CONSTANT: &&MyType = &&MyType;
|
||||||
| ------------------------ constant defined here
|
| ------------------------ constant defined here
|
||||||
...
|
...
|
||||||
LL | if let CONSTANT = &&MyType {
|
LL | if let CONSTANT = &&MyType {
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
--> $DIR/const-partial_eq-fallback-ice.rs:5:1
|
||||||
|
|
|
||||||
|
LL | impl PartialEq<usize> for MyType {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0));
|
||||||
fn main() {
|
fn main() {
|
||||||
match WRAP_DIRECT_INLINE {
|
match WRAP_DIRECT_INLINE {
|
||||||
WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
|
WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
_ => { println!("WRAP_DIRECT_INLINE did not match itself"); }
|
_ => { println!("WRAP_DIRECT_INLINE did not match itself"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/cant-hide-behind-direct-struct-embedded.rs:22:9
|
--> $DIR/cant-hide-behind-direct-struct-embedded.rs:22:9
|
||||||
|
|
|
|
||||||
|
LL | struct NoDerive(#[allow(dead_code)] i32);
|
||||||
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0));
|
LL | const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0));
|
||||||
| ------------------------------------ constant defined here
|
| ------------------------------------ constant defined here
|
||||||
...
|
...
|
||||||
LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
|
LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
--> $DIR/cant-hide-behind-direct-struct-embedded.rs:11:1
|
||||||
|
|
|
||||||
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ const WRAP_DIRECT_PARAM: WrapParam<NoDerive> = WrapParam(NoDerive(0));
|
||||||
fn main() {
|
fn main() {
|
||||||
match WRAP_DIRECT_PARAM {
|
match WRAP_DIRECT_PARAM {
|
||||||
WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
|
WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
_ => { println!("WRAP_DIRECT_PARAM did not match itself"); }
|
_ => { println!("WRAP_DIRECT_PARAM did not match itself"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/cant-hide-behind-direct-struct-param.rs:21:9
|
--> $DIR/cant-hide-behind-direct-struct-param.rs:21:9
|
||||||
|
|
|
|
||||||
|
LL | struct NoDerive(i32);
|
||||||
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const WRAP_DIRECT_PARAM: WrapParam<NoDerive> = WrapParam(NoDerive(0));
|
LL | const WRAP_DIRECT_PARAM: WrapParam<NoDerive> = WrapParam(NoDerive(0));
|
||||||
| -------------------------------------------- constant defined here
|
| -------------------------------------------- constant defined here
|
||||||
...
|
...
|
||||||
LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
|
LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
--> $DIR/cant-hide-behind-direct-struct-param.rs:10:1
|
||||||
|
|
|
||||||
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0)
|
||||||
fn main() {
|
fn main() {
|
||||||
match WRAP_DOUBLY_INDIRECT_INLINE {
|
match WRAP_DOUBLY_INDIRECT_INLINE {
|
||||||
WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
|
WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
_ => { println!("WRAP_DOUBLY_INDIRECT_INLINE correctly did not match itself"); }
|
_ => { println!("WRAP_DOUBLY_INDIRECT_INLINE correctly did not match itself"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:22:9
|
--> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:22:9
|
||||||
|
|
|
|
||||||
|
LL | struct NoDerive(#[allow(dead_code)] i32);
|
||||||
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0));
|
LL | const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0));
|
||||||
| ------------------------------------------------ constant defined here
|
| ------------------------------------------------ constant defined here
|
||||||
...
|
...
|
||||||
LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
|
LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
--> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:11:1
|
||||||
|
|
|
||||||
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(& & NoDe
|
||||||
fn main() {
|
fn main() {
|
||||||
match WRAP_DOUBLY_INDIRECT_PARAM {
|
match WRAP_DOUBLY_INDIRECT_PARAM {
|
||||||
WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
|
WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
_ => { println!("WRAP_DOUBLY_INDIRECT_PARAM correctly did not match itself"); }
|
_ => { println!("WRAP_DOUBLY_INDIRECT_PARAM correctly did not match itself"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/cant-hide-behind-doubly-indirect-param.rs:22:9
|
--> $DIR/cant-hide-behind-doubly-indirect-param.rs:22:9
|
||||||
|
|
|
|
||||||
|
LL | struct NoDerive(#[allow(dead_code)] i32);
|
||||||
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(& & NoDerive(0));
|
LL | const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(& & NoDerive(0));
|
||||||
| -------------------------------------------------------- constant defined here
|
| -------------------------------------------------------- constant defined here
|
||||||
...
|
...
|
||||||
LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
|
LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
--> $DIR/cant-hide-behind-doubly-indirect-param.rs:11:1
|
||||||
|
|
|
||||||
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0));
|
||||||
fn main() {
|
fn main() {
|
||||||
match WRAP_INDIRECT_INLINE {
|
match WRAP_INDIRECT_INLINE {
|
||||||
WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
|
WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
_ => { println!("WRAP_INDIRECT_INLINE did not match itself"); }
|
_ => { println!("WRAP_INDIRECT_INLINE did not match itself"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/cant-hide-behind-indirect-struct-embedded.rs:22:9
|
--> $DIR/cant-hide-behind-indirect-struct-embedded.rs:22:9
|
||||||
|
|
|
|
||||||
|
LL | struct NoDerive(#[allow(dead_code)] i32);
|
||||||
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0));
|
LL | const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0));
|
||||||
| ----------------------------------------- constant defined here
|
| ----------------------------------------- constant defined here
|
||||||
...
|
...
|
||||||
LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
|
LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
--> $DIR/cant-hide-behind-indirect-struct-embedded.rs:11:1
|
||||||
|
|
|
||||||
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ const WRAP_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(NoDerive(0));
|
||||||
fn main() {
|
fn main() {
|
||||||
match WRAP_INDIRECT_PARAM {
|
match WRAP_INDIRECT_PARAM {
|
||||||
WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
|
WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `NoDerive` in a pattern
|
||||||
_ => { println!("WRAP_INDIRECT_PARAM correctly did not match itself"); }
|
_ => { println!("WRAP_INDIRECT_PARAM correctly did not match itself"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `NoDerive` in a pattern
|
||||||
--> $DIR/cant-hide-behind-indirect-struct-param.rs:22:9
|
--> $DIR/cant-hide-behind-indirect-struct-param.rs:22:9
|
||||||
|
|
|
|
||||||
|
LL | struct NoDerive(#[allow(dead_code)] i32);
|
||||||
|
| --------------- `NoDerive` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const WRAP_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(NoDerive(0));
|
LL | const WRAP_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(NoDerive(0));
|
||||||
| ------------------------------------------------- constant defined here
|
| ------------------------------------------------- constant defined here
|
||||||
...
|
...
|
||||||
LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
|
LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
--> $DIR/cant-hide-behind-indirect-struct-param.rs:11:1
|
||||||
|
|
|
||||||
|
LL | impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -13,27 +13,35 @@
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct B(i32);
|
struct B(i32);
|
||||||
|
//~^ NOTE `B` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
//~| NOTE `B` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
|
||||||
// Overriding `PartialEq` to use this strange notion of "equality" exposes
|
// Overriding `PartialEq` to use this strange notion of "equality" exposes
|
||||||
// whether `match` is using structural-equality or method-dispatch
|
// whether `match` is using structural-equality or method-dispatch
|
||||||
// under the hood, which is the antithesis of rust-lang/rfcs#1445
|
// under the hood, which is the antithesis of rust-lang/rfcs#1445
|
||||||
impl PartialEq for B {
|
impl PartialEq for B {
|
||||||
|
//~^ NOTE the `PartialEq` trait must be derived, manual `impl`s are not sufficient
|
||||||
|
//~| NOTE the `PartialEq` trait must be derived, manual `impl`s are not sufficient
|
||||||
fn eq(&self, other: &B) -> bool { std::cmp::min(self.0, other.0) == 0 }
|
fn eq(&self, other: &B) -> bool { std::cmp::min(self.0, other.0) == 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
const RR_B0: & & B = & & B(0);
|
const RR_B0: & & B = & & B(0);
|
||||||
const RR_B1: & & B = & & B(1);
|
const RR_B1: & & B = & & B(1);
|
||||||
|
//~^ NOTE constant defined here
|
||||||
|
//~| NOTE constant defined here
|
||||||
|
|
||||||
match RR_B0 {
|
match RR_B0 {
|
||||||
RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
|
RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `B` in a pattern
|
||||||
|
//~| NOTE constant of non-structural type
|
||||||
_ => { }
|
_ => { }
|
||||||
}
|
}
|
||||||
|
|
||||||
match RR_B1 {
|
match RR_B1 {
|
||||||
RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
|
RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `B` in a pattern
|
||||||
|
//~| NOTE constant of non-structural type
|
||||||
_ => { }
|
_ => { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,38 @@
|
||||||
error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `B` in a pattern
|
||||||
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:29:9
|
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:35:9
|
||||||
|
|
|
|
||||||
|
LL | struct B(i32);
|
||||||
|
| -------- `B` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const RR_B1: & & B = & & B(1);
|
LL | const RR_B1: & & B = & & B(1);
|
||||||
| ------------------ constant defined here
|
| ------------------ constant defined here
|
||||||
...
|
...
|
||||||
LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
|
LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
|
||||||
| ^^^^^
|
| ^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:22:1
|
||||||
|
|
|
||||||
|
LL | impl PartialEq for B {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `B` in a pattern
|
||||||
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:35:9
|
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:42:9
|
||||||
|
|
|
|
||||||
|
LL | struct B(i32);
|
||||||
|
| -------- `B` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const RR_B1: & & B = & & B(1);
|
LL | const RR_B1: & & B = & & B(1);
|
||||||
| ------------------ constant defined here
|
| ------------------ constant defined here
|
||||||
...
|
...
|
||||||
LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
|
LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
|
||||||
| ^^^^^
|
| ^^^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:22:1
|
||||||
|
|
|
||||||
|
LL | impl PartialEq for B {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Note: It is no longer true that both `Eq` and `PartialEq` must the derived, only the later.
|
||||||
|
|
||||||
#[derive(Eq)]
|
#[derive(Eq)]
|
||||||
struct Foo {
|
struct Foo {
|
||||||
x: u32
|
x: u32
|
||||||
|
@ -15,7 +17,7 @@ fn main() {
|
||||||
let y = Foo { x: 1 };
|
let y = Foo { x: 1 };
|
||||||
match y {
|
match y {
|
||||||
FOO => { }
|
FOO => { }
|
||||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR constant of non-structural type `Foo` in a pattern
|
||||||
_ => { }
|
_ => { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,20 @@
|
||||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]`
|
error: constant of non-structural type `Foo` in a pattern
|
||||||
--> $DIR/match-requires-both-partialeq-and-eq.rs:17:9
|
--> $DIR/match-requires-both-partialeq-and-eq.rs:19:9
|
||||||
|
|
|
|
||||||
|
LL | struct Foo {
|
||||||
|
| ---------- `Foo` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
|
||||||
|
...
|
||||||
LL | const FOO: Foo = Foo { x: 0 };
|
LL | const FOO: Foo = Foo { x: 0 };
|
||||||
| -------------- constant defined here
|
| -------------- constant defined here
|
||||||
...
|
...
|
||||||
LL | FOO => { }
|
LL | FOO => { }
|
||||||
| ^^^
|
| ^^^ constant of non-structural type
|
||||||
|
|
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
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
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
--> $DIR/match-requires-both-partialeq-and-eq.rs:8:1
|
||||||
|
|
|
||||||
|
LL | impl PartialEq for Foo {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue