Skip to content

From over Into for external crate types which is impossible to implement #9638

Closed
@Firstyear

Description

@Firstyear

Summary

Clippy lints stating that from over into is preferred is impossible to satisfy. You can't implement a trait on a struct from an external crate.

Also common to hit with should_implement_trait.

Clippy should not recommend From over Into or Should implement trait when the target type is an out of crate type which is impossible to compile for.

Lint Name

from_over_into

Reproducer

error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
   --> webauthn-rs-proto/src/extensions.rs:186:1
    |
186 | impl Into<js_sys::Object> for &RequestAuthenticationExtensions {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider to implement `From<&extensions::RequestAuthenticationExtensions>` instead
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into

Version

rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: aarch64-apple-darwin
release: 1.64.0
LLVM version: 14.0.6

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions