Install projection from RPITIT to default trait method opaque correctly#109198
Install projection from RPITIT to default trait method opaque correctly#109198bors merged 9 commits intorust-lang:masterfrom
Conversation
|
@rustbot author Actually don't think we need some of this stuff I'm doing here. |
e41f976 to
8d922eb
Compare
|
@rustbot ready |
|
Sorry, second commit is mistitled -- should probably be something like "fix param-env and wfcheck for default trait body RPITITs", but I'm going to sleep. |
| // get out of alignment, or else we do actually need to substitute these predicates. | ||
| if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) { | ||
| predicates = tcx.predicates_of(fn_def_id).instantiate_identity(tcx).predicates; | ||
| } |
There was a problem hiding this comment.
I think this part of the change is what makes the tests included in this commit pass, right?.
There was a problem hiding this comment.
both changes are needed to make the test pass, otherwise the error message goes from a "needs type info" error to a wfchecking error, iirc.
| && let Some(opaque_def_id) = opaque_ty.def_id.as_local() | ||
| && let opaque = tcx.hir().expect_item(opaque_def_id).expect_opaque_ty() | ||
| && let hir::OpaqueTyOrigin::FnReturn(source) | hir::OpaqueTyOrigin::AsyncFn(source) = opaque.origin | ||
| && source == fn_def_id |
There was a problem hiding this comment.
If I understand correct this is equivalent to what was before but done a little bit better, or are there actual difference? if so in which cases?.
There was a problem hiding this comment.
This is not equivalent. If we call is_impl_trait_in_trait on an opaque def id, then it returns false.
There was a problem hiding this comment.
Without this, some tests begin to spuriously pass wfcheck.
There was a problem hiding this comment.
the first commit in the stack "breaks" tests/ui/impl-trait/in-trait/wf-bounds.rs by actually projecting the RPITIT to a real opaque type, so this commit fixes the test by always checking for an opaque type.
There was a problem hiding this comment.
the first commit in the stack "breaks"
tests/ui/impl-trait/in-trait/wf-bounds.rsby actually projecting the RPITIT to a real opaque type, so this commit fixes the test by always checking for an opaque type.
Ahh right, because we project the projection to an opaque, that's the thing.
| } | ||
|
|
||
| // Compute the bounds on Self and the type parameters. | ||
| let ty::InstantiatedPredicates { mut predicates, .. } = |
There was a problem hiding this comment.
Wouldn't be more clear if this is an else of the if let from below?.
There was a problem hiding this comment.
Yeah, that works too.
|
This looks good to me, r=me after mine is merged and rebased. |
|
@bors r=spastorino |
…-body, r=spastorino Install projection from RPITIT to default trait method opaque correctly 1. For new lowering strategy `-Zlower-impl-trait-in-trait-to-assoc-ty`, install the correct default trait method projection predicates (RPITIT -> opaque). This makes default trait body tests pass! 2. Fix two WF-checking bugs -- first, we want to make sure that we're always looking for an opaque type in `check_return_position_impl_trait_in_trait_bounds`. That's because the RPITIT projections are normalized to opaques during wfcheck. Second, fix RPITIT's param-envs by not adding the projection predicates that we install on trait methods to make default RPITITs work -- I left a comment why. 3. Also, just a small drive-by for `rustc_on_unimplemented`. Not sure if it affects any tests, but can't hurt. r? `@spastorino,` based off of rust-lang#109140
…-body, r=spastorino Install projection from RPITIT to default trait method opaque correctly 1. For new lowering strategy `-Zlower-impl-trait-in-trait-to-assoc-ty`, install the correct default trait method projection predicates (RPITIT -> opaque). This makes default trait body tests pass! 2. Fix two WF-checking bugs -- first, we want to make sure that we're always looking for an opaque type in `check_return_position_impl_trait_in_trait_bounds`. That's because the RPITIT projections are normalized to opaques during wfcheck. Second, fix RPITIT's param-envs by not adding the projection predicates that we install on trait methods to make default RPITITs work -- I left a comment why. 3. Also, just a small drive-by for `rustc_on_unimplemented`. Not sure if it affects any tests, but can't hurt. r? ``@spastorino,`` based off of rust-lang#109140
…-body, r=spastorino Install projection from RPITIT to default trait method opaque correctly 1. For new lowering strategy `-Zlower-impl-trait-in-trait-to-assoc-ty`, install the correct default trait method projection predicates (RPITIT -> opaque). This makes default trait body tests pass! 2. Fix two WF-checking bugs -- first, we want to make sure that we're always looking for an opaque type in `check_return_position_impl_trait_in_trait_bounds`. That's because the RPITIT projections are normalized to opaques during wfcheck. Second, fix RPITIT's param-envs by not adding the projection predicates that we install on trait methods to make default RPITITs work -- I left a comment why. 3. Also, just a small drive-by for `rustc_on_unimplemented`. Not sure if it affects any tests, but can't hurt. r? ```@spastorino,``` based off of rust-lang#109140
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#108958 (Remove box expressions from HIR) - rust-lang#109044 (Prevent stable `libtest` from supporting `-Zunstable-options`) - rust-lang#109155 (Fix riscv64 fuchsia LLVM target name) - rust-lang#109156 (Fix linker detection for clang with prefix) - rust-lang#109181 (inherit_overflow: adapt pattern to also work with v0 mangling) - rust-lang#109198 (Install projection from RPITIT to default trait method opaque correctly) - rust-lang#109215 (Use sort_by_key instead of sort_by) - rust-lang#109229 (Fix invalid markdown link references) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…er-errors Add revisions for -Zlower-impl-trait-in-trait-to-assoc-ty fixed tests Needs to go on top of rust-lang#109198 r? `@compiler-errors`
…er-errors Add revisions for -Zlower-impl-trait-in-trait-to-assoc-ty fixed tests Needs to go on top of rust-lang#109198 r? `@compiler-errors`
…er-errors Add revisions for -Zlower-impl-trait-in-trait-to-assoc-ty fixed tests Needs to go on top of rust-lang#109198 r? ``@compiler-errors``
For new lowering strategy
-Zlower-impl-trait-in-trait-to-assoc-ty, install the correct default trait method projection predicates (RPITIT -> opaque). This makes default trait body tests pass!Fix two WF-checking bugs -- first, we want to make sure that we're always looking for an opaque type in
check_return_position_impl_trait_in_trait_bounds. That's because the RPITIT projections are normalized to opaques during wfcheck. Second, fix RPITIT's param-envs by not adding the projection predicates that we install on trait methods to make default RPITITs work -- I left a comment why.Also, just a small drive-by for
rustc_on_unimplemented. Not sure if it affects any tests, but can't hurt.r? @spastorino, based off of #109140