Skip to content
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: incomprehensible "free region '' does not outlive 'foo" error #49493

Closed
nikomatsakis opened this issue Mar 30, 2018 · 2 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non Lexical Lifetimes (NLL)

Comments

@nikomatsakis
Copy link
Contributor

This program ought not to compile, but the error we get is pretty darn incomprehensible (play):

#![feature(nll)]
#![feature(in_band_lifetimes)]
#![allow(warnings)]

struct CookieJar<'data> {
    vec: Vec<String>,
    data: &'data (),
}

impl CookieJar<'data> {
    fn cookie_me(&self) -> Cookie<'data> {
        let next = 22;
        me_want_cookie(next, self)
    }
}

struct Cookie<'jar> {
    jar: &'jar CookieJar<'jar>
}

fn me_want_cookie(next: usize, jar: &'jar CookieJar<'jar>) -> Cookie<'jar> {
    Cookie { jar }
}

fn main() {
}

gives me

error: free region `` does not outlive free region `'data`
  --> src/main.rs:12:13
   |
12 |         let next = 22;
   |             ^^^^
@nikomatsakis nikomatsakis added A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non Lexical Lifetimes (NLL) WG-compiler-nll labels Mar 30, 2018
@sapphire-arches
Copy link
Contributor

Dupe of #49397 I think ref.

@nikomatsakis
Copy link
Contributor Author

Closing as dup of #49397

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non Lexical Lifetimes (NLL)
Projects
None yet
Development

No branches or pull requests

2 participants