diff --git a/impl/src/fmt.rs b/impl/src/fmt.rs index bc6f3dc..d049fd8 100644 --- a/impl/src/fmt.rs +++ b/impl/src/fmt.rs @@ -4,7 +4,7 @@ use crate::scan_expr::scan_expr; use crate::unraw::{IdentUnraw, MemberUnraw}; use proc_macro2::{Delimiter, TokenStream, TokenTree}; use quote::{format_ident, quote, quote_spanned}; -use std::collections::{BTreeSet as Set, HashMap as Map}; +use std::collections::{BTreeSet, HashMap as Map, HashSet}; use std::iter; use syn::ext::IdentExt; use syn::parse::discouraged::Speculative; @@ -33,7 +33,7 @@ impl Display<'_> { let mut out = String::new(); let mut args = self.args.clone(); let mut has_bonus_display = false; - let mut implied_bounds = Set::new(); + let mut implied_bounds = BTreeSet::new(); let mut has_trailing_comma = false; if let Some(TokenTree::Punct(punct)) = args.clone().into_iter().last() { @@ -85,7 +85,7 @@ impl Display<'_> { MemberUnraw::Named(ident) => ident.clone(), }; out += &formatvar.to_string(); - if !named_args.insert(formatvar.clone()) { + if !named_args.insert(member.clone()) { // Already specified in the format argument list. continue; } @@ -130,7 +130,7 @@ impl Display<'_> { } struct FmtArguments { - named: Set, + named: HashSet, first_unnamed: Option, } @@ -150,7 +150,7 @@ fn explicit_named_args(input: ParseStream) -> Result { input.parse::().unwrap(); Ok(FmtArguments { - named: Set::new(), + named: HashSet::new(), first_unnamed: None, }) } @@ -158,7 +158,7 @@ fn explicit_named_args(input: ParseStream) -> Result { fn try_explicit_named_args(input: ParseStream) -> Result { let mut syn_full = None; let mut args = FmtArguments { - named: Set::new(), + named: HashSet::new(), first_unnamed: None, }; @@ -172,7 +172,7 @@ fn try_explicit_named_args(input: ParseStream) -> Result { if input.peek(Ident::peek_any) && input.peek2(Token![=]) && !input.peek2(Token![==]) { let ident: IdentUnraw = input.parse()?; input.parse::()?; - args.named.insert(ident); + args.named.insert(MemberUnraw::Named(ident)); } else { begin_unnamed = Some(input.fork()); } @@ -196,7 +196,7 @@ fn try_explicit_named_args(input: ParseStream) -> Result { fn fallback_explicit_named_args(input: ParseStream) -> Result { let mut args = FmtArguments { - named: Set::new(), + named: HashSet::new(), first_unnamed: None, }; @@ -209,7 +209,7 @@ fn fallback_explicit_named_args(input: ParseStream) -> Result { input.parse::()?; let ident: IdentUnraw = input.parse()?; input.parse::()?; - args.named.insert(ident); + args.named.insert(MemberUnraw::Named(ident)); } } diff --git a/impl/src/unraw.rs b/impl/src/unraw.rs index c627661..267bd02 100644 --- a/impl/src/unraw.rs +++ b/impl/src/unraw.rs @@ -74,6 +74,7 @@ impl ToTokens for IdentUnraw { } } +#[derive(Clone)] pub enum MemberUnraw { Named(IdentUnraw), Unnamed(Index),