Skip to content

Commit

Permalink
Fix clippy issues (#6179)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfiedotwtf committed Sep 12, 2024
1 parent 04e6bc5 commit 4ce8d65
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion forc-pkg/src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions forc-plugins/forc-client/tests/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ async fn test_simple_deploy() {
node.kill().unwrap();
let expected = vec![DeployedContract {
id: ContractId::from_str(
"50fe882cbef5f3da6da82509a66b7e5e0a64a40d70164861c01c908a332198ae",
"47fd96252869c61cc26e8274a7991c8d97bf522d4742036ce09699af59524cbb",
)
.unwrap(),
proxy: None,
Expand Down Expand Up @@ -383,7 +383,7 @@ async fn test_deploy_submit_only() {
node.kill().unwrap();
let expected = vec![DeployedContract {
id: ContractId::from_str(
"50fe882cbef5f3da6da82509a66b7e5e0a64a40d70164861c01c908a332198ae",
"47fd96252869c61cc26e8274a7991c8d97bf522d4742036ce09699af59524cbb",
)
.unwrap(),
proxy: None,
Expand Down
6 changes: 3 additions & 3 deletions forc/src/cli/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ forc_util::cli_examples! {
/// - `script`, `predicate` and `contract` projects will produce their bytecode in binary format `<project-name>.bin`.
///
/// - `script` projects will also produce a file containing the hash of the bytecode binary
/// `<project-name>-bin-hash` (using `fuel_cypto::Hasher`).
/// `<project-name>-bin-hash` (using `fuel_cypto::Hasher`).
///
/// - `predicate` projects will also produce a file containing the **root** hash of the bytecode binary
/// `<project-name>-bin-root` (using `fuel_tx::Contract::root_from_code`).
/// `<project-name>-bin-root` (using `fuel_tx::Contract::root_from_code`).
///
/// - `contract` and `library` projects will also produce the public ABI in JSON format
/// `<project-name>-abi.json`.
/// `<project-name>-abi.json`.
#[derive(Debug, Default, Parser)]
#[clap(bin_name = "forc build", version, after_help = help())]
pub struct Command {
Expand Down
4 changes: 2 additions & 2 deletions sway-core/src/asm_generation/fuel/analyses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 6 additions & 8 deletions sway-core/src/asm_generation/fuel/programs/abstract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,12 @@ impl AbstractProgram {
/// Builds the asm preamble, which includes metadata and a jump past the metadata.
/// 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:
/// | WORD | OP |
/// |------|-------------------------------------------------------------------------|
/// | 1 | MOV $scratch $pc <br /> JMPF $zero i2 |
/// | 2 | DATA_START (0-32) (in bytes, offset from $is) <br /> DATA_START (32-64) |
/// | 3 | LW $ds $scratch 1 <br /> ADD $ds $ds $scratch |
/// | 4 | .program_start: |
fn build_prologue(&mut self) -> AllocatedAbstractInstructionSet {
let label = self.reg_seqr.get_label();
AllocatedAbstractInstructionSet {
Expand Down
6 changes: 4 additions & 2 deletions sway-core/src/asm_generation/fuel/register_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ impl RegisterPool {
}
}

#[allow(clippy::doc_lazy_continuation)]
/// Given a list of instructions `ops` and a `live_out` table computed using the method
/// `liveness_analysis()`, create an interference graph (aka a "conflict" graph):
/// * Nodes = virtual registers
Expand Down Expand Up @@ -191,8 +192,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],
Expand Down Expand Up @@ -373,6 +374,7 @@ fn compute_def_use_points(ops: &[Op]) -> FxHashMap<VirtualRegister, (Vec<usize>,
res
}

#[allow(clippy::doc_lazy_continuation)]
/// Given an interference graph and a integer k, figure out if the graph k-colorable. Graph
/// coloring is an NP-complete problem, but the algorithm below is a simple stack based
/// approximation that relies on the fact that any node n in the graph that has fewer than k
Expand Down
1 change: 1 addition & 0 deletions sway-core/src/language/ty/expression/reassignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TyExpression>),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ fn check_for_unconstrained_type_parameters(
) -> Result<(), ErrorEmitted> {
// Create a list of defined generics, with the generic and a span.
// Purposefully exclude the "self" type parameters.
#[allow(clippy::mutable_key_type)]
let mut defined_generics: HashMap<_, _> = HashMap::from_iter(
type_parameters
.iter()
Expand All @@ -1484,6 +1485,7 @@ fn check_for_unconstrained_type_parameters(
);

// create a list of the generics in use in the impl signature
#[allow(clippy::mutable_key_type)]
let mut generics_in_use = HashSet::new();
for type_arg in trait_type_arguments.iter() {
generics_in_use.extend(type_arg.type_id.extract_nested_generics(engines));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ type CarryOverTupleDeclarations = Vec<VarDecl>;
/// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,8 @@ 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.
/// - 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<usize> {
arms_reachability
Expand Down
1 change: 1 addition & 0 deletions sway-core/src/semantic_analysis/type_check_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@ impl<'a> TypeCheckContext<'a> {
}

if !maybe_method_decl_refs.is_empty() {
#[allow(clippy::mutable_key_type)]
let mut trait_methods =
HashMap::<(CallPath, Vec<WithEngines<TypeArgument>>), DeclRefFunction>::new();
let mut impl_self_method = None;
Expand Down
1 change: 1 addition & 0 deletions sway-core/src/type_system/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ impl TypeId {
inner_types
}

#[allow(clippy::mutable_key_type)]
pub(crate) fn extract_nested_generics(
self,
engines: &Engines,
Expand Down
1 change: 1 addition & 0 deletions sway-core/src/type_system/unify/occurs_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ impl<'a> OccursCheck<'a> {
/// case the occurs check would return `false`, as this is a valid
/// unification.
pub(super) fn check(&self, generic: TypeId, other: TypeId) -> bool {
#[allow(clippy::mutable_key_type)]
let other_generics = other.extract_nested_generics(self.engines);
other_generics.contains(
&self
Expand Down
11 changes: 4 additions & 7 deletions sway-lsp/src/utils/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|c| matches!(c, ',' | ' ' | '\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 {
Expand Down

0 comments on commit 4ce8d65

Please sign in to comment.