Rust (2021+)
1. Supported Versions & File Extensions
Section titled “1. Supported Versions & File Extensions”- Language Standard: Rust 2021 Edition (plus compatible Rust 2024 items)
- Recognized Extensions:
.rs - Stdin Flag:
-l rustor-l rs - Measured Throughput (
v0.4.0):132.8 usByteStringRust Parser Small BS(Small ~85 LOC,RQ7);1.40 msfull Rust pipeline (~100 LOC,RQ2);46,362 LOC/sonripgrep(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'0). - Raw Identifiers (
r#): Raw identifiers (r#type,r#match,r#async) intern cleanly intoSwissTablewith bit-identicalSymbolIdresolution. - Core Rust Grammar:
fn/async fn/unsafe fn/const fn,struct,enum,trait,impl(inherent and trait impls),usetrees,moddeclarations,matcharms,if let/while let, closures, andletpattern bindings.
3. Language-Specific Alpha Scoping & ABI F_T Rules
Section titled “3. Language-Specific Alpha Scoping & ABI F_T Rules”- Sequential
letShadowing (canonicalizeAlphaModuleForLang): Re-binding the same name withlet x = ...; let x = x + 1;allocates distinct sequential ordinals (@v0.0,@v0.1) so SSA def-use edges inF_DFand expressions inF1stay exact. - ABI Scalar Widths, Mutability & Ordered Tuples (
F_T): Distinguishes exact primitive widths (i32vsi64,u32vsusize,f32vsf64), reference mutability (Mutability:&Tvs&mut T), and ordered tuples ((A, B)vs(B, A)inTypeTuple). - Visibility & Generics (
F2/F_T):pub,pub(crate), andpub(super)items stay signature-sensitive inF2, while trait bounds,whereclauses, generic parameters (α0,α1), and lifetimes ('0,'1) normalize deterministically inF_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 (rustcorcargo) 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.