Repository navigation
E0027 suggestion introduces refactoring-hazard #132008
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Activity
- addedA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
on Oct 21, 2024 - addedA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyD-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.
on Oct 21, 2024 - addedE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.and removedA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyD-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.
on Oct 21, 2024 @rustbot claim
@aticu How does this sound to you?
error[E0027]: pattern does not mention field `name` --> /Users/dp/Desktop/rust/tests/ui/error-codes/E0027.rs:11:9 | LL | Dog { age: x } => {} | ^^^^^^^^^^^^^^ missing field `name` | help: include the missing field in the pattern | LL | Dog { age: x, name } => {} | ~~~~~~~~ help: if the value is not relevant, discard it | LL | Dog { age: x, name: _ } => {} | ~~~~~~~~~~~ help: or allow missing fields here | LL | Dog { age: x, .. } => {} | ~~~~~~Looks good to me, thanks!
- added a commit that references this issue
on Nov 5, 2024 - added a commit that references this issue
on Nov 5, 2024 - added a commit that references this issue
on Nov 5, 2024
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
I often find myself trying to write code in such a way that future changes to a
struct, require me to look at all uses, since they may not accurately reflect what I want after the refactoring. The current suggestion actively goes against that, ignoring future field-additions.Ignoring fields is of course still a valid option in some cases, so the new suggestion would give both variants, allowing the user to choose which is more appropriate in this case (and making them aware of the trade-offs).
At the very least the message should reflect the trade-offs made when writing
..(also ignoring all fields added in the future).Other cases
The error message for three fields:
It is unclear to me whether for more than one field the error message should just scale to more fields (
field2: _, field3: _) or just suggest the..syntax and warn that it might result in unwanted ignored fields if more fields are added.Rust Version
Anything else?
No response