rust-lang / rust-lang/rust-analyzer

Macros cannot be expanded in certain situations.

Open
#17,837 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

rust-analyzer version: v0.3.2062

rustc version: rustc 1.80.0 (051478957 2024-07-21)

editor or extension: VSCode

relevant settings: default

repository link (if public, optional): (https://github.com/jkb0o/belly/blob/main/crates/belly_widgets/src/input/slider.rs)

code snippet to reproduce:

#[widget]
#[extends(RangeWidget)]
#[styles(
    slider .slider-grabber {
      margin: 0px;
      min-width: 16px;
      min-height: 16px;
      width: 16px;
      height: 16px;
    }
)]
fn slider(ctx: &mut WidgetContext) {
    let grabber = SliderGrabber {
        slider: ctx.entity(),
    };
    let params = ctx.params();
    ctx.render(eml! {
        <range c:slider params=params>
            <slot separator>
                <button with=grabber mode="instant" c:slider-grabber>
                </button>
            </slot>
        </range>
    })
}

When I use the command 'Expand macro recursively at caret' on a macro widget, nothing happens. After that, I commented out the content in the macro styles, and it worked.

For example:

#[widget]
#[extends(RangeWidget)]
#[styles(
    // slider .slider-grabber {
    //   margin: 0px;
    //   min-width: 16px;
    //   min-height: 16px;
    //   width: 16px;
    //   height: 16px;
    // }
)]
fn slider(ctx: &mut WidgetContext) {

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 with the reproduction in crates/belly_widgets/src/input/slider.rs and use rust-analyzer's “Expand macro recursively at caret” command on the widget macro. Compare expansion with and without the contents of the styles macro, then trace the macro-expansion entry point and related tests. Done means the widget expands while retaining the styles content.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.