Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b297698

Browse files
committed
Fix #[expect] for clippy::boxed_local
1 parent b6ee6bb commit b297698

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

clippy_lints/src/escape.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clippy_utils::diagnostics::span_lint;
1+
use clippy_utils::diagnostics::span_lint_hir;
22
use clippy_utils::ty::contains_ty;
33
use rustc_hir::intravisit;
44
use rustc_hir::{self, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node};
@@ -118,9 +118,10 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
118118
});
119119

120120
for node in v.set {
121-
span_lint(
121+
span_lint_hir(
122122
cx,
123123
BOXED_LOCAL,
124+
node,
124125
cx.tcx.hir().span(node),
125126
"local variable doesn't need to be boxed here",
126127
);

tests/ui/escape_analysis.rs renamed to tests/ui/boxed_local.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(box_syntax)]
2+
#![feature(lint_reasons)]
23
#![allow(
34
clippy::borrowed_box,
45
clippy::needless_pass_by_value,
@@ -202,3 +203,8 @@ mod issue4804 {
202203
fn foo(x: Box<u32>) {}
203204
}
204205
}
206+
207+
#[expect(clippy::boxed_local)]
208+
fn check_expect(x: Box<A>) {
209+
x.foo();
210+
}

tests/ui/escape_analysis.stderr renamed to tests/ui/boxed_local.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
error: local variable doesn't need to be boxed here
2-
--> $DIR/escape_analysis.rs:40:13
2+
--> $DIR/boxed_local.rs:41:13
33
|
44
LL | fn warn_arg(x: Box<A>) {
55
| ^
66
|
77
= note: `-D clippy::boxed-local` implied by `-D warnings`
88

99
error: local variable doesn't need to be boxed here
10-
--> $DIR/escape_analysis.rs:131:12
10+
--> $DIR/boxed_local.rs:132:12
1111
|
1212
LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
1313
| ^^^^^^^^^^^
1414

1515
error: local variable doesn't need to be boxed here
16-
--> $DIR/escape_analysis.rs:195:44
16+
--> $DIR/boxed_local.rs:196:44
1717
|
1818
LL | fn default_impl_x(self: Box<Self>, x: Box<u32>) -> u32 {
1919
| ^
2020

2121
error: local variable doesn't need to be boxed here
22-
--> $DIR/escape_analysis.rs:202:16
22+
--> $DIR/boxed_local.rs:203:16
2323
|
2424
LL | fn foo(x: Box<u32>) {}
2525
| ^

0 commit comments

Comments
 (0)