Skip to content

Commit 2d054d0

Browse files
committed
more replace FxHashMap with FxIndexMap
1 parent 5f16827 commit 2d054d0

File tree

4 files changed

+11
-27
lines changed

4 files changed

+11
-27
lines changed

compiler/rustc_interface/src/passes.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,7 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) {
306306

307307
// Gate identifiers containing invalid Unicode codepoints that were recovered during lexing.
308308
sess.parse_sess.bad_unicode_identifiers.with_lock(|identifiers| {
309-
// We will soon sort, so the initial order does not matter.
310-
#[allow(rustc::potential_query_instability)]
311-
let mut identifiers: Vec<_> = identifiers.drain().collect();
312-
identifiers.sort_by_key(|&(key, _)| key);
309+
let identifiers: Vec<_> = identifiers.drain(..).collect();
313310
for (ident, mut spans) in identifiers.into_iter() {
314311
spans.sort();
315312
if ident == sym::ferris {
@@ -435,7 +432,6 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
435432

436433
// The entries will be used to declare dependencies beween files in a
437434
// Makefile-like output, so the iteration order does not matter.
438-
#[allow(rustc::potential_query_instability)]
439435
let extra_tracked_files =
440436
file_depinfo.iter().map(|path_sym| normalize_path(PathBuf::from(path_sym.as_str())));
441437
files.extend(extra_tracked_files);

compiler/rustc_lint/src/context.rs

-2
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ impl LintStore {
431431
// Note: find_best_match_for_name depends on the sort order of its input vector.
432432
// To ensure deterministic output, sort elements of the lint_groups hash map.
433433
// Also, never suggest deprecated lint groups.
434-
// We will soon sort, so the initial order does not matter.
435-
#[allow(rustc::potential_query_instability)]
436434
let mut groups: Vec<_> = self
437435
.lint_groups
438436
.iter()

compiler/rustc_lint/src/non_ascii_idents.rs

-7
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,8 @@ impl EarlyLintPass for NonAsciiIdents {
175175

176176
// Sort by `Span` so that error messages make sense with respect to the
177177
// order of identifier locations in the code.
178-
// We will soon sort, so the initial order does not matter.
179-
#[allow(rustc::potential_query_instability)]
180178
let mut symbols: Vec<_> = symbols.iter().collect();
181179
symbols.sort_by_key(|k| k.1);
182-
183180
for (symbol, &sp) in symbols.iter() {
184181
let symbol_str = symbol.as_str();
185182
if symbol_str.is_ascii() {
@@ -300,8 +297,6 @@ impl EarlyLintPass for NonAsciiIdents {
300297
}
301298

302299
if has_suspicious {
303-
// The end result is put in `lint_reports` which is sorted.
304-
#[allow(rustc::potential_query_instability)]
305300
let verified_augmented_script_sets = script_states
306301
.iter()
307302
.flat_map(|(k, v)| match v {
@@ -314,8 +309,6 @@ impl EarlyLintPass for NonAsciiIdents {
314309
let mut lint_reports: BTreeMap<(Span, Vec<char>), AugmentedScriptSet> =
315310
BTreeMap::new();
316311

317-
// The end result is put in `lint_reports` which is sorted.
318-
#[allow(rustc::potential_query_instability)]
319312
'outerloop: for (augment_script_set, usage) in script_states {
320313
let ScriptSetUsage::Suspicious(mut ch_list, sp) = usage else { continue };
321314

compiler/rustc_session/src/parse.rs

+10-13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::lint::{
1111
};
1212
use crate::Session;
1313
use rustc_ast::node_id::NodeId;
14-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
14+
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
1515
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
1616
use rustc_errors::{emitter::SilentEmitter, DiagCtxt};
1717
use rustc_errors::{
@@ -30,7 +30,7 @@ use std::str;
3030
/// used and should be feature gated accordingly in `check_crate`.
3131
#[derive(Default)]
3232
pub struct GatedSpans {
33-
pub spans: Lock<FxHashMap<Symbol, Vec<Span>>>,
33+
pub spans: Lock<FxIndexMap<Symbol, Vec<Span>>>,
3434
}
3535

3636
impl GatedSpans {
@@ -50,12 +50,9 @@ impl GatedSpans {
5050
}
5151

5252
/// Prepend the given set of `spans` onto the set in `self`.
53-
pub fn merge(&self, mut spans: FxHashMap<Symbol, Vec<Span>>) {
53+
pub fn merge(&self, mut spans: FxIndexMap<Symbol, Vec<Span>>) {
5454
let mut inner = self.spans.borrow_mut();
55-
// The entries will be moved to another map so the drain order does not
56-
// matter.
57-
#[allow(rustc::potential_query_instability)]
58-
for (gate, mut gate_spans) in inner.drain() {
55+
for (gate, mut gate_spans) in inner.drain(..) {
5956
spans.entry(gate).or_default().append(&mut gate_spans);
6057
}
6158
*inner = spans;
@@ -65,7 +62,7 @@ impl GatedSpans {
6562
#[derive(Default)]
6663
pub struct SymbolGallery {
6764
/// All symbols occurred and their first occurrence span.
68-
pub symbols: Lock<FxHashMap<Symbol, Span>>,
65+
pub symbols: Lock<FxIndexMap<Symbol, Span>>,
6966
}
7067

7168
impl SymbolGallery {
@@ -205,19 +202,19 @@ pub struct ParseSess {
205202
/// Places where identifiers that contain invalid Unicode codepoints but that look like they
206203
/// should be. Useful to avoid bad tokenization when encountering emoji. We group them to
207204
/// provide a single error per unique incorrect identifier.
208-
pub bad_unicode_identifiers: Lock<FxHashMap<Symbol, Vec<Span>>>,
205+
pub bad_unicode_identifiers: Lock<FxIndexMap<Symbol, Vec<Span>>>,
209206
source_map: Lrc<SourceMap>,
210207
pub buffered_lints: Lock<Vec<BufferedEarlyLint>>,
211208
/// Contains the spans of block expressions that could have been incomplete based on the
212209
/// operation token that followed it, but that the parser cannot identify without further
213210
/// analysis.
214-
pub ambiguous_block_expr_parse: Lock<FxHashMap<Span, Span>>,
211+
pub ambiguous_block_expr_parse: Lock<FxIndexMap<Span, Span>>,
215212
pub gated_spans: GatedSpans,
216213
pub symbol_gallery: SymbolGallery,
217214
/// Environment variables accessed during the build and their values when they exist.
218-
pub env_depinfo: Lock<FxHashSet<(Symbol, Option<Symbol>)>>,
215+
pub env_depinfo: Lock<FxIndexSet<(Symbol, Option<Symbol>)>>,
219216
/// File paths accessed during the build.
220-
pub file_depinfo: Lock<FxHashSet<Symbol>>,
217+
pub file_depinfo: Lock<FxIndexSet<Symbol>>,
221218
/// Whether cfg(version) should treat the current release as incomplete
222219
pub assume_incomplete_release: bool,
223220
/// Spans passed to `proc_macro::quote_span`. Each span has a numerical
@@ -247,7 +244,7 @@ impl ParseSess {
247244
bad_unicode_identifiers: Lock::new(Default::default()),
248245
source_map,
249246
buffered_lints: Lock::new(vec![]),
250-
ambiguous_block_expr_parse: Lock::new(FxHashMap::default()),
247+
ambiguous_block_expr_parse: Lock::new(Default::default()),
251248
gated_spans: GatedSpans::default(),
252249
symbol_gallery: SymbolGallery::default(),
253250
env_depinfo: Default::default(),

0 commit comments

Comments
 (0)