-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalP-mediumMedium priorityMedium priority
Description
Spawned off of #54825 (comment)
For this code:
rust/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.rs
Lines 12 to 15 in fe8ace8
unsafe fn foo(x: *const Box<isize>) -> Box<isize> { | |
let y = *x; //~ ERROR cannot move out of dereference of raw pointer | |
return y; | |
} |
which produces this diagnostic output:
LL | let y = *x; //~ ERROR cannot move out of dereference of raw pointer | |
| ^^ | |
| | | |
| cannot move out of dereference of raw pointer | |
| help: consider removing the `*`: `x` |
@nikomatsakis made this comment about the HELP on line 8:
Pre-existing but: it is...strange that we make this suggestion. It seems almost certainly wrong. It doesn't preserve the type or "intent" of the code in any particular way...? It's also distinct from what the AST checker says, which is to suggest
&*x
(though I would argue that is also wrong, for similar reasons). It feels like the best suggestion might beptr::read
but I'm sort of inclined to just not suggest anything at all.
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goalP-mediumMedium priorityMedium priority