Skip to content

Commit

Permalink
unrelated cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kadiwa4 committed Sep 1, 2024
1 parent 1a1cc05 commit b34811b
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,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()
{
Expand Down Expand Up @@ -2660,7 +2652,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
Expand Down

0 comments on commit b34811b

Please sign in to comment.