Skip to content

Commit

Permalink
fix lints for stable (#14)
Browse files Browse the repository at this point in the history
* fix lints

* more lints
  • Loading branch information
assafvayner authored Sep 20, 2024
1 parent 9392e59 commit 9ba46cb
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 54 deletions.
2 changes: 1 addition & 1 deletion cas_client/src/data_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl std::fmt::Debug for DataTransport {
/// Right now this retries every h2 error. Reading these:
/// - https://docs.rs/h2/latest/h2/struct.Error.html,
/// - https://docs.rs/h2/latest/h2/struct.Reason.html
/// unclear if there is any reason not to retry.
/// unclear if there is any reason not to retry.
#[derive(Error, Debug)]
enum RetryError {
#[error("{0}")]
Expand Down
72 changes: 33 additions & 39 deletions file_utils/src/privilege_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,14 @@ mod test {
fn test_create_dir_all() -> anyhow::Result<()> {
// Run this test manually, steps:

// For Unix
// 1. Run the below shell script in an empty dir with standard privileges.
// 2. Set env var 'XET_TEST_PATH' to this path.
// 3. Build the test executable by running 'cargo test -p gitxetcore --lib --no-run'.
// 4. Locate the path to the executable as TEST_EXE
// 5. Run test with a non-root user: 'TEST_EXE config::permission::test::test_create_dir_all --exact --nocapture --include-ignored'

r#"
sudo mkdir rootdir
"#;
/* For Unix
1. Run the below shell script in an empty dir with standard privileges.
2. Set env var 'XET_TEST_PATH' to this path.
3. Build the test executable by running 'cargo test -p gitxetcore --lib --no-run'.
4. Locate the path to the executable as TEST_EXE
5. Run test with a non-root user: 'TEST_EXE config::permission::test::test_create_dir_all --exact --nocapture --include-ignored'
sudo mkdir rootdir
*/

let test_path = std::env::var("XET_TEST_PATH")?;
std::env::set_current_dir(test_path)?;
Expand All @@ -273,16 +271,15 @@ sudo mkdir rootdir
fn test_create_dir_all_sudo() -> anyhow::Result<()> {
// Run this test manually, steps:

// For Unix
// 1. Run the below shell script in an empty dir with standard privileges.
// 2. Set env var 'XET_TEST_PATH' to this path.
// 3. Build the test executable by running 'cargo test -p gitxetcore --lib --no-run'.
// 4. Locate the path to the executable as TEST_EXE
// 5. Run test with root user: 'sudo -E TEST_EXE config::permission::test::test_create_dir_all_sudo --exact --nocapture --include-ignored'
/* For Unix
1. Run the below shell script in an empty dir with standard privileges.
2. Set env var 'XET_TEST_PATH' to this path.
3. Build the test executable by running 'cargo test -p gitxetcore --lib --no-run'.
4. Locate the path to the executable as TEST_EXE
5. Run test with a non-root user: 'sudo -E TEST_EXE config::permission::test::test_create_dir_all_sudo --exact --nocapture --include-ignored'
r#"
mkdir regdir
"#;
mkdir regdir
*/

let test_path = std::env::var("XET_TEST_PATH")?;
std::env::set_current_dir(test_path)?;
Expand Down Expand Up @@ -310,17 +307,16 @@ mkdir regdir
fn test_create_file() -> anyhow::Result<()> {
// Run this test manually, steps:

// For Unix
// 1. Run the below shell script in an empty dir with standard privileges.
// 2. Set env var 'XET_TEST_PATH' to this path.
// 3. Build the test executable by running 'cargo test -p gitxetcore --lib --no-run'.
// 4. Locate the path to the executable as TEST_EXE
// 5. Run test with a non-root user: 'TEST_EXE config::permission::test::test_create_file --exact --nocapture --include-ignored'
/* For Unix
1. Run the below shell script in an empty dir with standard privileges.
2. Set env var 'XET_TEST_PATH' to this path.
3. Build the test executable by running 'cargo test -p gitxetcore --lib --no-run'.
4. Locate the path to the executable as TEST_EXE
5. Run test with a non-root user: 'TEST_EXE config::permission::test::test_create_file --exact --nocapture --include-ignored'
r#"
sudo mkdir rootdir
sudo touch rootdir/file
"#;
sudo mkdir rootdir
sudo touch rootdir/file
*/

let test_path = std::env::var("XET_TEST_PATH")?;
std::env::set_current_dir(test_path)?;
Expand All @@ -345,16 +341,14 @@ sudo touch rootdir/file
fn test_create_file_sudo() -> anyhow::Result<()> {
// Run this test manually, steps:

// For Unix
// 1. Run the below shell script in an empty dir with standard privileges.
// 2. Set env var 'XET_TEST_PATH' to this path.
// 3. Build the test executable by running 'cargo test -p gitxetcore --lib --no-run'.
// 4. Locate the path to the executable as TEST_EXE
// 5. Run test with root user: 'sudo -E TEST_EXE config::permission::test::test_create_file_sudo --exact --nocapture --include-ignored'

r#"
mkdir regdir
"#;
/* For Unix
1. Run the below shell script in an empty dir with standard privileges.
2. Set env var 'XET_TEST_PATH' to this path.
3. Build the test executable by running 'cargo test -p gitxetcore --lib --no-run'.
4. Locate the path to the executable as TEST_EXE
5. Run test with a non-root user: 'sudo -E TEST_EXE config::permission::test::test_create_file_sudo --exact --nocapture --include-ignored'
mkdir regdir
*/

let test_path = std::env::var("XET_TEST_PATH")?;
std::env::set_current_dir(test_path)?;
Expand Down
2 changes: 2 additions & 0 deletions mdb_shard/src/set_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,14 @@ mod tests {
std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(&shard_path_1)?
.write_all(&disk_shard_1[..])?;

std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(&shard_path_2)?
.write_all(&disk_shard_2[..])?;

Expand Down
3 changes: 3 additions & 0 deletions merkledb/benches/rolling_hash_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ impl SumHash {
let mut bytehash: [u32; 256] = [0; 256];
if seed > 0 {
let mut rng = ChaChaRng::seed_from_u64(seed);
#[allow(clippy::needless_range_loop)]
for i in 0..256 {
bytehash[i] = rng.next_u32();
}
} else {
#[allow(clippy::needless_range_loop)]
for i in 0..256 {
bytehash[i] = i as u32;
}
Expand Down Expand Up @@ -189,6 +191,7 @@ impl GearHash {
pub fn init(mask: u32, seed: u64) -> GearHash {
let mut rng = ChaChaRng::seed_from_u64(seed);
let mut bytehash: [u32; 256] = [0; 256];
#[allow(clippy::needless_range_loop)]
for i in 0..256 {
bytehash[i] = rng.next_u32();
}
Expand Down
3 changes: 3 additions & 0 deletions xet_error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ trybuild = { version = "1.0.81", features = ["diff"] }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
rustdoc-args = ["--generate-link-to-definition"]

[features]
error_generic_member_access = []
5 changes: 2 additions & 3 deletions xet_error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,10 @@
clippy::return_self_not_must_use,
clippy::wildcard_imports
)]
#![cfg_attr(error_generic_member_access, feature(error_generic_member_access))]

mod aserror;
mod display;
#[cfg(error_generic_member_access)]
#[cfg(feature = "error_generic_member_access")]
mod provide;

pub use xet_error_impl::*;
Expand All @@ -251,7 +250,7 @@ pub mod __private {
pub use crate::aserror::AsDynError;
#[doc(hidden)]
pub use crate::display::AsDisplay;
#[cfg(error_generic_member_access)]
#[cfg(feature = "error_generic_member_access")]
#[doc(hidden)]
pub use crate::provide::ThiserrorProvide;
}
Expand Down
10 changes: 4 additions & 6 deletions xet_error/tests/test_backtrace.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#![cfg_attr(xet_error_nightly_testing, feature(error_generic_member_access))]

use xet_error::Error;

#[derive(Error, Debug)]
#[error("...")]
pub struct Inner;

#[cfg(xet_error_nightly_testing)]
#[cfg(feature = "error_generic_member_access")]
#[derive(Error, Debug)]
#[error("...")]
pub struct InnerBacktrace {
backtrace: std::backtrace::Backtrace,
}

#[cfg(xet_error_nightly_testing)]
#[cfg(feature = "error_generic_member_access")]
pub mod structs {
use super::{Inner, InnerBacktrace};
use std::backtrace::Backtrace;
Expand Down Expand Up @@ -147,7 +145,7 @@ pub mod structs {
}
}

#[cfg(xet_error_nightly_testing)]
#[cfg(feature = "error_generic_member_access")]
pub mod enums {
use super::{Inner, InnerBacktrace};
use std::backtrace::Backtrace;
Expand Down Expand Up @@ -270,5 +268,5 @@ pub mod enums {
}

#[test]
#[cfg_attr(not(xet_error_nightly_testing), ignore)]
#[cfg_attr(not(feature = "error_generic_member_access"), ignore)]
fn test_backtrace() {}
8 changes: 3 additions & 5 deletions xet_error/tests/test_option.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![cfg_attr(xet_error_nightly_testing, feature(error_generic_member_access))]

#[cfg(xet_error_nightly_testing)]
#[cfg(feature = "error_generic_member_access")]
pub mod structs {
use std::backtrace::Backtrace;
use xet_error::Error;
Expand Down Expand Up @@ -45,7 +43,7 @@ pub mod structs {
}
}

#[cfg(xet_error_nightly_testing)]
#[cfg(feature = "error_generic_member_access")]
pub mod enums {
use std::backtrace::Backtrace;
use xet_error::Error;
Expand Down Expand Up @@ -101,5 +99,5 @@ pub mod enums {
}

#[test]
#[cfg_attr(not(xet_error_nightly_testing), ignore)]
#[cfg_attr(not(feature = "error_generic_member_access"), ignore)]
fn test_option() {}

0 comments on commit 9ba46cb

Please sign in to comment.