File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,16 @@ use crate::intrinsics;
7474/// See the [module-level documentation][mod] for more details.
7575///
7676/// [mod]: index.html
77+ // This trait is not unsafe, though we rely on the specifics of it's sole impl's
78+ // `type_id` function in unsafe code (e.g., `downcast`). Normally, that would be
79+ // a problem, but because the only impl of `Any` is a blanket implementation, no
80+ // other code can implement `Any`.
81+ //
82+ // We could plausibly make this trait unsafe -- it would not cause breakage,
83+ // since we control all the implementations -- but we choose not to as that's
84+ // both not really necessary and may confuse users about the distinction of
85+ // unsafe traits and unsafe methods (i.e., `type_id` would still be safe to call,
86+ // but we would likely want to indicate as such in documentation).
7787#[ stable( feature = "rust1" , since = "1.0.0" ) ]
7888pub trait Any : ' static {
7989 /// Gets the `TypeId` of `self`.
You can’t perform that action at this time.
0 commit comments