Skip to content

unexpected behavior of pub(in other_module) #109657

Open
@lcnr

Description

@lcnr
mod parent {
    mod this {
        pub(in super::sibling) fn foo() {}
    }
    
    mod sibling {
        fn bar() {
            super::this::foo();
        }
    }
}

results in

error[E0433]: failed to resolve: could not find `sibling` in `super`
 --> src/lib.rs:3:23
  |
3 |         pub(in super::sibling) fn foo() {}
  |                       ^^^^^^^ could not find `sibling` in `super`

this error feels very weird 🤔

I see the following possible fixes here:

  • this is a bug with name resolution and should compile
  • the in super::sibling error should be changed to explain what's going on here and why that doesn't work

found via #109511 (comment)

cc @petrochenkov in case you know more about what's going on here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions