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
Rollup merge of #156828 - P8L1:share-trait-core-bootstrap, r=SimonSapin
Add unstable Share trait
Tracking issue: #156756
This adds an initial unstable `Share` trait for clone-as-alias types, as part of the 2026 ergonomic ref-counting project goal.
```rust
pub trait Share: Clone {
fn share(&self) -> Self {
Clone::clone(self)
}
}
```
This PR adds a separate unstable feature gate:
```rust
#![feature(share_trait)]
```
and places the trait next to `Clone` in `core::clone`.
Implemented initial impls:
- `impl<T: ?Sized> Share for &T`
- `impl<T: ?Sized, A: Allocator + Clone> Share for Rc<T, A>`
- `impl<T: ?Sized, A: Allocator + Clone> Share for Arc<T, A>`
- `impl<T> Share for std::sync::mpsc::Sender<T>`
- `impl<T> Share for std::sync::mpsc::SyncSender<T>`
The PR deliberately does not add `Share` to the prelude.
r? @nikomatsakis@rustbot label F-ergonomic_clones
Copy file name to clipboardExpand all lines: tests/ui/README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1244,6 +1244,10 @@ In this directory, multiple crates are compiled, but some of them have `inline`
1244
1244
1245
1245
Tests on name shadowing.
1246
1246
1247
+
## `tests/ui/share-trait`
1248
+
1249
+
Tests for the unstable `Share` trait.
1250
+
1247
1251
## `tests/ui/shell-argfiles/`: `-Z shell-argfiles` command line flag
1248
1252
1249
1253
The `-Zshell-argfiles` compiler flag allows argfiles to be parsed using POSIX "shell-style" quoting. When enabled, the compiler will use shlex to parse the arguments from argfiles specified with `@shell:<path>`.
0 commit comments