-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Cannot dyn upcast to target w/ auto traits implied by source's principal's supertraits #119335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
Comments
I'll fix it. @rustbot claim |
This would be awesome, thank you so much for looking into it! ❤️ |
This includes the previously unsupported |
@crlf0710: Yes, if |
21 tasks
trait AnySendSync: Any + Send + Sync {}
impl<T: Any + Send + Sync> AnySendSync for T {}
fn main() {
let ptr = &() as &dyn AnySendSync;
// Compile error, unless you remove the "+ Send + Sync" part
let ptr = ptr as &(dyn Any + Send + Sync);
} |
This got fixed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
Originally posted by @Ekleog in #65991 (comment)
I just tried using this feature to upcast to
Any + Send + Sync
, and it seems to me like this is currently not allowed:(playground link)
With references, the situation does not seem better than with
Arc
: this does not compile either(playground link)
Is this expected? I can't find any reference to this limitation, neither explicitly in the RFC text nor in this tracking issue. The RFC text does mention not supporting upcasting to multiple traits, but I'd have expected lifetimes as well as auto traits to not be included in the limitation.
If it is expected that this feature is stabilized without this support, does anyone know where I should watch, to know of the news on that front?
Minimized:
We should be able to upcast to a dyn type w/ auto-traits that show up in the principal's supertraits too.
The text was updated successfully, but these errors were encountered: