diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce8b1f7a3a3..626406ef9c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: nightly-2024-08-22 + toolchain: nightly-2024-09-04 targets: wasm32-unknown-unknown - uses: Swatinem/rust-cache@v2 - run: | @@ -63,7 +63,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: components: rustfmt - toolchain: nightly-2024-08-22 + toolchain: nightly-2024-09-04 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - name: Install nextest @@ -86,7 +86,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: components: rustfmt - toolchain: nightly-2024-08-22 + toolchain: nightly-2024-09-04 - uses: Swatinem/rust-cache@v2 - run: scripts/rust_fmt.sh --check @@ -125,7 +125,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: components: clippy - toolchain: nightly-2024-08-22 + toolchain: nightly-2024-09-04 - uses: Swatinem/rust-cache@v2 - run: > scripts/clippy.sh @@ -142,7 +142,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: nightly-2024-08-22 + toolchain: nightly-2024-09-04 - uses: Swatinem/rust-cache@v2 - run: > scripts/docs.sh diff --git a/crates/cairo-lang-casm/src/builder.rs b/crates/cairo-lang-casm/src/builder.rs index 95abc44023a..1f22fc22c67 100644 --- a/crates/cairo-lang-casm/src/builder.rs +++ b/crates/cairo-lang-casm/src/builder.rs @@ -113,9 +113,11 @@ pub struct CasmBuildResult { pub branches: [(State, Vec); BRANCH_COUNT], } -/// Builder to more easily write casm code without specifically thinking about ap changes and the -/// sizes of opcodes. Wrong usages of it would panic instead of returning a result, as this builder -/// assumes we are in a post validation of parameters stage. +/// Builder to more easily write casm code. +/// +/// Allows CASM building without specifically thinking about ap changes and the sizes of opcodes. +/// Wrong usages of it would panic instead of returning a result, as this builder assumes we are in +/// a post validation of parameters stage. pub struct CasmBuilder { /// The state at a point of jumping into a label, per label. label_state: UnorderedHashMap, diff --git a/crates/cairo-lang-defs/src/plugin_utils.rs b/crates/cairo-lang-defs/src/plugin_utils.rs index 43b387b95b2..d467a5c3da5 100644 --- a/crates/cairo-lang-defs/src/plugin_utils.rs +++ b/crates/cairo-lang-defs/src/plugin_utils.rs @@ -109,6 +109,7 @@ pub fn escape_node(db: &dyn SyntaxGroup, node: SyntaxNode) -> String { } /// Macro to extract unnamed arguments of an inline macro. +/// /// Gets the expected number of unnamed arguments, and the pattern for the allowed bracket types, /// and returns a fixed size array with the argument expressions. /// diff --git a/crates/cairo-lang-diagnostics/src/diagnostics.rs b/crates/cairo-lang-diagnostics/src/diagnostics.rs index 5dfdff76781..2c4b335273b 100644 --- a/crates/cairo-lang-diagnostics/src/diagnostics.rs +++ b/crates/cairo-lang-diagnostics/src/diagnostics.rs @@ -160,6 +160,7 @@ impl ToMaybe for Option { } /// Temporary trait to allow conversions from `Maybe` to `Option`. +/// /// The behavior is identical to [Result::ok]. It is used to mark all the location where there /// is a conversion between the two mechanisms. // TODO(lior): Remove this trait after converting all the functions. diff --git a/crates/cairo-lang-filesystem/src/db.rs b/crates/cairo-lang-filesystem/src/db.rs index c75a0984aeb..7132dc9db9f 100644 --- a/crates/cairo-lang-filesystem/src/db.rs +++ b/crates/cairo-lang-filesystem/src/db.rs @@ -51,6 +51,7 @@ pub struct CrateSettings { } /// The Cairo edition of a crate. +/// /// Editions are a mechanism to allow breaking changes in the compiler. /// Compiler minor version updates will always support all editions supported by the previous /// updates with the same major version. Compiler major version updates may remove support for older diff --git a/crates/cairo-lang-filesystem/src/ids.rs b/crates/cairo-lang-filesystem/src/ids.rs index fb02a8d9f5b..06e223c6f04 100644 --- a/crates/cairo-lang-filesystem/src/ids.rs +++ b/crates/cairo-lang-filesystem/src/ids.rs @@ -35,6 +35,7 @@ impl CrateId { } /// A trait for getting the internal salsa::InternId of a short id object. +/// /// This id is unstable across runs and should not be used to anything that is externally visible. /// This is currently used to pick representative for strongly connected components. pub trait UnstableSalsaId { diff --git a/crates/cairo-lang-lowering/src/destructs.rs b/crates/cairo-lang-lowering/src/destructs.rs index e4081f57e6f..42d036e6329 100644 --- a/crates/cairo-lang-lowering/src/destructs.rs +++ b/crates/cairo-lang-lowering/src/destructs.rs @@ -1,4 +1,6 @@ -//! This module implements the destructor call addition. It is assumed to run after the panic phase. +//! This module implements the destructor call addition. +//! +//! It is assumed to run after the panic phase. //! This is similar to the borrow checking algorithm, except we handle "undroppable drops" by adding //! destructor calls. diff --git a/crates/cairo-lang-lowering/src/lower/context.rs b/crates/cairo-lang-lowering/src/lower/context.rs index a2c10817334..14d409efbcf 100644 --- a/crates/cairo-lang-lowering/src/lower/context.rs +++ b/crates/cairo-lang-lowering/src/lower/context.rs @@ -99,6 +99,7 @@ impl<'db> Index for VariableAllocator<'db> { } /// Lowering context for the encapsulating semantic function. +/// /// Each semantic function may generate multiple lowered functions. This context is common to all /// the generated lowered functions of an encapsulating semantic function. pub struct EncapsulatingLoweringContext<'db> { diff --git a/crates/cairo-lang-lowering/src/objects.rs b/crates/cairo-lang-lowering/src/objects.rs index 2b43fe311e8..3efa0e411b0 100644 --- a/crates/cairo-lang-lowering/src/objects.rs +++ b/crates/cairo-lang-lowering/src/objects.rs @@ -1,4 +1,5 @@ //! Intermediate representation objects after lowering from semantic. +//! //! This representation is SSA (static single-assignment): each variable is defined before usage and //! assigned once. It is also normal form: each function argument is a variable, rather than a //! compound expression. diff --git a/crates/cairo-lang-lowering/src/optimizations/remappings.rs b/crates/cairo-lang-lowering/src/optimizations/remappings.rs index 3dd69fb747e..d9bef94fefe 100644 --- a/crates/cairo-lang-lowering/src/optimizations/remappings.rs +++ b/crates/cairo-lang-lowering/src/optimizations/remappings.rs @@ -1,4 +1,5 @@ //! Remove unnecessary remapping of variables optimization. +//! //! At each convergence, we have one or more branches with remappings of variables. //! A destination variable `dest` introduced by the remappings must be remapped at every branch //! `b_i` by mapping a source variable `src_i->dest`. diff --git a/crates/cairo-lang-lowering/src/optimizations/return_optimization.rs b/crates/cairo-lang-lowering/src/optimizations/return_optimization.rs index 2eea084a6dd..a20d4fb415a 100644 --- a/crates/cairo-lang-lowering/src/optimizations/return_optimization.rs +++ b/crates/cairo-lang-lowering/src/optimizations/return_optimization.rs @@ -303,6 +303,7 @@ pub struct ReturnInfo { } /// A wrapper around `ReturnInfo` that makes it optional. +/// /// None indicates that the return info is unknown. /// If early_return_possible() returns true, the function can return early as the return value is /// already known. diff --git a/crates/cairo-lang-lowering/src/optimizations/split_structs.rs b/crates/cairo-lang-lowering/src/optimizations/split_structs.rs index d6cb2b80655..bae1c309e0a 100644 --- a/crates/cairo-lang-lowering/src/optimizations/split_structs.rs +++ b/crates/cairo-lang-lowering/src/optimizations/split_structs.rs @@ -17,10 +17,10 @@ use crate::{ StatementStructDestructure, VarRemapping, VarUsage, Variable, VariableId, }; -/// Splits all the variables that were created by struct_construct and -/// reintroduces the struct_construct statement when needed. +/// Splits all the variables that were created by struct_construct and reintroduces the +/// struct_construct statement when needed. +/// /// Note that if a member is used after the struct then is means that that struct is copyable. - pub fn split_structs(lowered: &mut FlatLowered) { if lowered.blocks.is_empty() { return; diff --git a/crates/cairo-lang-plugins/src/plugins/config.rs b/crates/cairo-lang-plugins/src/plugins/config.rs index feaa3578caa..00b6d1c7325 100644 --- a/crates/cairo-lang-plugins/src/plugins/config.rs +++ b/crates/cairo-lang-plugins/src/plugins/config.rs @@ -14,6 +14,7 @@ use cairo_lang_syntax::node::{ast, Terminal, TypedSyntaxNode}; use cairo_lang_utils::try_extract_matches; /// Plugin that enables ignoring modules not involved in the current config. +/// /// Mostly useful for marking test modules to prevent usage of their functionality out of tests, /// and reduce compilation time when the tests data isn't required. #[derive(Debug, Default)] diff --git a/crates/cairo-lang-runner/src/profiling.rs b/crates/cairo-lang-runner/src/profiling.rs index ee9e266dd74..776c77b420a 100644 --- a/crates/cairo-lang-runner/src/profiling.rs +++ b/crates/cairo-lang-runner/src/profiling.rs @@ -523,6 +523,7 @@ fn is_cairo_trace( /// Converts a sierra statement index to the index of the function that contains it (the index in /// the list in the sierra program). +/// /// Assumes that the given `statement_idx` is valid (that is within range of the given /// `sierra_program`) and that the given `sierra_program` is valid, specifically that the first /// function's entry point is 0. diff --git a/crates/cairo-lang-semantic/src/expr/pattern.rs b/crates/cairo-lang-semantic/src/expr/pattern.rs index ad80e3ac2b8..3bc21105dae 100644 --- a/crates/cairo-lang-semantic/src/expr/pattern.rs +++ b/crates/cairo-lang-semantic/src/expr/pattern.rs @@ -12,6 +12,7 @@ use crate::db::SemanticGroup; use crate::{semantic, ConcreteStructId, ExprLiteral, ExprStringLiteral, LocalVariable, PatternId}; /// Semantic representation of a Pattern. +/// /// A pattern is a way to "destructure" values. A pattern may introduce new variables that are bound /// to inner values of a specific value. For example, a tuple pattern destructures a tuple /// and may result in new variables for an elements of that tuple. diff --git a/crates/cairo-lang-semantic/src/items/generics.rs b/crates/cairo-lang-semantic/src/items/generics.rs index f1e9334941d..3421fd051db 100644 --- a/crates/cairo-lang-semantic/src/items/generics.rs +++ b/crates/cairo-lang-semantic/src/items/generics.rs @@ -99,9 +99,11 @@ impl DebugWithDb for GenericArgumentId { } } -/// Head of a generic argument. A non-param non-variable generic argument has a head, which -/// represents the kind of the root node in its tree. This is used for caching queries for fast -/// lookups when the generic argument is not completely inferred yet. +/// Head of a generic argument. +/// +/// A non-param non-variable generic argument has a head, which represents the kind of the root node +/// in its tree. This is used for caching queries for fast lookups when the generic argument is not +/// completely inferred yet. #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub enum GenericArgumentHead { Type(TypeHead), diff --git a/crates/cairo-lang-semantic/src/items/imp.rs b/crates/cairo-lang-semantic/src/items/imp.rs index 2859fa8eed8..8944f7fce27 100644 --- a/crates/cairo-lang-semantic/src/items/imp.rs +++ b/crates/cairo-lang-semantic/src/items/imp.rs @@ -428,9 +428,11 @@ impl UnstableSalsaId for ImplId { } } -/// Head of an impl. A non-param non-variable impl has a head, which represents the kind of the root -/// node in its tree representation. This is used for caching queries for fast lookups when the impl -/// is not completely inferred yet. +/// Head of an impl. +/// +/// A non-param non-variable impl has a head, which represents the kind of the root node in its tree +/// representation. This is used for caching queries for fast lookups when the impl is not +/// completely inferred yet. #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub enum ImplHead { Concrete(ImplDefId), diff --git a/crates/cairo-lang-semantic/src/types.rs b/crates/cairo-lang-semantic/src/types.rs index 7d8609c9791..4db682ec2a3 100644 --- a/crates/cairo-lang-semantic/src/types.rs +++ b/crates/cairo-lang-semantic/src/types.rs @@ -210,9 +210,11 @@ impl DebugWithDb for TypeLongId { } } -/// Head of a type. A type that is not one of {generic param, type variable, impl type} has a head, -/// which represents the kind of the root node in its type tree. This is used for caching queries -/// for fast lookups when the type is not completely inferred yet. +/// Head of a type. +/// +/// A type that is not one of {generic param, type variable, impl type} has a head, which represents +/// the kind of the root node in its type tree. This is used for caching queries for fast lookups +/// when the type is not completely inferred yet. #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub enum TypeHead { Concrete(GenericTypeId), diff --git a/crates/cairo-lang-sierra-gas/src/core_libfunc_cost_base.rs b/crates/cairo-lang-sierra-gas/src/core_libfunc_cost_base.rs index 2c3ea029f00..bfe92235f22 100644 --- a/crates/cairo-lang-sierra-gas/src/core_libfunc_cost_base.rs +++ b/crates/cairo-lang-sierra-gas/src/core_libfunc_cost_base.rs @@ -57,9 +57,11 @@ use crate::objects::{ }; use crate::starknet_libfunc_cost_base::starknet_libfunc_cost_base; -/// The cost per each unique key in the dictionary. This cost is pre-charged for each access -/// (read/write/entry), and the overhead cost is refunded for each repeated access. -/// Repeated access is access to a key that has already been accessed before. +/// The cost per each unique key in the dictionary. +/// +/// This cost is pre-charged for each access (read/write/entry), and the overhead cost is refunded +/// for each repeated access. Repeated access is access to a key that has already been accessed +/// before. pub const DICT_SQUASH_UNIQUE_KEY_COST: ConstCost = ConstCost { steps: 46, holes: 0, range_checks: 6, range_checks96: 0 }; /// The cost per each access to a key after the first access. diff --git a/crates/cairo-lang-sierra-generator/src/local_variables.rs b/crates/cairo-lang-sierra-generator/src/local_variables.rs index 633e349bb5d..d0ddb6d78e4 100644 --- a/crates/cairo-lang-sierra-generator/src/local_variables.rs +++ b/crates/cairo-lang-sierra-generator/src/local_variables.rs @@ -242,7 +242,7 @@ struct BranchInfo { impl<'a> FindLocalsContext<'a> { /// Given a variable that might be an alias follow aliases until we get the original variable. - pub fn peel_aliases(&'a self, mut var: &'a VariableId) -> &VariableId { + pub fn peel_aliases(&'a self, mut var: &'a VariableId) -> &'a VariableId { while let Some(alias) = self.aliases.get(var) { var = alias; } @@ -250,7 +250,7 @@ impl<'a> FindLocalsContext<'a> { } /// Given a variable, that might be an alias of a const, follow the const aliases until we get /// the root variable. - pub fn peel_const_aliases(&'a self, mut var: &'a VariableId) -> &VariableId { + pub fn peel_const_aliases(&'a self, mut var: &'a VariableId) -> &'a VariableId { while let Some(alias) = self.const_aliases.get(var) { var = alias; } diff --git a/crates/cairo-lang-sierra-generator/src/replace_ids.rs b/crates/cairo-lang-sierra-generator/src/replace_ids.rs index b4b3f4c7d8f..d597115ee09 100644 --- a/crates/cairo-lang-sierra-generator/src/replace_ids.rs +++ b/crates/cairo-lang-sierra-generator/src/replace_ids.rs @@ -78,6 +78,7 @@ pub trait SierraIdReplacer { /// Replaces `cairo_lang_sierra::ids::{ConcreteLibfuncId, ConcreteTypeId, FunctionId}` with a dummy /// ids whose debug string is the string representing the expanded information about the id. +/// /// For Libfuncs and Types - that would be recursively opening their generic arguments, for /// functions - that would be getting their original name. For example, while the original debug /// string may be `[6]`, the resulting debug string may be: @@ -194,6 +195,7 @@ pub fn replace_sierra_ids( /// Replaces `cairo_lang_sierra::ids::{ConcreteLibfuncId, ConcreteTypeId, FunctionId}` with a dummy /// ids whose debug string is the string representing the expanded information about the id. +/// /// For Libfuncs and Types - that would be recursively opening their generic arguments, for /// functions - that would be getting their original name. For example, while the original debug /// string may be `[6]`, the resulting debug string may be: diff --git a/crates/cairo-lang-sierra-generator/src/statements_code_locations.rs b/crates/cairo-lang-sierra-generator/src/statements_code_locations.rs index 5000f5548a6..7c0bc873e94 100644 --- a/crates/cairo-lang-sierra-generator/src/statements_code_locations.rs +++ b/crates/cairo-lang-sierra-generator/src/statements_code_locations.rs @@ -28,7 +28,9 @@ pub struct SourceCodeSpan { } /// The mapping between sierra statement indexes and locations in cairo code -/// (if obtainable) which caused the statement to be generated. Should be created using +/// (if obtainable) which caused the statement to be generated. +/// +/// Should be created using /// [`crate::statements_locations::StatementsLocations::extract_statements_source_code_locations`]. #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct StatementsSourceCodeLocations { diff --git a/crates/cairo-lang-sierra-generator/src/statements_functions.rs b/crates/cairo-lang-sierra-generator/src/statements_functions.rs index feae5a0128b..333c306338a 100644 --- a/crates/cairo-lang-sierra-generator/src/statements_functions.rs +++ b/crates/cairo-lang-sierra-generator/src/statements_functions.rs @@ -6,7 +6,9 @@ use cairo_lang_utils::ordered_hash_map::OrderedHashMap; use serde::{Deserialize, Serialize}; /// The mapping from sierra statement index to fully qualified Cairo path of the Cairo function -/// (if obtainable) which caused the statement to be generated. Should be created using +/// (if obtainable) which caused the statement to be generated. +/// +/// Should be created using /// [`crate::statements_locations::StatementsLocations::extract_statements_functions`]. #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct StatementsFunctions { diff --git a/crates/cairo-lang-sierra-generator/src/test_utils.rs b/crates/cairo-lang-sierra-generator/src/test_utils.rs index 2646507326c..0b2f19c00e6 100644 --- a/crates/cairo-lang-sierra-generator/src/test_utils.rs +++ b/crates/cairo-lang-sierra-generator/src/test_utils.rs @@ -288,6 +288,7 @@ pub fn dummy_push_values_ex( } /// Creates a test for a given function that reads test files. +/// /// filenames - a vector of tests files the test will apply to. /// db - the salsa DB to use for the test. /// func - the function to be applied on the test params to generate the tested result. diff --git a/crates/cairo-lang-sierra/src/algorithm/topological_order.rs b/crates/cairo-lang-sierra/src/algorithm/topological_order.rs index 25133d24346..5a2aeaba36a 100644 --- a/crates/cairo-lang-sierra/src/algorithm/topological_order.rs +++ b/crates/cairo-lang-sierra/src/algorithm/topological_order.rs @@ -12,6 +12,7 @@ enum TopologicalOrderStatus { } /// Returns the topological ordering. +/// /// `detect_cycles` - if true, the function will return an error if a cycle is detected, else will /// not detect the cycle, and ordering within cycles won't be topological. /// `roots` - the roots of the graph. diff --git a/crates/cairo-lang-sierra/src/extensions/lib_func.rs b/crates/cairo-lang-sierra/src/extensions/lib_func.rs index 0b56e1cbe3c..df353f010b9 100644 --- a/crates/cairo-lang-sierra/src/extensions/lib_func.rs +++ b/crates/cairo-lang-sierra/src/extensions/lib_func.rs @@ -353,6 +353,7 @@ impl From for ParamSignature { } /// Information regarding the reference created as an output of a library function. +/// /// For example, whether the reference is equal to one of the parameters (as in the dup() function), /// or whether it's newly allocated local variable. #[derive(Debug, Clone)] diff --git a/crates/cairo-lang-sierra/src/extensions/modules/coupon.rs b/crates/cairo-lang-sierra/src/extensions/modules/coupon.rs index dc850f04a7c..073e700ac54 100644 --- a/crates/cairo-lang-sierra/src/extensions/modules/coupon.rs +++ b/crates/cairo-lang-sierra/src/extensions/modules/coupon.rs @@ -14,6 +14,7 @@ use crate::program::GenericArg; /// Coupon type `Coupon` (`function::Coupon`) which represents that the cost of a /// function was paid, without calling the function yet. +/// /// Using the coupon the function can be called without paying the cost. #[derive(Default)] pub struct CouponType {} @@ -68,10 +69,11 @@ define_libfunc_hierarchy! { }, CouponConcreteLibfunc } -/// Libfunc for buying a coupon for a function. The cost of the coupon is the cost of running the -/// function (not including the `call` and `ret` instructions). -/// The coupon can be used to pay in advance for running the function, and run it later for -/// free (paying only for the `call` and `ret` instructions) using `coupon_call`. +/// Libfunc for buying a coupon for a function. +/// +/// The cost of the coupon is the cost of running the function (not including the `call` and `ret` +/// instructions). The coupon can be used to pay in advance for running the function, and run it +/// later for free (paying only for the `call` and `ret` instructions) using `coupon_call`. #[derive(Default)] pub struct CouponBuyLibfunc {} impl NamedLibfunc for CouponBuyLibfunc { diff --git a/crates/cairo-lang-sierra/src/extensions/modules/ec.rs b/crates/cairo-lang-sierra/src/extensions/modules/ec.rs index e351ba037c0..ecebc2031ac 100644 --- a/crates/cairo-lang-sierra/src/extensions/modules/ec.rs +++ b/crates/cairo-lang-sierra/src/extensions/modules/ec.rs @@ -121,6 +121,7 @@ impl NoGenericArgsGenericLibfunc for EcCreatePointLibfunc { } /// Libfunc for creating an EC point from its x coordinate. +/// /// If there exists `y` such that `(x, y)` is on the curve, either `(x, y)` or `(x, -y)` (both /// constitute valid points on the curve) is returned. /// Otherwise, nothing is returned. diff --git a/crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs b/crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs index 83976f5175f..7f0093a67f0 100644 --- a/crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs +++ b/crates/cairo-lang-sierra/src/extensions/modules/felt252_dict.rs @@ -24,6 +24,7 @@ use crate::ids::{ConcreteTypeId, GenericTypeId}; use crate::program::{ConcreteTypeLongId, GenericArg}; /// Type representing a dictionary from a felt252 to types of size one. +/// /// This is currently only bounded for all numeric types, Nullable, and Enum types with 2 or less /// variants, as this are the types that has proper default as 0, and therefore can be properly used /// as a value in the dictionary. diff --git a/crates/cairo-lang-sierra/src/extensions/modules/segment_arena.rs b/crates/cairo-lang-sierra/src/extensions/modules/segment_arena.rs index ac4c30731ca..644bd1c94d8 100644 --- a/crates/cairo-lang-sierra/src/extensions/modules/segment_arena.rs +++ b/crates/cairo-lang-sierra/src/extensions/modules/segment_arena.rs @@ -2,6 +2,7 @@ use crate::extensions::NoGenericArgsGenericType; use crate::ids::GenericTypeId; /// Type for the Segment Arena builtin. +/// /// This type should be initialized and destructed by the OS. /// It is assumed to be a pointer to a segment containing the following struct: /// A data segment start. diff --git a/crates/cairo-lang-starknet-classes/src/compiler_version.rs b/crates/cairo-lang-starknet-classes/src/compiler_version.rs index b5d1940030a..56494c84662 100644 --- a/crates/cairo-lang-starknet-classes/src/compiler_version.rs +++ b/crates/cairo-lang-starknet-classes/src/compiler_version.rs @@ -26,6 +26,7 @@ pub fn current_compiler_version_id() -> VersionId { } /// The version of the Sierra compiler that compiled the contract. +/// /// Major version should be updated in any non-backwards compatible change of the Sierra compiler. /// Minor version should be updated in any backwards compatible change of the Sierra compiler. /// For more information see docs/CONTRIBUTING.md. diff --git a/crates/cairo-lang-syntax-codegen/src/generator.rs b/crates/cairo-lang-syntax-codegen/src/generator.rs index 24a41f35974..6dbcd8f0dc5 100644 --- a/crates/cairo-lang-syntax-codegen/src/generator.rs +++ b/crates/cairo-lang-syntax-codegen/src/generator.rs @@ -49,7 +49,7 @@ pub fn reformat_rust_code(text: String) -> String { } pub fn reformat_rust_code_inner(text: String) -> String { let sh = Shell::new().unwrap(); - sh.set_var("RUSTUP_TOOLCHAIN", "nightly-2024-08-22"); + sh.set_var("RUSTUP_TOOLCHAIN", "nightly-2024-09-04"); let rustfmt_toml = project_root().join("rustfmt.toml"); let mut stdout = cmd!(sh, "rustfmt --config-path {rustfmt_toml}").stdin(text).read().unwrap(); if !stdout.ends_with('\n') { @@ -172,6 +172,7 @@ fn generate_key_fields_code() -> rust::Tokens { use super::kind::SyntaxKind; $("/// Gets the vector of children ids that are the indexing key for this SyntaxKind.\n") + $("///\n") $("/// Each SyntaxKind has some children that are defined in the spec to be its indexing key\n") $("/// for its stable pointer. See [super::stable_ptr].\n") pub fn get_key_fields(kind: SyntaxKind, children: &[GreenId]) -> Vec { diff --git a/crates/cairo-lang-syntax/src/attribute/consts.rs b/crates/cairo-lang-syntax/src/attribute/consts.rs index 2fae97404df..cdc9dd15af2 100644 --- a/crates/cairo-lang-syntax/src/attribute/consts.rs +++ b/crates/cairo-lang-syntax/src/attribute/consts.rs @@ -33,6 +33,7 @@ pub const FEATURE_ATTR: &str = "feature"; pub const IMPLICIT_PRECEDENCE_ATTR: &str = "implicit_precedence"; /// An attribute for the declaration of a starknet interface. +/// /// It is used in the starknet crate, however it is defined here because it is currently used in the /// corelib. /// TODO(Gil): Remove this once `starknet` is removed from corelib. diff --git a/crates/cairo-lang-syntax/src/node/key_fields.rs b/crates/cairo-lang-syntax/src/node/key_fields.rs index da602e9c476..b179d4774cb 100644 --- a/crates/cairo-lang-syntax/src/node/key_fields.rs +++ b/crates/cairo-lang-syntax/src/node/key_fields.rs @@ -2,6 +2,7 @@ use super::ids::GreenId; use super::kind::SyntaxKind; /// Gets the vector of children ids that are the indexing key for this SyntaxKind. +/// /// Each SyntaxKind has some children that are defined in the spec to be its indexing key /// for its stable pointer. See [super::stable_ptr]. pub fn get_key_fields(kind: SyntaxKind, children: &[GreenId]) -> Vec { diff --git a/crates/cairo-lang-syntax/src/node/stable_ptr.rs b/crates/cairo-lang-syntax/src/node/stable_ptr.rs index 27beab79fbb..e98e2eb1ee6 100644 --- a/crates/cairo-lang-syntax/src/node/stable_ptr.rs +++ b/crates/cairo-lang-syntax/src/node/stable_ptr.rs @@ -4,6 +4,7 @@ use super::ids::{GreenId, SyntaxStablePtrId}; use super::kind::SyntaxKind; /// Stable pointer to a node in the syntax tree. +/// /// Has enough information to uniquely define a node in the AST, given the tree. /// Has undefined behavior when used with the wrong tree. /// This is not a real pointer in the low-level sense, just a representation of the path from the diff --git a/crates/cairo-lang-test-plugin/src/lib.rs b/crates/cairo-lang-test-plugin/src/lib.rs index 32b6e495635..e2af0128af0 100644 --- a/crates/cairo-lang-test-plugin/src/lib.rs +++ b/crates/cairo-lang-test-plugin/src/lib.rs @@ -176,6 +176,7 @@ pub fn compile_test_prepared_db( } /// Encapsulation of all data required to execute tests. +/// /// This includes the source code compiled to a Sierra program and all cairo-test specific /// data extracted from it. /// This can be stored on the filesystem and shared externally. @@ -187,6 +188,7 @@ pub struct TestCompilation { } /// Encapsulation of all data required to execute tests, except for the Sierra program itself. +/// /// This includes all cairo-test specific data extracted from the program. /// This can be stored on the filesystem and shared externally. #[derive(Clone, Serialize, Deserialize, Debug, PartialEq)] diff --git a/crates/cairo-lang-test-runner/src/lib.rs b/crates/cairo-lang-test-runner/src/lib.rs index 6c87a04c5f5..4ac720d1309 100644 --- a/crates/cairo-lang-test-runner/src/lib.rs +++ b/crates/cairo-lang-test-runner/src/lib.rs @@ -176,6 +176,7 @@ fn format_for_panic(mut felts: IntoIter) -> String { } /// Whether to run the profiler, and what results to produce. +/// /// With `None`, don't run the profiler. /// With `Sierra`, run the profiler and produce sierra profiling information. /// With `Cairo`, run the profiler and additionally produce cairo profiling information (e.g. diff --git a/crates/cairo-lang-test-utils/src/parse_test_file.rs b/crates/cairo-lang-test-utils/src/parse_test_file.rs index 2c2489812ea..9801cd2dfa8 100644 --- a/crates/cairo-lang-test-utils/src/parse_test_file.rs +++ b/crates/cairo-lang-test-utils/src/parse_test_file.rs @@ -183,6 +183,7 @@ pub trait TestFileRunner { } /// Creates a test that reads test files for a given function. +/// /// test_name - the name of the test. /// filenames - a vector of tests files the test applies to. /// runner - the struct implementing `TestFileRunner + Default`. @@ -274,6 +275,7 @@ impl TestFileRunner for SimpleRunner { } /// Creates a test that reads test files for a given function. +/// /// test_name - the name of the test. /// filenames - a vector of test files the test applies to. /// func - the function to be applied on the test params to generate the tested result. diff --git a/crates/cairo-lang-utils/src/graph_algos/feedback_set.rs b/crates/cairo-lang-utils/src/graph_algos/feedback_set.rs index 4a66f2147ac..770925f1169 100644 --- a/crates/cairo-lang-utils/src/graph_algos/feedback_set.rs +++ b/crates/cairo-lang-utils/src/graph_algos/feedback_set.rs @@ -1,5 +1,6 @@ //! A feedback-vertex-set is a set of vertices whose removal leaves a graph without cycles //! (). +//! //! We use this algorithm to spot the relevant places for adding `withdraw_gas` statements in the //! resulting Sierra code - there should be a `withdraw_gas` call in every recursive call, or in //! other words, in any cycle in the function call graph. diff --git a/crates/cairo-lang-utils/src/lib.rs b/crates/cairo-lang-utils/src/lib.rs index edfdf5e030b..37ca5ac57df 100644 --- a/crates/cairo-lang-utils/src/lib.rs +++ b/crates/cairo-lang-utils/src/lib.rs @@ -59,8 +59,9 @@ impl OptionHelper for Option { } } -/// Borrows a mutable reference as Box for the lifespan of this function. Runs the given closure -/// with the boxed value as a parameter. +/// Borrows a mutable reference as Box for the lifespan of this function. +/// +/// Runs the given closure with the boxed value as a parameter. /// The closure is expected to return a boxed value, whose changes will be reflected on the mutable /// reference. /// Example: @@ -167,6 +168,7 @@ impl UpcastMut for T { } /// Returns `Some(())` if the condition is true, otherwise `None`. +/// /// Useful in functions returning `None` on some condition: /// `require(condition)?;` /// And for functions returning `Err` on some condition: diff --git a/crates/cairo-lang-utils/src/unordered_hash_map.rs b/crates/cairo-lang-utils/src/unordered_hash_map.rs index b4d416bd6b2..d00dd7212aa 100644 --- a/crates/cairo-lang-utils/src/unordered_hash_map.rs +++ b/crates/cairo-lang-utils/src/unordered_hash_map.rs @@ -25,6 +25,7 @@ use hashbrown::HashMap; use itertools::Itertools; /// A hash map that does not care about the order of insertion. +/// /// In particular, it does not support iterating, in order to guarantee deterministic compilation. /// It does support aggregation which can be used in intermediate computations (see `aggregate_by`). /// For an iterable version see [OrderedHashMap](crate::ordered_hash_map::OrderedHashMap). diff --git a/crates/cairo-lang-utils/src/unordered_hash_set.rs b/crates/cairo-lang-utils/src/unordered_hash_set.rs index 7c5dff66d6c..d6706c25bae 100644 --- a/crates/cairo-lang-utils/src/unordered_hash_set.rs +++ b/crates/cairo-lang-utils/src/unordered_hash_set.rs @@ -10,6 +10,7 @@ use std::collections::HashSet; use hashbrown::HashSet; /// A hash set that does not care about the order of insertion. +/// /// In particular, it does not support iterating, in order to guarantee deterministic compilation. /// For an iterable version see [OrderedHashSet](crate::ordered_hash_set::OrderedHashSet). #[cfg(feature = "std")] diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 795eee4a129..f82deba43a0 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -24,7 +24,7 @@ The `rustfmt` configuration used by cairo requires a nightly version of Rust. You can install the nightly version by running. ```sh -rustup install nightly-2024-08-22 +rustup install nightly-2024-09-04 ``` ## Running Tests diff --git a/docs/reference/src/components/cairo/modules/getting_started/pages/prerequisites.adoc b/docs/reference/src/components/cairo/modules/getting_started/pages/prerequisites.adoc index 0a1cca612af..a4b7aef2214 100644 --- a/docs/reference/src/components/cairo/modules/getting_started/pages/prerequisites.adoc +++ b/docs/reference/src/components/cairo/modules/getting_started/pages/prerequisites.adoc @@ -36,5 +36,5 @@ You can install the nightly version by running. [source,bash] ---- -rustup install nightly-2024-08-22 +rustup install nightly-2024-09-04 ---- diff --git a/rustfmt.toml b/rustfmt.toml index 6b5759d88e3..25baeea7b81 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -23,11 +23,11 @@ wrap_comments = true # "rust-analyzer.rustfmt.overrideCommand": [ # "rustup", # "run", -# "nightly-2024-08-22", +# "nightly-2024-09-04", # "--", # "rustfmt", # "--edition", # "2021", # "--" # ] -# and run "rustup toolchain install nightly-2024-08-22". +# and run "rustup toolchain install nightly-2024-09-04". diff --git a/scripts/clippy.sh b/scripts/clippy.sh index 265a91c0139..e16ac5f5cd6 100755 --- a/scripts/clippy.sh +++ b/scripts/clippy.sh @@ -1,6 +1,6 @@ #!/bin/bash -export RUSTUP_TOOLCHAIN="${RUSTUP_TOOLCHAIN:-nightly-2024-08-22}" +export RUSTUP_TOOLCHAIN="${RUSTUP_TOOLCHAIN:-nightly-2024-09-04}" cargo clippy "$@" --all-targets --all-features -- -D warnings -D future-incompatible \ -D nonstandard-style -D rust-2018-idioms -D unused diff --git a/scripts/docs.sh b/scripts/docs.sh index d4ed818e031..90dddbf8126 100755 --- a/scripts/docs.sh +++ b/scripts/docs.sh @@ -1,5 +1,5 @@ #!/bin/bash -export RUSTUP_TOOLCHAIN="${RUSTUP_TOOLCHAIN:-nightly-2024-08-22}" +export RUSTUP_TOOLCHAIN="${RUSTUP_TOOLCHAIN:-nightly-2024-09-04}" RUSTDOCFLAGS="-Dwarnings" cargo doc --document-private-items --no-deps --all-features diff --git a/scripts/rust_fmt.sh b/scripts/rust_fmt.sh index 6b7a88e94fc..3fc5e7b54ca 100755 --- a/scripts/rust_fmt.sh +++ b/scripts/rust_fmt.sh @@ -1,5 +1,5 @@ #!/bin/bash -export RUSTUP_TOOLCHAIN="${RUSTUP_TOOLCHAIN:-nightly-2024-08-22}" +export RUSTUP_TOOLCHAIN="${RUSTUP_TOOLCHAIN:-nightly-2024-09-04}" cargo fmt --all -- "$@"