Skip to content

Commit 60fe49c

Browse files
authored
Rollup merge of rust-lang#108958 - clubby789:unbox-the-hir, r=compiler-errors
Remove box expressions from HIR After rust-lang#108516, `#[rustc_box]` is used at HIR->THIR lowering and this is no longer emitted, so it can be removed. This is based on top of rust-lang#108471 to help with conflicts, so 43490488ccacd1a822e9c621f5ed6fca99959a0b is the only relevant commit (sorry for all the duplicated pings!) ````@rustbot```` label +S-blocked
2 parents d1b28f3 + f2eddc5 commit 60fe49c

13 files changed

+7
-27
lines changed

clippy_lints/src/infinite_iter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn is_infinite(cx: &LateContext<'_>, expr: &Expr<'_>) -> Finiteness {
167167
Finite
168168
},
169169
ExprKind::Block(block, _) => block.expr.as_ref().map_or(Finite, |e| is_infinite(cx, e)),
170-
ExprKind::Box(e) | ExprKind::AddrOf(BorrowKind::Ref, _, e) => is_infinite(cx, e),
170+
ExprKind::AddrOf(BorrowKind::Ref, _, e) => is_infinite(cx, e),
171171
ExprKind::Call(path, _) => {
172172
if let ExprKind::Path(ref qpath) = path.kind {
173173
cx.qpath_res(qpath, path.hir_id)

clippy_lints/src/loops/never_loop.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ fn stmt_to_expr<'tcx>(stmt: &Stmt<'tcx>) -> Option<(&'tcx Expr<'tcx>, Option<&'t
124124
#[allow(clippy::too_many_lines)]
125125
fn never_loop_expr(expr: &Expr<'_>, ignore_ids: &mut Vec<HirId>, main_loop_id: HirId) -> NeverLoopResult {
126126
match expr.kind {
127-
ExprKind::Box(e)
128-
| ExprKind::Unary(_, e)
127+
ExprKind::Unary(_, e)
129128
| ExprKind::Cast(e, _)
130129
| ExprKind::Type(e, _)
131130
| ExprKind::Field(e, _)

clippy_lints/src/matches/significant_drop_in_scrutinee.rs

-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ impl<'a, 'tcx> Visitor<'tcx> for SigDropHelper<'a, 'tcx> {
321321
self.has_significant_drop = true;
322322
}
323323
}
324-
ExprKind::Box(..) |
325324
ExprKind::Array(..) |
326325
ExprKind::Call(..) |
327326
ExprKind::Unary(..) |

clippy_lints/src/methods/unnecessary_sort_by.rs

-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ struct SortByKeyDetection {
3333
/// contains a and the other replaces it with b)
3434
fn mirrored_exprs(a_expr: &Expr<'_>, a_ident: &Ident, b_expr: &Expr<'_>, b_ident: &Ident) -> bool {
3535
match (&a_expr.kind, &b_expr.kind) {
36-
// Two boxes with mirrored contents
37-
(ExprKind::Box(left_expr), ExprKind::Box(right_expr)) => {
38-
mirrored_exprs(left_expr, a_ident, right_expr, b_ident)
39-
},
4036
// Two arrays with mirrored contents
4137
(ExprKind::Array(left_exprs), ExprKind::Array(right_exprs)) => {
4238
iter::zip(*left_exprs, *right_exprs).all(|(left, right)| mirrored_exprs(left, a_ident, right, b_ident))

clippy_lints/src/no_effect.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
127127
| ExprKind::Type(inner, _)
128128
| ExprKind::Unary(_, inner)
129129
| ExprKind::Field(inner, _)
130-
| ExprKind::AddrOf(_, _, inner)
131-
| ExprKind::Box(inner) => has_no_effect(cx, inner),
130+
| ExprKind::AddrOf(_, _, inner) => has_no_effect(cx, inner),
132131
ExprKind::Struct(_, fields, ref base) => {
133132
!has_drop(cx, cx.typeck_results().expr_ty(expr))
134133
&& 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
234233
| ExprKind::Type(inner, _)
235234
| ExprKind::Unary(_, inner)
236235
| ExprKind::Field(inner, _)
237-
| ExprKind::AddrOf(_, _, inner)
238-
| ExprKind::Box(inner) => reduce_expression(cx, inner).or_else(|| Some(vec![inner])),
236+
| ExprKind::AddrOf(_, _, inner) => reduce_expression(cx, inner).or_else(|| Some(vec![inner])),
239237
ExprKind::Struct(_, fields, ref base) => {
240238
if has_drop(cx, cx.typeck_results().expr_ty(expr)) {
241239
None

clippy_lints/src/shadow.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ fn is_self_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, mut expr: &Expr<'_>, hir_
213213
}
214214
loop {
215215
expr = match expr.kind {
216-
ExprKind::Box(e)
217-
| ExprKind::AddrOf(_, _, e)
216+
ExprKind::AddrOf(_, _, e)
218217
| ExprKind::Block(
219218
&Block {
220219
stmts: [],

clippy_lints/src/significant_drop_tightening.rs

-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ impl<'cx, 'sdt, 'tcx> Visitor<'tcx> for SigDropFinder<'cx, 'sdt, 'tcx> {
380380
| hir::ExprKind::Assign(..)
381381
| hir::ExprKind::AssignOp(..)
382382
| hir::ExprKind::Binary(..)
383-
| hir::ExprKind::Box(..)
384383
| hir::ExprKind::Call(..)
385384
| hir::ExprKind::Field(..)
386385
| hir::ExprKind::If(..)

clippy_lints/src/utils/author.rs

-5
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,6 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
395395
}
396396
self.expr(field!(let_expr.init));
397397
},
398-
ExprKind::Box(inner) => {
399-
bind!(self, inner);
400-
kind!("Box({inner})");
401-
self.expr(inner);
402-
},
403398
ExprKind::Array(elements) => {
404399
bind!(self, elements);
405400
kind!("Array({elements})");

clippy_utils/src/check_proc_macro.rs

-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ fn qpath_search_pat(path: &QPath<'_>) -> (Pat, Pat) {
112112
/// Get the search patterns to use for the given expression
113113
fn expr_search_pat(tcx: TyCtxt<'_>, e: &Expr<'_>) -> (Pat, Pat) {
114114
match e.kind {
115-
ExprKind::Box(e) => (Pat::Str("box"), expr_search_pat(tcx, e).1),
116115
ExprKind::ConstBlock(_) => (Pat::Str("const"), Pat::Str("}")),
117116
ExprKind::Tup([]) => (Pat::Str(")"), Pat::Str("(")),
118117
ExprKind::Unary(UnOp::Deref, e) => (Pat::Str("*"), expr_search_pat(tcx, e).1),

clippy_utils/src/eager_or_lazy.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ fn expr_eagerness<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> EagernessS
199199
},
200200

201201
// Memory allocation, custom operator, loop, or call to an unknown function
202-
ExprKind::Box(_)
203-
| ExprKind::Unary(..)
202+
ExprKind::Unary(..)
204203
| ExprKind::Binary(..)
205204
| ExprKind::Loop(..)
206205
| ExprKind::Call(..) => self.eagerness = Lazy,

clippy_utils/src/hir_utils.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ impl HirEqInterExpr<'_, '_, '_> {
249249
both(&li.label, &ri.label, |l, r| l.ident.name == r.ident.name)
250250
&& both(le, re, |l, r| self.eq_expr(l, r))
251251
},
252-
(&ExprKind::Box(l), &ExprKind::Box(r)) => self.eq_expr(l, r),
253252
(&ExprKind::Call(l_fun, l_args), &ExprKind::Call(r_fun, r_args)) => {
254253
self.inner.allow_side_effects && self.eq_expr(l_fun, r_fun) && self.eq_exprs(l_args, r_args)
255254
},
@@ -628,7 +627,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
628627
self.hash_expr(j);
629628
}
630629
},
631-
ExprKind::Box(e) | ExprKind::DropTemps(e) | ExprKind::Yield(e, _) => {
630+
ExprKind::DropTemps(e) | ExprKind::Yield(e, _) => {
632631
self.hash_expr(e);
633632
},
634633
ExprKind::Call(fun, args) => {

clippy_utils/src/sugg.rs

-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ impl<'a> Sugg<'a> {
133133

134134
match expr.kind {
135135
hir::ExprKind::AddrOf(..)
136-
| hir::ExprKind::Box(..)
137136
| hir::ExprKind::If(..)
138137
| hir::ExprKind::Let(..)
139138
| hir::ExprKind::Closure { .. }

clippy_utils/src/visitors.rs

-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ pub fn for_each_unconsumed_temporary<'tcx, B>(
600600
helper(typeck, false, e, f)?;
601601
},
602602
ExprKind::Block(&Block { expr: Some(e), .. }, _)
603-
| ExprKind::Box(e)
604603
| ExprKind::Cast(e, _)
605604
| ExprKind::Unary(_, e) => {
606605
helper(typeck, true, e, f)?;

0 commit comments

Comments
 (0)