Skip to content

Commit d66e861

Browse files
committed
some more fixes
1 parent ad4beca commit d66e861

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

compiler/rustc_data_structures/src/stable_set.rs

+12
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ where
4141

4242
impl<T> Eq for StableSet<T> where T: Eq + Hash {}
4343

44+
impl<T: Eq + Hash> Extend<T> for StableSet<T> {
45+
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
46+
self.base.extend(iter);
47+
}
48+
}
49+
50+
impl<T: Eq + Hash> std::iter::FromIterator<T> for StableSet<T> {
51+
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
52+
Self { base: FxHashSet::from_iter(iter) }
53+
}
54+
}
55+
4456
impl<T: Eq + Hash> StableSet<T> {
4557
pub fn new() -> StableSet<T> {
4658
StableSet { base: FxHashSet::default() }

compiler/rustc_hir/src/hir_id.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::def_id::{LocalDefId, CRATE_DEF_INDEX};
2+
use rustc_data_structures::fx::FxHashMap;
23
use rustc_index::vec::IndexVec;
34
use std::fmt;
45

@@ -42,7 +43,8 @@ impl fmt::Display for HirId {
4243
}
4344

4445
rustc_data_structures::define_id_collections!(HirIdMap, HirIdSet, HirId);
45-
rustc_data_structures::define_id_collections!(ItemLocalMap, ItemLocalSet, ItemLocalId);
46+
pub type ItemLocalMap<T> = FxHashMap<ItemLocalId, T>;
47+
pub type ItemLocalSet = rustc_data_structures::stable_set::StableSet<ItemLocalId>;
4648

4749
rustc_index::newtype_index! {
4850
/// An `ItemLocalId` uniquely identifies something within a given "item-like";

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ rustc_queries! {
12761276
desc { "looking up a named region" }
12771277
}
12781278
query is_late_bound_map(_: LocalDefId) ->
1279-
Option<(LocalDefId, &'tcx FxHashSet<ItemLocalId>)> {
1279+
Option<(LocalDefId, &'tcx StableSet<ItemLocalId>)> {
12801280
desc { "testing if a region is late bound" }
12811281
}
12821282
/// For a given item (like a struct), gets the default lifetimes to be used

compiler/rustc_middle/src/ty/query/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use crate::ty::util::AlwaysRequiresDrop;
3333
use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
3434
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
3535
use rustc_data_structures::stable_hasher::StableVec;
36+
use rustc_data_structures::stable_set::StableSet;
3637
use rustc_data_structures::steal::Steal;
3738
use rustc_data_structures::svh::Svh;
3839
use rustc_data_structures::sync::Lrc;

compiler/rustc_resolve/src/late/lifetimes.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use crate::late::diagnostics::{ForLifetimeSpanType, MissingLifetimeSpot};
1010
use rustc_ast::walk_list;
1111
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
12+
use rustc_data_structures::stable_set::StableSet;
1213
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
1314
use rustc_hir as hir;
1415
use rustc_hir::def::{DefKind, Res};
@@ -575,7 +576,7 @@ fn item_for(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> LocalDefId {
575576
fn is_late_bound_map<'tcx>(
576577
tcx: TyCtxt<'tcx>,
577578
def_id: LocalDefId,
578-
) -> Option<(LocalDefId, &'tcx FxHashSet<ItemLocalId>)> {
579+
) -> Option<(LocalDefId, &'tcx StableSet<ItemLocalId>)> {
579580
match tcx.def_kind(def_id) {
580581
DefKind::AnonConst => {
581582
let mut def_id = tcx
@@ -740,9 +741,9 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
740741
});
741742
}
742743
for (&owner, late_bound) in resolved_lifetimes.late_bound.iter() {
743-
late_bound.iter().for_each(|&local_id| {
744+
for &local_id in late_bound.to_sorted_vec() {
744745
self.map.late_bound.insert(hir::HirId { owner, local_id });
745-
});
746+
}
746747
}
747748
for (&owner, late_bound_vars) in
748749
resolved_lifetimes.late_bound_vars.iter()

0 commit comments

Comments
 (0)