Skip to content

v2.21.0

Latest

Choose a tag to compare

@github-actions github-actions released this 09 Oct 11:52
· 0 commits to main since this release
90c0e8d

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_gas check 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 of core::traits::Copy::<test::NoSerde>). #10327 #10328 #10330
  • Cheaper circuit guarantee verification. New u96_limbs_less_than_guarantee_verify_v2 libfunc verifies a U96LimbsLtGuarantee in a single call with one range check, and the corelib Destruct for U96LimbsLtGuarantee<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_v2 libfunc 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::x instead of test::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 generic PartialEq impls while ignoring a user PartialEq impl; such comparisons are now rejected with UnsupportedConstant. 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 return into 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: dup panic 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_data and 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 for expression, fixed the location of missing-before-EOF diagnostics, and stopped colored_printer panicking on valid tokens. #10254 #10256 #10261
  • Syntax node casts now verify the token kind. #10248
  • cairo-test ran 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_const by 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 Felt252Dict values, and validated fp-continuity in local_into_box (from v2.19.5). #10380
  • Pinned good_lp to keep gas solver results stable. #10378

Starknet

  • Return a UnexpectedEntryPointCost error instead of panicking when an entry point uses a builtin before its first withdraw_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 named component. #10273

Corelib

  • Store::scrub no longer overflows when the cleared value ends at the last slot of a base address. by @Bruce039 in #10419
  • Destruct for U96LimbsLtGuarantee<4> uses the single-call u96_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 use items 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 SyntaxNode by data only, materialize children per tree instead of per node, chunk the arena at item boundaries, key the get_children memo 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 lowering signature() methods. #10326

Documentation

Other

  • Replaced the ark-* crates with lambdaworks-math for secp256k1/r1 syscalls in the runner. #10329
  • Made Lowered.signature exact at every lowering stage. #10322 #10323 #10324
  • Golden test infrastructure: migrated test data to a single cairo_code input 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

Full Changelog: v2.20.0...v2.21.0