Remove box expressions from HIR
This commit is contained in:
parent
669e751639
commit
9afffc5b61
@ -259,7 +259,6 @@ pub enum ExprPrecedence {
|
|||||||
Assign,
|
Assign,
|
||||||
AssignOp,
|
AssignOp,
|
||||||
|
|
||||||
Box,
|
|
||||||
AddrOf,
|
AddrOf,
|
||||||
Let,
|
Let,
|
||||||
Unary,
|
Unary,
|
||||||
@ -319,8 +318,7 @@ impl ExprPrecedence {
|
|||||||
ExprPrecedence::AssignOp => AssocOp::Assign.precedence() as i8,
|
ExprPrecedence::AssignOp => AssocOp::Assign.precedence() as i8,
|
||||||
|
|
||||||
// Unary, prefix
|
// Unary, prefix
|
||||||
ExprPrecedence::Box
|
ExprPrecedence::AddrOf
|
||||||
| ExprPrecedence::AddrOf
|
|
||||||
// Here `let pats = expr` has `let pats =` as a "unary" prefix of `expr`.
|
// Here `let pats = expr` has `let pats =` as a "unary" prefix of `expr`.
|
||||||
// However, this is not exactly right. When `let _ = a` is the LHS of a binop we
|
// However, this is not exactly right. When `let _ = a` is the LHS of a binop we
|
||||||
// need parens sometimes. E.g. we can print `(let _ = a) && b` as `let _ = a && b`
|
// need parens sometimes. E.g. we can print `(let _ = a) && b` as `let _ = a && b`
|
||||||
|
@ -1673,7 +1673,6 @@ pub struct Expr<'hir> {
|
|||||||
impl Expr<'_> {
|
impl Expr<'_> {
|
||||||
pub fn precedence(&self) -> ExprPrecedence {
|
pub fn precedence(&self) -> ExprPrecedence {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
ExprKind::Box(_) => ExprPrecedence::Box,
|
|
||||||
ExprKind::ConstBlock(_) => ExprPrecedence::ConstBlock,
|
ExprKind::ConstBlock(_) => ExprPrecedence::ConstBlock,
|
||||||
ExprKind::Array(_) => ExprPrecedence::Array,
|
ExprKind::Array(_) => ExprPrecedence::Array,
|
||||||
ExprKind::Call(..) => ExprPrecedence::Call,
|
ExprKind::Call(..) => ExprPrecedence::Call,
|
||||||
@ -1763,7 +1762,6 @@ impl Expr<'_> {
|
|||||||
| ExprKind::Lit(_)
|
| ExprKind::Lit(_)
|
||||||
| ExprKind::ConstBlock(..)
|
| ExprKind::ConstBlock(..)
|
||||||
| ExprKind::Unary(..)
|
| ExprKind::Unary(..)
|
||||||
| ExprKind::Box(..)
|
|
||||||
| ExprKind::AddrOf(..)
|
| ExprKind::AddrOf(..)
|
||||||
| ExprKind::Binary(..)
|
| ExprKind::Binary(..)
|
||||||
| ExprKind::Yield(..)
|
| ExprKind::Yield(..)
|
||||||
@ -1851,7 +1849,6 @@ impl Expr<'_> {
|
|||||||
| ExprKind::InlineAsm(..)
|
| ExprKind::InlineAsm(..)
|
||||||
| ExprKind::AssignOp(..)
|
| ExprKind::AssignOp(..)
|
||||||
| ExprKind::ConstBlock(..)
|
| ExprKind::ConstBlock(..)
|
||||||
| ExprKind::Box(..)
|
|
||||||
| ExprKind::Binary(..)
|
| ExprKind::Binary(..)
|
||||||
| ExprKind::Yield(..)
|
| ExprKind::Yield(..)
|
||||||
| ExprKind::DropTemps(..)
|
| ExprKind::DropTemps(..)
|
||||||
@ -1862,8 +1859,7 @@ impl Expr<'_> {
|
|||||||
/// To a first-order approximation, is this a pattern?
|
/// To a first-order approximation, is this a pattern?
|
||||||
pub fn is_approximately_pattern(&self) -> bool {
|
pub fn is_approximately_pattern(&self) -> bool {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
ExprKind::Box(_)
|
ExprKind::Array(_)
|
||||||
| ExprKind::Array(_)
|
|
||||||
| ExprKind::Call(..)
|
| ExprKind::Call(..)
|
||||||
| ExprKind::Tup(_)
|
| ExprKind::Tup(_)
|
||||||
| ExprKind::Lit(_)
|
| ExprKind::Lit(_)
|
||||||
@ -1910,8 +1906,6 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool {
|
|||||||
|
|
||||||
#[derive(Debug, HashStable_Generic)]
|
#[derive(Debug, HashStable_Generic)]
|
||||||
pub enum ExprKind<'hir> {
|
pub enum ExprKind<'hir> {
|
||||||
/// A `box x` expression.
|
|
||||||
Box(&'hir Expr<'hir>),
|
|
||||||
/// Allow anonymous constants from an inline `const` block
|
/// Allow anonymous constants from an inline `const` block
|
||||||
ConstBlock(AnonConst),
|
ConstBlock(AnonConst),
|
||||||
/// An array (e.g., `[a, b, c, d]`).
|
/// An array (e.g., `[a, b, c, d]`).
|
||||||
|
@ -682,7 +682,6 @@ pub fn walk_anon_const<'v, V: Visitor<'v>>(visitor: &mut V, constant: &'v AnonCo
|
|||||||
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) {
|
pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>) {
|
||||||
visitor.visit_id(expression.hir_id);
|
visitor.visit_id(expression.hir_id);
|
||||||
match expression.kind {
|
match expression.kind {
|
||||||
ExprKind::Box(ref subexpression) => visitor.visit_expr(subexpression),
|
|
||||||
ExprKind::Array(subexpressions) => {
|
ExprKind::Array(subexpressions) => {
|
||||||
walk_list!(visitor, visit_expr, subexpressions);
|
walk_list!(visitor, visit_expr, subexpressions);
|
||||||
}
|
}
|
||||||
|
@ -1366,10 +1366,6 @@ impl<'a> State<'a> {
|
|||||||
self.ibox(INDENT_UNIT);
|
self.ibox(INDENT_UNIT);
|
||||||
self.ann.pre(self, AnnNode::Expr(expr));
|
self.ann.pre(self, AnnNode::Expr(expr));
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
hir::ExprKind::Box(expr) => {
|
|
||||||
self.word_space("Box::new");
|
|
||||||
self.print_call_post(std::slice::from_ref(expr));
|
|
||||||
}
|
|
||||||
hir::ExprKind::Array(exprs) => {
|
hir::ExprKind::Array(exprs) => {
|
||||||
self.print_expr_vec(exprs);
|
self.print_expr_vec(exprs);
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
ExprKind::Box(subexpr) => self.check_expr_box(subexpr, expected),
|
|
||||||
ExprKind::Lit(ref lit) => self.check_lit(&lit, expected),
|
ExprKind::Lit(ref lit) => self.check_lit(&lit, expected),
|
||||||
ExprKind::Binary(op, lhs, rhs) => self.check_binop(expr, op, lhs, rhs, expected),
|
ExprKind::Binary(op, lhs, rhs) => self.check_binop(expr, op, lhs, rhs, expected),
|
||||||
ExprKind::Assign(lhs, rhs, span) => {
|
ExprKind::Assign(lhs, rhs, span) => {
|
||||||
@ -358,16 +357,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_expr_box(&self, expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>) -> Ty<'tcx> {
|
|
||||||
let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| match ty.kind() {
|
|
||||||
ty::Adt(def, _) if def.is_box() => Expectation::rvalue_hint(self, ty.boxed_ty()),
|
|
||||||
_ => NoExpectation,
|
|
||||||
});
|
|
||||||
let referent_ty = self.check_expr_with_expectation(expr, expected_inner);
|
|
||||||
self.require_type_is_sized(referent_ty, expr.span, traits::SizedBoxType);
|
|
||||||
self.tcx.mk_box(referent_ty)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_expr_unary(
|
fn check_expr_unary(
|
||||||
&self,
|
&self,
|
||||||
unop: hir::UnOp,
|
unop: hir::UnOp,
|
||||||
|
@ -356,10 +356,6 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||||||
self.walk_captures(closure);
|
self.walk_captures(closure);
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprKind::Box(ref base) => {
|
|
||||||
self.consume_expr(base);
|
|
||||||
}
|
|
||||||
|
|
||||||
hir::ExprKind::Yield(value, _) => {
|
hir::ExprKind::Yield(value, _) => {
|
||||||
self.consume_expr(value);
|
self.consume_expr(value);
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,6 @@ impl<'a, 'tcx> DropRangeVisitor<'a, 'tcx> {
|
|||||||
//
|
//
|
||||||
// Some of these may be interesting in the future
|
// Some of these may be interesting in the future
|
||||||
ExprKind::Path(..)
|
ExprKind::Path(..)
|
||||||
| ExprKind::Box(..)
|
|
||||||
| ExprKind::ConstBlock(..)
|
| ExprKind::ConstBlock(..)
|
||||||
| ExprKind::Array(..)
|
| ExprKind::Array(..)
|
||||||
| ExprKind::Call(..)
|
| ExprKind::Call(..)
|
||||||
@ -478,7 +477,6 @@ impl<'a, 'tcx> Visitor<'tcx> for DropRangeVisitor<'a, 'tcx> {
|
|||||||
| ExprKind::AssignOp(..)
|
| ExprKind::AssignOp(..)
|
||||||
| ExprKind::Binary(..)
|
| ExprKind::Binary(..)
|
||||||
| ExprKind::Block(..)
|
| ExprKind::Block(..)
|
||||||
| ExprKind::Box(..)
|
|
||||||
| ExprKind::Cast(..)
|
| ExprKind::Cast(..)
|
||||||
| ExprKind::Closure { .. }
|
| ExprKind::Closure { .. }
|
||||||
| ExprKind::ConstBlock(..)
|
| ExprKind::ConstBlock(..)
|
||||||
|
@ -382,7 +382,6 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||||||
| hir::ExprKind::Struct(..)
|
| hir::ExprKind::Struct(..)
|
||||||
| hir::ExprKind::Repeat(..)
|
| hir::ExprKind::Repeat(..)
|
||||||
| hir::ExprKind::InlineAsm(..)
|
| hir::ExprKind::InlineAsm(..)
|
||||||
| hir::ExprKind::Box(..)
|
|
||||||
| hir::ExprKind::Err(_) => Ok(self.cat_rvalue(expr.hir_id, expr.span, expr_ty)),
|
| hir::ExprKind::Err(_) => Ok(self.cat_rvalue(expr.hir_id, expr.span, expr_ty)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -305,8 +305,6 @@ pub enum ObligationCauseCode<'tcx> {
|
|||||||
SizedReturnType,
|
SizedReturnType,
|
||||||
/// Yield type must be `Sized`.
|
/// Yield type must be `Sized`.
|
||||||
SizedYieldType,
|
SizedYieldType,
|
||||||
/// Box expression result type must be `Sized`.
|
|
||||||
SizedBoxType,
|
|
||||||
/// Inline asm operand type must be `Sized`.
|
/// Inline asm operand type must be `Sized`.
|
||||||
InlineAsmSized,
|
InlineAsmSized,
|
||||||
/// `[expr; N]` requires `type_of(expr): Copy`.
|
/// `[expr; N]` requires `type_of(expr): Copy`.
|
||||||
|
@ -780,7 +780,6 @@ impl<'tcx> Cx<'tcx> {
|
|||||||
hir::ExprKind::DropTemps(ref source) => {
|
hir::ExprKind::DropTemps(ref source) => {
|
||||||
ExprKind::Use { source: self.mirror_expr(source) }
|
ExprKind::Use { source: self.mirror_expr(source) }
|
||||||
}
|
}
|
||||||
hir::ExprKind::Box(ref value) => ExprKind::Box { value: self.mirror_expr(value) },
|
|
||||||
hir::ExprKind::Array(ref fields) => {
|
hir::ExprKind::Array(ref fields) => {
|
||||||
ExprKind::Array { fields: self.mirror_exprs(fields) }
|
ExprKind::Array { fields: self.mirror_exprs(fields) }
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
|
|||||||
record_variants!(
|
record_variants!(
|
||||||
(self, e, e.kind, Id::Node(e.hir_id), hir, Expr, ExprKind),
|
(self, e, e.kind, Id::Node(e.hir_id), hir, Expr, ExprKind),
|
||||||
[
|
[
|
||||||
Box, ConstBlock, Array, Call, MethodCall, Tup, Binary, Unary, Lit, Cast, Type,
|
ConstBlock, Array, Call, MethodCall, Tup, Binary, Unary, Lit, Cast, Type,
|
||||||
DropTemps, Let, If, Loop, Match, Closure, Block, Assign, AssignOp, Field, Index,
|
DropTemps, Let, If, Loop, Match, Closure, Block, Assign, AssignOp, Field, Index,
|
||||||
Path, AddrOf, Break, Continue, Ret, InlineAsm, Struct, Repeat, Yield, Err
|
Path, AddrOf, Break, Continue, Ret, InlineAsm, Struct, Repeat, Yield, Err
|
||||||
]
|
]
|
||||||
|
@ -473,7 +473,6 @@ impl<'tcx> Visitor<'tcx> for IrMaps<'tcx> {
|
|||||||
| hir::ExprKind::Struct(..)
|
| hir::ExprKind::Struct(..)
|
||||||
| hir::ExprKind::Repeat(..)
|
| hir::ExprKind::Repeat(..)
|
||||||
| hir::ExprKind::InlineAsm(..)
|
| hir::ExprKind::InlineAsm(..)
|
||||||
| hir::ExprKind::Box(..)
|
|
||||||
| hir::ExprKind::Type(..)
|
| hir::ExprKind::Type(..)
|
||||||
| hir::ExprKind::Err(_)
|
| hir::ExprKind::Err(_)
|
||||||
| hir::ExprKind::Path(hir::QPath::TypeRelative(..))
|
| hir::ExprKind::Path(hir::QPath::TypeRelative(..))
|
||||||
@ -1059,8 +1058,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
|||||||
self.propagate_through_expr(&l, r_succ)
|
self.propagate_through_expr(&l, r_succ)
|
||||||
}
|
}
|
||||||
|
|
||||||
hir::ExprKind::Box(ref e)
|
hir::ExprKind::AddrOf(_, _, ref e)
|
||||||
| hir::ExprKind::AddrOf(_, _, ref e)
|
|
||||||
| hir::ExprKind::Cast(ref e, _)
|
| hir::ExprKind::Cast(ref e, _)
|
||||||
| hir::ExprKind::Type(ref e, _)
|
| hir::ExprKind::Type(ref e, _)
|
||||||
| hir::ExprKind::DropTemps(ref e)
|
| hir::ExprKind::DropTemps(ref e)
|
||||||
@ -1425,7 +1423,6 @@ fn check_expr<'tcx>(this: &mut Liveness<'_, 'tcx>, expr: &'tcx Expr<'tcx>) {
|
|||||||
| hir::ExprKind::Closure { .. }
|
| hir::ExprKind::Closure { .. }
|
||||||
| hir::ExprKind::Path(_)
|
| hir::ExprKind::Path(_)
|
||||||
| hir::ExprKind::Yield(..)
|
| hir::ExprKind::Yield(..)
|
||||||
| hir::ExprKind::Box(..)
|
|
||||||
| hir::ExprKind::Type(..)
|
| hir::ExprKind::Type(..)
|
||||||
| hir::ExprKind::Err(_) => {}
|
| hir::ExprKind::Err(_) => {}
|
||||||
}
|
}
|
||||||
|
@ -179,8 +179,7 @@ enum ItemKind {
|
|||||||
impl<'tcx> CheckInlineAssembly<'tcx> {
|
impl<'tcx> CheckInlineAssembly<'tcx> {
|
||||||
fn check_expr(&mut self, expr: &'tcx hir::Expr<'tcx>, span: Span) {
|
fn check_expr(&mut self, expr: &'tcx hir::Expr<'tcx>, span: Span) {
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
ExprKind::Box(..)
|
ExprKind::ConstBlock(..)
|
||||||
| ExprKind::ConstBlock(..)
|
|
||||||
| ExprKind::Array(..)
|
| ExprKind::Array(..)
|
||||||
| ExprKind::Call(..)
|
| ExprKind::Call(..)
|
||||||
| ExprKind::MethodCall(..)
|
| ExprKind::MethodCall(..)
|
||||||
|
@ -2944,9 +2944,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||||||
ObligationCauseCode::SizedYieldType => {
|
ObligationCauseCode::SizedYieldType => {
|
||||||
err.note("the yield type of a generator must have a statically known size");
|
err.note("the yield type of a generator must have a statically known size");
|
||||||
}
|
}
|
||||||
ObligationCauseCode::SizedBoxType => {
|
|
||||||
err.note("the type of a box expression must have a statically known size");
|
|
||||||
}
|
|
||||||
ObligationCauseCode::AssignmentLhsSized => {
|
ObligationCauseCode::AssignmentLhsSized => {
|
||||||
err.note("the left-hand-side of an assignment must have a statically known size");
|
err.note("the left-hand-side of an assignment must have a statically known size");
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
|
|||||||
Finite
|
Finite
|
||||||
},
|
},
|
||||||
ExprKind::Block(block, _) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)),
|
ExprKind::Block(block, _) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)),
|
||||||
ExprKind::Box(e) | ExprKind::AddrOf(BorrowKind::Ref, _, e) => is_infinite(cx, e),
|
ExprKind::AddrOf(BorrowKind::Ref, _, e) => is_infinite(cx, e),
|
||||||
ExprKind::Call(path, _) => {
|
ExprKind::Call(path, _) => {
|
||||||
if let ExprKind::Path(ref qpath) = path.kind {
|
if let ExprKind::Path(ref qpath) = path.kind {
|
||||||
cx.qpath_res(qpath, path.hir_id)
|
cx.qpath_res(qpath, path.hir_id)
|
||||||
|
@ -124,8 +124,7 @@ fn stmt_to_expr<'tcx>(stmt: &Stmt<'tcx>) -> Option<(&'tcx Expr<'tcx>, Option<&'t
|
|||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
fn never_loop_expr(expr: &Expr<'_>, ignore_ids: &mut Vec<HirId>, main_loop_id: HirId) -> NeverLoopResult {
|
fn never_loop_expr(expr: &Expr<'_>, ignore_ids: &mut Vec<HirId>, main_loop_id: HirId) -> NeverLoopResult {
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
ExprKind::Box(e)
|
ExprKind::Unary(_, e)
|
||||||
| ExprKind::Unary(_, e)
|
|
||||||
| ExprKind::Cast(e, _)
|
| ExprKind::Cast(e, _)
|
||||||
| ExprKind::Type(e, _)
|
| ExprKind::Type(e, _)
|
||||||
| ExprKind::Field(e, _)
|
| ExprKind::Field(e, _)
|
||||||
|
@ -321,7 +321,6 @@ impl<'a, 'tcx> Visitor<'tcx> for SigDropHelper<'a, 'tcx> {
|
|||||||
self.has_significant_drop = true;
|
self.has_significant_drop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExprKind::Box(..) |
|
|
||||||
ExprKind::Array(..) |
|
ExprKind::Array(..) |
|
||||||
ExprKind::Call(..) |
|
ExprKind::Call(..) |
|
||||||
ExprKind::Unary(..) |
|
ExprKind::Unary(..) |
|
||||||
|
@ -33,10 +33,6 @@ struct SortByKeyDetection {
|
|||||||
/// contains a and the other replaces it with b)
|
/// contains a and the other replaces it with b)
|
||||||
fn mirrored_exprs(a_expr: &Expr<'_>, a_ident: &Ident, b_expr: &Expr<'_>, b_ident: &Ident) -> bool {
|
fn mirrored_exprs(a_expr: &Expr<'_>, a_ident: &Ident, b_expr: &Expr<'_>, b_ident: &Ident) -> bool {
|
||||||
match (&a_expr.kind, &b_expr.kind) {
|
match (&a_expr.kind, &b_expr.kind) {
|
||||||
// Two boxes with mirrored contents
|
|
||||||
(ExprKind::Box(left_expr), ExprKind::Box(right_expr)) => {
|
|
||||||
mirrored_exprs(left_expr, a_ident, right_expr, b_ident)
|
|
||||||
},
|
|
||||||
// Two arrays with mirrored contents
|
// Two arrays with mirrored contents
|
||||||
(ExprKind::Array(left_exprs), ExprKind::Array(right_exprs)) => {
|
(ExprKind::Array(left_exprs), ExprKind::Array(right_exprs)) => {
|
||||||
iter::zip(*left_exprs, *right_exprs).all(|(left, right)| mirrored_exprs(left, a_ident, right, b_ident))
|
iter::zip(*left_exprs, *right_exprs).all(|(left, right)| mirrored_exprs(left, a_ident, right, b_ident))
|
||||||
|
@ -127,8 +127,7 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
|||||||
| ExprKind::Type(inner, _)
|
| ExprKind::Type(inner, _)
|
||||||
| ExprKind::Unary(_, inner)
|
| ExprKind::Unary(_, inner)
|
||||||
| ExprKind::Field(inner, _)
|
| ExprKind::Field(inner, _)
|
||||||
| ExprKind::AddrOf(_, _, inner)
|
| ExprKind::AddrOf(_, _, inner) => has_no_effect(cx, inner),
|
||||||
| ExprKind::Box(inner) => has_no_effect(cx, inner),
|
|
||||||
ExprKind::Struct(_, fields, ref base) => {
|
ExprKind::Struct(_, fields, ref base) => {
|
||||||
!has_drop(cx, cx.typeck_results().expr_ty(expr))
|
!has_drop(cx, cx.typeck_results().expr_ty(expr))
|
||||||
&& fields.iter().all(|field| has_no_effect(cx, field.expr))
|
&& fields.iter().all(|field| has_no_effect(cx, field.expr))
|
||||||
@ -234,8 +233,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<Vec
|
|||||||
| ExprKind::Type(inner, _)
|
| ExprKind::Type(inner, _)
|
||||||
| ExprKind::Unary(_, inner)
|
| ExprKind::Unary(_, inner)
|
||||||
| ExprKind::Field(inner, _)
|
| ExprKind::Field(inner, _)
|
||||||
| ExprKind::AddrOf(_, _, inner)
|
| ExprKind::AddrOf(_, _, inner) => reduce_expression(cx, inner).or_else(|| Some(vec![inner])),
|
||||||
| ExprKind::Box(inner) => reduce_expression(cx, inner).or_else(|| Some(vec![inner])),
|
|
||||||
ExprKind::Struct(_, fields, ref base) => {
|
ExprKind::Struct(_, fields, ref base) => {
|
||||||
if has_drop(cx, cx.typeck_results().expr_ty(expr)) {
|
if has_drop(cx, cx.typeck_results().expr_ty(expr)) {
|
||||||
None
|
None
|
||||||
|
@ -213,8 +213,7 @@ fn is_self_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, mut expr: &Expr<'_>, hir_
|
|||||||
}
|
}
|
||||||
loop {
|
loop {
|
||||||
expr = match expr.kind {
|
expr = match expr.kind {
|
||||||
ExprKind::Box(e)
|
ExprKind::AddrOf(_, _, e)
|
||||||
| ExprKind::AddrOf(_, _, e)
|
|
||||||
| ExprKind::Block(
|
| ExprKind::Block(
|
||||||
&Block {
|
&Block {
|
||||||
stmts: [],
|
stmts: [],
|
||||||
|
@ -380,7 +380,6 @@ impl<'cx, 'sdt, 'tcx> Visitor<'tcx> for SigDropFinder<'cx, 'sdt, 'tcx> {
|
|||||||
| hir::ExprKind::Assign(..)
|
| hir::ExprKind::Assign(..)
|
||||||
| hir::ExprKind::AssignOp(..)
|
| hir::ExprKind::AssignOp(..)
|
||||||
| hir::ExprKind::Binary(..)
|
| hir::ExprKind::Binary(..)
|
||||||
| hir::ExprKind::Box(..)
|
|
||||||
| hir::ExprKind::Call(..)
|
| hir::ExprKind::Call(..)
|
||||||
| hir::ExprKind::Field(..)
|
| hir::ExprKind::Field(..)
|
||||||
| hir::ExprKind::If(..)
|
| hir::ExprKind::If(..)
|
||||||
|
@ -395,11 +395,6 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
self.expr(field!(let_expr.init));
|
self.expr(field!(let_expr.init));
|
||||||
},
|
},
|
||||||
ExprKind::Box(inner) => {
|
|
||||||
bind!(self, inner);
|
|
||||||
kind!("Box({inner})");
|
|
||||||
self.expr(inner);
|
|
||||||
},
|
|
||||||
ExprKind::Array(elements) => {
|
ExprKind::Array(elements) => {
|
||||||
bind!(self, elements);
|
bind!(self, elements);
|
||||||
kind!("Array({elements})");
|
kind!("Array({elements})");
|
||||||
|
@ -112,7 +112,6 @@ fn qpath_search_pat(path: &QPath<'_>) -> (Pat, Pat) {
|
|||||||
/// Get the search patterns to use for the given expression
|
/// Get the search patterns to use for the given expression
|
||||||
fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) {
|
fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) {
|
||||||
match e.kind {
|
match e.kind {
|
||||||
ExprKind::Box(e) => (Pat::Str("box"), expr_search_pat(tcx, e).1),
|
|
||||||
ExprKind::ConstBlock(_) => (Pat::Str("const"), Pat::Str("}")),
|
ExprKind::ConstBlock(_) => (Pat::Str("const"), Pat::Str("}")),
|
||||||
ExprKind::Tup([]) => (Pat::Str(")"), Pat::Str("(")),
|
ExprKind::Tup([]) => (Pat::Str(")"), Pat::Str("(")),
|
||||||
ExprKind::Unary(UnOp::Deref, e) => (Pat::Str("*"), expr_search_pat(tcx, e).1),
|
ExprKind::Unary(UnOp::Deref, e) => (Pat::Str("*"), expr_search_pat(tcx, e).1),
|
||||||
|
@ -199,8 +199,7 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Memory allocation, custom operator, loop, or call to an unknown function
|
// Memory allocation, custom operator, loop, or call to an unknown function
|
||||||
ExprKind::Box(_)
|
ExprKind::Unary(..)
|
||||||
| ExprKind::Unary(..)
|
|
||||||
| ExprKind::Binary(..)
|
| ExprKind::Binary(..)
|
||||||
| ExprKind::Loop(..)
|
| ExprKind::Loop(..)
|
||||||
| ExprKind::Call(..) => self.eagerness = Lazy,
|
| ExprKind::Call(..) => self.eagerness = Lazy,
|
||||||
|
@ -249,7 +249,6 @@ impl HirEqInterExpr<'_, '_, '_> {
|
|||||||
both(&li.label, &ri.label, |l, r| l.ident.name == r.ident.name)
|
both(&li.label, &ri.label, |l, r| l.ident.name == r.ident.name)
|
||||||
&& both(le, re, |l, r| self.eq_expr(l, r))
|
&& both(le, re, |l, r| self.eq_expr(l, r))
|
||||||
},
|
},
|
||||||
(&ExprKind::Box(l), &ExprKind::Box(r)) => self.eq_expr(l, r),
|
|
||||||
(&ExprKind::Call(l_fun, l_args), &ExprKind::Call(r_fun, r_args)) => {
|
(&ExprKind::Call(l_fun, l_args), &ExprKind::Call(r_fun, r_args)) => {
|
||||||
self.inner.allow_side_effects && self.eq_expr(l_fun, r_fun) && self.eq_exprs(l_args, r_args)
|
self.inner.allow_side_effects && self.eq_expr(l_fun, r_fun) && self.eq_exprs(l_args, r_args)
|
||||||
},
|
},
|
||||||
@ -628,7 +627,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
|||||||
self.hash_expr(j);
|
self.hash_expr(j);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExprKind::Box(e) | ExprKind::DropTemps(e) | ExprKind::Yield(e, _) => {
|
ExprKind::DropTemps(e) | ExprKind::Yield(e, _) => {
|
||||||
self.hash_expr(e);
|
self.hash_expr(e);
|
||||||
},
|
},
|
||||||
ExprKind::Call(fun, args) => {
|
ExprKind::Call(fun, args) => {
|
||||||
|
@ -133,7 +133,6 @@ impl<'a> Sugg<'a> {
|
|||||||
|
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
hir::ExprKind::AddrOf(..)
|
hir::ExprKind::AddrOf(..)
|
||||||
| hir::ExprKind::Box(..)
|
|
||||||
| hir::ExprKind::If(..)
|
| hir::ExprKind::If(..)
|
||||||
| hir::ExprKind::Let(..)
|
| hir::ExprKind::Let(..)
|
||||||
| hir::ExprKind::Closure { .. }
|
| hir::ExprKind::Closure { .. }
|
||||||
|
@ -600,7 +600,6 @@ pub fn for_each_unconsumed_temporary<'tcx, B>(
|
|||||||
helper(typeck, false, e, f)?;
|
helper(typeck, false, e, f)?;
|
||||||
},
|
},
|
||||||
ExprKind::Block(&Block { expr: Some(e), .. }, _)
|
ExprKind::Block(&Block { expr: Some(e), .. }, _)
|
||||||
| ExprKind::Box(e)
|
|
||||||
| ExprKind::Cast(e, _)
|
| ExprKind::Cast(e, _)
|
||||||
| ExprKind::Unary(_, e) => {
|
| ExprKind::Unary(_, e) => {
|
||||||
helper(typeck, true, e, f)?;
|
helper(typeck, true, e, f)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user