{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreih3t5jdg4gtcluihnra6ytza62oilt6quop7tmhrv55xylpvtueoi",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mfq5aaxawbe2"
},
"path": "/t/method-auto-de-ref-and-lack-of-it-in-rfc-132-ufcs/24005#post_10",
"publishedAt": "2026-02-26T00:24:18.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"[1]",
"↩︎"
],
"textContent": "CAD97:\n\n> Thus the only version of autoref on argument position I could support would autoref not to `&[mut] $expr` semantics but instead to `&[mut] { $expr }` semantics, which puts the expression still in a value expression position, meaning that the source place gets moved from.\n\n[1]\n\nCAD97:\n\n> you can't do `f(x)` where `x: Box<i32>, f: fn(&i32)`, you need to introduce the reference yourself as `f(&x)` in order for autoderef to project through. [...] I think nowadays we could justify removing this restriction, thus allowing automatic reborrows of non-reference types, at least non-mutably.\n\nTaking these together, do you mean:\n\nGiven `t: T` and `f: fn(&U)` and `T` not `&U`, `f(t)`:\n\n * Acts like `f(&*t)` if `T: Deref<Target = U>` (or `&****t` as required etc)\n * Else acts like `f(& { t })` if `T = U`\n * (Else doesn't compile or whatever, not going to attempt being exhaustive)\n\n\n\nSo for example,\n\n\n fn g<T>(_: &T) {}\n\n fn ex(bx: Box<i32>) {\n g::<i32>(bx); // Doesn't drop `bx`: `g(&*bx)`\n g::<Box<i32>>(bx); // Drops `bx`: `g(& { bx })`\n }\n\n\nI.e. where things drop depends on probing types for `Deref` impls?\n\n* * *\n\n 1. I've seen people want that, and I think it has the same \"moved it? oops guess I'll clone\" hazards as `P: AsRef<Path>`. I'm willing to be convinced it's fine, but that's also not the actual point of this reply, hence hiding this in a footnote. ↩︎\n\n\n",
"title": "Method auto-(de)ref (and lack of it) in RFC 132 ufcs"
}