File tree Expand file tree Collapse file tree 2 files changed +34
-40
lines changed Expand file tree Collapse file tree 2 files changed +34
-40
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments