about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-01-08 01:49:26 +0000
committerbors <bors@rust-lang.org>2021-01-08 01:49:26 +0000
commit2950c8e1cb32e864b599c4b4dae896d29d86e5e7 (patch)
treebd994fa51a05d2e4e30bdeab54b0fae8a94061f6
parente15bef9d3f7ea89a821abbc861e09be285a7f619 (diff)
parent0e14a7550632f9bbe4e0f0b5589a8c38b55d649b (diff)
downloadrust-2950c8e1cb32e864b599c4b4dae896d29d86e5e7.tar.gz
rust-2950c8e1cb32e864b599c4b4dae896d29d86e5e7.zip
Auto merge of #6566 - giraffate:reduce_the_span_in_from_over_into, r=Manishearth
Reduce the span in `from_over_into` to impl header

A follow up of https://github.com/rust-lang/rust-clippy/pull/6476#discussion_r546271382
> That item might be quite large. We may want to reduce the span to the `impl` header.

changelog: none
-rw-r--r--clippy_lints/src/from_over_into.rs2
-rw-r--r--tests/ui/from_over_into.stderr8
2 files changed, 3 insertions, 7 deletions
diff --git a/clippy_lints/src/from_over_into.rs b/clippy_lints/src/from_over_into.rs
index 1e7e5f53cc2..b010abda24d 100644
--- a/clippy_lints/src/from_over_into.rs
+++ b/clippy_lints/src/from_over_into.rs
@@ -70,7 +70,7 @@ impl LateLintPass<'_> for FromOverInto {
                 span_lint_and_help(
                     cx,
                     FROM_OVER_INTO,
-                    item.span,
+                    cx.tcx.sess.source_map().guess_head_span(item.span),
                     "an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true",
                     None,
                     "consider to implement `From` instead",
diff --git a/tests/ui/from_over_into.stderr b/tests/ui/from_over_into.stderr
index 18f56f85432..b101d2704fb 100644
--- a/tests/ui/from_over_into.stderr
+++ b/tests/ui/from_over_into.stderr
@@ -1,12 +1,8 @@
 error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
   --> $DIR/from_over_into.rs:6:1
    |
-LL | / impl Into<StringWrapper> for String {
-LL | |     fn into(self) -> StringWrapper {
-LL | |         StringWrapper(self)
-LL | |     }
-LL | | }
-   | |_^
+LL | impl Into<StringWrapper> for String {
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `-D clippy::from-over-into` implied by `-D warnings`
    = help: consider to implement `From` instead