@@ -60,11 +60,6 @@ extern crate clippy_utils;
60
60
#[ macro_use]
61
61
extern crate declare_clippy_lint;
62
62
63
- use std:: collections:: BTreeMap ;
64
-
65
- use rustc_data_structures:: fx:: FxHashSet ;
66
- use rustc_lint:: { Lint , LintId } ;
67
-
68
63
#[ cfg( feature = "internal" ) ]
69
64
pub mod deprecated_lints;
70
65
#[ cfg_attr( feature = "internal" , allow( clippy:: missing_clippy_version_attribute) ) ]
@@ -383,6 +378,10 @@ mod zero_sized_map_values;
383
378
// end lints modules, do not remove this comment, it’s used in `update_lints`
384
379
385
380
use clippy_config:: { get_configuration_metadata, Conf } ;
381
+ use clippy_utils:: macros:: FormatArgsStorage ;
382
+ use rustc_data_structures:: fx:: FxHashSet ;
383
+ use rustc_lint:: { Lint , LintId } ;
384
+ use std:: collections:: BTreeMap ;
386
385
387
386
/// Register all pre expansion lints
388
387
///
@@ -652,7 +651,13 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
652
651
. collect ( ) ,
653
652
) )
654
653
} ) ;
655
- store. register_early_pass ( || Box :: < utils:: format_args_collector:: FormatArgsCollector > :: default ( ) ) ;
654
+ let format_args_storage = FormatArgsStorage :: default ( ) ;
655
+ let format_args = format_args_storage. clone ( ) ;
656
+ store. register_early_pass ( move || {
657
+ Box :: new ( utils:: format_args_collector:: FormatArgsCollector :: new (
658
+ format_args. clone ( ) ,
659
+ ) )
660
+ } ) ;
656
661
store. register_late_pass ( |_| Box :: new ( utils:: dump_hir:: DumpHir ) ) ;
657
662
store. register_late_pass ( |_| Box :: new ( utils:: author:: Author ) ) ;
658
663
store. register_late_pass ( move |_| {
@@ -694,13 +699,15 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
694
699
store. register_late_pass ( |_| Box :: new ( non_octal_unix_permissions:: NonOctalUnixPermissions ) ) ;
695
700
store. register_early_pass ( || Box :: new ( unnecessary_self_imports:: UnnecessarySelfImports ) ) ;
696
701
store. register_late_pass ( move |_| Box :: new ( approx_const:: ApproxConstant :: new ( msrv ( ) ) ) ) ;
702
+ let format_args = format_args_storage. clone ( ) ;
697
703
store. register_late_pass ( move |_| {
698
704
Box :: new ( methods:: Methods :: new (
699
705
avoid_breaking_exported_api,
700
706
msrv ( ) ,
701
707
allow_expect_in_tests,
702
708
allow_unwrap_in_tests,
703
709
allowed_dotfiles. clone ( ) ,
710
+ format_args. clone ( ) ,
704
711
) )
705
712
} ) ;
706
713
store. register_late_pass ( move |_| Box :: new ( matches:: Matches :: new ( msrv ( ) ) ) ) ;
@@ -764,7 +771,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
764
771
store. register_late_pass ( |_| Box :: < regex:: Regex > :: default ( ) ) ;
765
772
store. register_late_pass ( move |_| Box :: new ( copies:: CopyAndPaste :: new ( ignore_interior_mutability. clone ( ) ) ) ) ;
766
773
store. register_late_pass ( |_| Box :: new ( copy_iterator:: CopyIterator ) ) ;
767
- store. register_late_pass ( |_| Box :: new ( format:: UselessFormat ) ) ;
774
+ let format_args = format_args_storage. clone ( ) ;
775
+ store. register_late_pass ( move |_| Box :: new ( format:: UselessFormat :: new ( format_args. clone ( ) ) ) ) ;
768
776
store. register_late_pass ( |_| Box :: new ( swap:: Swap ) ) ;
769
777
store. register_late_pass ( |_| Box :: new ( overflow_check_conditional:: OverflowCheckConditional ) ) ;
770
778
store. register_late_pass ( |_| Box :: < new_without_default:: NewWithoutDefault > :: default ( ) ) ;
@@ -788,7 +796,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
788
796
store. register_late_pass ( |_| Box :: new ( partialeq_ne_impl:: PartialEqNeImpl ) ) ;
789
797
store. register_late_pass ( |_| Box :: new ( unused_io_amount:: UnusedIoAmount ) ) ;
790
798
store. register_late_pass ( move |_| Box :: new ( large_enum_variant:: LargeEnumVariant :: new ( enum_variant_size_threshold) ) ) ;
791
- store. register_late_pass ( |_| Box :: new ( explicit_write:: ExplicitWrite ) ) ;
799
+ let format_args = format_args_storage. clone ( ) ;
800
+ store. register_late_pass ( move |_| Box :: new ( explicit_write:: ExplicitWrite :: new ( format_args. clone ( ) ) ) ) ;
792
801
store. register_late_pass ( |_| Box :: new ( needless_pass_by_value:: NeedlessPassByValue ) ) ;
793
802
store. register_late_pass ( move |tcx| {
794
803
Box :: new ( pass_by_ref_or_value:: PassByRefOrValue :: new (
@@ -830,7 +839,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
830
839
store. register_late_pass ( move |_| Box :: new ( mut_key:: MutableKeyType :: new ( ignore_interior_mutability. clone ( ) ) ) ) ;
831
840
store. register_early_pass ( || Box :: new ( reference:: DerefAddrOf ) ) ;
832
841
store. register_early_pass ( || Box :: new ( double_parens:: DoubleParens ) ) ;
833
- store. register_late_pass ( |_| Box :: new ( format_impl:: FormatImpl :: new ( ) ) ) ;
842
+ let format_args = format_args_storage. clone ( ) ;
843
+ store. register_late_pass ( move |_| Box :: new ( format_impl:: FormatImpl :: new ( format_args. clone ( ) ) ) ) ;
834
844
store. register_early_pass ( || Box :: new ( unsafe_removed_from_name:: UnsafeNameRemoval ) ) ;
835
845
store. register_early_pass ( || Box :: new ( else_if_without_else:: ElseIfWithoutElse ) ) ;
836
846
store. register_early_pass ( || Box :: new ( int_plus_one:: IntPlusOne ) ) ;
@@ -955,8 +965,14 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
955
965
accept_comment_above_attributes,
956
966
) )
957
967
} ) ;
958
- store
959
- . register_late_pass ( move |_| Box :: new ( format_args:: FormatArgs :: new ( msrv ( ) , allow_mixed_uninlined_format_args) ) ) ;
968
+ let format_args = format_args_storage. clone ( ) ;
969
+ store. register_late_pass ( move |_| {
970
+ Box :: new ( format_args:: FormatArgs :: new (
971
+ format_args. clone ( ) ,
972
+ msrv ( ) ,
973
+ allow_mixed_uninlined_format_args,
974
+ ) )
975
+ } ) ;
960
976
store. register_late_pass ( |_| Box :: new ( trailing_empty_array:: TrailingEmptyArray ) ) ;
961
977
store. register_early_pass ( || Box :: new ( octal_escapes:: OctalEscapes ) ) ;
962
978
store. register_late_pass ( |_| Box :: new ( needless_late_init:: NeedlessLateInit ) ) ;
@@ -967,7 +983,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
967
983
store. register_late_pass ( |_| Box :: new ( default_union_representation:: DefaultUnionRepresentation ) ) ;
968
984
store. register_late_pass ( |_| Box :: < only_used_in_recursion:: OnlyUsedInRecursion > :: default ( ) ) ;
969
985
store. register_late_pass ( move |_| Box :: new ( dbg_macro:: DbgMacro :: new ( allow_dbg_in_tests) ) ) ;
970
- store. register_late_pass ( move |_| Box :: new ( write:: Write :: new ( allow_print_in_tests) ) ) ;
986
+ let format_args = format_args_storage. clone ( ) ;
987
+ store. register_late_pass ( move |_| Box :: new ( write:: Write :: new ( format_args. clone ( ) , allow_print_in_tests) ) ) ;
971
988
store. register_late_pass ( move |_| {
972
989
Box :: new ( cargo:: Cargo {
973
990
ignore_publish : cargo_ignore_publish,
0 commit comments