Skip to content

Rust (2021+)

  • Language Standard: Rust 2021 Edition (plus compatible Rust 2024 items)
  • Recognized Extensions: .rs
  • Stdin Flag: -l rust or -l rs
  • Measured Throughput (v0.4.0): 132.8 us ByteString Rust Parser Small BS (Small ~85 LOC, RQ7); 1.40 ms full Rust pipeline (~100 LOC, RQ2); 46,362 LOC/s on ripgrep (205.1× faster than CodeQL)

2. Supported Constructs & ByteString Fast Path

Section titled “2. Supported Constructs & ByteString Fast Path”

Canontra’s pure-Haskell ByteString-native Rust frontend (Canontra.Parser.Rust) supports:

  • Generic Associated Types (GATs): Trait associated types with lifetime or generic parameters (type Item<'a> where Self: 'a;), normalizing lifetime names deterministically ('a →\to '0).
  • Raw Identifiers (r#): Raw identifiers (r#type, r#match, r#async) intern cleanly into SwissTable with bit-identical SymbolId resolution.
  • Core Rust Grammar: fn / async fn / unsafe fn / const fn, struct, enum, trait, impl (inherent and trait impls), use trees, mod declarations, match arms, if let / while let, closures, and let pattern bindings.

3. Language-Specific Alpha Scoping & ABI F_T Rules

Section titled “3. Language-Specific Alpha Scoping & ABI F_T Rules”
  • Sequential let Shadowing (canonicalizeAlphaModuleForLang): Re-binding the same name with let x = ...; let x = x + 1; allocates distinct sequential ordinals (@v0.0, @v0.1) so SSA def-use edges in F_DF and expressions in F1 stay exact.
  • ABI Scalar Widths, Mutability & Ordered Tuples (F_T): Distinguishes exact primitive widths (i32 vs i64, u32 vs usize, f32 vs f64), reference mutability (Mutability: &T vs &mut T), and ordered tuples ((A, B) vs (B, A) in TypeTuple).
  • Visibility & Generics (F2 / F_T): pub, pub(crate), and pub(super) items stay signature-sensitive in F2, while trait bounds, where clauses, generic parameters (α0, α1), and lifetimes ('0, '1) normalize deterministically in F_T.

4. Unsupported & Conservative-Fallback Constructs

Section titled “4. Unsupported & Conservative-Fallback Constructs”
  • Procedural Macros (#[derive(...)], Attribute & Function-Like Proc Macros): Because Canontra executes zero external compilers (rustc or cargo) and zero dynamic libraries, proc macros are hashed at their surface attribute and token-tree structure rather than expanded.
  • Complex macro_rules! Expansions: Macro invocations are tokenized safely as call/token-tree nodes rather than recursively expanded across crates.
  • Conditional Compilation (#[cfg(...)]): Branches present in the source file are hashed deterministically rather than filtered for a single target triple.