-
Notifications
You must be signed in to change notification settings - Fork 74
Description
Metadata | |
---|---|
Point of contact | @nikomatsakis |
Team(s) | compiler, lang |
Goal document | 2025h2/ergonomic-rc |
Summary
We propose to write an alternative RFC for ergonomic ref-counting that makes lightweight cloning automatic and hold design meetings so the lang team can compare both approaches. This work builds on RFC #3680, which proposed a new keyword, use
, that could be used with closures (use || ...
) and expressions like x.use
to help address a longstanding problem: working with ref-counted data structures like Arc<T>
is verbose and confusing.
The 2025H1 work delivered .use
syntax that works technically, but community feedback on the RFC pointed out a tension: if we're trying to improve ergonomics, why add more required syntax? We'll write an RFC exploring the automatic approach, complete the implementation work needed to support it, and run design meetings to help the lang team decide. This will tell us about the impact on user experience and performance, how well we can catch problematic cases, and which approach works better for Rust developers working with ref-counted data.
Tasks and status
- Author alternative RFC (@nikomatsakis)
- Complete seamless implementation (@spastorino)
- Standard reviews (compiler
)
- Design meeting (lang
)
- RFC decision (lang
)
Note: we have updated the body to match the 2025h2 goal. Your original text is preserved below.
Metadata | |
---|---|
Point of contact | @spastorino |
Team(s) | lang |
Goal document | 2025h1/ergonomic-rc |
Summary
- Deliver a nightly implementation of the experimental
use
syntax for ergonomic ref-counting. - RFC decision on the above
Tasks and status
- Implementation (@spastorino)
- Reviews (@nikomatsakis)
- Lang-team champion (lang
)
- Author RFC (@joshtriplett)
- Introduce
x.use
anduse ||
syntax andUseCloned
trait (Ergonomic ref counting rust#134797). - Modify codegen so that we guarantee that
x.use
will do a copy ifX: Copy
is true after monomorphization. Right now the desugaring toclone
occurs before monomorphization and hence it will call theclone
method even for those instances whereX
is aCopy
type. - Convert
x.use
to a move rather than a clone if this is a last-use. - Make
x
equivalent tox.use
but with an (allow-by-default) lint to signal that something special is happened.
Metadata
Metadata
Assignees
Type
Projects
Status