Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0e14a75

Browse files
committed
Reduce the span in from_over_into to impl header
1 parent 8e5c5a6 commit 0e14a75

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)