pub struct Diagnostic {
pub kind: DiagKind,
pub unit: UnitId,
pub span: Span,
pub node: Option<NodeRef>,
}Expand description
One problem found while resolving, located in a unit.
§Examples
use hir_lang::{Span, UnitId};
use intern_lang::Interner;
use resolve_lang::{DiagKind, Diagnostic};
let d = Diagnostic { kind: DiagKind::NoParent, unit: UnitId::new(0), span: Span::new(3, 9), node: None };
assert_eq!(d.message(&Interner::new()), "`parent::` used in a class with no base class");Fields§
§kind: DiagKindWhat went wrong.
unit: UnitIdThe unit it is in.
span: SpanWhere: the offending name’s source span (for an expanded name, the span its origin records).
node: Option<NodeRef>The HIR node it is about: usually the path, or the item for definitions and mixins.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn message<L: Lookup>(&self, names: &L) -> String
pub fn message<L: Lookup>(&self, names: &L) -> String
A one-line English message, with names spelled through names.
§Examples
use hir_lang::{Name, Ns, Span, UnitId};
use intern_lang::Interner;
use resolve_lang::{DiagKind, Diagnostic};
let mut names = Interner::new();
let (lenght, length) = (Name::new(names.intern("lenght")), Name::new(names.intern("length")));
let d = Diagnostic {
kind: DiagKind::Unresolved { name: lenght, ns: Ns::Value, container: None, suggestion: Some(length) },
unit: UnitId::new(0),
span: Span::new(0, 6),
node: None,
};
assert_eq!(d.message(&names), "cannot find value `lenght` in this scope; did you mean `length`?");Trait Implementations§
Source§impl Clone for Diagnostic
impl Clone for Diagnostic
impl Copy for Diagnostic
Source§impl Debug for Diagnostic
impl Debug for Diagnostic
impl Eq for Diagnostic
Source§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
impl StructuralPartialEq for Diagnostic
Auto Trait Implementations§
impl Freeze for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl UnsafeUnpin for Diagnostic
impl UnwindSafe for Diagnostic
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