oak_rust/language/
mod.rs

1use crate::{ast::RustRoot, kind::RustSyntaxKind};
2use oak_core::Language;
3
4/// Configuration for the Rust language parser.
5///
6/// This struct contains language-specific options that control parsing behavior
7/// and compatibility with different versions or extensions of Rust.
8#[derive(Copy, Clone, Debug)]
9pub struct RustLanguage {
10    /// Allow `@gc_pointer` kind in old rust
11    ///
12    /// This flag enables support for the experimental garbage collection pointer kind
13    /// that was briefly considered for early Rust versions. When enabled, the parser
14    /// will recognize `@gc_pointer` annotations on types.
15    pub gc_pointer: bool,
16    /// Allow `box Class {}` kind in old rust
17    ///
18    /// This flag enables support for the deprecated box kind that was used in early
19    /// Rust versions before the current `Box::new()` kind was standardized.
20    /// When enabled, the parser will recognize expressions like `box Class {}`.
21    pub box_syntax: bool,
22}
23
24/// Default implementation for RustLanguage.
25///
26/// Creates a RustLanguage instance with all experimental features disabled,
27/// corresponding to the standard modern Rust kind.
28impl Default for RustLanguage {
29    fn default() -> Self {
30        Self {
31            // no longer used
32            gc_pointer: false,
33            // no longer used
34            box_syntax: false,
35        }
36    }
37}
38
39/// Implementation of the Language trait for RustLanguage.
40///
41/// This connects the language configuration to the specific kind kinds
42/// and AST root type used for Rust parsing.
43impl Language for RustLanguage {
44    type SyntaxKind = RustSyntaxKind;
45    type TypedRoot = RustRoot;
46}