-
Notifications
You must be signed in to change notification settings - Fork 14k
Description
What is wrong?
Since type_id() is stable rust programs rely on Any to be implemented correctly for rust safety relevant thinks (like downcast).
Given the coding guide lines Any needs to be a unsafe-to-implement trait as implementing it wrongly causes unsafety.
Is it a problem?
Luckily no on can (currently) implement Any per-hand as any implementation conflicts with it's wild card implementations this means:
- All impl. of
Anyhappen to be correct. - We can change it without causing breakage, at last as far as I can tell.
Why should we change it?
The std is often used as an example for how thinks are done correctly in rust. If it is unsafe people looking at it would potentially think about why it needs to be unsafe and learn something from it. But if it isn't they might be surprised when there Any like trait is leads to unsafe behavior.
What if we can't change it?
I think we can, as practically no one can implement any by hand. But if we can't we should at last document that it should be any in it's rust doc.