rust-lang / rust-lang/rust-analyzer

Show proc-macro panic backtrace

Open
#8,471 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-macro C-feature S-actionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Some macros panic when expanded by rust-analyzer. For example, xshell::cmd!("echo Ok") panics with message called Option::unwrap()on aNone value. However, it is difficult to debug this panic without having a backtrace.

That's why I'd propose e.g.:

  1. adding a setting to proc_macro_srv to capture panic backtraces.
  2. adding a CLI flag to rust-analyzer diagnostics to enable this setting.

Or any other way to see a backtrace.

UPD: xshell issue was resolved after upgrading to latest master, but I still think macro panic backtraces are useful for debugging both rust-analyzer and procmacros.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the proc_macro_srv setting mentioned in the issue and the rust-analyzer diagnostics CLI entry point. Define a supported way to enable proc-macro panic backtraces and verify that a panic during macro expansion exposes a usable backtrace.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.