-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking issue for illegal_struct_or_enum_constant_pattern
compatibility lint
#36891
Closed
3 tasks done
Labels
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
B-unstable
Blocker: Implemented in the nightly compiler and unstable.
Comments
@nikomatsakis, could you write a description for this? |
This was referenced Oct 5, 2016
steveklabnik
added
the
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
label
Oct 7, 2016
@petrochenkov done. |
brson
added
the
B-unstable
Blocker: Implemented in the nightly compiler and unstable.
label
Mar 1, 2017
bors
added a commit
that referenced
this issue
Jun 1, 2017
Turn sufficiently old compatibility lints into hard errors It's been almost 7 months since #36894 was merged, so it's time to take the next step. [breaking-change], needs crater run. PRs/issues submitted to affected crates: https://github.com/alexcrichton/ctest/pull/17 Sean1708/rusty-cheddar#55 m-r-r/helianto#3 azdle/virgil#1 rust-locale/rust-locale#24 mneumann/acyclic-network-rs#1 reem/rust-typemap#38 cc https://internals.rust-lang.org/t/moving-forward-on-forward-compatibility-lints/4204 cc #34537 #36887 Closes #36886 Closes #36888 Closes #36890 Closes #36891 Closes #36892 r? @nikomatsakis
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this issue
Jun 1, 2017
Turn sufficiently old compatibility lints into hard errors It's been almost 7 months since rust-lang#36894 was merged, so it's time to take the next step. [breaking-change], needs crater run. PRs/issues submitted to affected crates: https://github.com/alexcrichton/ctest/pull/17 Sean1708/rusty-cheddar#55 m-r-r/helianto#3 azdle/virgil#1 rust-locale/rust-locale#24 mneumann/acyclic-network-rs#1 reem/rust-typemap#38 cc https://internals.rust-lang.org/t/moving-forward-on-forward-compatibility-lints/4204 cc rust-lang#34537 rust-lang#36887 Closes rust-lang#36886 Closes rust-lang#36888 Closes rust-lang#36890 Closes rust-lang#36891 Closes rust-lang#36892 r? @nikomatsakis
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
B-unstable
Blocker: Implemented in the nightly compiler and unstable.
This is the summary issue for the
illegal_struct_or_enum_constant_pattern
future-compatibility warning and other related errors. The goal of
this page is describe why this change was made and how you can fix
code that is affected by it. It also provides a place to ask questions
or register a complaint if you feel the change should not be made. For
more information on the policy around future-compatibility warnings,
see our breaking change policy guidelines.
What is the warning for?
Rust 1.0 accepted a number of patterns -- and in particular accepted constant in patterns --
in a broader range of situations that was originally intended. RFC 1445 spelled out
some restrictions on what kinds of constants can be used in patterns, at least until the
final semantics are affirmatively decided. The intention is that user-defined
struct
andenum
types can only be used in match patterns if they derive thePartialEq
andEq
traits (note that the traits must be automatically derived using
#[derive(...)]
, they cannotbe implemented by hand).
This means that a match like this is illegal:
To make it legal, add
#[derive(PartialEq, Eq)]
to theFoo
struct.The reason for this restriction is that pattern matching does not
actually invoke the
Eq
methods defined in those traits.Instead, internally, it compares each field deeply and recursively.
If you are using
#[derive]
, this is guaranteed to be equivalentto invoking the methods by hand. But if you are not using
#[derive]
,then the
Eq
comparison method could do arbitrary things.When will this warning become a hard error?
At the beginning of each 6-week release cycle, the Rust compiler team
will review the set of outstanding future compatibility warnings and
nominate some of them for Final Comment Period. Toward the end of
the cycle, we will review any comments and make a final determination
whether to convert the warning into a hard error or remove it
entirely.
Current status
illegal_struct_or_enum_constant_pattern
lint as warn-by-defaultillegal_struct_or_enum_constant_pattern
lint deny-by-defaultillegal_struct_or_enum_constant_pattern
lint a hard errorThe text was updated successfully, but these errors were encountered: