Closed
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
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: The 2024 editionRelating to patterns and pattern matchingArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: Confusing error or lint that should be reworked.Relevant to the compiler team, which will review and decide on the PR/issue.