Skip to content

Commit 8276e68

Browse files
committed
Migrate write.rs to a late pass
1 parent 4df6032 commit 8276e68

33 files changed

+550
-1264
lines changed

clippy_lints/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ impl<'tcx> LateLintPass<'tcx> for UselessFormat {
7171
let value = arg.param.value;
7272
if_chain! {
7373
if format_args.format_string.parts == [kw::Empty];
74+
if arg.format.is_default();
7475
if match cx.typeck_results().expr_ty(value).peel_refs().kind() {
7576
ty::Adt(adt, _) => cx.tcx.is_diagnostic_item(sym::String, adt.did()),
7677
ty::Str => true,
7778
_ => false,
7879
};
79-
if !arg.format.has_string_formatting();
8080
then {
8181
let is_new_string = match value.kind {
8282
ExprKind::Binary(..) => true,

clippy_lints/src/format_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'tcx> LateLintPass<'tcx> for FormatArgs {
7777
if let ExpnKind::Macro(_, name) = outermost_expn_data.kind;
7878
then {
7979
for arg in &format_args.args {
80-
if arg.format.has_string_formatting() {
80+
if !arg.format.is_default() {
8181
continue;
8282
}
8383
if is_aliased(&format_args, arg.param.value.hir_id) {

clippy_lints/src/lib.register_all.rs

-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
350350
LintId::of(useless_conversion::USELESS_CONVERSION),
351351
LintId::of(vec::USELESS_VEC),
352352
LintId::of(vec_init_then_push::VEC_INIT_THEN_PUSH),
353-
LintId::of(write::POSITIONAL_NAMED_FORMAT_PARAMETERS),
354353
LintId::of(write::PRINTLN_EMPTY_STRING),
355354
LintId::of(write::PRINT_LITERAL),
356355
LintId::of(write::PRINT_WITH_NEWLINE),

clippy_lints/src/lib.register_lints.rs

-1
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ store.register_lints(&[
593593
vec_init_then_push::VEC_INIT_THEN_PUSH,
594594
wildcard_imports::ENUM_GLOB_USE,
595595
wildcard_imports::WILDCARD_IMPORTS,
596-
write::POSITIONAL_NAMED_FORMAT_PARAMETERS,
597596
write::PRINTLN_EMPTY_STRING,
598597
write::PRINT_LITERAL,
599598
write::PRINT_STDERR,

clippy_lints/src/lib.register_suspicious.rs

-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ store.register_group(true, "clippy::suspicious", Some("clippy_suspicious"), vec!
3636
LintId::of(suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL),
3737
LintId::of(swap_ptr_to_ref::SWAP_PTR_TO_REF),
3838
LintId::of(unused_peekable::UNUSED_PEEKABLE),
39-
LintId::of(write::POSITIONAL_NAMED_FORMAT_PARAMETERS),
4039
])

clippy_lints/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ extern crate rustc_lint;
3939
extern crate rustc_middle;
4040
extern crate rustc_mir_dataflow;
4141
extern crate rustc_parse;
42-
extern crate rustc_parse_format;
4342
extern crate rustc_session;
4443
extern crate rustc_span;
4544
extern crate rustc_target;
@@ -423,7 +422,6 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, sess: &Se
423422
})
424423
});
425424

426-
store.register_pre_expansion_pass(|| Box::new(write::Write::default()));
427425
store.register_pre_expansion_pass(move || Box::new(attrs::EarlyAttributes { msrv }));
428426
}
429427

@@ -871,6 +869,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
871869
ignore_publish: cargo_ignore_publish,
872870
})
873871
});
872+
store.register_late_pass(|| Box::new(write::Write::default()));
874873
store.register_early_pass(|| Box::new(crate_in_macro_def::CrateInMacroDef));
875874
store.register_early_pass(|| Box::new(empty_structs_with_brackets::EmptyStructsWithBrackets));
876875
store.register_late_pass(|| Box::new(unnecessary_owned_empty_strings::UnnecessaryOwnedEmptyStrings));

clippy_lints/src/renamed_lints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
3636
("clippy::invalid_ref", "invalid_value"),
3737
("clippy::mem_discriminant_non_enum", "enum_intrinsics_non_enums"),
3838
("clippy::panic_params", "non_fmt_panics"),
39+
("clippy::positional_named_format_parameters", "named_arguments_used_positionally"),
3940
("clippy::temporary_cstring_as_ptr", "temporary_cstring_as_ptr"),
4041
("clippy::unknown_clippy_lints", "unknown_lints"),
4142
("clippy::unused_label", "unused_labels"),

clippy_lints/src/utils/conf.rs

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

473473
let mut msg = String::from(prefix);
474474
for row in 0..rows {
475-
write!(msg, "\n").unwrap();
475+
writeln!(msg).unwrap();
476476
for (column, column_width) in column_widths.iter().copied().enumerate() {
477477
let index = column * rows + row;
478478
let field = fields.get(index).copied().unwrap_or_default();

0 commit comments

Comments
 (0)