Stream: t-compiler/rust-analyzer

Topic: is_ method generation


Riccardo D'Ambrosio (Feb 08 2021 at 20:59, on Zulip):

Hello!

I am loving the new changelog with is_ method generation. although there are a couple things which confuse me:

Id be wiling to PR both changes for learning more about RA.

Lukas Wirth (Feb 08 2021 at 21:27, on Zulip):

regarding point 2, this was already filed https://github.com/rust-analyzer/rust-analyzer/issues/7601 feel free to implement that :smile:

Lukas Wirth (Feb 08 2021 at 21:28, on Zulip):

regarding point 1, what would be the benefit of using PartialEq over matches!?

Joshua Nelson (Feb 08 2021 at 22:20, on Zulip):

Matches is actually more efficient usually

Joshua Nelson (Feb 08 2021 at 22:21, on Zulip):

PartialEq is usually implemented in terms of a match

Yoshua Wuyts (Feb 08 2021 at 22:27, on Zulip):

Filed an additional bug regarding the lint: https://github.com/rust-analyzer/rust-analyzer/issues/7605

The generated methods should be appended, not prepended to the impl block

Yoshua Wuyts (Feb 08 2021 at 22:28, on Zulip):

Probably a matter of finding the last close } in the block, and then inserting the method right before that. This should probably be a new method in utils tho

Riccardo D'Ambrosio (Feb 09 2021 at 01:30, on Zulip):

Where is the code for this assist located so i can take a look?

Riccardo D'Ambrosio (Feb 09 2021 at 01:31, on Zulip):

lol nevermind i found it

Laurențiu (Feb 09 2021 at 08:19, on Zulip):

Why does it use matches! even if the enum implements PartialEq?

Also, matches! always works, while eq only works if it implements PartialEq

Yoshua Wuyts (Feb 09 2021 at 12:02, on Zulip):

And filed another one https://github.com/rust-analyzer/rust-analyzer/issues/7607 -- already know how to fix this, will send through a patch later.

Yoshua Wuyts (Feb 09 2021 at 12:03, on Zulip):

(first time contributing code to RA, still learning how the various parts of an assist fit together :sweat_smile: )

Riccardo D'Ambrosio (Feb 09 2021 at 14:26, on Zulip):

Another issue i found is that it produces invalid intra doc links for its docs

Riccardo D'Ambrosio (Feb 09 2021 at 14:27, on Zulip):

Since it just writes the variant without the enum beforehand

Riccardo D'Ambrosio (Feb 09 2021 at 14:27, on Zulip):

This makes it fail check-doc-links CI which made me a bit confused when i pushed to my repo :sweat_smile:

Riccardo D'Ambrosio (Feb 09 2021 at 14:28, on Zulip):

Maybe if it is trivial to see if the variants are in scope then use the variants directly and otherwise fully qualify them?

Laurențiu (Feb 09 2021 at 14:41, on Zulip):

Riccardo D'Ambrosio said:

Maybe if it is trivial to see if the variants are in scope then use the variants directly and otherwise fully qualify them?

It seems reasonable to always qualify the variants with the enum name

Last update: Jul 24 2021 at 20:00UTC