Skip to main content

InfixDeclaration

Enum InfixDeclaration 

Source
pub enum InfixDeclaration {
    InThisModule(NodeSpan),
    InImportedModule(SourceSpan),
    Unknown,
}
Expand description

Part of Error::AmbiguousOperatorPrecedence’s public shape, so it is re-exported alongside the error rather than left behind a private module. Where an operator’s infix declaration was written, to the extent canonicalization can say — the three cases a SpanLabel under it has to distinguish.

A phase only ever sees one module and never learns which file it was read from, so a label about the module under check leaves SpanLabel::file as None and the driver fills it in at render time. A label about an imported operator cannot do that: its span belongs to the exporting module’s file, and rendering it against the importing one underlines unrelated text. That is what SourceSpan and SpanLabel::file were built for (ERR-5), and this enum is what picks between them.

Variants§

§

InThisModule(NodeSpan)

Declared by the module under check. Its span is a byte range in the file the diagnostic is already being rendered against.

§

InImportedModule(SourceSpan)

Declared by an imported module whose Interface knew both the span and the file it was written in.

§

Unknown

Declared by an imported module whose Interface could not say which file it came from — a hand-built one, or one built before its file was known (see Interface::source_span). There is nothing honest to underline, so a diagnostic renders no label rather than one against the wrong file.

Implementations§

Source§

impl InfixDeclaration

Source

pub fn label(&self, message: String) -> Option<SpanLabel>

A secondary label under this declaration, when there is one to point at.

None covers both the unknown case and a [NodeSpan] with no position behind it — a label at byte 0 of the module under check is worse than no label at all.

Trait Implementations§

Source§

impl Clone for InfixDeclaration

Source§

fn clone(&self) -> InfixDeclaration

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 InfixDeclaration

Source§

impl Debug for InfixDeclaration

Source§

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

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

impl PartialEq for InfixDeclaration

Source§

fn eq(&self, other: &InfixDeclaration) -> 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 InfixDeclaration

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.