tree-sitter-rust
tree-sitter-rust copied to clipboard
Highlight `box`
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
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.
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.
For reference:
- https://github.com/rust-lang/rust/issues/49733
- https://doc.rust-lang.org/unstable-book/language-features/box-syntax.html
@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))
?
What I understood was that nothing is clear LOL
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.
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