-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases #103488
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still unsound when equating two opaque types with the same DefId
during coherence, similar to #102048. With the current setup that might be difficult to fix, though I might be wrong.
We can land this PR and then I can try to write an example and open an issue.
fn eq(&self, _other: &(Foo, i32)) -> bool { | ||
true | ||
} | ||
} | ||
|
||
fn foo() -> Foo { | ||
//~^ ERROR can't compare `Bar` with `(Bar, i32)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected, still weird 😁
87bc33e
to
a41f93a
Compare
error[E0119]: conflicting implementations of trait `Bop` for type `Bar<()>` | ||
--> $DIR/impl_trait_for_same_tait.rs:27:1 | ||
| | ||
LL | impl Bop for Bar<()> {} | ||
| -------------------- first implementation here | ||
... | ||
LL | impl Bop for Barr { | ||
| ^^^^^^^^^^^^^^^^^ conflicting implementation for `Bar<()>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure yet how to improve this diagnostic beyond looking at the entries in take_opaque_types()
and doing some guessing for common cases.
a41f93a
to
86dc770
Compare
☔ The latest upstream changes (presumably #103727) made this pull request unmergeable. Please resolve the merge conflicts. |
86dc770
to
4d7c724
Compare
This comment has been minimized.
This comment has been minimized.
4d7c724
to
b8a45f6
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
☔ The latest upstream changes (presumably #101834) made this pull request unmergeable. Please resolve the merge conflicts. |
b8a45f6
to
c67ec50
Compare
@@ -809,6 +831,10 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> { | |||
true | |||
} | |||
|
|||
fn mark_ambiguous(&mut self) { | |||
bug!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that should be reachable when using generic const exprs when relating a const inference var (from a const param) with an unevaluated constant during coherence
This comment has been minimized.
This comment has been minimized.
5b9d06f
to
1e768de
Compare
200226d
to
8774fa8
Compare
…ect unsound cases
☔ The latest upstream changes (presumably #103491) made this pull request unmergeable. Please resolve the merge conflicts. |
…lally allow trait resolution to prove false things during coherence
8774fa8
to
603a83b
Compare
603a83b
to
c16a90f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me
|
||
// Ok because `i32` does not implement `Dummy`, | ||
// so it can't possibly be the hidden type of `F`. | ||
impl Test for i32 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does that work? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when coherence is checking whether F
conflicts with i32
we register i32
as the hidden type of F
and that fails because i32: !Dummy
but F = impl Dummy
.
@bors r=lcnr |
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases r? `@lcnr` fixes rust-lang#99840
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases r? ``@lcnr`` fixes rust-lang#99840
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases r? ```@lcnr``` fixes rust-lang#99840
…earth Rollup of 6 pull requests Successful merges: - rust-lang#103488 (Allow opaque types in trait impl headers and rely on coherence to reject unsound cases) - rust-lang#104359 (Refactor must_use lint into two parts) - rust-lang#104612 (Lower return type outside async block creation) - rust-lang#104621 (Fix --extern library finding errors) - rust-lang#104647 (enable fuzzy_provenance_casts lint in liballoc and libstd) - rust-lang#104750 (Bump `fd-lock` in `bootstrap` again) Failed merges: - rust-lang#104732 (Refactor `ty::ClosureKind` related stuff) r? `@ghost` `@rustbot` modify labels: rollup
This PR was a perf regression (see the report here #104758 (comment)). It's relatively small and mostly limited to secondary workloads so I'm marking as triaged. |
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases r? ````@lcnr```` fixes rust-lang#99840
r? @lcnr
fixes #99840