mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
make note less verbose
This commit is contained in:
parent
b6f194b48c
commit
a5ae9044fb
2 changed files with 20 additions and 32 deletions
|
@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
|
||||||
let arg_ty = cx.typeck_results().expr_ty(arg);
|
let arg_ty = cx.typeck_results().expr_ty(arg);
|
||||||
let is_copy = is_copy(cx, arg_ty);
|
let is_copy = is_copy(cx, arg_ty);
|
||||||
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
|
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
|
||||||
let (lint, msg) = match fn_name {
|
let (lint, msg, note_span) = match fn_name {
|
||||||
// early return for uplifted lints: dropping_references, dropping_copy_types, forgetting_references, forgetting_copy_types
|
// early return for uplifted lints: dropping_references, dropping_copy_types, forgetting_references, forgetting_copy_types
|
||||||
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return,
|
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return,
|
||||||
sym::mem_forget if arg_ty.is_ref() => return,
|
sym::mem_forget if arg_ty.is_ref() => return,
|
||||||
|
@ -144,20 +144,24 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
|
||||||
|| drop_is_single_call_in_arm
|
|| drop_is_single_call_in_arm
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
(DROP_NON_DROP, DROP_NON_DROP_SUMMARY.into())
|
(DROP_NON_DROP, DROP_NON_DROP_SUMMARY.into(), Some(arg.span))
|
||||||
},
|
},
|
||||||
sym::mem_forget => {
|
sym::mem_forget => {
|
||||||
if arg_ty.needs_drop(cx.tcx, cx.param_env) {
|
if arg_ty.needs_drop(cx.tcx, cx.param_env) {
|
||||||
(MEM_FORGET, Cow::Owned(format!(
|
(
|
||||||
"usage of `mem::forget` on {}",
|
MEM_FORGET,
|
||||||
if arg_ty.ty_adt_def().map_or(false, |def| def.has_dtor(cx.tcx)) {
|
Cow::Owned(format!(
|
||||||
"`Drop` type"
|
"usage of `mem::forget` on {}",
|
||||||
} else {
|
if arg_ty.ty_adt_def().map_or(false, |def| def.has_dtor(cx.tcx)) {
|
||||||
"type with `Drop` fields"
|
"`Drop` type"
|
||||||
}
|
} else {
|
||||||
)))
|
"type with `Drop` fields"
|
||||||
|
}
|
||||||
|
)),
|
||||||
|
None,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
(FORGET_NON_DROP, FORGET_NON_DROP_SUMMARY.into())
|
(FORGET_NON_DROP, FORGET_NON_DROP_SUMMARY.into(), Some(arg.span))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => return,
|
_ => return,
|
||||||
|
@ -167,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
|
||||||
lint,
|
lint,
|
||||||
expr.span,
|
expr.span,
|
||||||
&msg,
|
&msg,
|
||||||
Some(arg.span),
|
note_span,
|
||||||
&format!("argument has type `{arg_ty}`"),
|
&format!("argument has type `{arg_ty}`"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,7 @@ error: usage of `mem::forget` on `Drop` type
|
||||||
LL | memstuff::forget(six);
|
LL | memstuff::forget(six);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: argument has type `std::sync::Arc<i32>`
|
= note: argument has type `std::sync::Arc<i32>`
|
||||||
--> $DIR/mem_forget.rs:14:22
|
|
||||||
|
|
|
||||||
LL | memstuff::forget(six);
|
|
||||||
| ^^^
|
|
||||||
= note: `-D clippy::mem-forget` implied by `-D warnings`
|
= note: `-D clippy::mem-forget` implied by `-D warnings`
|
||||||
|
|
||||||
error: usage of `mem::forget` on `Drop` type
|
error: usage of `mem::forget` on `Drop` type
|
||||||
|
@ -17,11 +13,7 @@ error: usage of `mem::forget` on `Drop` type
|
||||||
LL | std::mem::forget(seven);
|
LL | std::mem::forget(seven);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: argument has type `std::rc::Rc<i32>`
|
= note: argument has type `std::rc::Rc<i32>`
|
||||||
--> $DIR/mem_forget.rs:17:22
|
|
||||||
|
|
|
||||||
LL | std::mem::forget(seven);
|
|
||||||
| ^^^^^
|
|
||||||
|
|
||||||
error: usage of `mem::forget` on `Drop` type
|
error: usage of `mem::forget` on `Drop` type
|
||||||
--> $DIR/mem_forget.rs:20:5
|
--> $DIR/mem_forget.rs:20:5
|
||||||
|
@ -29,11 +21,7 @@ error: usage of `mem::forget` on `Drop` type
|
||||||
LL | forgetSomething(eight);
|
LL | forgetSomething(eight);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: argument has type `std::vec::Vec<i32>`
|
= note: argument has type `std::vec::Vec<i32>`
|
||||||
--> $DIR/mem_forget.rs:20:21
|
|
||||||
|
|
|
||||||
LL | forgetSomething(eight);
|
|
||||||
| ^^^^^
|
|
||||||
|
|
||||||
error: usage of `mem::forget` on type with `Drop` fields
|
error: usage of `mem::forget` on type with `Drop` fields
|
||||||
--> $DIR/mem_forget.rs:23:5
|
--> $DIR/mem_forget.rs:23:5
|
||||||
|
@ -41,11 +29,7 @@ error: usage of `mem::forget` on type with `Drop` fields
|
||||||
LL | std::mem::forget(string);
|
LL | std::mem::forget(string);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: argument has type `std::string::String`
|
= note: argument has type `std::string::String`
|
||||||
--> $DIR/mem_forget.rs:23:22
|
|
||||||
|
|
|
||||||
LL | std::mem::forget(string);
|
|
||||||
| ^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue