Skip to content

missing_inline_in_public_items triggers for impl From<Private> for Public #12911

@tguichaoua

Description

@tguichaoua

Summary

AFAIK, it's not possible to call <Public as From<Private>>::from(_) from an outer crate since Private is not accesible.
So there is no need to mark the method #[inline].

Lint Name

missing_inline_in_public_items

Reproducer

I tried this code:

#![warn(clippy::missing_inline_in_public_items)]

pub struct Public;
struct Private;

impl From<Private> for Public {
    fn from(_value: Private) -> Self {
        todo!();
    }
}

I saw this happen:

warning: missing `#[inline]` for a method
  --> src/lib.rs:8:5
   |
8  | /     fn from(_value: Private) -> Self {
9  | |         todo!();
10 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_inline_in_public_items
note: the lint level is defined here
  --> src/lib.rs:1:9
   |
1  | #![warn(clippy::missing_inline_in_public_items)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I expected to see this happen:

The lint should not trigger.

Version

rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-pc-windows-msvc
release: 1.78.0
LLVM version: 18.1.2

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