Open
Description
Code
// This is just the documentation sample for the lint
#![deny(unnameable_types)]
mod m {
pub struct S;
}
pub fn get_unnameable() -> m::S { m::S }
Current output
error: struct `S` is reachable but cannot be named
--> src/lib.rs:5:5
|
5 | pub struct S;
| ^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)`
|
note: the lint level is defined here
--> src/lib.rs:2:9
|
2 | #![deny(unnameable_types)]
| ^^^^^^^^^^^^^^^^
Desired output
error: struct `S` is reachable but cannot be named
--> src/lib.rs:5:5
|
5 | pub struct S;
| ^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)`
|
note: `S` is reachable from here
|
8 | pub fn get_unnameable() -> m::S { m::S }
| ^^^^ returns a value of type `S`
|
note: the lint level is defined here
--> src/lib.rs:2:9
|
2 | #![deny(unnameable_types)]
| ^^^^^^^^^^^^^^^^
Rationale and extra context
The output should give at least one example of how the type is reachable. This will:
- Help understand why the lint is not a false-positive (a reaction I had when first enabling it — “surely these can't be…”).
- If the desired outcome is that the type is not reachable, help the user make it not reachable.
Right now, this is a pure “hidden action at a distance” situation: there is no way to discover where the type is reachable other than by searching for uses of it (which can be difficult).
Other cases
No response
Rust Version
rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-apple-darwin
release: 1.79.0
LLVM version: 18.1.7
Anything else?
@rustbot label +A-lint +A-visibility +L-unnameable_types
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Visibility / privacyDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Lint: unnameable_typesRelevant to the compiler team, which will review and decide on the PR/issue.