thepowersgang / mrustc

Alternative rust compiler (re-implementation)
MIT License
2.18k stars 109 forks source link

'Macro_InvokeRules_MatchPattern - No arm matched' error in mrustc #321

Open iamanonymouscs opened 1 year ago

iamanonymouscs commented 1 year ago

Code

$ cat 2.rs code:

macro_rules! cbor_map {
    ($key:expr) => {
        $key.signum();
    };
}

fn main() {
    cbor_map! { 
        #[cfg(test)] 
        8
    };
}

It seems that the macro expansion failed to match any arms in the cbor_map! macro definition.

Command

mrustc -L output-1.54.0 2.rs

Output

Setup: V V V
(0.00 s) Setup: DONE
Target Load: V V V
(0.00 s) Target Load: DONE
Parse: V V V
(0.00 s) Parse: DONE
LoadCrates: V V V
(0.39 s) LoadCrates: DONE
Expand: V V V
/home/interesting/mrustc/2.rs:11:7 BUG:src/macro_rules/eval.cpp:1920: TODO: Macro_InvokeRules_MatchPattern - No arm matched - (0, 21)
Aborted (core dumped)

Version

I build the mrustc by using build-1.54.0.sh mrustc --version

rustc 1.29.100 (mrustc v0.10.0 master:4c7e8171)
release: 1.29.100
- Build time: Tue, 26 Sep 2023 07:36:21 +0000
- Commit: 4c7e81716493678df9fe9cac86ea9beedc57db44
thepowersgang commented 1 year ago

Looks like :expr isn't matching attributes

iamanonymouscs commented 1 year ago

Looks like :expr isn't matching attributes

Is this an issue with the code itself or an internal error in the compiler? I initially thought it was an internal issue with the compiler when encountering the BUG statement. Of course, there are syntax errors in the code itself.

thepowersgang commented 1 year ago

If rustc accepts that code, then it's a mrustc bug and will be addressed next time I do a push to clean up tickets.