Skip to content

Commit be9cfb3

Browse files
committed
Auto merge of #99058 - michaelwoerister:remove-stable-set-and-map, r=nagisa
Remove the unused StableSet and StableMap types from rustc_data_structures. The current implementation is not "stable" in the same sense that `HashStable` and `StableHasher` are stable, i.e. across compilation sessions. So, in my opinion, it's better to remove those types (which are basically unused anyway) than to give the wrong impression that these are safe for incr. comp. I plan to provide new "stable" collection types soon that can be used to replace `FxHashMap` and `FxHashSet` in query results (see [draft](michaelwoerister@69d03ac)). It's unsound that `HashMap` and `HashSet` implement `HashStable` (see #98890 for a recent P-critical bug caused by this) -- so we should make some progress there.
2 parents d68e7eb + 88f6c6d commit be9cfb3

File tree

42 files changed

+48
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+48
-228
lines changed

compiler/rustc_ast_lowering/src/asm.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use super::LoweringContext;
44

55
use rustc_ast::ptr::P;
66
use rustc_ast::*;
7-
use rustc_data_structures::fx::FxHashMap;
8-
use rustc_data_structures::stable_set::FxHashSet;
7+
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
98
use rustc_errors::struct_span_err;
109
use rustc_hir as hir;
1110
use rustc_hir::def::{DefKind, Res};

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Error reporting machinery for lifetime errors.
22
3-
use rustc_data_structures::stable_set::FxHashSet;
3+
use rustc_data_structures::fx::FxHashSet;
44
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
55
use rustc_hir::def_id::DefId;
66
use rustc_hir::intravisit::Visitor;

compiler/rustc_codegen_gcc/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use gccjit::{ToLValue, ToRValue, Type};
22
use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeMethods};
3-
use rustc_data_structures::stable_set::FxHashSet;
3+
use rustc_data_structures::fx::FxHashSet;
44
use rustc_middle::bug;
55
use rustc_middle::ty::Ty;
66
use rustc_target::abi::call::{CastTarget, FnAbi, PassMode, Reg, RegKind};

compiler/rustc_codegen_gcc/src/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_codegen_ssa::traits::{
3030
OverflowOp,
3131
StaticBuilderMethods,
3232
};
33-
use rustc_data_structures::stable_set::FxHashSet;
33+
use rustc_data_structures::fx::FxHashSet;
3434
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
3535
use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, LayoutOfHelpers, TyAndLayout};
3636
use rustc_span::Span;

compiler/rustc_data_structures/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,10 @@ pub mod sip128;
6161
pub mod small_c_str;
6262
pub mod small_str;
6363
pub mod snapshot_map;
64-
pub mod stable_map;
6564
pub mod svh;
6665
pub use ena::snapshot_vec;
6766
pub mod memmap;
6867
pub mod sorted_map;
69-
pub mod stable_set;
7068
#[macro_use]
7169
pub mod stable_hasher;
7270
mod atomic_ref;

compiler/rustc_data_structures/src/stable_map.rs

-100
This file was deleted.

compiler/rustc_data_structures/src/stable_set.rs

-77
This file was deleted.

compiler/rustc_errors/src/diagnostic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
CodeSuggestion, DiagnosticMessage, EmissionGuarantee, Level, LintDiagnosticBuilder, MultiSpan,
44
SubdiagnosticMessage, Substitution, SubstitutionPart, SuggestionStyle,
55
};
6-
use rustc_data_structures::stable_map::FxHashMap;
6+
use rustc_data_structures::fx::FxHashMap;
77
use rustc_error_messages::FluentValue;
88
use rustc_hir as hir;
99
use rustc_lint_defs::{Applicability, LintExpectationId};

compiler/rustc_hir/src/lang_items.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::def_id::DefId;
1111
use crate::{MethodKind, Target};
1212

1313
use rustc_ast as ast;
14-
use rustc_data_structures::fx::FxHashMap;
14+
use rustc_data_structures::fx::FxIndexMap;
1515
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1616
use rustc_macros::HashStable_Generic;
1717
use rustc_span::symbol::{kw, sym, Symbol};
@@ -134,8 +134,8 @@ macro_rules! language_item_table {
134134
}
135135

136136
/// A mapping from the name of the lang item to its order and the form it must be of.
137-
pub static ITEM_REFS: LazyLock<FxHashMap<Symbol, (usize, Target)>> = LazyLock::new(|| {
138-
let mut item_refs = FxHashMap::default();
137+
pub static ITEM_REFS: LazyLock<FxIndexMap<Symbol, (usize, Target)>> = LazyLock::new(|| {
138+
let mut item_refs = FxIndexMap::default();
139139
$( item_refs.insert($module::$name, (LangItem::$variant as usize, $target)); )*
140140
item_refs
141141
});

compiler/rustc_hir/src/pat_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::def::{CtorOf, DefKind, Res};
22
use crate::def_id::DefId;
33
use crate::hir::{self, HirId, PatKind};
4-
use rustc_data_structures::stable_set::FxHashSet;
4+
use rustc_data_structures::fx::FxHashSet;
55
use rustc_span::hygiene::DesugaringKind;
66
use rustc_span::symbol::Ident;
77
use rustc_span::Span;

compiler/rustc_hir/src/weak_lang_items.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ use crate::def_id::DefId;
44
use crate::{lang_items, LangItem, LanguageItems};
55

66
use rustc_ast as ast;
7-
use rustc_data_structures::stable_map::StableMap;
7+
use rustc_data_structures::fx::FxIndexMap;
88
use rustc_span::symbol::{sym, Symbol};
99

1010
use std::sync::LazyLock;
1111

1212
macro_rules! weak_lang_items {
1313
($($name:ident, $item:ident, $sym:ident;)*) => (
1414

15-
pub static WEAK_ITEMS_REFS: LazyLock<StableMap<Symbol, LangItem>> = LazyLock::new(|| {
16-
let mut map = StableMap::default();
15+
pub static WEAK_ITEMS_REFS: LazyLock<FxIndexMap<Symbol, LangItem>> = LazyLock::new(|| {
16+
let mut map = FxIndexMap::default();
1717
$(map.insert(sym::$name, LangItem::$item);)*
1818
map
1919
});

compiler/rustc_incremental/src/assert_module_sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
//! was re-used.
2424
2525
use rustc_ast as ast;
26-
use rustc_data_structures::stable_set::FxHashSet;
26+
use rustc_data_structures::fx::FxHashSet;
2727
use rustc_hir::def_id::LOCAL_CRATE;
2828
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
2929
use rustc_middle::ty::TyCtxt;

compiler/rustc_incremental/src/persist/work_product.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! [work products]: WorkProduct
44
55
use crate::persist::fs::*;
6-
use rustc_data_structures::stable_map::FxHashMap;
6+
use rustc_data_structures::fx::FxHashMap;
77
use rustc_fs_util::link_or_copy;
88
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
99
use rustc_session::Session;

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::infer::error_reporting::note_and_explain_region;
66
use crate::infer::lexical_region_resolve::RegionResolutionError;
77
use crate::infer::{SubregionOrigin, TypeTrace};
88
use crate::traits::ObligationCauseCode;
9-
use rustc_data_structures::stable_set::FxHashSet;
9+
use rustc_data_structures::fx::FxHashSet;
1010
use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan};
1111
use rustc_hir as hir;
1212
use rustc_hir::intravisit::Visitor;

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
44
use crate::infer::lexical_region_resolve::RegionResolutionError;
55
use crate::infer::{SubregionOrigin, TypeTrace};
66
use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
7-
use rustc_data_structures::stable_set::FxHashSet;
7+
use rustc_data_structures::fx::FxHashSet;
88
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan};
99
use rustc_hir::def_id::DefId;
1010
use rustc_hir::intravisit::{walk_ty, Visitor};

compiler/rustc_infer/src/infer/error_reporting/note.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
357357
let trait_predicates = self.tcx.explicit_predicates_of(trait_item_def_id);
358358
let impl_predicates = self.tcx.explicit_predicates_of(impl_item_def_id);
359359

360-
let impl_predicates: rustc_data_structures::stable_set::FxHashSet<_> =
360+
let impl_predicates: rustc_data_structures::fx::FxHashSet<_> =
361361
impl_predicates.predicates.into_iter().map(|(pred, _)| pred).collect();
362362
let clauses: Vec<_> = trait_predicates
363363
.predicates

compiler/rustc_middle/src/mir/query.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::mir::{Body, ConstantKind, Promoted};
44
use crate::ty::{self, OpaqueHiddenType, Ty, TyCtxt};
5-
use rustc_data_structures::stable_map::FxHashMap;
5+
use rustc_data_structures::fx::FxHashMap;
66
use rustc_data_structures::vec_map::VecMap;
77
use rustc_errors::ErrorGuaranteed;
88
use rustc_hir as hir;

compiler/rustc_middle/src/mir/switch_sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Lazily compute the inverse of each `SwitchInt`'s switch targets. Modeled after
22
//! `Predecessors`/`PredecessorCache`.
33
4+
use rustc_data_structures::fx::FxHashMap;
45
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5-
use rustc_data_structures::stable_map::FxHashMap;
66
use rustc_data_structures::sync::OnceCell;
77
use rustc_index::vec::IndexVec;
88
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};

compiler/rustc_middle/src/traits/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_data_structures::stable_set::FxHashSet;
1+
use rustc_data_structures::fx::FxHashSet;
22

33
use crate::ty::{PolyTraitRef, TyCtxt};
44

compiler/rustc_mir_dataflow/src/un_derefer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_data_structures::stable_map::FxHashMap;
1+
use rustc_data_structures::fx::FxHashMap;
22
use rustc_middle::mir::*;
33
use rustc_middle::ty::TyCtxt;
44

compiler/rustc_mir_transform/src/uninhabited_enum_branching.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! A pass that eliminates branches on uninhabited enum variants.
22
33
use crate::MirPass;
4-
use rustc_data_structures::stable_set::FxHashSet;
4+
use rustc_data_structures::fx::FxHashSet;
55
use rustc_middle::mir::{
66
BasicBlockData, Body, Local, Operand, Rvalue, StatementKind, SwitchTargets, Terminator,
77
TerminatorKind,

compiler/rustc_passes/src/weak_lang_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
6868
}
6969
}
7070

71-
for (name, item) in WEAK_ITEMS_REFS.clone().into_sorted_vector().into_iter() {
71+
for (name, &item) in WEAK_ITEMS_REFS.iter() {
7272
if missing.contains(&item) && required(tcx, item) && items.require(item).is_err() {
7373
if item == LangItem::PanicImpl {
7474
tcx.sess.err("`#[panic_handler]` function required, but not found");

compiler/rustc_target/src/asm/aarch64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{InlineAsmArch, InlineAsmType};
22
use crate::spec::{RelocModel, Target};
3-
use rustc_data_structures::stable_set::FxHashSet;
3+
use rustc_data_structures::fx::FxHashSet;
44
use rustc_macros::HashStable_Generic;
55
use rustc_span::Symbol;
66
use std::fmt;

compiler/rustc_target/src/asm/arm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{InlineAsmArch, InlineAsmType};
22
use crate::spec::{RelocModel, Target};
3-
use rustc_data_structures::stable_set::FxHashSet;
3+
use rustc_data_structures::fx::FxHashSet;
44
use rustc_macros::HashStable_Generic;
55
use rustc_span::{sym, Symbol};
66
use std::fmt;

0 commit comments

Comments
 (0)