mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Rename hir::Let
into hir::LetExpr
This commit is contained in:
parent
c86f3ac24f
commit
98e66553a6
@ -157,7 +157,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
hir::ExprKind::AddrOf(*k, *m, ohs)
|
||||
}
|
||||
ExprKind::Let(pat, scrutinee, span, is_recovered) => {
|
||||
hir::ExprKind::Let(self.arena.alloc(hir::Let {
|
||||
hir::ExprKind::Let(self.arena.alloc(hir::LetExpr {
|
||||
span: self.lower_span(*span),
|
||||
pat: self.lower_pat(pat),
|
||||
ty: None,
|
||||
|
@ -1259,7 +1259,7 @@ pub struct Arm<'hir> {
|
||||
/// In an `if let`, imagine it as `if (let <pat> = <expr>) { ... }`; in a let-else, it is part of
|
||||
/// the desugaring to if-let. Only let-else supports the type annotation at present.
|
||||
#[derive(Debug, Clone, Copy, HashStable_Generic)]
|
||||
pub struct Let<'hir> {
|
||||
pub struct LetExpr<'hir> {
|
||||
pub span: Span,
|
||||
pub pat: &'hir Pat<'hir>,
|
||||
pub ty: Option<&'hir Ty<'hir>>,
|
||||
@ -1852,7 +1852,7 @@ pub enum ExprKind<'hir> {
|
||||
///
|
||||
/// These are not `Local` and only occur as expressions.
|
||||
/// The `let Some(x) = foo()` in `if let Some(x) = foo()` is an example of `Let(..)`.
|
||||
Let(&'hir Let<'hir>),
|
||||
Let(&'hir LetExpr<'hir>),
|
||||
/// An `if` block, with an optional else block.
|
||||
///
|
||||
/// I.e., `if <expr> { <expr> } else { <expr> }`.
|
||||
|
@ -753,7 +753,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
|
||||
ExprKind::DropTemps(ref subexpression) => {
|
||||
try_visit!(visitor.visit_expr(subexpression));
|
||||
}
|
||||
ExprKind::Let(Let { span: _, pat, ty, init, is_recovered: _ }) => {
|
||||
ExprKind::Let(LetExpr { span: _, pat, ty, init, is_recovered: _ }) => {
|
||||
// match the visit order in walk_local
|
||||
try_visit!(visitor.visit_expr(init));
|
||||
try_visit!(visitor.visit_pat(pat));
|
||||
|
@ -1387,7 +1387,7 @@ impl<'a> State<'a> {
|
||||
// Print `}`:
|
||||
self.bclose_maybe_open(expr.span, true);
|
||||
}
|
||||
hir::ExprKind::Let(&hir::Let { pat, ty, init, .. }) => {
|
||||
hir::ExprKind::Let(&hir::LetExpr { pat, ty, init, .. }) => {
|
||||
self.print_let(pat, ty, init);
|
||||
}
|
||||
hir::ExprKind::If(test, blk, elseopt) => {
|
||||
|
@ -317,7 +317,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
err.note("`if` expressions without `else` evaluate to `()`");
|
||||
err.help("consider adding an `else` block that evaluates to the expected type");
|
||||
*error = true;
|
||||
if let ExprKind::Let(hir::Let { span, pat, init, .. }) = cond_expr.kind
|
||||
if let ExprKind::Let(hir::LetExpr { span, pat, init, .. }) = cond_expr.kind
|
||||
&& let ExprKind::Block(block, _) = then_expr.kind
|
||||
// Refutability checks occur on the MIR, so we approximate it here by checking
|
||||
// if we have an enum with a single variant or a struct in the pattern.
|
||||
|
@ -1261,7 +1261,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn check_expr_let(&self, let_expr: &'tcx hir::Let<'tcx>, hir_id: HirId) -> Ty<'tcx> {
|
||||
pub(super) fn check_expr_let(
|
||||
&self,
|
||||
let_expr: &'tcx hir::LetExpr<'tcx>,
|
||||
hir_id: HirId,
|
||||
) -> Ty<'tcx> {
|
||||
// for let statements, this is done in check_stmt
|
||||
let init = let_expr.init;
|
||||
self.warn_if_unreachable(init.hir_id, init.span, "block in `let` expression");
|
||||
|
@ -245,7 +245,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
hir::ExprKind::Let(hir::Let { pat, init, .. }) => {
|
||||
hir::ExprKind::Let(hir::LetExpr { pat, init, .. }) => {
|
||||
self.walk_local(init, pat, None, |t| t.borrow_expr(init, ty::ImmBorrow))
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ impl<'a> DeclOrigin<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A declaration is an abstraction of [hir::Local] and [hir::Let].
|
||||
/// A declaration is an abstraction of [hir::Local] and [hir::LetExpr].
|
||||
///
|
||||
/// It must have a hir_id, as this is how we connect gather_locals to the check functions.
|
||||
pub(super) struct Declaration<'a> {
|
||||
@ -48,9 +48,9 @@ impl<'a> From<&'a hir::Local<'a>> for Declaration<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<(&'a hir::Let<'a>, hir::HirId)> for Declaration<'a> {
|
||||
fn from((let_expr, hir_id): (&'a hir::Let<'a>, hir::HirId)) -> Self {
|
||||
let hir::Let { pat, ty, span, init, is_recovered: _ } = *let_expr;
|
||||
impl<'a> From<(&'a hir::LetExpr<'a>, hir::HirId)> for Declaration<'a> {
|
||||
fn from((let_expr, hir_id): (&'a hir::LetExpr<'a>, hir::HirId)) -> Self {
|
||||
let hir::LetExpr { pat, ty, span, init, is_recovered: _ } = *let_expr;
|
||||
Declaration { hir_id, pat, ty, span, init: Some(init), origin: DeclOrigin::LetExpr }
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
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_middle::lint::in_external_macro;
|
||||
use rustc_middle::ty;
|
||||
@ -103,7 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for PatternTypeMismatch {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let ExprKind::Let(Let { pat, .. }) = expr.kind {
|
||||
if let ExprKind::Let(LetExpr { pat, .. }) = expr.kind {
|
||||
apply_lint(cx, pat, DerefPossible::Possible);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
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_session::impl_lint_pass;
|
||||
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 {
|
||||
Node::Arm(_) | Node::Pat(_) => continue,
|
||||
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,
|
||||
},
|
||||
Node::Local(local) => local.init,
|
||||
|
@ -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>) {
|
||||
match expr.kind {
|
||||
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)
|
||||
&& let Some(op) = should_lint(cx, init) =>
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ impl<'hir> IfLet<'hir> {
|
||||
if let ExprKind::If(
|
||||
Expr {
|
||||
kind:
|
||||
ExprKind::Let(&hir::Let {
|
||||
ExprKind::Let(&hir::LetExpr {
|
||||
pat: let_pat,
|
||||
init: let_expr,
|
||||
span: let_span,
|
||||
@ -379,7 +379,7 @@ impl<'hir> WhileLet<'hir> {
|
||||
ExprKind::If(
|
||||
Expr {
|
||||
kind:
|
||||
ExprKind::Let(&hir::Let {
|
||||
ExprKind::Let(&hir::LetExpr {
|
||||
pat: let_pat,
|
||||
init: let_expr,
|
||||
span: let_span,
|
||||
|
@ -8,7 +8,7 @@ use rustc_hir::def::Res;
|
||||
use rustc_hir::MatchSource::TryDesugar;
|
||||
use rustc_hir::{
|
||||
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,
|
||||
};
|
||||
use rustc_lexer::{tokenize, TokenKind};
|
||||
@ -837,7 +837,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
},
|
||||
ExprKind::Let(Let { pat, init, ty, .. }) => {
|
||||
ExprKind::Let(LetExpr { pat, init, ty, .. }) => {
|
||||
self.hash_expr(init);
|
||||
if let Some(ty) = ty {
|
||||
self.hash_ty(ty);
|
||||
|
@ -5,7 +5,7 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
use rustc_hir::intravisit::{self, walk_block, walk_expr, Visitor};
|
||||
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,
|
||||
};
|
||||
use rustc_lint::LateContext;
|
||||
@ -624,7 +624,7 @@ pub fn for_each_unconsumed_temporary<'tcx, B>(
|
||||
| ExprKind::Field(e, _)
|
||||
| ExprKind::Unary(UnOp::Deref, e)
|
||||
| ExprKind::Match(e, ..)
|
||||
| ExprKind::Let(&Let { init: e, .. }) => {
|
||||
| ExprKind::Let(&LetExpr { init: e, .. }) => {
|
||||
helper(typeck, false, e, f)?;
|
||||
},
|
||||
ExprKind::Block(&Block { expr: Some(e), .. }, _) | ExprKind::Cast(e, _) | ExprKind::Unary(_, e) => {
|
||||
|
Loading…
Reference in New Issue
Block a user