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

Implement the new desugaring from try_trait_v2 #84767

Merged
merged 11 commits into from
May 18, 2021

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Apr 30, 2021

Currently blocked on #84782, which has a PR in #84811 Rebased atop that fix.

try_trait_v2 tracking issue: #84277

Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits.

r? @ghost

(This probably shouldn't go in during the last week before the fork anyway.) Fork happened.

| --- consider giving `fut` the explicit type `impl Future`, where the type parameter `E` is specified
...
LL | Ok(())
| ^^ cannot infer type for type parameter `E` declared on the enum `Result`
Copy link
Member Author

Choose a reason for hiding this comment

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

@estebank I got some of the places fixed up, but there are some others like this where I've regressed the diagnostics, losing some of the special ? notes. If you have any pointers to share on how to get them fixed up, I'd appreciate it.

Copy link
Contributor

Choose a reason for hiding this comment

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

To be fair, the existing ? diagnostic was already incorrect: this seems to imply that the async block behaves similarly to try, which it doesn't. We might have to proactively look for ? expressions in async block bodies and give a specific error for them, or collect their spans and see if any E0282s happen in the same block as one of them, to treat them explicitly. Don't think these should block landing this, but needs to be addressed before these errors land on stable.

|
LL | / fn option_to_result() -> Result<u64, String> {
LL | | Some(3)?;
| | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u64, String>`
Copy link
Member Author

Choose a reason for hiding this comment

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

❤️ rustc_on_unimplemented

@scottmcm scottmcm force-pushed the try_trait_actual branch 2 times, most recently from c65047a to 1f5d2ee Compare May 1, 2021 00:15
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm added the F-try_trait_v2 Tracking issue for RFC#3058 label May 1, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@scottmcm
Copy link
Member Author

scottmcm commented May 3, 2021

@bors try @rust-timer queue

@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 May 3, 2021
@bors
Copy link
Contributor

bors commented May 3, 2021

⌛ Trying commit b1cf4cec0ab0c51b45db9c665ade7419c7cd85f0 with merge 9e1fbcd2d92fbe606de781106bb28b5c1e981c0a...

@bors
Copy link
Contributor

bors commented May 3, 2021

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

@rust-timer
Copy link
Collaborator

Queued 9e1fbcd2d92fbe606de781106bb28b5c1e981c0a with parent 59f551a, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (9e1fbcd2d92fbe606de781106bb28b5c1e981c0a): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 3, 2021
@scottmcm scottmcm changed the title [STILL WORKING ON IT] Implement the new desugaring from try_trait_v2 Implement the new desugaring from try_trait_v2 May 3, 2021
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

nits, then r=me

src/test/codegen/try_identity.rs Outdated Show resolved Hide resolved
src/test/mir-opt/simplify-arm.rs Outdated Show resolved Hide resolved
src/test/mir-opt/simplify_try.rs Outdated Show resolved Hide resolved
@lcnr
Copy link
Contributor

lcnr commented May 18, 2021

@bors rollup=never

Thanks for the suggestions, lcnr!

Co-authored-by: lcnr <[email protected]>
@rust-log-analyzer

This comment has been minimized.

@scottmcm
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented May 18, 2021

📌 Commit e2edee4 has been approved by lcnr

@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 May 18, 2021
@bors
Copy link
Contributor

bors commented May 18, 2021

⌛ Testing commit e2edee4 with merge 4e3e6db...

@bors
Copy link
Contributor

bors commented May 18, 2021

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 4e3e6db to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 18, 2021
@bors bors merged commit 4e3e6db into rust-lang:master May 18, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 18, 2021
@scottmcm scottmcm deleted the try_trait_actual branch May 18, 2021 23:09
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #84767!

Tested on commit 4e3e6db.
Direct link to PR: #84767

💔 rls on windows: test-pass → build-fail (cc @Xanewok).
💔 rls on linux: test-pass → build-fail (cc @Xanewok).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request May 18, 2021
Tested on commit rust-lang/rust@4e3e6db.
Direct link to PR: <rust-lang/rust#84767>

💔 rls on windows: test-pass → build-fail (cc @Xanewok).
💔 rls on linux: test-pass → build-fail (cc @Xanewok).
flip1995 pushed a commit to flip1995/rust that referenced this pull request May 20, 2021
Implement the new desugaring from `try_trait_v2`

~~Currently blocked on rust-lang#84782, which has a PR in rust-lang#84811 Rebased atop that fix.

`try_trait_v2` tracking issue: rust-lang#84277

Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them.  (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits.

r? `@ghost`

~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
@rylev
Copy link
Member

rylev commented May 25, 2021

@lcnr @scottmcm this looks like it caused some bigger perf issues after merging than in the original perf run.

A cursory look points to mir_built being the source of most of regression. Is more mir being produced by this change?

@scottmcm
Copy link
Member Author

There's actually less MIR being produced now.

The red at https://github.com/rust-lang/rust/pull/84767/files#diff-d93592ecc730e2061ac31cad11e78e3bb7cdc7ca3257a85f04bbd3f48c0c6521L1938 is because it only needs to make one call (from_residual(r)) in the short-circuiting branch, not the two (from_err(From::from(e))) that it used to. That thus results in one fewer basic block in MIR: https://github.com/rust-lang/rust/pull/84767/files#diff-a7c7df8af59063804b05ac13069f523e405cd5ecce0f157de356b37922461f34L71

My guess would be more stress on the type solvers. jyn pointed out that diesel is hitting type_op_prove_predicate pretty hard, apparently, so it might be that the trait structure is harder for the compiler to prove than the old one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-try_trait_v2 Tracking issue for RFC#3058 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.

9 participants