Skip to content

Add keyword raw#585

Merged
psibi merged 1 commit intorust-lang:masterfrom
skr4n:add-raw-keyword
Apr 13, 2026
Merged

Add keyword raw#585
psibi merged 1 commit intorust-lang:masterfrom
skr4n:add-raw-keyword

Conversation

@skr4n
Copy link
Copy Markdown
Contributor

@skr4n skr4n commented Apr 13, 2026

Append the keywords list to Include the raw borrow operator, stabilized in Rust 2024.

https://doc.rust-lang.org/reference/expressions/operator-expr.html#raw-borrow-operators

Append the keywords list to Include the raw borrow operator,
stabilized in Rust 2024.

https://doc.rust-lang.org/reference/expressions/operator-expr.html#raw-borrow-operators
Copy link
Copy Markdown
Member

@psibi psibi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@psibi psibi merged commit 6482f56 into rust-lang:master Apr 13, 2026
16 checks passed
@PuercoPop
Copy link
Copy Markdown
Contributor

I'm confused about the choice of reference, which describes operator expressions not keywords. The keyword reference lists it as a "Weak Keyword". Which means it is only a keyword in certain contexts. If we see the list of weak keywords, except for static the rest are not listed as keywords.

And using font-lock for context sensitive highlighting seems like the wrong tool for the job.

@jcs090218
Copy link
Copy Markdown
Member

Yeah, you are right. Probably need to take care in special cases like other weak keywords.

@skr4n skr4n deleted the add-raw-keyword branch April 14, 2026 05:39
skr4n added a commit to skr4n/rust-mode that referenced this pull request Apr 14, 2026
This reverts commit 6482f56.

The raw borrow operator is a weak keyword,
as such, it must only be highlighted in the right context.

Weak keywords:
https://doc.rust-lang.org/reference/keywords.html#weak-keywords
@skr4n
Copy link
Copy Markdown
Contributor Author

skr4n commented Apr 14, 2026

My bad, thanks for pointing this out.
Fixed this in #586

psibi pushed a commit that referenced this pull request Apr 16, 2026
* Revert "Add keyword `raw` (#585)"

This reverts commit 6482f56.

The raw borrow operator is a weak keyword,
as such, it must only be highlighted in the right context.

Weak keywords:
https://doc.rust-lang.org/reference/keywords.html#weak-keywords

* Add `raw` borrow operator as a contextual keyword

The `raw` borrow operator is a contextual keyword.
Highlight it only in the context of borrows.
```rust
let mut x = 5;

// highlight "raw" here
let a = &raw const x;
let b = &raw mut x;

// do not highlight "raw" here
let raw = &x as *const _;
let raw_mut = &x as *mut _;
```

Raw borrow operator:
https://doc.rust-lang.org/reference/expressions/operator-expr.html#raw-borrow-operators
Rust weak keywords:
https://doc.rust-lang.org/reference/keywords.html#weak-keywords
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants