@@ -1306,33 +1306,33 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1306
1306
}
1307
1307
} ;
1308
1308
1309
- for region in defined_by. values ( ) {
1310
- debug ! (
1311
- "check_uses_for_lifetimes_defined_by_scope: region = {:?}" ,
1312
- region
1313
- ) ;
1314
-
1315
- let def_id = match region {
1309
+ let mut def_ids: Vec < _ > = defined_by. values ( )
1310
+ . flat_map ( |region| match region {
1316
1311
Region :: EarlyBound ( _, def_id, _)
1317
1312
| Region :: LateBound ( _, def_id, _)
1318
- | Region :: Free ( _, def_id) => def_id,
1313
+ | Region :: Free ( _, def_id) => Some ( * def_id) ,
1319
1314
1320
- Region :: LateBoundAnon ( ..) | Region :: Static => continue ,
1321
- } ;
1315
+ Region :: LateBoundAnon ( ..) | Region :: Static => None ,
1316
+ } )
1317
+ . collect ( ) ;
1318
+
1319
+ // ensure that we issue lints in a repeatable order
1320
+ def_ids. sort_by_key ( |& def_id| self . tcx . def_path_hash ( def_id) ) ;
1322
1321
1322
+ for def_id in def_ids {
1323
1323
debug ! (
1324
1324
"check_uses_for_lifetimes_defined_by_scope: def_id = {:?}" ,
1325
- def_id
1325
+ def_id,
1326
1326
) ;
1327
1327
1328
- let lifetimeuseset = self . lifetime_uses . remove ( def_id) ;
1328
+ let lifetimeuseset = self . lifetime_uses . remove ( & def_id) ;
1329
1329
debug ! (
1330
1330
"check_uses_for_lifetimes_defined_by_scope: lifetimeuseset = {:?}" ,
1331
1331
lifetimeuseset
1332
1332
) ;
1333
1333
match lifetimeuseset {
1334
1334
Some ( LifetimeUseSet :: One ( _) ) => {
1335
- let node_id = self . tcx . hir . as_local_node_id ( * def_id) . unwrap ( ) ;
1335
+ let node_id = self . tcx . hir . as_local_node_id ( def_id) . unwrap ( ) ;
1336
1336
debug ! ( "node id first={:?}" , node_id) ;
1337
1337
if let hir:: map:: NodeLifetime ( hir_lifetime) = self . tcx . hir . get ( node_id) {
1338
1338
let span = hir_lifetime. span ;
@@ -1359,7 +1359,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1359
1359
debug ! ( "Not one use lifetime" ) ;
1360
1360
}
1361
1361
None => {
1362
- let node_id = self . tcx . hir . as_local_node_id ( * def_id) . unwrap ( ) ;
1362
+ let node_id = self . tcx . hir . as_local_node_id ( def_id) . unwrap ( ) ;
1363
1363
if let hir:: map:: NodeLifetime ( hir_lifetime) = self . tcx . hir . get ( node_id) {
1364
1364
let span = hir_lifetime. span ;
1365
1365
let id = hir_lifetime. id ;
0 commit comments