-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Incorrect object-safety with where Option<Self>: Sized
#25204
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Another weird case: fn weird<T: ?Sized>(_: Option<T>) where Option<T>: Sized {}
fn main() {} Error:
|
The compiler does not deduce |
@arielb1 I pretty much figured out that the compiler only sometimes does that. I would prefer it to always do it, or never do it. I expect the current code to have a compile error on this line: let y: Box<Foo> = x; |
I have realized that the However, this code somehow compiles: |
@theemathas Hm, I'd expect that code to compile, and only allow instance of |
Possibly related to #19182 |
Its not the same issue, but the problem is that object safety does not consider non-supertrait predicates. |
related to #27675 |
I think the compiler is now properly flagged this code under the warnings issued by RFC 1214: trait OptSelfSized where Option<Self>: Sized { } yields:
|
This appears to be fixed, but I'm not certain. |
Closing, please reopen if this is still an issue. |
Code:
playpen
I'm not sure which line is the compiler wrong, but this combination of compile successes/failures is very inconsistent.
The text was updated successfully, but these errors were encountered: