Skip to content

pub(in) visibility doesn't allow used paths, unless macro-expanded #60552

@qnighy

Description

@qnighy

Paths usually respect use aliases of modules, but paths in pub(in) not.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a6c5906c564f63850530fcd28c64379c

mod m1 {
    pub(in crate::m2) fn f() {}
    //~^ERROR cannot find module `m2` in module `crate`
}
use m1 as m2;

This seems to be a matter of the order of evaluation, hence the following variant compiles:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a1b35f783b9c0aa35e58df3b7d4f41d5

mod m1 {
    crate::id! {
        pub(in crate::m2) fn f() {}
    }
}
use m1 as m2;

#[macro_export]
macro_rules! id {
    ($($x:tt)*) => { $($x)* };
}

I expect these behaviors to match.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyA-visibilityArea: Visibility / privacyT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions