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

Point at return expression for RPIT-related error #97818

Merged
merged 1 commit into from
Jun 22, 2022

Conversation

compiler-errors
Copy link
Member

Certainly this needs some diagnostic refining, but I wanted to show that it was possible first and foremost. Not sure if this is the right approach. Open to feedback.

Fixes #80583

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 7, 2022
@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 7, 2022
@petrochenkov
Copy link
Contributor

r? rust-lang/diagnostics

@rust-highfive rust-highfive assigned oli-obk and unassigned petrochenkov Jun 7, 2022
@bors
Copy link
Contributor

bors commented Jun 11, 2022

☔ The latest upstream changes (presumably #97980) made this pull request unmergeable. Please resolve the merge conflicts.

Comment on lines 71 to 79
let cause = ObligationCause::misc(span, body_id);
let cause = ObligationCause::new(span, body_id, code.clone());
let ty_var = self.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeInference,
span: cause.span,
span,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

We can certainly do this for now, but doesn't scale very well to longer inference chains or going through any kind of branching.

I would like to generally improve inference errors to know the start and end of the inference and improve diagnostics from that. So ideally we'd have a new TypeVariableOriginKind and use that information to improve the spans right when the inference variable gets inferred to a concrete type.

So... short term, your change is the best effect-for-effort change we can make, but it should probably have a fixme or issue so we have a canonical thing to point to and collect experiments and other information.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 21, 2022

@rustbot author

needs a rebase and a minor fixme fix

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 21, 2022
@compiler-errors
Copy link
Member Author

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Jun 22, 2022

📌 Commit 52409c4 has been approved by oli-obk

@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 Jun 22, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 22, 2022
… r=oli-obk

Point at return expression for RPIT-related error

Certainly this needs some diagnostic refining, but I wanted to show that it was possible first and foremost. Not sure if this is the right approach. Open to feedback.

Fixes rust-lang#80583
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 22, 2022
Rollup of 10 pull requests

Successful merges:

 - rust-lang#95446 (update CPU usage script)
 - rust-lang#96768 (Use futex based thread parker on Fuchsia.)
 - rust-lang#97454 (Add release notes for 1.62)
 - rust-lang#97516 (clarify how Rust atomics correspond to C++ atomics)
 - rust-lang#97818 (Point at return expression for RPIT-related error)
 - rust-lang#97895 (Simplify `likely!` and `unlikely!` macro)
 - rust-lang#98005 (Add some tests for impossible bounds)
 - rust-lang#98226 (Document unstable `--extern` options)
 - rust-lang#98356 (Add missing period)
 - rust-lang#98363 (remove use of &Alloc in btree tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit dfc6d7a into rust-lang:master Jun 22, 2022
@rustbot rustbot added this to the 1.63.0 milestone Jun 22, 2022
@compiler-errors compiler-errors deleted the rpit-error-spanned branch August 11, 2023 20:17
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.

Error when concrete type doesn't satisfy impl trait is poorly spanned
6 participants