Open MolotovCherry opened 1 month ago
Slightly minimized:
mod something {
pub fn builder() -> WantsNext {
WantsNext
}
struct WantsNext;
impl WantsNext {
pub fn next(self) -> WantsFinish {
WantsFinish
}
}
struct WantsFinish;
impl WantsFinish {
pub fn finish(self) {}
}
}
fn main() {
something::builder().next().finish();
}
Output:
Compiling playground v0.0.1 (/playground)
warning: type `WantsNext` is more private than the item `builder`
--> src/main.rs:2:5
|
2 | pub fn builder() -> WantsNext {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function `builder` is reachable at visibility `pub(crate)`
|
note: but type `WantsNext` is only usable at visibility `pub(self)`
--> src/main.rs:6:5
|
6 | struct WantsNext;
| ^^^^^^^^^^^^^^^^
= note: `#[warn(private_interfaces)]` on by default
error: type `WantsFinish` is private
--> src/main.rs:20:33
|
20 | something::builder().next().finish();
| ^^^^^^ private type
warning: `playground` (bin "playground") generated 1 warning
error: could not compile `playground` (bin "playground") due to 1 previous error; 1 warning emitted
The issue is that all 3 function calls in main() should be errors, since they all involve private types. However, only the last function call is displayed as an error. Ideally, only the first function call would be displayed as an error.
I tried to look for an existing issue but could not find any. Apologies if this has been reported already.
It should be reporting the private error for
Wants_X
, but instead it completely skips the error onbuilder()
and displays error forfinish()
Code
Current output
If you remove the
finish()
line, the output is still wrong (span appears to be incorrect).If you make
Wants_Finish
pub
, you get this (span definitely wrong)Desired output
Rationale and extra context
No response
Other cases
No response
Rust Version
Anything else?
No response