Skip to content

NLL: Implied bounds computation misses some relationships #52078

Description

@lqd

Found while triaging the NLL-enabled crater run, and extracted from specs-0.10.

#![feature(nll)]
#![allow(unused_variables)]

struct Drain<'a, T: 'a> {
    _marker: ::std::marker::PhantomData<&'a T>,
}

trait Join {
    type Value;
    fn get(value: &mut Self::Value);
}

impl<'a, T> Join for Drain<'a, T> {
    type Value = &'a mut Option<T>;
    
    fn get<'b>(value: &'b mut Self::Value) {
    }
}

fn main() {
}

Playground

Note: the added 'b is to make the error message clearer, about a the missed relationship between 'a and 'b from the argument type (maybe because it is going through the associated type).

Otherwise fn get(value: &mut Self::Value) yields this more obscure free region "'a" does not outlive free region "".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)C-enhancementCategory: An issue proposing an enhancement or a PR with one.NLL-completeWorking towards the "valid code works" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions