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 removing superfluous semicolon when statements used as expression #121153

Merged
merged 2 commits into from
Mar 2, 2024

Conversation

chenyukang
Copy link
Member

Fixes #105431

  • it's not a pure recursive visitor, so I guess there may be some more complex scenarios not covered.
  • moved consider_removing_semicolon to compiler/rustc_infer for reusing this helper function.

@rustbot
Copy link
Collaborator

rustbot commented Feb 15, 2024

r? @michaelwoerister

rustbot has assigned @michaelwoerister.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 Feb 15, 2024
let node = self.tcx.hir_node(*hir_id);
let mut blocks = vec![];
if let hir::Node::Block(block) = node
&& let Some(expr) = block.expr
Copy link
Member Author

Choose a reason for hiding this comment

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

it seems hard to make it pure recursive, because I want to use self.tcx.parent_hir_node(..), and local function can not capture self.

@michaelwoerister
Copy link
Member

r? diagnostics

@rustbot rustbot assigned estebank and unassigned michaelwoerister Feb 19, 2024
@bors
Copy link
Contributor

bors commented Feb 20, 2024

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

@chenyukang chenyukang force-pushed the yukang-fix-105431-type-mismatch branch from 0d1b0f8 to 29cb86c Compare February 21, 2024 01:38
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 after the nitpick

@@ -293,6 +298,97 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
}

pub(super) fn suggest_for_statments_as_exp(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we rename this to suggest_turning_stmt_into_expr or something?

@bors
Copy link
Contributor

bors commented Feb 28, 2024

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

@chenyukang chenyukang force-pushed the yukang-fix-105431-type-mismatch branch from 29cb86c to e2ce5d7 Compare February 29, 2024 00:46
@chenyukang
Copy link
Member Author

@rustbot r=estebank

@@ -22,7 +22,7 @@ use rustc_hir::{
Path, QPath, Stmt, StmtKind, TyKind, WherePredicate,
};
use rustc_hir_analysis::astconv::AstConv;
use rustc_infer::traits::{self, StatementAsExpression};
use rustc_infer::traits::{self};
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
use rustc_infer::traits::{self};
use rustc_infer::traits;

@estebank
Copy link
Contributor

estebank commented Mar 1, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Mar 1, 2024

📌 Commit e2ce5d7 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 Mar 1, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 2, 2024
…iaskrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#111505 (Made `INVALID_DOC_ATTRIBUTES` lint deny by default)
 - rust-lang#120305 (Delete line if suggestion would replace it with an empty line)
 - rust-lang#121153 (Suggest removing superfluous semicolon when statements used as expression)
 - rust-lang#121497 (`-Znext-solver=coherence`: suggest increasing recursion limit)
 - rust-lang#121634 (Clarify behavior of slice prefix/suffix operations in case of equality)
 - rust-lang#121706 (match lowering: Remove hacky branch in sort_candidate)
 - rust-lang#121730 (Add profiling support to AIX)
 - rust-lang#121750 (match lowering: Separate the `bool` case from other integers in `TestKind`)
 - rust-lang#121803 (Never say "`Trait` is implemented for `{type error}`")
 - rust-lang#121811 (Move sanitizer ui tests to sanitizer directory)
 - rust-lang#121824 (Implement missing ABI structures in StableMIR)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b8cdcfa into rust-lang:master Mar 2, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Mar 2, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 2, 2024
Rollup merge of rust-lang#121153 - chenyukang:yukang-fix-105431-type-mismatch, r=estebank

Suggest removing superfluous semicolon when statements used as expression

Fixes rust-lang#105431

- it's not a pure recursive visitor, so I guess there may be some more complex scenarios not covered.
- moved `consider_removing_semicolon` to `compiler/rustc_infer` for reusing this helper function.
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.

Improve error message for statements used as expressions
5 participants