Skip to content

Fix/6098 #6102

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

Closed
wants to merge 14 commits into from
Closed

Fix/6098 #6102

wants to merge 14 commits into from

Conversation

wileyj
Copy link
Collaborator

@wileyj wileyj commented May 9, 2025

Adds #[allow(unused_imports)] to unused import warnings during cargo check.

This PR is to check something unrelated, so it may be closed if this "fix" is deemed insufficient to resolve #6098

@wileyj wileyj requested review from a team as code owners May 9, 2025 20:15
@wileyj wileyj linked an issue May 9, 2025 that may be closed by this pull request
@kantai
Copy link
Contributor

kantai commented May 12, 2025

I think it'd be better to do something more targeted to the feature activation, like the following patchset:

diff --git a/clarity/src/vm/analysis/mod.rs b/clarity/src/vm/analysis/mod.rs
index 11e42ad9ae..2be1dcdf50 100644
--- a/clarity/src/vm/analysis/mod.rs
+++ b/clarity/src/vm/analysis/mod.rs
@@ -34,13 +34,16 @@ use self::trait_checker::TraitChecker;
 use self::type_checker::v2_05::TypeChecker as TypeChecker2_05;
 use self::type_checker::v2_1::TypeChecker as TypeChecker2_1;
 pub use self::types::{AnalysisPass, ContractAnalysis};
+#[cfg(feature = "rusqlite")]
 use crate::vm::ast::{build_ast_with_rules, ASTRules};
 use crate::vm::costs::LimitedCostTracker;
 #[cfg(feature = "rusqlite")]
 use crate::vm::database::MemoryBackingStore;
 use crate::vm::database::STORE_CONTRACT_SRC_INTERFACE;
 use crate::vm::representations::SymbolicExpression;
-use crate::vm::types::{QualifiedContractIdentifier, TypeSignature};
+#[cfg(feature = "rusqlite")]
+use crate::vm::types::TypeSignature;
+use crate::vm::types::QualifiedContractIdentifier;
 use crate::vm::ClarityVersion;
 
 /// Used by CLI tools like the docs generator. Not used in production
diff --git a/clarity/src/vm/docs/contracts.rs b/clarity/src/vm/docs/contracts.rs
index 1acdda78d8..48684c0ca0 100644
--- a/clarity/src/vm/docs/contracts.rs
+++ b/clarity/src/vm/docs/contracts.rs
@@ -4,13 +4,11 @@ use hashbrown::{HashMap, HashSet};
 use stacks_common::consts::CHAIN_ID_TESTNET;
 use stacks_common::types::StacksEpochId;
 
-#[cfg(feature = "rusqlite")]
 use crate::vm::analysis::mem_type_check;
 use crate::vm::analysis::ContractAnalysis;
 use crate::vm::ast::{build_ast_with_rules, ASTRules};
 use crate::vm::contexts::GlobalContext;
 use crate::vm::costs::LimitedCostTracker;
-#[cfg(feature = "rusqlite")]
 use crate::vm::database::MemoryBackingStore;
 use crate::vm::docs::{get_input_type_string, get_output_type_string, get_signature};
 use crate::vm::types::{FunctionType, QualifiedContractIdentifier, Value};
@@ -63,7 +61,6 @@ fn make_func_ref(func_name: &str, func_type: &FunctionType, description: &str) -
     }
 }
 
-#[cfg(feature = "rusqlite")]
 #[allow(clippy::expect_used)]
 fn get_constant_value(var_name: &str, contract_content: &str) -> Value {
     let to_eval = format!("{}\n{}", contract_content, var_name);
@@ -72,7 +69,6 @@ fn get_constant_value(var_name: &str, contract_content: &str) -> Value {
         .expect("BUG: failed to return constant value")
 }
 
-#[cfg(feature = "rusqlite")]
 fn doc_execute(program: &str) -> Result<Option<Value>, vm::Error> {
     let contract_id = QualifiedContractIdentifier::transient();
     let mut contract_context = ContractContext::new(contract_id.clone(), ClarityVersion::Clarity2);
@@ -99,7 +95,6 @@ fn doc_execute(program: &str) -> Result<Option<Value>, vm::Error> {
     })
 }
 
-#[cfg(feature = "rusqlite")]
 #[allow(clippy::expect_used)]
 pub fn make_docs(
     content: &str,
@@ -185,7 +180,6 @@ pub fn make_docs(
 
 /// Produce a set of documents for multiple contracts, supplied as a list of `(contract_name, contract_content)` pairs,
 ///  and a map from `contract_name` to corresponding `ContractSupportDocs`
-#[cfg(feature = "rusqlite")]
 pub fn produce_docs_refs<A: AsRef<str>, B: AsRef<str>>(
     contracts: &[(A, B)],
     support_docs: &HashMap<&str, ContractSupportDocs>,
diff --git a/clarity/src/vm/docs/mod.rs b/clarity/src/vm/docs/mod.rs
index d47057b29c..54e1247f9b 100644
--- a/clarity/src/vm/docs/mod.rs
+++ b/clarity/src/vm/docs/mod.rs
@@ -23,6 +23,7 @@ use crate::vm::types::{FixedFunction, FunctionType};
 use crate::vm::variables::NativeVariables;
 use crate::vm::ClarityVersion;
 
+#[cfg(feature = "rusqlite")]
 pub mod contracts;
 
 #[derive(Serialize)]

@wileyj
Copy link
Collaborator Author

wileyj commented May 12, 2025

I think it'd be better to do something more targeted to the feature activation, like the following patchset:

diff --git a/clarity/src/vm/analysis/mod.rs b/clarity/src/vm/analysis/mod.rs
index 11e42ad9ae..2be1dcdf50 100644
--- a/clarity/src/vm/analysis/mod.rs
+++ b/clarity/src/vm/analysis/mod.rs
@@ -34,13 +34,16 @@ use self::trait_checker::TraitChecker;
 use self::type_checker::v2_05::TypeChecker as TypeChecker2_05;
 use self::type_checker::v2_1::TypeChecker as TypeChecker2_1;
 pub use self::types::{AnalysisPass, ContractAnalysis};
+#[cfg(feature = "rusqlite")]
 use crate::vm::ast::{build_ast_with_rules, ASTRules};
 use crate::vm::costs::LimitedCostTracker;
 #[cfg(feature = "rusqlite")]
 use crate::vm::database::MemoryBackingStore;
 use crate::vm::database::STORE_CONTRACT_SRC_INTERFACE;
 use crate::vm::representations::SymbolicExpression;
-use crate::vm::types::{QualifiedContractIdentifier, TypeSignature};
+#[cfg(feature = "rusqlite")]
+use crate::vm::types::TypeSignature;
+use crate::vm::types::QualifiedContractIdentifier;
 use crate::vm::ClarityVersion;
 
 /// Used by CLI tools like the docs generator. Not used in production
diff --git a/clarity/src/vm/docs/contracts.rs b/clarity/src/vm/docs/contracts.rs
index 1acdda78d8..48684c0ca0 100644
--- a/clarity/src/vm/docs/contracts.rs
+++ b/clarity/src/vm/docs/contracts.rs
@@ -4,13 +4,11 @@ use hashbrown::{HashMap, HashSet};
 use stacks_common::consts::CHAIN_ID_TESTNET;
 use stacks_common::types::StacksEpochId;
 
-#[cfg(feature = "rusqlite")]
 use crate::vm::analysis::mem_type_check;
 use crate::vm::analysis::ContractAnalysis;
 use crate::vm::ast::{build_ast_with_rules, ASTRules};
 use crate::vm::contexts::GlobalContext;
 use crate::vm::costs::LimitedCostTracker;
-#[cfg(feature = "rusqlite")]
 use crate::vm::database::MemoryBackingStore;
 use crate::vm::docs::{get_input_type_string, get_output_type_string, get_signature};
 use crate::vm::types::{FunctionType, QualifiedContractIdentifier, Value};
@@ -63,7 +61,6 @@ fn make_func_ref(func_name: &str, func_type: &FunctionType, description: &str) -
     }
 }
 
-#[cfg(feature = "rusqlite")]
 #[allow(clippy::expect_used)]
 fn get_constant_value(var_name: &str, contract_content: &str) -> Value {
     let to_eval = format!("{}\n{}", contract_content, var_name);
@@ -72,7 +69,6 @@ fn get_constant_value(var_name: &str, contract_content: &str) -> Value {
         .expect("BUG: failed to return constant value")
 }
 
-#[cfg(feature = "rusqlite")]
 fn doc_execute(program: &str) -> Result<Option<Value>, vm::Error> {
     let contract_id = QualifiedContractIdentifier::transient();
     let mut contract_context = ContractContext::new(contract_id.clone(), ClarityVersion::Clarity2);
@@ -99,7 +95,6 @@ fn doc_execute(program: &str) -> Result<Option<Value>, vm::Error> {
     })
 }
 
-#[cfg(feature = "rusqlite")]
 #[allow(clippy::expect_used)]
 pub fn make_docs(
     content: &str,
@@ -185,7 +180,6 @@ pub fn make_docs(
 
 /// Produce a set of documents for multiple contracts, supplied as a list of `(contract_name, contract_content)` pairs,
 ///  and a map from `contract_name` to corresponding `ContractSupportDocs`
-#[cfg(feature = "rusqlite")]
 pub fn produce_docs_refs<A: AsRef<str>, B: AsRef<str>>(
     contracts: &[(A, B)],
     support_docs: &HashMap<&str, ContractSupportDocs>,
diff --git a/clarity/src/vm/docs/mod.rs b/clarity/src/vm/docs/mod.rs
index d47057b29c..54e1247f9b 100644
--- a/clarity/src/vm/docs/mod.rs
+++ b/clarity/src/vm/docs/mod.rs
@@ -23,6 +23,7 @@ use crate::vm::types::{FixedFunction, FunctionType};
 use crate::vm::variables::NativeVariables;
 use crate::vm::ClarityVersion;
 
+#[cfg(feature = "rusqlite")]
 pub mod contracts;
 
 #[derive(Serialize)]

this was definitely a solution i was looking into (the [allow(unused_imports)] didn't sit right with me either).
i can take a shot at this today

@wileyj wileyj closed this May 12, 2025
@wileyj wileyj deleted the fix/6098 branch May 12, 2025 20:48
Copy link

codecov bot commented May 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.54%. Comparing base (1f833be) to head (c6cd44b).
Report is 92 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6102      +/-   ##
===========================================
- Coverage    83.71%   83.54%   -0.17%     
===========================================
  Files          538      538              
  Lines       388438   388534      +96     
  Branches       323      323              
===========================================
- Hits        325172   324593     -579     
- Misses       63258    63933     +675     
  Partials         8        8              
Files with missing lines Coverage Δ
clarity/src/vm/analysis/mod.rs 95.23% <ø> (ø)
clarity/src/vm/docs/contracts.rs 95.52% <ø> (ø)

... and 65 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e45867c...c6cd44b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix unused imports from cargo check
2 participants