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

#[path] does not accept macro-generated paths #118312

Closed
Nemo157 opened this issue Nov 26, 2023 · 2 comments
Closed

#[path] does not accept macro-generated paths #118312

Nemo157 opened this issue Nov 26, 2023 · 2 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Nemo157
Copy link
Member

Nemo157 commented Nov 26, 2023

I tried this code:

#[path = concat!(env!("OUT_DIR"), "/zbus_xmlgen_output.rs")]
mod generated;

I expected to see this happen: the module is loaded from the expanded path

Instead, this happened:

error: malformed `path` attribute input
 --> src/main.rs:1:1
  |
1 | #[path = concat!(env!("OUT_DIR"), "/zbus_xmlgen_output.rs")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]`

(Attempted as a workaround for #117464 as zbus-xmlgen generates inner doc attributes).

Meta

rustc --version --verbose:

rustc 1.76.0 (a1a37735c 2023-11-23)
binary: rustc
commit-hash: a1a37735cbc3db359d0b24ba9085c9fcbe1bc274
commit-date: 2023-11-23
host: x86_64-unknown-linux-gnu
release: 1.76.0
LLVM version: 17.0.5
@Nemo157 Nemo157 added the C-bug Category: This is a bug. label Nov 26, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 26, 2023
@fmease fmease added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 26, 2023
@ehuss
Copy link
Contributor

ehuss commented Nov 26, 2023

Thanks for the report! I'm going to close as a duplicate of #87681. I'm not sure how feasible it would be to implement eager expansion in that position due to the way #[path] works during expansion.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2023
@Nemo157
Copy link
Member Author

Nemo157 commented Nov 26, 2023

Ah thanks, I was sure this would have been reported before and spent a while searching but failed to find that issue.

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants