From 7fe7621af0954bcbac68264d68327ed23ea48560 Mon Sep 17 00:00:00 2001 From: Kaya Gokalp Date: Tue, 22 Oct 2024 15:45:35 -0700 Subject: [PATCH 1/4] chore: use rust v1.82 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58be69c8e88..7ee790eb4de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,8 +15,8 @@ concurrency: env: CARGO_TERM_COLOR: always REGISTRY: ghcr.io - RUST_VERSION: 1.79.0 - NIGHTLY_RUST_VERSION: nightly-2024-07-16 + RUST_VERSION: 1.82.0 + NIGHTLY_RUST_VERSION: nightly-2024-10-21 jobs: get-fuel-core-version: From 1bca0270c3ea77f6193260cd905671a806efd7da Mon Sep 17 00:00:00 2001 From: Kaya Gokalp Date: Tue, 22 Oct 2024 21:23:43 -0700 Subject: [PATCH 2/4] clippy lints --- forc-pkg/src/pkg.rs | 27 ++++++++++++--------------- sway-lsp/src/utils/markdown.rs | 2 +- swayfmt/src/comments.rs | 2 +- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/forc-pkg/src/pkg.rs b/forc-pkg/src/pkg.rs index 9467b483b2e..1da43b76b18 100644 --- a/forc-pkg/src/pkg.rs +++ b/forc-pkg/src/pkg.rs @@ -893,22 +893,19 @@ fn validate_version(member_manifests: &MemberManifestFiles) -> Result<()> { /// If required minimum forc version is higher than current forc version return an error with /// upgrade instructions fn validate_pkg_version(pkg_manifest: &PackageManifestFile) -> Result<()> { - match &pkg_manifest.project.forc_version { - Some(min_forc_version) => { - // Get the current version of the toolchain - let crate_version = env!("CARGO_PKG_VERSION"); - let toolchain_version = semver::Version::parse(crate_version)?; - if toolchain_version < *min_forc_version { - bail!( - "{:?} requires forc version {} but current forc version is {}\nUpdate the toolchain by following: https://fuellabs.github.io/sway/v{}/introduction/installation.html", - pkg_manifest.project.name, - min_forc_version, - crate_version, - crate_version - ); - } + if let Some(min_forc_version) = &pkg_manifest.project.forc_version { + // Get the current version of the toolchain + let crate_version = env!("CARGO_PKG_VERSION"); + let toolchain_version = semver::Version::parse(crate_version)?; + if toolchain_version < *min_forc_version { + bail!( + "{:?} requires forc version {} but current forc version is {}\nUpdate the toolchain by following: https://fuellabs.github.io/sway/v{}/introduction/installation.html", + pkg_manifest.project.name, + min_forc_version, + crate_version, + crate_version + ); } - None => {} }; Ok(()) } diff --git a/sway-lsp/src/utils/markdown.rs b/sway-lsp/src/utils/markdown.rs index fd9056a8deb..0d504f87511 100644 --- a/sway-lsp/src/utils/markdown.rs +++ b/sway-lsp/src/utils/markdown.rs @@ -52,7 +52,7 @@ fn is_sway_fence(s: &str) -> bool { let tokens = s .trim() - .split(|c| matches!(c, ',' | ' ' | '\t')) + .split([',', ' ', '\t']) .filter_map(|t| { let t = t.trim(); (!t.is_empty()).then_some(t) diff --git a/swayfmt/src/comments.rs b/swayfmt/src/comments.rs index aa6b4848aaf..e891ca15666 100644 --- a/swayfmt/src/comments.rs +++ b/swayfmt/src/comments.rs @@ -103,7 +103,7 @@ pub fn write_comments( // If the already formatted code ends with some pattern and doesn't already end with a newline, // we want to add a newline here. - if formatted_code.ends_with(&['{', '}']) && !formatted_code.ends_with('\n') { + if formatted_code.ends_with(['{', '}']) && !formatted_code.ends_with('\n') { writeln!(formatted_code)?; } From 7b2177947e7dcc3c790e7a38850d27b33c248a05 Mon Sep 17 00:00:00 2001 From: Kaya Gokalp Date: Thu, 24 Oct 2024 11:23:04 -0700 Subject: [PATCH 3/4] fix clippy doc lints --- forc-pkg/src/manifest/mod.rs | 2 +- forc/src/cli/commands/build.rs | 6 +++--- sway-core/src/asm_generation/fuel/analyses.rs | 4 ++-- .../src/asm_generation/fuel/programs/abstract.rs | 14 +++++++------- .../src/asm_generation/fuel/register_allocator.rs | 7 ++++--- .../src/language/ty/expression/reassignment.rs | 1 + .../expression/match_expression/typed/mod.rs | 10 +++++----- .../match_expression/typed/typed_match_branch.rs | 10 +++++----- .../ast_node/expression/typed_expression.rs | 1 + sway-lsp/src/utils/markdown.rs | 11 ++++------- 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/forc-pkg/src/manifest/mod.rs b/forc-pkg/src/manifest/mod.rs index 28729aff757..adc4f6a3abd 100644 --- a/forc-pkg/src/manifest/mod.rs +++ b/forc-pkg/src/manifest/mod.rs @@ -771,7 +771,7 @@ impl std::ops::Deref for PackageManifestFile { /// This can be configured using environment variables: /// - use `FORC_IMPLICIT_STD_PATH` for the path for the std-lib; /// - use `FORC_IMPLICIT_STD_GIT`, `FORC_IMPLICIT_STD_GIT_TAG` and/or `FORC_IMPLICIT_STD_GIT_BRANCH` to configure -/// the git repo of the std-lib. +/// the git repo of the std-lib. fn implicit_std_dep() -> Dependency { if let Ok(path) = std::env::var("FORC_IMPLICIT_STD_PATH") { return Dependency::Detailed(DependencyDetails { diff --git a/forc/src/cli/commands/build.rs b/forc/src/cli/commands/build.rs index ae88dfebfdc..f55225f4c60 100644 --- a/forc/src/cli/commands/build.rs +++ b/forc/src/cli/commands/build.rs @@ -17,13 +17,13 @@ forc_util::cli_examples! { /// - `script`, `predicate` and `contract` projects will produce their bytecode in binary format `.bin`. /// /// - `script` projects will also produce a file containing the hash of the bytecode binary -/// `-bin-hash` (using `fuel_cypto::Hasher`). +/// `-bin-hash` (using `fuel_cypto::Hasher`). /// /// - `predicate` projects will also produce a file containing the **root** hash of the bytecode binary -/// `-bin-root` (using `fuel_tx::Contract::root_from_code`). +/// `-bin-root` (using `fuel_tx::Contract::root_from_code`). /// /// - `contract` and `library` projects will also produce the public ABI in JSON format -/// `-abi.json`. +/// `-abi.json`. #[derive(Debug, Default, Parser)] #[clap(bin_name = "forc build", version, after_help = help())] pub struct Command { diff --git a/sway-core/src/asm_generation/fuel/analyses.rs b/sway-core/src/asm_generation/fuel/analyses.rs index cfd4cb931d6..9bdcac0d489 100644 --- a/sway-core/src/asm_generation/fuel/analyses.rs +++ b/sway-core/src/asm_generation/fuel/analyses.rs @@ -17,9 +17,9 @@ use crate::asm_lang::{ControlFlowOp, Label, Op, VirtualRegister}; /// Two tables are generated: `live_in` and `live_out`. Each row in the tables corresponds to an /// instruction in the program. /// * A virtual register is in the `live_out` table for a given instruction if it is live on any -/// of that node's out-edges +/// of that node's out-edges /// * A virtual register is in the `live_in` table for a given instruction if it is live on any -/// of that node's in-edges +/// of that node's in-edges /// /// /// Algorithm: diff --git a/sway-core/src/asm_generation/fuel/programs/abstract.rs b/sway-core/src/asm_generation/fuel/programs/abstract.rs index 17b6240a95d..338b1f03d9c 100644 --- a/sway-core/src/asm_generation/fuel/programs/abstract.rs +++ b/sway-core/src/asm_generation/fuel/programs/abstract.rs @@ -164,13 +164,13 @@ impl AbstractProgram { /// Right now, it looks like this: /// /// WORD OP - /// 1 MOV $scratch $pc - /// - JMPF $zero i2 - /// 2 DATA_START (0-32) (in bytes, offset from $is) - /// - DATA_START (32-64) - /// 3 LW $ds $scratch 1 - /// - ADD $ds $ds $scratch - /// 4 .program_start: + /// [1] MOV $scratch $pc + /// [-] JMPF $zero i2 + /// [2] DATA_START (0-32) (in bytes, offset from $is) + /// [-] DATA_START (32-64) + /// [3] LW $ds $scratch 1 + /// [-] ADD $ds $ds $scratch + /// [4] .program_start: fn build_prologue(&mut self) -> AllocatedAbstractInstructionSet { let label = self.reg_seqr.get_label(); AllocatedAbstractInstructionSet { diff --git a/sway-core/src/asm_generation/fuel/register_allocator.rs b/sway-core/src/asm_generation/fuel/register_allocator.rs index 8e02d2d29fa..b3304563222 100644 --- a/sway-core/src/asm_generation/fuel/register_allocator.rs +++ b/sway-core/src/asm_generation/fuel/register_allocator.rs @@ -121,8 +121,8 @@ impl RegisterPool { /// add edges (v, b_1), ..., (v, b_n) for any b_i different from c. /// 3. for non-MOVE def of virtual register v with live_out virtual registers b_1, ..., b_n: /// add edges (v, b_1), ..., (v, b_n) -/// =============================================================================================== /// +/// =============================================================================================== pub(crate) fn create_interference_graph( ops: &[Op], live_out: &[BTreeSet], @@ -191,8 +191,8 @@ pub(crate) fn create_interference_graph( /// * When two registers are coalesced, a new node with a new virtual register (generated using the /// register sequencer) is created in the interference graph. /// * When a MOVE instruction is removed, the offset of each subsequent instruction has to be -/// updated, as well as the immediate values for some or all jump instructions (`ji`, `jnei`, and -/// `jnzi for now). +/// updated, as well as the immediate values for some or all jump instructions (`ji`, `jnei`, and +/// `jnzi for now). /// pub(crate) fn coalesce_registers( ops: &[Op], @@ -386,6 +386,7 @@ fn compute_def_use_points(ops: &[Op]) -> FxHashMap, /// 3. If some vertex n still has k or more neighbors, then the graph may not be k colorable. /// We still add it to the stack as is, as a potential spill. When popping, if we still /// can't colour it, then it becomes an actual spill. +/// /// =============================================================================================== /// pub(crate) fn color_interference_graph( diff --git a/sway-core/src/language/ty/expression/reassignment.rs b/sway-core/src/language/ty/expression/reassignment.rs index 358855a0102..54a8e740c5c 100644 --- a/sway-core/src/language/ty/expression/reassignment.rs +++ b/sway-core/src/language/ty/expression/reassignment.rs @@ -47,6 +47,7 @@ pub enum TyReassignmentTarget { /// E.g.: /// - *my_ref /// - **if x > 0 { &mut &mut a } else { &mut &mut b } + /// /// The [TyExpression] is guaranteed to be of [TyExpressionVariant::Deref]. Deref(Box), } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/typed/mod.rs b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/typed/mod.rs index c974226d2b7..b547768d094 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/typed/mod.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/typed/mod.rs @@ -20,12 +20,12 @@ //! for a particular match branch (arm): //! - branch condition: Overall condition that must be `true` for the branch to match. //! - result variable declarations: Variable declarations that needs to be added to the -//! match branch result, before the actual body. Here we distinguish between the variables -//! actually declared in the match arm pattern and so called "tuple variables" that are -//! compiler generated and contain values for variables extracted out of individual OR variants. +//! match branch result, before the actual body. Here we distinguish between the variables +//! actually declared in the match arm pattern and so called "tuple variables" that are +//! compiler generated and contain values for variables extracted out of individual OR variants. //! - OR variant index variables: Variable declarations that are generated in case of having -//! variables in OR patterns. Index variables hold 1-based index of the OR variant being matched -//! or zero if non of the OR variants has matched. +//! variables in OR patterns. Index variables hold 1-based index of the OR variant being matched +//! or zero if non of the OR variants has matched. //! //! Afterwards, these three artifacts coming from every individual branch are glued together in the //! [crate::ty::TyMatchExpression] to form the final desugaring. diff --git a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/typed/typed_match_branch.rs b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/typed/typed_match_branch.rs index f8b530e2107..7e110b86e49 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/typed/typed_match_branch.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/typed/typed_match_branch.rs @@ -252,12 +252,12 @@ type CarryOverTupleDeclarations = Vec; /// via [ty::TyMatchBranch]: /// - branch condition: Overall condition that must be `true` for the branch to match. /// - result variable declarations: Variable declarations that needs to be added to the -/// match branch result, before the actual body. Here we distinguish between the variables -/// actually declared in the match arm pattern and so called "tuple variables" that are -/// compiler generated and contain values for variables extracted out of individual OR variants. +/// match branch result, before the actual body. Here we distinguish between the variables +/// actually declared in the match arm pattern and so called "tuple variables" that are +/// compiler generated and contain values for variables extracted out of individual OR variants. /// - OR variant index variables: Variable declarations that are generated in case of having -/// variables in OR patterns. Index variables hold 1-based index of the OR variant being matched -/// or zero if non of the OR variants has matched. +/// variables in OR patterns. Index variables hold 1-based index of the OR variant being matched +/// or zero if non of the OR variants has matched. /// /// ## Algorithm Overview /// The algorithm traverses the `req_decl_tree` bottom up from left to right and collects the diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs index dd4a14f0b74..606aa0e44c0 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs @@ -995,6 +995,7 @@ impl ty::TyExpression { /// Returns the position of the first match arm that is an "interior" arm, meaning: /// - arm is a catch-all arm /// - arm is not the last match arm + /// /// or `None` if such arm does not exist. /// Note that the arm can be the first arm. fn interior_catch_all_arm_position(arms_reachability: &[ReachableReport]) -> Option { diff --git a/sway-lsp/src/utils/markdown.rs b/sway-lsp/src/utils/markdown.rs index 0d504f87511..115f6c9bba3 100644 --- a/sway-lsp/src/utils/markdown.rs +++ b/sway-lsp/src/utils/markdown.rs @@ -50,13 +50,10 @@ fn is_sway_fence(s: &str) -> bool { let mut seen_sway_tags = false; let mut seen_other_tags = false; - let tokens = s - .trim() - .split([',', ' ', '\t']) - .filter_map(|t| { - let t = t.trim(); - (!t.is_empty()).then_some(t) - }); + let tokens = s.trim().split([',', ' ', '\t']).filter_map(|t| { + let t = t.trim(); + (!t.is_empty()).then_some(t) + }); for token in tokens { match token { From c778082bea8bd095005510e52e88ef9ad87ffd25 Mon Sep 17 00:00:00 2001 From: Kaya Gokalp Date: Sun, 27 Oct 2024 12:38:11 -0700 Subject: [PATCH 4/4] clippy: silence clippy mutable key --- .../src/semantic_analysis/ast_node/declaration/impl_trait.rs | 1 + sway-core/src/semantic_analysis/type_check_context.rs | 1 + sway-core/src/type_system/id.rs | 1 + sway-core/src/type_system/unify/occurs_check.rs | 1 + 4 files changed, 4 insertions(+) diff --git a/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs b/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs index 033fe5cff9b..8d88a8989d8 100644 --- a/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs +++ b/sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs @@ -1,3 +1,4 @@ +#![allow(clippy::mutable_key_type)] use std::{ collections::{BTreeMap, HashMap, HashSet}, sync::Arc, diff --git a/sway-core/src/semantic_analysis/type_check_context.rs b/sway-core/src/semantic_analysis/type_check_context.rs index 455cc21fb4b..e8295edd291 100644 --- a/sway-core/src/semantic_analysis/type_check_context.rs +++ b/sway-core/src/semantic_analysis/type_check_context.rs @@ -1,3 +1,4 @@ +#![allow(clippy::mutable_key_type)] use std::collections::{HashMap, VecDeque}; use crate::{ diff --git a/sway-core/src/type_system/id.rs b/sway-core/src/type_system/id.rs index b1eda847745..2f5c0ec0ed8 100644 --- a/sway-core/src/type_system/id.rs +++ b/sway-core/src/type_system/id.rs @@ -1,3 +1,4 @@ +#![allow(clippy::mutable_key_type)] use indexmap::IndexMap; use sway_error::{ error::CompileError, diff --git a/sway-core/src/type_system/unify/occurs_check.rs b/sway-core/src/type_system/unify/occurs_check.rs index 003878f3fb7..af893ad7cfe 100644 --- a/sway-core/src/type_system/unify/occurs_check.rs +++ b/sway-core/src/type_system/unify/occurs_check.rs @@ -1,3 +1,4 @@ +#![allow(clippy::mutable_key_type)] use crate::{engine_threading::Engines, type_system::priv_prelude::*}; /// Helper struct to perform the occurs check.