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

#[macro_export(hello, world)] #107231

Closed
SoniEx2 opened this issue Jan 23, 2023 · 3 comments · Fixed by #107911
Closed

#[macro_export(hello, world)] #107231

SoniEx2 opened this issue Jan 23, 2023 · 3 comments · Fixed by #107911
Assignees
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@SoniEx2
Copy link
Contributor

SoniEx2 commented Jan 23, 2023

I tried this code:

#[macro_export(hello, world)]
macro_rules! foo {
    () => {}
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=9c40221c498bdc99beb7022d53fdb086

I expected to see this happen: it shouldn't compile

Instead, this happened: it compiles

Meta

rustc --version --verbose:

N/A
Backtrace

<backtrace>

@SoniEx2 SoniEx2 added the C-bug Category: This is a bug. label Jan 23, 2023
@fmease
Copy link
Member

fmease commented Jan 23, 2023

For anyone who would like to work on this, the following code needs to be adjusted to check if the meta-item list is empty or if it only contains the identifier local_inner_macros (i.e. only allowing the attribute to be #[macro_export] or #[macro_export(local_inner_macros)]:

fn check_macro_export(&self, hir_id: HirId, attr: &Attribute, target: Target) {

Due to backward compatibility concerns, probably only a future-incompat warning should be issued if the verification fails.

@rustbot label T-compiler A-attributes

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 23, 2023
@blyxyas
Copy link
Member

blyxyas commented Jan 23, 2023

@rustbot claim

@blyxyas
Copy link
Member

blyxyas commented Jan 23, 2023

First rust-lang/rust contribution I hope this goes well

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 22, 2023
…er-errors

Add check for invalid #[macro_export] arguments

Resolves rust-lang#107231
Sorry if I made something wrong, this is my first contribution to the repo.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 23, 2023
…er-errors

Add check for invalid #[macro_export] arguments

Resolves rust-lang#107231
Sorry if I made something wrong, this is my first contribution to the repo.
@bors bors closed this as completed in cf049ac Feb 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 (`#[…]`, `#![…]`) 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

Successfully merging a pull request may close this issue.

4 participants