Auto merge of #88689 - Aaron1011:confused-std-resolver, r=cjgillot
Move `confused_type_with_std_module` to `ResolverOutputs` This eliminates untracked global state from `Session`.
This commit is contained in:
commit
385f8e2078
6 changed files with 12 additions and 11 deletions
|
@ -137,6 +137,9 @@ pub struct ResolverOutputs {
|
||||||
/// A list of proc macro LocalDefIds, written out in the order in which
|
/// A list of proc macro LocalDefIds, written out in the order in which
|
||||||
/// they are declared in the static array generated by proc_macro_harness.
|
/// they are declared in the static array generated by proc_macro_harness.
|
||||||
pub proc_macros: Vec<LocalDefId>,
|
pub proc_macros: Vec<LocalDefId>,
|
||||||
|
/// Mapping from ident span to path span for paths that don't exist as written, but that
|
||||||
|
/// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.
|
||||||
|
pub confused_type_with_std_module: FxHashMap<Span, Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
|
|
@ -1999,9 +1999,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
||||||
let item_span =
|
let item_span =
|
||||||
path.iter().last().map_or(span, |segment| segment.ident.span);
|
path.iter().last().map_or(span, |segment| segment.ident.span);
|
||||||
|
|
||||||
let mut hm = self.r.session.confused_type_with_std_module.borrow_mut();
|
self.r.confused_type_with_std_module.insert(item_span, span);
|
||||||
hm.insert(item_span, span);
|
self.r.confused_type_with_std_module.insert(span, span);
|
||||||
hm.insert(span, span);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1038,6 +1038,7 @@ pub struct Resolver<'a> {
|
||||||
/// A list of proc macro LocalDefIds, written out in the order in which
|
/// A list of proc macro LocalDefIds, written out in the order in which
|
||||||
/// they are declared in the static array generated by proc_macro_harness.
|
/// they are declared in the static array generated by proc_macro_harness.
|
||||||
proc_macros: Vec<NodeId>,
|
proc_macros: Vec<NodeId>,
|
||||||
|
confused_type_with_std_module: FxHashMap<Span, Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Nothing really interesting here; it just provides memory for the rest of the crate.
|
/// Nothing really interesting here; it just provides memory for the rest of the crate.
|
||||||
|
@ -1404,6 +1405,7 @@ impl<'a> Resolver<'a> {
|
||||||
main_def: Default::default(),
|
main_def: Default::default(),
|
||||||
trait_impls: Default::default(),
|
trait_impls: Default::default(),
|
||||||
proc_macros: Default::default(),
|
proc_macros: Default::default(),
|
||||||
|
confused_type_with_std_module: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let root_parent_scope = ParentScope::module(graph_root, &resolver);
|
let root_parent_scope = ParentScope::module(graph_root, &resolver);
|
||||||
|
@ -1447,6 +1449,7 @@ impl<'a> Resolver<'a> {
|
||||||
let maybe_unused_extern_crates = self.maybe_unused_extern_crates;
|
let maybe_unused_extern_crates = self.maybe_unused_extern_crates;
|
||||||
let glob_map = self.glob_map;
|
let glob_map = self.glob_map;
|
||||||
let main_def = self.main_def;
|
let main_def = self.main_def;
|
||||||
|
let confused_type_with_std_module = self.confused_type_with_std_module;
|
||||||
ResolverOutputs {
|
ResolverOutputs {
|
||||||
definitions,
|
definitions,
|
||||||
cstore: Box::new(self.crate_loader.into_cstore()),
|
cstore: Box::new(self.crate_loader.into_cstore()),
|
||||||
|
@ -1464,6 +1467,7 @@ impl<'a> Resolver<'a> {
|
||||||
main_def,
|
main_def,
|
||||||
trait_impls: self.trait_impls,
|
trait_impls: self.trait_impls,
|
||||||
proc_macros,
|
proc_macros,
|
||||||
|
confused_type_with_std_module,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1486,6 +1490,7 @@ impl<'a> Resolver<'a> {
|
||||||
main_def: self.main_def.clone(),
|
main_def: self.main_def.clone(),
|
||||||
trait_impls: self.trait_impls.clone(),
|
trait_impls: self.trait_impls.clone(),
|
||||||
proc_macros,
|
proc_macros,
|
||||||
|
confused_type_with_std_module: self.confused_type_with_std_module.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,10 +183,6 @@ pub struct Session {
|
||||||
/// Cap lint level specified by a driver specifically.
|
/// Cap lint level specified by a driver specifically.
|
||||||
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
|
pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
|
||||||
|
|
||||||
/// Mapping from ident span to path span for paths that don't exist as written, but that
|
|
||||||
/// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.
|
|
||||||
pub confused_type_with_std_module: Lock<FxHashMap<Span, Span>>,
|
|
||||||
|
|
||||||
/// Tracks the current behavior of the CTFE engine when an error occurs.
|
/// Tracks the current behavior of the CTFE engine when an error occurs.
|
||||||
/// Options range from returning the error without a backtrace to returning an error
|
/// Options range from returning the error without a backtrace to returning an error
|
||||||
/// and immediately printing the backtrace to stderr.
|
/// and immediately printing the backtrace to stderr.
|
||||||
|
@ -1313,7 +1309,6 @@ pub fn build_session(
|
||||||
print_fuel,
|
print_fuel,
|
||||||
jobserver: jobserver::client(),
|
jobserver: jobserver::client(),
|
||||||
driver_lint_caps,
|
driver_lint_caps,
|
||||||
confused_type_with_std_module: Lock::new(Default::default()),
|
|
||||||
ctfe_backtrace,
|
ctfe_backtrace,
|
||||||
miri_unleashed_features: Lock::new(Default::default()),
|
miri_unleashed_features: Lock::new(Default::default()),
|
||||||
asm_arch,
|
asm_arch,
|
||||||
|
|
|
@ -1495,9 +1495,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let mut err = struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type");
|
let mut err = struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type");
|
||||||
if let (true, Ok(snippet)) = (
|
if let (true, Ok(snippet)) = (
|
||||||
self.tcx()
|
self.tcx()
|
||||||
.sess
|
.resolutions(())
|
||||||
.confused_type_with_std_module
|
.confused_type_with_std_module
|
||||||
.borrow()
|
|
||||||
.keys()
|
.keys()
|
||||||
.any(|full_span| full_span.contains(span)),
|
.any(|full_span| full_span.contains(span)),
|
||||||
self.tcx().sess.source_map().span_to_snippet(span),
|
self.tcx().sess.source_map().span_to_snippet(span),
|
||||||
|
|
|
@ -434,7 +434,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(span) =
|
if let Some(span) =
|
||||||
tcx.sess.confused_type_with_std_module.borrow().get(&span)
|
tcx.resolutions(()).confused_type_with_std_module.get(&span)
|
||||||
{
|
{
|
||||||
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(*span) {
|
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(*span) {
|
||||||
err.span_suggestion(
|
err.span_suggestion(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue