Skip to content

Commit 6750424

Browse files
committed
Migrate write.rs to a late pass
1 parent 0509a96 commit 6750424

20 files changed

+589
-556
lines changed

clippy_lints/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessFormat {
7676
ty::Str => true,
7777
_ => false,
7878
};
79-
if let Some(args) = format_args.args();
79+
if let Some(args) = format_args.args(cx);
8080
if args.iter().all(|arg| arg.format_trait == sym::Display && !arg.has_string_formatting());
8181
then {
8282
let is_new_string = match value.kind {

clippy_lints/src/format_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs {
7474
if let Some(macro_def_id) = outermost_expn_data.macro_def_id;
7575
if is_format_macro(cx, macro_def_id);
7676
if let ExpnKind::Macro(_, name) = outermost_expn_data.kind;
77-
if let Some(args) = format_args.args();
77+
if let Some(args) = format_args.args(cx);
7878
then {
7979
for (i, arg) in args.iter().enumerate() {
8080
if arg.format_trait != sym::Display {

clippy_lints/src/format_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn check_self_in_format_args<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>,
168168
if let macro_def_id = outer_macro.def_id;
169169
if let Some(format_args) = FormatArgsExpn::find_nested(cx, expr, outer_macro.expn);
170170
if is_format_macro(cx, macro_def_id);
171-
if let Some(args) = format_args.args();
171+
if let Some(args) = format_args.args(cx);
172172
then {
173173
for arg in args {
174174
if arg.format_trait != impl_trait.name {

clippy_lints/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ extern crate rustc_lint;
4040
extern crate rustc_middle;
4141
extern crate rustc_mir_dataflow;
4242
extern crate rustc_parse;
43-
extern crate rustc_parse_format;
4443
extern crate rustc_session;
4544
extern crate rustc_span;
4645
extern crate rustc_target;
@@ -439,7 +438,6 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, sess: &Se
439438
})
440439
});
441440

442-
store.register_pre_expansion_pass(|| Box::new(write::Write::default()));
443441
store.register_pre_expansion_pass(move || Box::new(attrs::EarlyAttributes { msrv }));
444442
}
445443

@@ -881,6 +879,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
881879
ignore_publish: cargo_ignore_publish,
882880
})
883881
});
882+
store.register_late_pass(|| Box::new(write::Write::default()));
884883
store.register_early_pass(|| Box::new(crate_in_macro_def::CrateInMacroDef));
885884
store.register_early_pass(|| Box::new(empty_structs_with_brackets::EmptyStructsWithBrackets));
886885
store.register_late_pass(|| Box::new(unnecessary_owned_empty_strings::UnnecessaryOwnedEmptyStrings));

0 commit comments

Comments
 (0)