Skip to content

Commit ced5d6d

Browse files
committed
remove uncessary collect
1 parent 44792be commit ced5d6d

File tree

9 files changed

+28
-11
lines changed

9 files changed

+28
-11
lines changed

compiler/rustc_borrowck/src/region_infer/values.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_data_structures::fx::FxIndexSet;
1+
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
22
use rustc_index::bit_set::SparseBitMatrix;
33
use rustc_index::interval::IntervalSet;
44
use rustc_index::interval::SparseIntervalMatrix;
@@ -41,7 +41,7 @@ pub(crate) struct LivenessValues {
4141

4242
/// Which regions are live. This is exclusive with the fine-grained tracking in `points`, and
4343
/// currently only used for validating promoteds (which don't care about more precise tracking).
44-
live_regions: Option<FxIndexSet<RegionVid>>,
44+
live_regions: Option<FxHashSet<RegionVid>>,
4545

4646
/// For each region: the points where it is live.
4747
///
@@ -103,6 +103,10 @@ impl LivenessValues {
103103
self.points.as_ref().expect("use with_specific_points").rows()
104104
}
105105

106+
/// Iterate through each region that has a value in this set.
107+
// We are passing query instability implications to the caller.
108+
#[rustc_lint_query_instability]
109+
#[allow(rustc::potential_query_instability)]
106110
pub(crate) fn live_regions_unordered(&self) -> impl Iterator<Item = RegionVid> + '_ {
107111
self.live_regions.as_ref().unwrap().iter().copied()
108112
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
599599
//
600600
// add_location doesn't care about ordering so not a problem for the live regions to be
601601
// unordered.
602+
#[allow(rustc::potential_query_instability)]
602603
for region in liveness_constraints.live_regions_unordered() {
603604
self.cx
604605
.borrowck_context

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,7 @@ fn link_staticlib<'a>(
563563
.extract_bundled_libs(path, tempdir.as_ref(), &relevant_libs)
564564
.unwrap_or_else(|e| sess.dcx().emit_fatal(e));
565565

566-
let relevant_libs: Vec<Symbol> = relevant_libs.into_iter().collect();
567-
for filename in relevant_libs {
566+
for filename in relevant_libs.iter() {
568567
let joined = tempdir.as_ref().join(filename.as_str());
569568
let path = joined.as_path();
570569
ab.add_archive(path, Box::new(|_| false)).unwrap();
@@ -2215,6 +2214,7 @@ fn linker_with_args<'a>(
22152214
.expect("failed to find crate type in dependency format list");
22162215

22172216
// We sort the libraries below
2217+
#[allow(rustc::potential_query_instability)]
22182218
let mut native_libraries_from_nonstatics = codegen_results
22192219
.crate_info
22202220
.native_libraries

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ fn exported_symbols_provider_local(
320320
let (_, cgus) = tcx.collect_and_partition_mono_items(());
321321

322322
// The symbols created in this loop are sorted below it
323+
#[allow(rustc::potential_query_instability)]
323324
for (mono_item, data) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
324325
if data.linkage != Linkage::External {
325326
// We can only re-use things with external linkage, otherwise

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ impl CrateInfo {
912912
.collect();
913913
let prefix = if target.is_like_windows && target.arch == "x86" { "_" } else { "" };
914914

915+
#[allow(rustc::potential_query_instability)]
915916
info.linked_symbols
916917
.iter_mut()
917918
.filter(|(crate_type, _)| {

compiler/rustc_const_eval/src/interpret/memory.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
514514
// Unlike all the other GC helpers where we check if an `AllocId` is found in the interpreter or
515515
// is live, here all the IDs in the map are for dead allocations so we don't
516516
// need to check for liveness.
517+
#[allow(rustc::potential_query_instability)] // Only used from Miri, not queries.
517518
self.memory.dead_alloc_map.retain(|id, _| reachable_allocs.contains(id));
518519
}
519520
}

compiler/rustc_interface/src/passes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +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-
let identifiers: Vec<_> = identifiers.drain(..).collect();
310-
for (ident, mut spans) in identifiers.into_iter() {
309+
for (ident, mut spans) in identifiers.drain(..) {
311310
spans.sort();
312311
if ident == sym::ferris {
313312
let first_span = spans[0];
@@ -437,6 +436,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
437436
files.extend(extra_tracked_files);
438437

439438
// We also need to track used PGO profile files
439+
#[allow(rustc::potential_query_instability)]
440440
if let Some(ref profile_instr) = sess.opts.cg.profile_use {
441441
files.push(normalize_path(profile_instr.as_path().to_path_buf()));
442442
}

compiler/rustc_lint/src/non_ascii_idents.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +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)]
178180
let mut symbols: Vec<_> = symbols.iter().collect();
179181
symbols.sort_by_key(|k| k.1);
180182
for (symbol, &sp) in symbols.iter() {
@@ -297,6 +299,8 @@ impl EarlyLintPass for NonAsciiIdents {
297299
}
298300

299301
if has_suspicious {
302+
// The end result is put in `lint_reports` which is sorted.
303+
#[allow(rustc::potential_query_instability)]
300304
let verified_augmented_script_sets = script_states
301305
.iter()
302306
.flat_map(|(k, v)| match v {
@@ -309,6 +313,8 @@ impl EarlyLintPass for NonAsciiIdents {
309313
let mut lint_reports: BTreeMap<(Span, Vec<char>), AugmentedScriptSet> =
310314
BTreeMap::new();
311315

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

compiler/rustc_session/src/parse.rs

Lines changed: 8 additions & 5 deletions
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::{FxIndexMap, FxIndexSet};
14+
use rustc_data_structures::fx::{FxHashMap, 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<FxIndexMap<Symbol, Vec<Span>>>,
33+
pub spans: Lock<FxHashMap<Symbol, Vec<Span>>>,
3434
}
3535

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

5252
/// Prepend the given set of `spans` onto the set in `self`.
53-
pub fn merge(&self, mut spans: FxIndexMap<Symbol, Vec<Span>>) {
53+
pub fn merge(&self, mut spans: FxHashMap<Symbol, Vec<Span>>) {
5454
let mut inner = self.spans.borrow_mut();
55-
for (gate, mut gate_spans) in inner.drain(..) {
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() {
5659
spans.entry(gate).or_default().append(&mut gate_spans);
5760
}
5861
*inner = spans;
@@ -62,7 +65,7 @@ impl GatedSpans {
6265
#[derive(Default)]
6366
pub struct SymbolGallery {
6467
/// All symbols occurred and their first occurrence span.
65-
pub symbols: Lock<FxIndexMap<Symbol, Span>>,
68+
pub symbols: Lock<FxHashMap<Symbol, Span>>,
6669
}
6770

6871
impl SymbolGallery {

0 commit comments

Comments
 (0)