Skip to content

Add raw borrow operator as a contextual keyword#586

Merged
psibi merged 2 commits intorust-lang:masterfrom
skr4n:add-raw-operator
Apr 16, 2026
Merged

Add raw borrow operator as a contextual keyword#586
psibi merged 2 commits intorust-lang:masterfrom
skr4n:add-raw-operator

Conversation

@skr4n
Copy link
Copy Markdown
Contributor

@skr4n skr4n commented Apr 14, 2026

The raw borrow operator is a contextual keyword.
Highlight it only in the context of borrows.

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 _;

Reverts #585

skr4n added 2 commits April 14, 2026 11:11
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
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
@skr4n skr4n mentioned this pull request Apr 14, 2026
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 for the quick fix!

@psibi psibi merged commit 06cf088 into rust-lang:master Apr 16, 2026
31 of 32 checks passed
@skr4n skr4n deleted the add-raw-operator branch April 16, 2026 08:31
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.

3 participants