-
Notifications
You must be signed in to change notification settings - Fork 14k
Use the new solver in the impossible_predicates
#136988
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| //@ run-pass | ||
| //@ revisions: current next | ||
| //@ ignore-compare-mode-next-solver (explicit revisions) | ||
| //@[next] compile-flags: -Znext-solver | ||
|
|
||
| trait Id { | ||
| type This<'a>; | ||
| } | ||
| impl<T> Id for T { | ||
| type This<'a> = T; | ||
| } | ||
|
|
||
| trait Trait<T> {} | ||
| impl<T: Id> Trait<for<'a> fn(T::This<'a>)> for T {} | ||
|
|
||
| trait Method<T: Id> { | ||
| fn call_me(&self) | ||
| where | ||
| T: Trait<for<'a> fn(T::This<'a>)>; | ||
| } | ||
|
|
||
| impl<T, U> Method<U> for T { | ||
| fn call_me(&self) { | ||
| println!("method was reachable"); | ||
| } | ||
| } | ||
|
|
||
| fn generic<T: Id>(x: &dyn Method<T>) { | ||
| // Proving `T: Trait<for<'a> fn(T::This<'a>)>` holds. | ||
| x.call_me(); | ||
| } | ||
|
|
||
| fn main() { | ||
| // Proving `u32: Trait<fn(u32)>` fails due to incompleteness. | ||
| // We don't add the method to the vtable of `dyn Method`, so | ||
| // calling it causes UB. | ||
| generic::<u32>(&()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is that the right understanding of what's going on here? And then its just generally unsound for checking impossible preds to consider preds to be impossible if they actually aren't.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. In other words, the impossible preds query needs to be complete b/c we use "this goal is impossible to satisfy" responses to skip monomorphizing items with bad where clauses in codegen. Here in vtable, but also as monomorphization roots, etc. |
||
| } | ||
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.
It feels kind of weird to be using the new trait solver "because its more complete" while also using a typing mode that is allowed to be incomplete (unlike coherence mode). I guess it is also true that the not-required-to-be-complete solver modes in the new solver should less incomplete than the not-required-to-be-complete-solver-modes in the old solver. So still a good change and it being weird is kind of pre-existing.
Do we expect the trait solver to always be complete even outside of coherence in some specific circumstances? What are those circumstances?
Uh oh!
There was an error while loading. Please reload this page.
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 think the following is required in all
TypingModeSo we'd have "
for<T: Clone> Foo<T>: CloneimpliesFoo<u32>: Clone" and "Foo<?x>: CloneimpliesFoo<Vec<u32>>: Clone".I am not totally sure whether
Foo<?x>: CloneimpliesFoo<Vec<?x>>: Cloneand think that not doing so wouldn't be unsound, just questionable.