Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
emilio opened this issue Aug 2, 2023 · 3 comments
Closed

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

emilio opened this issue Aug 2, 2023 · 3 comments
Labels
C-bug Category: This is a bug.

Comments

@emilio
Copy link
Contributor

emilio commented Aug 2, 2023

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 :)

@emilio emilio added the C-bug Category: This is a bug. label Aug 2, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 2, 2023
emilio added a commit to servo/rust-cssparser that referenced this issue Aug 2, 2023
@emilio
Copy link
Contributor Author

emilio commented Aug 2, 2023

For reference the work around is servo/rust-cssparser#354. The code that wouldn't build otherwise would be this.

github-merge-queue bot pushed a commit to servo/rust-cssparser that referenced this issue Aug 2, 2023
@fmease
Copy link
Member

fmease commented Aug 2, 2023

Duplicate of #79260.

@rustbot label -needs-triage

@rustbot rustbot removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 10, 2023
@ChrisDenton
Copy link
Member

Closing as duplicate of #79260.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants