From 47efcf39a6dfbbbb7f0c48db349b36db4bfa311c Mon Sep 17 00:00:00 2001 From: Ori Ziv Date: Mon, 7 Oct 2024 19:06:12 +0300 Subject: [PATCH] Remove unneeded `allow`s - or make them `expect` instead. commit-id:3f0039b9 --- crates/cairo-lang-casm/src/assembler.rs | 1 - crates/cairo-lang-casm/src/inline.rs | 1 - crates/cairo-lang-lowering/src/diagnostic.rs | 14 +++++--------- crates/cairo-lang-runner/src/lib.rs | 1 - crates/cairo-lang-semantic/src/expr/compute.rs | 2 +- crates/cairo-lang-sierra-ap-change/src/compute.rs | 2 +- .../src/store_variables/known_stack.rs | 1 - crates/cairo-lang-sierra-to-casm/src/lib.rs | 2 -- .../src/casm_contract_class.rs | 2 -- ensure-no_std/src/main.rs | 4 ++-- tests/examples_test.rs | 2 +- 11 files changed, 10 insertions(+), 22 deletions(-) diff --git a/crates/cairo-lang-casm/src/assembler.rs b/crates/cairo-lang-casm/src/assembler.rs index 4e4e5eeef5f..d72fd5f8055 100644 --- a/crates/cairo-lang-casm/src/assembler.rs +++ b/crates/cairo-lang-casm/src/assembler.rs @@ -58,7 +58,6 @@ pub enum Opcode { } /// The low level representation of a cairo instruction. -#[allow(dead_code)] #[derive(Debug, Eq, PartialEq)] pub struct InstructionRepr { pub off0: i16, diff --git a/crates/cairo-lang-casm/src/inline.rs b/crates/cairo-lang-casm/src/inline.rs index 1ee2b6947d5..6fcfb567e42 100644 --- a/crates/cairo-lang-casm/src/inline.rs +++ b/crates/cairo-lang-casm/src/inline.rs @@ -239,7 +239,6 @@ macro_rules! is_inc_ap { }; } -#[allow(dead_code)] #[derive(Default)] pub struct CasmContext { pub current_code_offset: usize, diff --git a/crates/cairo-lang-lowering/src/diagnostic.rs b/crates/cairo-lang-lowering/src/diagnostic.rs index aa91eaf6720..a09b95f1d9d 100644 --- a/crates/cairo-lang-lowering/src/diagnostic.rs +++ b/crates/cairo-lang-lowering/src/diagnostic.rs @@ -96,16 +96,12 @@ impl DiagnosticEntry for LoweringDiagnostic { &self.location.notes } - #[allow(unreachable_patterns, clippy::single_match)] fn location(&self, db: &Self::DbType) -> DiagnosticLocation { - match &self.kind { - LoweringDiagnosticKind::Unreachable { last_statement_ptr } => { - return self - .location - .stable_location - .diagnostic_location_until(db.upcast(), *last_statement_ptr); - } - _ => {} + if let LoweringDiagnosticKind::Unreachable { last_statement_ptr } = &self.kind { + return self + .location + .stable_location + .diagnostic_location_until(db.upcast(), *last_statement_ptr); } self.location.stable_location.diagnostic_location(db.upcast()) } diff --git a/crates/cairo-lang-runner/src/lib.rs b/crates/cairo-lang-runner/src/lib.rs index d60e0429717..34472893f08 100644 --- a/crates/cairo-lang-runner/src/lib.rs +++ b/crates/cairo-lang-runner/src/lib.rs @@ -199,7 +199,6 @@ pub struct SierraCasmRunner { type_sizes: TypeSizeMap, /// The casm program matching the Sierra code. casm_program: CairoProgram, - #[allow(dead_code)] /// Mapping from class_hash to contract info. starknet_contracts_info: OrderedHashMap, /// Whether to run the profiler when running using this runner. diff --git a/crates/cairo-lang-semantic/src/expr/compute.rs b/crates/cairo-lang-semantic/src/expr/compute.rs index f094f55b5c2..264a89a5782 100644 --- a/crates/cairo-lang-semantic/src/expr/compute.rs +++ b/crates/cairo-lang-semantic/src/expr/compute.rs @@ -1899,7 +1899,7 @@ fn compute_expr_indexed_semantic( /// call and Index operator differs in the diagnostics they emit. The function returns the /// function_id to call, the trait containing the function, the self argument, with snapshots added /// if needed, and the mutability of the self argument. -#[allow(clippy::too_many_arguments)] +#[expect(clippy::too_many_arguments)] fn compute_method_function_call_data( ctx: &mut ComputationContext<'_>, candidate_traits: &[TraitId], diff --git a/crates/cairo-lang-sierra-ap-change/src/compute.rs b/crates/cairo-lang-sierra-ap-change/src/compute.rs index ad2c5f0420e..05d6e1de014 100644 --- a/crates/cairo-lang-sierra-ap-change/src/compute.rs +++ b/crates/cairo-lang-sierra-ap-change/src/compute.rs @@ -37,7 +37,7 @@ impl<'a, TokenUsages: Fn(CostTokenType) -> usize> InvocationApChangeInfoProvider #[derive(Clone, Debug)] enum ApTrackingBase { FunctionStart(FunctionId), - #[allow(dead_code)] + #[expect(dead_code)] EnableStatement(StatementIdx), } diff --git a/crates/cairo-lang-sierra-generator/src/store_variables/known_stack.rs b/crates/cairo-lang-sierra-generator/src/store_variables/known_stack.rs index 37de7d43fc7..3317e7a1699 100644 --- a/crates/cairo-lang-sierra-generator/src/store_variables/known_stack.rs +++ b/crates/cairo-lang-sierra-generator/src/store_variables/known_stack.rs @@ -111,7 +111,6 @@ impl KnownStack { /// /// For example, merging the stacks [0, 1, 2, 3, 4] and [1, 9, 3, 4] (where the last element in /// the top) will yield [3, 4] (1 will not be included because of the hole). - #[allow(dead_code)] pub fn merge_with(&self, other: &Self) -> Self { // Choose the new offset to be the maximum of the input offsets. This is somewhat arbitrary. let new_offset = max(self.offset, other.offset); diff --git a/crates/cairo-lang-sierra-to-casm/src/lib.rs b/crates/cairo-lang-sierra-to-casm/src/lib.rs index 2270eb150fd..214cc1db563 100644 --- a/crates/cairo-lang-sierra-to-casm/src/lib.rs +++ b/crates/cairo-lang-sierra-to-casm/src/lib.rs @@ -2,8 +2,6 @@ pub mod annotations; pub mod circuit; -// TODO(ilya): Reduce the size of CompilationError. -#[allow(clippy::result_large_err)] pub mod compiler; pub mod environment; pub mod invocations; diff --git a/crates/cairo-lang-starknet-classes/src/casm_contract_class.rs b/crates/cairo-lang-starknet-classes/src/casm_contract_class.rs index 9abea3cb2a4..12ec13cb552 100644 --- a/crates/cairo-lang-starknet-classes/src/casm_contract_class.rs +++ b/crates/cairo-lang-starknet-classes/src/casm_contract_class.rs @@ -336,8 +336,6 @@ impl CasmContractClass { .0) } - // TODO(ilya): Reduce the size of CompilationError. - #[allow(clippy::result_large_err)] pub fn from_contract_class_with_debug_info( contract_class: ContractClass, add_pythonic_hints: bool, diff --git a/ensure-no_std/src/main.rs b/ensure-no_std/src/main.rs index 7e6a6348f3a..ef30bf084f7 100644 --- a/ensure-no_std/src/main.rs +++ b/ensure-no_std/src/main.rs @@ -18,7 +18,7 @@ pub extern "C" fn _start() -> ! { // NOTE: this should be initialized before use static ALLOC: esp_alloc::EspHeap = esp_alloc::EspHeap::empty(); -#[allow(unused_imports)] +#[expect(unused_imports)] use cairo_lang_casm; -#[allow(unused_imports)] +#[expect(unused_imports)] use cairo_lang_utils; diff --git a/tests/examples_test.rs b/tests/examples_test.rs index dce0dc78610..6a72d8d87ec 100644 --- a/tests/examples_test.rs +++ b/tests/examples_test.rs @@ -40,7 +40,7 @@ fn example_dir_data() -> ExampleDirData { } #[rstest] -#[allow(unused_variables)] +#[expect(unused_variables)] fn lowering_test(example_dir_data: &ExampleDirData) {} /// Returns the path of the relevant test file.