-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Change opaque types to not be structural match. #72156
Comments
The same problem probably also exists for |
I don't know what "leak" means. But forbidding it for now seems best. :D |
This is what I've meant with "leak": fn test<T: Sync>(_: T) {}
fn ok() -> impl Eq {
7
}
fn not_ok() -> impl Eq {
std::cell::Cell::new(7)
}
fn main() {
test(ok());
// This works, `ok` returns a type implementing `Sync`.
//
// Note that we do not explicitly mention `Send` in the return type of `ok`.
test(not_ok());
// This fails, `not_ok` returns a type not implementing `Sync`.
} |
Ah I see -- auto traits are "leaked" through opaque ("impl Trait") types.
|
I don't see the connection between auto traits and leaking through opaque types rn. fn int() -> impl Send {
7
}
fn main() {
let _x: i32 = int().wrapping_add(7);
} |
AFAIK all auto traits currently leak through opaque types ( |
Didn't know we leak |
#72153 now explicitly changes opaque types to not be structural match. In case there is a use case where we want to change this, we can open a new issue. |
The following currently passes the structural match check and causes an ICE later on:
(now that #72153 has landed, this emits an error)
I believe we have to either leak the structural match property of opaque types,
(similar to
Send
andSync
afaict) or forbid this entirely.I am in favor of the second option for now. It should not be a breaking change to go from the
second to the first later on.
This issue concerns the implementation in #72153
@eddyb @pnkfelix @RalfJung
The text was updated successfully, but these errors were encountered: