-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NLL: Implicit reborrow hides error "Cannot move out of Struct with destructor" #52059
Comments
assigning to self, hoping to investigate this week |
(to be clear, even an explicit reborrow would produce the error message that is being deemed inferior here...) |
To be even more clear: the error here isn't about the illegality of moving out of a struct with a destructor, because the code is not doing any such move. What the code is doing is borrowing into the interior of a struct with a destructor, and that borrow outlives the lifetime of the struct. Thus the struct's That's not to say that the given error message cannot be improved. In particular, it might be better if it said something like:
|
Okay I think I have a patch to fix this. And it seems like it improves some of our other diagnostics elsewhere. Will post PR soonish. |
…ct, r=nikomatsakis Report when borrow could cause `&mut` aliasing during Drop We were already issuing an error for the cases where this cropped up, so this is not fixing any soundness holes. The previous diagnostic just wasn't accurately describing the problem in the user's code. Fix #52059
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
gives a better error message:
self.url
cannot move out of type "S<'_>", which implements the "Drop" trait
.The text was updated successfully, but these errors were encountered: