Skip to content

Commit 17691ee

Browse files
committed
Slightly optimize Resolver::krate
1 parent 4b4a343 commit 17691ee

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/hir_def/src/resolver.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,13 @@ impl Resolver {
448448
}
449449

450450
pub fn krate(&self) -> CrateId {
451-
self.module_scope().0.krate()
451+
self.scopes
452+
.get(0)
453+
.and_then(|scope| match scope {
454+
Scope::ModuleScope(m) => Some(m.def_map.krate()),
455+
_ => None,
456+
})
457+
.expect("module scope invariant violated")
452458
}
453459

454460
pub fn where_predicates_in_scope(

0 commit comments

Comments
 (0)