about summary refs log tree commit diff
path: root/src/tools/clippy
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2022-02-13 16:27:59 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2022-07-01 17:39:19 +0200
commit42e4eee8931479a02c11c88ddaddb3a494e136c6 (patch)
treea1b3bade4e24fbe6bbcff84376aed94bc6505257 /src/tools/clippy
parentca1e68b3229e710c3948a361ee770d846a88e6da (diff)
downloadrust-42e4eee8931479a02c11c88ddaddb3a494e136c6.tar.gz
rust-42e4eee8931479a02c11c88ddaddb3a494e136c6.zip
Shorten def_span for more items.
Diffstat (limited to 'src/tools/clippy')
-rw-r--r--src/tools/clippy/clippy_lints/src/operators/numeric_arithmetic.rs9
-rw-r--r--src/tools/clippy/tests/ui/crashes/ice-6252.stderr2
-rw-r--r--src/tools/clippy/tests/ui/derive_hash_xor_eq.stderr16
-rw-r--r--src/tools/clippy/tests/ui/derive_ord_xor_partial_ord.stderr16
-rw-r--r--src/tools/clippy/tests/ui/needless_pass_by_value.stderr8
5 files changed, 18 insertions, 33 deletions
diff --git a/src/tools/clippy/clippy_lints/src/operators/numeric_arithmetic.rs b/src/tools/clippy/clippy_lints/src/operators/numeric_arithmetic.rs
index 82f454d02f7..b6097710dc6 100644
--- a/src/tools/clippy/clippy_lints/src/operators/numeric_arithmetic.rs
+++ b/src/tools/clippy/clippy_lints/src/operators/numeric_arithmetic.rs
@@ -96,11 +96,12 @@ impl Context {
     }
 
     pub fn enter_body(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
-        let body_owner = cx.tcx.hir().body_owner_def_id(body.id());
+        let body_owner = cx.tcx.hir().body_owner(body.id());
+        let body_owner_def_id = cx.tcx.hir().local_def_id(body_owner);
 
-        match cx.tcx.hir().body_owner_kind(body_owner) {
+        match cx.tcx.hir().body_owner_kind(body_owner_def_id) {
             hir::BodyOwnerKind::Static(_) | hir::BodyOwnerKind::Const => {
-                let body_span = cx.tcx.def_span(body_owner);
+                let body_span = cx.tcx.hir().span_with_body(body_owner);
 
                 if let Some(span) = self.const_span {
                     if span.contains(body_span) {
@@ -115,7 +116,7 @@ impl Context {
 
     pub fn body_post(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
         let body_owner = cx.tcx.hir().body_owner(body.id());
-        let body_span = cx.tcx.hir().span(body_owner);
+        let body_span = cx.tcx.hir().span_with_body(body_owner);
 
         if let Some(span) = self.const_span {
             if span.contains(body_span) {
diff --git a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr
index d930d486fde..a6a767483ed 100644
--- a/src/tools/clippy/tests/ui/crashes/ice-6252.stderr
+++ b/src/tools/clippy/tests/ui/crashes/ice-6252.stderr
@@ -25,7 +25,7 @@ error[E0046]: not all trait items implemented, missing: `VAL`
   --> $DIR/ice-6252.rs:10:1
    |
 LL |     const VAL: T;
-   |     ------------- `VAL` from trait
+   |     ------------ `VAL` from trait
 ...
 LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `VAL` in implementation
diff --git a/src/tools/clippy/tests/ui/derive_hash_xor_eq.stderr b/src/tools/clippy/tests/ui/derive_hash_xor_eq.stderr
index e5184bd1407..2a4abb0c519 100644
--- a/src/tools/clippy/tests/ui/derive_hash_xor_eq.stderr
+++ b/src/tools/clippy/tests/ui/derive_hash_xor_eq.stderr
@@ -8,12 +8,8 @@ LL | #[derive(Hash)]
 note: `PartialEq` implemented here
   --> $DIR/derive_hash_xor_eq.rs:15:1
    |
-LL | / impl PartialEq for Bar {
-LL | |     fn eq(&self, _: &Bar) -> bool {
-LL | |         true
-LL | |     }
-LL | | }
-   | |_^
+LL | impl PartialEq for Bar {
+   | ^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are deriving `Hash` but have implemented `PartialEq` explicitly
@@ -25,12 +21,8 @@ LL | #[derive(Hash)]
 note: `PartialEq` implemented here
   --> $DIR/derive_hash_xor_eq.rs:24:1
    |
-LL | / impl PartialEq<Baz> for Baz {
-LL | |     fn eq(&self, _: &Baz) -> bool {
-LL | |         true
-LL | |     }
-LL | | }
-   | |_^
+LL | impl PartialEq<Baz> for Baz {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are implementing `Hash` explicitly but have derived `PartialEq`
diff --git a/src/tools/clippy/tests/ui/derive_ord_xor_partial_ord.stderr b/src/tools/clippy/tests/ui/derive_ord_xor_partial_ord.stderr
index 32896c99dad..baf8341aba9 100644
--- a/src/tools/clippy/tests/ui/derive_ord_xor_partial_ord.stderr
+++ b/src/tools/clippy/tests/ui/derive_ord_xor_partial_ord.stderr
@@ -8,12 +8,8 @@ LL | #[derive(Ord, PartialEq, Eq)]
 note: `PartialOrd` implemented here
   --> $DIR/derive_ord_xor_partial_ord.rs:24:1
    |
-LL | / impl PartialOrd for DeriveOrd {
-LL | |     fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
-LL | |         Some(other.cmp(self))
-LL | |     }
-LL | | }
-   | |_^
+LL | impl PartialOrd for DeriveOrd {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are deriving `Ord` but have implemented `PartialOrd` explicitly
@@ -25,12 +21,8 @@ LL | #[derive(Ord, PartialEq, Eq)]
 note: `PartialOrd` implemented here
   --> $DIR/derive_ord_xor_partial_ord.rs:33:1
    |
-LL | / impl PartialOrd<DeriveOrdWithExplicitTypeVariable> for DeriveOrdWithExplicitTypeVariable {
-LL | |     fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
-LL | |         Some(other.cmp(self))
-LL | |     }
-LL | | }
-   | |_^
+LL | impl PartialOrd<DeriveOrdWithExplicitTypeVariable> for DeriveOrdWithExplicitTypeVariable {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are implementing `Ord` explicitly but have derived `PartialOrd`
diff --git a/src/tools/clippy/tests/ui/needless_pass_by_value.stderr b/src/tools/clippy/tests/ui/needless_pass_by_value.stderr
index d960c86a9f0..38f33c53f12 100644
--- a/src/tools/clippy/tests/ui/needless_pass_by_value.stderr
+++ b/src/tools/clippy/tests/ui/needless_pass_by_value.stderr
@@ -124,7 +124,7 @@ help: consider marking this type as `Copy`
   --> $DIR/needless_pass_by_value.rs:123:1
    |
 LL | struct CopyWrapper(u32);
-   | ^^^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^^^^
 
 error: this argument is passed by value, but not consumed in the function body
   --> $DIR/needless_pass_by_value.rs:131:29
@@ -136,7 +136,7 @@ help: consider marking this type as `Copy`
   --> $DIR/needless_pass_by_value.rs:123:1
    |
 LL | struct CopyWrapper(u32);
-   | ^^^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^^^^
 
 error: this argument is passed by value, but not consumed in the function body
   --> $DIR/needless_pass_by_value.rs:131:45
@@ -148,7 +148,7 @@ help: consider marking this type as `Copy`
   --> $DIR/needless_pass_by_value.rs:123:1
    |
 LL | struct CopyWrapper(u32);
-   | ^^^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^^^^
 
 error: this argument is passed by value, but not consumed in the function body
   --> $DIR/needless_pass_by_value.rs:131:61
@@ -160,7 +160,7 @@ help: consider marking this type as `Copy`
   --> $DIR/needless_pass_by_value.rs:123:1
    |
 LL | struct CopyWrapper(u32);
-   | ^^^^^^^^^^^^^^^^^^^^^^^^
+   | ^^^^^^^^^^^^^^^^^^
 
 error: this argument is passed by value, but not consumed in the function body
   --> $DIR/needless_pass_by_value.rs:143:40