|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_note;
|
2 |
| -use clippy_utils::is_lint_allowed; |
3 | 2 | use clippy_utils::macros::root_macro_call_first_node;
|
4 | 3 | use rustc_ast::LitKind;
|
5 | 4 | use rustc_hir::{Expr, ExprKind};
|
@@ -52,24 +51,19 @@ impl_lint_pass!(LargeIncludeFile => [LARGE_INCLUDE_FILE]);
|
52 | 51 |
|
53 | 52 | impl LateLintPass<'_> for LargeIncludeFile {
|
54 | 53 | fn check_expr(&mut self, cx: &LateContext<'_>, expr: &'_ Expr<'_>) {
|
55 |
| - if let Some(macro_call) = root_macro_call_first_node(cx, expr) |
56 |
| - && !is_lint_allowed(cx, LARGE_INCLUDE_FILE, expr.hir_id) |
57 |
| - && (cx.tcx.is_diagnostic_item(sym::include_bytes_macro, macro_call.def_id) |
58 |
| - || cx.tcx.is_diagnostic_item(sym::include_str_macro, macro_call.def_id)) |
59 |
| - && let ExprKind::Lit(lit) = &expr.kind |
60 |
| - { |
61 |
| - let len = match &lit.node { |
| 54 | + if let ExprKind::Lit(lit) = &expr.kind |
| 55 | + && let len = match &lit.node { |
62 | 56 | // include_bytes
|
63 | 57 | LitKind::ByteStr(bstr, _) => bstr.len(),
|
64 | 58 | // include_str
|
65 | 59 | LitKind::Str(sym, _) => sym.as_str().len(),
|
66 | 60 | _ => return,
|
67 |
| - }; |
68 |
| - |
69 |
| - if len as u64 <= self.max_file_size { |
70 |
| - return; |
71 | 61 | }
|
72 |
| - |
| 62 | + && len as u64 > self.max_file_size |
| 63 | + && let Some(macro_call) = root_macro_call_first_node(cx, expr) |
| 64 | + && (cx.tcx.is_diagnostic_item(sym::include_bytes_macro, macro_call.def_id) |
| 65 | + || cx.tcx.is_diagnostic_item(sym::include_str_macro, macro_call.def_id)) |
| 66 | + { |
73 | 67 | span_lint_and_note(
|
74 | 68 | cx,
|
75 | 69 | LARGE_INCLUDE_FILE,
|
|
0 commit comments