Spawned off of #54825 (comment)
For this code:
|
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 be ptr::read but I'm sort of inclined to just not suggest anything at all.
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
which produces this diagnostic output:
rust/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr
Lines 4 to 8 in fe8ace8
@nikomatsakis made this comment about the HELP on line 8: