You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Match ergonomics error message about Rust 2024 future compatibility in Rust 2024 #136456
In Rust 2024, the following error message is emitted:
//@ edition: 2024fnmain(){let[&_x] = &mut[&()];//~^ ERROR this pattern relies on behavior which may change in edition 2024//~| ERROR cannot implicitly match against multiple layers of reference//~| NOTE make the implied reference pattern explicit}
This message isn't great. The problem isn't really that the behavior may change in Rust 2024, it's that this is simply disallowed (starting in Rust 2024).
We should probably also remove the bit about "implicitly matching against multiple layers of references". If someone is in the Rust 2024 headspace, this isn't necessarily what the person was trying to do in writing this.
I've been wondering about how to word this better.. I agree that "cannot implicitly match against multiple layers of reference" isn't ideal, but I'd like some explanation of what went wrong on that label, since it does point to the & that's disallowed. Maybe something that matches the wording in the edition guide, since there's a link in the error? e.g. "reference patterns can only be written when the pattern is fully explicit up to that point" or "reference patterns can only be written when the default binding mode is by-move". Or one of those with "&"/"&mut" as appropriate instead of "reference" to be a little more concise. Or maybe it could be framed in terms of being disallowed when the default binding mode is by-reference, to match with the other labels the error can have (or maybe those labels should also be framed in terms of only being allowed when the default binding mode is by-move?). I'll think about it.
In any case, I'll update the error message and label text. If anyone has wording ideas or opinions, please let me know. @rustbot claim
The commits from #136475 were merged via #136577. I completely forgot this wouldn't automatically be closed that way, but the improved wording is now in nightly (playground link).
Activity
dianne commentedon Feb 3, 2025
I've been wondering about how to word this better.. I agree that "cannot implicitly match against multiple layers of reference" isn't ideal, but I'd like some explanation of what went wrong on that label, since it does point to the
&that's disallowed. Maybe something that matches the wording in the edition guide, since there's a link in the error? e.g. "reference patterns can only be written when the pattern is fully explicit up to that point" or "reference patterns can only be written when the default binding mode is by-move". Or one of those with "&"/"&mut" as appropriate instead of "reference" to be a little more concise. Or maybe it could be framed in terms of being disallowed when the default binding mode is by-reference, to match with the other labels the error can have (or maybe those labels should also be framed in terms of only being allowed when the default binding mode is by-move?). I'll think about it.In any case, I'll update the error message and label text. If anyone has wording ideas or opinions, please let me know. @rustbot claim
dianne commentedon Feb 10, 2025
The commits from #136475 were merged via #136577. I completely forgot this wouldn't automatically be closed that way, but the improved wording is now in nightly (playground link).
traviscross commentedon Feb 10, 2025
Closing as fixed by: