Compiling a project with rsc
How to set up any Rust project to compile under the rs edition compiler.
Prerequisites
Build rsc from the rs repo:
cd ~/git/rs/rsc
cargo build --release
The binary is at ~/git/rs/rsc/target/release/rsc.
Building your project with rsc
$env.RUSTC = ($env.HOME + "/git/rs/rsc/target/release/rsc")
$env.RUSTFLAGS = "--rs-edition"
cd ~/git/your-project
cargo build
Without --rs-edition, only attribute-triggered lints run (#[deterministic], #[step], #[derive(Addressed)]). With --rs-edition, edition restriction lints (RS501–RS507) activate.
Edition restrictions (RS501–RS507)
Every violation must be fixed — not suppressed — unless interfacing with an external Rust crate.
| code | forbidden | replacement |
|---|---|---|
| RS501 | Box::new() |
stack values or Arena<T, N> |
| RS502 | Vec<T> |
BoundedVec<T, N> with compile-time capacity |
| RS503 | String |
&str or ArrayString<N> |
| RS504 | dyn Trait |
generics or enum dispatch |
| RS505 | Arc<T>, Rc<T> |
cell-owned state or bounded channels |
| RS506 | panic!() |
Result for recoverable, abort for unrecoverable |
| RS507 | HashMap, HashSet |
BTreeMap, BTreeSet, or BoundedMap<K,V,N> |
Fixing violations
When rsc reports errors, apply these patterns:
// RS501: Box::new(x) → stack value or arena
let node = arena.alloc?;
// RS502: Vec<T> → BoundedVec<T, N>
let items: = new;
// RS502: vec.collect() → bounded collect
let result: = iter.try_collect?;
// RS503: String → ArrayString or &str
let name: = try_from?;
// RS507: HashMap<K,V> → BTreeMap<K,V> or BoundedMap<K,V,N>
let lookup: = new;
Opt-in for external crate boundaries
When wrapping an external Rust crate that uses heap types internally, opt in at module or function scope:
// lifts RS501, RS502, RS503, RS505
// lifts RS504
// lifts RS507
// RS506 (panic) has no opt-out — always enforced
Never apply at crate level.
rs-lang types
Add rs-lang as a dependency and import the prelude:
use *;
Available types:
BoundedVec<T, N>— fixed-capacity vec,try_push()returns Err if fullBoundedMap<K, V, N>— fixed-capacity ordered mapArrayString<N>— fixed-capacity stringArena<T, N>— typed arena, compile-time max, all freed on dropFixedPoint<u128, DECIMALS>— deterministic decimal arithmeticParticle— 64-byte content-address hash (Copy, Eq, Ord)
CLAUDE.md template for companion projects
Add this section to the CLAUDE.md of any project compiled with rsc:
- -