@@ -29,7 +29,7 @@ use rustc_span::Span;
2929use smallvec:: { smallvec, SmallVec } ;
3030
3131use rustc_span:: source_map:: { respan, Spanned } ;
32- use std:: collections:: BTreeSet ;
32+ use std:: collections:: { hash_map :: Entry , BTreeSet } ;
3333use std:: mem:: { replace, take} ;
3434use tracing:: debug;
3535
@@ -1060,36 +1060,29 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
10601060 continue ;
10611061 }
10621062
1063- let def_kind = match param. kind {
1064- GenericParamKind :: Type { .. } => DefKind :: TyParam ,
1065- GenericParamKind :: Const { .. } => DefKind :: ConstParam ,
1066- _ => unreachable ! ( ) ,
1067- } ;
1068-
10691063 let ident = param. ident . normalize_to_macros_2_0 ( ) ;
10701064 debug ! ( "with_generic_param_rib: {}" , param. id) ;
10711065
1072- if seen_bindings. contains_key ( & ident) {
1073- let span = seen_bindings. get ( & ident) . unwrap ( ) ;
1074- let err = ResolutionError :: NameAlreadyUsedInParameterList ( ident. name , * span) ;
1075- self . report_error ( param. ident . span , err) ;
1066+ match seen_bindings. entry ( ident) {
1067+ Entry :: Occupied ( entry) => {
1068+ let span = * entry. get ( ) ;
1069+ let err = ResolutionError :: NameAlreadyUsedInParameterList ( ident. name , span) ;
1070+ self . report_error ( param. ident . span , err) ;
1071+ }
1072+ Entry :: Vacant ( entry) => {
1073+ entry. insert ( param. ident . span ) ;
1074+ }
10761075 }
1077- seen_bindings. entry ( ident) . or_insert ( param. ident . span ) ;
10781076
10791077 // Plain insert (no renaming).
1080- let res = Res :: Def ( def_kind, self . r . local_def_id ( param. id ) . to_def_id ( ) ) ;
1081-
1082- match param. kind {
1083- GenericParamKind :: Type { .. } => {
1084- function_type_rib. bindings . insert ( ident, res) ;
1085- self . r . record_partial_res ( param. id , PartialRes :: new ( res) ) ;
1086- }
1087- GenericParamKind :: Const { .. } => {
1088- function_value_rib. bindings . insert ( ident, res) ;
1089- self . r . record_partial_res ( param. id , PartialRes :: new ( res) ) ;
1090- }
1078+ let ( rib, def_kind) = match param. kind {
1079+ GenericParamKind :: Type { .. } => ( & mut function_type_rib, DefKind :: TyParam ) ,
1080+ GenericParamKind :: Const { .. } => ( & mut function_value_rib, DefKind :: ConstParam ) ,
10911081 _ => unreachable ! ( ) ,
1092- }
1082+ } ;
1083+ let res = Res :: Def ( def_kind, self . r . local_def_id ( param. id ) . to_def_id ( ) ) ;
1084+ self . r . record_partial_res ( param. id , PartialRes :: new ( res) ) ;
1085+ rib. bindings . insert ( ident, res) ;
10931086 }
10941087
10951088 self . ribs [ ValueNS ] . push ( function_value_rib) ;
0 commit comments