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

Suggest returning local on "expected ty, found ()" due to expr-less block #98784

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

compiler-errors
Copy link
Member

Putting this up for initial review. Notably, this doesn't consider if the value has possibly been moved, or whether the type is Copy. It also provides a structured suggestion if there's one "preferred" binding that matches the type (i.e. one binding in the block or its parent), otherwise it just points them out if there's fewer than 4 of them.

Fixes #98177

r? @estebank

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 1, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 1, 2022
@rust-log-analyzer

This comment has been minimized.

Comment on lines +887 to +891
err.span_suggestion_verbose(
span_semi,
"consider removing this semicolon and boxing the expression",
"",
Copy link
Contributor

Choose a reason for hiding this comment

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

preexisting: This stands out to me. I guess we didn't have the statement span without the semicolon to suggest Box::new( before?

Copy link
Member Author

Choose a reason for hiding this comment

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

I will fix that -- we should be able to strip the semicolon and provide a full suggestion (MaybeIncorrect, still) to box it

@compiler-errors
Copy link
Member Author

@rustbot author

@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 Jul 8, 2022
@bors
Copy link
Contributor

bors commented Jul 9, 2022

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

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 10, 2022
…k-compatible, r=estebank

Do not call `check_expr` in `check_compatible`, since it has side-effects

Fixes a weird suggestion in rust-lang#98784

found later:
Fixes rust-lang#98894
Fixes rust-lang#98897
@compiler-errors
Copy link
Member Author

@rustbot ready

this is ready for another round of review i think, fixed the whitespace issue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 19, 2022
Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

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

r=me

@compiler-errors
Copy link
Member Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jul 20, 2022

📌 Commit b0a8190 has been approved by estebank

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 Jul 20, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 20, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#98784 (Suggest returning local on "expected `ty`, found `()`" due to expr-less block)
 - rust-lang#98916 (Windows: Use `FindFirstFileW` for getting the metadata of locked system files)
 - rust-lang#99433 (Erase regions before comparing signatures of foreign fns.)
 - rust-lang#99452 (int_macros was only using to_xe_bytes_doc and not from_xe_bytes_doc)
 - rust-lang#99481 (Add regression test for rust-lang#71547)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 97c9f16 into rust-lang:master Jul 20, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 20, 2022
@compiler-errors compiler-errors deleted the forgot-to-return-binding branch August 11, 2023 20:01
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.

On functions with return type and no returned value, point at appropriate bindings to be returned
6 participants