Skip to content

Arbitrary Self Types #619

Description

@tomassedovic
Metadata
Point of contact @dingxiangfei2009
Team(s) lang, lang-docs, libs, libs-api, types
Goal document 2026/arbitrary-self-types

Summary

It is possible to create custom smart pointers by implementing the Deref trait. However, the standard library types are able to do things user-defined pointers can't. For example, acting as a method receiver (self etc.) or turning a concrete type implementing a custom Trait to a dyn Trait.

These limitations are of particular importance to low-level systems (e.g. Rust for Linux) and cross-language interoperability (e.g. when designing a reference to C++ objects).

We want to stabilize these features to reduce the gap between smart pointers in the standard library and user-defined ones.

These features are all interconnected and depend on one another so we're proposing a single goal that makes user-defined smart pointers on par with the ones in the standard library.

Tasks and status


Note: we have updated the body to match the 2026 goal. Your original text is preserved below.

Details

Metadata
Point of contact @dingxiangfei2009
Team(s) lang, lang-docs, libs, libs-api, types
Goal document 2026/arbitrary-self-types

Summary

It is possible to create custom smart pointers by implementing the Deref trait. However, the standard library types are able to do things user-defined pointers can't. For example, acting as a method receiver (self etc.) or turning a concrete type implementing a custom Trait to a dyn Trait.

These limitations are of particular importance to low-level systems (e.g. Rust for Linux) and cross-language interoperability (e.g. when designing a reference to C++ objects).

We want to stabilize these features to reduce the gap between smart pointers in the standard library and user-defined ones.

These features are all interconnected and depend on one another so we're proposing a single goal that makes user-defined smart pointers on par with the ones in the standard library.

Tasks and status

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions