mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 05:03:21 +00:00
Shorten def_span for more items.
This commit is contained in:
parent
09f5df5087
commit
d5e33d3ded
5 changed files with 18 additions and 33 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue