@@ -18,6 +18,7 @@ use rustc_ast::visit::{
1818} ;
1919use rustc_ast:: * ;
2020use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexMap } ;
21+ use rustc_data_structures:: unord:: { UnordMap , UnordSet } ;
2122use rustc_errors:: codes:: * ;
2223use rustc_errors:: {
2324 Applicability , DiagArgValue , ErrorGuaranteed , IntoDiagArg , StashKey , Suggestions ,
@@ -47,8 +48,6 @@ mod diagnostics;
4748
4849type Res = def:: Res < NodeId > ;
4950
50- type IdentMap < T > = FxHashMap < Ident , T > ;
51-
5251use diagnostics:: { ElisionFnParameter , LifetimeElisionCandidate , MissingLifetime } ;
5352
5453#[ derive( Copy , Clone , Debug ) ]
@@ -273,8 +272,8 @@ impl RibKind<'_> {
273272/// resolving, the name is looked up from inside out.
274273#[ derive( Debug ) ]
275274pub ( 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 > ) > > ,
278277 pub kind : RibKind < ' ra > ,
279278}
280279
@@ -1605,12 +1604,12 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
16051604 // for better diagnostics.
16061605 let mut forward_ty_ban_rib_const_param_ty = Rib {
16071606 bindings : forward_ty_ban_rib. bindings . clone ( ) ,
1608- patterns_with_skipped_bindings : FxHashMap :: default ( ) ,
1607+ patterns_with_skipped_bindings : Default :: default ( ) ,
16091608 kind : RibKind :: ForwardGenericParamBan ( ForwardGenericParamBanReason :: ConstParamTy ) ,
16101609 } ;
16111610 let mut forward_const_ban_rib_const_param_ty = Rib {
16121611 bindings : forward_const_ban_rib. bindings . clone ( ) ,
1613- patterns_with_skipped_bindings : FxHashMap :: default ( ) ,
1612+ patterns_with_skipped_bindings : Default :: default ( ) ,
16141613 kind : RibKind :: ForwardGenericParamBan ( ForwardGenericParamBanReason :: ConstParamTy ) ,
16151614 } ;
16161615 // 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> {
23342333 let local_candidates = self . lifetime_elision_candidates . take ( ) ;
23352334
23362335 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 ( ) ;
23382337 let lifetime_count = distinct. len ( ) ;
23392338 if lifetime_count != 0 {
23402339 parameter_info. push ( ElisionFnParameter {
@@ -2358,14 +2357,13 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
23582357 }
23592358 } ) ) ;
23602359 }
2361- let mut distinct_iter = distinct. into_iter ( ) ;
2362- if let Some ( res) = distinct_iter. next ( ) {
2360+ if !distinct. is_empty ( ) {
23632361 match elision_lifetime {
23642362 // We are the first parameter to bind lifetimes.
23652363 Elision :: None => {
2366- if distinct_iter . next ( ) . is_none ( ) {
2364+ if let Some ( res ) = distinct . get_only ( ) {
23672365 // We have a single lifetime => success.
2368- elision_lifetime = Elision :: Param ( res)
2366+ elision_lifetime = Elision :: Param ( * res)
23692367 } else {
23702368 // We have multiple lifetimes => error.
23712369 elision_lifetime = Elision :: Err ;
@@ -2890,6 +2888,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
28902888 break ;
28912889 }
28922890
2891+ #[ allow( rustc:: potential_query_instability) ] // FIXME
28932892 seen_bindings
28942893 . extend ( parent_rib. bindings . keys ( ) . map ( |ident| ( * ident, ident. span ) ) ) ;
28952894 }
@@ -4004,7 +4003,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
40044003 }
40054004 }
40064005
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 > {
40084007 & mut self . ribs [ ns] . last_mut ( ) . unwrap ( ) . bindings
40094008 }
40104009
@@ -5202,6 +5201,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
52025201 let mut late_resolution_visitor = LateResolutionVisitor :: new ( self ) ;
52035202 late_resolution_visitor. resolve_doc_links ( & krate. attrs , MaybeExported :: Ok ( CRATE_NODE_ID ) ) ;
52045203 visit:: walk_crate ( & mut late_resolution_visitor, krate) ;
5204+ #[ allow( rustc:: potential_query_instability) ] // FIXME
52055205 for ( id, span) in late_resolution_visitor. diag_metadata . unused_labels . iter ( ) {
52065206 self . lint_buffer . buffer_lint (
52075207 lint:: builtin:: UNUSED_LABELS ,
0 commit comments