@@ -60,11 +60,6 @@ extern crate clippy_utils;
6060#[ macro_use]
6161extern crate declare_clippy_lint;
6262
63- use std:: collections:: BTreeMap ;
64-
65- use rustc_data_structures:: fx:: FxHashSet ;
66- use rustc_lint:: { Lint , LintId } ;
67-
6863#[ cfg( feature = "internal" ) ]
6964pub mod deprecated_lints;
7065#[ cfg_attr( feature = "internal" , allow( clippy:: missing_clippy_version_attribute) ) ]
@@ -384,6 +379,10 @@ mod zero_sized_map_values;
384379// end lints modules, do not remove this comment, it’s used in `update_lints`
385380
386381use clippy_config:: { get_configuration_metadata, Conf } ;
382+ use clippy_utils:: macros:: FormatArgsStorage ;
383+ use rustc_data_structures:: fx:: FxHashSet ;
384+ use rustc_lint:: { Lint , LintId } ;
385+ use std:: collections:: BTreeMap ;
387386
388387/// Register all pre expansion lints
389388///
@@ -615,6 +614,14 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
615614 }
616615 }
617616
617+ let format_args_storage = FormatArgsStorage :: default ( ) ;
618+ let format_args = format_args_storage. clone ( ) ;
619+ store. register_early_pass ( move || {
620+ Box :: new ( utils:: format_args_collector:: FormatArgsCollector :: new (
621+ format_args. clone ( ) ,
622+ ) )
623+ } ) ;
624+
618625 // all the internal lints
619626 #[ cfg( feature = "internal" ) ]
620627 {
@@ -655,7 +662,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
655662 . collect ( ) ,
656663 ) )
657664 } ) ;
658- store. register_early_pass ( || Box :: < utils:: format_args_collector:: FormatArgsCollector > :: default ( ) ) ;
659665 store. register_late_pass ( |_| Box :: new ( utils:: dump_hir:: DumpHir ) ) ;
660666 store. register_late_pass ( |_| Box :: new ( utils:: author:: Author ) ) ;
661667 store. register_late_pass ( move |_| {
@@ -697,13 +703,15 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
697703 store. register_late_pass ( |_| Box :: new ( non_octal_unix_permissions:: NonOctalUnixPermissions ) ) ;
698704 store. register_early_pass ( || Box :: new ( unnecessary_self_imports:: UnnecessarySelfImports ) ) ;
699705 store. register_late_pass ( move |_| Box :: new ( approx_const:: ApproxConstant :: new ( msrv ( ) ) ) ) ;
706+ let format_args = format_args_storage. clone ( ) ;
700707 store. register_late_pass ( move |_| {
701708 Box :: new ( methods:: Methods :: new (
702709 avoid_breaking_exported_api,
703710 msrv ( ) ,
704711 allow_expect_in_tests,
705712 allow_unwrap_in_tests,
706713 allowed_dotfiles. clone ( ) ,
714+ format_args. clone ( ) ,
707715 ) )
708716 } ) ;
709717 store. register_late_pass ( move |_| Box :: new ( matches:: Matches :: new ( msrv ( ) ) ) ) ;
@@ -768,7 +776,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
768776 store. register_late_pass ( |_| Box :: < regex:: Regex > :: default ( ) ) ;
769777 store. register_late_pass ( move |_| Box :: new ( copies:: CopyAndPaste :: new ( ignore_interior_mutability. clone ( ) ) ) ) ;
770778 store. register_late_pass ( |_| Box :: new ( copy_iterator:: CopyIterator ) ) ;
771- store. register_late_pass ( |_| Box :: new ( format:: UselessFormat ) ) ;
779+ let format_args = format_args_storage. clone ( ) ;
780+ store. register_late_pass ( move |_| Box :: new ( format:: UselessFormat :: new ( format_args. clone ( ) ) ) ) ;
772781 store. register_late_pass ( |_| Box :: new ( swap:: Swap ) ) ;
773782 store. register_late_pass ( |_| Box :: new ( overflow_check_conditional:: OverflowCheckConditional ) ) ;
774783 store. register_late_pass ( |_| Box :: < new_without_default:: NewWithoutDefault > :: default ( ) ) ;
@@ -792,7 +801,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
792801 store. register_late_pass ( |_| Box :: new ( partialeq_ne_impl:: PartialEqNeImpl ) ) ;
793802 store. register_late_pass ( |_| Box :: new ( unused_io_amount:: UnusedIoAmount ) ) ;
794803 store. register_late_pass ( move |_| Box :: new ( large_enum_variant:: LargeEnumVariant :: new ( enum_variant_size_threshold) ) ) ;
795- store. register_late_pass ( |_| Box :: new ( explicit_write:: ExplicitWrite ) ) ;
804+ let format_args = format_args_storage. clone ( ) ;
805+ store. register_late_pass ( move |_| Box :: new ( explicit_write:: ExplicitWrite :: new ( format_args. clone ( ) ) ) ) ;
796806 store. register_late_pass ( |_| Box :: new ( needless_pass_by_value:: NeedlessPassByValue ) ) ;
797807 store. register_late_pass ( move |tcx| {
798808 Box :: new ( pass_by_ref_or_value:: PassByRefOrValue :: new (
@@ -834,7 +844,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
834844 store. register_late_pass ( move |_| Box :: new ( mut_key:: MutableKeyType :: new ( ignore_interior_mutability. clone ( ) ) ) ) ;
835845 store. register_early_pass ( || Box :: new ( reference:: DerefAddrOf ) ) ;
836846 store. register_early_pass ( || Box :: new ( double_parens:: DoubleParens ) ) ;
837- store. register_late_pass ( |_| Box :: new ( format_impl:: FormatImpl :: new ( ) ) ) ;
847+ let format_args = format_args_storage. clone ( ) ;
848+ store. register_late_pass ( move |_| Box :: new ( format_impl:: FormatImpl :: new ( format_args. clone ( ) ) ) ) ;
838849 store. register_early_pass ( || Box :: new ( unsafe_removed_from_name:: UnsafeNameRemoval ) ) ;
839850 store. register_early_pass ( || Box :: new ( else_if_without_else:: ElseIfWithoutElse ) ) ;
840851 store. register_early_pass ( || Box :: new ( int_plus_one:: IntPlusOne ) ) ;
@@ -960,8 +971,14 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
960971 accept_comment_above_attributes,
961972 ) )
962973 } ) ;
963- store
964- . register_late_pass ( move |_| Box :: new ( format_args:: FormatArgs :: new ( msrv ( ) , allow_mixed_uninlined_format_args) ) ) ;
974+ let format_args = format_args_storage. clone ( ) ;
975+ store. register_late_pass ( move |_| {
976+ Box :: new ( format_args:: FormatArgs :: new (
977+ format_args. clone ( ) ,
978+ msrv ( ) ,
979+ allow_mixed_uninlined_format_args,
980+ ) )
981+ } ) ;
965982 store. register_late_pass ( |_| Box :: new ( trailing_empty_array:: TrailingEmptyArray ) ) ;
966983 store. register_early_pass ( || Box :: new ( octal_escapes:: OctalEscapes ) ) ;
967984 store. register_late_pass ( |_| Box :: new ( needless_late_init:: NeedlessLateInit ) ) ;
@@ -972,7 +989,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
972989 store. register_late_pass ( |_| Box :: new ( default_union_representation:: DefaultUnionRepresentation ) ) ;
973990 store. register_late_pass ( |_| Box :: < only_used_in_recursion:: OnlyUsedInRecursion > :: default ( ) ) ;
974991 store. register_late_pass ( move |_| Box :: new ( dbg_macro:: DbgMacro :: new ( allow_dbg_in_tests) ) ) ;
975- store. register_late_pass ( move |_| Box :: new ( write:: Write :: new ( allow_print_in_tests) ) ) ;
992+ let format_args = format_args_storage. clone ( ) ;
993+ store. register_late_pass ( move |_| Box :: new ( write:: Write :: new ( format_args. clone ( ) , allow_print_in_tests) ) ) ;
976994 store. register_late_pass ( move |_| {
977995 Box :: new ( cargo:: Cargo {
978996 ignore_publish : cargo_ignore_publish,
0 commit comments