Skip to content

NLL: Improve move error loop detection #54015

Closed
@davidtwco

Description

@davidtwco

In #53995, errors were deduplicated and generally this kept errors with the improved "previous iteration of loop" diagnostic:

LL |         while true { while true { while true { x = y; x.clone(); } } }
   |                                                    ^ value moved here in previous iteration of loop

However, in one case, liveness-move-in-while.rs, the remaining error did not have the improved loop diagnostic.

From @nikomatsakis, in a comment from that PR (context mine):

actually, I think this [the diagnostic with loop message being missing] is an improvement — or rather it would be if the previous message mentioned the loop. Basically these seem like duplicate errors. I'm not sure why the "borrow of moved value" doesn't mention the loop, though: it seems like a failure in our loop printing heuristic, which is not very good. I think we ought to be walking from the point of the move forward (but ignoring backedges) — if we encounter the use point, then there is no loop, but otherwise we can say "in previous iteration of loop"... or something like that.

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)NLL-diagnosticsWorking towards the "diagnostic parity" goal

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions