rustc suggests a syntax error (for x in &mut mut y) #67683
Labels
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
C-bug
Category: This is a bug.
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
This may be a duplicate of issue #57431; I don't understand Rust well enough yet to be sure.
When using
chunks_exact
instead ofchunks_exact_mut
and then mutating through the returned slices, rustc complains and suggests iterating over&mut mut chunks
in the loop, which appears to be a syntax error.I tried this code:
I expected to see this happen:
The actual bug is
chunks_exact
should bechunks_exact_mut
(and then switchremainder
tointo_remainder
to match). That's probably a tall order for the compiler to suggest, but the error message should definitely not suggest a syntax error.Instead, this happened:
Applying the suggestion results in a syntax error:
Meta
rustc --version --verbose
:rustc 1.40.0 (73528e3 2019-12-16)
binary: rustc
commit-hash: 73528e3
commit-date: 2019-12-16
host: x86_64-unknown-linux-gnu
release: 1.40.0
LLVM version: 9.0
The text was updated successfully, but these errors were encountered: