Skip to content

Commit

Permalink
Auto merge of rust-lang#6566 - giraffate:reduce_the_span_in_from_over…
Browse files Browse the repository at this point in the history
…_into, r=Manishearth

Reduce the span in `from_over_into` to impl header

A follow up of rust-lang/rust-clippy#6476 (comment)
> That item might be quite large. We may want to reduce the span to the `impl` header.

changelog: none
  • Loading branch information
bors committed Jan 8, 2021
2 parents e15bef9 + 0e14a75 commit 2950c8e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/from_over_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 2 additions & 6 deletions tests/ui/from_over_into.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 2950c8e

Please sign in to comment.