Skip to content

Can't define headers in fn items (or doctests) #12

Description

@FelixMcFelix

Code like the following which attempts to define a header within a fn breaks horribly:

fn hello() {
    #[derive(Ingot)]
    pub struct Broken {
        pub fine: u8,
    }
}
error: cannot find type `BrokenRef` in this scope
   --> ingot/src/lib.rs:180:16
    |
180 |     pub struct Broken {
    |                ^^^^^^ names from parent modules are not accessible without an explicit import
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
    = note: `#[deny(proc_macro_derive_resolution_fallback)]` on by default

Although the types in question are not defined in a mod, all of them are referenced within the implementation-private module created to hold a header's chunk types and other generated artefacts.

An unfortunate victim of this is that doctests cannot include packet definitions, since they compile to a fn.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions