-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhelpful / misleading error message and help message when using a reference to a vector #83924
Comments
I'm actually surprised that you got E0277 when doing |
@rustbot label: +T-libs +A-iterators +A-coercions |
Okay, this is due to the desugaring in rust/compiler/rustc_ast_lowering/src/expr.rs Lines 1710 to 1728 in e1d49aa
Because |
@rustbot label: -T-libs +T-compiler |
Add suggestion to reborrow mutable references when they're moved in a for loop Address rust-lang#83924
Add suggestion to reborrow mutable references when they're moved in a for loop Address rust-lang#83924
Hello,
There is a case where the Rust compiler error message is misleading. I tried this code :
…which gives the following error message, and misleading « help » message :
Especially, the
help: consider borrowing to avoid moving into the for loop: '&v'
is the misleading part, does not help solve the problem at all, and sent me an a wrong path.As I am new to Rust, this got me scratching my head for some time until someone explained it to me (here).
(And since the Rust compiler is most of the time very helpful, I did not even consider that its suggestion could be wrong haha. Hm.)
Instead of this, maybe a short message explaining how to reborrow the reference in this kind of situation would be more helpful and less misleading ?
Thank you.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: