Skip to content

Commit e348451

Browse files
committed
Add msrv to manual_div_ceil
1 parent 588cd65 commit e348451

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

clippy_config/src/msrvs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ msrv_aliases! {
2020
1,81,0 { LINT_REASONS_STABILIZATION }
2121
1,77,0 { C_STR_LITERALS }
2222
1,76,0 { PTR_FROM_REF, OPTION_RESULT_INSPECT }
23+
1,73,0 { MANUAL_DIV_CEIL }
2324
1,71,0 { TUPLE_ARRAY_CONVERSIONS, BUILD_HASHER_HASH_ONE }
2425
1,70,0 { OPTION_RESULT_IS_VARIANT_AND, BINARY_HEAP_RETAIN }
2526
1,68,0 { PATH_MAIN_SEPARATOR_STR }

clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
11781178
store.register_late_pass(|_| Box::new(set_contains_or_insert::HashsetInsertAfterContains));
11791179
store.register_early_pass(|| Box::new(byte_char_slices::ByteCharSlice));
11801180
store.register_early_pass(|| Box::new(cfg_not_test::CfgNotTest));
1181-
store.register_late_pass(|_| Box::new(manual_div_ceil::ManualDivCeil));
1181+
store.register_late_pass(move |_| Box::new(manual_div_ceil::ManualDivCeil::new(msrv())));
11821182
// add lints here, do not remove this comment, it's used in `new_lint`
11831183
}
11841184

clippy_lints/src/manual_div_ceil.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use clippy_config::msrvs::{self, Msrv};
12
use clippy_utils::diagnostics::span_lint_and_sugg;
23
use clippy_utils::source::snippet_with_applicability;
34
use clippy_utils::SpanlessEq;
@@ -7,7 +8,7 @@ use rustc_errors::Applicability;
78
use rustc_hir::{Expr, ExprKind};
89
use rustc_lint::{LateContext, LateLintPass};
910
use rustc_middle::ty::{self};
10-
use rustc_session::declare_lint_pass;
11+
use rustc_session::impl_lint_pass;
1112

1213
declare_clippy_lint! {
1314
/// ### What it does
@@ -36,10 +37,25 @@ declare_clippy_lint! {
3637
"manually reimplementing `div_ceil`"
3738
}
3839

39-
declare_lint_pass!(ManualDivCeil => [MANUAL_DIV_CEIL]);
40+
pub struct ManualDivCeil {
41+
msrv: Msrv,
42+
}
43+
44+
impl ManualDivCeil {
45+
#[must_use]
46+
pub fn new(msrv: Msrv) -> Self {
47+
Self { msrv }
48+
}
49+
}
50+
51+
impl_lint_pass!(ManualDivCeil => [MANUAL_DIV_CEIL]);
52+
53+
impl<'tcx> LateLintPass<'tcx> for ManualDivCeil {
54+
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
55+
if !self.msrv.meets(msrvs::MANUAL_DIV_CEIL) {
56+
return;
57+
}
4058

41-
impl LateLintPass<'_> for ManualDivCeil {
42-
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
4359
let mut applicability = Applicability::MachineApplicable;
4460

4561
if let ExprKind::Binary(div_op, div_lhs, div_rhs) = expr.kind

0 commit comments

Comments
 (0)