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

Strange diagnostic message with a suggestion to annotate the lifetime #100442

Closed
uselessgoddess opened this issue Aug 12, 2022 · 0 comments · Fixed by #100940
Closed

Strange diagnostic message with a suggestion to annotate the lifetime #100442

uselessgoddess opened this issue Aug 12, 2022 · 0 comments · Fixed by #100940
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@uselessgoddess
Copy link

uselessgoddess commented Aug 12, 2022

I wanted to issue a bug report in bumpalo and show an example of a vector error message from std
But I got a very strange suggest from compiler:

fn foo() -> impl Iterator<Item = usize> {
    let arena = Bump::new();
    // vec![in &arena; 1, 2, 3].into_iter()
    let mut vec = Vec::new_in(&arena);
    vec.push(1);
    vec.push(2);
    vec.push(3);
    vec.into_iter()
}

link to playground

error[E0597]: `arena` does not live long enough
  --> src\main.rs:8:31
   |
8  |     let mut vec = Vec::new_in(&arena);
   |                               ^^^^^^ borrowed value does not live long enough
...
12 |     vec.into_iter()
   |     --------------- opaque type requires that `arena` is borrowed for `'static`
13 | }
   | - `arena` dropped here while still borrowed
   |
help: you can add a bound to the opaque type to make it last less than `'static` and match `'static`
   |
12 |     vec.into_iter() + 'static
   |                     +++++++++

I even thought there was progress in type_ascription feature
In general, this message is very strange. Right now in growth I can't make arena live longer (I can, but not through annotations)

@uselessgoddess uselessgoddess added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 12, 2022
@TaKO8Ki TaKO8Ki self-assigned this Aug 12, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 24, 2022
…d-to-opaque-type, r=fee1-dead

Do not suggest adding a bound to a opaque type

fixes rust-lang#100442
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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants