Better help for `pub(in parent)` in edition 2018 and beyond
@bb1yd is already working on this.
Since Aug 3, 2026.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
Code
// Compile with edition 2018 or later
mod foo {
pub(in parent) fn bar() {
println!("hello from bar");
}
}
fn main() {
bar();
}
Current output
error: relative paths are not supported in visibilities in 2018 edition or later
--> src/lib.rs:2:12
|
2 | pub(in parent) fn bar() {
| ^^^^^^ help: try: `crate::parent`
Desired output
error: relative paths are not supported in visibilities in 2018 edition or later
--> src/lib.rs:2:12
|
2 | pub(in parent) fn bar() {
| ^^^^^^ help: try: `crate::parent`
| ^^^^^^^^ help: did you mean? `super`
Rationale and extra context
If the programmer wrote pub(in parent) and there is no module named parent in the crate (at the location where edition 2015 would have resolved the path), it is likely that what they were actually trying to do is make the item visible to "the parent module", which is properly spelled super.
It would also probably be helpful to refer the programmer to https://doc.rust-lang.org/reference/visibility-and-privacy.html#pubin-path-pubcrate-pubsuper-and-pubself either directly or via --explain.
Note also that this error is missing an E-code (and therefore there is nothing to use --explain on).
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.
Assessment
This issue has not been assessed yet.