Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(clarity): Remove unused imports and enable warning #5660

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clarity/src/libclarity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![cfg_attr(test, allow(unused_variables, unused_assignments))]

#[allow(unused_imports)]
#[macro_use(o, slog_log, slog_trace, slog_debug, slog_info, slog_warn, slog_error)]
extern crate slog;

#[macro_use]
extern crate serde_derive;

#[macro_use]
extern crate serde_json;

#[cfg(any(test, feature = "testing"))]
Expand Down
4 changes: 2 additions & 2 deletions clarity/src/vm/analysis/analysis_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use std::collections::{BTreeMap, BTreeSet};

use stacks_common::types::StacksEpochId;

use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult};
use crate::vm::analysis::errors::{CheckErrors, CheckResult};
use crate::vm::analysis::type_checker::ContractAnalysis;
use crate::vm::database::{
ClarityBackingStore, ClarityDeserializable, ClaritySerializable, RollbackWrapper,
};
use crate::vm::representations::ClarityName;
use crate::vm::types::signatures::FunctionSignature;
use crate::vm::types::{FunctionType, QualifiedContractIdentifier, TraitIdentifier, TypeSignature};
use crate::vm::types::{FunctionType, QualifiedContractIdentifier, TraitIdentifier};
use crate::vm::ClarityVersion;

pub struct AnalysisDatabase<'a> {
Expand Down
12 changes: 3 additions & 9 deletions clarity/src/vm/analysis/arithmetic_checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use hashbrown::HashMap;

pub use super::errors::{
check_argument_count, check_arguments_at_least, CheckError, CheckErrors, CheckResult,
};
use super::AnalysisDatabase;
use crate::vm::analysis::types::{AnalysisPass, ContractAnalysis};
use crate::vm::analysis::types::ContractAnalysis;
use crate::vm::functions::define::{DefineFunctions, DefineFunctionsParsed};
use crate::vm::functions::{tuples, NativeFunctions};
use crate::vm::functions::NativeFunctions;
use crate::vm::representations::SymbolicExpressionType::{
Atom, AtomValue, Field, List, LiteralValue, TraitReference,
};
use crate::vm::representations::{ClarityName, SymbolicExpression, SymbolicExpressionType};
use crate::vm::types::{
parse_name_type_pairs, PrincipalData, TupleTypeSignature, TypeSignature, Value,
};
use crate::vm::representations::{ClarityName, SymbolicExpression};
use crate::vm::variables::NativeVariables;
use crate::vm::ClarityVersion;

Expand Down
7 changes: 2 additions & 5 deletions clarity/src/vm/analysis/read_only_checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ pub use super::errors::{
use super::AnalysisDatabase;
use crate::vm::analysis::types::{AnalysisPass, ContractAnalysis};
use crate::vm::functions::define::DefineFunctionsParsed;
use crate::vm::functions::{tuples, NativeFunctions};
use crate::vm::functions::NativeFunctions;
use crate::vm::representations::SymbolicExpressionType::{
Atom, AtomValue, Field, List, LiteralValue, TraitReference,
};
use crate::vm::representations::{ClarityName, SymbolicExpression, SymbolicExpressionType};
use crate::vm::types::{
parse_name_type_pairs, PrincipalData, TupleTypeSignature, TypeSignature, Value,
};
use crate::vm::variables::NativeVariables;
use crate::vm::types::{PrincipalData, Value};
use crate::vm::ClarityVersion;

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion clarity/src/vm/analysis/read_only_checker/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rstest_reuse::{self, *};
use stacks_common::types::StacksEpochId;

use crate::vm::analysis::type_checker::v2_1::tests::mem_type_check;
use crate::vm::analysis::{type_check, CheckError, CheckErrors};
use crate::vm::analysis::{type_check, CheckErrors};
use crate::vm::ast::parse;
use crate::vm::database::MemoryBackingStore;
use crate::vm::tests::test_clarity_versions;
Expand Down
6 changes: 1 addition & 5 deletions clarity/src/vm/analysis/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@

use stacks_common::types::StacksEpochId;

use crate::vm::analysis::errors::CheckErrors;
use crate::vm::analysis::mem_type_check as mem_run_analysis;
use crate::vm::analysis::type_checker::v2_1::tests::mem_type_check;
use crate::vm::analysis::{
mem_type_check as mem_run_analysis, type_check, AnalysisDatabase, ContractAnalysis,
};
use crate::vm::ast::parse;
use crate::vm::ClarityVersion;

#[test]
Expand Down
8 changes: 1 addition & 7 deletions clarity/src/vm/analysis/trait_checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use hashbrown::HashMap;
use stacks_common::types::StacksEpochId;

use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult};
use crate::vm::analysis::errors::{CheckErrors, CheckResult};
use crate::vm::analysis::types::{AnalysisPass, ContractAnalysis};
use crate::vm::analysis::AnalysisDatabase;
use crate::vm::functions::define::{DefineFunctions, DefineFunctionsParsed};
use crate::vm::functions::NativeFunctions;
use crate::vm::representations::SymbolicExpressionType::{Atom, AtomValue, List, LiteralValue};
use crate::vm::representations::{ClarityName, SymbolicExpression};
use crate::vm::types::{FunctionType, TraitIdentifier, TypeSignature, Value};

pub struct TraitChecker {
epoch: StacksEpochId,
Expand Down
3 changes: 1 addition & 2 deletions clarity/src/vm/analysis/trait_checker/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ use rstest::rstest;
use rstest_reuse::{self, *};
use stacks_common::types::StacksEpochId;

use crate::vm::analysis::contract_interface_builder::build_contract_interface;
use crate::vm::analysis::errors::CheckErrors;
use crate::vm::analysis::{type_check, AnalysisDatabase, CheckError};
use crate::vm::analysis::{type_check, CheckError};
use crate::vm::ast::errors::ParseErrors;
use crate::vm::ast::{build_ast, parse};
use crate::vm::database::MemoryBackingStore;
Expand Down
14 changes: 3 additions & 11 deletions clarity/src/vm/analysis/type_checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,11 @@ pub mod v2_1;

use stacks_common::types::StacksEpochId;

use super::errors::{
check_argument_count, check_arguments_at_least, check_arguments_at_most, CheckError,
CheckErrors, CheckResult,
};
use super::errors::{CheckErrors, CheckResult};
pub use super::types::{AnalysisPass, ContractAnalysis};
use super::AnalysisDatabase;
use crate::vm::costs::{analysis_typecheck_cost, CostTracker, LimitedCostTracker};
use crate::vm::types::signatures::{
CallableSubtype, FunctionArgSignature, FunctionReturnsSignature,
};
use crate::vm::types::{
FixedFunction, FunctionType, PrincipalData, SequenceSubtype, StringSubtype, TypeSignature,
};
use crate::vm::costs::CostTracker;
use crate::vm::types::{FunctionType, TypeSignature};
use crate::vm::{ClarityVersion, Value};

impl FunctionType {
Expand Down
3 changes: 1 addition & 2 deletions clarity/src/vm/analysis/type_checker/v2_05/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ use hashbrown::{HashMap, HashSet};

use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult};
use crate::vm::analysis::types::ContractAnalysis;
use crate::vm::contexts::MAX_CONTEXT_DEPTH;
use crate::vm::representations::{ClarityName, SymbolicExpression};
use crate::vm::representations::ClarityName;
use crate::vm::types::signatures::FunctionSignature;
use crate::vm::types::{FunctionType, TraitIdentifier, TypeSignature};

Expand Down
13 changes: 5 additions & 8 deletions clarity/src/vm/analysis/type_checker/v2_05/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,31 @@ pub mod natives;

use std::collections::BTreeMap;

use hashbrown::HashMap;
use stacks_common::types::StacksEpochId;

use self::contexts::ContractContext;
pub use self::natives::{SimpleNativeFunction, TypedNativeFunction};
use super::contexts::{TypeMap, TypingContext};
use super::{AnalysisPass, ContractAnalysis};
use super::ContractAnalysis;
pub use crate::vm::analysis::errors::{
check_argument_count, check_arguments_at_least, CheckError, CheckErrors, CheckResult,
};
use crate::vm::analysis::AnalysisDatabase;
use crate::vm::contexts::Environment;
use crate::vm::costs::cost_functions::ClarityCostFunction;
use crate::vm::costs::{
analysis_typecheck_cost, cost_functions, runtime_cost, ClarityCostFunctionReference,
CostErrors, CostOverflowingMath, CostTracker, ExecutionCost, LimitedCostTracker,
analysis_typecheck_cost, runtime_cost, CostErrors, CostOverflowingMath, CostTracker,
ExecutionCost, LimitedCostTracker,
};
use crate::vm::errors::InterpreterError;
use crate::vm::functions::define::DefineFunctionsParsed;
use crate::vm::functions::NativeFunctions;
use crate::vm::representations::SymbolicExpressionType::{
Atom, AtomValue, Field, List, LiteralValue, TraitReference,
};
use crate::vm::representations::{depth_traverse, ClarityName, SymbolicExpression};
use crate::vm::types::signatures::{FunctionSignature, BUFF_20};
use crate::vm::types::signatures::FunctionSignature;
use crate::vm::types::{
parse_name_type_pairs, FixedFunction, FunctionArg, FunctionType, PrincipalData,
QualifiedContractIdentifier, TupleTypeSignature, TypeSignature, Value,
QualifiedContractIdentifier, TypeSignature, Value,
};
use crate::vm::variables::NativeVariables;
use crate::vm::ClarityVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

use super::{no_type, FunctionType, TypeChecker, TypeResult, TypingContext};
use crate::vm::analysis::errors::{check_argument_count, CheckError, CheckErrors, CheckResult};
use super::{TypeChecker, TypeResult, TypingContext};
use crate::vm::analysis::errors::{check_argument_count, CheckErrors};
use crate::vm::costs::cost_functions::ClarityCostFunction;
use crate::vm::costs::{cost_functions, runtime_cost};
use crate::vm::costs::runtime_cost;
use crate::vm::representations::SymbolicExpression;
use crate::vm::types::{BlockInfoProperty, TupleTypeSignature, TypeSignature, MAX_VALUE_SIZE};
use crate::vm::types::TypeSignature;

pub fn check_special_get_owner(
checker: &mut TypeChecker,
Expand Down
11 changes: 4 additions & 7 deletions clarity/src/vm/analysis/type_checker/v2_05/natives/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@

use stacks_common::types::StacksEpochId;

use super::check_special_tuple_cons;
use crate::vm::analysis::type_checker::v2_05::{
check_arguments_at_least, no_type, CheckError, CheckErrors, TypeChecker, TypeResult,
TypingContext,
check_arguments_at_least, CheckError, CheckErrors, TypeChecker, TypeResult, TypingContext,
};
use crate::vm::costs::cost_functions::ClarityCostFunction;
use crate::vm::costs::{analysis_typecheck_cost, cost_functions, runtime_cost};
use crate::vm::functions::tuples;
use crate::vm::representations::{SymbolicExpression, SymbolicExpressionType};
use crate::vm::types::{PrincipalData, TypeSignature, Value};
use crate::vm::costs::{analysis_typecheck_cost, runtime_cost};
use crate::vm::representations::SymbolicExpression;
use crate::vm::types::TypeSignature;

pub fn check_special_fetch_entry(
checker: &mut TypeChecker,
Expand Down
8 changes: 2 additions & 6 deletions clarity/src/vm/analysis/type_checker/v2_05/natives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ use stacks_common::types::StacksEpochId;
use super::{
check_argument_count, check_arguments_at_least, no_type, TypeChecker, TypeResult, TypingContext,
};
use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult};
use crate::vm::analysis::errors::{CheckError, CheckErrors};
use crate::vm::costs::cost_functions::ClarityCostFunction;
use crate::vm::costs::{
analysis_typecheck_cost, cost_functions, runtime_cost, CostOverflowingMath,
};
use crate::vm::errors::{Error as InterpError, InterpreterError, RuntimeErrorType};
use crate::vm::costs::{analysis_typecheck_cost, runtime_cost};
use crate::vm::functions::{handle_binding_list, NativeFunctions};
use crate::vm::types::{
BlockInfoProperty, FixedFunction, FunctionArg, FunctionSignature, FunctionType, PrincipalData,
TupleTypeSignature, TypeSignature, Value, BUFF_20, BUFF_32, BUFF_33, BUFF_64, BUFF_65,
MAX_VALUE_SIZE,
};
use crate::vm::{ClarityName, ClarityVersion, SymbolicExpression, SymbolicExpressionType};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
use stacks_common::types::StacksEpochId;

use crate::vm::analysis::type_checker::v2_05::{
check_argument_count, check_arguments_at_least, no_type, CheckError, CheckErrors, TypeChecker,
TypeResult, TypingContext,
check_argument_count, check_arguments_at_least, no_type, CheckErrors, TypeChecker, TypeResult,
TypingContext,
};
use crate::vm::costs::cost_functions::ClarityCostFunction;
use crate::vm::costs::{analysis_typecheck_cost, cost_functions, runtime_cost};
use crate::vm::costs::{analysis_typecheck_cost, runtime_cost};
use crate::vm::representations::{ClarityName, SymbolicExpression};
use crate::vm::types::TypeSignature;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ use stacks_common::types::StacksEpochId;

use super::{SimpleNativeFunction, TypedNativeFunction};
use crate::vm::analysis::type_checker::v2_05::{
check_argument_count, check_arguments_at_least, no_type, CheckErrors, CheckResult, TypeChecker,
check_argument_count, check_arguments_at_least, CheckErrors, CheckResult, TypeChecker,
TypeResult, TypingContext,
};
use crate::vm::costs::cost_functions::ClarityCostFunction;
use crate::vm::costs::{analysis_typecheck_cost, cost_functions, runtime_cost};
use crate::vm::costs::{analysis_typecheck_cost, runtime_cost};
use crate::vm::functions::NativeFunctions;
use crate::vm::representations::{SymbolicExpression, SymbolicExpressionType};
pub use crate::vm::types::signatures::{BufferLength, ListTypeData, StringUTF8Length, BUFF_1};
use crate::vm::types::SequenceSubtype::*;
use crate::vm::types::StringSubtype::*;
use crate::vm::types::{FunctionType, TypeSignature, Value, MAX_VALUE_SIZE};
use crate::vm::types::{FunctionType, TypeSignature, Value};
use crate::vm::ClarityVersion;

fn get_simple_native_or_user_define(
Expand Down
3 changes: 0 additions & 3 deletions clarity/src/vm/analysis/type_checker/v2_05/tests/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use stacks_common::types::StacksEpochId;

use crate::vm::analysis::errors::CheckErrors;
use crate::vm::analysis::AnalysisDatabase;
use crate::vm::ast::parse;
use crate::vm::database::MemoryBackingStore;
use crate::vm::tooling::mem_type_check;
Expand Down Expand Up @@ -151,8 +150,6 @@ fn test_names_tokens_contracts() {

#[test]
fn test_bad_asset_usage() {
use crate::vm::analysis::type_check;

let bad_scripts = [
"(ft-get-balance stackoos tx-sender)",
"(ft-get-balance u1234 tx-sender)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ use {assert_json_diff, serde_json};

use crate::vm::analysis::contract_interface_builder::build_contract_interface;
use crate::vm::analysis::errors::CheckErrors;
use crate::vm::analysis::{
mem_type_check, type_check, AnalysisDatabase, CheckError, ContractAnalysis,
};
use crate::vm::analysis::{mem_type_check, type_check};
use crate::vm::ast::parse;
use crate::vm::costs::LimitedCostTracker;
use crate::vm::database::MemoryBackingStore;
use crate::vm::types::QualifiedContractIdentifier;
use crate::vm::{ClarityVersion, SymbolicExpression};
use crate::vm::ClarityVersion;

const SIMPLE_TOKENS: &str = "(define-map tokens { account: principal } { balance: uint })
(define-read-only (my-get-token-balance (account principal))
Expand Down Expand Up @@ -603,7 +600,6 @@ fn test_same_function_name() {

#[test]
fn test_expects() {
use crate::vm::analysis::type_check;
let okay = "(define-map tokens { id: int } { balance: int })
(define-private (my-get-token-balance)
(let ((balance (unwrap!
Expand Down
17 changes: 5 additions & 12 deletions clarity/src/vm/analysis/type_checker/v2_05/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@
use stacks_common::types::StacksEpochId;

use crate::vm::analysis::errors::CheckErrors;
use crate::vm::analysis::type_checker::v2_05::{TypeChecker, TypeResult, TypingContext};
use crate::vm::analysis::types::ContractAnalysis;
use crate::vm::analysis::{mem_type_check, type_check, AnalysisDatabase};
use crate::vm::analysis::mem_type_check;
use crate::vm::analysis::type_checker::v2_05::TypeResult;
use crate::vm::ast::build_ast;
use crate::vm::ast::errors::ParseErrors;
use crate::vm::ast::{build_ast, parse};
use crate::vm::contexts::OwnedEnvironment;
use crate::vm::database::MemoryBackingStore;
use crate::vm::representations::SymbolicExpression;
use crate::vm::types::SequenceSubtype::*;
use crate::vm::types::StringSubtype::*;
use crate::vm::types::TypeSignature::{BoolType, IntType, PrincipalType, SequenceType, UIntType};
use crate::vm::types::TypeSignature::{BoolType, IntType, PrincipalType, UIntType};
use crate::vm::types::{
FixedFunction, FunctionType, PrincipalData, QualifiedContractIdentifier, TypeSignature, Value,
BUFF_32, BUFF_64,
FixedFunction, FunctionType, QualifiedContractIdentifier, TypeSignature, BUFF_32, BUFF_64,
};
use crate::vm::ClarityVersion;

Expand Down Expand Up @@ -1437,8 +1432,6 @@ fn test_response_inference() {

#[test]
fn test_function_arg_names() {
use crate::vm::analysis::type_check;

let functions = [
"(define-private (test (x int)) (ok 0))
(define-public (test-pub (x int)) (ok 0))
Expand Down
5 changes: 2 additions & 3 deletions clarity/src/vm/analysis/type_checker/v2_1/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ use hashbrown::{HashMap, HashSet};
use crate::vm::analysis::errors::{CheckError, CheckErrors, CheckResult};
use crate::vm::analysis::type_checker::is_reserved_word;
use crate::vm::analysis::types::ContractAnalysis;
use crate::vm::contexts::MAX_CONTEXT_DEPTH;
use crate::vm::representations::{ClarityName, SymbolicExpression};
use crate::vm::types::signatures::{CallableSubtype, FunctionSignature};
use crate::vm::representations::ClarityName;
use crate::vm::types::signatures::FunctionSignature;
use crate::vm::types::{FunctionType, QualifiedContractIdentifier, TraitIdentifier, TypeSignature};
use crate::vm::ClarityVersion;

Expand Down
Loading
Loading