-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Dont collect assoc ty item bounds from trait where clause for host effect predicates #143895
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
Dont collect assoc ty item bounds from trait where clause for host effect predicates #143895
Conversation
This PR changes a file inside |
6eebb24
to
8daf98b
Compare
@@ -889,8 +889,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), | |||
tcx.ensure_ok().predicates_of(def_id); | |||
tcx.ensure_ok().explicit_item_bounds(def_id); | |||
tcx.ensure_ok().explicit_item_self_bounds(def_id); | |||
tcx.ensure_ok().item_bounds(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.
We don't need to ensure these queries, since they're just computed from the explicit ones we're ensuring above.
@@ -1042,8 +1040,12 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), | |||
let has_type = match assoc_item.container { | |||
ty::AssocItemContainer::Impl => true, | |||
ty::AssocItemContainer::Trait => { | |||
tcx.ensure_ok().item_bounds(def_id); | |||
tcx.ensure_ok().item_self_bounds(def_id); | |||
tcx.ensure_ok().explicit_item_bounds(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.
Ensuring the explicit flavor of the item bounds queries, and also making sure to ensure the const ones too.
@@ -124,6 +124,7 @@ fn remap_gat_vars_and_recurse_into_nested_projections<'tcx>( | |||
ty::ClauseKind::Trait(tr) => tr.self_ty(), | |||
ty::ClauseKind::Projection(proj) => proj.projection_term.self_ty(), | |||
ty::ClauseKind::TypeOutlives(outlives) => outlives.0, | |||
ty::ClauseKind::HostEffect(host) => host.self_ty(), | |||
_ => return None, |
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.
seems like a good candidate for an exhaustive match
@bors r+ |
…d-host-eff, r=oli-obk Dont collect assoc ty item bounds from trait where clause for host effect predicates For background, we uplift `where Self::Assoc: Trait` bounds in a trait's where clauses into *item bounds* on `type Assoc;`. This is because before we *had* syntactical item bounds, users would express their item bounds like so. Let's opt out of doing this same behavior for `HostEffect` predicates like `where Self::Assoc: [const] Trait`. I left a comment in the code: ```rust // FIXME(const_trait_impl): We *could* uplift the // `where Self::Assoc: [const] Trait` bounds from the parent trait // here too, but we'd need to split `const_conditions` into two // queries (like we do for `trait_explicit_predicates_and_bounds`) // since we need to also filter the predicates *out* of the const // conditions or they lead to cycles in the trait solver when // utilizing these bounds. For now, let's do nothing. ``` As an aside, this was an ICE that was only triggerable when building libraries and not binaries because we never were calling `tcx.ensure_ok().explicit_implied_const_bounds(def_id);` on associated types like we should have been. I adjusted the calls to `ensure_ok` to make sure this happens, so we catch bugs like this in the future more easily. As another aside, I fixed the bound uplifting logic for *always const* predicates, since those act like normal clauses and have no notion of conditional constness. r? ``@oli-obk`` ``@fee1-dead`` or anyone really Fixes rust-lang#133275
Rollup of 15 pull requests Successful merges: - #142304 (tests: Add `RUST_BACKTRACE` and `-Cpanic` revisions to `panic-main.rs` test) - #143388 (Various refactors to the LTO handling code) - #143409 (Enable xgot feature for mips64 musl targets) - #143592 (UWP: link ntdll functions using raw-dylib) - #143595 (add `const_make_global`; err for `const_allocate` ptrs if didn't call) - #143678 (Added error for invalid char cast) - #143820 (Fixed a core crate compilation failure when enabling the `optimize_for_size` feature on some targets) - #143829 (Trim `BorrowedCursor` API) - #143846 (pass --gc-sections if -Zexport-executable-symbols is enabled and improve tests) - #143851 (ci cleanup: rustdoc-gui-test now installs browser-ui-test) - #143856 (Linting public reexport of private dependencies) - #143895 (Dont collect assoc ty item bounds from trait where clause for host effect predicates) - #143922 (Improve path segment joining) - #143964 (Fix handling of SCRIPT_ARG in docker images) - #144016 (trait_sel: `MetaSized` always holds temporarily) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 15 pull requests Successful merges: - #142304 (tests: Add `RUST_BACKTRACE` and `-Cpanic` revisions to `panic-main.rs` test) - #143388 (Various refactors to the LTO handling code) - #143409 (Enable xgot feature for mips64 musl targets) - #143592 (UWP: link ntdll functions using raw-dylib) - #143595 (add `const_make_global`; err for `const_allocate` ptrs if didn't call) - #143678 (Added error for invalid char cast) - #143820 (Fixed a core crate compilation failure when enabling the `optimize_for_size` feature on some targets) - #143829 (Trim `BorrowedCursor` API) - #143851 (ci cleanup: rustdoc-gui-test now installs browser-ui-test) - #143856 (Linting public reexport of private dependencies) - #143895 (Dont collect assoc ty item bounds from trait where clause for host effect predicates) - #143922 (Improve path segment joining) - #143964 (Fix handling of SCRIPT_ARG in docker images) - #144002 (Update poison.rs) - #144016 (trait_sel: `MetaSized` always holds temporarily) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #143895 - compiler-errors:trait-wc-item-bound-host-eff, r=oli-obk Dont collect assoc ty item bounds from trait where clause for host effect predicates For background, we uplift `where Self::Assoc: Trait` bounds in a trait's where clauses into *item bounds* on `type Assoc;`. This is because before we *had* syntactical item bounds, users would express their item bounds like so. Let's opt out of doing this same behavior for `HostEffect` predicates like `where Self::Assoc: [const] Trait`. I left a comment in the code: ```rust // FIXME(const_trait_impl): We *could* uplift the // `where Self::Assoc: [const] Trait` bounds from the parent trait // here too, but we'd need to split `const_conditions` into two // queries (like we do for `trait_explicit_predicates_and_bounds`) // since we need to also filter the predicates *out* of the const // conditions or they lead to cycles in the trait solver when // utilizing these bounds. For now, let's do nothing. ``` As an aside, this was an ICE that was only triggerable when building libraries and not binaries because we never were calling `tcx.ensure_ok().explicit_implied_const_bounds(def_id);` on associated types like we should have been. I adjusted the calls to `ensure_ok` to make sure this happens, so we catch bugs like this in the future more easily. As another aside, I fixed the bound uplifting logic for *always const* predicates, since those act like normal clauses and have no notion of conditional constness. r? ```@oli-obk``` ```@fee1-dead``` or anyone really Fixes #133275
For background, we uplift
where Self::Assoc: Trait
bounds in a trait's where clauses into item bounds ontype Assoc;
. This is because before we had syntactical item bounds, users would express their item bounds like so.Let's opt out of doing this same behavior for
HostEffect
predicates likewhere Self::Assoc: [const] Trait
. I left a comment in the code:As an aside, this was an ICE that was only triggerable when building libraries and not binaries because we never were calling
tcx.ensure_ok().explicit_implied_const_bounds(def_id);
on associated types like we should have been. I adjusted the calls toensure_ok
to make sure this happens, so we catch bugs like this in the future more easily.As another aside, I fixed the bound uplifting logic for always const predicates, since those act like normal clauses and have no notion of conditional constness.
r? @oli-obk @fee1-dead or anyone really
Fixes #133275