Skip to content

fix: do not show raw identifier label in completions - #23364

Open
A4-Tacks wants to merge 1 commit into
rust-lang:masterfrom
A4-Tacks:raw-ident-path-label
Open

A4-Tacks wants to merge 1 commit into
rust-lang:masterfrom
A4-Tacks:raw-ident-path-label

Conversation

@A4-Tacks

Copy link
Copy Markdown
Member

Example

mod foo {
    pub struct r#if;
    pub struct r#struct<T>;
    pub mod r#mod;
}
type X = foo::$0;

Before this PR

md r#mod::
st if                 r#if
st r#struct<…> r#struct<T>

After this PR

md mod::
st if                 r#if
st struct<…>   r#struct<T>

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 14, 2026
Example
---
```rust
mod foo {
    pub struct r#if;
    pub struct r#struct<T>;
    pub mod r#mod;
}
type X = foo::$0;
```

**Before this PR**

```rust
md r#mod::
st if                 r#if
st r#struct<…> r#struct<T>
```

**After this PR**

```rust
md mod::
st if                 r#if
st struct<…>   r#struct<T>
```
@A4-Tacks
A4-Tacks force-pushed the raw-ident-path-label branch from 228001c to 4651294 Compare September 14, 2026 17:21
@ChayimFriedman2

Copy link
Copy Markdown
Contributor

I actually prefer the old way. But why is if not escaped?

@A4-Tacks

Copy link
Copy Markdown
Member Author

The old implement is not easy to use, for the following reasons:

  1. Inconsistent behavior with other completion items
  2. Completing r#struct requires input rstruct instead of struct

Another behavior is to make all labels use r# and 'lookup' without escaping, but this requires changing too much code

And it seems that this PR implementation is now more consistent:

md non_keyword::
md mod::
st if                 r#if
st struct<…>   r#struct<T>
st foo<…>           foo<T>

Rather than:

md non_keyword::
md r#mod::
st r#if               r#if
st r#struct<…> r#struct<T>
st foo<…>           foo<T>

And this PR only removes a small range of raw ident escaping, and the current behavior has not been escaped in most places, so this is a 'fix' PR and improves user experience

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

Sure, it only inserts r# when needed, like people do in Rust.

And you don't need to type r, it'll work fine if you only type the keyword (since editors fuzzy-match).

@A4-Tacks

Copy link
Copy Markdown
Member Author

And you don't need to type r, it'll work fine if you only type the keyword (since editors fuzzy-match).

No, I need to type r. I'll reproduce it in coc.nvim, maybe it's because of {"label":"r#struct<…>","filterText":"r#struct"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants