diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index b1c2a51daa0..384aca7fead 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -467,7 +467,7 @@ pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span: let mut contains_initial_stars = false; for line in doc.lines() { let offset = line.as_ptr() as usize - doc.as_ptr() as usize; - debug_assert_eq!(offset as u32 as usize, offset, "`offset` shouldn't overflow `u32`"); + debug_assert_eq!(offset as u32 as usize, offset); contains_initial_stars |= line.trim_start().starts_with('*'); // +1 adds the newline, +3 skips the opening delimiter sizes.push((line.len() + 1, span.with_lo(span.lo() + BytePos(3 + offset as u32)))); diff --git a/clippy_lints/src/duplicate_mod.rs b/clippy_lints/src/duplicate_mod.rs index 9135af40979..7ff7068f0b0 100644 --- a/clippy_lints/src/duplicate_mod.rs +++ b/clippy_lints/src/duplicate_mod.rs @@ -90,11 +90,7 @@ impl EarlyLintPass for DuplicateMod { } // At this point the lint would be emitted - assert_eq!( - spans.len(), - lint_levels.len(), - "`spans` and `lint_levels` should have equal lengths" - ); + assert_eq!(spans.len(), lint_levels.len()); let spans: Vec<_> = spans .iter() .zip(lint_levels) diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index 68fb88bcf7e..4c69dacf381 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -242,7 +242,7 @@ fn to_camel_case(item_name: &str) -> String { impl LateLintPass<'_> for EnumVariantNames { fn check_item_post(&mut self, _cx: &LateContext<'_>, _item: &Item<'_>) { let last = self.modules.pop(); - assert!(last.is_some(), "`modules` should not be empty"); + assert!(last.is_some()); } #[expect(clippy::similar_names)] diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index e24f3aa567a..9f6917c146f 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -408,10 +408,7 @@ fn do_check(lint: &mut NonExpressiveNames, cx: &EarlyContext<'_>, attrs: &[Attri /// Precondition: `a_name.chars().count() < b_name.chars().count()`. #[must_use] fn levenstein_not_1(a_name: &str, b_name: &str) -> bool { - debug_assert!( - a_name.chars().count() < b_name.chars().count(), - "Precondition: `a_name.chars().count() < b_name.chars().count()` does not meet" - ); + debug_assert!(a_name.chars().count() < b_name.chars().count()); let mut a_chars = a_name.chars(); let mut b_chars = b_name.chars(); while let (Some(a), Some(b)) = (a_chars.next(), b_chars.next()) { diff --git a/clippy_utils/src/attrs.rs b/clippy_utils/src/attrs.rs index 75f7b5cf98e..7987a233bdc 100644 --- a/clippy_utils/src/attrs.rs +++ b/clippy_utils/src/attrs.rs @@ -31,7 +31,7 @@ pub struct LimitStack { impl Drop for LimitStack { fn drop(&mut self) { - assert_eq!(self.stack.len(), 1, "stack should only have one element"); + assert_eq!(self.stack.len(), 1); } } @@ -49,9 +49,7 @@ impl LimitStack { } pub fn pop_attrs(&mut self, sess: &Session, attrs: &[ast::Attribute], name: &'static str) { let stack = &mut self.stack; - parse_attrs(sess, attrs, name, |val| { - assert_eq!(stack.pop(), Some(val), "incorrect last element"); - }); + parse_attrs(sess, attrs, name, |val| assert_eq!(stack.pop(), Some(val))); } } diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 1c453b87f8d..213e5b33503 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -1011,13 +1011,10 @@ pub fn capture_local_usage(cx: &LateContext<'_>, e: &Expr<'_>) -> CaptureKind { capture } - debug_assert!( - matches!( - e.kind, - ExprKind::Path(QPath::Resolved(None, Path { res: Res::Local(_), .. })) - ), - "`e.kind` should be a resolved local path" - ); + debug_assert!(matches!( + e.kind, + ExprKind::Path(QPath::Resolved(None, Path { res: Res::Local(_), .. })) + )); let mut child_id = e.hir_id; let mut capture = CaptureKind::Value; diff --git a/clippy_utils/src/numeric_literal.rs b/clippy_utils/src/numeric_literal.rs index 7d8f31e1dfb..c225398ad2a 100644 --- a/clippy_utils/src/numeric_literal.rs +++ b/clippy_utils/src/numeric_literal.rs @@ -179,7 +179,7 @@ impl<'a> NumericLiteral<'a> { } pub fn group_digits(output: &mut String, input: &str, group_size: usize, partial_group_first: bool, pad: bool) { - debug_assert!(group_size > 0, "group size should be greater than zero"); + debug_assert!(group_size > 0); let mut digits = input.chars().filter(|&c| c != '_'); @@ -219,7 +219,7 @@ impl<'a> NumericLiteral<'a> { } fn split_suffix<'a>(src: &'a str, lit_kind: &LitKind) -> (&'a str, Option<&'a str>) { - debug_assert!(lit_kind.is_numeric(), "`lit_kind` should be numeric"); + debug_assert!(lit_kind.is_numeric()); lit_suffix_length(lit_kind) .and_then(|suffix_length| src.len().checked_sub(suffix_length)) .map_or((src, None), |split_pos| { @@ -229,7 +229,7 @@ fn split_suffix<'a>(src: &'a str, lit_kind: &LitKind) -> (&'a str, Option<&'a st } fn lit_suffix_length(lit_kind: &LitKind) -> Option { - debug_assert!(lit_kind.is_numeric(), "`lit_kind` should be numeric"); + debug_assert!(lit_kind.is_numeric()); let suffix = match lit_kind { LitKind::Int(_, int_lit_kind) => match int_lit_kind { LitIntType::Signed(int_ty) => Some(int_ty.name_str()), diff --git a/clippy_utils/src/ty.rs b/clippy_utils/src/ty.rs index 2b3c781477f..7cbb77ea2a8 100644 --- a/clippy_utils/src/ty.rs +++ b/clippy_utils/src/ty.rs @@ -225,7 +225,8 @@ pub fn implements_trait_with_env<'tcx>( trait_id: DefId, ty_params: impl IntoIterator>>, ) -> bool { - assert!(!ty.needs_infer(), "Clippy shouldn't have infer types"); + // Clippy shouldn't have infer types + assert!(!ty.needs_infer()); let ty = tcx.erase_regions(ty); if ty.has_escaping_bound_vars() { diff --git a/lintcheck/src/main.rs b/lintcheck/src/main.rs index 6e39c8d4243..23c85298027 100644 --- a/lintcheck/src/main.rs +++ b/lintcheck/src/main.rs @@ -383,7 +383,7 @@ impl Crate { .status() .expect("failed to run cargo"); - assert_eq!(status.code(), Some(0), "`cargo check` exited with non-zero code"); + assert_eq!(status.code(), Some(0)); return Vec::new(); } @@ -741,7 +741,6 @@ fn print_stats(old_stats: HashMap, new_stats: HashMap<&String, us let mut new_stats_deduped = new_stats; // remove duplicates from both hashmaps - #[allow(clippy::missing_assert_message)] for (k, v) in &same_in_both_hashmaps { assert!(old_stats_deduped.remove(k) == Some(*v)); assert!(new_stats_deduped.remove(k) == Some(*v)); diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 2f2d305f54b..c10ee969c01 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -410,10 +410,7 @@ fn check_rustfix_coverage() { }; if let Ok(missing_coverage_contents) = std::fs::read_to_string(missing_coverage_path) { - assert!( - RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS.iter().is_sorted_by_key(Path::new), - "`RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS` should be sorted" - ); + assert!(RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS.iter().is_sorted_by_key(Path::new)); for rs_file in missing_coverage_contents.lines() { let rs_path = Path::new(rs_file); diff --git a/tests/integration.rs b/tests/integration.rs index 2d2d6e6739e..a771d8b87c8 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -21,7 +21,6 @@ const CARGO_CLIPPY: &str = "cargo-clippy"; const CARGO_CLIPPY: &str = "cargo-clippy.exe"; #[cfg_attr(feature = "integration", test)] -#[allow(clippy::missing_assert_message)] fn integration_test() { let repo_name = env::var("INTEGRATION").expect("`INTEGRATION` var not set"); let repo_url = format!("https://github.com/{repo_name}"); diff --git a/tests/test_utils/mod.rs b/tests/test_utils/mod.rs index 3081bf2d8cc..ea8c54e08b3 100644 --- a/tests/test_utils/mod.rs +++ b/tests/test_utils/mod.rs @@ -5,7 +5,7 @@ use std::sync::LazyLock; pub static CARGO_CLIPPY_PATH: LazyLock = LazyLock::new(|| { let mut path = std::env::current_exe().unwrap(); - assert!(path.pop(), "current running executable path shouldn't be empty"); // deps + assert!(path.pop()); // deps path.set_file_name("cargo-clippy"); path });