-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-edition-2024Area: The 2024 editionArea: The 2024 editionA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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
Code
use std::collections::BTreeMap;
fn demo(map: BTreeMap<(usize, usize), char>) {
map.iter().filter(|(&(_x, _y), &_c)| false);
}
Current output
error: patterns are not allowed to reset the default binding mode in edition 2024
--> src/lib.rs:4:24
|
4 | map.iter().filter(|(&(_x, _y), &_c)| false);
| -^^^^^^^^^^^^^^^
| |
| help: desugar the match ergonomics: `&`
Desired output
error: patterns are not allowed to reset the default binding mode in edition 2024
--> src/lib.rs:4:24
|
4 | map.iter().filter(|(&(_x, _y), &_c)| false);
| -^^^^^^^^^^^^^^^
| |
| help: add an `&` at the beginning of this pattern
Rationale and extra context
Presented with this error, I was completely stumped. I have no idea what the suggestion is attempting to get me to do.
I do not think the word "desugar" is useful here because it's not obvious to me (a) that there was sugar and (b) what the sugaring was. Without that knowledge, the suggestion is non-actionable.
After minutes of reading/reducing/reproducing the problem, I finally realized that that the -
part of the -^^^^^^^^^^^^^^^
was pointing to the parenthesis and not to the &
, so I tried adding it and it compiled.
Additionally, I worry that "default binding mode" is not an established / well-known terminology so there's not much meat from that message for me to go on either.
Rust Version
rustc 1.85.0-nightly (c44b3d50f 2024-12-03)
binary: rustc
commit-hash: c44b3d50fea96a3e0417e8264c16ea21a0a3fca2
commit-date: 2024-12-03
host: aarch64-apple-darwin
release: 1.85.0-nightly
LLVM version: 19.1.4
seritools, eric-seppanen and anko
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-edition-2024Area: The 2024 editionArea: The 2024 editionA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.