Skip to main content

Reason

Enum Reason 

Source
pub enum Reason {
Show 27 variants Annotation, Literal, FunctionShape, Application, IfCondition, IfBranch, CaseBranch, CasePattern, ParameterPattern, DeclarationBody, LetBinding, LetBody, TupleElements, Unit, RecordFields, Update, UpdateField, Access, Accessor, RecordPatternEntry, RecordPatternBinding, RecordPatternEntryWithBindings, InstanceRequired, InstanceContext, SuperclassInstance, InstanceMember, DerivationBinding,
}
Expand description

Why two types were required to match.

A constraint on its own is a pair of types, which is everything inference needs and nothing a reader can act on. The reason is what turns “cannot match Bool with Int” into something located: this branch has type Bool, and Int is what was expected because of this annotation. Elm calls this a Reason, rustc an ObligationCause.

Variants§

§

Annotation

A declaration’s type annotation, which its body has to satisfy.

§

Literal

A literal’s own type: 'a' is a Char.

§

FunctionShape

A function’s type is its parameter’s type arrow its body’s type.

§

Application

What is applied has to be a function from the argument’s type.

§

IfCondition

The condition of an if has to be a Bool.

§

IfBranch

Every branch of an if has the type of the whole if.

§

CaseBranch

Every branch of a case has the type of the whole case.

§

CasePattern

A pattern has to match the type of the expression being matched on.

§

ParameterPattern

A parameter written as a pattern has to match the type of the argument it takes.

§

DeclarationBody

The body of a declaration that wrote a parameter as a pattern has the type the declaration returns. It is the one branch of the match that parameter became, and is reported as what the source wrote: a body, not a case branch.

§

LetBinding

A let binding has the type of the value bound to it.

§

LetBody

A let has the type of its body.

§

TupleElements

A tuple’s type is the tuple of its elements’ types.

§

Unit

() is the unit type’s one value.

§

RecordFields

A record’s type is the record type of its fields’ types.

§

Update

An update has the type of the record it updates.

§

UpdateField

A field’s new value in an update has the type the field already has. Carried by the equation a FieldConstraint of an update becomes once its record type is known, at the value’s span.

§

Access

A field access has the type of the field it reads. Carried by the equation a FieldConstraint of an access becomes, at the access’s span.

§

Accessor

An accessor’s result has the type of the field it reads. Carried by the equation a FieldConstraint of an accessor becomes, at the accessor’s span.

§

RecordPatternEntry

A record pattern’s entry matches a value of the type its field has. Carried by the equation a FieldConstraint of a record pattern becomes, at the span of the entry’s own pattern — Celsius in { taken = Celsius } — when that pattern binds no name, so that nothing but the pattern decides the entry’s type and a mismatch is the pattern’s.

§

RecordPatternBinding

RecordPatternEntry for an entry whose pattern is a name, the binding in { taken } or { taken = t }. That name’s type is constrained by nothing but the body’s uses of it, so when the equation fails the pattern is not what disagrees with the field: a use is, and the note says so. The caret is still under the binding (ERR-20).

§

RecordPatternEntryWithBindings

RecordPatternEntry for an entry whose pattern is neither a name nor binding-free, Box x in { taken = Box x }: either the pattern or a use of a name it binds can be what disagrees with the field, and nothing here tells which, so the note names both.

§

InstanceRequired

A use of a name whose type has a context. The context’s constraints are instantiated at the types the use gave its variables, and each requires an instance of its class at that type. Carried by an Obligation and never by an equation, at the span of the use.

§

InstanceContext

An instance a use requires has a context of its own, and each of its constraints requires an instance in turn, at the type the instance was used at. Carried by an Obligation at the span of the use that started the chain.

§

SuperclassInstance

A class with a superclass requires an instance of the superclass at every type it has an instance for. Carried by an Obligation at the span of the instance declaration.

§

InstanceMember

A binding of an instance has the type its class gave the member, at the type the instance is for. It is the reason of the equation the member’s signature stands in for, at the span of the instance’s head line, where an annotation would be.

§

DerivationBinding

A binding of a derivation has the type the chapter gives it over the member’s answer type. It is the reason of the equation that type stands in for, at the span of derived member, where an annotation would be.

Trait Implementations§

Source§

impl Clone for Reason

Source§

fn clone(&self) -> Reason

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 Reason

Source§

impl Debug for Reason

Source§

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

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

impl Eq for Reason

Source§

impl PartialEq for Reason

Source§

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

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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.