Skip to content

"patterns are not allowed to reset the default binding mode" suggestion means nothing to me #133854

Closed
@shepmaster

Description

@shepmaster
Member

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

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Dec 4, 2024
added
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
D-confusingDiagnostics: Confusing error or lint that should be reworked.
A-patternsRelating to patterns and pattern matching
on Dec 4, 2024
traviscross

traviscross commented on Dec 10, 2024

@traviscross
Contributor
dianne

dianne commented on Dec 16, 2024

@dianne
Contributor

@rustbot claim

added 5 commits that reference this issue on Dec 18, 2024

Rollup merge of rust-lang#134394 - dianne:clarify-pat-2024-migration,…

435bb02

Rollup merge of rust-lang#134394 - dianne:clarify-pat-2024-migration,…

06081aa

Rollup merge of rust-lang#134394 - dianne:clarify-pat-2024-migration,…

7b9787f

Rollup merge of rust-lang#134394 - dianne:clarify-pat-2024-migration,…

e7b22a1

Rollup merge of rust-lang#134394 - dianne:clarify-pat-2024-migration,…

f3faaf5
added a commit that references this issue on Dec 18, 2024
bea1745
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-edition-2024Area: The 2024 editionA-patternsRelating to patterns and pattern matchingA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-confusingDiagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @shepmaster@traviscross@fmease@dianne

    Issue actions

      "patterns are not allowed to reset the default binding mode" suggestion means nothing to me · Issue #133854 · rust-lang/rust