-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
quickfix inserts where clause for tuple structs in wrong place and causes errors #10923
Comments
What does |
|
Oh, so its not a RA bug, but a compiler bug? |
Yes, I was just wondering whether it might come from the derive macro, but this does indeed look like it's from rustc. |
should i close this issue and report the bug at rust compiler repo? |
Given this assist is sourced from rustc, I think we can close this issue here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am newbie, so i will repeat when i learnt on rust official discord while debugging this issue.
Reproduce error:
add
derive_more
andhalfbrown
as dependencies.create a tuple struct with
halfbrown::HashMap
as its only field.derive
IntoIterator
using derive_more with the #[derive(IntoIterator)]vscode/RA complain that the macro needs trait bounds of IntoIterator for the inner field.
suggest the quickfix to put a where class specifying the requirement. I click on quickfix

quickfix introduces the where clause between the struct name and the parenthesis which declare the fields, which introduces a whole new class of errors

the full errors that cargo check gives me:
The Fix:
changing
pub struct UOMap<K: std::hash::Hash,V> where halfbrown::HashMap<K, V>: std::iter::IntoIterator(HashMap<K, V>);
to
pub struct UOMap<K: std::hash::Hash,V>(HashMap<K, V>) where halfbrown::HashMap<K, V>: std::iter::IntoIterator;
basically, insert the where clause AFTER the closing parenthesis. from what i was told on the discord, where clause needs to come just before the first
{
, but idk how it will be dealt with in regards to tuple struct.rust-analyzer version: rust-analyzer version: d9b2291 2021-11-29 stable
rustc version: rustc 1.57.0 (f1edd0429 2021-11-29)
The text was updated successfully, but these errors were encountered: