tree-sitter-rust icon indicating copy to clipboard operation
tree-sitter-rust copied to clipboard

Highlight `box`

Open Nokel81 opened this issue 6 years ago • 6 comments

Now that the box keyword has been reserved in Rust2018, and it is possible to use it behind a gate I think it would make sense to highlight it as a keyword

Nokel81 avatar Feb 14 '19 23:02 Nokel81

Can you share a link to the docs for this? Upon first search, all I'm seeing is very old discussions about the box syntax that was eventually removed.

maxbrunsfeld avatar Jun 10 '19 18:06 maxbrunsfeld

Sure, here says that is is a reserved keyword (even in Rust2015 it seems). And here is the uses of box, which are currently unstable in nightly but do work.

Nokel81 avatar Jun 10 '19 18:06 Nokel81

For reference:

  1. https://github.com/rust-lang/rust/issues/49733
  2. https://doc.rust-lang.org/unstable-book/language-features/box-syntax.html

GrayJack avatar Jun 26 '19 14:06 GrayJack

@GrayJack So if I read correctly, they are removing the let x = box 1; syntax but might be keeping the if let box Some(y) = Box::new(Some(10))?

Nokel81 avatar Jun 26 '19 14:06 Nokel81

What I understood was that nothing is clear LOL

GrayJack avatar Jun 27 '19 22:06 GrayJack

On another dive into the comments on those features using the box keyword:

Looks like box as expression will probably never go to stable and probably remain as a unstable feature till some problems related to the Box can be fixed, a possible fix for those problems would be this RFC, but it wasn't accepted yet (21/10/2020). Once Box type problems fixed, this feature will probably be removed.

About the box pattern, it also looks like it will never face the light of a stable release (there some thoughts about removing it and adding a deref pattern that will work on any type that can de dereferenced).

Either way, I think it's ok for us to implement those in the parser, since those features are used inside the stdlib and when we open those std files in a editor using tree-sitter the syntax usually breaks. Implementing them would mean that we can get closer to be possible to highlight and parse any Rust code.

GrayJack avatar Oct 21 '20 05:10 GrayJack

I think we're gonna close this out since it probably will never be stabilized, and might be removed in the future, seems like deref patterns will supersede box patterns

amaanq avatar Feb 17 '24 21:02 amaanq