klion26 commented on PR #9498:
URL: https://github.com/apache/arrow-rs/pull/9498#issuecomment-3988097222

   > 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](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=39965d8396a186f18363c513fc2cfe65
   )
   ```
   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](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=94254bc70450d2c153e5f59f0eb3cde6)
   ```
   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
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to