Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 87c2a9f

Browse files
authoredMar 22, 2025
Rollup merge of rust-lang#138580 - petrochenkov:resinstab, r=Nadrieril
resolve: Avoid some unstable iteration 2 Continuation of rust-lang#138502.
2 parents 834b6e7 + 0bf529e commit 87c2a9f

File tree

8 files changed

+9
-14
lines changed

8 files changed

+9
-14
lines changed
 

‎compiler/rustc_resolve/src/build_reduced_graph.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,6 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
11151115
}
11161116
});
11171117
} else {
1118-
#[allow(rustc::potential_query_instability)] // FIXME
11191118
for ident in single_imports.iter().cloned() {
11201119
let result = self.r.maybe_resolve_ident_in_module(
11211120
ModuleOrUniformRoot::Module(module),

‎compiler/rustc_resolve/src/diagnostics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14681468
return;
14691469
}
14701470

1471-
#[allow(rustc::potential_query_instability)] // FIXME
14721471
let unused_macro = self.unused_macros.iter().find_map(|(def_id, (_, unused_ident))| {
14731472
if unused_ident.name == ident.name { Some((def_id, unused_ident)) } else { None }
14741473
});

‎compiler/rustc_resolve/src/ident.rs

-1
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
946946

947947
// Check if one of single imports can still define the name,
948948
// if it can then our result is not determined and can be invalidated.
949-
#[allow(rustc::potential_query_instability)] // FIXME
950949
for single_import in &resolution.single_imports {
951950
if ignore_import == Some(*single_import) {
952951
// This branch handles a cycle in single imports.

‎compiler/rustc_resolve/src/imports.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::cell::Cell;
44
use std::mem;
55

66
use rustc_ast::NodeId;
7-
use rustc_data_structures::fx::FxHashSet;
7+
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
88
use rustc_data_structures::intern::Interned;
99
use rustc_errors::codes::*;
1010
use rustc_errors::{Applicability, MultiSpan, pluralize, struct_span_code_err};
@@ -233,7 +233,7 @@ impl<'ra> ImportData<'ra> {
233233
pub(crate) struct NameResolution<'ra> {
234234
/// Single imports that may define the name in the namespace.
235235
/// Imports are arena-allocated, so it's ok to use pointers as keys.
236-
pub single_imports: FxHashSet<Import<'ra>>,
236+
pub single_imports: FxIndexSet<Import<'ra>>,
237237
/// The least shadowable known binding for this name, or None if there are no known bindings.
238238
pub binding: Option<NameBinding<'ra>>,
239239
pub shadowed_glob: Option<NameBinding<'ra>>,
@@ -494,7 +494,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
494494
let key = BindingKey::new(target, ns);
495495
let _ = this.try_define(import.parent_scope.module, key, dummy_binding, false);
496496
this.update_resolution(import.parent_scope.module, key, false, |_, resolution| {
497-
resolution.single_imports.remove(&import);
497+
resolution.single_imports.swap_remove(&import);
498498
})
499499
});
500500
self.record_use(target, dummy_binding, Used::Other);
@@ -862,7 +862,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
862862
}
863863
let key = BindingKey::new(target, ns);
864864
this.update_resolution(parent, key, false, |_, resolution| {
865-
resolution.single_imports.remove(&import);
865+
resolution.single_imports.swap_remove(&import);
866866
});
867867
}
868868
}

‎compiler/rustc_resolve/src/late.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ struct DiagMetadata<'ast> {
672672

673673
/// A list of labels as of yet unused. Labels will be removed from this map when
674674
/// they are used (in a `break` or `continue` statement)
675-
unused_labels: FxHashMap<NodeId, Span>,
675+
unused_labels: FxIndexMap<NodeId, Span>,
676676

677677
/// Only used for better errors on `let x = { foo: bar };`.
678678
/// In the case of a parse error with `let x = { foo: bar, };`, this isn't needed, it's only
@@ -4779,7 +4779,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
47794779
Ok((node_id, _)) => {
47804780
// Since this res is a label, it is never read.
47814781
self.r.label_res_map.insert(expr.id, node_id);
4782-
self.diag_metadata.unused_labels.remove(&node_id);
4782+
self.diag_metadata.unused_labels.swap_remove(&node_id);
47834783
}
47844784
Err(error) => {
47854785
self.report_error(label.ident.span, error);
@@ -5201,7 +5201,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
52015201
let mut late_resolution_visitor = LateResolutionVisitor::new(self);
52025202
late_resolution_visitor.resolve_doc_links(&krate.attrs, MaybeExported::Ok(CRATE_NODE_ID));
52035203
visit::walk_crate(&mut late_resolution_visitor, krate);
5204-
#[allow(rustc::potential_query_instability)] // FIXME
52055204
for (id, span) in late_resolution_visitor.diag_metadata.unused_labels.iter() {
52065205
self.lint_buffer.buffer_lint(
52075206
lint::builtin::UNUSED_LABELS,

‎compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
10361036
Applicability::MaybeIncorrect,
10371037
);
10381038
// Do not lint against unused label when we suggest them.
1039-
self.diag_metadata.unused_labels.remove(node_id);
1039+
self.diag_metadata.unused_labels.swap_remove(node_id);
10401040
}
10411041
}
10421042
}

‎compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ pub struct Resolver<'ra, 'tcx> {
11371137
non_macro_attr: MacroData,
11381138
local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>,
11391139
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
1140-
unused_macros: FxHashMap<LocalDefId, (NodeId, Ident)>,
1140+
unused_macros: FxIndexMap<LocalDefId, (NodeId, Ident)>,
11411141
/// A map from the macro to all its potentially unused arms.
11421142
unused_macro_rules: FxIndexMap<LocalDefId, UnordMap<usize, (Ident, Span)>>,
11431143
proc_macro_stubs: FxHashSet<LocalDefId>,

‎compiler/rustc_resolve/src/macros.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
323323
}
324324

325325
fn check_unused_macros(&mut self) {
326-
#[allow(rustc::potential_query_instability)] // FIXME
327326
for (_, &(node_id, ident)) in self.unused_macros.iter() {
328327
self.lint_buffer.buffer_lint(
329328
UNUSED_MACROS,
@@ -576,7 +575,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
576575
match res {
577576
Res::Def(DefKind::Macro(_), def_id) => {
578577
if let Some(def_id) = def_id.as_local() {
579-
self.unused_macros.remove(&def_id);
578+
self.unused_macros.swap_remove(&def_id);
580579
if self.proc_macro_stubs.contains(&def_id) {
581580
self.dcx().emit_err(errors::ProcMacroSameCrate {
582581
span: path.span,

0 commit comments

Comments
 (0)
Failed to load comments.