diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a0896d8234..c95b17da266 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -267,7 +267,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: clippy - args: --workspace --all-targets -- -D warnings + args: --workspace --all-targets --tests -- -D warnings - name: Run rustfmt uses: actions-rs/cargo@v1 diff --git a/crates/rspack_core/src/diagnostics.rs b/crates/rspack_core/src/diagnostics.rs index 7e6ad787d78..b4588ec6c61 100644 --- a/crates/rspack_core/src/diagnostics.rs +++ b/crates/rspack_core/src/diagnostics.rs @@ -78,6 +78,7 @@ impl miette::Diagnostic for ModuleBuildError { } /// Represent any errors or warnings during module parse +/// /// This does NOT aligned with webpack as webpack does not have parse warning. /// However, rspack may create warning during parsing stage, taking CSS as an example. #[derive(Debug, Error)] diff --git a/crates/rspack_core/src/options/filename.rs b/crates/rspack_core/src/options/filename.rs index 3435d43f66f..002ffb3c6d8 100644 --- a/crates/rspack_core/src/options/filename.rs +++ b/crates/rspack_core/src/options/filename.rs @@ -127,10 +127,9 @@ impl LocalFilenameFn for NoFilenameFn { impl From for Filename { fn from(value: FilenameTemplate) -> Self { - Self(match value.0 { - FilenameKind::Template(template) => FilenameKind::Template(template), - FilenameKind::Fn(no_fn) => match no_fn.0 {}, - }) + let FilenameKind::Template(template) = value.0; + + Self(FilenameKind::Template(template)) } } diff --git a/crates/rspack_regex/src/algo.rs b/crates/rspack_regex/src/algo.rs index f3fc9c1f25c..62107985119 100644 --- a/crates/rspack_regex/src/algo.rs +++ b/crates/rspack_regex/src/algo.rs @@ -112,24 +112,6 @@ impl Algo { } } -#[cfg(test)] -impl Algo { - fn end_with_pats(&self) -> std::collections::HashSet<&str> { - match self { - Algo::EndWith { pats } => pats.iter().map(|s| s.as_str()).collect(), - Algo::Regress(_) => panic!("expect EndWith"), - } - } - - fn is_end_with(&self) -> bool { - matches!(self, Self::EndWith { .. }) - } - - fn is_regress(&self) -> bool { - matches!(self, Self::Regress(..)) - } -} - fn is_ends_with_regex(hir: &Hir) -> bool { if let HirKind::Concat(list) = hir.kind() { list[0].kind() != &HirKind::Look(Look::Start) @@ -143,6 +125,23 @@ fn is_ends_with_regex(hir: &Hir) -> bool { mod test_algo { use super::*; + impl Algo { + fn end_with_pats(&self) -> std::collections::HashSet<&str> { + match self { + Algo::EndWith { pats } => pats.iter().map(|s| s.as_str()).collect(), + Algo::Regress(_) => panic!("expect EndWith"), + } + } + + fn is_end_with(&self) -> bool { + matches!(self, Self::EndWith { .. }) + } + + fn is_regress(&self) -> bool { + matches!(self, Self::Regress(..)) + } + } + #[test] fn should_use_end_with_algo_with_i_flag() { assert!(Algo::new("\\.js$", "").unwrap().is_end_with()); diff --git a/crates/rspack_util/src/infallible.rs b/crates/rspack_util/src/infallible.rs index 4589fe7896f..3224b1f0b8d 100644 --- a/crates/rspack_util/src/infallible.rs +++ b/crates/rspack_util/src/infallible.rs @@ -8,9 +8,7 @@ pub trait ResultInfallibleExt { impl ResultInfallibleExt for Result { type Ok = T; fn always_ok(self) -> T { - match self { - Ok(ok) => ok, - Err(infallible) => match infallible {}, - } + let Ok(ok) = self; + ok } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a9f7244565d..0ce1d9a0180 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,4 +2,4 @@ profile = "default" # Use nightly for better access to the latest Rust features. # This date is aligned to stable release dates. -channel = "nightly-2024-06-07" # v1.80.0 +channel = "nightly-2024-09-05" # v1.81.0