@@ -18,7 +18,7 @@ use crate::Locator;
1818use crate :: codes:: NoqaCode ;
1919use crate :: fs:: relativize_path;
2020use crate :: message:: OldDiagnostic ;
21- use crate :: registry:: { Rule , RuleSet } ;
21+ use crate :: registry:: Rule ;
2222use crate :: rule_redirects:: get_redirect_target;
2323
2424/// Generates an array of edits that matches the length of `messages`.
@@ -780,7 +780,7 @@ fn build_noqa_edits_by_diagnostic(
780780 if let Some ( noqa_edit) = generate_noqa_edit (
781781 comment. directive ,
782782 comment. line ,
783- RuleSet :: from_rule ( comment. rule ) ,
783+ vec ! [ comment. rule] ,
784784 locator,
785785 line_ending,
786786 ) {
@@ -829,7 +829,7 @@ fn build_noqa_edits_by_line<'a>(
829829
830830struct NoqaComment < ' a > {
831831 line : TextSize ,
832- rule : Rule ,
832+ rule : NoqaCode ,
833833 directive : Option < & ' a Directive < ' a > > ,
834834}
835835
@@ -845,13 +845,11 @@ fn find_noqa_comments<'a>(
845845
846846 // Mark any non-ignored diagnostics.
847847 for message in diagnostics {
848- let Some ( rule) = message. to_rule ( ) else {
848+ let Some ( rule) = message. to_noqa_code ( ) else {
849849 comments_by_line. push ( None ) ;
850850 continue ;
851851 } ;
852852
853- let code = rule. noqa_code ( ) ;
854-
855853 match & exemption {
856854 FileExemption :: All ( _) => {
857855 // If the file is exempted, don't add any noqa directives.
@@ -860,7 +858,7 @@ fn find_noqa_comments<'a>(
860858 }
861859 FileExemption :: Codes ( codes) => {
862860 // 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 ) {
864862 comments_by_line. push ( None ) ;
865863 continue ;
866864 }
@@ -878,7 +876,7 @@ fn find_noqa_comments<'a>(
878876 continue ;
879877 }
880878 Directive :: Codes ( codes) => {
881- if codes. includes ( code ) {
879+ if codes. includes ( rule ) {
882880 comments_by_line. push ( None ) ;
883881 continue ;
884882 }
@@ -897,7 +895,7 @@ fn find_noqa_comments<'a>(
897895 continue ;
898896 }
899897 directive @ Directive :: Codes ( codes) => {
900- if !codes. includes ( code ) {
898+ if !codes. includes ( rule ) {
901899 comments_by_line. push ( Some ( NoqaComment {
902900 line : directive_line. start ( ) ,
903901 rule,
@@ -922,7 +920,7 @@ fn find_noqa_comments<'a>(
922920
923921struct NoqaEdit < ' a > {
924922 edit_range : TextRange ,
925- rules : RuleSet ,
923+ rules : Vec < NoqaCode > ,
926924 codes : Option < & ' a Codes < ' a > > ,
927925 line_ending : LineEnding ,
928926}
@@ -943,16 +941,13 @@ impl NoqaEdit<'_> {
943941 writer,
944942 self . rules
945943 . iter ( )
946- . map ( |rule| rule . noqa_code ( ) . to_string ( ) )
944+ . map ( ToString :: to_string)
947945 . chain ( codes. iter ( ) . map ( ToString :: to_string) )
948946 . sorted_unstable ( ) ,
949947 ) ;
950948 }
951949 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) ) ;
956951 }
957952 }
958953 write ! ( writer, "{}" , self . line_ending. as_str( ) ) . unwrap ( ) ;
@@ -968,7 +963,7 @@ impl Ranged for NoqaEdit<'_> {
968963fn generate_noqa_edit < ' a > (
969964 directive : Option < & ' a Directive > ,
970965 offset : TextSize ,
971- rules : RuleSet ,
966+ rules : Vec < NoqaCode > ,
972967 locator : & Locator ,
973968 line_ending : LineEnding ,
974969) -> Option < NoqaEdit < ' a > > {
0 commit comments