Skip to main content

DiagKind

Enum DiagKind 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

§name: Name

The name.

§ns: Ns

The syntactic namespace of the path.

§container: Option<Name>

The module or type the name was looked up in, for m::x.

§suggestion: Option<Name>

The did-you-mean candidate.

§

AmbiguousGlob

A name more than one glob import provides, with different meanings.

Fields

§name: Name

The name.

§first: Res

One meaning.

§second: Res

Another meaning.

§

Private

A name that exists but is not visible from here. The path is still resolved to it, so tools can navigate.

Fields

§name: Name

The name.

§res: Res

What it resolved to.

§vis: Vis

Its visibility.

§

Duplicate

A second definition of a name in one scope and namespace.

Fields

§name: Name

The name.

§first: Span

Where the first definition’s name is.

§

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.

Fields

§name: Name

The name.

§binder: BinderId

The local it would have named.

§

WrongKind

A definition of the wrong kind for its position (a function used as a type, a local named by a constructor pattern).

Fields

§name: Name

The name.

§ns: Ns

The syntactic namespace of the path.

§found: DefKind

What the name actually is.

§

NotAContainer

A path that continues past something without members (f::x where f is a function, or a variant used as a prefix).

Fields

§name: Name

The name of the non-container.

§found: DefKind

What it is.

§

Shadowing

A binder that reuses a visible name the policy forbids shadowing.

Fields

§name: Name

The name.

§shadowed: BinderId

The binder it shadows.

§

BrokenImport

A name whose import failed to resolve (the import itself has its own diagnostic).

Fields

§name: Name

The name.

§

ImportCycle

An import that depends on itself through other imports.

Fields

§name: Name

The name the import binds.

§

ImportAmbiguity

An import that resolved while a glob import of the same scope was still undetermined, and that the finished glob makes ambiguous.

Fields

§name: Name

The name.

§

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.

Fields

§root: PathRoot

The root.

§

OutsideType

self::, parent::, or static:: outside any class, interface, or impl.

Fields

§root: PathRoot

The root.

§

NoParent

parent:: in a class with no base class.

§

SuperBeyondRoot

super:: past the unit’s root module.

Fields

§levels: u8

The number of levels asked for.

§

MixinConflict

Two mixins provide the same member and no insteadof rule chooses.

Fields

§name: Name

The member name.

§first: DefId

The member taken (the first mixin’s).

§second: DefId

The member dropped.

§

NotAMixin

Something that is not a mixin used as one.

Fields

§found: DefKind

What it is.

§

UnknownMixinMember

A mixin rule naming a member no used mixin has.

Fields

§name: Symbol

The member name.

§

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.

Fields

§class: Name

The class.

§

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.

Fields

§error: HirError

The refusal.

Implementations§

Source§

impl DiagKind

Source

pub const fn is_unresolved(&self) -> bool

Whether this is an unresolved-name diagnostic.

§Examples
use resolve_lang::DiagKind;

assert!(!DiagKind::NoParent.is_unresolved());
Source

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));

Trait Implementations§

Source§

impl Clone for DiagKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for DiagKind

Source§

impl Debug for DiagKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DiagKind

Source§

impl PartialEq for DiagKind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DiagKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.