Skip to content

Commit 390f038

Browse files
committed
Add macro test
1 parent cb897d0 commit 390f038

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

clippy_lints/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
936936
store.register_early_pass(|| Box::new(byte_char_slices::ByteCharSlice));
937937
store.register_early_pass(|| Box::new(cfg_not_test::CfgNotTest));
938938
store.register_late_pass(|_| Box::new(zombie_processes::ZombieProcesses));
939-
store.register_late_pass(move |_| Box::new(manual_div_ceil::ManualDivCeil::new(msrv())));
939+
store.register_late_pass(move |_| Box::new(manual_div_ceil::ManualDivCeil::new(conf)));
940940
// add lints here, do not remove this comment, it's used in `new_lint`
941941
}

clippy_lints/src/manual_div_ceil.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use rustc_middle::ty::{self};
1212
use rustc_session::impl_lint_pass;
1313
use rustc_span::symbol::Symbol;
1414

15+
use clippy_config::Conf;
16+
1517
declare_clippy_lint! {
1618
/// ### What it does
1719
/// Checks for an expression like `(x + (y - 1)) / y` which is a common manual reimplementation
@@ -45,8 +47,10 @@ pub struct ManualDivCeil {
4547

4648
impl ManualDivCeil {
4749
#[must_use]
48-
pub fn new(msrv: Msrv) -> Self {
49-
Self { msrv }
50+
pub fn new(conf: &'static Conf) -> Self {
51+
Self {
52+
msrv: conf.msrv.clone(),
53+
}
5054
}
5155
}
5256

tests/ui/manual_div_ceil.rs

+9
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,13 @@ fn main() {
2727
let _ = (z as i32 + (y_i - 1)) / y_i;
2828
let _ = (7_u32 as i32 + (y_i - 1)) / y_i;
2929
let _ = (7_u32 as i32 + (4 - 1)) / 4;
30+
31+
macro_rules! fill_via_chunks {
32+
($size: expr, $b: expr) => {{
33+
let size = $size;
34+
let chunk_size = ($b + size - 1) / size;
35+
}};
36+
}
37+
38+
fill_via_chunks!(45, 45);
3039
}

0 commit comments

Comments
 (0)