|
1 | 1 | use rustc_hir::def_id::LocalDefId; |
2 | 2 | use rustc_hir::intravisit::FnKind; |
3 | 3 | use rustc_hir::{Body,FnDecl}; |
4 | | -use rustc_lint::{LateContext,LateLintPass}; |
| 4 | +use rustc_lint::Level::Deny; |
| 5 | +use rustc_lint::{LateContext,LateLintPass,Lint}; |
5 | 6 | use rustc_session::declare_lint_pass; |
6 | 7 | use rustc_span::Span; |
7 | 8 |
|
8 | | -declare_clippy_lint!{ |
9 | | -/// ### What it does |
10 | | -/// Checks for comparisons where one side of the relation is |
11 | | -/// either the minimum or maximum value for its type and warns if it involves a |
12 | | -/// case that is always true or always false. Only integer and boolean types are |
13 | | -/// checked. |
14 | | -/// |
15 | | -/// ### Why is this bad? |
16 | | -/// An expression like `min <= x` may misleadingly imply |
17 | | -/// that it is possible for `x` to be less than the minimum. Expressions like |
18 | | -/// `max < x` are probably mistakes. |
19 | | -/// |
20 | | -/// ### Known problems |
21 | | -/// For `usize` the size of the current compile target will |
22 | | -/// be assumed (e.g., 64 bits on 64 bit systems). This means code that uses such |
23 | | -/// a comparison to detect target pointer width will trigger this lint. One can |
24 | | -/// use `mem::sizeof` and compare its value or conditional compilation |
25 | | -/// attributes |
26 | | -/// like `#[cfg(target_pointer_width = "64")] ..` instead. |
27 | | -/// |
28 | | -/// ### Example |
29 | | -/// ```no_run |
30 | | -/// let vec: Vec<isize> = Vec::new(); |
31 | | -/// if vec.len() <= 0 {} |
32 | | -/// if 100 > i32::MAX {} |
33 | | -/// ``` |
34 | | - #[clippy::version = "1.82.0"] |
35 | | -pubCLIPPY_CTFE, |
36 | | - correctness, |
37 | | -"a comparison with a maximum or minimum value that is always true or false" |
38 | | -} |
| 9 | +/// Ensures that Constant-time Function Evaluation is being done (specifically, MIR lint passes). |
| 10 | +/// See rust-lang/rust#125116 for more info. |
| 11 | +#[clippy::version = "1.82.0"] |
| 12 | +pubstaticCLIPPY_CTFE:&Lint = &Lint{ |
| 13 | +name:&"clippy::CLIPPY_CTFE", |
| 14 | +default_level:Deny, |
| 15 | +desc:"Ensure CTFE is being made", |
| 16 | +edition_lint_opts:None, |
| 17 | +report_in_external_macro:true, |
| 18 | +future_incompatible:None, |
| 19 | +is_externally_loaded:true, |
| 20 | +crate_level_only:false, |
| 21 | +eval_always:true, |
| 22 | + ..Lint::default_fields_for_macro() |
| 23 | +}; |
| 24 | + |
| 25 | +// No static CLIPPY_CTFE_INFO because we want this lint to be invisible |
39 | 26 |
|
40 | 27 | declare_lint_pass!{ClippyCtfe => [CLIPPY_CTFE]} |
41 | 28 |
|
|
0 commit comments