-
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 breaks functions with intermingled lifetimes in return type when returned value is a (non-borrowed) associated type #49354
Comments
Minified. trait Visitor<'de> {
type Value;
}
impl<'a, 'de: 'a> Visitor<'de> for &'a () {
type Value = ();
}
//error: free region `'a` does not outlive free region `'de`
fn visit_seq<'de: 'a, 'a>() -> <&'a () as Visitor<'de>>::Value {}
// ^^
fn main() {} |
This was broken sometime in between nightly-2018-03-07 and nightly-2018-03-15. There don't seem to be any nightly builds available between those two dates, I don't think I can narrow it down further on my computer. |
I'll take a go at this issue. |
An update on my progress with this: I've got the logging for the some recent commit near HEAD and a commit before the regression was introduced. #48411 was a pretty large change and there's no clear place (to my untrained eyes) where it might have introduced the regression. I'm struggling to make heads of tails of what exactly is happening. I've got the logging in a gist. |
Thank you for taking this on! If there's anything I can do to help, I can try. I'm not well-versed in compiler-internals, though, so I probably won't be able to help much. |
@davidtwco ah indeed that is a big PR =) I guess it's not surprising that it has a bit of fallout. I imagine I'll have to dig a bit deeper. I wonder if we can find a more minimal example. |
I wonder if #49824 is related. |
I'm going to unassign myself from this issue. Not got a lot of time over the next month or so and don't want this priority issue to be held up. |
…nikomatsakis Register outlives predicates from queries the right way around. Closes #49354 The region constraints from queries need to be reversed from sub to outlives. Note: wf checking reports these errors before NLL, so I'm not sure if there's any case when these predicates need to be created at all. cc @nikomatsakis
Code which returns this kind of complicated expression involving two different lifetimes compiles under normal compilation conditions, but fails with
#![feature(nll)]
.Minified example (courtesy of @matthewjasper).
working playground: https://play.rust-lang.org/?gist=5f08095fda551daa89fadf0b8566989e&version=nightly
broken playground: https://play.rust-lang.org/?gist=a5d0d7619f610d94fe316c80b0f1dfbb&version=nightly
Original post / serde_derive generated code example
The source code is anything like the following:
Pared down generated code:
This code compiles without NLL enabled, but with NLL, fails with:
Playground working: https://play.rust-lang.org/?gist=cb213e15287e06e85fb7a55412967b23&version=nightly
Playground failing: https://play.rust-lang.org/?gist=c4745b7f9e40f16bd7fe62f27d9c534b&version=nightly
The text was updated successfully, but these errors were encountered: