Skip to content

type_alias_impl_trait: from_over_into does not apply #10983

Closed
@matthiaskrgr

Description

@matthiaskrgr

Summary

.

Reproducer

I tried this code:

#![feature(type_alias_impl_trait)]

type T = impl Sized;

struct Foo;

impl Into<T> for Foo {
    fn into(self) -> T {}
}

fn main(){
    let _: T = Foo.into();
}
warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
 --> src/main.rs:7:1
  |
7 | impl Into<T> for Foo {
  | ^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into
  = note: `#[warn(clippy::from_over_into)]` on by default
help: replace the `Into` implementation with `From<Foo>`
  |
7 ~ impl From<Foo> for T {
8 ~     fn from(val: Foo) -> Self {}
  |

warning: 1 warning emitted

the suggestion does not apply:

The following errors were reported:
error[E0119]: conflicting implementations of trait `std::convert::From<T>` for type `T`
 --> src/main.rs:7:1
  |
7 | impl From<Foo> for T {
  | ^^^^^^^^^^^^^^^^^^^^
  |
  = note: conflicting implementation in crate `core`:
          - impl<T> std::convert::From<T> for T;

error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.
Original diagnostics will follow.

Version

rustc 1.72.0-nightly (3b2073f07 2023-06-17)
binary: rustc
commit-hash: 3b2073f0762cff4d3d625bb10017e0ce4e7abe50
commit-date: 2023-06-17
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions