Allocate traits in scope upfront when type checking instead of recollecting them everytime

This commit is contained in:
Lukas Wirth 2023-03-05 15:04:46 +01:00
parent a8606e5363
commit a51267c5e0
4 changed files with 66 additions and 50 deletions

View file

@ -449,6 +449,15 @@ impl Resolver {
traits
}
pub fn traits_in_scope_from_block_scopes(&self) -> impl Iterator<Item = TraitId> + '_ {
self.scopes()
.filter_map(|scope| match scope {
Scope::BlockScope(m) => Some(m.def_map[m.module_id].scope.traits()),
_ => None,
})
.flatten()
}
pub fn module(&self) -> ModuleId {
let (def_map, local_id) = self.item_scope();
def_map.module_id(local_id)