Skip to content

Commit 6f98ee9

Browse files
committed
ensure lint are issued in a stable order
1 parent 0a9dcaf commit 6f98ee9

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/librustc/middle/resolve_lifetime.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -1306,33 +1306,33 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
13061306
}
13071307
};
13081308

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 {
13161311
Region::EarlyBound(_, def_id, _)
13171312
| Region::LateBound(_, def_id, _)
1318-
| Region::Free(_, def_id) => def_id,
1313+
| Region::Free(_, def_id) => Some(*def_id),
13191314

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));
13221321

1322+
for def_id in def_ids {
13231323
debug!(
13241324
"check_uses_for_lifetimes_defined_by_scope: def_id = {:?}",
1325-
def_id
1325+
def_id,
13261326
);
13271327

1328-
let lifetimeuseset = self.lifetime_uses.remove(def_id);
1328+
let lifetimeuseset = self.lifetime_uses.remove(&def_id);
13291329
debug!(
13301330
"check_uses_for_lifetimes_defined_by_scope: lifetimeuseset = {:?}",
13311331
lifetimeuseset
13321332
);
13331333
match lifetimeuseset {
13341334
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();
13361336
debug!("node id first={:?}", node_id);
13371337
if let hir::map::NodeLifetime(hir_lifetime) = self.tcx.hir.get(node_id) {
13381338
let span = hir_lifetime.span;
@@ -1359,7 +1359,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
13591359
debug!("Not one use lifetime");
13601360
}
13611361
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();
13631363
if let hir::map::NodeLifetime(hir_lifetime) = self.tcx.hir.get(node_id) {
13641364
let span = hir_lifetime.span;
13651365
let id = hir_lifetime.id;

0 commit comments

Comments
 (0)