@@ -18,6 +18,7 @@ use rustc_ast::visit::{
18
18
} ;
19
19
use rustc_ast:: * ;
20
20
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap } ;
21
+ use rustc_data_structures:: unord:: { UnordMap , UnordSet } ;
21
22
use rustc_errors:: codes:: * ;
22
23
use rustc_errors:: {
23
24
Applicability , DiagArgValue , ErrorGuaranteed , IntoDiagArg , StashKey , Suggestions ,
@@ -47,8 +48,6 @@ mod diagnostics;
47
48
48
49
type Res = def:: Res < NodeId > ;
49
50
50
- type IdentMap < T > = FxHashMap < Ident , T > ;
51
-
52
51
use diagnostics:: { ElisionFnParameter , LifetimeElisionCandidate , MissingLifetime } ;
53
52
54
53
#[ derive( Copy , Clone , Debug ) ]
@@ -273,8 +272,8 @@ impl RibKind<'_> {
273
272
/// resolving, the name is looked up from inside out.
274
273
#[ derive( Debug ) ]
275
274
pub ( crate ) struct Rib < ' ra , R = Res > {
276
- pub bindings : IdentMap < R > ,
277
- pub patterns_with_skipped_bindings : FxHashMap < DefId , Vec < ( Span , Result < ( ) , ErrorGuaranteed > ) > > ,
275
+ pub bindings : FxHashMap < Ident , R > ,
276
+ pub patterns_with_skipped_bindings : UnordMap < DefId , Vec < ( Span , Result < ( ) , ErrorGuaranteed > ) > > ,
278
277
pub kind : RibKind < ' ra > ,
279
278
}
280
279
@@ -1605,12 +1604,12 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
1605
1604
// for better diagnostics.
1606
1605
let mut forward_ty_ban_rib_const_param_ty = Rib {
1607
1606
bindings : forward_ty_ban_rib. bindings . clone ( ) ,
1608
- patterns_with_skipped_bindings : FxHashMap :: default ( ) ,
1607
+ patterns_with_skipped_bindings : Default :: default ( ) ,
1609
1608
kind : RibKind :: ForwardGenericParamBan ( ForwardGenericParamBanReason :: ConstParamTy ) ,
1610
1609
} ;
1611
1610
let mut forward_const_ban_rib_const_param_ty = Rib {
1612
1611
bindings : forward_const_ban_rib. bindings . clone ( ) ,
1613
- patterns_with_skipped_bindings : FxHashMap :: default ( ) ,
1612
+ patterns_with_skipped_bindings : Default :: default ( ) ,
1614
1613
kind : RibKind :: ForwardGenericParamBan ( ForwardGenericParamBanReason :: ConstParamTy ) ,
1615
1614
} ;
1616
1615
// We'll ban these with a `ConstParamTy` rib, so just clear these ribs for better
@@ -2334,7 +2333,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
2334
2333
let local_candidates = self . lifetime_elision_candidates . take ( ) ;
2335
2334
2336
2335
if let Some ( candidates) = local_candidates {
2337
- let distinct: FxHashSet < _ > = candidates. iter ( ) . map ( |( res, _) | * res) . collect ( ) ;
2336
+ let distinct: UnordSet < _ > = candidates. iter ( ) . map ( |( res, _) | * res) . collect ( ) ;
2338
2337
let lifetime_count = distinct. len ( ) ;
2339
2338
if lifetime_count != 0 {
2340
2339
parameter_info. push ( ElisionFnParameter {
@@ -2358,14 +2357,13 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
2358
2357
}
2359
2358
} ) ) ;
2360
2359
}
2361
- let mut distinct_iter = distinct. into_iter ( ) ;
2362
- if let Some ( res) = distinct_iter. next ( ) {
2360
+ if !distinct. is_empty ( ) {
2363
2361
match elision_lifetime {
2364
2362
// We are the first parameter to bind lifetimes.
2365
2363
Elision :: None => {
2366
- if distinct_iter . next ( ) . is_none ( ) {
2364
+ if let Some ( res ) = distinct . get_only ( ) {
2367
2365
// We have a single lifetime => success.
2368
- elision_lifetime = Elision :: Param ( res)
2366
+ elision_lifetime = Elision :: Param ( * res)
2369
2367
} else {
2370
2368
// We have multiple lifetimes => error.
2371
2369
elision_lifetime = Elision :: Err ;
@@ -2890,6 +2888,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
2890
2888
break ;
2891
2889
}
2892
2890
2891
+ #[ allow( rustc:: potential_query_instability) ] // FIXME
2893
2892
seen_bindings
2894
2893
. extend ( parent_rib. bindings . keys ( ) . map ( |ident| ( * ident, ident. span ) ) ) ;
2895
2894
}
@@ -4004,7 +4003,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
4004
4003
}
4005
4004
}
4006
4005
4007
- fn innermost_rib_bindings ( & mut self , ns : Namespace ) -> & mut IdentMap < Res > {
4006
+ fn innermost_rib_bindings ( & mut self , ns : Namespace ) -> & mut FxHashMap < Ident , Res > {
4008
4007
& mut self . ribs [ ns] . last_mut ( ) . unwrap ( ) . bindings
4009
4008
}
4010
4009
@@ -5202,6 +5201,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
5202
5201
let mut late_resolution_visitor = LateResolutionVisitor :: new ( self ) ;
5203
5202
late_resolution_visitor. resolve_doc_links ( & krate. attrs , MaybeExported :: Ok ( CRATE_NODE_ID ) ) ;
5204
5203
visit:: walk_crate ( & mut late_resolution_visitor, krate) ;
5204
+ #[ allow( rustc:: potential_query_instability) ] // FIXME
5205
5205
for ( id, span) in late_resolution_visitor. diag_metadata . unused_labels . iter ( ) {
5206
5206
self . lint_buffer . buffer_lint (
5207
5207
lint:: builtin:: UNUSED_LABELS ,
0 commit comments