Skip to content

Tail-position tmp().1 is refused as an implicit field move (D32) while the same expression is accepted as a call argument #1281

Closed

Description

@ehartford

Found writing a debug-alloc fixture for PR #1275 (a facade constructor returns (status, R)). Worked around with let (_, s) = …; s; filed, not fixed.

Repro (installed with, main 478b264 + #1274)

type R { n: i32 }
impl Drop for R:
    move fn drop(): print("drop")
fn make() -> (i32, R): (0, R { n: 1 })
fn take(r: R) -> i32: r.n
fn give() -> R: make().1
fn main:
    print(f"{take(make().1)} {give().n}")
error: a field never moves out implicitly (§2.2, D32)
 --> vac.w:6:17
6 | fn give() -> R: make().1
  |                 ^^^^^^^^
  = help: clone it (`make().1.clone()`), or restructure so the owner transfers it — a vacate needs a `var` base or a `mut fn` receiver

With give removed, take(make().1) is accepted and runs (drop, 1): the same expression — element 1 of an rvalue tuple temporary — is a legal owned argument but not a legal tail/return value.

Expected vs actual

Spec §2.2 (D32) forbids the implicit vacate of a field through a place and asks for a mutable path (var base or mut fn receiver); §9.6 says rvalue receivers become statement temporaries under the ordinary move and temporary-drop rules (§2.2, §2.4). A make().1 base is not a place the caller could keep whole — the temporary is the sole owner and dies at statement end — and the compiler already treats it that way in argument position. Expected: the two positions agree. Either both accept (the temporary transfers its element; its other element drops at statement end) or both refuse with the same diagnostic; the fix-it's advice (var base / mut fn receiver) cannot be followed for a temporary either way. Actual: accepted as an argument, refused as a tail expression.

Activity

  1. added a commit that references this issue on Sep 22, 2026
  2. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Verified fixed on main 55739d4 (release binary): both positions get "a field never moves out implicitly (§2.2, D32)".

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