@@ -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
///
@@ -615,6 +614,14 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
615
614
}
616
615
}
617
616
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
+
618
625
// all the internal lints
619
626
#[ cfg( feature = "internal" ) ]
620
627
{
@@ -655,7 +662,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
655
662
. collect ( ) ,
656
663
) )
657
664
} ) ;
658
- store. register_early_pass ( || Box :: < utils:: format_args_collector:: FormatArgsCollector > :: default ( ) ) ;
659
665
store. register_late_pass ( |_| Box :: new ( utils:: dump_hir:: DumpHir ) ) ;
660
666
store. register_late_pass ( |_| Box :: new ( utils:: author:: Author ) ) ;
661
667
store. register_late_pass ( move |_| {
@@ -697,13 +703,15 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
697
703
store. register_late_pass ( |_| Box :: new ( non_octal_unix_permissions:: NonOctalUnixPermissions ) ) ;
698
704
store. register_early_pass ( || Box :: new ( unnecessary_self_imports:: UnnecessarySelfImports ) ) ;
699
705
store. register_late_pass ( move |_| Box :: new ( approx_const:: ApproxConstant :: new ( msrv ( ) ) ) ) ;
706
+ let format_args = format_args_storage. clone ( ) ;
700
707
store. register_late_pass ( move |_| {
701
708
Box :: new ( methods:: Methods :: new (
702
709
avoid_breaking_exported_api,
703
710
msrv ( ) ,
704
711
allow_expect_in_tests,
705
712
allow_unwrap_in_tests,
706
713
allowed_dotfiles. clone ( ) ,
714
+ format_args. clone ( ) ,
707
715
) )
708
716
} ) ;
709
717
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) {
768
776
store. register_late_pass ( |_| Box :: < regex:: Regex > :: default ( ) ) ;
769
777
store. register_late_pass ( move |_| Box :: new ( copies:: CopyAndPaste :: new ( ignore_interior_mutability. clone ( ) ) ) ) ;
770
778
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 ( ) ) ) ) ;
772
781
store. register_late_pass ( |_| Box :: new ( swap:: Swap ) ) ;
773
782
store. register_late_pass ( |_| Box :: new ( overflow_check_conditional:: OverflowCheckConditional ) ) ;
774
783
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) {
792
801
store. register_late_pass ( |_| Box :: new ( partialeq_ne_impl:: PartialEqNeImpl ) ) ;
793
802
store. register_late_pass ( |_| Box :: new ( unused_io_amount:: UnusedIoAmount ) ) ;
794
803
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 ( ) ) ) ) ;
796
806
store. register_late_pass ( |_| Box :: new ( needless_pass_by_value:: NeedlessPassByValue ) ) ;
797
807
store. register_late_pass ( move |tcx| {
798
808
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) {
834
844
store. register_late_pass ( move |_| Box :: new ( mut_key:: MutableKeyType :: new ( ignore_interior_mutability. clone ( ) ) ) ) ;
835
845
store. register_early_pass ( || Box :: new ( reference:: DerefAddrOf ) ) ;
836
846
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 ( ) ) ) ) ;
838
849
store. register_early_pass ( || Box :: new ( unsafe_removed_from_name:: UnsafeNameRemoval ) ) ;
839
850
store. register_early_pass ( || Box :: new ( else_if_without_else:: ElseIfWithoutElse ) ) ;
840
851
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) {
960
971
accept_comment_above_attributes,
961
972
) )
962
973
} ) ;
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
+ } ) ;
965
982
store. register_late_pass ( |_| Box :: new ( trailing_empty_array:: TrailingEmptyArray ) ) ;
966
983
store. register_early_pass ( || Box :: new ( octal_escapes:: OctalEscapes ) ) ;
967
984
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) {
972
989
store. register_late_pass ( |_| Box :: new ( default_union_representation:: DefaultUnionRepresentation ) ) ;
973
990
store. register_late_pass ( |_| Box :: < only_used_in_recursion:: OnlyUsedInRecursion > :: default ( ) ) ;
974
991
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) ) ) ;
976
994
store. register_late_pass ( move |_| {
977
995
Box :: new ( cargo:: Cargo {
978
996
ignore_publish : cargo_ignore_publish,
0 commit comments