@@ -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) ) ]
@@ -384,6 +379,10 @@ mod zero_sized_map_values;
384
379
// end lints modules, do not remove this comment, it’s used in `update_lints`
385
380
386
381
use 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 ;
387
386
388
387
/// Register all pre expansion lints
389
388
///
@@ -654,7 +653,13 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
654
653
. collect ( ) ,
655
654
) )
656
655
} ) ;
657
- store. register_early_pass ( || Box :: < utils:: format_args_collector:: FormatArgsCollector > :: default ( ) ) ;
656
+ let format_args_storage = FormatArgsStorage :: default ( ) ;
657
+ let format_args = format_args_storage. clone ( ) ;
658
+ store. register_early_pass ( move || {
659
+ Box :: new ( utils:: format_args_collector:: FormatArgsCollector :: new (
660
+ format_args. clone ( ) ,
661
+ ) )
662
+ } ) ;
658
663
store. register_late_pass ( |_| Box :: new ( utils:: dump_hir:: DumpHir ) ) ;
659
664
store. register_late_pass ( |_| Box :: new ( utils:: author:: Author ) ) ;
660
665
store. register_late_pass ( move |_| {
@@ -696,13 +701,15 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
696
701
store. register_late_pass ( |_| Box :: new ( non_octal_unix_permissions:: NonOctalUnixPermissions ) ) ;
697
702
store. register_early_pass ( || Box :: new ( unnecessary_self_imports:: UnnecessarySelfImports ) ) ;
698
703
store. register_late_pass ( move |_| Box :: new ( approx_const:: ApproxConstant :: new ( msrv ( ) ) ) ) ;
704
+ let format_args = format_args_storage. clone ( ) ;
699
705
store. register_late_pass ( move |_| {
700
706
Box :: new ( methods:: Methods :: new (
701
707
avoid_breaking_exported_api,
702
708
msrv ( ) ,
703
709
allow_expect_in_tests,
704
710
allow_unwrap_in_tests,
705
711
allowed_dotfiles. clone ( ) ,
712
+ format_args. clone ( ) ,
706
713
) )
707
714
} ) ;
708
715
store. register_late_pass ( move |_| Box :: new ( matches:: Matches :: new ( msrv ( ) ) ) ) ;
@@ -766,7 +773,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
766
773
store. register_late_pass ( |_| Box :: < regex:: Regex > :: default ( ) ) ;
767
774
store. register_late_pass ( move |_| Box :: new ( copies:: CopyAndPaste :: new ( ignore_interior_mutability. clone ( ) ) ) ) ;
768
775
store. register_late_pass ( |_| Box :: new ( copy_iterator:: CopyIterator ) ) ;
769
- store. register_late_pass ( |_| Box :: new ( format:: UselessFormat ) ) ;
776
+ let format_args = format_args_storage. clone ( ) ;
777
+ store. register_late_pass ( move |_| Box :: new ( format:: UselessFormat :: new ( format_args. clone ( ) ) ) ) ;
770
778
store. register_late_pass ( |_| Box :: new ( swap:: Swap ) ) ;
771
779
store. register_late_pass ( |_| Box :: new ( overflow_check_conditional:: OverflowCheckConditional ) ) ;
772
780
store. register_late_pass ( |_| Box :: < new_without_default:: NewWithoutDefault > :: default ( ) ) ;
@@ -790,7 +798,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
790
798
store. register_late_pass ( |_| Box :: new ( partialeq_ne_impl:: PartialEqNeImpl ) ) ;
791
799
store. register_late_pass ( |_| Box :: new ( unused_io_amount:: UnusedIoAmount ) ) ;
792
800
store. register_late_pass ( move |_| Box :: new ( large_enum_variant:: LargeEnumVariant :: new ( enum_variant_size_threshold) ) ) ;
793
- store. register_late_pass ( |_| Box :: new ( explicit_write:: ExplicitWrite ) ) ;
801
+ let format_args = format_args_storage. clone ( ) ;
802
+ store. register_late_pass ( move |_| Box :: new ( explicit_write:: ExplicitWrite :: new ( format_args. clone ( ) ) ) ) ;
794
803
store. register_late_pass ( |_| Box :: new ( needless_pass_by_value:: NeedlessPassByValue ) ) ;
795
804
store. register_late_pass ( move |tcx| {
796
805
Box :: new ( pass_by_ref_or_value:: PassByRefOrValue :: new (
@@ -832,7 +841,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
832
841
store. register_late_pass ( move |_| Box :: new ( mut_key:: MutableKeyType :: new ( ignore_interior_mutability. clone ( ) ) ) ) ;
833
842
store. register_early_pass ( || Box :: new ( reference:: DerefAddrOf ) ) ;
834
843
store. register_early_pass ( || Box :: new ( double_parens:: DoubleParens ) ) ;
835
- store. register_late_pass ( |_| Box :: new ( format_impl:: FormatImpl :: new ( ) ) ) ;
844
+ let format_args = format_args_storage. clone ( ) ;
845
+ store. register_late_pass ( move |_| Box :: new ( format_impl:: FormatImpl :: new ( format_args. clone ( ) ) ) ) ;
836
846
store. register_early_pass ( || Box :: new ( unsafe_removed_from_name:: UnsafeNameRemoval ) ) ;
837
847
store. register_early_pass ( || Box :: new ( else_if_without_else:: ElseIfWithoutElse ) ) ;
838
848
store. register_early_pass ( || Box :: new ( int_plus_one:: IntPlusOne ) ) ;
@@ -958,8 +968,14 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
958
968
accept_comment_above_attributes,
959
969
) )
960
970
} ) ;
961
- store
962
- . register_late_pass ( move |_| Box :: new ( format_args:: FormatArgs :: new ( msrv ( ) , allow_mixed_uninlined_format_args) ) ) ;
971
+ let format_args = format_args_storage. clone ( ) ;
972
+ store. register_late_pass ( move |_| {
973
+ Box :: new ( format_args:: FormatArgs :: new (
974
+ format_args. clone ( ) ,
975
+ msrv ( ) ,
976
+ allow_mixed_uninlined_format_args,
977
+ ) )
978
+ } ) ;
963
979
store. register_late_pass ( |_| Box :: new ( trailing_empty_array:: TrailingEmptyArray ) ) ;
964
980
store. register_early_pass ( || Box :: new ( octal_escapes:: OctalEscapes ) ) ;
965
981
store. register_late_pass ( |_| Box :: new ( needless_late_init:: NeedlessLateInit ) ) ;
@@ -970,7 +986,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
970
986
store. register_late_pass ( |_| Box :: new ( default_union_representation:: DefaultUnionRepresentation ) ) ;
971
987
store. register_late_pass ( |_| Box :: < only_used_in_recursion:: OnlyUsedInRecursion > :: default ( ) ) ;
972
988
store. register_late_pass ( move |_| Box :: new ( dbg_macro:: DbgMacro :: new ( allow_dbg_in_tests) ) ) ;
973
- store. register_late_pass ( move |_| Box :: new ( write:: Write :: new ( allow_print_in_tests) ) ) ;
989
+ let format_args = format_args_storage. clone ( ) ;
990
+ store. register_late_pass ( move |_| Box :: new ( write:: Write :: new ( format_args. clone ( ) , allow_print_in_tests) ) ) ;
974
991
store. register_late_pass ( move |_| {
975
992
Box :: new ( cargo:: Cargo {
976
993
ignore_publish : cargo_ignore_publish,
0 commit comments