pub struct ResolvedUnit { /* private fields */ }Expand description
One resolved unit.
§Examples
use hir_lang::Builder;
use intern_lang::Interner;
let mut b = Builder::new();
let root = b.module(None, &[]);
let res = resolve_lang::resolve(b.finish(root)?, &Interner::new())?;
assert_eq!(res.units().len(), 1);
assert!(res.units()[0].hir().validate().is_ok());Implementations§
Source§impl ResolvedUnit
impl ResolvedUnit
Sourcepub fn id(&self) -> UnitId
pub fn id(&self) -> UnitId
The unit’s id.
§Examples
use hir_lang::{Builder, UnitId};
use intern_lang::Interner;
let mut b = Builder::for_unit(UnitId::new(4));
let root = b.module(None, &[]);
let res = resolve_lang::resolve(b.finish(root)?, &Interner::new())?;
assert_eq!(res.units()[0].id(), UnitId::new(4));Sourcepub fn name(&self) -> Option<Name>
pub fn name(&self) -> Option<Name>
The root name other units reached this unit by, if it had one.
§Examples
use hir_lang::Builder;
use intern_lang::Interner;
let mut b = Builder::new();
let root = b.module(None, &[]);
let res = resolve_lang::resolve(b.finish(root)?, &Interner::new())?;
assert!(res.units()[0].name().is_none());Sourcepub fn hir(&self) -> &Hir
pub fn hir(&self) -> &Hir
The resolved HIR: every resolvable path’s slot is filled through
hir-lang’s checked setters, so it is still a valid Hir.
§Examples
use hir_lang::Builder;
use intern_lang::Interner;
let mut b = Builder::new();
let root = b.module(None, &[]);
let res = resolve_lang::resolve(b.finish(root)?, &Interner::new())?;
assert_eq!(res.units()[0].hir().root(), root);Sourcepub fn into_hir(self) -> Hir
pub fn into_hir(self) -> Hir
Takes the resolved HIR.
§Examples
use hir_lang::Builder;
use intern_lang::Interner;
let mut b = Builder::new();
let root = b.module(None, &[]);
let res = resolve_lang::resolve(b.finish(root)?, &Interner::new())?;
let (units, _, _) = res.into_parts();
let hir = units.into_iter().next().unwrap().into_hir();
assert!(hir.validate().is_ok());Sourcepub fn members(&self, class: ItemId) -> Option<&[ClassMember]>
pub fn members(&self, class: ItemId) -> Option<&[ClassMember]>
The effective members of a class or interface item (its own members
plus what its mixins contribute), sorted by namespace, then by name
(symbol order, not spelling).
None for other items.
§Examples
use hir_lang::{Builder, ClassDef, Item, ItemKind, Name};
use intern_lang::Interner;
let mut names = Interner::new();
let mut b = Builder::new();
let body = b.block(&[], None);
let m = b.func(Name::new(names.intern("m")), &[], body);
let items = b.list(&[m]);
let class = b.item(Item::new(Some(Name::new(names.intern("C"))), ItemKind::Class(ClassDef { items, ..ClassDef::default() })));
let root = b.module(None, &[class]);
let res = resolve_lang::resolve(b.finish(root)?, &names)?;
assert_eq!(res.units()[0].members(class).map(<[_]>::len), Some(1));Sourcepub fn ident_binds(&self, pat: PatId) -> Option<bool>
pub fn ident_binds(&self, pat: PatId) -> Option<bool>
For a Pat::Ident pattern: Some(true) if it binds its binder,
Some(false) if its path named a constant, unit variant, or unit
record (it matches that value). None for other patterns.
§Examples
use hir_lang::{Builder, PatId};
use intern_lang::Interner;
let mut b = Builder::new();
let root = b.module(None, &[]);
let res = resolve_lang::resolve(b.finish(root)?, &Interner::new())?;
assert_eq!(res.units()[0].ident_binds(PatId::from_index(0).unwrap()), None);Trait Implementations§
Source§impl Clone for ResolvedUnit
impl Clone for ResolvedUnit
Auto Trait Implementations§
impl Freeze for ResolvedUnit
impl RefUnwindSafe for ResolvedUnit
impl Send for ResolvedUnit
impl Sync for ResolvedUnit
impl Unpin for ResolvedUnit
impl UnsafeUnpin for ResolvedUnit
impl UnwindSafe for ResolvedUnit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more