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

Conserve cause of ImplDerivedObligation in E0599 #106702

Merged
merged 2 commits into from
Jan 12, 2023

Conversation

estebank
Copy link
Contributor

CC #86377.

@rustbot
Copy link
Collaborator

rustbot commented Jan 11, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@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 Jan 11, 2023
@estebank estebank marked this pull request as ready for review January 11, 2023 03:13
@compiler-errors
Copy link
Member

r? @compiler-errors @bors r+ as requested

@bors
Copy link
Contributor

bors commented Jan 11, 2023

📌 Commit 3a16c1aa1a3fafd8103dc65f66c8b785e7ded725 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 Jan 11, 2023
@estebank
Copy link
Contributor Author

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Jan 11, 2023

📌 Commit 5e8b8e7c03a397de79afce6adcc3218b7f742409 has been approved by compiler-errors

It is now in the queue for this repository.

@estebank
Copy link
Contributor Author

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Jan 11, 2023

📌 Commit 317adda has been approved by compiler-errors

It is now in the queue for this repository.

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 12, 2023
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#106167 (Fix invalid syntax and incomplete suggestion in impl Trait parameter type suggestions for E0311)
 - rust-lang#106309 (Prefer non-`[type error]` candidates during selection)
 - rust-lang#106532 (Allow codegen to unsize `dyn*` to `dyn`)
 - rust-lang#106596 (Hide more of long types in E0271)
 - rust-lang#106638 (std tests: use __OsLocalKeyInner from realstd)
 - rust-lang#106676 (Test that we cannot use trait impl methods arguments as defining uses)
 - rust-lang#106702 (Conserve cause of `ImplDerivedObligation` in E0599)
 - rust-lang#106732 (rustc_llvm: replace llvm::makeArrayRef with ArrayRef constructors.)
 - rust-lang#106733 (Revert "warn newer available version of the x tool")
 - rust-lang#106748 (Clean up `OnUnimplementedFormatString::verify`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 8a13157 into rust-lang:master Jan 12, 2023
@rustbot rustbot added this to the 1.68.0 milestone Jan 12, 2023
|_idx, span| {
let misc = traits::ObligationCause::misc(span, self.body_id);
let parent_trait_pred = ty::Binder::dummy(ty::TraitPredicate {
trait_ref: ty::TraitRef::from_method(self.tcx, impl_def_id, substs),
Copy link
Member

Choose a reason for hiding this comment

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

I should've caught this when reviewing this, but this is not correct. We cannot construct a trait ref out of an impl def id and impl substs, and it's not meaningful to even use tcx.impl_trait_ref(impl_def_id).subst(self.tcx, substs) here because this is an inherent impl by construction.

I fixed this in #110133

compiler-errors added a commit to compiler-errors/rust that referenced this pull request Apr 11, 2023
…trochenkov

Do not use ImplDerivedObligationCause for inherent impl method error reporting

We were constructing a `TraitRef` out of impl substs, for an *inherent* impl that has no corresponding trait. Instead of doing that, let's construct a meaningful obligation cause code, and instead adjust the error reporting machinery to handle that correctly.

Fixes rust-lang#110131
cc rust-lang#106702, which introduced this regression
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 12, 2023
…trochenkov

Do not use ImplDerivedObligationCause for inherent impl method error reporting

We were constructing a `TraitRef` out of impl substs, for an *inherent* impl that has no corresponding trait. Instead of doing that, let's construct a meaningful obligation cause code, and instead adjust the error reporting machinery to handle that correctly.

Fixes rust-lang#110131
cc rust-lang#106702, which introduced this regression
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