rust-lang / rust-lang/rust-analyzer

`string_deref_patterns` unsupported with rust-analyzer

Open
#17,768 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
0.3.2053-standalone (fd74511f3 2024-07-28)

rustc version: (eg. output of rustc -V)
rustc 1.82.0-nightly (8e86c9567 2024-08-01)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)
VS Code v0.4.2058 (pre-release)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

code snippet to reproduce:

#![feature(string_deref_patterns)]
enum Foo {
    Bar(String),
    X,
}

fn foo(x: Foo) -> bool {
    match x {
        Foo::Bar("bar") => true, // expected String, found &str
        _ => false,
    }
}

Works with cargo check so just a rust-analyzer issue

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 provided minimal Rust snippet using the string_deref_patterns feature and compare rust-analyzer's result with cargo check. Trace the rust-analyzer analysis that handles the match pattern and reproduce the expected String versus &str discrepancy. Done means rust-analyzer accepts this valid pattern consistently with cargo check.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
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.