resolve: Avoid some unstable iteration 2
This commit is contained in:
parent
4510e86a41
commit
ba4190cf7e
8 changed files with 9 additions and 14 deletions
|
@ -1115,7 +1115,6 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
#[allow(rustc::potential_query_instability)] // FIXME
|
|
||||||
for ident in single_imports.iter().cloned() {
|
for ident in single_imports.iter().cloned() {
|
||||||
let result = self.r.maybe_resolve_ident_in_module(
|
let result = self.r.maybe_resolve_ident_in_module(
|
||||||
ModuleOrUniformRoot::Module(module),
|
ModuleOrUniformRoot::Module(module),
|
||||||
|
|
|
@ -1468,7 +1468,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(rustc::potential_query_instability)] // FIXME
|
|
||||||
let unused_macro = self.unused_macros.iter().find_map(|(def_id, (_, unused_ident))| {
|
let unused_macro = self.unused_macros.iter().find_map(|(def_id, (_, unused_ident))| {
|
||||||
if unused_ident.name == ident.name { Some((def_id, unused_ident)) } else { None }
|
if unused_ident.name == ident.name { Some((def_id, unused_ident)) } else { None }
|
||||||
});
|
});
|
||||||
|
|
|
@ -946,7 +946,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
||||||
|
|
||||||
// Check if one of single imports can still define the name,
|
// Check if one of single imports can still define the name,
|
||||||
// if it can then our result is not determined and can be invalidated.
|
// if it can then our result is not determined and can be invalidated.
|
||||||
#[allow(rustc::potential_query_instability)] // FIXME
|
|
||||||
for single_import in &resolution.single_imports {
|
for single_import in &resolution.single_imports {
|
||||||
if ignore_import == Some(*single_import) {
|
if ignore_import == Some(*single_import) {
|
||||||
// This branch handles a cycle in single imports.
|
// This branch handles a cycle in single imports.
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::cell::Cell;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use rustc_ast::NodeId;
|
use rustc_ast::NodeId;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
|
||||||
use rustc_data_structures::intern::Interned;
|
use rustc_data_structures::intern::Interned;
|
||||||
use rustc_errors::codes::*;
|
use rustc_errors::codes::*;
|
||||||
use rustc_errors::{Applicability, MultiSpan, pluralize, struct_span_code_err};
|
use rustc_errors::{Applicability, MultiSpan, pluralize, struct_span_code_err};
|
||||||
|
@ -233,7 +233,7 @@ impl<'ra> ImportData<'ra> {
|
||||||
pub(crate) struct NameResolution<'ra> {
|
pub(crate) struct NameResolution<'ra> {
|
||||||
/// Single imports that may define the name in the namespace.
|
/// Single imports that may define the name in the namespace.
|
||||||
/// Imports are arena-allocated, so it's ok to use pointers as keys.
|
/// Imports are arena-allocated, so it's ok to use pointers as keys.
|
||||||
pub single_imports: FxHashSet<Import<'ra>>,
|
pub single_imports: FxIndexSet<Import<'ra>>,
|
||||||
/// The least shadowable known binding for this name, or None if there are no known bindings.
|
/// The least shadowable known binding for this name, or None if there are no known bindings.
|
||||||
pub binding: Option<NameBinding<'ra>>,
|
pub binding: Option<NameBinding<'ra>>,
|
||||||
pub shadowed_glob: Option<NameBinding<'ra>>,
|
pub shadowed_glob: Option<NameBinding<'ra>>,
|
||||||
|
@ -494,7 +494,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
||||||
let key = BindingKey::new(target, ns);
|
let key = BindingKey::new(target, ns);
|
||||||
let _ = this.try_define(import.parent_scope.module, key, dummy_binding, false);
|
let _ = this.try_define(import.parent_scope.module, key, dummy_binding, false);
|
||||||
this.update_resolution(import.parent_scope.module, key, false, |_, resolution| {
|
this.update_resolution(import.parent_scope.module, key, false, |_, resolution| {
|
||||||
resolution.single_imports.remove(&import);
|
resolution.single_imports.swap_remove(&import);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
self.record_use(target, dummy_binding, Used::Other);
|
self.record_use(target, dummy_binding, Used::Other);
|
||||||
|
@ -862,7 +862,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
||||||
}
|
}
|
||||||
let key = BindingKey::new(target, ns);
|
let key = BindingKey::new(target, ns);
|
||||||
this.update_resolution(parent, key, false, |_, resolution| {
|
this.update_resolution(parent, key, false, |_, resolution| {
|
||||||
resolution.single_imports.remove(&import);
|
resolution.single_imports.swap_remove(&import);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -672,7 +672,7 @@ struct DiagMetadata<'ast> {
|
||||||
|
|
||||||
/// A list of labels as of yet unused. Labels will be removed from this map when
|
/// A list of labels as of yet unused. Labels will be removed from this map when
|
||||||
/// they are used (in a `break` or `continue` statement)
|
/// they are used (in a `break` or `continue` statement)
|
||||||
unused_labels: FxHashMap<NodeId, Span>,
|
unused_labels: FxIndexMap<NodeId, Span>,
|
||||||
|
|
||||||
/// Only used for better errors on `let x = { foo: bar };`.
|
/// Only used for better errors on `let x = { foo: bar };`.
|
||||||
/// In the case of a parse error with `let x = { foo: bar, };`, this isn't needed, it's only
|
/// 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> {
|
||||||
Ok((node_id, _)) => {
|
Ok((node_id, _)) => {
|
||||||
// Since this res is a label, it is never read.
|
// Since this res is a label, it is never read.
|
||||||
self.r.label_res_map.insert(expr.id, node_id);
|
self.r.label_res_map.insert(expr.id, node_id);
|
||||||
self.diag_metadata.unused_labels.remove(&node_id);
|
self.diag_metadata.unused_labels.swap_remove(&node_id);
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
self.report_error(label.ident.span, error);
|
self.report_error(label.ident.span, error);
|
||||||
|
@ -5201,7 +5201,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
||||||
let mut late_resolution_visitor = LateResolutionVisitor::new(self);
|
let mut late_resolution_visitor = LateResolutionVisitor::new(self);
|
||||||
late_resolution_visitor.resolve_doc_links(&krate.attrs, MaybeExported::Ok(CRATE_NODE_ID));
|
late_resolution_visitor.resolve_doc_links(&krate.attrs, MaybeExported::Ok(CRATE_NODE_ID));
|
||||||
visit::walk_crate(&mut late_resolution_visitor, krate);
|
visit::walk_crate(&mut late_resolution_visitor, krate);
|
||||||
#[allow(rustc::potential_query_instability)] // FIXME
|
|
||||||
for (id, span) in late_resolution_visitor.diag_metadata.unused_labels.iter() {
|
for (id, span) in late_resolution_visitor.diag_metadata.unused_labels.iter() {
|
||||||
self.lint_buffer.buffer_lint(
|
self.lint_buffer.buffer_lint(
|
||||||
lint::builtin::UNUSED_LABELS,
|
lint::builtin::UNUSED_LABELS,
|
||||||
|
|
|
@ -1036,7 +1036,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
||||||
Applicability::MaybeIncorrect,
|
Applicability::MaybeIncorrect,
|
||||||
);
|
);
|
||||||
// Do not lint against unused label when we suggest them.
|
// Do not lint against unused label when we suggest them.
|
||||||
self.diag_metadata.unused_labels.remove(node_id);
|
self.diag_metadata.unused_labels.swap_remove(node_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1137,7 +1137,7 @@ pub struct Resolver<'ra, 'tcx> {
|
||||||
non_macro_attr: MacroData,
|
non_macro_attr: MacroData,
|
||||||
local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>,
|
local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>,
|
||||||
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
|
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
|
||||||
unused_macros: FxHashMap<LocalDefId, (NodeId, Ident)>,
|
unused_macros: FxIndexMap<LocalDefId, (NodeId, Ident)>,
|
||||||
/// A map from the macro to all its potentially unused arms.
|
/// A map from the macro to all its potentially unused arms.
|
||||||
unused_macro_rules: FxIndexMap<LocalDefId, UnordMap<usize, (Ident, Span)>>,
|
unused_macro_rules: FxIndexMap<LocalDefId, UnordMap<usize, (Ident, Span)>>,
|
||||||
proc_macro_stubs: FxHashSet<LocalDefId>,
|
proc_macro_stubs: FxHashSet<LocalDefId>,
|
||||||
|
|
|
@ -323,7 +323,6 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_unused_macros(&mut self) {
|
fn check_unused_macros(&mut self) {
|
||||||
#[allow(rustc::potential_query_instability)] // FIXME
|
|
||||||
for (_, &(node_id, ident)) in self.unused_macros.iter() {
|
for (_, &(node_id, ident)) in self.unused_macros.iter() {
|
||||||
self.lint_buffer.buffer_lint(
|
self.lint_buffer.buffer_lint(
|
||||||
UNUSED_MACROS,
|
UNUSED_MACROS,
|
||||||
|
@ -576,7 +575,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
||||||
match res {
|
match res {
|
||||||
Res::Def(DefKind::Macro(_), def_id) => {
|
Res::Def(DefKind::Macro(_), def_id) => {
|
||||||
if let Some(def_id) = def_id.as_local() {
|
if let Some(def_id) = def_id.as_local() {
|
||||||
self.unused_macros.remove(&def_id);
|
self.unused_macros.swap_remove(&def_id);
|
||||||
if self.proc_macro_stubs.contains(&def_id) {
|
if self.proc_macro_stubs.contains(&def_id) {
|
||||||
self.dcx().emit_err(errors::ProcMacroSameCrate {
|
self.dcx().emit_err(errors::ProcMacroSameCrate {
|
||||||
span: path.span,
|
span: path.span,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue