resolve: Pre-intern tool module bindings

This commit is contained in:
Vadim Petrochenkov 2023-08-18 17:18:26 +08:00
parent 05010b6074
commit d1f8ea417c
2 changed files with 11 additions and 2 deletions

View File

@ -572,8 +572,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
)),
}
}
Scope::ToolPrelude => match this.registered_tools.get(&ident).cloned() {
Some(ident) => ok(Res::ToolMod, ident.span, this.arenas),
Scope::ToolPrelude => match this.registered_tool_bindings.get(&ident) {
Some(binding) => Ok((*binding, Flags::empty())),
None => Err(Determinacy::Determined),
},
Scope::StdLibPrelude => {

View File

@ -1006,6 +1006,7 @@ pub struct Resolver<'a, 'tcx> {
dummy_binding: NameBinding<'a>,
builtin_types_bindings: FxHashMap<Symbol, NameBinding<'a>>,
builtin_attrs_bindings: FxHashMap<Symbol, NameBinding<'a>>,
registered_tool_bindings: FxHashMap<Ident, NameBinding<'a>>,
used_extern_options: FxHashSet<Symbol>,
macro_names: FxHashSet<Ident>,
@ -1359,6 +1360,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
(builtin_attr.name, binding)
})
.collect(),
registered_tool_bindings: registered_tools
.iter()
.map(|ident| {
let binding = (Res::ToolMod, pub_vis, ident.span, LocalExpnId::ROOT)
.to_name_binding(arenas);
(*ident, binding)
})
.collect(),
used_extern_options: Default::default(),
macro_names: FxHashSet::default(),