Skip to content

Commit b2722b2

Browse files
committed
Migrate write.rs to a late pass
1 parent d422baa commit b2722b2

20 files changed

+589
-553
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
@@ -41,7 +41,6 @@ extern crate rustc_lint;
4141
extern crate rustc_middle;
4242
extern crate rustc_mir_dataflow;
4343
extern crate rustc_parse;
44-
extern crate rustc_parse_format;
4544
extern crate rustc_session;
4645
extern crate rustc_span;
4746
extern crate rustc_target;
@@ -441,7 +440,6 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, sess: &Se
441440
})
442441
});
443442

444-
store.register_pre_expansion_pass(|| Box::new(write::Write::default()));
445443
store.register_pre_expansion_pass(move || Box::new(attrs::EarlyAttributes { msrv }));
446444
}
447445

@@ -892,6 +890,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
892890
ignore_publish: cargo_ignore_publish,
893891
})
894892
});
893+
store.register_late_pass(|| Box::new(write::Write::default()));
895894
store.register_early_pass(|| Box::new(crate_in_macro_def::CrateInMacroDef));
896895
store.register_early_pass(|| Box::new(empty_structs_with_brackets::EmptyStructsWithBrackets));
897896
store.register_late_pass(|| Box::new(unnecessary_owned_empty_strings::UnnecessaryOwnedEmptyStrings));

0 commit comments

Comments
 (0)