Skip to content
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

Add revisions for -Zlower-impl-trait-in-trait-to-assoc-ty fixed tests #109193

Merged
merged 1 commit into from
Mar 18, 2023

Conversation

spastorino
Copy link
Member

@spastorino spastorino commented Mar 15, 2023

Needs to go on top of #109198

r? @compiler-errors

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 15, 2023
@compiler-errors
Copy link
Member

compiler-errors commented Mar 15, 2023

Moving forward, can you not commit a separate "Add revisions to fixed tests" commit? If any of the first 3 commits fixes a UI test, then that UI test should be associated with each commit that fixes it. If the commit doesn't fix any UI tests, then it can probably be squashed together with the other commits that fully fix a test or not.

Basically I want to see--

Commit A

  • Changes some files
  • Fixes some UI tests

Commit B

  • Changes some files
  • Fixes some UI tests

It's hard to tell what is fixed by what, especially because there are not many comments in this PR really.

compiler/rustc_hir_analysis/src/check/check.rs Outdated Show resolved Hide resolved
compiler/rustc_hir_analysis/src/check/check.rs Outdated Show resolved Hide resolved
@@ -396,10 +396,29 @@ impl<'tcx> InferCtxt<'tcx> {
/// defining scope.
#[instrument(skip(self), level = "trace", ret)]
fn opaque_type_origin_unchecked(&self, def_id: LocalDefId) -> OpaqueTyOrigin {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes me uncomfortable that we're calling opaque_type_origin_unchecked on an associated type. That's probably wrong...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to check why is being called.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fixed alternatively by #109198, and should make it so that we don't need to modify opaque_type_origin_unchecked at all.

Copy link
Member Author

@spastorino spastorino Mar 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell me how #109198 avoid calling this function?. I see in the logs that this is coming from check_fn.

Copy link
Member

@compiler-errors compiler-errors Mar 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given some -> impl Trait in trait, let's call that opaque def-id#1 (DefKind::Opaque). We later synthesize a def-id#2, which is an associated type (DefKind::AssocTy).

In typeck_with_fallback, we normalize ty::Alias(ty::Projection, def-id#2) in the original trait signature to ty::Alias(ty::Opaque, def-id#2) instead of ty::Alias(ty::Opaque, def-id#1), because of this FIXME:

// FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty) need to project to the opaque, could
// get it via type_of + subst.

self.predicates.push(
ty::Binder::bind_with_vars(
ty::ProjectionPredicate {
projection_ty: alias_ty,
term: self.tcx.mk_alias(ty::Opaque, alias_ty).into(),
},
self.bound_vars,
)
.to_predicate(self.tcx),

That's wrong, because def-id#2 is an associated type.

That passes a signature with the return type of ty::Alias(ty::Opaque, def-id#2) to check_fn, which passes it to replace_opaque_types_with_inference_vars. That tries to call opaque_type_origin on def-id#2 (reminder: an associated type) which ICEs.

That is what I fixed in #109198.

@@ -2231,6 +2231,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
// ambiguous impls. The latter *ought* to be a
// coherence violation, so we don't report it here.

if self.tcx.opt_rpitit_info(obligation.cause.body_id.to_def_id()).is_some() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not generally sound to skip reporting an error here, without at least delaying a bug or something else. Can you explain why you're doing this?

@spastorino
Copy link
Member Author

Moving forward, can you not commit a separate "Add revisions to fixed tests" commit? If any of the first 3 commits fixes a UI test, then that UI test should be associated with each commit that fixes it. If the commit doesn't fix any UI tests, then it can probably be squashed together with the other commits that fully fix a test or not.

We need all the changes to make the working tests pass. Each commit was making this tests ICE in a new part of the code :).

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@spastorino spastorino changed the title More properly handle trait's default bodies on -Zlower-impl-trait-in-trait-to-assoc-ty Add revisions for -Zlower-impl-trait-in-trait-to-assoc-ty fixed tests Mar 16, 2023
@spastorino
Copy link
Member Author

@compiler-errors only the last commit is relevant. Maybe you can even fetch that one up and place it in #109198 ?

@compiler-errors
Copy link
Member

my pr already got rolled up into a rollup lol

r=me when it's landed

@bors rollup

@spastorino
Copy link
Member Author

This thing is going to fail until #109198 is merged and we rebase on top of it.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@spastorino
Copy link
Member Author

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Mar 17, 2023

📌 Commit ae78e9b has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 17, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 17, 2023
…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`
@rust-log-analyzer

This comment has been minimized.

@spastorino
Copy link
Member Author

@bors r-

Something is odd here.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 17, 2023
@spastorino
Copy link
Member Author

Now yes ...

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Mar 17, 2023

📌 Commit e0302bb has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 17, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 17, 2023
…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`
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 18, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#107416 (Error code E0794 for late-bound lifetime parameter error.)
 - rust-lang#108772 (Speed up tidy quite a lot)
 - rust-lang#109193 (Add revisions for -Zlower-impl-trait-in-trait-to-assoc-ty fixed tests)
 - rust-lang#109234 (Tweak implementation of overflow checking assertions)
 - rust-lang#109238 (Fix generics mismatch errors for RPITITs on -Zlower-impl-trait-in-trait-to-assoc-ty)
 - rust-lang#109283 (rustdoc: reduce allocations in `visibility_to_src_with_space`)
 - rust-lang#109287 (Use `size_of_val` instead of manual calculation)
 - rust-lang#109288 (Stabilise `unix_socket_abstract`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a79925d into rust-lang:master Mar 18, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants