-
Couldn't load subscription status.
- Fork 13.9k
Only include dyn Trait<Assoc = ...> associated type bounds for Self: Sized associated types if they are provided
#140684
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
|
HIR ty lowering was modified cc @fmease |
…f they are provided
f595989 to
4f72796
Compare
| } | ||
|
|
||
| impl Other for dyn Trait {} | ||
| // `dyn Trait<Assoc = ()>` is a different "nominal type" than `dyn Traiat`. |
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.
| // `dyn Trait<Assoc = ()>` is a different "nominal type" than `dyn Traiat`. | |
| // `dyn Trait<Assoc = ()>` is a different "nominal type" than `dyn Trait`. |
|
cc @rust-lang/types this PR fixes an unintended side-effect of a larger change from #136458. r=me after nit |
4f72796 to
3799d84
Compare
|
@bors r+ rollup |
… r=lcnr Only include `dyn Trait<Assoc = ...>` associated type bounds for `Self: Sized` associated types if they are provided Since rust-lang#136458, we began filtering out associated types with `Self: Sized` bounds when constructing the list of associated type bounds to put into our `dyn Trait` types. For example, given: ```rust trait Trait { type Assoc where Self: Sized; } ``` After rust-lang#136458, even if a user writes `dyn Trait<Assoc = ()>`, the lowered ty would have an empty projection list, and thus be equivalent to `dyn Trait`. However, this has the side effect of no longer constraining any types in the RHS of `Assoc = ...`, not implying any WF implied bounds, and not requiring that they hold when unsizing. After this PR, we include these bounds, but (still) do not require that they are provided. If the are not provided, they are skipped from the projections list. This results in `dyn Trait` types that have differing numbers of projection bounds. This will lead to re-introducing type mismatches e.g. between `dyn Trait` and `dyn Trait<Assoc = ()>`. However, this is expected and doesn't suffer from any of the deduplication unsoundness from before rust-lang#136458. We may want to begin to ignore thse bounds in the future by bumping `unused_associated_type_bounds` to an FCW. I don't want to tangle that up into the fix that was originally intended in rust-lang#136458, so I'm doing a "fix-forward" in this PR and deferring thinking about this for the future. Fixes rust-lang#140645 r? lcnr
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#140095 (Eliminate `word_and_empty` methods.) - rust-lang#140341 (Clarify black_box warning a bit) - rust-lang#140684 (Only include `dyn Trait<Assoc = ...>` associated type bounds for `Self: Sized` associated types if they are provided) - rust-lang#140707 (Structurally normalize in range pattern checking in HIR typeck) - rust-lang#140716 (Improve `-Zremap-path-scope` tests with dependency) - rust-lang#140800 (Make `rustdoc-tempdir-removal` run-make tests work on other platforms than linux) - rust-lang#140802 (Add release notes for 1.87.0) - rust-lang#140811 (Enable triagebot note functionality for rust-lang/rust) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#140684 - compiler-errors:unnecessary-assoc, r=lcnr Only include `dyn Trait<Assoc = ...>` associated type bounds for `Self: Sized` associated types if they are provided Since rust-lang#136458, we began filtering out associated types with `Self: Sized` bounds when constructing the list of associated type bounds to put into our `dyn Trait` types. For example, given: ```rust trait Trait { type Assoc where Self: Sized; } ``` After rust-lang#136458, even if a user writes `dyn Trait<Assoc = ()>`, the lowered ty would have an empty projection list, and thus be equivalent to `dyn Trait`. However, this has the side effect of no longer constraining any types in the RHS of `Assoc = ...`, not implying any WF implied bounds, and not requiring that they hold when unsizing. After this PR, we include these bounds, but (still) do not require that they are provided. If the are not provided, they are skipped from the projections list. This results in `dyn Trait` types that have differing numbers of projection bounds. This will lead to re-introducing type mismatches e.g. between `dyn Trait` and `dyn Trait<Assoc = ()>`. However, this is expected and doesn't suffer from any of the deduplication unsoundness from before rust-lang#136458. We may want to begin to ignore thse bounds in the future by bumping `unused_associated_type_bounds` to an FCW. I don't want to tangle that up into the fix that was originally intended in rust-lang#136458, so I'm doing a "fix-forward" in this PR and deferring thinking about this for the future. Fixes rust-lang#140645 r? lcnr
|
Accepting for beta backport (directly into the stable PR) given the vote in Zulip. |
[stable] Prepare the 1.87.0 release Preparing the stable artifacts as described in the release process. This PR also includes the following last minute backports: * rust-lang#140810 * rust-lang#140601 * rust-lang#140684 r? `@ghost`
[stable] Prepare the 1.87.0 release Preparing the stable artifacts as described in the release process. This PR also includes the following last minute backports: * rust-lang#140810 * rust-lang#140601 * rust-lang#140684 r? `@ghost`
Since #136458, we began filtering out associated types with
Self: Sizedbounds when constructing the list of associated type bounds to put into ourdyn Traittypes. For example, given:After #136458, even if a user writes
dyn Trait<Assoc = ()>, the lowered ty would have an empty projection list, and thus be equivalent todyn Trait. However, this has the side effect of no longer constraining any types in the RHS ofAssoc = ..., not implying any WF implied bounds, and not requiring that they hold when unsizing.After this PR, we include these bounds, but (still) do not require that they are provided. If the are not provided, they are skipped from the projections list.
This results in
dyn Traittypes that have differing numbers of projection bounds. This will lead to re-introducing type mismatches e.g. betweendyn Traitanddyn Trait<Assoc = ()>. However, this is expected and doesn't suffer from any of the deduplication unsoundness from before #136458.We may want to begin to ignore thse bounds in the future by bumping
unused_associated_type_boundsto an FCW. I don't want to tangle that up into the fix that was originally intended in #136458, so I'm doing a "fix-forward" in this PR and deferring thinking about this for the future.Fixes #140645
r? lcnr