rust-analyzer: Macro invocation Error for simple dbg macro

The following code shows an error of “failed to parse or resolve macro invocation” in master bb697727a

fn main() {
    dbg!("test");
}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 10
  • Comments: 21 (9 by maintainers)

Commits related to this issue

Most upvoted comments

The warning can be disabled using:

"rust-analyzer.diagnostics.disabled": [
  "macro-error"
]

At this point there’s no need for more confirmations.

The resolution error should now be fixed. I’ll look into the misplaced diagnostics later.

I just compiled the rust-analyzer-git package on ArchLinux, but I’m still seeing failed to parse macro invocation for my invocation of the serde_json::json! macro.

(the misplaced diagnostics are now also fixed)

Same as @jeromegn , I am still getting the error on the nightly version of rust-analyzer, in my case in a call to futures::try_join!.

I started getting this error after I updated to 0.2.408. Reverting to 0.2.400 fixes the issue. In addition to dbg!, usage of assert_eq! with a message seemed to cause this as well. I’m on Ubuntu 20.04.1 LTS and vscode

Version: 1.51.1 Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f Date: 2020-11-10T23:31:29.624Z Electron: 9.3.3 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Linux x64 5.4.0-56-generic

if that’s of any interest.

In my case the issue also causes error flood in seemingly unrelated parts of the source file. For example, somewhere in the source I can have the following lines:

let longs: HashSet<BitVector> = offset_codes.iter().cloned().collect();
let shorts: HashSet<BitVector> = offset_codes.iter().map(|&b| contexts::hash(&[(b, 0.into())])).collect();
dbg!(longs.len(), shorts.len());

And it causes the following errors within the same file: <image src="https://user-images.githubusercontent.com/3784017/101149626-c75ddb80-3651-11eb-8652-61198e538e4b.png" width="50%" height="50%">

P.S.: If I comment the dbg! line all errors disappear.

You can use the nightly version, but I’d suggest manually replacing the LSP binary or waiting until tomorrow because of a Code extension bug related to the update functionality (#6757).

Or you could disable the warning.