Skip to content

Commit 818a91e

Browse files
committed
Migrate write.rs to a late pass
1 parent 05a51e5 commit 818a91e

21 files changed

+572
-552
lines changed

clippy_lints/src/format.rs

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

clippy_lints/src/format_args.rs

+1-1
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

+1-1
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

+1-2
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;
@@ -437,7 +436,6 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, sess: &Se
437436
})
438437
});
439438

440-
store.register_pre_expansion_pass(|| Box::new(write::Write::default()));
441439
store.register_pre_expansion_pass(move || Box::new(attrs::EarlyAttributes { msrv }));
442440
}
443441

@@ -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));

clippy_lints/src/utils/conf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ pub fn format_error(error: Box<dyn Error>) -> String {
449449

450450
let mut msg = String::from(prefix);
451451
for row in 0..rows {
452-
write!(msg, "\n").unwrap();
452+
writeln!(msg).unwrap();
453453
for (column, column_width) in column_widths.iter().copied().enumerate() {
454454
let index = column * rows + row;
455455
let field = fields.get(index).copied().unwrap_or_default();

0 commit comments

Comments
 (0)