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

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

Open
workingjubilee opened this issue Apr 17, 2024 · 2 comments
Open

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

workingjubilee opened this issue Apr 17, 2024 · 2 comments
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-bug Category: This is a bug. WG-macros Working group: Macros

Comments

@workingjubilee
Copy link
Contributor

...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
@workingjubilee workingjubilee added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. labels Apr 17, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 17, 2024
@ChayimFriedman2
Copy link
Contributor

The usual workaround is to put only the macro declarations in lib.rs and the implementation in modules.

@workingjubilee
Copy link
Contributor Author

@ChayimFriedman2 I'm aware there are workarounds, of course! What I'm asking about is why I am forced to use this software architecture?

@workingjubilee workingjubilee added the WG-macros Working group: Macros label Apr 17, 2024
@saethlin saethlin added A-proc-macros Area: Procedural macros and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-bug Category: This is a bug. WG-macros Working group: Macros
Projects
None yet
Development

No branches or pull requests

4 participants