Skip to content

Propagate coercion cause into try_coerce #89028

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

Merged
merged 1 commit into from
Sep 19, 2021

Conversation

Aaron1011
Copy link
Member

Currently, coerce_inner discards its ObligationCause
when calling try_coerce. This interfers with other
diagnostc improvements I'm working on, since we will lose
the original span by the time the actual coercion occurs.

Additionally, we now use the span of the trailing expression
(rather than the span of the entire function) when performing
a coercion in check_return_expr. This currently has no visible
effect on any of the unit tests, but will unblock future
diagnostic improvements.

Currently, `coerce_inner` discards its `ObligationCause`
when calling `try_coerce`. This interfers with other
diagnostc improvements I'm working on, since we will lose
the original span by the time the actual coercion occurs.

Additionally, we now use the span of the trailing expression
(rather than the span of the entire function) when performing
a coercion in `check_return_expr`. This currently has no visible
effect on any of the unit tests, but will unblock future
diagnostic improvements.
@rust-highfive
Copy link
Contributor

r? @nagisa

(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 Sep 16, 2021
@oli-obk
Copy link
Contributor

oli-obk commented Sep 17, 2021

@bors try @rust-timer queue

inference perf can easily be regressed by innocent changes, let's check that first

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 17, 2021
@bors
Copy link
Collaborator

bors commented Sep 17, 2021

⌛ Trying commit 31cdd8c with merge 9a02d2019558beb5eb9dcb801d3d4e86ea21c3b4...

@bors
Copy link
Collaborator

bors commented Sep 17, 2021

☀️ Try build successful - checks-actions
Build commit: 9a02d2019558beb5eb9dcb801d3d4e86ea21c3b4 (9a02d2019558beb5eb9dcb801d3d4e86ea21c3b4)

@rust-timer
Copy link
Collaborator

Queued 9a02d2019558beb5eb9dcb801d3d4e86ea21c3b4 with parent 78a46ef, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9a02d2019558beb5eb9dcb801d3d4e86ea21c3b4): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 17, 2021
Copy link
Member

@nagisa nagisa left a comment

Choose a reason for hiding this comment

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

Looks like a good improvement.

let mut span = return_expr.span;
// Use the span of the trailing expression for our cause,
// not the span of the entire function
if !explicit_return {
Copy link
Member

Choose a reason for hiding this comment

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

Is it actually necessary to have the boolean flag here? I imagine it is trying to account for something like

return { foo; bar; baz };

so that rustc would span the entire block and not just baz here? It seems to me that it would be actually better, and more consistent if we spanned the last expression of the block in these situations.

@nagisa
Copy link
Member

nagisa commented Sep 17, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 17, 2021

📌 Commit 31cdd8c has been approved by nagisa

@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 Sep 17, 2021
@bors
Copy link
Collaborator

bors commented Sep 19, 2021

⌛ Testing commit 31cdd8c with merge 3bca723...

@bors
Copy link
Collaborator

bors commented Sep 19, 2021

☀️ Test successful - checks-actions
Approved by: nagisa
Pushing 3bca723 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 19, 2021
@bors bors merged commit 3bca723 into rust-lang:master Sep 19, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 19, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3bca723): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants