Skip to content

NLL: Implied bounds computation misses some relationships #52078

Closed

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

  1. added
    A-NLLArea: Non-lexical lifetimes (NLL)
    on Jul 5, 2018
  2. added
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 11, 2018
  3. self-assigned this
    on Jul 17, 2018
  4. nikomatsakis commented on Jul 18, 2018

    @nikomatsakis
    Contributor

    Turns out to be fixed by #51959

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