Suggestion: Color variable when moved in VS Code

Hello, first time posting :grinning:

Probably not the right place to turn, but I want to give a quick suggestion for a feature of the VS Code extension. Would it be possible to color variables when they are moved? In cases like method calls the syntax looks the same whether you borrow or move. It would be nice to immediately see if the variable goes out of scope when you call the method.

struct Message(String);

impl Message {
    fn owned_print(self) {
        println!("{}", self.0);

    fn borrowed_print(&self) {
        println!("{}", self.0);

fn main() {
    let s = Message(String::from("Hello"));

When calling "s.owned_print()", could the extension tag "s" differently so it sticks out in the color theme?


We tag the method name in the method call with a consuming modifier currently, but not much more. This is tracked in [Semantic Highlighting] Consuming modifier should apply to other cases ยท Issue #5856 ยท rust-analyzer/rust-analyzer ยท GitHub

1 Like

To expand on @Veykril's answer -- we already include ownership&aliasing into into the highlighting tags we set for rust code. But it's up to the theme to actually make use of this info. Here's how it looks when I configure VS Code to display ownership transition in bold red:


Thanks for the answers!

So I assume that this tag is not widely used since no existing themes, that I have at least, seem to care about it. Wouldn't it be better to use a more common tag so that you don't need to have a rust-specific theme, or is it the correct use case to change this manually as you did? Either way, I made the same change and it works perfectly!

As far as I know, there isn't a more common tag we can use here. Open to suggestions though!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.