#[non_exhaustive]pub enum DiagKind {
Show 23 variants
Unresolved {
name: Name,
ns: Ns,
container: Option<Name>,
suggestion: Option<Name>,
},
AmbiguousGlob {
name: Name,
first: Res,
second: Res,
},
Private {
name: Name,
res: Res,
vis: Vis,
},
Duplicate {
name: Name,
first: Span,
},
CannotCapture {
name: Name,
binder: BinderId,
},
WrongKind {
name: Name,
ns: Ns,
found: DefKind,
},
NotAContainer {
name: Name,
found: DefKind,
},
Shadowing {
name: Name,
shadowed: BinderId,
},
BrokenImport {
name: Name,
},
ImportCycle {
name: Name,
},
ImportAmbiguity {
name: Name,
},
GlobsUnsupported,
AliasesUnsupported,
RootUnsupported {
root: PathRoot,
},
OutsideType {
root: PathRoot,
},
NoParent,
SuperBeyondRoot {
levels: u8,
},
MixinConflict {
name: Name,
first: DefId,
second: DefId,
},
NotAMixin {
found: DefKind,
},
UnknownMixinMember {
name: Symbol,
},
MixinCycle,
InconsistentMro {
class: Name,
},
Rejected {
error: HirError,
},
}Expand description
What went wrong, with the data a tool needs to explain or fix it.
§Examples
use hir_lang::{Name, Ns, Symbol};
use resolve_lang::DiagKind;
let x = Name::new(Symbol::from_u32(1).unwrap());
let k = DiagKind::Unresolved { name: x, ns: Ns::Value, container: None, suggestion: None };
assert!(k.is_unresolved());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Unresolved
A name that is not visible here (or, with container, that the
container does not define). suggestion is the closest visible name
within a small edit distance, if any.
Fields
AmbiguousGlob
A name more than one glob import provides, with different meanings.
Private
A name that exists but is not visible from here. The path is still resolved to it, so tools can navigate.
Duplicate
A second definition of a name in one scope and namespace.
CannotCapture
A local of an enclosing function used where it cannot be captured
(inside a nested item, or past a frame that does not capture), or a
place alias (let_place) used past any frame, a closure included.
WrongKind
A definition of the wrong kind for its position (a function used as a type, a local named by a constructor pattern).
Fields
NotAContainer
A path that continues past something without members (f::x where
f is a function, or a variant used as a prefix).
Shadowing
A binder that reuses a visible name the policy forbids shadowing.
BrokenImport
A name whose import failed to resolve (the import itself has its own diagnostic).
ImportCycle
An import that depends on itself through other imports.
ImportAmbiguity
An import that resolved while a glob import of the same scope was still undetermined, and that the finished glob makes ambiguous.
GlobsUnsupported
A glob import in a language without them.
AliasesUnsupported
An aliased import in a language without them.
RootUnsupported
A path root the language does not have, or that cannot start an import.
OutsideType
self::, parent::, or static:: outside any class, interface, or impl.
NoParent
parent:: in a class with no base class.
SuperBeyondRoot
super:: past the unit’s root module.
MixinConflict
Two mixins provide the same member and no insteadof rule chooses.
Fields
NotAMixin
Something that is not a mixin used as one.
UnknownMixinMember
A mixin rule naming a member no used mixin has.
MixinCycle
A mixin that uses itself, directly or through other mixins.
InconsistentMro
A class whose bases admit no C3 method resolution order (Python’s
TypeError at class creation): a base listed before a class that
derives from it, a repeated base, or orders that contradict each
other. Member lookup falls back to the bases’ orders concatenated left
to right without repeats.
Rejected
The HIR refused a resolution resolve-lang computed. This indicates a
disagreement between this crate and hir-lang’s checks; the path is
left as Res::Err so the Hir stays valid.
Implementations§
Source§impl DiagKind
impl DiagKind
Sourcepub const fn is_unresolved(&self) -> bool
pub const fn is_unresolved(&self) -> bool
Whether this is an unresolved-name diagnostic.
§Examples
use resolve_lang::DiagKind;
assert!(!DiagKind::NoParent.is_unresolved());Sourcepub const fn suggestion(&self) -> Option<Name>
pub const fn suggestion(&self) -> Option<Name>
The did-you-mean suggestion, if this diagnostic has one.
§Examples
use hir_lang::{Name, Ns, Symbol};
use resolve_lang::DiagKind;
let (x, y) = (Name::new(Symbol::from_u32(1).unwrap()), Name::new(Symbol::from_u32(2).unwrap()));
let k = DiagKind::Unresolved { name: x, ns: Ns::Value, container: None, suggestion: Some(y) };
assert_eq!(k.suggestion(), Some(y));