pub struct LambdaAnnotationMismatch {
pub range: TextRange,
pub param_name: Option<String>,
pub expected: Ty,
pub found: Ty,
}Expand description
One incompatibility between a lambda’s own written annotation (a
param’s : T or the lambda’s : R return annotation) and its
body-derived type (issue #1994, RULED 2026-08-01, closing #1932: “the
written annotation takes priority… an incompatible body is an eager
error at the lambda, not a deferred surprise at the call site”).
Unlike TypedAssignMismatch/DirectCallArgMismatch (both E063,
gradual/advisory — the body-derived type wins regardless, the
annotation-vs-body comparison is only ever a warning), a mismatch
recorded here is reported unconditionally as an Error-severity E174
by strict::check_lambda_annotation_mismatches — the written annotation
replaces the body-derived type at this slot (see
body::InferPass::infer_lambda’s own doc for the precedence change),
so a disagreement is never merely advisory.
Recorded only when a written annotation exists for this slot and the
body-derived type is not itself unresolved (Ty::is_unresolved) — an
unannotated slot has nothing to compare against and keeps #1910’s
unchanged body-derived-wins behavior, and an Unknown/Conflicted
body-derived type never disagrees with anything (mirrors
annotations::report_if_mismatched’s identical guard for the fn/flow
case).
Fields§
§range: TextRangeThe diagnostic site: the mismatched param’s own : T annotation
range, or the lambda’s own : R return-annotation range.
param_name: Option<String>Some(param name) for a mismatched parameter annotation, None for
the lambda’s own return annotation.
expected: TyThe written annotation’s resolved type — what now governs this slot’s type.
found: TyThe body’s own independent derivation, which disagreed.
Trait Implementations§
Source§impl Clone for LambdaAnnotationMismatch
impl Clone for LambdaAnnotationMismatch
Source§fn clone(&self) -> LambdaAnnotationMismatch
fn clone(&self) -> LambdaAnnotationMismatch
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LambdaAnnotationMismatch
impl Debug for LambdaAnnotationMismatch
impl Eq for LambdaAnnotationMismatch
Source§impl PartialEq for LambdaAnnotationMismatch
impl PartialEq for LambdaAnnotationMismatch
impl StructuralPartialEq for LambdaAnnotationMismatch
Auto Trait Implementations§
impl Freeze for LambdaAnnotationMismatch
impl RefUnwindSafe for LambdaAnnotationMismatch
impl Send for LambdaAnnotationMismatch
impl Sync for LambdaAnnotationMismatch
impl Unpin for LambdaAnnotationMismatch
impl UnsafeUnpin for LambdaAnnotationMismatch
impl UnwindSafe for LambdaAnnotationMismatch
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.