@@ -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
///
@@ -614,6 +613,14 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
614
613
}
615
614
}
616
615
616
+ let format_args_storage = FormatArgsStorage :: default ( ) ;
617
+ let format_args = format_args_storage. clone ( ) ;
618
+ store. register_early_pass ( move || {
619
+ Box :: new ( utils:: format_args_collector:: FormatArgsCollector :: new (
620
+ format_args. clone ( ) ,
621
+ ) )
622
+ } ) ;
623
+
617
624
// all the internal lints
618
625
#[ cfg( feature = "internal" ) ]
619
626
{
@@ -654,7 +661,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
654
661
. collect ( ) ,
655
662
) )
656
663
} ) ;
657
- store. register_early_pass ( || Box :: < utils:: format_args_collector:: FormatArgsCollector > :: default ( ) ) ;
658
664
store. register_late_pass ( |_| Box :: new ( utils:: dump_hir:: DumpHir ) ) ;
659
665
store. register_late_pass ( |_| Box :: new ( utils:: author:: Author ) ) ;
660
666
store. register_late_pass ( move |_| {
@@ -696,13 +702,15 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
696
702
store. register_late_pass ( |_| Box :: new ( non_octal_unix_permissions:: NonOctalUnixPermissions ) ) ;
697
703
store. register_early_pass ( || Box :: new ( unnecessary_self_imports:: UnnecessarySelfImports ) ) ;
698
704
store. register_late_pass ( move |_| Box :: new ( approx_const:: ApproxConstant :: new ( msrv ( ) ) ) ) ;
705
+ let format_args = format_args_storage. clone ( ) ;
699
706
store. register_late_pass ( move |_| {
700
707
Box :: new ( methods:: Methods :: new (
701
708
avoid_breaking_exported_api,
702
709
msrv ( ) ,
703
710
allow_expect_in_tests,
704
711
allow_unwrap_in_tests,
705
712
allowed_dotfiles. clone ( ) ,
713
+ format_args. clone ( ) ,
706
714
) )
707
715
} ) ;
708
716
store. register_late_pass ( move |_| Box :: new ( matches:: Matches :: new ( msrv ( ) ) ) ) ;
@@ -766,7 +774,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
766
774
store. register_late_pass ( |_| Box :: < regex:: Regex > :: default ( ) ) ;
767
775
store. register_late_pass ( move |_| Box :: new ( copies:: CopyAndPaste :: new ( ignore_interior_mutability. clone ( ) ) ) ) ;
768
776
store. register_late_pass ( |_| Box :: new ( copy_iterator:: CopyIterator ) ) ;
769
- store. register_late_pass ( |_| Box :: new ( format:: UselessFormat ) ) ;
777
+ let format_args = format_args_storage. clone ( ) ;
778
+ store. register_late_pass ( move |_| Box :: new ( format:: UselessFormat :: new ( format_args. clone ( ) ) ) ) ;
770
779
store. register_late_pass ( |_| Box :: new ( swap:: Swap ) ) ;
771
780
store. register_late_pass ( |_| Box :: new ( overflow_check_conditional:: OverflowCheckConditional ) ) ;
772
781
store. register_late_pass ( |_| Box :: < new_without_default:: NewWithoutDefault > :: default ( ) ) ;
@@ -790,7 +799,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
790
799
store. register_late_pass ( |_| Box :: new ( partialeq_ne_impl:: PartialEqNeImpl ) ) ;
791
800
store. register_late_pass ( |_| Box :: new ( unused_io_amount:: UnusedIoAmount ) ) ;
792
801
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 ) ) ;
802
+ let format_args = format_args_storage. clone ( ) ;
803
+ store. register_late_pass ( move |_| Box :: new ( explicit_write:: ExplicitWrite :: new ( format_args. clone ( ) ) ) ) ;
794
804
store. register_late_pass ( |_| Box :: new ( needless_pass_by_value:: NeedlessPassByValue ) ) ;
795
805
store. register_late_pass ( move |tcx| {
796
806
Box :: new ( pass_by_ref_or_value:: PassByRefOrValue :: new (
@@ -832,7 +842,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
832
842
store. register_late_pass ( move |_| Box :: new ( mut_key:: MutableKeyType :: new ( ignore_interior_mutability. clone ( ) ) ) ) ;
833
843
store. register_early_pass ( || Box :: new ( reference:: DerefAddrOf ) ) ;
834
844
store. register_early_pass ( || Box :: new ( double_parens:: DoubleParens ) ) ;
835
- store. register_late_pass ( |_| Box :: new ( format_impl:: FormatImpl :: new ( ) ) ) ;
845
+ let format_args = format_args_storage. clone ( ) ;
846
+ store. register_late_pass ( move |_| Box :: new ( format_impl:: FormatImpl :: new ( format_args. clone ( ) ) ) ) ;
836
847
store. register_early_pass ( || Box :: new ( unsafe_removed_from_name:: UnsafeNameRemoval ) ) ;
837
848
store. register_early_pass ( || Box :: new ( else_if_without_else:: ElseIfWithoutElse ) ) ;
838
849
store. register_early_pass ( || Box :: new ( int_plus_one:: IntPlusOne ) ) ;
@@ -958,8 +969,14 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
958
969
accept_comment_above_attributes,
959
970
) )
960
971
} ) ;
961
- store
962
- . register_late_pass ( move |_| Box :: new ( format_args:: FormatArgs :: new ( msrv ( ) , allow_mixed_uninlined_format_args) ) ) ;
972
+ let format_args = format_args_storage. clone ( ) ;
973
+ store. register_late_pass ( move |_| {
974
+ Box :: new ( format_args:: FormatArgs :: new (
975
+ format_args. clone ( ) ,
976
+ msrv ( ) ,
977
+ allow_mixed_uninlined_format_args,
978
+ ) )
979
+ } ) ;
963
980
store. register_late_pass ( |_| Box :: new ( trailing_empty_array:: TrailingEmptyArray ) ) ;
964
981
store. register_early_pass ( || Box :: new ( octal_escapes:: OctalEscapes ) ) ;
965
982
store. register_late_pass ( |_| Box :: new ( needless_late_init:: NeedlessLateInit ) ) ;
@@ -970,7 +987,8 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
970
987
store. register_late_pass ( |_| Box :: new ( default_union_representation:: DefaultUnionRepresentation ) ) ;
971
988
store. register_late_pass ( |_| Box :: < only_used_in_recursion:: OnlyUsedInRecursion > :: default ( ) ) ;
972
989
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) ) ) ;
990
+ let format_args = format_args_storage. clone ( ) ;
991
+ store. register_late_pass ( move |_| Box :: new ( write:: Write :: new ( format_args. clone ( ) , allow_print_in_tests) ) ) ;
974
992
store. register_late_pass ( move |_| {
975
993
Box :: new ( cargo:: Cargo {
976
994
ignore_publish : cargo_ignore_publish,
0 commit comments