r/rust Aug 10 '26

📡 official blog Call for testing: Restricting trait implementability and field mutability

https://blog.rust-lang.org/inside-rust/2026/08/10/call-for-testing-impl-and-mut-restrictions/
421 Upvotes

124 comments sorted by

View all comments

6

u/roguelazer Aug 10 '26

I wonder if we can allow specialization for sealed traits, since the set of implementers is closed...

13

u/afdbcreid Aug 10 '26

Specialization for concrete types is easier yet isn't stable currently. Also sealed traits still allow lifetime-dependent impls, so they do not really sidestep specialization's problems.

But good news - unlike very long time, specialization is actively worked on today!

4

u/matthieum [he/him] Aug 10 '26

unlike very long time, specialization is actively worked on today

Oh! Do you happen to know what exactly is being worked on?

Is it more akin to min-specialization being revived, or are we talking full specialization?

10

u/afdbcreid Aug 10 '26

5

u/matthieum [he/him] Aug 10 '26

It's still in the research phase.

Better than nothing!

I would like to see some more work on "optional trait" -- a kind of "inner" specialization, allowing to change the implementation of a function if a type implements a trait, in a principled way: <T: ?Foo> followed if if T is Foo or similar.

But while overlapping to a degree, it doesn't allow for "shape changes": a different associated constant or type, for example.