where clause for tuple structs recommended at wrong place causing syntax errors #91520
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.
Me Newbie. I had this issue while trying to create a new type to abstract over a HashMap, went to rust discord where i got the fix. then, as i got the suggestion as a quickfix from vscode, i thought it was a Rust analyzer bug, rust-lang/rust-analyzer#10923 . but this is a rust bug it seems.
Reproduce error:
derive_more
andhalfbrown
as dependencies. //hashbrown will probably work toohalfbrown::HashMap
as its only field.UOMap<K,V>(halfbrown::HashMap<K,V>)
IntoIterator
using derive_more with the #[derive(IntoIterator)] and vscode gives this error.cargo check output:
8 | pub struct UOMap<K: std::hash::Hash,V> where halfbrown::HashMap<K, V>: IntoIterator(HashMap<K, V>);
with where clause between the struct name and the parenthesis which declare the fields, is wrong and introduces a whole new class of errorscargo output:
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.rustc version: rustc 1.57.0 (f1edd04 2021-11-29)
The text was updated successfully, but these errors were encountered: