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
{{ message }}
Repository navigation
Additional trait restrictions prevent use of trait methods #44064
I would expect main_3 to compile, because main_2 compiles, however main_3 fails to compile with the error
error[E0599]: no method named `downcast_ref` found for type `&std::boxed::Box<std::any::Any + std::marker::Send + std::marker::Sync>` in the current scope
--> src/main.rs:23:19
|
23 | let foo = foo.downcast_ref::<Foo>().unwrap();
| ^^^^^^^^^^^^
error: aborting due to previous error(s)
error:Could not compile `playground`.To learn more, run the command again with --verbose.
I guess the question is "should adding a provided method on a trait be a breaking change for multi-trait trait objects in the event that ambiguity between methods for multiple traits is introduced by the provided method's presence?" Which I think the answer is no, so yeah it makes sense to prevent method calls in this way, but perhaps the compiler could give a better syntax hint as to what should be done instead.
I wouldn't be opposed to an impl for Any + Send + Sync but I also don't think it's terribly necessary.
Activity
kennytm commentedon Aug 23, 2017
Any + Sendalso works, since there is animplfor it. This needs a separateimpldue to #23423, in order to fix #18737.So to fix this we just need to forward
Any + SyncandAny + Send + Syncalso.Xaeroxe commentedon Aug 23, 2017
After thoughts on filing this issue:
I guess the question is "should adding a provided method on a trait be a breaking change for multi-trait trait objects in the event that ambiguity between methods for multiple traits is introduced by the provided method's presence?" Which I think the answer is no, so yeah it makes sense to prevent method calls in this way, but perhaps the compiler could give a better syntax hint as to what should be done instead.
I wouldn't be opposed to an impl for
Any + Send + Syncbut I also don't think it's terribly necessary.Xaeroxe commentedon Aug 23, 2017
So I'm going to close this issue.