Skip to content

Proc macro fn cannot be exported except from the crate root #124068

Open
@workingjubilee

Description

@workingjubilee

...that's all I've got, tbh.

it's mentioned as a limitation but I have no idea why. I genuinely looked for an issue about this but couldn't find one? maybe my issue-finding-fu is just weakened by this late hour. this makes me feel obligated to open a bug.

   Compiling pgrx-macros v0.12.0-alpha.1 (/home/jubilee/pgrx/pgrx-macros)
error: functions tagged with `#[proc_macro_attribute]` must currently reside in the root of the crate
  --> pgrx-macros/src/operators.rs:20:1
   |
20 | pub fn opname(_attr: TokenStream, item: TokenStream) -> TokenStream {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `pgrx-macros` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `pgrx-macros` (lib) due to 1 previous error

why this?

I have a macro crate with 1200 lines in its lib.rs already! and it's only 1200 because half of the macros have poor-to-zero documentation!

Meta

rustc --version --verbose:

rustc 1.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: x86_64-unknown-linux-gnu
release: 1.77.2
LLVM version: 17.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosC-bugCategory: This is a bug.WG-macrosWorking group: Macros

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions