mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
remove IndirectStructuralMatch lint, emit the usual hard error instead
This commit is contained in:
parent
79734f1db8
commit
179a6a08b1
@ -539,6 +539,11 @@ fn register_builtins(store: &mut LintStore) {
|
|||||||
"converted into hard error, see RFC #3535 \
|
"converted into hard error, see RFC #3535 \
|
||||||
<https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
|
<https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
|
||||||
);
|
);
|
||||||
|
store.register_removed(
|
||||||
|
"indirect_structural_match",
|
||||||
|
"converted into hard error, see RFC #3535 \
|
||||||
|
<https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_internals(store: &mut LintStore) {
|
fn register_internals(store: &mut LintStore) {
|
||||||
|
@ -50,7 +50,6 @@ declare_lint_pass! {
|
|||||||
HIDDEN_GLOB_REEXPORTS,
|
HIDDEN_GLOB_REEXPORTS,
|
||||||
ILL_FORMED_ATTRIBUTE_INPUT,
|
ILL_FORMED_ATTRIBUTE_INPUT,
|
||||||
INCOMPLETE_INCLUDE,
|
INCOMPLETE_INCLUDE,
|
||||||
INDIRECT_STRUCTURAL_MATCH,
|
|
||||||
INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
|
INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
|
||||||
INLINE_NO_SANITIZE,
|
INLINE_NO_SANITIZE,
|
||||||
INVALID_DOC_ATTRIBUTES,
|
INVALID_DOC_ATTRIBUTES,
|
||||||
@ -2355,52 +2354,6 @@ declare_lint! {
|
|||||||
"outlives requirements can be inferred"
|
"outlives requirements can be inferred"
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint! {
|
|
||||||
/// The `indirect_structural_match` lint detects a `const` in a pattern
|
|
||||||
/// that manually implements [`PartialEq`] and [`Eq`].
|
|
||||||
///
|
|
||||||
/// [`PartialEq`]: https://doc.rust-lang.org/std/cmp/trait.PartialEq.html
|
|
||||||
/// [`Eq`]: https://doc.rust-lang.org/std/cmp/trait.Eq.html
|
|
||||||
///
|
|
||||||
/// ### Example
|
|
||||||
///
|
|
||||||
/// ```rust,compile_fail
|
|
||||||
/// #![deny(indirect_structural_match)]
|
|
||||||
///
|
|
||||||
/// struct NoDerive(i32);
|
|
||||||
/// impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
|
|
||||||
/// impl Eq for NoDerive { }
|
|
||||||
/// #[derive(PartialEq, Eq)]
|
|
||||||
/// struct WrapParam<T>(T);
|
|
||||||
/// const WRAP_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(NoDerive(0));
|
|
||||||
/// fn main() {
|
|
||||||
/// match WRAP_INDIRECT_PARAM {
|
|
||||||
/// WRAP_INDIRECT_PARAM => { }
|
|
||||||
/// _ => { }
|
|
||||||
/// }
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
/// {{produces}}
|
|
||||||
///
|
|
||||||
/// ### Explanation
|
|
||||||
///
|
|
||||||
/// The compiler unintentionally accepted this form in the past. This is a
|
|
||||||
/// [future-incompatible] lint to transition this to a hard error in the
|
|
||||||
/// future. See [issue #62411] for a complete description of the problem,
|
|
||||||
/// and some possible solutions.
|
|
||||||
///
|
|
||||||
/// [issue #62411]: https://github.com/rust-lang/rust/issues/62411
|
|
||||||
/// [future-incompatible]: ../index.md#future-incompatible-lints
|
|
||||||
pub INDIRECT_STRUCTURAL_MATCH,
|
|
||||||
Warn,
|
|
||||||
"constant used in pattern contains value of non-structural-match type in a field or a variant",
|
|
||||||
@future_incompatible = FutureIncompatibleInfo {
|
|
||||||
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
|
|
||||||
reference: "issue #120362 <https://github.com/rust-lang/rust/issues/120362>",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
/// The `deprecated_in_future` lint is internal to rustc and should not be
|
/// The `deprecated_in_future` lint is internal to rustc and should not be
|
||||||
/// used by user code.
|
/// used by user code.
|
||||||
|
@ -109,9 +109,6 @@ mir_build_extern_static_requires_unsafe_unsafe_op_in_unsafe_fn_allowed =
|
|||||||
.note = extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
|
.note = extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
|
||||||
.label = use of extern static
|
.label = use of extern static
|
||||||
|
|
||||||
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)]`
|
|
||||||
|
|
||||||
mir_build_inform_irrefutable = `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
|
mir_build_inform_irrefutable = `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
|
||||||
|
|
||||||
mir_build_initializing_type_with_requires_unsafe =
|
mir_build_initializing_type_with_requires_unsafe =
|
||||||
@ -257,9 +254,6 @@ mir_build_non_exhaustive_patterns_type_not_empty = non-exhaustive patterns: type
|
|||||||
mir_build_non_partial_eq_match =
|
mir_build_non_partial_eq_match =
|
||||||
to use a constant of type `{$non_peq_ty}` in a pattern, the type must implement `PartialEq`
|
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)]`
|
|
||||||
|
|
||||||
mir_build_pattern_not_covered = refutable pattern in {$origin}
|
mir_build_pattern_not_covered = refutable pattern in {$origin}
|
||||||
.pattern_ty = the matched value is of type `{$pattern_ty}`
|
.pattern_ty = the matched value is of type `{$pattern_ty}`
|
||||||
|
|
||||||
|
@ -802,22 +802,6 @@ pub struct NonEmptyNeverPattern<'tcx> {
|
|||||||
pub ty: Ty<'tcx>,
|
pub ty: Ty<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
|
||||||
#[diag(mir_build_indirect_structural_match)]
|
|
||||||
#[note(mir_build_type_not_structural_tip)]
|
|
||||||
#[note(mir_build_type_not_structural_more_info)]
|
|
||||||
pub struct IndirectStructuralMatch<'tcx> {
|
|
||||||
pub non_sm_ty: Ty<'tcx>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
|
||||||
#[diag(mir_build_nontrivial_structural_match)]
|
|
||||||
#[note(mir_build_type_not_structural_tip)]
|
|
||||||
#[note(mir_build_type_not_structural_more_info)]
|
|
||||||
pub struct NontrivialStructuralMatch<'tcx> {
|
|
||||||
pub non_sm_ty: Ty<'tcx>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(mir_build_exceeds_mcdc_condition_num_limit)]
|
#[diag(mir_build_exceeds_mcdc_condition_num_limit)]
|
||||||
pub(crate) struct MCDCExceedsConditionNumLimit {
|
pub(crate) struct MCDCExceedsConditionNumLimit {
|
||||||
|
@ -16,8 +16,8 @@ use std::cell::Cell;
|
|||||||
|
|
||||||
use super::PatCtxt;
|
use super::PatCtxt;
|
||||||
use crate::errors::{
|
use crate::errors::{
|
||||||
IndirectStructuralMatch, InvalidPattern, NaNPattern, PointerPattern, TypeNotPartialEq,
|
InvalidPattern, NaNPattern, PointerPattern, TypeNotPartialEq, TypeNotStructural, UnionPattern,
|
||||||
TypeNotStructural, UnionPattern, UnsizedPattern,
|
UnsizedPattern,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
||||||
@ -49,15 +49,6 @@ struct ConstToPat<'tcx> {
|
|||||||
// value.
|
// value.
|
||||||
saw_const_match_error: Cell<Option<ErrorGuaranteed>>,
|
saw_const_match_error: Cell<Option<ErrorGuaranteed>>,
|
||||||
|
|
||||||
// This tracks if we emitted some diagnostic for a given const value, so that
|
|
||||||
// we will not subsequently issue an irrelevant lint for the same const
|
|
||||||
// value.
|
|
||||||
saw_const_match_lint: Cell<bool>,
|
|
||||||
|
|
||||||
// For backcompat we need to keep allowing non-structurally-eq types behind references.
|
|
||||||
// See also all the `cant-hide-behind` tests.
|
|
||||||
behind_reference: Cell<bool>,
|
|
||||||
|
|
||||||
// inference context used for checking `T: Structural` bounds.
|
// inference context used for checking `T: Structural` bounds.
|
||||||
infcx: InferCtxt<'tcx>,
|
infcx: InferCtxt<'tcx>,
|
||||||
|
|
||||||
@ -84,8 +75,6 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||||||
infcx,
|
infcx,
|
||||||
param_env: pat_ctxt.param_env,
|
param_env: pat_ctxt.param_env,
|
||||||
saw_const_match_error: Cell::new(None),
|
saw_const_match_error: Cell::new(None),
|
||||||
saw_const_match_lint: Cell::new(false),
|
|
||||||
behind_reference: Cell::new(false),
|
|
||||||
treat_byte_string_as_slice: pat_ctxt
|
treat_byte_string_as_slice: pat_ctxt
|
||||||
.typeck_results
|
.typeck_results
|
||||||
.treat_byte_string_as_slice
|
.treat_byte_string_as_slice
|
||||||
@ -197,7 +186,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||||||
// complained about structural match violations there, so we don't
|
// complained about structural match violations there, so we don't
|
||||||
// have to check anything any more.
|
// have to check anything any more.
|
||||||
}
|
}
|
||||||
} else if !have_valtree && !self.saw_const_match_lint.get() {
|
} else if !have_valtree {
|
||||||
// The only way valtree construction can fail without the structural match
|
// The only way valtree construction can fail without the structural match
|
||||||
// checker finding a violation is if there is a pointer somewhere.
|
// checker finding a violation is if there is a pointer somewhere.
|
||||||
self.tcx().emit_node_span_lint(
|
self.tcx().emit_node_span_lint(
|
||||||
@ -274,36 +263,11 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||||||
cv: ValTree<'tcx>,
|
cv: ValTree<'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
) -> Result<Box<Pat<'tcx>>, FallbackToOpaqueConst> {
|
) -> Result<Box<Pat<'tcx>>, FallbackToOpaqueConst> {
|
||||||
let id = self.id;
|
|
||||||
let span = self.span;
|
let span = self.span;
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let param_env = self.param_env;
|
let param_env = self.param_env;
|
||||||
|
|
||||||
let kind = match ty.kind() {
|
let kind = match ty.kind() {
|
||||||
// If the type is not structurally comparable, just emit the constant directly,
|
|
||||||
// causing the pattern match code to treat it opaquely.
|
|
||||||
// FIXME: This code doesn't emit errors itself, the caller emits the errors.
|
|
||||||
// So instead of specific errors, you just get blanket errors about the whole
|
|
||||||
// const type. See
|
|
||||||
// https://github.com/rust-lang/rust/pull/70743#discussion_r404701963 for
|
|
||||||
// details.
|
|
||||||
// Backwards compatibility hack because we can't cause hard errors on these
|
|
||||||
// types, so we compare them via `PartialEq::eq` at runtime.
|
|
||||||
ty::Adt(..) if !self.type_marked_structural(ty) && self.behind_reference.get() => {
|
|
||||||
if self.saw_const_match_error.get().is_none() && !self.saw_const_match_lint.get() {
|
|
||||||
self.saw_const_match_lint.set(true);
|
|
||||||
tcx.emit_node_span_lint(
|
|
||||||
lint::builtin::INDIRECT_STRUCTURAL_MATCH,
|
|
||||||
id,
|
|
||||||
span,
|
|
||||||
IndirectStructuralMatch { non_sm_ty: ty },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Since we are behind a reference, we can just bubble the error up so we get a
|
|
||||||
// constant at reference type, making it easy to let the fallback call
|
|
||||||
// `PartialEq::eq` on it.
|
|
||||||
return Err(FallbackToOpaqueConst);
|
|
||||||
}
|
|
||||||
ty::FnDef(..) => {
|
ty::FnDef(..) => {
|
||||||
let e = tcx.dcx().emit_err(InvalidPattern { span, non_sm_ty: ty });
|
let e = tcx.dcx().emit_err(InvalidPattern { span, non_sm_ty: ty });
|
||||||
self.saw_const_match_error.set(Some(e));
|
self.saw_const_match_error.set(Some(e));
|
||||||
@ -377,38 +341,6 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||||||
ty::Str => {
|
ty::Str => {
|
||||||
PatKind::Constant { value: mir::Const::Ty(ty::Const::new_value(tcx, cv, ty)) }
|
PatKind::Constant { value: mir::Const::Ty(ty::Const::new_value(tcx, cv, ty)) }
|
||||||
}
|
}
|
||||||
// Backwards compatibility hack: support references to non-structural types,
|
|
||||||
// but hard error if we aren't behind a double reference. We could just use
|
|
||||||
// the fallback code path below, but that would allow *more* of this fishy
|
|
||||||
// code to compile, as then it only goes through the future incompat lint
|
|
||||||
// instead of a hard error.
|
|
||||||
ty::Adt(_, _) if !self.type_marked_structural(*pointee_ty) => {
|
|
||||||
if self.behind_reference.get() {
|
|
||||||
if self.saw_const_match_error.get().is_none()
|
|
||||||
&& !self.saw_const_match_lint.get()
|
|
||||||
{
|
|
||||||
self.saw_const_match_lint.set(true);
|
|
||||||
tcx.emit_node_span_lint(
|
|
||||||
lint::builtin::INDIRECT_STRUCTURAL_MATCH,
|
|
||||||
self.id,
|
|
||||||
span,
|
|
||||||
IndirectStructuralMatch { non_sm_ty: *pointee_ty },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Err(FallbackToOpaqueConst);
|
|
||||||
} else {
|
|
||||||
if let Some(e) = self.saw_const_match_error.get() {
|
|
||||||
// We already errored. Signal that in the pattern, so that follow up errors can be silenced.
|
|
||||||
PatKind::Error(e)
|
|
||||||
} else {
|
|
||||||
let err = TypeNotStructural { span, non_sm_ty: *pointee_ty };
|
|
||||||
let e = tcx.dcx().emit_err(err);
|
|
||||||
self.saw_const_match_error.set(Some(e));
|
|
||||||
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
|
|
||||||
PatKind::Error(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// All other references are converted into deref patterns and then recursively
|
// All other references are converted into deref patterns and then recursively
|
||||||
// convert the dereferenced constant to a pattern that is the sub-pattern of the
|
// convert the dereferenced constant to a pattern that is the sub-pattern of the
|
||||||
// deref pattern.
|
// deref pattern.
|
||||||
@ -419,7 +351,6 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||||||
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
|
// We errored. Signal that in the pattern, so that follow up errors can be silenced.
|
||||||
PatKind::Error(e)
|
PatKind::Error(e)
|
||||||
} else {
|
} else {
|
||||||
let old = self.behind_reference.replace(true);
|
|
||||||
// `b"foo"` produces a `&[u8; 3]`, but you can't use constants of array type when
|
// `b"foo"` produces a `&[u8; 3]`, but you can't use constants of array type when
|
||||||
// matching against references, you can only use byte string literals.
|
// matching against references, you can only use byte string literals.
|
||||||
// The typechecker has a special case for byte string literals, by treating them
|
// The typechecker has a special case for byte string literals, by treating them
|
||||||
@ -434,7 +365,6 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||||||
};
|
};
|
||||||
// References have the same valtree representation as their pointee.
|
// References have the same valtree representation as their pointee.
|
||||||
let subpattern = self.recur(cv, pointee_ty)?;
|
let subpattern = self.recur(cv, pointee_ty)?;
|
||||||
self.behind_reference.set(old);
|
|
||||||
PatKind::Deref { subpattern }
|
PatKind::Deref { subpattern }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
|
|
||||||
#![allow(non_local_definitions)]
|
#![allow(non_local_definitions)]
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
|
|
||||||
// This test is checking our logic for structural match checking by enumerating
|
// This test is checking our logic for structural match checking by enumerating
|
||||||
// the different kinds of const expressions. This test is collecting cases where
|
// the different kinds of const expressions. This test is collecting cases where
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
//@ aux-build:consts.rs
|
//@ aux-build:consts.rs
|
||||||
|
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
|
|
||||||
extern crate consts;
|
extern crate consts;
|
||||||
|
|
||||||
struct Defaulted;
|
struct Defaulted;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/cross-crate-fail.rs:11:9
|
||||||
|
|
|
|
||||||
LL | consts::SOME => panic!(),
|
LL | consts::SOME => panic!(),
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
@ -8,7 +8,7 @@ LL | consts::SOME => panic!(),
|
|||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq)]`
|
error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq)]`
|
||||||
--> $DIR/cross-crate-fail.rs:20:9
|
--> $DIR/cross-crate-fail.rs:18:9
|
||||||
|
|
|
|
||||||
LL | <Defaulted as consts::AssocConst>::SOME => panic!(),
|
LL | <Defaulted as consts::AssocConst>::SOME => panic!(),
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
//@ aux-build:consts.rs
|
//@ aux-build:consts.rs
|
||||||
|
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
|
|
||||||
extern crate consts;
|
extern crate consts;
|
||||||
use consts::CustomEq;
|
use consts::CustomEq;
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
//@ run-pass
|
//@ run-pass
|
||||||
|
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
|
|
||||||
struct CustomEq;
|
struct CustomEq;
|
||||||
|
|
||||||
impl Eq for CustomEq {}
|
impl Eq for CustomEq {}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#![warn(indirect_structural_match)]
|
|
||||||
|
|
||||||
struct NoEq;
|
struct NoEq;
|
||||||
|
|
||||||
enum Foo {
|
enum Foo {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/no-eq-branch-fail.rs:19:9
|
||||||
|
|
|
|
||||||
LL | BAR_BAZ => panic!(),
|
LL | BAR_BAZ => panic!(),
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
// See also RFC 1445
|
// See also RFC 1445
|
||||||
|
|
||||||
#![feature(type_ascription)]
|
#![feature(type_ascription)]
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
//~^ NOTE lint level is defined here
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
struct NoPartialEq;
|
struct NoPartialEq;
|
||||||
@ -96,9 +94,7 @@ fn main() {
|
|||||||
|
|
||||||
const ADDR_OF: &OND = &Some(NoDerive);
|
const ADDR_OF: &OND = &Some(NoDerive);
|
||||||
match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
||||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||||
//~| NOTE the traits must be derived
|
//~| NOTE the traits must be derived
|
||||||
//~| NOTE StructuralPartialEq.html for details
|
//~| NOTE StructuralPartialEq.html for details
|
||||||
//~| WARN previously accepted by the compiler but is being phased out
|
|
||||||
//~| NOTE for more information, see
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/reject_non_structural.rs:40:36
|
||||||
|
|
|
|
||||||
LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), };
|
||||||
| ^^^^
|
| ^^^^
|
||||||
@ -8,7 +8,7 @@ LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"
|
|||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/reject_non_structural.rs:46:28
|
||||||
|
|
|
|
||||||
LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
@ -17,7 +17,7 @@ LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), };
|
|||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/reject_non_structural.rs:53:27
|
||||||
|
|
|
|
||||||
LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), };
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
@ -26,7 +26,7 @@ LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops")
|
|||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/reject_non_structural.rs:59:36
|
||||||
|
|
|
|
||||||
LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), };
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
@ -35,7 +35,7 @@ LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoop
|
|||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/reject_non_structural.rs:65:28
|
||||||
|
|
|
|
||||||
LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), };
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
@ -44,7 +44,7 @@ LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => p
|
|||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/reject_non_structural.rs:71:36
|
||||||
|
|
|
|
||||||
LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), };
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
@ -53,7 +53,7 @@ LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoop
|
|||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/reject_non_structural.rs:77:33
|
||||||
|
|
|
|
||||||
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), };
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
@ -62,7 +62,7 @@ LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops
|
|||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/reject_non_structural.rs:84:28
|
||||||
|
|
|
|
||||||
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), };
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
@ -71,7 +71,7 @@ LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => p
|
|||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/reject_non_structural.rs:90:28
|
||||||
|
|
|
|
||||||
LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
@ -79,38 +79,14 @@ LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), };
|
|||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
||||||
--> $DIR/reject_non_structural.rs:98:29
|
--> $DIR/reject_non_structural.rs:96:29
|
||||||
|
|
|
|
||||||
LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), };
|
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 #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/reject_non_structural.rs:14:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to 9 previous errors; 1 warning emitted
|
error: aborting due to 10 previous errors
|
||||||
|
|
||||||
Future incompatibility report: Future breakage diagnostic:
|
|
||||||
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"), };
|
|
||||||
| ^^^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/reject_non_structural.rs:14:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
// Regression test for the ICE described in #89088.
|
// Regression test for the ICE described in #89088.
|
||||||
|
|
||||||
//@ check-pass
|
|
||||||
|
|
||||||
#![allow(indirect_structural_match)]
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
const FOO: &A = &A::Field(Cow::Borrowed("foo"));
|
const FOO: &A = &A::Field(Cow::Borrowed("foo"));
|
||||||
@ -16,7 +13,7 @@ fn main() {
|
|||||||
let var = A::Field(Cow::Borrowed("bar"));
|
let var = A::Field(Cow::Borrowed("bar"));
|
||||||
|
|
||||||
match &var {
|
match &var {
|
||||||
FOO => todo!(),
|
FOO => todo!(), //~ERROR derive(PartialEq)
|
||||||
_ => todo!()
|
_ => todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
Future incompatibility report: Future breakage diagnostic:
|
error: to use a constant of type `Cow<'_, str>` in a pattern, `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]`
|
||||||
warning: to use a constant of type `Cow<'_, str>` in a pattern, `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]`
|
--> $DIR/issue-89088.rs:16:9
|
||||||
--> $DIR/issue-89088.rs:19:9
|
|
||||||
|
|
|
|
||||||
LL | FOO => todo!(),
|
LL | FOO => todo!(),
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#![warn(indirect_structural_match)]
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
trait Foo<'a> {
|
trait Foo<'a> {
|
||||||
const C: Option<Cell<&'a u32>>;
|
const C: Option<Cell<&'a u32>>;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0597]: `a` does not live long enough
|
error[E0597]: `a` does not live long enough
|
||||||
--> $DIR/issue-55511.rs:13:28
|
--> $DIR/issue-55511.rs:12:28
|
||||||
|
|
|
|
||||||
LL | let a = 22;
|
LL | let a = 22;
|
||||||
| - binding `a` declared here
|
| - binding `a` declared here
|
||||||
|
@ -9,15 +9,3 @@ LL | if let CONSTANT = &&MyType {
|
|||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
Future incompatibility report: Future breakage diagnostic:
|
|
||||||
warning: 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 {
|
|
||||||
| ^^^^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
// through that we had intended to reject.
|
// through that we had intended to reject.
|
||||||
//
|
//
|
||||||
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
|
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
struct NoDerive(i32);
|
struct NoDerive(i32);
|
||||||
|
|
||||||
// This impl makes NoDerive irreflexive.
|
// This impl makes NoDerive irreflexive.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
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
|
--> $DIR/cant-hide-behind-direct-struct-param.rs:21:9
|
||||||
|
|
|
|
||||||
LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
|
LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); }
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
// through that we had intended to reject.
|
// through that we had intended to reject.
|
||||||
//
|
//
|
||||||
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
|
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
//@ run-pass
|
|
||||||
|
|
||||||
struct NoDerive(#[allow(dead_code)] i32);
|
struct NoDerive(#[allow(dead_code)] i32);
|
||||||
|
|
||||||
@ -22,8 +20,7 @@ const WRAP_DOUBLY_INDIRECT_INLINE: & &WrapInline = & &WrapInline(& & NoDerive(0)
|
|||||||
fn main() {
|
fn main() {
|
||||||
match WRAP_DOUBLY_INDIRECT_INLINE {
|
match WRAP_DOUBLY_INDIRECT_INLINE {
|
||||||
WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
|
WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
|
||||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||||
//~| WARN this was previously accepted
|
|
||||||
_ => { println!("WRAP_DOUBLY_INDIRECT_INLINE correctly did not match itself"); }
|
_ => { println!("WRAP_DOUBLY_INDIRECT_INLINE correctly did not match itself"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,11 @@
|
|||||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: 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
|
--> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:22:9
|
||||||
|
|
|
|
||||||
LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE matched itself"); }
|
LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLINE 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 #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:7:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: 1 warning emitted
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
Future incompatibility report: Future breakage diagnostic:
|
|
||||||
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"); }
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:7:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
// through that we had intended to reject.
|
// through that we had intended to reject.
|
||||||
//
|
//
|
||||||
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
|
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
//@ run-pass
|
|
||||||
|
|
||||||
struct NoDerive(#[allow(dead_code)] i32);
|
struct NoDerive(#[allow(dead_code)] i32);
|
||||||
|
|
||||||
@ -22,8 +20,7 @@ const WRAP_DOUBLY_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(& & NoDe
|
|||||||
fn main() {
|
fn main() {
|
||||||
match WRAP_DOUBLY_INDIRECT_PARAM {
|
match WRAP_DOUBLY_INDIRECT_PARAM {
|
||||||
WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
|
WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
|
||||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||||
//~| WARN this was previously accepted
|
|
||||||
_ => { println!("WRAP_DOUBLY_INDIRECT_PARAM correctly did not match itself"); }
|
_ => { println!("WRAP_DOUBLY_INDIRECT_PARAM correctly did not match itself"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,11 @@
|
|||||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: 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
|
--> $DIR/cant-hide-behind-doubly-indirect-param.rs:22:9
|
||||||
|
|
|
|
||||||
LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM matched itself"); }
|
LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_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 #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/cant-hide-behind-doubly-indirect-param.rs:7:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: 1 warning emitted
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
Future incompatibility report: Future breakage diagnostic:
|
|
||||||
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"); }
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/cant-hide-behind-doubly-indirect-param.rs:7:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
// through that we had intended to reject.
|
// through that we had intended to reject.
|
||||||
//
|
//
|
||||||
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
|
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
//@ run-pass
|
|
||||||
|
|
||||||
struct NoDerive(#[allow(dead_code)] i32);
|
struct NoDerive(#[allow(dead_code)] i32);
|
||||||
|
|
||||||
@ -22,8 +20,7 @@ const WRAP_INDIRECT_INLINE: & &WrapInline = & &WrapInline(NoDerive(0));
|
|||||||
fn main() {
|
fn main() {
|
||||||
match WRAP_INDIRECT_INLINE {
|
match WRAP_INDIRECT_INLINE {
|
||||||
WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
|
WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
|
||||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||||
//~| WARN this was previously accepted
|
|
||||||
_ => { println!("WRAP_INDIRECT_INLINE did not match itself"); }
|
_ => { println!("WRAP_INDIRECT_INLINE did not match itself"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,11 @@
|
|||||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: 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
|
--> $DIR/cant-hide-behind-indirect-struct-embedded.rs:22:9
|
||||||
|
|
|
|
||||||
LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itself"); }
|
LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE 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 #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/cant-hide-behind-indirect-struct-embedded.rs:7:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: 1 warning emitted
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
Future incompatibility report: Future breakage diagnostic:
|
|
||||||
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"); }
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/cant-hide-behind-indirect-struct-embedded.rs:7:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
// through that we had intended to reject.
|
// through that we had intended to reject.
|
||||||
//
|
//
|
||||||
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
|
// See discussion on rust-lang/rust#62307 and rust-lang/rust#62339
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
//@ run-pass
|
|
||||||
|
|
||||||
struct NoDerive(#[allow(dead_code)] i32);
|
struct NoDerive(#[allow(dead_code)] i32);
|
||||||
|
|
||||||
@ -22,8 +20,7 @@ const WRAP_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(NoDerive(0));
|
|||||||
fn main() {
|
fn main() {
|
||||||
match WRAP_INDIRECT_PARAM {
|
match WRAP_INDIRECT_PARAM {
|
||||||
WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
|
WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
|
||||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||||
//~| WARN this was previously accepted
|
|
||||||
_ => { println!("WRAP_INDIRECT_PARAM correctly did not match itself"); }
|
_ => { println!("WRAP_INDIRECT_PARAM correctly did not match itself"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,11 @@
|
|||||||
warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq)]`
|
error: 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
|
--> $DIR/cant-hide-behind-indirect-struct-param.rs:22:9
|
||||||
|
|
|
|
||||||
LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself"); }
|
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 #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/cant-hide-behind-indirect-struct-param.rs:7:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: 1 warning emitted
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
Future incompatibility report: Future breakage diagnostic:
|
|
||||||
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"); }
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/cant-hide-behind-indirect-struct-param.rs:7:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
// Issue 62307 pointed out a case where the structural-match checking
|
// Issue 62307 pointed out a case where the structural-match checking
|
||||||
// was too shallow.
|
// was too shallow.
|
||||||
#![warn(indirect_structural_match)]
|
|
||||||
//@ run-pass
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct B(i32);
|
struct B(i32);
|
||||||
@ -29,15 +27,13 @@ fn main() {
|
|||||||
|
|
||||||
match RR_B0 {
|
match RR_B0 {
|
||||||
RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
|
RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
|
||||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||||
//~| WARN this was previously accepted
|
|
||||||
_ => { }
|
_ => { }
|
||||||
}
|
}
|
||||||
|
|
||||||
match RR_B1 {
|
match RR_B1 {
|
||||||
RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
|
RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
|
||||||
//~^ WARN must be annotated with `#[derive(PartialEq)]`
|
//~^ ERROR must be annotated with `#[derive(PartialEq)]`
|
||||||
//~| WARN this was previously accepted
|
|
||||||
_ => { }
|
_ => { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,63 +1,20 @@
|
|||||||
warning: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]`
|
error: 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
|
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:29:9
|
||||||
|
|
|
|
||||||
LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
|
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 #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:13:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
warning: to use a constant of type `B` in a pattern, `B` must be annotated with `#[derive(PartialEq)]`
|
error: 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
|
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:35:9
|
||||||
|
|
|
|
||||||
LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
|
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 #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
= note: the traits must be derived, manual `impl`s are not sufficient
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
||||||
|
|
||||||
warning: 2 warnings emitted
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
Future incompatibility report: Future breakage diagnostic:
|
|
||||||
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); }
|
|
||||||
| ^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:13:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Future breakage diagnostic:
|
|
||||||
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); }
|
|
||||||
| ^^^^^
|
|
||||||
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
|
||||||
= note: for more information, see issue #120362 <https://github.com/rust-lang/rust/issues/120362>
|
|
||||||
= note: the traits must be derived, manual `impl`s are not sufficient
|
|
||||||
= note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
|
|
||||||
note: the lint level is defined here
|
|
||||||
--> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:13:9
|
|
||||||
|
|
|
||||||
LL | #![warn(indirect_structural_match)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user