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

Wrong suggestion of using + static instead of <'static> for unions #71196

Closed
Dylan-DPC-zz opened this issue Apr 16, 2020 · 0 comments · Fixed by #71235
Closed

Wrong suggestion of using + static instead of <'static> for unions #71196

Dylan-DPC-zz opened this issue Apr 16, 2020 · 0 comments · Fixed by #71235
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Dylan-DPC-zz
Copy link

Dylan-DPC-zz commented Apr 16, 2020

Someone had this problem on discord, so creating an issue:

pub union Test<'t> {
    i: &'t i64,
    f: &'t f64,
}
thread_local! {
    static vals: RefCell<HashMap<i32, Vec<Vec<Test>>>> = RefCell::new(HashMap::new());
}

Rust suggests you to:

error[E0106]: missing lifetime specifier

   |
   |     static vals: RefCell<HashMap<i32, Vec<Vec<Test>>>> = RefCell::new(HashMap::new());
   |                                               ^^^^ help: consider giving it a 'static lifetime: `Test + 'static`
   |
   = help: this function's return type contains a borrowed value, but there is no value for it to be 
borrowed from

instead it should suggest to use Test<'static> and not <Test + 'static>

playground link

@Dylan-DPC-zz Dylan-DPC-zz added C-bug Category: This is a bug. A-diagnostics Area: Messages for errors, warnings, and lints labels Apr 16, 2020
@jonas-schievink jonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 16, 2020
@JohnTitor JohnTitor added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. labels Apr 16, 2020
@estebank estebank self-assigned this Apr 17, 2020
estebank added a commit to estebank/rust that referenced this issue Apr 17, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 21, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 23, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 24, 2020
@bors bors closed this as completed in 13c1dae Apr 24, 2020
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-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-bug Category: This is a bug. D-incorrect Diagnostics: A diagnostic that is giving misleading or incorrect information. 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.

4 participants