Skip to content

Commit

Permalink
Merge pull request #28374 from ProvableHQ/clippy
Browse files Browse the repository at this point in the history
Address clippy lints.
  • Loading branch information
d0cd authored Oct 3, 2024
2 parents 61c71e6 + f283ff2 commit 12159ec
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 41 deletions.
2 changes: 1 addition & 1 deletion compiler/passes/src/type_checking/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ impl<'a, N: Network> TypeChecker<'a, N> {
}

// Type check the function's parameters.
function.input.iter().enumerate().for_each(|(_index, input_var)| {
function.input.iter().for_each(|input_var| {
// Check that the type of input parameter is defined.
self.assert_type_is_valid(input_var.type_(), input_var.span());
// Check that the type of the input parameter is not a tuple.
Expand Down
2 changes: 1 addition & 1 deletion compiler/span/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use core::ops::{Add, Sub};
use serde::{Deserialize, Serialize};
use std::{fmt, usize};
use std::fmt;

use crate::symbol::with_session_globals;

Expand Down
2 changes: 1 addition & 1 deletion docs/grammar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<'a> Processor<'a> {
let def = def.trim();

// try to find rule matching definition or fail
let rule = self.rules.get(&def.to_string()).cloned().unwrap();
let rule = self.rules.get(def).cloned().unwrap();

self.enter_scope(Scope::Definition(rule));
}
Expand Down
29 changes: 0 additions & 29 deletions leo/cli/helpers/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,6 @@ pub struct Format<F = Full, T = SystemTime> {
}

impl<F, T> Format<F, T> {
/// Use the full JSON format.
///
/// The full format includes fields from all entered spans.
///
/// # Example Output
///
/// ```ignore,json
/// {"timestamp":"Feb 20 11:28:15.096","level":"INFO","target":"mycrate","fields":{"message":"some message", "key": "value"}}
/// ```
///
/// # Options
///
/// - [`Format::flatten_event`] can be used to enable flattening event fields into the root
/// object.
///
/// [`Format::flatten_event`]: #method.flatten_event
#[cfg(feature = "json")]
pub fn json(self) -> Format<Json, T> {
Format {
format: Json::default(),
timer: self.timer,
ansi: self.ansi,
display_target: self.display_target,
display_level: self.display_level,
display_thread_id: self.display_thread_id,
display_thread_name: self.display_thread_name,
}
}

/// Use the given [`timer`] for log message timestamps.
///
/// See [`time`] for the provided timer implementations.
Expand Down
10 changes: 5 additions & 5 deletions leo/package/src/root/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use snarkvm::console::account::PrivateKey;
use snarkvm::prelude::{MainnetV0, Network, TestnetV0};

use serde::Deserialize;
use std::{borrow::Cow, fs::File, io::Write, path::Path};
use std::{borrow::Cow, fmt, fs::File, io::Write, path::Path};

pub static ENV_FILENAME: &str = ".env";

Expand Down Expand Up @@ -67,15 +67,15 @@ impl<N: Network> Env<N> {
}
}

impl<N: Network> ToString for Env<N> {
fn to_string(&self) -> String {
impl<N: Network> fmt::Display for Env<N> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Get the network name.
let network = match N::ID {
MainnetV0::ID => NetworkName::MainnetV0,
TestnetV0::ID => NetworkName::TestnetV0,
_ => unimplemented!("Unsupported network"),
};
// Return the formatted string.
format!("NETWORK={network}\nPRIVATE_KEY={}\nENDPOINT={}\n", self.private_key, self.endpoint)
// Write the formatted string.
write!(f, "NETWORK={network}\nPRIVATE_KEY={}\nENDPOINT={}\n", self.private_key, self.endpoint)
}
}
5 changes: 1 addition & 4 deletions tests/test-framework/src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ pub fn find_tests(path: &Path) -> impl Iterator<Item = (PathBuf, String)> {
// Check if the file is a .leo file.
let is_leo_file = path.extension().filter(|s| *s == "leo").is_some();
// Read the test filter from the environment.
let filter = match std::env::var("TEST_FILTER") {
Ok(filter) => filter,
Err(_) => String::new(),
};
let filter = std::env::var("TEST_FILTER").unwrap_or_default();
// Check if the path contains the filter.
let satisfies_filter = filter.is_empty() || path.to_string_lossy().contains(&filter);
// If the file is a .leo file and satisfies the filter, return the path and the file contents.
Expand Down

0 comments on commit 12159ec

Please sign in to comment.