rust-lang / rust-lang/rust

Better help for `pub(in parent)` in edition 2018 and beyond

Open
#118,878 2 comments 0 reactions 1 assignee View on GitHub

@bb1yd is already working on this.

Since Aug 3, 2026.

A-diagnostics A-resolve D-newcomer-roadblock T-compiler
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.