Skip to content

Commit ec358cc

Browse files
committed
clippy: turn on manual_assert lint
Style thing.
1 parent b2767a4 commit ec358cc

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ large_stack_arrays = "warn"
9999
large_types_passed_by_value = "warn"
100100
linkedlist = "warn"
101101
macro_use_imports = "warn"
102-
manual_assert = "allow"
102+
manual_assert = "warn"
103103
manual_instant_elapsed = "warn"
104104
manual_is_power_of_two = "warn"
105105
manual_is_variant_and = "warn"

src/error.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@ impl Position {
3535
///
3636
/// Line or column are zero.
3737
pub const fn new(line: usize, col: usize) -> Self {
38-
if line == 0 {
39-
panic!("Line must not be zero");
40-
}
38+
// assert_ne not available in constfn
39+
assert!(line != 0, "line must not be zero",);
4140
// Safety: Checked above
4241
let line = unsafe { NonZeroUsize::new_unchecked(line) };
43-
if col == 0 {
44-
panic!("Column must not be zero");
45-
}
42+
assert!(col != 0, "column must not be zero",);
4643
// Safety: Checked above
4744
let col = unsafe { NonZeroUsize::new_unchecked(col) };
4845
Self { line, col }

src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,10 @@ fn main() {
620620
) {
621621
Ok(_) => panic!("Accepted faulty program"),
622622
Err(error) => {
623-
if !error.contains("Expected expression of type `bool`, found type `()`") {
624-
panic!("Unexpected error: {error}")
625-
}
623+
assert!(
624+
error.contains("Expected expression of type `bool`, found type `()`"),
625+
"Unexpected error: {error}",
626+
);
626627
}
627628
}
628629
}

0 commit comments

Comments
 (0)