-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Shadowed macro causes macro-error #7084
Comments
triage: I can't reproduce in current master 8584d26. @vallentin Would you mind to try it again ? |
@edwin0cheng 8584d26 isn't on @vallentin not really, you'd need to wait until tomorrow. Building from source isn't that hard, though. (I can't reproduce it either) Also, that's a lovely issue report, I wish we had more of these. |
It wasn't the difficulty, it's more that I'm expecting a clean build to take quite a bit of time. I'm running Windows 10. I tested the above using only default settings, with the exception of |
A clean release build takes about 5 minutes. |
I can't reproduce the error in current master either, and changing the second macro definition to take just one argument does cause an error only in the second call; though it's worth noting that goto definition, hover etc. refer to the wrong macro for the first definition. |
Hmm, that's odd. I assume you aren't using Windows then? However, I don't at all see how this would be affected by OS, so it's rather confusing. Is there any more information I can provide? Here's step-by-step what I do to reproduce the issue (on Windows 10): git clone https://github.com/rust-analyzer/rust-analyzer
cd rust-analyzer
cargo build --release
cp target/release/rust-analyzer.exe ~/AppData/Roaming/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-x86_64-pc-windows-msvc.exe
cd ..
cargo new foo
code foo Then paste the following code in fn main() {
macro_rules! foo {
($a:expr) => {};
}
foo!(1);
macro_rules! foo {
($a:expr, $b:expr) => {};
}
foo!(1, 2);
} Checking "Show RA Version" correctly shows: rust-analyzer version: 2021-01-04 (903d1f8) Here's a screenshot showing both the issue and the version: (All default settings.) |
Oh, putting all that code into |
I literally just had the same thought pop into my head after commenting. Now I feel silly! How come this worked previously? |
It didn't, we just didn't emit those macro errors until recently. |
That's #1559. |
Is there any way to suppress that error? I have a few files that are affected by this change. Which prevents any other errors from being detected. |
You can add This shouldn't prevent other errors from being detected though. |
Thanks! The files where the issue occurs in conjunction are quite big. I'll look into making a MCVE, and post it if/when I'm able to. |
Triage: Still happening, presumably because we don't really handle legacy macro scopes in |
This works now AFAICT. |
🤨 oh it does, but why/how? |
The first
foo!(1);
uses to the subsequent shadowedmacro_rules! foo
. Causingexpected leaf: `,` rust-analyzer(macro-error)
. Performing "Go to Definition" confirms this, as the cursor jumps to the secondmacro_rules! foo
.This issue must have been introduced lately, as a few weeks ago this was not an issue.
Issue exists on both stable and the latest nightly release:
The text was updated successfully, but these errors were encountered: