Rename hir::Let into hir::LetExpr

This commit is contained in:
Guillaume Gomez 2024-03-20 16:47:11 +01:00
parent 76096efb48
commit 54d1260174
6 changed files with 11 additions and 11 deletions

View File

@ -1,5 +1,5 @@
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::diagnostics::span_lint_and_help;
use rustc_hir::{intravisit, Body, Expr, ExprKind, FnDecl, Let, LocalSource, Mutability, Pat, PatKind, Stmt, StmtKind}; use rustc_hir::{intravisit, Body, Expr, ExprKind, FnDecl, LetExpr, LocalSource, Mutability, Pat, PatKind, Stmt, StmtKind};
use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::lint::in_external_macro; use rustc_middle::lint::in_external_macro;
use rustc_middle::ty; use rustc_middle::ty;
@ -103,7 +103,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
} }
} }
} }
if let ExprKind::Let(Let { pat, .. }) = expr.kind { if let ExprKind::Let(LetExpr { pat, .. }) = expr.kind {
apply_lint(cx, pat, DerefPossible::Possible); apply_lint(cx, pat, DerefPossible::Possible);
} }
} }

View File

@ -5,7 +5,7 @@
use rustc_hir::def::Res; use rustc_hir::def::Res;
use rustc_hir::def_id::LocalDefId; use rustc_hir::def_id::LocalDefId;
use rustc_hir::hir_id::ItemLocalId; use rustc_hir::hir_id::ItemLocalId;
use rustc_hir::{Block, Body, BodyOwnerKind, Expr, ExprKind, HirId, Let, Node, Pat, PatKind, QPath, UnOp}; use rustc_hir::{Block, Body, BodyOwnerKind, Expr, ExprKind, HirId, LetExpr, Node, Pat, PatKind, QPath, UnOp};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_session::impl_lint_pass; use rustc_session::impl_lint_pass;
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
@ -238,7 +238,7 @@ fn find_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'
let init = match node { let init = match node {
Node::Arm(_) | Node::Pat(_) => continue, Node::Arm(_) | Node::Pat(_) => continue,
Node::Expr(expr) => match expr.kind { Node::Expr(expr) => match expr.kind {
ExprKind::Match(e, _, _) | ExprKind::Let(&Let { init: e, .. }) => Some(e), ExprKind::Match(e, _, _) | ExprKind::Let(&LetExpr { init: e, .. }) => Some(e),
_ => None, _ => None,
}, },
Node::Local(local) => local.init, Node::Local(local) => local.init,

View File

@ -131,7 +131,7 @@ fn non_consuming_ok_arm<'a>(cx: &LateContext<'a>, arm: &hir::Arm<'a>) -> bool {
fn check_expr<'a>(cx: &LateContext<'a>, expr: &'a hir::Expr<'a>) { fn check_expr<'a>(cx: &LateContext<'a>, expr: &'a hir::Expr<'a>) {
match expr.kind { match expr.kind {
hir::ExprKind::If(cond, _, _) hir::ExprKind::If(cond, _, _)
if let ExprKind::Let(hir::Let { pat, init, .. }) = cond.kind if let ExprKind::Let(hir::LetExpr { pat, init, .. }) = cond.kind
&& is_ok_wild_or_dotdot_pattern(cx, pat) && is_ok_wild_or_dotdot_pattern(cx, pat)
&& let Some(op) = should_lint(cx, init) => && let Some(op) = should_lint(cx, init) =>
{ {

View File

@ -102,7 +102,7 @@ pub fn hir(cx: &LateContext<'_>, expr: &Expr<'hir>) -> Option<Self> {
if let ExprKind::If( if let ExprKind::If(
Expr { Expr {
kind: kind:
ExprKind::Let(&hir::Let { ExprKind::Let(&hir::LetExpr {
pat: let_pat, pat: let_pat,
init: let_expr, init: let_expr,
span: let_span, span: let_span,
@ -379,7 +379,7 @@ pub const fn hir(expr: &Expr<'hir>) -> Option<Self> {
ExprKind::If( ExprKind::If(
Expr { Expr {
kind: kind:
ExprKind::Let(&hir::Let { ExprKind::Let(&hir::LetExpr {
pat: let_pat, pat: let_pat,
init: let_expr, init: let_expr,
span: let_span, span: let_span,

View File

@ -8,7 +8,7 @@
use rustc_hir::MatchSource::TryDesugar; use rustc_hir::MatchSource::TryDesugar;
use rustc_hir::{ use rustc_hir::{
ArrayLen, BinOpKind, BindingAnnotation, Block, BodyId, Closure, Expr, ExprField, ExprKind, FnRetTy, GenericArg, ArrayLen, BinOpKind, BindingAnnotation, Block, BodyId, Closure, Expr, ExprField, ExprKind, FnRetTy, GenericArg,
GenericArgs, HirId, HirIdMap, InlineAsmOperand, Let, Lifetime, LifetimeName, Pat, PatField, PatKind, Path, GenericArgs, HirId, HirIdMap, InlineAsmOperand, LetExpr, Lifetime, LifetimeName, Pat, PatField, PatKind, Path,
PathSegment, PrimTy, QPath, Stmt, StmtKind, Ty, TyKind, TypeBinding, PathSegment, PrimTy, QPath, Stmt, StmtKind, Ty, TyKind, TypeBinding,
}; };
use rustc_lexer::{tokenize, TokenKind}; use rustc_lexer::{tokenize, TokenKind};
@ -837,7 +837,7 @@ pub fn hash_expr(&mut self, e: &Expr<'_>) {
} }
} }
}, },
ExprKind::Let(Let { pat, init, ty, .. }) => { ExprKind::Let(LetExpr { pat, init, ty, .. }) => {
self.hash_expr(init); self.hash_expr(init);
if let Some(ty) = ty { if let Some(ty) = ty {
self.hash_ty(ty); self.hash_ty(ty);

View File

@ -5,7 +5,7 @@
use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::intravisit::{self, walk_block, walk_expr, Visitor}; use rustc_hir::intravisit::{self, walk_block, walk_expr, Visitor};
use rustc_hir::{ use rustc_hir::{
AnonConst, Arm, Block, BlockCheckMode, Body, BodyId, Expr, ExprKind, HirId, ItemId, ItemKind, Let, Pat, QPath, AnonConst, Arm, Block, BlockCheckMode, Body, BodyId, Expr, ExprKind, HirId, ItemId, ItemKind, LetExpr, Pat, QPath,
Stmt, UnOp, UnsafeSource, Unsafety, Stmt, UnOp, UnsafeSource, Unsafety,
}; };
use rustc_lint::LateContext; use rustc_lint::LateContext;
@ -624,7 +624,7 @@ fn helper<'tcx, B>(
| ExprKind::Field(e, _) | ExprKind::Field(e, _)
| ExprKind::Unary(UnOp::Deref, e) | ExprKind::Unary(UnOp::Deref, e)
| ExprKind::Match(e, ..) | ExprKind::Match(e, ..)
| ExprKind::Let(&Let { init: e, .. }) => { | ExprKind::Let(&LetExpr { init: e, .. }) => {
helper(typeck, false, e, f)?; helper(typeck, false, e, f)?;
}, },
ExprKind::Block(&Block { expr: Some(e), .. }, _) | ExprKind::Cast(e, _) | ExprKind::Unary(_, e) => { ExprKind::Block(&Block { expr: Some(e), .. }, _) | ExprKind::Cast(e, _) | ExprKind::Unary(_, e) => {