Revert "Dogfood `missing_assert_message` on Clippy"

This reverts commit ec653570ad50d11ecc3b5649dd28e29ed96199d3.
This commit is contained in:
unexge 2023-02-18 19:18:52 +00:00
parent 6fac73b987
commit b4b2b1235a
12 changed files with 18 additions and 34 deletions

View File

@ -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))));

View File

@ -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)

View File

@ -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)]

View File

@ -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()) {

View File

@ -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)));
}
}

View File

@ -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;

View File

@ -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<usize> {
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()),

View File

@ -225,7 +225,8 @@ pub fn implements_trait_with_env<'tcx>(
trait_id: DefId,
ty_params: impl IntoIterator<Item = Option<GenericArg<'tcx>>>,
) -> 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() {

View File

@ -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<String, usize>, 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));

View File

@ -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);

View File

@ -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}");

View File

@ -5,7 +5,7 @@ use std::sync::LazyLock;
pub static CARGO_CLIPPY_PATH: LazyLock<PathBuf> = 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
});