#rustlang isn't `Arc<dyn Trait>: Sized`? I'm getting a Sized error with an Impl on actix_web's `trait FromRequest: Sized {...}` With a type where `T` in `struct MyStruct<T, K>(T, K)` is `Arc<dyn Trait + 'static>`. Still unable to minimize in playground :(
-
Show this thread
-
Figured it out: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=220ca6db5a25f8d0499ce0ed886f8f8d … The fix is in the comment delimited by /* */. I was very confused how that line could fail, and the next could not.
1 reply 0 retweets 2 likesShow this thread -
Replying to @Nashenas88
`Arc<dyn Trait>` is `Sized`. If you post the full compiler output I can probably help more, but this likely means you're trying to rely on a trait impl which looks like `impl<T> SomeTrait for Arc<T> where T: SomeTrait`, which requires the thing in the Arc is sized
1 reply 0 retweets 1 like -
Replying to @sgrif
The output in the playground is all I was seeing in my more complicated case. The fix was literally adding the `?Sized` bound (by uncommenting the /* comment in the minified example above). What was not obvious to me, is why that was necessary, since using the line below that
2 replies 0 retweets 0 likes -
Replying to @Nashenas88 @sgrif
I could uncomment the // line and it would compile fine. In my actual code, the Arc was important, so I couldn't use the line below.
1 reply 0 retweets 0 likes
Right, because `Arc<T>` is sized. When you write `impl<T> MustSized for Injected<Arc<T>>`, it's the same as if you wrote `impl<T: Sized> MustSized for injected<Arc<T>>`. Since `dyn Trait` isn't `Sized`, it doesn't apply. Adding `T: ?Sized` cancels the implied sized bound
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.