rust-lang / rust-lang/rust-clippy
`missing_inline_in_public_items` triggers for `impl From<Private> for Public`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the missing_inline_in_public_items lint and reproduce the report with the example in src/lib.rs. Check the lint's handling of impl From<Private> for Public; done means this private-argument method no longer produces a warning while the lint continues to cover applicable public items.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100