Fix #[expect]
for clippy::boxed_local
This commit is contained in:
parent
b6ee6bba4c
commit
b2976980b5
@ -1,4 +1,4 @@
|
||||
use clippy_utils::diagnostics::span_lint;
|
||||
use clippy_utils::diagnostics::span_lint_hir;
|
||||
use clippy_utils::ty::contains_ty;
|
||||
use rustc_hir::intravisit;
|
||||
use rustc_hir::{self, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node};
|
||||
@ -118,9 +118,10 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
|
||||
});
|
||||
|
||||
for node in v.set {
|
||||
span_lint(
|
||||
span_lint_hir(
|
||||
cx,
|
||||
BOXED_LOCAL,
|
||||
node,
|
||||
cx.tcx.hir().span(node),
|
||||
"local variable doesn't need to be boxed here",
|
||||
);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![feature(box_syntax)]
|
||||
#![feature(lint_reasons)]
|
||||
#![allow(
|
||||
clippy::borrowed_box,
|
||||
clippy::needless_pass_by_value,
|
||||
@ -202,3 +203,8 @@ mod issue4804 {
|
||||
fn foo(x: Box<u32>) {}
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(clippy::boxed_local)]
|
||||
fn check_expect(x: Box<A>) {
|
||||
x.foo();
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:40:13
|
||||
--> $DIR/boxed_local.rs:41:13
|
||||
|
|
||||
LL | fn warn_arg(x: Box<A>) {
|
||||
| ^
|
||||
@ -7,19 +7,19 @@ LL | fn warn_arg(x: Box<A>) {
|
||||
= note: `-D clippy::boxed-local` implied by `-D warnings`
|
||||
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:131:12
|
||||
--> $DIR/boxed_local.rs:132:12
|
||||
|
|
||||
LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:195:44
|
||||
--> $DIR/boxed_local.rs:196:44
|
||||
|
|
||||
LL | fn default_impl_x(self: Box<Self>, x: Box<u32>) -> u32 {
|
||||
| ^
|
||||
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:202:16
|
||||
--> $DIR/boxed_local.rs:203:16
|
||||
|
|
||||
LL | fn foo(x: Box<u32>) {}
|
||||
| ^
|
Loading…
x
Reference in New Issue
Block a user