We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
For rust-lang/rust#44173
We should have a "use unit value" lint that checks for:
()
where the origin of the () is basically a semicolonless block
An example of an early pass is https://github.com/rust-lang-nursery/rust-clippy/blob/master/clippy_lints/src/precedence.rs
What we want is an early pass (runs on the AST before typechecking) with a check_expr and check_stmt that look for:
check_expr
check_stmt
and then run a is_unit_expr check on their contents (the initializer for assignment/let, and each of the arguments for calls)
is_unit_expr
is_unit_expr will:
Block
Expr
We can also have it recurse, where if the last statement is a StmtKind::Expr, then recurse down and check if that expr evaluates to unit.
StmtKind::Expr
Then, if any of the is_unit_expr calls evaluates to true, throw the lint.
@zmanian is working on this
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
For rust-lang/rust#44173
We should have a "use unit value" lint that checks for:
()
being assigned to a variable()
being passed to a functionwhere the origin of the
()
is basically a semicolonless blockAn example of an early pass is https://github.com/rust-lang-nursery/rust-clippy/blob/master/clippy_lints/src/precedence.rs
What we want is an early pass (runs on the AST before typechecking) with a
check_expr
andcheck_stmt
that look for:and then run a
is_unit_expr
check on their contents (the initializer for assignment/let, and each of the arguments for calls)is_unit_expr
will:Block
, return true if the last statement is not anExpr
statementWe can also have it recurse, where if the last statement is a
StmtKind::Expr
, then recurse down and check if that expr evaluates to unit.Then, if any of the
is_unit_expr
calls evaluates to true, throw the lint.@zmanian is working on this
The text was updated successfully, but these errors were encountered: