Open
Description
Code
trait Bar {}
pub trait Foo {
fn foo() -> impl Bar;
}
fn main() {}
Current output
Empty output with no warnings.
Desired output
warning: trait `Bar` is more private than the item `Foo::foo`
--> foo.rs:4:1
|
4 | fn foo() -> impl Bar;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ associated function `Foo::foo` is reachable at visibility `pub`
|
note: but trait `Bar` is only usable at visibility `pub(crate)`
--> foo.rs:1:1
|
1 | trait Bar {}
| ^^^^^^^^^
= note: `#[warn(private_interfaces)]` on by default
warning: 1 warning emitted
Rationale and extra context
No response
Other cases
Both using a concrete type or using RPIT in a method outside traits produce correct lints:
struct X;
pub trait Foo {
fn foo() -> X;
}
produces
warning: type `X` is more private than the item `Foo::foo`
trait Bar {}
impl Bar for () {}
fn foo() -> impl Bar {}
Produces
warning: trait `Bar` is more private than the item `foo`
Rust Version
rustc 1.90.0-nightly (5adb489a8 2025-07-05)
binary: rustc
commit-hash: 5adb489a8034f7b56b29f3b28af0813c866f679c
commit-date: 2025-07-05
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: Lints (warnings about flaws in source code) such as unused_mut.Area: Visibility / privacyCategory: This is a bug.Lint: False negative (should have fired but didn't).Lint: private_interfacesRelevant to the compiler team, which will review and decide on the PR/issue.