rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.2k stars 1.6k forks source link

Macro expansion recurses endlessly? #10256

Open Veykril opened 3 years ago

Veykril commented 3 years ago

The following macro + invocation(taken from https://github.com/rust-lang/rust/issues/88577#issuecomment-914665202) seems to recurse endlessly(or just takes a very long time?) even emitting a warning in name res, [WARN hir_def::nameres::collector] macro expansion is too deep

macro_rules! many_args {
    ([$($t:tt)*]#$($h:tt)*) => {
        many_args!{[$($t)*$($t)*]$($h)*}
    };
    ([$($t:tt)*]) => {
        fn _f($($t: ()),*) {}
    }
}

many_args!{[_]########## ######}
WaffleLapkin commented 2 years ago

I think this is not an issue anymore, for me RA_LOG="hir_def=info" rust-analyzer analysis-stats . doesn't produce any warnings and seems to be working fine?

2022-06-05_14-17

Veykril commented 2 years ago

it is giving me an expansion error now, so I assume we broke something in macro expansion again image

WaffleLapkin commented 2 years ago

The only thing I get is the error from rustc about too many arguments: 2022-06-05_14-41

Veykril commented 2 years ago

Huh? That seems odd, are you certain you are on the latest version? (or do you have macro-error disabled in your settings perhaps)

WaffleLapkin commented 2 years ago

r-a version: 815b43429 2022-06-05 nightly These are all the r-a settings in vscode:

"rust-analyzer.updates.channel": "nightly",
"rust-analyzer.cargo.allFeatures": true,
"rust-analyzer.checkOnSave.enable": true,
"rust-analyzer.imports.prefix": "crate",
"rust-analyzer.cargo.buildScripts.enable": true,
"rust-analyzer.rustc.source": "discover",

Though it seems like the first two are outdated...