Skip to content

Method call on a bare Type.Variant path receiver fails MIR lowering (S.A.tag()) #1310

Closed

Description

@ehartford

Found while writing the #1289 behavior test.

A method call whose receiver is a bare unit-variant path fails to lower; binding the variant first works.

enum S { A | B(i32) }
impl S:
    fn tag(self: &Self) -> i32: 1
fn main:
    let x = S.A
    print(f"{x.tag()}")      // ok
    print(f"{S.A.tag()}")    // MIR lowering failed
error: MIR lowering failed for function 'main' in r_path.w; AST codegen was removed, so this function cannot be compiled
WITH_MIR_AUDIT=1: [mir-lower-fail] kind=27 (NK_CALL) fn=main span=266..275

Reproduces on the installed with (main at bbb9c5b) with a hand-written impl, so it is independent of @[derive]. Expected: an rvalue receiver of a unit variant lowers like let x = S.A; x.tag() (§9.7 / §11).

Workaround: bind the variant to a local first (the #1289 test does this).

Activity

  1. added 2 commits that reference this issue on Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions