You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tail-position tmp().1 is refused as an implicit field move (D32) while the same expression is accepted as a call argument #1281
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
Fix #1280 (Box[T].ptr reads the payload's first field) and #1281 (ele…
ehartford commentedon Sep 26, 2026
Verified fixed on main 55739d4 (release binary): both positions get "a field never moves out implicitly (§2.2, D32)".