-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.L-unnameable_typesLint: unnameable_typesLint: unnameable_typesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
#![warn(unnameable_types)]
pub mod foo {
pub fn get() -> bar::Baz {
bar::Baz
}
mod bar {
pub struct Baz;
}
}
Current output
warning: struct `Baz` is reachable but cannot be named
--> src/lib.rs:9:9
|
9 | pub struct Baz;
| ^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(foo)`
|
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![warn(unnameable_types)]
| ^^^^^^^^^^^^^^^^
warning: `playground` (lib) generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.27s
Desired output
- reachable at visibility `pub`, but can only be named at visibility `pub(foo)`
+ reachable at visibility `pub`, but can only be named at visibility `pub(in crate::foo)`
Rationale and extra context
pub(foo)
is not valid visibility syntax.
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
Note that this is the pre-release of stable 1.79.0. Nightly has the same flaw.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.L-unnameable_typesLint: unnameable_typesLint: unnameable_typesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.