Skip to content

Incorrectly highlighting tuple structs as functions #205

Open
@scizzorz

Description

@scizzorz

I've noticed that tuple structs are often being highlighted as functions, which leads to some confusion because the highlighting appears inconsistent. Notably, in an enum body:

pub enum Message {
  Greeting(String), // highlighted as function - notice no space before paren
  Goodbye (String), // highlighted as normal text - notice space before paren
  Wave, // highlighted as normal text
  NamedGreeting { // highlighted as normal text
    target: String,
    words: String,
  }
}

You can see that even GH has an issue with inconsistency here - the empty option (Wave) and the struct option (NamedGreeting) are both highlighted as normal text, while the other two are highlighted as a function call. rust.vim only highlights the Greeting option. Because different items of the enum are highlighted differently, it can lead to some confusion because the highlighting doesn't actually mean anything in those cases - it's accidental.

I realize there's some difficulty determining whether an identifier is a function call, a tuple struct, etc, but I think there's a few solutions. My first idea would be to highlight all enum members, as well as the final identifier in scoped lists (eg, this same problem occurs with phrasing::Message::Greeting(...) vs phrasing::Message::Wave - the Greeting is highlighted while the Wave isn't, leading to a false sense of difference between the two).

Thanks for reading!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions