Skip to content

"use self::..." doesn't work inside of functions #18084

Closed
@sfackler

Description

@sfackler
fn main() {
    use self::inner::A;
    mod inner {
        pub struct A;
    }
}
<anon>:2:9: 2:14 error: unresolved import `self::inner::A`. Maybe a missing `extern crate inner`?
<anon>:2     use self::inner::A;
                 ^~~~~

This works, so I'm assuming the issue is that self doesn't behave correctly inside of an anonymous module:

fn main() {
    mod inner {
        pub struct A;
    }
    inner::A;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language 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