1
Fork 0

rustc_hir: Less error-prone methods for accessing PartialRes resolution

This commit is contained in:
Vadim Petrochenkov 2022-10-10 19:21:35 +04:00
parent 518263d889
commit 1a8f177772
12 changed files with 75 additions and 90 deletions

View file

@ -464,6 +464,16 @@ impl PartialRes {
pub fn unresolved_segments(&self) -> usize {
self.unresolved_segments
}
#[inline]
pub fn full_res(&self) -> Option<Res<NodeId>> {
(self.unresolved_segments == 0).then_some(self.base_res)
}
#[inline]
pub fn expect_full_res(&self) -> Res<NodeId> {
self.full_res().expect("unexpected unresolved segments")
}
}
/// Different kinds of symbols can coexist even if they share the same textual name.