-
Couldn't load subscription status.
- Fork 13.9k
Rework unsizing coercions in the new solver #147840
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
Conversation
|
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor changes to |
This comment has been minimized.
This comment has been minimized.
|
can you split the old solver custom fulfillment loop out into its own function? named something that makes it clear that its old solver specific too |
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.
please add comments to the added tests explaining why we've added them and also link to the relevant issues
| fn foo<'a>(x: Box<dyn Trait<'a>>) -> Box<dyn Super<'a>> { | ||
| x | ||
| //~^ ERROR type annotations needed: cannot satisfy `dyn Trait<'_>: Unsize<dyn Super<'_>> | ||
| } |
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.
why does this one not use revisions?
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.
good question 🤔 it should get some :)
9846ace to
316479a
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
316479a to
4b66d2b
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
4b66d2b to
29f04e0
Compare
This comment has been minimized.
This comment has been minimized.
29f04e0 to
f2d7236
Compare
f2d7236 to
95200bf
Compare
|
@rustbot review |
| && let ty::Infer(ty::TyVar(vid)) = *pred.self_ty().skip_binder().kind() | ||
| && self.fcx.type_var_is_sized(vid) | ||
| { | ||
| // Here we detected that an unszing to `dyn Trait` is possible, yay! |
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 comment does not quite seem right 🤔
So what's going on is that we end up with a coercion from ?is_sized to some dyn Trait. The only way that can succeed is via unsizing, so we just unsize here. If we don't know whether the infer var has to be Sized, this could also just end up being an ordinary assignment, in which case trying to coerce would be wrong.
As the error messages when coercing where we shouldn't are worse than the error messages when not coercing when we should, we fall back to equality/subtyping if it's unclear whether we should coerce
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.
hmm, I think I understand what you mean here, and I think the comment explains that better now
|
pls link to the fixed trait-system-refactor-initiative issues 😁 |
95200bf to
1756622
Compare
|
@rustbot review |
|
@bors r+ |
…=lcnr Rework unsizing coercions in the new solver Replaces rust-lang#141926, contains: - a commit adding tests that fail before this work - the two commits from the previous PR - a commit in which these tests are fixed - finally, a fixup for an in my opinion rather large regression in diagnostics. It's still not perfect, but better? I hope this is roughly what you had in mind Fixes rust-lang/trait-system-refactor-initiative#241 and rust-lang/trait-system-refactor-initiative#238, adding tests for both r? `@lcnr`
Rollup of 6 pull requests Successful merges: - #147840 (Rework unsizing coercions in the new solver) - #148139 (Add `coverage` scope for controlling paths in code coverage) - #148154 (Add a mailmap entry) - #148158 (ci: loongarch64: use medium code model to avoid relocation overflows) - #148172 (rustc-dev-guide subtree update) - #148175 (Fix typos: duplicate words in comments) r? `@ghost` `@rustbot` modify labels: rollup
…=lcnr Rework unsizing coercions in the new solver Replaces rust-lang#141926, contains: - a commit adding tests that fail before this work - the two commits from the previous PR - a commit in which these tests are fixed - finally, a fixup for an in my opinion rather large regression in diagnostics. It's still not perfect, but better? I hope this is roughly what you had in mind Fixes rust-lang/trait-system-refactor-initiative#241 and rust-lang/trait-system-refactor-initiative#238, adding tests for both r? ``@lcnr``
…=lcnr Rework unsizing coercions in the new solver Replaces rust-lang#141926, contains: - a commit adding tests that fail before this work - the two commits from the previous PR - a commit in which these tests are fixed - finally, a fixup for an in my opinion rather large regression in diagnostics. It's still not perfect, but better? I hope this is roughly what you had in mind Fixes rust-lang/trait-system-refactor-initiative#241 and rust-lang/trait-system-refactor-initiative#238, adding tests for both r? ```@lcnr```
Rollup of 14 pull requests Successful merges: - #144936 (CFI: Fix types that implement Fn, FnMut, or FnOnce) - #147185 (repr(transparent): do not consider repr(C) types to be 1-ZST) - #147840 (Rework unsizing coercions in the new solver) - #147915 (Update target maintainers android.md) - #148013 (1.91.0 release notes) - #148044 (compiletest: show output in debug logging) - #148057 (tests/ui/sanitizer/hwaddress.rs: Run on aarch64 and remove cgu hack) - #148139 (Add `coverage` scope for controlling paths in code coverage) - #148154 (Add a mailmap entry) - #148158 (ci: loongarch64: use medium code model to avoid relocation overflows) - #148166 (Re-enable macro-stepping test for AArch64) - #148172 (rustc-dev-guide subtree update) - #148175 (Fix typos: duplicate words in comments) - #148186 (rustdoc-search: add an integration test for CCI) Failed merges: - #147935 (Add LLVM realtime sanitizer) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 6 pull requests Successful merges: - #147840 (Rework unsizing coercions in the new solver) - #148139 (Add `coverage` scope for controlling paths in code coverage) - #148154 (Add a mailmap entry) - #148158 (ci: loongarch64: use medium code model to avoid relocation overflows) - #148172 (rustc-dev-guide subtree update) - #148175 (Fix typos: duplicate words in comments) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #147840 - jdonszelmann:unsizing-coercions, r=lcnr Rework unsizing coercions in the new solver Replaces #141926, contains: - a commit adding tests that fail before this work - the two commits from the previous PR - a commit in which these tests are fixed - finally, a fixup for an in my opinion rather large regression in diagnostics. It's still not perfect, but better? I hope this is roughly what you had in mind Fixes rust-lang/trait-system-refactor-initiative#241 and rust-lang/trait-system-refactor-initiative#238, adding tests for both r? ````@lcnr````
Replaces #141926, contains:
I hope this is roughly what you had in mind
Fixes rust-lang/trait-system-refactor-initiative#241 and rust-lang/trait-system-refactor-initiative#238, adding tests for both
r? @lcnr