@@ -18,7 +18,7 @@ use crate::Locator;
18
18
use crate :: codes:: NoqaCode ;
19
19
use crate :: fs:: relativize_path;
20
20
use crate :: message:: OldDiagnostic ;
21
- use crate :: registry:: { Rule , RuleSet } ;
21
+ use crate :: registry:: Rule ;
22
22
use crate :: rule_redirects:: get_redirect_target;
23
23
24
24
/// Generates an array of edits that matches the length of `messages`.
@@ -780,7 +780,7 @@ fn build_noqa_edits_by_diagnostic(
780
780
if let Some ( noqa_edit) = generate_noqa_edit (
781
781
comment. directive ,
782
782
comment. line ,
783
- RuleSet :: from_rule ( comment. rule ) ,
783
+ vec ! [ comment. rule] ,
784
784
locator,
785
785
line_ending,
786
786
) {
@@ -829,7 +829,7 @@ fn build_noqa_edits_by_line<'a>(
829
829
830
830
struct NoqaComment < ' a > {
831
831
line : TextSize ,
832
- rule : Rule ,
832
+ rule : NoqaCode ,
833
833
directive : Option < & ' a Directive < ' a > > ,
834
834
}
835
835
@@ -845,13 +845,11 @@ fn find_noqa_comments<'a>(
845
845
846
846
// Mark any non-ignored diagnostics.
847
847
for message in diagnostics {
848
- let Some ( rule) = message. to_rule ( ) else {
848
+ let Some ( rule) = message. to_noqa_code ( ) else {
849
849
comments_by_line. push ( None ) ;
850
850
continue ;
851
851
} ;
852
852
853
- let code = rule. noqa_code ( ) ;
854
-
855
853
match & exemption {
856
854
FileExemption :: All ( _) => {
857
855
// If the file is exempted, don't add any noqa directives.
@@ -860,7 +858,7 @@ fn find_noqa_comments<'a>(
860
858
}
861
859
FileExemption :: Codes ( codes) => {
862
860
// If the diagnostic is ignored by a global exemption, don't add a noqa directive.
863
- if codes. contains ( & & code ) {
861
+ if codes. contains ( & & rule ) {
864
862
comments_by_line. push ( None ) ;
865
863
continue ;
866
864
}
@@ -878,7 +876,7 @@ fn find_noqa_comments<'a>(
878
876
continue ;
879
877
}
880
878
Directive :: Codes ( codes) => {
881
- if codes. includes ( code ) {
879
+ if codes. includes ( rule ) {
882
880
comments_by_line. push ( None ) ;
883
881
continue ;
884
882
}
@@ -897,7 +895,7 @@ fn find_noqa_comments<'a>(
897
895
continue ;
898
896
}
899
897
directive @ Directive :: Codes ( codes) => {
900
- if !codes. includes ( code ) {
898
+ if !codes. includes ( rule ) {
901
899
comments_by_line. push ( Some ( NoqaComment {
902
900
line : directive_line. start ( ) ,
903
901
rule,
@@ -922,7 +920,7 @@ fn find_noqa_comments<'a>(
922
920
923
921
struct NoqaEdit < ' a > {
924
922
edit_range : TextRange ,
925
- rules : RuleSet ,
923
+ rules : Vec < NoqaCode > ,
926
924
codes : Option < & ' a Codes < ' a > > ,
927
925
line_ending : LineEnding ,
928
926
}
@@ -943,16 +941,13 @@ impl NoqaEdit<'_> {
943
941
writer,
944
942
self . rules
945
943
. iter ( )
946
- . map ( |rule| rule . noqa_code ( ) . to_string ( ) )
944
+ . map ( ToString :: to_string)
947
945
. chain ( codes. iter ( ) . map ( ToString :: to_string) )
948
946
. sorted_unstable ( ) ,
949
947
) ;
950
948
}
951
949
None => {
952
- push_codes (
953
- writer,
954
- self . rules . iter ( ) . map ( |rule| rule. noqa_code ( ) . to_string ( ) ) ,
955
- ) ;
950
+ push_codes ( writer, self . rules . iter ( ) . map ( ToString :: to_string) ) ;
956
951
}
957
952
}
958
953
write ! ( writer, "{}" , self . line_ending. as_str( ) ) . unwrap ( ) ;
@@ -968,7 +963,7 @@ impl Ranged for NoqaEdit<'_> {
968
963
fn generate_noqa_edit < ' a > (
969
964
directive : Option < & ' a Directive > ,
970
965
offset : TextSize ,
971
- rules : RuleSet ,
966
+ rules : Vec < NoqaCode > ,
972
967
locator : & Locator ,
973
968
line_ending : LineEnding ,
974
969
) -> Option < NoqaEdit < ' a > > {
0 commit comments