Repository navigation
nll: strange suggestion to "consider removing the * #54985
Copy link
Copy link
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::readbut I'm sort of inclined to just not suggest anything at all.
Reactions are currently unavailable
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
Activity
estebank commentedon Oct 11, 2018
rust/src/librustc_mir/borrow_check/move_errors.rs
Lines 353 to 406 in b8b4150
pnkfelix commentedon Oct 16, 2018
How bad might it be to just remove this suggestion entirely (vs attempting to fine tune when we emit it)? Can we easily weigh the good it brings vs the harm it causes?
nikomatsakis commentedon Oct 16, 2018
I'd prefer to just remove it entirely. I think it adds pretty little value.
nikomatsakis commentedon Oct 16, 2018
I could imagine using an extended error code to offer more detailed hints
nikomatsakis commentedon Oct 16, 2018
or else a reference to something online?
pnkfelix commentedon Oct 16, 2018
marking as NLL-deferred as this should not block RC2 (or even the Release, IMO).
pnkfelix commentedon Mar 20, 2019
NLL triage. Tagging as P-medium priority.
oli-obk commentedon May 24, 2019
Diagnostics triage: marking as E-easy since it's just removing the suggestion
Rollup merge of rust-lang#61332 - kennethbgoodin:borrowck-remove-aste…
Rollup merge of rust-lang#61332 - kennethbgoodin:borrowck-remove-aste…
awaitlink commentedon Jun 17, 2019
Shouldn't this be closed because #61332 is now merged?