mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-19 03:03:21 +00:00
Auto merge of #116167 - RalfJung:structural-eq, r=lcnr
remove StructuralEq trait The documentation given for the trait is outdated: *all* function pointers implement `PartialEq` and `Eq` these days. So the `StructuralEq` trait doesn't really seem to have any reason to exist any more. One side-effect of this PR is that we allow matching on some consts that do not implement `Eq`. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an `Eq` instance. If we want to require `Eq` we should adjust https://github.com/rust-lang/rust/pull/115893 to check for `Eq`, and rule out float matching for good. Fixes https://github.com/rust-lang/rust/issues/115881
This commit is contained in:
commit
dd2559e08e
@ -19,19 +19,6 @@ pub fn expand_deriving_eq(
|
||||
) {
|
||||
let span = cx.with_def_site_ctxt(span);
|
||||
|
||||
let structural_trait_def = TraitDef {
|
||||
span,
|
||||
path: path_std!(marker::StructuralEq),
|
||||
skip_path_as_bound: true, // crucial!
|
||||
needs_copy_as_bound_if_packed: false,
|
||||
additional_bounds: Vec::new(),
|
||||
supports_unions: true,
|
||||
methods: Vec::new(),
|
||||
associated_types: Vec::new(),
|
||||
is_const: false,
|
||||
};
|
||||
structural_trait_def.expand(cx, mitem, item, push);
|
||||
|
||||
let trait_def = TraitDef {
|
||||
span,
|
||||
path: path_std!(cmp::Eq),
|
||||
|
@ -104,9 +104,6 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
|
||||
#[lang = "structural_peq"]
|
||||
pub trait StructuralPartialEq {}
|
||||
|
||||
#[lang = "structural_teq"]
|
||||
pub trait StructuralEq {}
|
||||
|
||||
#[lang = "not"]
|
||||
pub trait Not {
|
||||
type Output;
|
||||
|
@ -100,9 +100,6 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
|
||||
#[lang = "structural_peq"]
|
||||
pub trait StructuralPartialEq {}
|
||||
|
||||
#[lang = "structural_teq"]
|
||||
pub trait StructuralEq {}
|
||||
|
||||
#[lang = "not"]
|
||||
pub trait Not {
|
||||
type Output;
|
||||
|
@ -61,9 +61,6 @@ mod libc {
|
||||
#[lang = "structural_peq"]
|
||||
pub trait StructuralPartialEq {}
|
||||
|
||||
#[lang = "structural_teq"]
|
||||
pub trait StructuralEq {}
|
||||
|
||||
#[lang = "drop_in_place"]
|
||||
#[allow(unconditional_recursion)]
|
||||
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
|
||||
|
@ -138,7 +138,7 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
|
||||
}
|
||||
// Trait objects are not allowed in type level constants, as we have no concept for
|
||||
// resolving their backing type, even if we can do that at const eval time. We may
|
||||
// hypothetically be able to allow `dyn StructuralEq` trait objects in the future,
|
||||
// hypothetically be able to allow `dyn StructuralPartialEq` trait objects in the future,
|
||||
// but it is unclear if this is useful.
|
||||
ty::Dynamic(..) => Err(ValTreeCreationError::NonSupportedType),
|
||||
|
||||
|
@ -143,8 +143,6 @@ language_item_table! {
|
||||
Unsize, sym::unsize, unsize_trait, Target::Trait, GenericRequirement::Minimum(1);
|
||||
/// Trait injected by `#[derive(PartialEq)]`, (i.e. "Partial EQ").
|
||||
StructuralPeq, sym::structural_peq, structural_peq_trait, Target::Trait, GenericRequirement::None;
|
||||
/// Trait injected by `#[derive(Eq)]`, (i.e. "Total EQ"; no, I will not apologize).
|
||||
StructuralTeq, sym::structural_teq, structural_teq_trait, Target::Trait, GenericRequirement::None;
|
||||
Copy, sym::copy, copy_trait, Target::Trait, GenericRequirement::Exact(0);
|
||||
Clone, sym::clone, clone_trait, Target::Trait, GenericRequirement::None;
|
||||
Sync, sym::sync, sync_trait, Target::Trait, GenericRequirement::Exact(0);
|
||||
|
@ -1360,9 +1360,9 @@ rustc_queries! {
|
||||
///
|
||||
/// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
|
||||
/// correctly.
|
||||
query has_structural_eq_impls(ty: Ty<'tcx>) -> bool {
|
||||
query has_structural_eq_impl(ty: Ty<'tcx>) -> bool {
|
||||
desc {
|
||||
"computing whether `{}` implements `PartialStructuralEq` and `StructuralEq`",
|
||||
"computing whether `{}` implements `StructuralPartialEq`",
|
||||
ty
|
||||
}
|
||||
}
|
||||
|
@ -1249,19 +1249,18 @@ impl<'tcx> Ty<'tcx> {
|
||||
/// Primitive types (`u32`, `str`) have structural equality by definition. For composite data
|
||||
/// types, equality for the type as a whole is structural when it is the same as equality
|
||||
/// between all components (fields, array elements, etc.) of that type. For ADTs, structural
|
||||
/// equality is indicated by an implementation of `PartialStructuralEq` and `StructuralEq` for
|
||||
/// that type.
|
||||
/// equality is indicated by an implementation of `StructuralPartialEq` for that type.
|
||||
///
|
||||
/// This function is "shallow" because it may return `true` for a composite type whose fields
|
||||
/// are not `StructuralEq`. For example, `[T; 4]` has structural equality regardless of `T`
|
||||
/// are not `StructuralPartialEq`. For example, `[T; 4]` has structural equality regardless of `T`
|
||||
/// because equality for arrays is determined by the equality of each array element. If you
|
||||
/// want to know whether a given call to `PartialEq::eq` will proceed structurally all the way
|
||||
/// down, you will need to use a type visitor.
|
||||
#[inline]
|
||||
pub fn is_structural_eq_shallow(self, tcx: TyCtxt<'tcx>) -> bool {
|
||||
match self.kind() {
|
||||
// Look for an impl of both `PartialStructuralEq` and `StructuralEq`.
|
||||
ty::Adt(..) => tcx.has_structural_eq_impls(self),
|
||||
// Look for an impl of `StructuralPartialEq`.
|
||||
ty::Adt(..) => tcx.has_structural_eq_impl(self),
|
||||
|
||||
// Primitive types that satisfy `Eq`.
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Str | ty::Never => true,
|
||||
|
@ -110,7 +110,7 @@ mir_build_extern_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed =
|
||||
mir_build_float_pattern = floating-point types cannot be used in patterns
|
||||
|
||||
mir_build_indirect_structural_match =
|
||||
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]`
|
||||
|
||||
mir_build_inform_irrefutable = `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
|
||||
|
||||
@ -254,7 +254,7 @@ mir_build_non_partial_eq_match =
|
||||
to use a constant of type `{$non_peq_ty}` in a pattern, the type must implement `PartialEq`
|
||||
|
||||
mir_build_nontrivial_structural_match =
|
||||
to use a constant of type `{$non_sm_ty}` in a pattern, the constant's initializer must be trivial or `{$non_sm_ty}` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
to use a constant of type `{$non_sm_ty}` in a pattern, the constant's initializer must be trivial or `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]`
|
||||
|
||||
mir_build_pattern_not_covered = refutable pattern in {$origin}
|
||||
.pattern_ty = the matched value is of type `{$pattern_ty}`
|
||||
@ -297,9 +297,9 @@ mir_build_trailing_irrefutable_let_patterns = trailing irrefutable {$count ->
|
||||
} into the body
|
||||
|
||||
mir_build_type_not_structural =
|
||||
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
to use a constant of type `{$non_sm_ty}` in a pattern, `{$non_sm_ty}` must be annotated with `#[derive(PartialEq)]`
|
||||
|
||||
mir_build_type_not_structural_more_info = see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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 = the traits must be derived, manual `impl`s are not sufficient
|
||||
|
||||
|
@ -310,7 +310,6 @@ symbols! {
|
||||
Some,
|
||||
SpanCtxt,
|
||||
String,
|
||||
StructuralEq,
|
||||
StructuralPartialEq,
|
||||
SubdiagnosticMessage,
|
||||
Sync,
|
||||
@ -1625,7 +1624,6 @@ symbols! {
|
||||
struct_variant,
|
||||
structural_match,
|
||||
structural_peq,
|
||||
structural_teq,
|
||||
sub,
|
||||
sub_assign,
|
||||
sub_with_overflow,
|
||||
|
@ -39,7 +39,7 @@ pub fn search_for_structural_match_violation<'tcx>(
|
||||
|
||||
/// This implements the traversal over the structure of a given type to try to
|
||||
/// find instances of ADTs (specifically structs or enums) that do not implement
|
||||
/// the structural-match traits (`StructuralPartialEq` and `StructuralEq`).
|
||||
/// `StructuralPartialEq`.
|
||||
struct Search<'tcx> {
|
||||
span: Span,
|
||||
|
||||
|
@ -6,13 +6,12 @@ use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt};
|
||||
|
||||
/// This method returns true if and only if `adt_ty` itself has been marked as
|
||||
/// eligible for structural-match: namely, if it implements both
|
||||
/// `StructuralPartialEq` and `StructuralEq` (which are respectively injected by
|
||||
/// `#[derive(PartialEq)]` and `#[derive(Eq)]`).
|
||||
/// eligible for structural-match: namely, if it implements
|
||||
/// `StructuralPartialEq` (which is injected by `#[derive(PartialEq)]`).
|
||||
///
|
||||
/// Note that this does *not* recursively check if the substructure of `adt_ty`
|
||||
/// implements the traits.
|
||||
fn has_structural_eq_impls<'tcx>(tcx: TyCtxt<'tcx>, adt_ty: Ty<'tcx>) -> bool {
|
||||
/// implements the trait.
|
||||
fn has_structural_eq_impl<'tcx>(tcx: TyCtxt<'tcx>, adt_ty: Ty<'tcx>) -> bool {
|
||||
let infcx = &tcx.infer_ctxt().build();
|
||||
let cause = ObligationCause::dummy();
|
||||
|
||||
@ -21,11 +20,6 @@ fn has_structural_eq_impls<'tcx>(tcx: TyCtxt<'tcx>, adt_ty: Ty<'tcx>) -> bool {
|
||||
let structural_peq_def_id =
|
||||
infcx.tcx.require_lang_item(LangItem::StructuralPeq, Some(cause.span));
|
||||
ocx.register_bound(cause.clone(), ty::ParamEnv::empty(), adt_ty, structural_peq_def_id);
|
||||
// for now, require `#[derive(Eq)]`. (Doing so is a hack to work around
|
||||
// the type `for<'a> fn(&'a ())` failing to implement `Eq` itself.)
|
||||
let structural_teq_def_id =
|
||||
infcx.tcx.require_lang_item(LangItem::StructuralTeq, Some(cause.span));
|
||||
ocx.register_bound(cause, ty::ParamEnv::empty(), adt_ty, structural_teq_def_id);
|
||||
|
||||
// We deliberately skip *reporting* fulfillment errors (via
|
||||
// `report_fulfillment_errors`), for two reasons:
|
||||
@ -40,5 +34,5 @@ fn has_structural_eq_impls<'tcx>(tcx: TyCtxt<'tcx>, adt_ty: Ty<'tcx>) -> bool {
|
||||
}
|
||||
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
providers.has_structural_eq_impls = has_structural_eq_impls;
|
||||
providers.has_structural_eq_impl = has_structural_eq_impl;
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ pub trait Unsize<T: ?Sized> {
|
||||
/// Required trait for constants used in pattern matches.
|
||||
///
|
||||
/// Any type that derives `PartialEq` automatically implements this trait,
|
||||
/// *regardless* of whether its type-parameters implement `Eq`.
|
||||
/// *regardless* of whether its type-parameters implement `PartialEq`.
|
||||
///
|
||||
/// If a `const` item contains some type that does not implement this trait,
|
||||
/// then that type either (1.) does not implement `PartialEq` (which means the
|
||||
@ -200,7 +200,7 @@ pub trait Unsize<T: ?Sized> {
|
||||
/// a pattern match.
|
||||
///
|
||||
/// See also the [structural match RFC][RFC1445], and [issue 63438] which
|
||||
/// motivated migrating from attribute-based design to this trait.
|
||||
/// motivated migrating from an attribute-based design to this trait.
|
||||
///
|
||||
/// [RFC1445]: https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md
|
||||
/// [issue 63438]: https://github.com/rust-lang/rust/issues/63438
|
||||
@ -218,7 +218,7 @@ marker_impls! {
|
||||
isize, i8, i16, i32, i64, i128,
|
||||
bool,
|
||||
char,
|
||||
str /* Technically requires `[u8]: StructuralEq` */,
|
||||
str /* Technically requires `[u8]: StructuralPartialEq` */,
|
||||
(),
|
||||
{T, const N: usize} [T; N],
|
||||
{T} [T],
|
||||
@ -275,6 +275,7 @@ marker_impls! {
|
||||
#[unstable(feature = "structural_match", issue = "31434")]
|
||||
#[diagnostic::on_unimplemented(message = "the type `{Self}` does not `#[derive(Eq)]`")]
|
||||
#[lang = "structural_teq"]
|
||||
#[cfg(bootstrap)]
|
||||
pub trait StructuralEq {
|
||||
// Empty.
|
||||
}
|
||||
@ -282,6 +283,7 @@ pub trait StructuralEq {
|
||||
// FIXME: Remove special cases of these types from the compiler pattern checking code and always check `T: StructuralEq` instead
|
||||
marker_impls! {
|
||||
#[unstable(feature = "structural_match", issue = "31434")]
|
||||
#[cfg(bootstrap)]
|
||||
StructuralEq for
|
||||
usize, u8, u16, u32, u64, u128,
|
||||
isize, i8, i16, i32, i64, i128,
|
||||
@ -859,6 +861,7 @@ impl<T: ?Sized> Default for PhantomData<T> {
|
||||
impl<T: ?Sized> StructuralPartialEq for PhantomData<T> {}
|
||||
|
||||
#[unstable(feature = "structural_match", issue = "31434")]
|
||||
#[cfg(bootstrap)]
|
||||
impl<T: ?Sized> StructuralEq for PhantomData<T> {}
|
||||
|
||||
/// Compiler-internal trait used to indicate the type of enum discriminants.
|
||||
@ -1038,6 +1041,20 @@ pub trait PointerLike {}
|
||||
#[unstable(feature = "adt_const_params", issue = "95174")]
|
||||
#[diagnostic::on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
|
||||
#[allow(multiple_supertrait_upcastable)]
|
||||
#[cfg(not(bootstrap))]
|
||||
pub trait ConstParamTy: StructuralPartialEq + Eq {}
|
||||
|
||||
/// A marker for types which can be used as types of `const` generic parameters.
|
||||
///
|
||||
/// These types must have a proper equivalence relation (`Eq`) and it must be automatically
|
||||
/// derived (`StructuralPartialEq`). There's a hard-coded check in the compiler ensuring
|
||||
/// that all fields are also `ConstParamTy`, which implies that recursively, all fields
|
||||
/// are `StructuralPartialEq`.
|
||||
#[lang = "const_param_ty"]
|
||||
#[unstable(feature = "adt_const_params", issue = "95174")]
|
||||
#[rustc_on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
|
||||
#[allow(multiple_supertrait_upcastable)]
|
||||
#[cfg(bootstrap)]
|
||||
pub trait ConstParamTy: StructuralEq + StructuralPartialEq + Eq {}
|
||||
|
||||
/// Derive macro generating an impl of the trait `ConstParamTy`.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use crate::cmp::Ordering::{self, *};
|
||||
use crate::marker::ConstParamTy;
|
||||
use crate::marker::{StructuralEq, StructuralPartialEq};
|
||||
use crate::marker::StructuralPartialEq;
|
||||
|
||||
// Recursive macro for implementing n-ary tuple functions and operations
|
||||
//
|
||||
@ -64,7 +64,8 @@ macro_rules! tuple_impls {
|
||||
maybe_tuple_doc! {
|
||||
$($T)+ @
|
||||
#[unstable(feature = "structural_match", issue = "31434")]
|
||||
impl<$($T),+> StructuralEq for ($($T,)+)
|
||||
#[cfg(bootstrap)]
|
||||
impl<$($T),+> crate::marker::StructuralEq for ($($T,)+)
|
||||
{}
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,6 @@ fn main() {
|
||||
// This used to cause an ICE (https://github.com/rust-lang/rust/issues/78071)
|
||||
match FOO_REF_REF {
|
||||
FOO_REF_REF => {},
|
||||
//~^ ERROR: to use a constant of type `Foo` in a pattern, `Foo` must be annotated
|
||||
//~| NOTE: for more information, see issue #62411 <https://github.com/rust-lang/ru
|
||||
Foo(_) => {},
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/ice-6254.rs:13:9
|
||||
|
|
||||
LL | FOO_REF_REF => {},
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: `-D indirect-structural-match` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(indirect_structural_match)]`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
@ -8,13 +8,11 @@ impl std::marker::ConstParamTy for ImplementsConstParamTy {}
|
||||
struct CantParam(ImplementsConstParamTy);
|
||||
|
||||
impl std::marker::ConstParamTy for CantParam {}
|
||||
//~^ error: the type `CantParam` does not `#[derive(Eq)]`
|
||||
//~| error: the type `CantParam` does not `#[derive(PartialEq)]`
|
||||
//~^ error: the type `CantParam` does not `#[derive(PartialEq)]`
|
||||
//~| the trait bound `CantParam: Eq` is not satisfied
|
||||
|
||||
#[derive(std::marker::ConstParamTy)]
|
||||
//~^ error: the type `CantParamDerive` does not `#[derive(Eq)]`
|
||||
//~| error: the type `CantParamDerive` does not `#[derive(PartialEq)]`
|
||||
//~^ error: the type `CantParamDerive` does not `#[derive(PartialEq)]`
|
||||
//~| the trait bound `CantParamDerive: Eq` is not satisfied
|
||||
struct CantParamDerive(ImplementsConstParamTy);
|
||||
|
||||
|
@ -21,17 +21,8 @@ LL | impl std::marker::ConstParamTy for CantParam {}
|
||||
note: required by a bound in `ConstParamTy`
|
||||
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
||||
|
||||
error[E0277]: the type `CantParam` does not `#[derive(Eq)]`
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36
|
||||
|
|
||||
LL | impl std::marker::ConstParamTy for CantParam {}
|
||||
| ^^^^^^^^^ the trait `StructuralEq` is not implemented for `CantParam`
|
||||
|
|
||||
note: required by a bound in `ConstParamTy`
|
||||
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
||||
|
||||
error[E0277]: the trait bound `CantParamDerive: Eq` is not satisfied
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:15:10
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10
|
||||
|
|
||||
LL | #[derive(std::marker::ConstParamTy)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `CantParamDerive`
|
||||
@ -46,7 +37,7 @@ LL | struct CantParamDerive(ImplementsConstParamTy);
|
||||
|
|
||||
|
||||
error[E0277]: the type `CantParamDerive` does not `#[derive(PartialEq)]`
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:15:10
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10
|
||||
|
|
||||
LL | #[derive(std::marker::ConstParamTy)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralPartialEq` is not implemented for `CantParamDerive`
|
||||
@ -55,16 +46,6 @@ note: required by a bound in `ConstParamTy`
|
||||
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
||||
= note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: the type `CantParamDerive` does not `#[derive(Eq)]`
|
||||
--> $DIR/const_param_ty_impl_no_structural_eq.rs:15:10
|
||||
|
|
||||
LL | #[derive(std::marker::ConstParamTy)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralEq` is not implemented for `CantParamDerive`
|
||||
|
|
||||
note: required by a bound in `ConstParamTy`
|
||||
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
||||
= note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
@ -1,5 +1,5 @@
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(adt_const_params, structural_match)]
|
||||
#![feature(adt_const_params)]
|
||||
|
||||
union Union {
|
||||
a: u8,
|
||||
@ -11,7 +11,6 @@ impl PartialEq for Union {
|
||||
}
|
||||
}
|
||||
impl Eq for Union {}
|
||||
impl std::marker::StructuralEq for Union {}
|
||||
|
||||
impl std::marker::ConstParamTy for Union {}
|
||||
//~^ ERROR the type `Union` does not `#[derive(PartialEq)]`
|
||||
@ -28,7 +27,6 @@ impl PartialEq for UnionDerive {
|
||||
}
|
||||
}
|
||||
impl Eq for UnionDerive {}
|
||||
impl std::marker::StructuralEq for UnionDerive {}
|
||||
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: this trait cannot be derived for unions
|
||||
--> $DIR/const_param_ty_impl_union.rs:19:10
|
||||
--> $DIR/const_param_ty_impl_union.rs:18:10
|
||||
|
|
||||
LL | #[derive(std::marker::ConstParamTy)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the type `Union` does not `#[derive(PartialEq)]`
|
||||
--> $DIR/const_param_ty_impl_union.rs:16:36
|
||||
--> $DIR/const_param_ty_impl_union.rs:15:36
|
||||
|
|
||||
LL | impl std::marker::ConstParamTy for Union {}
|
||||
| ^^^^^ the trait `StructuralPartialEq` is not implemented for `Union`
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: to use a constant of type `TypeId` in a pattern, `TypeId` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `TypeId` in a pattern, `TypeId` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/typeid-equality-by-subtyping.rs:18:9
|
||||
|
|
||||
LL | WHAT_A_TYPE => 0,
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: `Inner` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74950.rs:20:23
|
||||
--> $DIR/issue-74950.rs:19:23
|
||||
|
|
||||
LL | struct Outer<const I: Inner>;
|
||||
| ^^^^^
|
||||
@ -8,7 +8,7 @@ LL | struct Outer<const I: Inner>;
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
|
||||
error: `Inner` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74950.rs:20:23
|
||||
--> $DIR/issue-74950.rs:19:23
|
||||
|
|
||||
LL | struct Outer<const I: Inner>;
|
||||
| ^^^^^
|
||||
@ -18,7 +18,7 @@ LL | struct Outer<const I: Inner>;
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `Inner` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74950.rs:20:23
|
||||
--> $DIR/issue-74950.rs:19:23
|
||||
|
|
||||
LL | struct Outer<const I: Inner>;
|
||||
| ^^^^^
|
||||
@ -28,7 +28,7 @@ LL | struct Outer<const I: Inner>;
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `Inner` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74950.rs:20:23
|
||||
--> $DIR/issue-74950.rs:19:23
|
||||
|
|
||||
LL | struct Outer<const I: Inner>;
|
||||
| ^^^^^
|
||||
@ -37,15 +37,5 @@ LL | struct Outer<const I: Inner>;
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `Inner` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74950.rs:20:23
|
||||
|
|
||||
LL | struct Outer<const I: Inner>;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -15,13 +15,11 @@ struct Inner;
|
||||
// - impl PartialEq
|
||||
// - impl Eq
|
||||
// - impl StructuralPartialEq
|
||||
// - impl StructuralEq
|
||||
#[derive(PartialEq, Eq)]
|
||||
struct Outer<const I: Inner>;
|
||||
//[min]~^ `Inner` is forbidden
|
||||
//[min]~| `Inner` is forbidden
|
||||
//[min]~| `Inner` is forbidden
|
||||
//[min]~| `Inner` is forbidden
|
||||
//[min]~| `Inner` is forbidden
|
||||
|
||||
fn main() {}
|
||||
|
@ -11,14 +11,14 @@ fn main() {
|
||||
let _ = Defaulted;
|
||||
match None {
|
||||
consts::SOME => panic!(),
|
||||
//~^ must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ must be annotated with `#[derive(PartialEq)]`
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match None {
|
||||
<Defaulted as consts::AssocConst>::SOME => panic!(),
|
||||
//~^ must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ must be annotated with `#[derive(PartialEq)]`
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cross-crate-fail.rs:13:9
|
||||
|
|
||||
LL | consts::SOME => panic!(),
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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, Eq)]`
|
||||
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cross-crate-fail.rs:20:9
|
||||
|
|
||||
LL | <Defaulted as consts::AssocConst>::SOME => panic!(),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -27,9 +27,9 @@ const BAR_BAZ: Foo = if 42 == 42 {
|
||||
fn main() {
|
||||
match Foo::Qux(CustomEq) {
|
||||
BAR_BAZ => panic!(),
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
//~| WARN this was previously accepted
|
||||
//~| NOTE see issue #73448
|
||||
//~| NOTE `#[warn(nontrivial_structural_match)]` on by default
|
||||
|
@ -1,4 +1,4 @@
|
||||
warning: to use a constant of type `CustomEq` in a pattern, the constant's initializer must be trivial or `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `CustomEq` in a pattern, the constant's initializer must be trivial or `CustomEq` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/custom-eq-branch-warn.rs:29:9
|
||||
|
|
||||
LL | BAR_BAZ => panic!(),
|
||||
@ -7,7 +7,7 @@ LL | BAR_BAZ => panic!(),
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #73448 <https://github.com/rust-lang/rust/issues/73448>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
= note: `#[warn(nontrivial_structural_match)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -7,9 +7,7 @@ const E_SL: &[E] = &[E::A];
|
||||
|
||||
fn main() {
|
||||
match &[][..] {
|
||||
//~^ ERROR non-exhaustive patterns: `&_` not covered [E0004]
|
||||
//~^ ERROR non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered [E0004]
|
||||
E_SL => {}
|
||||
//~^ WARN to use a constant of type `E` in a pattern, `E` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~| WARN this was previously accepted by the compiler but is being phased out
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,16 @@
|
||||
warning: to use a constant of type `E` in a pattern, `E` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/incomplete-slice.rs:11:9
|
||||
|
|
||||
LL | E_SL => {}
|
||||
| ^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: `#[warn(indirect_structural_match)]` on by default
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `&_` not covered
|
||||
error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
|
||||
--> $DIR/incomplete-slice.rs:9:11
|
||||
|
|
||||
LL | match &[][..] {
|
||||
| ^^^^^^^ pattern `&_` not covered
|
||||
| ^^^^^^^ patterns `&[]` and `&[_, _, ..]` not covered
|
||||
|
|
||||
= note: the matched value is of type `&[E]`
|
||||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
||||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms
|
||||
|
|
||||
LL ~ E_SL => {},
|
||||
LL + &_ => todo!()
|
||||
LL + &[] | &[_, _, ..] => todo!()
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
||||
|
@ -1,16 +0,0 @@
|
||||
#![deny(unreachable_patterns)]
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct Opaque(i32);
|
||||
|
||||
impl Eq for Opaque {}
|
||||
|
||||
const FOO: Opaque = Opaque(42);
|
||||
|
||||
fn main() {
|
||||
match FOO {
|
||||
FOO => {},
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
_ => {}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
error: to use a constant of type `Opaque` in a pattern, `Opaque` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/issue-78057.rs:12:9
|
||||
|
|
||||
LL | FOO => {},
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
@ -19,7 +19,7 @@ const BAR_BAZ: Foo = if 42 == 42 {
|
||||
fn main() {
|
||||
match Foo::Qux(NoEq) {
|
||||
BAR_BAZ => panic!(),
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/no-eq-branch-fail.rs:21:9
|
||||
|
|
||||
LL | BAR_BAZ => panic!(),
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
// run-pass
|
||||
// Eventually this will be rejected (when the future-compat lints are turned into hard errors), and
|
||||
// then this test can be removed. But meanwhile we should ensure that this works and does not ICE.
|
||||
struct NoDerive(#[allow(dead_code)] i32);
|
||||
|
||||
#[derive(PartialEq)]
|
||||
@ -11,8 +9,6 @@ const WRAP_UNSAFE_EMBEDDED: &&WrapEmbedded = &&WrapEmbedded(std::ptr::null());
|
||||
fn main() {
|
||||
let b = match WRAP_UNSAFE_EMBEDDED {
|
||||
WRAP_UNSAFE_EMBEDDED => true,
|
||||
//~^ WARN: must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~| previously accepted
|
||||
_ => false,
|
||||
};
|
||||
assert!(b);
|
||||
|
@ -1,14 +0,0 @@
|
||||
warning: to use a constant of type `WrapEmbedded` in a pattern, `WrapEmbedded` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/null-raw-ptr-issue-119270.rs:13:9
|
||||
|
|
||||
LL | WRAP_UNSAFE_EMBEDDED => true,
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: `#[warn(indirect_structural_match)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -26,7 +26,7 @@ fn main() {
|
||||
|
||||
match None {
|
||||
NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
_ => panic!("whoops"),
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: to use a constant of type `NoPartialEq` in a pattern, `NoPartialEq` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoPartialEq` in a pattern, `NoPartialEq` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_partial_eq.rs:28:9
|
||||
|
|
||||
LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"),
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -40,65 +40,65 @@ fn main() {
|
||||
|
||||
const ENUM: Derive<NoDerive> = Derive::Some(NoDerive);
|
||||
match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const FIELD: OND = TrivialEq(Some(NoDerive)).0;
|
||||
match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const NO_DERIVE_SOME: OND = Some(NoDerive);
|
||||
const INDIRECT: OND = NO_DERIVE_SOME;
|
||||
match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const TUPLE: (OND, OND) = (None, Some(NoDerive));
|
||||
match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND);
|
||||
match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const ARRAY: [OND; 2] = [None, Some(NoDerive)];
|
||||
match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const REPEAT: [OND; 2] = [Some(NoDerive); 2];
|
||||
match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
trait Trait: Sized { const ASSOC: Option<Self>; }
|
||||
impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); }
|
||||
match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const BLOCK: OND = { NoDerive; Some(NoDerive) };
|
||||
match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
|
||||
const ADDR_OF: &OND = &Some(NoDerive);
|
||||
match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| NOTE the traits must be derived
|
||||
//~| NOTE StructuralEq.html for details
|
||||
//~| NOTE StructuralPartialEq.html for details
|
||||
//~| WARN previously accepted by the compiler but is being phased out
|
||||
//~| NOTE for more information, see issue #62411
|
||||
}
|
||||
|
@ -1,85 +1,85 @@
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:42:36
|
||||
|
|
||||
LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
||||
| ^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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 `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:48:28
|
||||
|
|
||||
LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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 `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:55:27
|
||||
|
|
||||
LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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 `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:61:36
|
||||
|
|
||||
LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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 `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:67:28
|
||||
|
|
||||
LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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 `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:73:36
|
||||
|
|
||||
LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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 `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:79:33
|
||||
|
|
||||
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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 `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:86:28
|
||||
|
|
||||
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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 `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:92:28
|
||||
|
|
||||
LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
||||
| ^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
|
||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/reject_non_structural.rs:98:29
|
||||
|
|
||||
LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
||||
@ -88,7 +88,7 @@ LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops")
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reject_non_structural.rs:14:9
|
||||
|
|
||||
|
@ -24,18 +24,18 @@ impl Eq for NoDerive { }
|
||||
fn main() {
|
||||
const INDEX: Option<NoDerive> = [None, Some(NoDerive(10))][0];
|
||||
match None { Some(_) => panic!("whoops"), INDEX => dbg!(INDEX), };
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| WARN this was previously accepted
|
||||
|
||||
const fn build() -> Option<NoDerive> { None }
|
||||
const CALL: Option<NoDerive> = build();
|
||||
match None { Some(_) => panic!("whoops"), CALL => dbg!(CALL), };
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| WARN this was previously accepted
|
||||
|
||||
impl NoDerive { const fn none() -> Option<NoDerive> { None } }
|
||||
const METHOD_CALL: Option<NoDerive> = NoDerive::none();
|
||||
match None { Some(_) => panic!("whoops"), METHOD_CALL => dbg!(METHOD_CALL), };
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| WARN this was previously accepted
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
warning: to use a constant of type `NoDerive` in a pattern, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `NoDerive` in a pattern, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/warn_corner_cases.rs:26:47
|
||||
|
|
||||
LL | match None { Some(_) => panic!("whoops"), INDEX => dbg!(INDEX), };
|
||||
@ -7,10 +7,10 @@ LL | match None { Some(_) => panic!("whoops"), INDEX => dbg!(INDEX), };
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #73448 <https://github.com/rust-lang/rust/issues/73448>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
= note: `#[warn(nontrivial_structural_match)]` on by default
|
||||
|
||||
warning: to use a constant of type `NoDerive` in a pattern, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `NoDerive` in a pattern, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/warn_corner_cases.rs:32:47
|
||||
|
|
||||
LL | match None { Some(_) => panic!("whoops"), CALL => dbg!(CALL), };
|
||||
@ -19,9 +19,9 @@ LL | match None { Some(_) => panic!("whoops"), CALL => dbg!(CALL), };
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #73448 <https://github.com/rust-lang/rust/issues/73448>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
|
||||
warning: to use a constant of type `NoDerive` in a pattern, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `NoDerive` in a pattern, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/warn_corner_cases.rs:38:47
|
||||
|
|
||||
LL | match None { Some(_) => panic!("whoops"), METHOD_CALL => dbg!(METHOD_CALL), };
|
||||
@ -30,7 +30,7 @@ LL | match None { Some(_) => panic!("whoops"), METHOD_CALL => dbg!(METHOD_CA
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #73448 <https://github.com/rust-lang/rust/issues/73448>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
|
||||
warning: 3 warnings emitted
|
||||
|
||||
|
@ -9,7 +9,7 @@ fn main() {
|
||||
const C: &S = &S;
|
||||
match C {
|
||||
C => {}
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
}
|
||||
const K: &T = &T;
|
||||
match K {
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: to use a constant of type `S` in a pattern, `S` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `S` in a pattern, `S` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/match_ice.rs:11:9
|
||||
|
|
||||
LL | C => {}
|
||||
| ^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -56,8 +56,6 @@ impl ::core::cmp::PartialEq for Empty {
|
||||
fn eq(&self, other: &Empty) -> bool { true }
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for Empty { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for Empty {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -132,8 +130,6 @@ impl ::core::cmp::PartialEq for Point {
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for Point { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for Point {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -219,8 +215,6 @@ impl ::core::cmp::PartialEq for PackedPoint {
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for PackedPoint { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for PackedPoint {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -333,8 +327,6 @@ impl ::core::cmp::PartialEq for Big {
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for Big { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for Big {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -500,8 +492,6 @@ impl ::core::cmp::PartialEq for Unsized {
|
||||
fn eq(&self, other: &Unsized) -> bool { self.0 == other.0 }
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for Unsized { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for Unsized {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -616,8 +606,6 @@ impl<T: ::core::cmp::PartialEq + Trait, U: ::core::cmp::PartialEq>
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl<T: Trait, U> ::core::marker::StructuralEq for Generic<T, U> { }
|
||||
#[automatically_derived]
|
||||
impl<T: ::core::cmp::Eq + Trait, U: ::core::cmp::Eq> ::core::cmp::Eq for
|
||||
Generic<T, U> where T::A: ::core::cmp::Eq {
|
||||
#[inline]
|
||||
@ -739,8 +727,6 @@ impl<T: ::core::cmp::PartialEq + ::core::marker::Copy + Trait,
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl<T: Trait, U> ::core::marker::StructuralEq for PackedGeneric<T, U> { }
|
||||
#[automatically_derived]
|
||||
impl<T: ::core::cmp::Eq + ::core::marker::Copy + Trait, U: ::core::cmp::Eq +
|
||||
::core::marker::Copy> ::core::cmp::Eq for PackedGeneric<T, U> where
|
||||
T::A: ::core::cmp::Eq + ::core::marker::Copy {
|
||||
@ -825,8 +811,6 @@ impl ::core::cmp::PartialEq for Enum0 {
|
||||
fn eq(&self, other: &Enum0) -> bool { match *self {} }
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for Enum0 { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for Enum0 {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -897,8 +881,6 @@ impl ::core::cmp::PartialEq for Enum1 {
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for Enum1 { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for Enum1 {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -965,8 +947,6 @@ impl ::core::cmp::PartialEq for Fieldless1 {
|
||||
fn eq(&self, other: &Fieldless1) -> bool { true }
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for Fieldless1 { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for Fieldless1 {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -1041,8 +1021,6 @@ impl ::core::cmp::PartialEq for Fieldless {
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for Fieldless { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for Fieldless {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -1150,8 +1128,6 @@ impl ::core::cmp::PartialEq for Mixed {
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for Mixed { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for Mixed {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -1279,8 +1255,6 @@ impl ::core::cmp::PartialEq for Fielded {
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl ::core::marker::StructuralEq for Fielded { }
|
||||
#[automatically_derived]
|
||||
impl ::core::cmp::Eq for Fielded {
|
||||
#[inline]
|
||||
#[doc(hidden)]
|
||||
@ -1402,8 +1376,6 @@ impl<T: ::core::cmp::PartialEq, U: ::core::cmp::PartialEq>
|
||||
}
|
||||
}
|
||||
#[automatically_derived]
|
||||
impl<T, U> ::core::marker::StructuralEq for EnumGeneric<T, U> { }
|
||||
#[automatically_derived]
|
||||
impl<T: ::core::cmp::Eq, U: ::core::cmp::Eq> ::core::cmp::Eq for
|
||||
EnumGeneric<T, U> {
|
||||
#[inline]
|
||||
|
@ -3,5 +3,5 @@ const CONST_STRING: String = String::new();
|
||||
fn main() {
|
||||
let empty_str = String::from("");
|
||||
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, Eq)]`
|
||||
//~^ ERROR to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq)]`
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `Vec<u8>` in a pattern, `Vec<u8>` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/issue-115599.rs:5:12
|
||||
|
|
||||
LL | if let CONST_STRING = empty_str {}
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -12,7 +12,7 @@ const CONSTANT: &&MyType = &&MyType;
|
||||
|
||||
fn main() {
|
||||
if let CONSTANT = &&MyType {
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
println!("did match!");
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `MyType` in a pattern, `MyType` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/const-partial_eq-fallback-ice.rs:14:12
|
||||
|
|
||||
LL | if let CONSTANT = &&MyType {
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -29,65 +29,63 @@ const BAZ: Baz = Baz::Baz1;
|
||||
fn main() {
|
||||
match FOO {
|
||||
FOO => {}
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match FOO_REF {
|
||||
FOO_REF => {}
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
Foo(_) => {}
|
||||
}
|
||||
|
||||
// This used to cause an ICE (https://github.com/rust-lang/rust/issues/78071)
|
||||
match FOO_REF_REF {
|
||||
FOO_REF_REF => {}
|
||||
//~^ WARNING must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~| WARNING this was previously accepted by the compiler but is being phased out
|
||||
Foo(_) => {}
|
||||
}
|
||||
|
||||
match BAR {
|
||||
Bar => {}
|
||||
BAR => {}
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR unreachable pattern
|
||||
_ => {}
|
||||
//~^ ERROR unreachable pattern
|
||||
}
|
||||
|
||||
match BAR {
|
||||
BAR => {}
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
Bar => {}
|
||||
//~^ ERROR unreachable pattern
|
||||
_ => {}
|
||||
//~^ ERROR unreachable pattern
|
||||
}
|
||||
|
||||
match BAR {
|
||||
BAR => {}
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
BAR => {}
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
_ => {}
|
||||
BAR => {} // should not be emitting unreachable warning
|
||||
//~^ ERROR unreachable pattern
|
||||
_ => {} // should not be emitting unreachable warning
|
||||
//~^ ERROR unreachable pattern
|
||||
}
|
||||
|
||||
match BAZ {
|
||||
BAZ => {}
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
Baz::Baz1 => {}
|
||||
Baz::Baz1 => {} // should not be emitting unreachable warning
|
||||
//~^ ERROR unreachable pattern
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match BAZ {
|
||||
Baz::Baz1 => {}
|
||||
BAZ => {}
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR unreachable pattern
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match BAZ {
|
||||
BAZ => {}
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
Baz::Baz2 => {}
|
||||
_ => {}
|
||||
_ => {} // should not be emitting unreachable warning
|
||||
//~^ ERROR unreachable pattern
|
||||
}
|
||||
|
||||
type Quux = fn(usize, usize) -> usize;
|
||||
|
@ -1,98 +1,5 @@
|
||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/consts-opaque.rs:31:9
|
||||
|
|
||||
LL | FOO => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/consts-opaque.rs:37:9
|
||||
|
|
||||
LL | FOO_REF => {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
warning: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/consts-opaque.rs:44:9
|
||||
|
|
||||
LL | FOO_REF_REF => {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: `#[warn(indirect_structural_match)]` on by default
|
||||
|
||||
error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/consts-opaque.rs:52:9
|
||||
|
|
||||
LL | BAR => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/consts-opaque.rs:58:9
|
||||
|
|
||||
LL | BAR => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/consts-opaque.rs:65:9
|
||||
|
|
||||
LL | BAR => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/consts-opaque.rs:67:9
|
||||
|
|
||||
LL | BAR => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/consts-opaque.rs:73:9
|
||||
|
|
||||
LL | BAZ => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/consts-opaque.rs:81:9
|
||||
|
|
||||
LL | BAZ => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/consts-opaque.rs:87:9
|
||||
|
|
||||
LL | BAZ => {}
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:98:9
|
||||
--> $DIR/consts-opaque.rs:96:9
|
||||
|
|
||||
LL | QUUX => {}
|
||||
| ^^^^
|
||||
@ -102,7 +9,7 @@ LL | QUUX => {}
|
||||
= note: `#[warn(pointer_structural_match)]` on by default
|
||||
|
||||
warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:100:9
|
||||
--> $DIR/consts-opaque.rs:98:9
|
||||
|
|
||||
LL | QUUX => {}
|
||||
| ^^^^
|
||||
@ -110,6 +17,15 @@ LL | QUUX => {}
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
|
||||
|
||||
warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:108:9
|
||||
|
|
||||
LL | WRAPQUUX => {}
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
|
||||
|
||||
warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:110:9
|
||||
|
|
||||
@ -120,7 +36,7 @@ LL | WRAPQUUX => {}
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
|
||||
|
||||
warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:112:9
|
||||
--> $DIR/consts-opaque.rs:117:9
|
||||
|
|
||||
LL | WRAPQUUX => {}
|
||||
| ^^^^^^^^
|
||||
@ -129,7 +45,7 @@ LL | WRAPQUUX => {}
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
|
||||
|
||||
warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:119:9
|
||||
--> $DIR/consts-opaque.rs:127:9
|
||||
|
|
||||
LL | WRAPQUUX => {}
|
||||
| ^^^^^^^^
|
||||
@ -138,16 +54,7 @@ LL | WRAPQUUX => {}
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
|
||||
|
||||
warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:129:9
|
||||
|
|
||||
LL | WRAPQUUX => {}
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
|
||||
|
||||
warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:141:9
|
||||
--> $DIR/consts-opaque.rs:139:9
|
||||
|
|
||||
LL | WHOKNOWSQUUX => {}
|
||||
| ^^^^^^^^^^^^
|
||||
@ -156,7 +63,7 @@ LL | WHOKNOWSQUUX => {}
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
|
||||
|
||||
warning: function pointers and raw pointers not derived from integers in patterns behave unpredictably and should not be relied upon. See https://github.com/rust-lang/rust/issues/70861 for details.
|
||||
--> $DIR/consts-opaque.rs:144:9
|
||||
--> $DIR/consts-opaque.rs:142:9
|
||||
|
|
||||
LL | WHOKNOWSQUUX => {}
|
||||
| ^^^^^^^^^^^^
|
||||
@ -164,14 +71,89 @@ LL | WHOKNOWSQUUX => {}
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/70861>
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/consts-opaque.rs:48:9
|
||||
|
|
||||
LL | Bar => {}
|
||||
| --- matches any value
|
||||
LL | BAR => {}
|
||||
| ^^^ unreachable pattern
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/consts-opaque.rs:6:9
|
||||
|
|
||||
LL | #![deny(unreachable_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/consts-opaque.rs:50:9
|
||||
|
|
||||
LL | Bar => {}
|
||||
| --- matches any value
|
||||
...
|
||||
LL | _ => {}
|
||||
| ^ unreachable pattern
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/consts-opaque.rs:56:9
|
||||
|
|
||||
LL | BAR => {}
|
||||
| --- matches any value
|
||||
LL | Bar => {}
|
||||
| ^^^ unreachable pattern
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/consts-opaque.rs:58:9
|
||||
|
|
||||
LL | BAR => {}
|
||||
| --- matches any value
|
||||
...
|
||||
LL | _ => {}
|
||||
| ^ unreachable pattern
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/consts-opaque.rs:64:9
|
||||
|
|
||||
LL | BAR => {}
|
||||
| --- matches any value
|
||||
LL | BAR => {} // should not be emitting unreachable warning
|
||||
| ^^^ unreachable pattern
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/consts-opaque.rs:66:9
|
||||
|
|
||||
LL | BAR => {}
|
||||
| --- matches any value
|
||||
...
|
||||
LL | _ => {} // should not be emitting unreachable warning
|
||||
| ^ unreachable pattern
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/consts-opaque.rs:72:9
|
||||
|
|
||||
LL | Baz::Baz1 => {} // should not be emitting unreachable warning
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/consts-opaque.rs:79:9
|
||||
|
|
||||
LL | BAZ => {}
|
||||
| ^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/consts-opaque.rs:87:9
|
||||
|
|
||||
LL | _ => {} // should not be emitting unreachable warning
|
||||
| ^
|
||||
|
||||
error[E0004]: non-exhaustive patterns: `Wrap(_)` not covered
|
||||
--> $DIR/consts-opaque.rs:127:11
|
||||
--> $DIR/consts-opaque.rs:125:11
|
||||
|
|
||||
LL | match WRAPQUUX {
|
||||
| ^^^^^^^^ pattern `Wrap(_)` not covered
|
||||
|
|
||||
note: `Wrap<fn(usize, usize) -> usize>` defined here
|
||||
--> $DIR/consts-opaque.rs:106:12
|
||||
--> $DIR/consts-opaque.rs:104:12
|
||||
|
|
||||
LL | struct Wrap<T>(T);
|
||||
| ^^^^
|
||||
@ -181,6 +163,6 @@ help: ensure that all possible cases are being handled by adding a match arm wit
|
||||
LL | WRAPQUUX => {}, Wrap(_) => todo!()
|
||||
| ++++++++++++++++++++
|
||||
|
||||
error: aborting due to 10 previous errors; 9 warnings emitted
|
||||
error: aborting due to 10 previous errors; 8 warnings emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
||||
|
@ -20,7 +20,7 @@ const WRAP_DIRECT_INLINE: WrapInline = WrapInline(NoDerive(0));
|
||||
fn main() {
|
||||
match WRAP_DIRECT_INLINE {
|
||||
WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
_ => { println!("WRAP_DIRECT_INLINE did not match itself"); }
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-direct-struct-embedded.rs:22:9
|
||||
|
|
||||
LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); }
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -20,7 +20,7 @@ const WRAP_DIRECT_PARAM: WrapParam<NoDerive> = WrapParam(NoDerive(0));
|
||||
fn main() {
|
||||
match WRAP_DIRECT_PARAM {
|
||||
WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
_ => { println!("WRAP_DIRECT_PARAM did not match itself"); }
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-direct-struct-param.rs:22:9
|
||||
|
|
||||
LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -22,7 +22,7 @@ const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0)
|
||||
fn main() {
|
||||
match WRAP_DOUBLY_INDIRECT_INLINE {
|
||||
WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| WARN this was previously accepted
|
||||
_ => { println!("WRAP_DOUBLY_INDIRECT_INLINE correctly did not match itself"); }
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:24:9
|
||||
|
|
||||
LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
|
||||
@ -7,7 +7,7 @@ LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLIN
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
note: the lint level is defined here
|
||||
--> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:7:9
|
||||
|
|
||||
|
@ -22,7 +22,7 @@ const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(& & NoDe
|
||||
fn main() {
|
||||
match WRAP_DOUBLY_INDIRECT_PARAM {
|
||||
WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| WARN this was previously accepted
|
||||
_ => { println!("WRAP_DOUBLY_INDIRECT_PARAM correctly did not match itself"); }
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-doubly-indirect-param.rs:24:9
|
||||
|
|
||||
LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
|
||||
@ -7,7 +7,7 @@ LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
note: the lint level is defined here
|
||||
--> $DIR/cant-hide-behind-doubly-indirect-param.rs:7:9
|
||||
|
|
||||
|
@ -22,7 +22,7 @@ const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0));
|
||||
fn main() {
|
||||
match WRAP_INDIRECT_INLINE {
|
||||
WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| WARN this was previously accepted
|
||||
_ => { println!("WRAP_INDIRECT_INLINE did not match itself"); }
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-indirect-struct-embedded.rs:24:9
|
||||
|
|
||||
LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
|
||||
@ -7,7 +7,7 @@ LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itse
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
note: the lint level is defined here
|
||||
--> $DIR/cant-hide-behind-indirect-struct-embedded.rs:7:9
|
||||
|
|
||||
|
@ -22,7 +22,7 @@ const WRAP_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(NoDerive(0));
|
||||
fn main() {
|
||||
match WRAP_INDIRECT_PARAM {
|
||||
WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| WARN this was previously accepted
|
||||
_ => { println!("WRAP_INDIRECT_PARAM correctly did not match itself"); }
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/cant-hide-behind-indirect-struct-param.rs:24:9
|
||||
|
|
||||
LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
|
||||
@ -7,7 +7,7 @@ LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
note: the lint level is defined here
|
||||
--> $DIR/cant-hide-behind-indirect-struct-param.rs:7:9
|
||||
|
|
||||
|
@ -8,16 +8,6 @@ LL | impl std::marker::StructuralPartialEq for Foo { }
|
||||
= help: add `#![feature(structural_match)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: use of unstable library feature 'structural_match'
|
||||
--> $DIR/feature-gate.rs:31:6
|
||||
|
|
||||
LL | impl std::marker::StructuralEq for Foo { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #31434 <https://github.com/rust-lang/rust/issues/31434> for more information
|
||||
= help: add `#![feature(structural_match)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -28,8 +28,6 @@ fn main() { //[with_gate]~ ERROR fatal error triggered by #[rustc_error]
|
||||
|
||||
impl std::marker::StructuralPartialEq for Foo { }
|
||||
//[no_gate]~^ ERROR use of unstable library feature 'structural_match'
|
||||
impl std::marker::StructuralEq for Foo { }
|
||||
//[no_gate]~^ ERROR use of unstable library feature 'structural_match'
|
||||
|
||||
impl PartialEq<Foo> for Foo {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
|
@ -13,7 +13,7 @@ const A: &[B] = &[];
|
||||
pub fn main() {
|
||||
match &[][..] {
|
||||
A => (),
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/issue-61188-match-slice-forbidden-without-eq.rs:15:9
|
||||
|
|
||||
LL | A => (),
|
||||
| ^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -29,14 +29,14 @@ fn main() {
|
||||
|
||||
match RR_B0 {
|
||||
RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| WARN this was previously accepted
|
||||
_ => { }
|
||||
}
|
||||
|
||||
match RR_B1 {
|
||||
RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
||||
//~| WARN this was previously accepted
|
||||
_ => { }
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
warning: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:31:9
|
||||
|
|
||||
LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
|
||||
@ -7,14 +7,14 @@ LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0);
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:13:9
|
||||
|
|
||||
LL | #![warn(indirect_structural_match, nontrivial_structural_match)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
warning: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:38:9
|
||||
|
|
||||
LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
|
||||
@ -23,7 +23,7 @@ LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1);
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411>
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
#[derive(PartialEq)]
|
||||
struct Foo {
|
||||
x: u32
|
||||
}
|
||||
|
||||
const FOO: Foo = Foo { x: 0 };
|
||||
|
||||
fn main() {
|
||||
let y = Foo { x: 1 };
|
||||
match y {
|
||||
FOO => { }
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
_ => { }
|
||||
}
|
||||
|
||||
let x = 0.0;
|
||||
match x {
|
||||
f32::INFINITY => { }
|
||||
//~^ WARNING floating-point types cannot be used in patterns
|
||||
//~| WARNING this was previously accepted by the compiler but is being phased out
|
||||
_ => { }
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/match-forbidden-without-eq.rs:11:9
|
||||
|
|
||||
LL | FOO => { }
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
warning: floating-point types cannot be used in patterns
|
||||
--> $DIR/match-forbidden-without-eq.rs:18:9
|
||||
|
|
||||
LL | f32::INFINITY => { }
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #41620 <https://github.com/rust-lang/rust/issues/41620>
|
||||
= note: `#[warn(illegal_floating_point_literal_pattern)]` on by default
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
@ -1,19 +0,0 @@
|
||||
// Issue 62307 pointed out a case where the structural-match checking
|
||||
// was too shallow.
|
||||
//
|
||||
// Here we check similar behavior for non-empty arrays of types that
|
||||
// do not derive `Eq`.
|
||||
//
|
||||
// (Current behavior for empty arrays differs and thus is not tested
|
||||
// here; see rust-lang/rust#62336.)
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
struct B(i32);
|
||||
|
||||
fn main() {
|
||||
const FOO: [B; 1] = [B(0)];
|
||||
match [B(1)] {
|
||||
FOO => { }
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
error: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
--> $DIR/match-nonempty-array-forbidden-without-eq.rs:16:9
|
||||
|
|
||||
LL | FOO => { }
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
@ -15,7 +15,7 @@ fn main() {
|
||||
let y = Foo { x: 1 };
|
||||
match y {
|
||||
FOO => { }
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||
_ => { }
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]`
|
||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]`
|
||||
--> $DIR/match-requires-both-partialeq-and-eq.rs:17:9
|
||||
|
|
||||
LL | FOO => { }
|
||||
| ^^^
|
||||
|
|
||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.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
|
||||
|
||||
|
@ -507,9 +507,6 @@ trait Clone: Sized {
|
||||
#[lang = "structural_peq"]
|
||||
trait StructuralPartialEq {}
|
||||
|
||||
#[lang = "structural_teq"]
|
||||
trait StructuralEq {}
|
||||
|
||||
const fn drop<T: ~const Destruct>(_: T) {}
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
|
@ -124,7 +124,7 @@ error: demangling-alt(<c::Foo_<{c::Foo { s: "abc", ch: 'x', slice: &[1, 2, 3] }}
|
||||
LL | #[rustc_symbol_name]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: symbol-name(_RMsf_CsCRATE_HASH_1cINtB<REF>_4Bar_KVNtB<REF>_3BarS1xh7b_s_1xt1000_EE)
|
||||
error: symbol-name(_RMsd_CsCRATE_HASH_1cINtB<REF>_4Bar_KVNtB<REF>_3BarS1xh7b_s_1xt1000_EE)
|
||||
--> $DIR/const-generics-structural-demangling.rs:93:5
|
||||
|
|
||||
LL | #[rustc_symbol_name]
|
||||
|
Loading…
Reference in New Issue
Block a user