-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[WIP] Enforce may-define-must-define for ATPITs #123046
[WIP] Enforce may-define-must-define for ATPITs #123046
Conversation
@@ -78,6 +82,24 @@ impl<'tcx> RegionInferenceContext<'tcx> { | |||
} | |||
} | |||
} | |||
|
|||
if !infcx.tcx.is_typeck_child(anchor.to_def_id()) { |
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.
Specifically, we can't enforce this on typeck children because it would mean that the given code fails:
trait Foo {
type Assoc;
fn foo() -> Self::Assoc;
}
impl Foo for () {
type Assoc = impl Sized;
fn foo() -> Self::Assoc {
let x = || {};
// ^^^^^ <- this body doesn't define `Self::Assoc`, even though it could.
""
}
}
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.
Do you have thoughts either, @aliemjay? 🤔
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 don't remember if this landed, but I once had a commit where opaques from children got copied into their parents during borrowck. Then we could stop looking at children entirely. Well, modulo opaques that are only mentioned in the signature of children, but... oh we don't have ATPIT tests for that, do we
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.
We don't collect opaques for typeck children anyways:
trait Foo {
type Assoc;
fn foo();
}
impl Foo for () {
type Assoc = impl Sized;
fn foo() {
let x = || -> Self::Assoc {
""
};
}
}
error[E0308]: mismatched types
--> src/lib.rs:12:9
|
9 | type Assoc = impl Sized;
| ---------- the expected opaque type
...
12 | ""
| ^^ expected opaque type, found `&str`
|
= note: expected opaque type `<() as Foo>::Assoc`
found reference `&'static str`
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.
And I don't think we want to -- since if we don't, then we only need to check that the typeck root defines the given opaques.
@@ -42,12 +43,15 @@ impl<'tcx> RegionInferenceContext<'tcx> { | |||
/// Check that all opaque types have the same region parameters if they have the same | |||
/// non-region parameters. This is necessary because within the new solver we perform various query operations | |||
/// modulo regions, and thus could unsoundly select some impls that don't hold. | |||
fn check_unique( | |||
fn check_unique_and_defined( |
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.
TODO: comment
@@ -78,6 +82,24 @@ impl<'tcx> RegionInferenceContext<'tcx> { | |||
} | |||
} | |||
} | |||
|
|||
if !infcx.tcx.is_typeck_child(anchor.to_def_id()) { |
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.
Do you have thoughts either, @aliemjay? 🤔
The job Click to see the possible cause of the failure (guessed by this bot)
|
☔ The latest upstream changes (presumably #116891) made this pull request unmergeable. Please resolve the merge conflicts. |
OK well I'm never actually gonna work on this. Sorry @oli-obk, feel free to take over 🫡 |
Putting this up in an incomplete state because I've got some concerns
r? oli-obk