Stream: t-compiler/wg-rls-2.0

Topic: Mutation points


Paul Faria (Aug 02 2020 at 19:44, on Zulip):

@matklad I also ran with your mutation points idea today and this is what I've come up with so far: Screenshot-from-2020-08-02-15-41-44.png

In this test, I changed mutable to just be bold, and mutation to have the underlines. Does it make sense to add the mutation modifier to ever name within the expr? I currently have it set to do that for all names/name ref in the lhs of an assignment expr, and in the expr of all method call expr where the self is &mut.

Paul Faria (Aug 02 2020 at 19:45, on Zulip):

Though I feel like such an algorithm falls apart if you have some kind of temporary. Something like (Struct {x: 5, g: 4}).mutation_fn().some_result would have the names in the temporary incorrectly highlighted. I'm not sure what to do for those kinds of cases.

matklad (Aug 02 2020 at 19:46, on Zulip):

Hm, I wonder it makes sense to underling function call instead

matklad (Aug 02 2020 at 19:46, on Zulip):

That way, you'll be able to intuitively re-use underlining

matklad (Aug 02 2020 at 19:47, on Zulip):
let mut *x* = ....;

*x*.foo();
*x*.*bar*();
matklad (Aug 02 2020 at 19:48, on Zulip):

I think (&mut self) methods is probably the single place where mutation happens implicitly, so maybe only highlight it

matklad (Aug 02 2020 at 19:48, on Zulip):

as in, &mut some_var is already syntactically visible

Paul Faria (Aug 02 2020 at 19:59, on Zulip):

Oh, that's already done in the PR in the other thread. I thought you had mentioned wanting to also highlight mutation points separately

Paul Faria (Aug 02 2020 at 19:59, on Zulip):

Copying here so no one needs to jump around: https://github.com/rust-analyzer/rust-analyzer/pull/5643

Paul Faria (Aug 02 2020 at 20:00, on Zulip):

matklad said:

(there's more general idea of highlighing not mutable types, but rather mutation points)

This is the comment I was referring to.

Last update: Sep 27 2020 at 13:45UTC