Rust: Add example from the basic-query-for-rust-code.rst.

This commit is contained in:
Geoffrey White
2025-11-06 17:50:59 +00:00
parent 84b50606ed
commit 6ce0a0d9df

View File

@@ -0,0 +1,15 @@
/**
* @name Empty 'if' statement
* @description Finds 'if' statements where the "then" branch is empty and no
* "else" branch exists.
* @id rust/examples/empty-if
* @tags example
*/
import rust
from IfExpr ifExpr
where
ifExpr.getThen().(BlockExpr).getStmtList().getNumberOfStmtOrExpr() = 0 and
not exists(ifExpr.getElse())
select ifExpr, "This 'if' expression is redundant."