Skip to content

closure_span_overlaps_error missing CoroutineClosure, worse async closure diagnostics #484

@SebTardif

Description

@SebTardif

Bug

closure_span_overlaps_error in compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs:489 matches ty::Closure(def_id, _) | ty::Coroutine(def_id, ..) but is missing ty::CoroutineClosure(def_id, ..).

When an async closure has a signature mismatch error and the closure span overlaps the error span, this function fails to recognize the CoroutineClosure type variant. It returns false instead of true, causing the fulfillment error adjustment logic to skip the async closure. This can lead to less precise error messages for async closure signature mismatches.

Code at fault

// adjust_fulfillment_errors.rs:489
ty::Closure(def_id, _) | ty::Coroutine(def_id, ..) =>
    expected_trait_ref.self_ty().kind()

Missing: ty::CoroutineClosure(def_id, ..)

Pattern

Same CoroutineClosure-missing-from-match pattern as #477, #478, #479, #483. The CoroutineClosure TyKind variant was added for async closures but many match sites were not updated.

Severity

Diagnostic-only. Affects error message quality for async closure signature mismatches, not correctness of compilation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsCompiler diagnosticsA-type-systemType systemI-wrongWrong result or data corruptionP-lowLow impact: edge case or niche scenariobugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions