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
Since any value can be converted to an Any trait object, you can run into subtle bugs where you put the wrong value behind the Any:
use std::any::Any;structFoo;fnmain(){let x:Box<Foo> = Box::new(Foo);letmut y:Box<Any> = x;let z:&mutAny = &mut*y;// remove the `*` and the next line panicslet a:&mutFoo = z.downcast_mut().unwrap();// panics if `z` contains `Box<Any>` instead of `Any`}
We should be linting all coercions of references/boxes to Any to a reference to Any. Especially around double references and similar this seems like it can go south very fast
The text was updated successfully, but these errors were encountered:
Since any value can be converted to an
Any
trait object, you can run into subtle bugs where you put the wrong value behind theAny
:We should be linting all coercions of references/boxes to
Any
to a reference toAny
. Especially around double references and similar this seems like it can go south very fastThe text was updated successfully, but these errors were encountered: