Skip to content

NLL: Implicit reborrow hides error "Cannot move out of Struct with destructor" #52059

Closed
@lqd

Description

@lqd

Found while triaging the NLL crater run, in Servo's url crate.

Playground

There's a Drop impl preventing , so the error should at least mention it. But the implicit reborrow self.url hides this error with a '*self.url' does not live long enough one.

Changing the impl to

impl<'a> S<'a> {
    fn finish(self) -> &'a mut String {
        let p = self.url;
        p
    }
}

gives a better error message: self.url cannot move out of type "S<'_>", which implements the "Drop" trait.

Metadata

Metadata

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