Skip to content
Open
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
4 changes: 2 additions & 2 deletions components/clarity-jupyter-kernel/src/jupyter/install.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dirs;
use failure::Error;
use std::io::Write;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::{env, fs};

pub fn install() -> Result<(), Error> {
Expand All @@ -24,7 +24,7 @@ pub fn install() -> Result<(), Error> {
Ok(())
}

pub fn install_resource(dir: &PathBuf, filename: &str, bytes: &'static [u8]) -> Result<(), Error> {
pub fn install_resource(dir: &Path, filename: &str, bytes: &'static [u8]) -> Result<(), Error> {
let res_path = dir.join(filename);
println!("Writing {}", res_path.to_string_lossy());
let mut file = fs::File::create(res_path)?;
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-repl/src/analysis/cache/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub type BindingMap<'a> = HashMap<Binding<'a>, BindingData<'a>>;

pub struct BindingMapBuilder<'a> {
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
/// Names of all `let` bindings and function args currently in scope
active_bindings: HashMap<&'a ClarityName, BindingData<'a>>,
/// Variables which went out of scope without being referenced
Expand All @@ -59,7 +59,7 @@ impl<'a> BindingMapBuilder<'a> {
pub fn build(
clarity_version: ClarityVersion,
contract_analysis: &'a ContractAnalysis,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
) -> BindingMap<'a> {
let mut builder = Self {
clarity_version,
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-repl/src/analysis/cache/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ pub type ConstantMap<'a> = IndexMap<&'a ClarityName, ConstantData<'a>>;

pub struct ConstantMapBuilder<'a> {
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
map: ConstantMap<'a>,
}

impl<'a> ConstantMapBuilder<'a> {
pub fn build(
clarity_version: ClarityVersion,
contract_analysis: &'a ContractAnalysis,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
) -> ConstantMap<'a> {
let mut builder = Self {
clarity_version,
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-repl/src/analysis/cache/data_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ pub type DataVarMap<'a> = IndexMap<&'a ClarityName, DataVarData<'a>>;

pub struct DataVarMapBuilder<'a> {
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
map: DataVarMap<'a>,
}

impl<'a> DataVarMapBuilder<'a> {
pub fn build(
clarity_version: ClarityVersion,
contract_analysis: &'a ContractAnalysis,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
) -> DataVarMap<'a> {
let mut builder = Self {
clarity_version,
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-repl/src/analysis/cache/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct FnMaps<'a> {

pub struct FnMapBuilder<'a> {
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
public: FnMap<'a>,
read_only: FnMap<'a>,
private: PrivateFnMap<'a>,
Expand All @@ -60,7 +60,7 @@ impl<'a> FnMapBuilder<'a> {
pub fn build(
clarity_version: ClarityVersion,
contract_analysis: &'a ContractAnalysis,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
) -> FnMaps<'a> {
let mut builder = Self {
clarity_version,
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-repl/src/analysis/cache/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ pub type MapDefinitionMap<'a> = IndexMap<&'a ClarityName, MapData<'a>>;

pub struct MapDefinitionMapBuilder<'a> {
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
map: MapDefinitionMap<'a>,
}

impl<'a> MapDefinitionMapBuilder<'a> {
pub fn build(
clarity_version: ClarityVersion,
contract_analysis: &'a ContractAnalysis,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
) -> MapDefinitionMap<'a> {
let mut builder = Self {
clarity_version,
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-repl/src/analysis/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::analysis::annotation::Annotation;
/// All fields are lazy-initialized, and only created if used in at least one pass
pub struct AnalysisCache<'a> {
pub contract_analysis: &'a ContractAnalysis,
pub annotations: &'a Vec<Annotation>,
pub annotations: &'a [Annotation],

constants: Option<ConstantMap<'a>>,
bindings: Option<BindingMap<'a>>,
Expand All @@ -36,7 +36,7 @@ pub struct AnalysisCache<'a> {
}

impl<'a> AnalysisCache<'a> {
pub fn new(contract_analysis: &'a ContractAnalysis, annotations: &'a Vec<Annotation>) -> Self {
pub fn new(contract_analysis: &'a ContractAnalysis, annotations: &'a [Annotation]) -> Self {
Self {
contract_analysis,
annotations,
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-repl/src/analysis/cache/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct TokenMaps<'a> {

pub struct TokenMapBuilder<'a> {
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
pub fts: TokenMap<'a>,
pub nfts: TokenMap<'a>,
}
Expand All @@ -44,7 +44,7 @@ impl<'a> TokenMapBuilder<'a> {
pub fn build(
clarity_version: ClarityVersion,
contract_analysis: &'a ContractAnalysis,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
) -> TokenMaps<'a> {
let mut builder = Self {
clarity_version,
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-repl/src/analysis/cache/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub struct TraitMaps<'a> {

pub struct TraitMapBuilder<'a> {
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
declared: DeclaredTraitMap<'a>,
imported: ImportedTraitMap<'a>,
}
Expand All @@ -71,7 +71,7 @@ impl<'a> TraitMapBuilder<'a> {
pub fn build(
clarity_version: ClarityVersion,
contract_analysis: &'a ContractAnalysis,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
) -> TraitMaps<'a> {
let mut builder = Self {
clarity_version,
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-repl/src/analysis/check_checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub struct CheckChecker<'a> {
tainted_nodes: HashMap<Node<'a>, TaintedNode<'a>>,
/// Map expression ID to a generated diagnostic
diagnostics: HashMap<u64, Vec<Diagnostic>>,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
active_annotation: Option<usize>,
/// Record all public functions defined
public_funcs: HashSet<&'a ClarityName>,
Expand All @@ -129,7 +129,7 @@ pub struct CheckChecker<'a> {
impl<'a> CheckChecker<'a> {
fn new(
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
level: Level,
settings: Settings,
) -> CheckChecker<'a> {
Expand Down
8 changes: 2 additions & 6 deletions components/clarity-repl/src/analysis/lints/at_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ use crate::analysis::{self, AnalysisPass, AnalysisResult, LintName};
pub struct AtBlock<'a> {
clarity_version: ClarityVersion,
diagnostics: Vec<Diagnostic>,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
level: Level,
active_annotation: Option<usize>,
}

impl<'a> AtBlock<'a> {
fn new(
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
level: Level,
) -> Self {
fn new(clarity_version: ClarityVersion, annotations: &'a [Annotation], level: Level) -> Self {
Self {
clarity_version,
level,
Expand Down
4 changes: 2 additions & 2 deletions components/clarity-repl/src/analysis/lints/noop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub struct NoopChecker<'a> {
clarity_version: ClarityVersion,
_settings: NoopCheckerSettings,
diagnostics: Vec<Diagnostic>,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
/// Clarity diagnostic level
level: Level,
active_annotation: Option<usize>,
Expand All @@ -154,7 +154,7 @@ pub struct NoopChecker<'a> {
impl<'a> NoopChecker<'a> {
fn new(
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
level: Level,
settings: NoopCheckerSettings,
) -> NoopChecker<'a> {
Expand Down
8 changes: 2 additions & 6 deletions components/clarity-repl/src/analysis/lints/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ use crate::analysis::{self, AnalysisPass, AnalysisResult, LintName};
pub struct PanicChecker<'a> {
clarity_version: ClarityVersion,
diagnostics: HashMap<u64, Vec<Diagnostic>>,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
level: Level,
active_annotation: Option<usize>,
}

impl<'a> PanicChecker<'a> {
fn new(
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
level: Level,
) -> Self {
fn new(clarity_version: ClarityVersion, annotations: &'a [Annotation], level: Level) -> Self {
Self {
clarity_version,
level,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::analysis::{self, AnalysisPass, AnalysisResult, LintName};
pub struct UnnecessaryAsMaxLen<'a> {
clarity_version: ClarityVersion,
diagnostics: Vec<Diagnostic>,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
type_map: Option<&'a TypeMap>,
level: Level,
active_annotation: Option<usize>,
Expand All @@ -27,7 +27,7 @@ pub struct UnnecessaryAsMaxLen<'a> {
impl<'a> UnnecessaryAsMaxLen<'a> {
fn new(
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
type_map: Option<&'a TypeMap>,
level: Level,
) -> Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::analysis::{self, AnalysisPass, AnalysisResult, LintName};
pub struct UnnecessaryPublic<'a, 'b, 'c> {
clarity_version: ClarityVersion,
diagnostics: Vec<Diagnostic>,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
analysis_db: &'b mut AnalysisDatabase<'c>,
epoch: StacksEpochId,
level: Level,
Expand All @@ -50,7 +50,7 @@ pub struct UnnecessaryPublic<'a, 'b, 'c> {
impl<'a, 'b, 'c> UnnecessaryPublic<'a, 'b, 'c> {
fn new(
clarity_version: ClarityVersion,
annotations: &'a Vec<Annotation>,
annotations: &'a [Annotation],
analysis_db: &'b mut AnalysisDatabase<'c>,
epoch: StacksEpochId,
level: Level,
Expand Down
2 changes: 1 addition & 1 deletion components/clarity-repl/src/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl From<SettingsFile> for Settings {
pub fn run_analysis(
contract_analysis: &mut ContractAnalysis,
analysis_db: &mut AnalysisDatabase,
annotations: &Vec<Annotation>,
annotations: &[Annotation],
settings: &Settings,
) -> Result<Vec<LintDiagnostic>, Vec<LintDiagnostic>> {
let mut errors: Vec<LintDiagnostic> = vec![];
Expand Down
2 changes: 1 addition & 1 deletion components/clarity-repl/src/repl/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl ClarityInterpreter {
&mut self,
contract: &ClarityContract,
contract_ast: &ContractAST,
annotations: &Vec<Annotation>,
annotations: &[Annotation],
) -> Result<(ContractAnalysis, Vec<LintDiagnostic>), Diagnostic> {
let mut analysis_db = AnalysisDatabase::new(&mut self.clarity_datastore);

Expand Down
2 changes: 1 addition & 1 deletion components/observer/src/event_handler/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ async fn handle_new_mempool_tx(
let transactions = match raw_txs
.iter()
.map(|tx_data| {
indexer::stacks::get_tx_description(tx_data, &vec![]).map(|(tx_description, ..)| {
indexer::stacks::get_tx_description(tx_data, &[]).map(|(tx_description, ..)| {
MempoolAdmissionData {
tx_data: tx_data.clone(),
tx_description,
Expand Down
2 changes: 1 addition & 1 deletion components/observer/src/indexer/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ pub fn standardize_bitcoin_block(

fn try_parse_stacks_operation(
block_height: u64,
_inputs: &Vec<BitcoinTransactionInputFullBreakdown>,
_inputs: &[BitcoinTransactionInputFullBreakdown],
outputs: &[BitcoinTransactionOutputFullBreakdown],
pox_config: &PoxConfig,
expected_magic_bytes: &[u8; 2],
Expand Down
2 changes: 1 addition & 1 deletion components/observer/src/indexer/stacks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ pub fn get_value_description(raw_value: &str, ctx: &Context) -> String {

pub fn get_tx_description(
raw_tx: &str,
tx_events: &Vec<&NewEvent>,
tx_events: &[&NewEvent],
) -> Result<
(
String, // Human readable transaction's description (contract-call, publish, ...)
Expand Down
10 changes: 5 additions & 5 deletions components/stacks-codec/src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ impl std::str::FromStr for StacksString {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
if !StacksString::is_valid_string(&String::from(s)) {
if !StacksString::is_valid_string(s) {
return Err("Invalid string".to_string());
}
Ok(StacksString(s.as_bytes().to_vec()))
Expand Down Expand Up @@ -1601,11 +1601,11 @@ impl From<ContractName> for StacksString {

impl StacksString {
/// Is the given string a valid Clarity string?
pub fn is_valid_string(s: &String) -> bool {
pub fn is_valid_string(s: &str) -> bool {
s.is_ascii() && StacksString::is_printable(s)
}

pub fn is_printable(s: &String) -> bool {
pub fn is_printable(s: &str) -> bool {
if !s.is_ascii() {
return false;
}
Expand All @@ -1624,7 +1624,7 @@ impl StacksString {
ClarityName::try_from(self.to_string()).is_ok()
}

pub fn from_string(s: &String) -> Option<StacksString> {
pub fn from_string(s: &str) -> Option<StacksString> {
if !StacksString::is_valid_string(s) {
return None;
}
Expand All @@ -1634,7 +1634,7 @@ impl StacksString {

#[test]
fn test_display() {
let stxstr = StacksString::from_string(&"hello".to_string()).unwrap();
let stxstr = StacksString::from_string("hello").unwrap();
println!("log: {stxstr:#?}");
println!("log: {:#?}", stxstr.to_string());
}
Expand Down
Loading