-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
loan paths leaking into borrowck errors #41962
Comments
I think those are just the loan paths that borrowck uses. It's not like MIR is hooked up to it. |
cc @rust-lang/compiler |
Yes, this is not MIR, but just regular loan-paths. Nonetheless, a suboptimal experience. I'm not sure what's the best way to present this. Probably we would want to (at minimum) filter on paths that the user couldn't write and try a more ambiguous phrasing (e.g., 'move occurs because bound value has type (cc @estebank) |
Or maybe we can give the name of the binding (when there is one)? That might take a bit of plumbing. |
There probably should be only one move error in this code, should't it? Would the following output be enough (with very small changes to the existing code)? error[E0382]: use of partially moved value: `maybe`
--> test.rs:7:30
|
7 | if let Some(thing) = maybe {
| ----- ^^^^^ value used here after move
| |
| value moved here, because it has type `std::vec::Vec<bool>`, which does't implement the `Copy` trait
error: aborting due to previous error |
I think so. |
@estebank that output looks good to me |
I'll post a PR later today, but I'm not entirely convinced with the output, too long a label in my eyes:
vs the current
Three other alternatives I can think of are:
and
Does it make sense to refer to |
|
|
@arielb1 is there any reason why I'll leave changing the presentation of a shorter path using the local scope's identifier to the purview of #21934. |
No. Maybe we should just change both (and the relevant MIR case) to |
@arielb1 Shouldn't it be |
@estebank |
Reword reason for move note On move errors, when encountering an enum variant, be more ambiguous and do not refer to the type on the cause note, to avoid referring to `(maybe as std::prelude::v1::Some).0`, and instead refer to `the value`. Sidesteps part of the problem with #41962: ``` error[E0382]: use of partially moved value: `maybe` --> file.rs:5:30 | 5 | if let Some(thing) = maybe { | ----- ^^^^^ value used here after move | | | value moved here = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` --> file.rs:5:21 | 5 | if let Some(thing) = maybe { | ^^^^^ value moved here in previous iteration of loop = note: move occurs because the value has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait error: aborting due to 2 previous errors ``` Previous discussion: #44360 r? @arielb1
…to my code. In particular, I am adding an implicit injected borrow on the pattern matches, and when we go around the loop, the compiler is reporting that this injected borrow is conflicting with the move of the original value when the match succeeds.
Fixed in beta:
|
Scratch that, didn't notice the second main message |
Current output:
|
(playpen)
gives the error
(maybe:std::prelude::v1::Some).0
seems to be MIR leaking into the UIcc @jonathandturner @eddyb
The text was updated successfully, but these errors were encountered: