`rust-analyzer` highlight `(self, ..) -> Self` methods

Currently rust-analyzer underlines method calls that takes &mut self as first parameter. I want to take this idea a bit further and implement similar highlighting for methods that takes self and returns Self.

Motivation is to make consuming builder flavor to look similarily distinct as borrowing flavor. But also to make snippets like below less intricate by highlighting most important elements:

let number = number.min(get_max()).max(get_min());

Underdotted line would look good enough:

let number = number.min(get_max()).max(get_min());
                    '''            '''

Let take this as minimalist version of my previous proposal.

I think rust-analyzer already sets “consuming” flag in semantic tokens? So it’s up to the theme to display this info.

1 Like

The difference AIUI is that that's for any fn(self), whereas @160R wants to differentiate between (T) -> T and (T) -> U.

1 Like

Yes, I can see through Inspect Editor Tokens and Scopes that there's "consuming" flag on methods, however I want something like "identity" flag for (T, ..) -> T methods, even for T: Copy

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.