rust-lang / rust-lang/rust-analyzer

Work on whitespace for find_node_at_offset_with_descend

Open
#21,729 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

AssistContext::find_node_at_offset_with_descend Return None on the whitespace within the macro, as the whitespace does not have descended

macro_rules! m { ($($t:tt)*) => {$($t)*} }
m!(match Some(2) {
    None => 3,
    $0
});

$0 cannot descend a token on WHITESPACE, unless $0 is on the }

Related #21453

Problem

Avoid descended cases that do not contain the this whitespace, e.g
call find_node_at_offset_with_descend::<ast::WildcardPat>() on $0 _ => 2

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 at AssistContext::find_node_at_offset_with_descend and reproduce the macro example with the offset on whitespace. Trace descended cases to ensure they contain the whitespace being queried; done means whitespace returns None and does not descend into unrelated cases such as WildcardPat.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.