Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtkana committed Oct 18, 2023
1 parent 66edf12 commit 3926f7e
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ runs:
- name: Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
toolchain: "1.70.0"

- uses: taiki-e/install-action@nextest

Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ jobs:
working-directory: .
run: cargo make test-doc

test:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: changes
if: needs.changes.outputs.trigger == 'true'
steps:
- name: Clone Project
uses: actions/checkout@v4
with:
lfs: false

- name: Setup Rust
uses: ./.github/actions/setup-rust

- name: Test
working-directory: .
run: cargo make test

docs:
runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down
23 changes: 17 additions & 6 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
[config]
default_to_workspace = false

[tasks.ci-flow]
dependencies = ["test-doc", "clippy", "test", "docs"]


[tasks.check]
command = "cargo"
args = ["check", "--all-features", "--all-targets"]

[tasks.test]
command = "cargo"
args = ["nextest", "run"]

[tasks.test-doc]
command = "cargo"
args = ["test", "--doc"]

[tasks.pre-docs]
script = '''
cargo run --bin snippetter
Expand All @@ -21,11 +33,6 @@ command = "cargo"
args = ["doc", "--workspace", "--no-deps"]
dependencies = ["pre-docs"]

[tasks.pedantics]
script = '''
cargo clippy --all-targets --all-features -- -W clippy::pedantic 2>&1 | grep 'note: `-W clippy::' | sed -n 's/.*note: `-W clippy::\([a-z|-]*\).*/\1/p' | sort | uniq
'''

[tasks.clippy]
command = "cargo"
args = [
Expand All @@ -51,5 +58,9 @@ args = [
"-Aclippy::similar-names",
"-Aclippy::uninlined-format-args",
"-Aclippy::unreadable_literal",
"-Aclippy::missing_fields_in_debug",
]

[tasks.pedantics]
script = '''
cargo clippy --all-targets --all-features -- -W clippy::pedantic 2>&1 | grep 'note: `-W clippy::' | sed -n 's/.*note: `-W clippy::\([a-z|-]*\).*/\1/p' | sort | uniq
'''
1 change: 0 additions & 1 deletion libs/randtools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ edition = "2018"

[dependencies]
rand = { workspace = true }
test-case = { workspace = true }
3 changes: 1 addition & 2 deletions libs/rb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ pub use list::RbReversibleList;

/// Iterators for a list based on a red-black tree.
pub mod list_iter {
use super::*;
pub use list::Range;
pub use super::list::RbList;
}

/// The trait for specifying the operation of a red-black tree.
Expand Down
8 changes: 4 additions & 4 deletions libs/rb/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ impl<O: Op> Eq for RbList<O> where O::Value: Eq {}
impl<O: Op> FromIterator<O::Value> for RbList<O> {
fn from_iter<T: IntoIterator<Item = O::Value>>(iter: T) -> Self {
Self {
tree: Tree::from_iter(
iter.into_iter()
.map(|value| Ptr::new(IrreversibleData::new(value))),
),
tree: iter
.into_iter()
.map(|value| Ptr::new(IrreversibleData::new(value)))
.collect(),
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions libs/rb/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ pub(super) mod tests {
vec
}

pub fn write<'a, C: Callback, F, S>(
pub(super) fn write<'a, C: Callback, F, S>(
w: &mut impl std::io::Write,
tree: &Tree<C>,
mut to_string: F,
Expand Down Expand Up @@ -1324,7 +1324,7 @@ pub(super) mod tests {
Ok(())
}

pub fn format<'a, C: Callback, F, S>(
pub(super) fn format<'a, C: Callback, F, S>(
tree: &Tree<C>,
to_string: F,
fg: &[(&'static str, Ptr<C>, ansi_term::Color)],
Expand Down Expand Up @@ -1538,8 +1538,9 @@ pub(super) mod tests {
let mut rng = StdRng::seed_from_u64(42);
for _ in 0..20 {
let len = rng.gen_range(0..100usize);
let tree =
Tree::<TestCallback>::from_iter((0..len as u64).map(|i| Ptr::new(Data::new(i))));
let tree = (0..len as u64)
.map(|i| Ptr::new(Data::new(i)))
.collect::<Tree<TestCallback>>();
eprintln!("{}", format(&tree, |data| data.value.to_string(), &[]));
for _ in 0..20 {
let value = rng.gen_range(0..=len as u64);
Expand Down
3 changes: 2 additions & 1 deletion libs/splay_tree/src/test_trivial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ impl LazyOps for I32Add {
}

#[test]
#[allow(clippy::redundant_clone)]
fn test_clone() {
let splay = (0..10).collect::<SplayTree<Nop<i32>>>();
let new = splay.clone();
assert_eq!(splay, new);
assert_eq!(&splay, &new);
for i in 0..10 {
splay.get(i);
new.get(i);
Expand Down
1 change: 0 additions & 1 deletion libs/tree_fold/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use std::fmt::Debug;
/// - `identity()` を `None` とかにして頑張るしかないですかね
/// - 辺重み
/// - `頂点重みで代用できませんかね。
///
pub trait Ops: Sized {
type Value: Clone + Debug + Default;
type Acc: Clone + Debug;
Expand Down
1 change: 0 additions & 1 deletion libs/zeta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
//! add_inv(&mut a);
//! assert_eq!(a, [1, 2, 4, 8]);
//! ```
//!
use std::cmp::Ord;
use std::cmp::{self};
Expand Down
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "1.70.0"

0 comments on commit 3926f7e

Please sign in to comment.