pub struct Resolution { /* private fields */ }Expand description
The result of resolving a program: the resolved units, every diagnostic, and the definition/reference index.
§Examples
use hir_lang::{Builder, Name};
use intern_lang::Interner;
let mut names = Interner::new();
let mut b = Builder::new();
let missing = b.name_expr(Name::new(names.intern("missing")));
let body = b.block(&[], Some(missing));
let f = b.func(Name::new(names.intern("f")), &[], body);
let root = b.module(None, &[f]);
let res = resolve_lang::resolve(b.finish(root)?, &names)?;
assert!(!res.is_clean());
assert_eq!(res.diagnostics()[0].message(&names), "cannot find value `missing` in this scope");Implementations§
Source§impl Resolution
impl Resolution
Sourcepub fn units(&self) -> &[ResolvedUnit]
pub fn units(&self) -> &[ResolvedUnit]
The resolved units, in the order they were added.
§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);Sourcepub fn unit(&self, id: UnitId) -> Option<&ResolvedUnit>
pub fn unit(&self, id: UnitId) -> Option<&ResolvedUnit>
One unit by id.
§Examples
use hir_lang::{Builder, UnitId};
use intern_lang::Interner;
let mut b = Builder::for_unit(UnitId::new(2));
let root = b.module(None, &[]);
let res = resolve_lang::resolve(b.finish(root)?, &Interner::new())?;
assert!(res.unit(UnitId::new(2)).is_some());
assert!(res.unit(UnitId::new(3)).is_none());Sourcepub fn hir(&self, id: UnitId) -> Option<&Hir>
pub fn hir(&self, id: UnitId) -> Option<&Hir>
The resolved HIR of one unit.
§Examples
use hir_lang::{Builder, UnitId};
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.hir(UnitId::new(0)).is_some());Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Every diagnostic, sorted by unit, then position, then discovery.
§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.diagnostics().is_empty());Sourcepub fn is_clean(&self) -> bool
pub fn is_clean(&self) -> bool
Whether resolution found nothing to report.
§Examples
use hir_lang::Builder;
use intern_lang::Interner;
let mut b = Builder::new();
let root = b.module(None, &[]);
assert!(resolve_lang::resolve(b.finish(root)?, &Interner::new())?.is_clean());Sourcepub fn index(&self) -> &Index
pub fn index(&self) -> &Index
The definition/reference index.
§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.index().references_all().is_empty());Sourcepub fn into_parts(self) -> (Vec<ResolvedUnit>, Vec<Diagnostic>, Index)
pub fn into_parts(self) -> (Vec<ResolvedUnit>, Vec<Diagnostic>, Index)
Takes the parts.
§Examples
use hir_lang::Builder;
use intern_lang::Interner;
let mut b = Builder::new();
let root = b.module(None, &[]);
let (units, diags, _index) = resolve_lang::resolve(b.finish(root)?, &Interner::new())?.into_parts();
assert_eq!((units.len(), diags.len()), (1, 0));Trait Implementations§
Source§impl Clone for Resolution
impl Clone for Resolution
Auto Trait Implementations§
impl Freeze for Resolution
impl RefUnwindSafe for Resolution
impl Send for Resolution
impl Sync for Resolution
impl Unpin for Resolution
impl UnsafeUnpin for Resolution
impl UnwindSafe for Resolution
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