Stream: t-compiler/wg-rls-2.0

Topic: Handling attributes in parser


Daniel Mcnab (Feb 22 2019 at 22:31, on Zulip):

Regarding: https://github.com/rust-analyzer/rust-analyzer/pull/846, @matklad said he wanted us to handle parsing attributes in all locations, and only error if they are in the wrong location.

In https://github.com/rust-analyzer/rust-analyzer/pull/509 I determined that it would be very complex to try and reverse-engineer where doc comments are allowed in the validation layer, which is essentially the same question. However, I'm not sure which layer this should be implemented on. My initial inclination is that this should be implemented on Parser by adding a new field such as manually_handle_attributes, which if not set will automatically skip and error on attributes (POUND, /// and //!) . However, this would complicate many of the methods of Parser. Writing this out makes me realise this is the way to go though.

Sorry about the ramble - I don't seem to be able to write well today...

Also this is my first Zulip topic - am I doing this right?

davidtwco (Feb 22 2019 at 22:35, on Zulip):

Also this is my first Zulip topic - am I doing this right?

:thumbs_up: Yes. One small tip: you can simplify links to the rust-analyzer repo by typing rust-analyzer#846 and rust-analyzer#509 and have them auto-linked. Also works in the topic name.

matklad (Feb 23 2019 at 10:12, on Zulip):

@Daniel Mcnab welcome to Zulip :)

would be very complex to try and reverse-engineer where doc comments are allowed in the validation layer,

Heh, I'd think that any handling of doc-comments will require some amount of boilerplate. It's not trivial to add them to the validation layer, but adding directly to the parser does not seem trivial either.

Last update: Nov 12 2019 at 16:25UTC