Repository navigation
What's Changed
Highlights
- Faster compilation and diagnostics. A series of optimizations across parsing, semantic analysis and lowering: module discovery (including plugin expansion) is now warmed up in parallel, the red-tree arena is built in place and chunked per item, trait-solving lookup contexts and code-size estimation are memoized, calls that would be inlined are no longer specialized first, and hash containers use foldhash. Diagnostics on large Starknet projects improved by up to ~40%. See Optimizations below.
- Build-independent Sierra output. The function chosen to carry the
withdraw_gascheck in a recursive cycle, and the order of impl candidates and impl type bounds, are now determined by a structural order instead of salsa internal ids, so the same program always compiles to the same Sierra regardless of parallel warmup. #10437 #10436 - Rustc-style names for generated functions. Closures and loops are named
{closure#N}/{loop#N}under their defining function (e.g.test::foo::{closure#0}::{loop#0}) instead of by source location, keeping Sierra debug names stable across edits. The Sierra parser accepts the new form alongside the old ones. #10359 #10360 - Shorter diagnostic paths. Types, traits, impls and generic arguments in type mismatch, trait resolution and inference diagnostics are now shown relative to the current module (
Copy::<NoSerde>instead ofcore::traits::Copy::<test::NoSerde>). #10327 #10328 #10330 - Cheaper circuit guarantee verification. New
u96_limbs_less_than_guarantee_verify_v2libfunc verifies aU96LimbsLtGuaranteein a single call with one range check, and the corelibDestructforU96LimbsLtGuarantee<4>now uses it. #10377 #10443
Features
- Contextualize paths in inference errors and type diagnostics, without prelude-shortening paths shadowed by local items. #10327 #10328 #10330
- Name generated functions (closures, loops) by a rustc-style path instead of their source location, and parse the new paths in generated Sierra. #10359 #10360
- Added the
u96_limbs_less_than_guarantee_verify_v2libfunc and used it in the corelib. #10377 #10443 - Trim unused parameters of compiler-generated loop functions, from both the signature and every call site. by @TomerStarkware in #10246
- Added support for injecting constant values externally via
ExternalConstPlugins, through the reserved__externally_provided_const__extern function. #10274 - Parameter debug paths now include the defining function (
test::foo::xinstead oftest::x). #10269
Bug Fixes
- Report macro expansion failures as diagnostics instead of panicking, and reject an expansion block with nothing repeating at its depth. #10297 #10298
- Validate the param kind of every macro rule param, not just the first. #10238
- Reject multiple
#[path(..)]attributes on a module. #10239 - Fixed const evaluation of
==/!=going through core's genericPartialEqimpls while ignoring a userPartialEqimpl; such comparisons are now rejected withUnsupportedConstant. by @0xShadowX in #10395 - Report an infinitely-sized type only at the member or variant that closes the cycle, instead of at every use. #10280
- Don't leak a closure's early
returninto the enclosing loop. #10258 - Desnap snapshot-only captured members instead of ICEing. #10240
- Don't forward a moved non-copyable enum payload in const folding (fixes a
Failed to specialize: duppanic in Sierra generation). by @Bruce039 in #10388 - Don't orphan non-droppable inputs in variable forwarding. by @eytan-starkware in #10260
- Don't ICE on a deref chain whose downstream impl has the wrong associated-type count. #10257
- Report an unresolved trait in a negative impl bound. #10255
- Return the real full path for a constant
ResolvedGenericItem. #10243 - Recover from salsa cycles in
enum_definition_dataand the item generic-params queries instead of panicking. #10268 #10272 - Ignore trivia around
#[cfg]operator names and around the#[inline]attribute argument. by @Bruce039 and @FlashWayne in #10389 #10417 - Use a trivia-free origin span for the
consteval_int!code mapping. #10262 - Analyzer plugins now properly forward inner spans. #10250
- Parser: don't consume the EOF sentinel in a truncated
forexpression, fixed the location of missing-before-EOF diagnostics, and stoppedcolored_printerpanicking on valid tokens. #10254 #10256 #10261 - Syntax node casts now verify the token kind. #10248
cairo-testran the wrong function when one test's full name was a suffix of another's. by @0xShadowX in #10393- Test plugin: don't panic on an invalid string in
#[should_panic]. by @FlashWayne in #10421 - Runner: return the correct entrypoint selector. #10242
- Lazily format the function path in optimization dump traces. #10355
Sierra
- Reject circuits whose gates form a cycle instead of looping forever. by @kriss39 in #10408
- Don't panic on invalid forward-declared type info. by @kriss39 in #10409
- Reject
felt252_div_constby a multiple of the prime. by @0xShadowX in #10424 - Fixed an overflow on a huge variant selector in a const enum. by @0xShadowX in #10415
- Fixed an ap-change underflow when merging tracking info from different bases. by @0xShadowX in #10413
- Avoid overflow when simulating
array_slice. by @wangjingshuiku in #10373 - Limited the enum variant types allowed as
Felt252Dictvalues, and validated fp-continuity inlocal_into_box(from v2.19.5). #10380 - Pinned
good_lpto keep gas solver results stable. #10378
Starknet
- Return a
UnexpectedEntryPointCosterror instead of panicking when an entry point uses a builtin before its firstwithdraw_gas. by @FlashWayne in #10411 - Check all non-flat event variant selectors for duplicates, not just
#[nested]ones. by @FlashWayne in #10403 - Name the generated embed impl after the impl alias, so two components with the same
#[embeddable_as]name no longer collide. by @FlashWayne in #10397 - Don't emit a leading
::for single-segment embedded impls. by @kriss39 in #10425 - Don't let the
#[embeddable_as]wrapper's component local shadow a parameter namedcomponent. #10273
Corelib
Store::scrubno longer overflows when the cleared value ends at the last slot of a base address. by @Bruce039 in #10419DestructforU96LimbsLtGuarantee<4>uses the single-callu96_limbs_less_than_guarantee_verify_v2. #10443
Formatter
- Break a match arm's pattern before breaking its block expression. by @liorgold2 in #10266
- Merge
pub useitems separated by a blank line. #10229 - Stop adding trailing separators in macro call token trees. #10354
- Keep parameter-list comment formatting idempotent. by @futurehua in #10208
- Format the trailing trivia of nodes kept as written, and don't glue a leading comment to the previous token. by @kriss39 in #10386 #10385
- Keep lists broken when an item has a comment on its own line, and keep match arm blocks broken when a comment precedes the closing brace. by @Bruce039 in #10391 #10433
Optimizations
- Warm up module discovery in parallel (~40% faster diagnostics on large Starknet projects, ~15% on the corelib). #10342
- Red tree: build the arena in place and hash
SyntaxNodeby data only, materialize children per tree instead of per node, chunk the arena at item boundaries, key theget_childrenmemo on the tracked node data, and check for missing nodes via a green tree walk. #10339 #10337 #10341 #10333 #10332 - Cache trivia green ids in the parser. #10343
- Compute expansion offsets only within macro expansions. #10340
- Memoize lookup-context enrichment for trait solving. #10334
- Drop salsa wrappers whose machinery outweighs the computation, and cache the never type in
CoreInfo. #10335 #10336 - Use foldhash for ordered and unordered hash containers. #10338 #10347
- Memoize function code size estimation, and skip specializing calls that would be inlined anyway (~4.5% faster full compilation). #10348 #10350
- Reprocess replaced block ends for inlining, and fold a struct destructure of a constant into member constants, slightly shrinking generated code. #10349 #10357
- Return
Maybe<&Signature>from the loweringsignature()methods. #10326
Documentation
- Corelib doc examples now compile:
bytes31,cmp,Iterator::any/all,assert!,storage_node, and the mutable tuple-pattern reference example. #10237 #10247 #10252 #10251 #10253 #10236 - Doc rendering: keep the
::before an associated-type segment in signatures, and keep a list item's marker outside the emphasis that opens it. #10271 #10279 - Standardized markdown formatting across documentation. #10364
- Comment and doc fixes. by @questfever, @zloglevel, @zjuzhongwen, @ginavalent, @colinaumaty, @myetcd, @somasoil and @fmterrors in #10345 #10353 #10356 #10375 #10365 #10405 #10439 #10444 #10241 #10259
Other
- Replaced the
ark-*crates withlambdaworks-mathfor secp256k1/r1 syscalls in the runner. #10329 - Made
Lowered.signatureexact at every lowering stage. #10322 #10323 #10324 - Golden test infrastructure: migrated test data to a single
cairo_codeinput with#[target_function], and unified the lowering/optimization runners. #10288 #10284 #10295 - CI: pinned GitHub Actions to commit SHAs and added Dependabot for them. #10230 #10231
- Dependency updates, including salsa. #10235 #10267 #10351 #10362
New Contributors
- @futurehua made their first contribution in #10208
- @questfever made their first contribution in #10345
- @zloglevel made their first contribution in #10353
- @zjuzhongwen made their first contribution in #10356
- @wangjingshuiku made their first contribution in #10373
- @ginavalent made their first contribution in #10375
- @colinaumaty made their first contribution in #10365
- @kriss39 made their first contribution in #10386
- @Bruce039 made their first contribution in #10389
- @FlashWayne made their first contribution in #10403
- @myetcd made their first contribution in #10405
- @0xShadowX made their first contribution in #10393
- @somasoil made their first contribution in #10439
- @fmterrors made their first contribution in #10444
Full Changelog: v2.20.0...v2.21.0