Skip to content

chore: remove duplicate macro partially_shredded_variant_array_gen#9498

Merged
scovich merged 1 commit into
apache:mainfrom
codephage2020:issue-9492
Mar 2, 2026
Merged

chore: remove duplicate macro partially_shredded_variant_array_gen#9498
scovich merged 1 commit into
apache:mainfrom
codephage2020:issue-9492

Conversation

@codephage2020
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

What changes are included in this PR?

Are these changes tested?

YES

Are there any user-facing changes?

NO

@github-actions github-actions Bot added the parquet-variant parquet-variant* crates label Mar 2, 2026
@codephage2020 codephage2020 changed the title chore: remove duplicate macro chore: remove duplicate macro partially_shredded_variant_array_gen Mar 2, 2026
Copy link
Copy Markdown
Member

@klion26 klion26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codephage2020, thanks for the improvement, LGTM. This must have been left behind when I resolved a conflict.

Copy link
Copy Markdown
Contributor

@scovich scovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit surprised the duplication didn't trigger compiler errors?
But removing it also doesn't trigger any errors, so LGTM.

@scovich scovich merged commit 4d8e8ba into apache:main Mar 2, 2026
18 checks passed
@codephage2020
Copy link
Copy Markdown
Contributor Author

codephage2020 commented Mar 3, 2026

I'm a bit surprised the duplication didn't trigger compiler errors?

It could be because the two macros have different parameter names?

@codephage2020 codephage2020 deleted the issue-9492 branch March 3, 2026 00:38
@klion26
Copy link
Copy Markdown
Member

klion26 commented Mar 3, 2026

I'm a bit surprised the duplication didn't trigger compiler errors? But removing it also doesn't trigger any errors, so LGTM.

Tried that

  • Same macro will override the previous one (same as variable)
  • Function will throw an error

same macro

macro_rules! my_macro {
    () => { println!("first"); };
}

macro_rules! my_macro {
    () => { println!("second"); };
}

fn main() {
    my_macro!(); // 输出 "second"
}

the output will be

warning: unused macro definition: `my_macro`
 --> src/main.rs:1:14
  |
1 | macro_rules! my_macro {
  |              ^^^^^^^^
  |
  = note: `#[warn(unused_macros)]` (part of `#[warn(unused)]`) on by default

warning: `playground` (bin "playground") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.79s
     Running `target/debug/playground`

same fun

fn my_fn() {
    println!("first");
}

fn my_fn() { // 编译错误:the name `my_fn` is defined multiple times
    println!("second");
}
fn main() {
    my_fn!();
}

will compile error

   Compiling playground v0.0.1 (/playground)
error[E0428]: the name `my_fn` is defined multiple times
 --> src/main.rs:5:1
  |
1 | fn my_fn() {
  | ---------- previous definition of the value `my_fn` here
...
5 | fn my_fn() { // 编译错误:the name `my_fn` is defined multiple times
  | ^^^^^^^^^^ `my_fn` redefined here
  |
  = note: `my_fn` must be defined only once in the value namespace of this module

error: cannot find macro `my_fn` in this scope
 --> src/main.rs:9:5
  |
9 |     my_fn!();
  |     ^^^^^
  |
  = note: `my_fn` is in scope, but it is a function, not a macro

For more information about this error, try `rustc --explain E0428`.
error: could not compile `playground` (bin "playground") due to 2 previous errors

@codephage2020
Copy link
Copy Markdown
Contributor Author

codephage2020 commented Mar 3, 2026

CC @scovich @klion26
I've reproduced the scenario and identified the cause: Rust does not check for duplicate macros, only for unused ones. The following example, which is identical to the original code, does not trigger an error.

fn main() {
    macro_rules! my_macro {
        () => { println!("first"); };
    }
    my_macro!();

    macro_rules! my_macro {
        () => { println!("second"); };
    }
    my_macro!();
}

output(NO WARNING)

first
second

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate macro definition: partially_shredded_variant_array_gen

3 participants