-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
format_args_collector
internal lint
- Loading branch information
Showing
5 changed files
with
34 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use clippy_utils::macros::collect_ast_format_args; | ||
use rustc_ast::{Expr, ExprKind}; | ||
use rustc_lint::{EarlyContext, EarlyLintPass}; | ||
use rustc_session::{declare_lint_pass, declare_tool_lint}; | ||
|
||
declare_clippy_lint! { | ||
/// ### What it does | ||
/// Collects [`rustc_ast::FormatArgs`] so that future late passes can call | ||
/// [`clippy_utils::macros::find_format_args`] | ||
pub FORMAT_ARGS_COLLECTOR, | ||
internal_warn, | ||
"collects `format_args` AST nodes for use in later lints" | ||
} | ||
|
||
declare_lint_pass!(FormatArgsCollector => [FORMAT_ARGS_COLLECTOR]); | ||
|
||
impl EarlyLintPass for FormatArgsCollector { | ||
fn check_expr(&mut self, _: &EarlyContext<'_>, expr: &Expr) { | ||
if let ExprKind::FormatArgs(args) = &expr.kind { | ||
collect_ast_format_args(expr.span, args); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod author; | ||
pub mod conf; | ||
pub mod dump_hir; | ||
pub mod format_args_collector; | ||
#[cfg(feature = "internal")] | ||
pub mod internal_lints; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters