Skip to content

Commit 84f7212

Browse files
committed
Rename CLIPPY_CTFE->CTFE and use declare_tool_lint to declare it
1 parent 8d3c564 commit 84f7212

File tree

2 files changed

+34
-40
lines changed

2 files changed

+34
-40
lines changed

clippy_lints/src/ctfe.rs

Lines changed: 0 additions & 40 deletions
This file was deleted.

clippy_lints/src/utils/ctfe.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use rustc_hir::def_id::LocalDefId;
2+
use rustc_hir::intravisit::FnKind;
3+
use rustc_hir::{Body, FnDecl};
4+
use rustc_lint::{LateContext, LateLintPass};
5+
use rustc_session::{declare_lint_pass, declare_tool_lint};
6+
use rustc_span::Span;
7+
8+
// Not using `declare_clippy_lint`, so that no static CLIPPY_CTFE_INFO is created, so this lint
9+
// doesn't show up in the documentation.
10+
declare_tool_lint! {
11+
/// Ensures that Constant-time Function Evaluation is being done (specifically, MIR lint passes).
12+
/// As Clippy deactivates codegen, this lint ensures that CTFE (used in hard errors) is still ran.
13+
pub clippy::CTFE,
14+
Allow,
15+
"Ensure CTFE is being made",
16+
report_in_external_macro: true,
17+
@eval_always = true
18+
}
19+
20+
declare_lint_pass! { ClippyCtfe => [CTFE] }
21+
22+
impl<'tcx> LateLintPass<'tcx> for ClippyCtfe {
23+
fn check_fn(
24+
&mut self,
25+
cx: &LateContext<'_>,
26+
_: FnKind<'tcx>,
27+
_: &'tcx FnDecl<'tcx>,
28+
_: &'tcx Body<'tcx>,
29+
_: Span,
30+
defid: LocalDefId,
31+
) {
32+
cx.tcx.ensure().mir_drops_elaborated_and_const_checked(defid); // Lint
33+
}
34+
}

0 commit comments

Comments
 (0)