Skip to content

Commit 2950c8e

Browse files
committed
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 #6476 (comment) > That item might be quite large. We may want to reduce the span to the `impl` header. changelog: none
2 parents e15bef9 + 0e14a75 commit 2950c8e

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

clippy_lints/src/from_over_into.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl LateLintPass<'_> for FromOverInto {
7070
span_lint_and_help(
7171
cx,
7272
FROM_OVER_INTO,
73-
item.span,
73+
cx.tcx.sess.source_map().guess_head_span(item.span),
7474
"an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true",
7575
None,
7676
"consider to implement `From` instead",

tests/ui/from_over_into.stderr

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
22
--> $DIR/from_over_into.rs:6:1
33
|
4-
LL | / impl Into<StringWrapper> for String {
5-
LL | | fn into(self) -> StringWrapper {
6-
LL | | StringWrapper(self)
7-
LL | | }
8-
LL | | }
9-
| |_^
4+
LL | impl Into<StringWrapper> for String {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106
|
117
= note: `-D clippy::from-over-into` implied by `-D warnings`
128
= help: consider to implement `From` instead

0 commit comments

Comments
 (0)