@@ -29,7 +29,7 @@ use rustc_span::Span;
29
29
use smallvec:: { smallvec, SmallVec } ;
30
30
31
31
use rustc_span:: source_map:: { respan, Spanned } ;
32
- use std:: collections:: BTreeSet ;
32
+ use std:: collections:: { hash_map :: Entry , BTreeSet } ;
33
33
use std:: mem:: { replace, take} ;
34
34
use tracing:: debug;
35
35
@@ -1060,36 +1060,29 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1060
1060
continue ;
1061
1061
}
1062
1062
1063
- let def_kind = match param. kind {
1064
- GenericParamKind :: Type { .. } => DefKind :: TyParam ,
1065
- GenericParamKind :: Const { .. } => DefKind :: ConstParam ,
1066
- _ => unreachable ! ( ) ,
1067
- } ;
1068
-
1069
1063
let ident = param. ident . normalize_to_macros_2_0 ( ) ;
1070
1064
debug ! ( "with_generic_param_rib: {}" , param. id) ;
1071
1065
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
+ }
1076
1075
}
1077
- seen_bindings. entry ( ident) . or_insert ( param. ident . span ) ;
1078
1076
1079
1077
// 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 ) ,
1091
1081
_ => 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) ;
1093
1086
}
1094
1087
1095
1088
self . ribs [ ValueNS ] . push ( function_value_rib) ;
0 commit comments