unrelated cleanup
This commit is contained in:
parent
c2270becb6
commit
d810d426a4
1 changed files with 2 additions and 10 deletions
|
@ -90,19 +90,11 @@ declare_lint! {
|
|||
|
||||
declare_lint_pass!(WhileTrue => [WHILE_TRUE]);
|
||||
|
||||
/// Traverse through any amount of parenthesis and return the first non-parens expression.
|
||||
fn pierce_parens(mut expr: &ast::Expr) -> &ast::Expr {
|
||||
while let ast::ExprKind::Paren(sub) = &expr.kind {
|
||||
expr = sub;
|
||||
}
|
||||
expr
|
||||
}
|
||||
|
||||
impl EarlyLintPass for WhileTrue {
|
||||
#[inline]
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
|
||||
if let ast::ExprKind::While(cond, _, label) = &e.kind
|
||||
&& let ast::ExprKind::Lit(token_lit) = pierce_parens(cond).kind
|
||||
&& let ast::ExprKind::Lit(token_lit) = cond.peel_parens().kind
|
||||
&& let token::Lit { kind: token::Bool, symbol: kw::True, .. } = token_lit
|
||||
&& !cond.span.from_expansion()
|
||||
{
|
||||
|
@ -2651,7 +2643,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
|
|||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `deref_nullptr` lint detects when an null pointer is dereferenced,
|
||||
/// The `deref_nullptr` lint detects when a null pointer is dereferenced,
|
||||
/// which causes [undefined behavior].
|
||||
///
|
||||
/// ### Example
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue