From 7b9999ca824d5a8d714c6191b9d939b59b994c75 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 13 Dec 2020 19:43:06 +0100 Subject: [PATCH] Fix clippy. --- src/tools/clippy/clippy_lints/src/functions.rs | 2 +- src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs | 2 +- src/tools/clippy/clippy_lints/src/panic_in_result_fn.rs | 2 +- src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/functions.rs b/src/tools/clippy/clippy_lints/src/functions.rs index 384d31a6bd505..fc049df8da6b3 100644 --- a/src/tools/clippy/clippy_lints/src/functions.rs +++ b/src/tools/clippy/clippy_lints/src/functions.rs @@ -255,7 +255,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions { intravisit::FnKind::Closure(_) => return, }; - let span = cx.tcx.hir().span(hir_id); + let span = cx.tcx.hir().span_with_body(hir_id); // don't warn for implementations, it's not their fault if !is_trait_impl_item(cx, hir_id) { diff --git a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs index 8b02149ab63ac..d1102542dd1d9 100644 --- a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs +++ b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs @@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn { } let def_id = cx.tcx.hir().local_def_id(hir_id); - let span = cx.tcx.hir().span(hir_id); + let span = cx.tcx.hir().span_with_body(hir_id); if in_external_macro(cx.tcx.sess, span) || is_entrypoint_fn(cx, def_id.to_def_id()) { return; diff --git a/src/tools/clippy/clippy_lints/src/panic_in_result_fn.rs b/src/tools/clippy/clippy_lints/src/panic_in_result_fn.rs index cac4e1c20849d..0e04845c5b580 100644 --- a/src/tools/clippy/clippy_lints/src/panic_in_result_fn.rs +++ b/src/tools/clippy/clippy_lints/src/panic_in_result_fn.rs @@ -45,7 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicInResultFn { if !matches!(fn_kind, FnKind::Closure(_)) && is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym::result_type) { - let span = cx.tcx.hir().span(hir_id); + let span = cx.tcx.hir().span_with_body(hir_id); lint_impl_body(cx, span, body); } } diff --git a/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs b/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs index ca3748e893aca..c5461832766ed 100644 --- a/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs +++ b/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs @@ -108,11 +108,10 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps { }); if can_sugg && !suggs.is_empty() { - let span = cx.tcx.hir().span(hir_id); span_lint_and_then( cx, UNNECESSARY_WRAPS, - span, + cx.tcx.hir().span_with_body(hir_id), format!( "this function's return value is unnecessarily wrapped by `{}`", return_type