External Publication
Visit Post

Method auto-(de)ref (and lack of it) in RFC 132 ufcs

Rust Internals [Unofficial] February 14, 2026
Source

Hmm, RFC 132 explicitly says this:

  • It is sometimes desirable not to have autoderef:
  • For methods like clone() that apply to almost all types, it is convenient to be more specific about which precise type you want to clone. To get this right with autoderef, one must know the precise rules being used, which is contrary to the "DWIM" intention.
  • For types that implement Deref<T>, UFCS can be used to unambiguously differentiate between methods invoked on the smart pointer itself and methods invoked on its referent.

Because the self parameter loses its magic in UFCS (because that’s what UFCS means), it would be extremely surprising for the first argument to auto-ref/deref, which doesn’t happen with non-method associated functions that are called identically.

Discussion in the ATmosphere

Loading comments...