Skip to content

Paths involving 'super' don't work from within a function #64079

Description

@Aaron1011

The following code compiles correctly:

struct Foo;
mod inner {
    use super::Foo;
}

However, when wrapped in a function:

fn outer() {
    struct Foo;
    mod inner {
        use super::Foo;
    }
}

it gives the following error:

error[E0432]: unresolved import `super::Foo`
 --> src/lib.rs:4:13
  |
4 |         use super::Foo;
  |             ^^^^^^^^^^ no `Foo` in the root

error: aborting due to previous error

This can make it difficult to write attribute macros which expand to module declarations. Ideally, such macros would be useeable no matter where the annotated type is declared. However, this issue prevents such macros from being used on a type declared within a function.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions