Skip to content

coercion becomes order dependent for higher-ranked functions #73154

Open
@nikomatsakis

Description

@nikomatsakis

#72493 revealed an interesting interaction between coercion, the universe transition (#56105), and the transition to NLL (#57895). What happens in the old-lub-glb-hr-noteq[12].rs tests introduced by that PR is:

  • We have to compute the "coercion LUB" of fn('a, 'b) -> 'a and fn('a, 'a) -> 'a. The "correct answer" is fn('a, 'a) -> 'a. With NLL migration mode, we get a hard error always, but once we enable the NLL mode, our answer depends on the order of the match arms.
  • The reason is that the coercion code finds that it can create a subtype for either order, so it produces a result that depends on the ordering. That same code introduces a "equality" requirement in migration mode that results in an error no matter what. But when those errors are suppressed, we generate NLL, and we only enforce subtyping, which either works or doesn't, depending on what type was chosen.

How should we fix this?

  • Keep the error? Unfortunate.
  • Extend the leak check so it can distinguish these two types correctly and make the coercion code do a "evaluate" that includes a leak check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions