-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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: error from URL crate #47703
Comments
As noted in the other issue, changing the method to the one below works around the bug: fn consume(self) -> &'a mut () {
let MyStruct { field, field2 } = self;
field
} In other words, when |
Another related case, from https://play.rust-lang.org/?gist=5b3934b08dec4d034dc5b00fba8647c3&version=nightly |
I'll take a look at this one. |
@nikomatsakis I would appreciate some pointers on where I should be looking for this, couldn't spot anything when I took a look at what was happening in the areas of the code that I'm familiar with. Not worked with the NLL code much. |
@davidtwco I don't know that this is an NLL problem per se, I think it has more to do with MIR borrowck. In particular, removing
I think the error comes precisely at |
Tracing through, I expect that we start at a rust/src/librustc_mir/borrow_check/mod.rs Lines 424 to 431 in 70f7d58
This invokes rust/src/librustc_mir/borrow_check/mod.rs Lines 711 to 724 in 70f7d58
which then checks for conflicts: rust/src/librustc_mir/borrow_check/mod.rs Lines 744 to 745 in 70f7d58
Inside the rust/src/librustc_mir/borrow_check/mod.rs Lines 753 to 760 in 70f7d58
I expect we head down this arm: rust/src/librustc_mir/borrow_check/mod.rs Line 823 in 70f7d58
and then presumably here: rust/src/librustc_mir/borrow_check/mod.rs Lines 859 to 867 in 70f7d58
Stepping back, I think the fundamental problem comes from the call to rust/src/librustc_mir/borrow_check/mod.rs Lines 762 to 766 in 70f7d58
Looking at the source of that function: rust/src/librustc_mir/borrow_check/mod.rs Lines 2054 to 2061 in 70f7d58
I expect the problem must be in the rust/src/librustc_mir/borrow_check/mod.rs Line 2076 in 70f7d58
But it seems like that function is returning rust/src/librustc_mir/borrow_check/mod.rs Lines 1967 to 1973 in 70f7d58
So I'm not sure where it goes wrong. Perhaps insert some debugs and see where my predictions go astray? =) |
Ok, after some discussion with @davidtwco it has become clear where I went wrong. The error is actually being reported by a I think what we have to do is to kind of "bake in" a bit of knowledge about the drop glue. For simplicity, I'll just describe what we need to do in terms of structs here as a kind of pseudo-code. Right now we do this:
This is too conservative. We want to be doing something like:
If we did this, we would wind up unrolling the |
Fixes NLL: error from URL crate Fixes #47703. r? @nikomatsakis
In #47596, @SimonSapin reported several NLL errors in dependencies of the servo crate. @Aaron1011 later minimized one of those errors into this example:
which yields:
Removing feature(nll) makes the code work, so probably this is an NLL bug.
The text was updated successfully, but these errors were encountered: