forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#10275 - Alexendoo:format-args-ast, r=flip1995
Migrate `write.rs` to `rustc_ast::FormatArgs` changelog: none Part 1 of rust-lang#10233 The additions to `clippy_utils` are the main novelty of this PR, there's no removals yet since other parts still rely on `FormatArgsExpn` The changes to `write.rs` itself are relatively straightforward this time around, as there's no lints in it that rely on type checking format params r? `@flip1995`
- Loading branch information
Showing
10 changed files
with
221 additions
and
90 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
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,9 @@ | ||
// aux-build:../../auxiliary/proc_macro_with_span.rs | ||
|
||
extern crate proc_macro_with_span; | ||
|
||
use proc_macro_with_span::with_span; | ||
|
||
fn main() { | ||
println!(with_span!(""something "")); | ||
} |
Oops, something went wrong.