Skip to content

Can't reference function-scoped type from function-scoped module #114369

@emilio

Description

@emilio

I tried this code:

fn main() {
    enum Outer {
        A,
        B,
    }
    
    mod inner {
        #[allow(unused_imports)]
        use super::*; // I was hoping this would help, but doesn't...
        
        // How do I reference the `Outer` type from here?
        type Foo = Outer;
    }
}

I expected to see this happen: I would expect it to compile, or to be a way of referencing Outer.

Instead, this happened:

error[E0412]: cannot find type `Outer` in this scope

The context is that I changed a macro from expanding to a plain function to expanding to a module (servo/rust-cssparser#353), but that broke code that used that macro with a type from a function.

A workaround I found is to just expand to an empty type and use associated functions, rather than a module, but seems unfortunate :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions