zargony / atom-language-rust

Rust language support in Atom - LOOKING FOR MAINTAINER, see #144
MIT License
116 stars 33 forks source link

Add dyn keyword support #139

Closed Boereck closed 5 years ago

Boereck commented 5 years ago

In rust 1.27 a new "dyn" keyword was introduced: https://blog.rust-lang.org/2018/06/21/Rust-1.27.html#dyn-trait This keyword is used in similar places as the mut keyword.

CryZe commented 5 years ago

I think impl is missing too, so you might want to add that as well, considering dyn is supposed to be its analogue.

Boereck commented 5 years ago

Good point. I will add it as well.

zargony commented 5 years ago

NIce, thanks! Could you also add some tests for the various use cases so that these keywords are tested properly and won't break in future?

Boereck commented 5 years ago

Yep, I will look into that. I haven't written a test for a grammar yet, but I will look at your test cases and try to write them accordingly.

Boereck commented 5 years ago

Phew, added a couple of test cases. I realized that the impl Type is only recognized in the currently allowed positions. In future impl Traits will be implemented e.g. for local variable declarations and global variables (see https://github.com/rust-lang/rust/issues/34511) to detect those correctly, bigger changes have to be done to the grammar definition. Funnily the impl keyword will be highlighted, but it will be recognized as an impl block for types/traits. I don't think this is worth to be tackled currently. But in future changes to do correct detection may have other positive side effects. E.g. the angle brackets for generic types are currently not highlighted consistently. When detecting variable declarations including type definitions, this may be fixed as a side effect.

treyzania commented 5 years ago

Can this be merged?

Also, we're missing something similar to this with the as in extern crate foo as bar;.

zargony commented 5 years ago

Sorry for the delay. Looks very good to me. Thanks a lot for taking the time to cover everything with test cases. Good work!