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 produces ungreat error messages with free regions #49397

Closed
sapphire-arches opened this issue Mar 26, 2018 · 3 comments
Closed

NLL produces ungreat error messages with free regions #49397

sapphire-arches opened this issue Mar 26, 2018 · 3 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non Lexical Lifetimes (NLL) C-enhancement Category: An issue proposing an enhancement or a PR with one. NLL-diagnostics Working torwads the "diagnostic parity" goal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sapphire-arches
Copy link
Contributor

NLL produces the following ungreat diagnostic message:

error: free region `` does not outlive free region `'a`
   --> src/main.rs:124:17
    |
124 |             let a = self.img.sub_image();
    |                 ^

Note the completely unnamed free region. I'm not sure what a good solution to this is, but it's probably not what is produced right now =)

When compiling the code here https://play.rust-lang.org/?gist=b7d7c69a4eb38a108409bb34a0a6ae46&version=nightly

@sapphire-arches sapphire-arches added A-diagnostics Area: Messages for errors, warnings, and lints A-NLL Area: Non Lexical Lifetimes (NLL) WG-compiler-nll NLL-diagnostics Working torwads the "diagnostic parity" goal labels Mar 26, 2018
@sapphire-arches
Copy link
Contributor Author

The unnamed region here is the automatic region created for the lifetime of the parameters.
Naming it as so:

 fn next<'b>(&'b mut self) -> Option<Self::Item> {

Produces the much better error message:

error: free region `'b` does not outlive free region `'gen_parent`
   --> src/main.rs:125:17
    |
125 |             let a = self.img.sub_image();
    |                 ^

@nikomatsakis
Copy link
Contributor

@bobtwinkles yeah so the empty string comes from the fact that it's an anoymous region, but what worries me more is that we highlight such random code. This is particularly evident in #49493.

@jkordish jkordish added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 5, 2018
@nikomatsakis
Copy link
Contributor

We have a lot of issues about this. I'm going to close this as a dup of #51027

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) C-enhancement Category: An issue proposing an enhancement or a PR with one. NLL-diagnostics Working torwads the "diagnostic parity" goal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants