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§
impl Copy for Reason
impl Eq for Reason
impl StructuralPartialEq for Reason
Auto Trait Implementations§
impl Freeze for Reason
impl RefUnwindSafe for Reason
impl Send for Reason
impl Sync for Reason
impl Unpin for Reason
impl UnsafeUnpin for Reason
impl UnwindSafe for Reason
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.