@@ -6,8 +6,6 @@ use std::fmt;
66
77use crate :: config:: ReportTactic ;
88
9- const FIX_ME_CHARS : & [ char ] = & [ 'f' , 'i' , 'x' , 'm' , 'e' ] ;
10-
119// Enabled implementation detail is here because it is
1210// irrelevant outside the issues module
1311fn is_enabled ( report_tactic : ReportTactic ) -> bool {
@@ -16,7 +14,7 @@ fn is_enabled(report_tactic: ReportTactic) -> bool {
1614
1715#[ derive( Clone , Copy ) ]
1816enum Seeking {
19- Issue { fixme_idx : usize } ,
17+ Issue { } ,
2018 Number { issue : Issue , part : NumberPart } ,
2119}
2220
@@ -30,7 +28,7 @@ enum NumberPart {
3028
3129#[ derive( PartialEq , Eq , Debug , Clone , Copy ) ]
3230pub struct Issue {
33- issue_type : IssueType ,
31+ issue_type : Option < IssueType > ,
3432 // Indicates whether we're looking for issues with missing numbers, or
3533 // all issues of this type.
3634 missing_number : bool ,
@@ -39,7 +37,7 @@ pub struct Issue {
3937impl fmt:: Display for Issue {
4038 fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> Result < ( ) , fmt:: Error > {
4139 let msg = match self . issue_type {
42- IssueType :: Fixme => "FIXME " ,
40+ _ => "" ,
4341 } ;
4442 let details = if self . missing_number {
4543 " without issue number"
@@ -52,9 +50,7 @@ impl fmt::Display for Issue {
5250}
5351
5452#[ derive( PartialEq , Eq , Debug , Clone , Copy ) ]
55- enum IssueType {
56- Fixme ,
57- }
53+ enum IssueType { }
5854
5955enum IssueClassification {
6056 Good ,
@@ -64,27 +60,25 @@ enum IssueClassification {
6460
6561pub ( crate ) struct BadIssueSeeker {
6662 state : Seeking ,
67- report_fixme : ReportTactic ,
6863}
6964
7065impl BadIssueSeeker {
71- pub ( crate ) fn new ( report_fixme : ReportTactic ) -> BadIssueSeeker {
66+ pub ( crate ) fn new ( ) -> BadIssueSeeker {
7267 BadIssueSeeker {
73- state : Seeking :: Issue { fixme_idx : 0 } ,
74- report_fixme,
68+ state : Seeking :: Issue { } ,
7569 }
7670 }
7771
7872 pub ( crate ) fn is_disabled ( & self ) -> bool {
79- ! is_enabled ( self . report_fixme )
73+ true
8074 }
8175
8276 // Check whether or not the current char is conclusive evidence for an
8377 // unnumbered TO-DO or FIX-ME.
8478 pub ( crate ) fn inspect ( & mut self , c : char ) -> Option < Issue > {
8579 match self . state {
86- Seeking :: Issue { fixme_idx } => {
87- self . state = self . inspect_issue ( c, fixme_idx ) ;
80+ Seeking :: Issue { } => {
81+ self . state = self . inspect_issue ( c, 0 ) ;
8882 }
8983 Seeking :: Number { issue, part } => {
9084 let result = self . inspect_number ( c, issue, part) ;
@@ -93,7 +87,7 @@ impl BadIssueSeeker {
9387 return None ;
9488 }
9589
96- self . state = Seeking :: Issue { fixme_idx : 0 } ;
90+ self . state = Seeking :: Issue { } ;
9791
9892 if let IssueClassification :: Bad ( issue) = result {
9993 return Some ( issue) ;
@@ -106,25 +100,10 @@ impl BadIssueSeeker {
106100
107101 fn inspect_issue ( & mut self , c : char , mut fixme_idx : usize ) -> Seeking {
108102 if let Some ( lower_case_c) = c. to_lowercase ( ) . next ( ) {
109- if is_enabled ( self . report_fixme ) && lower_case_c == FIX_ME_CHARS [ fixme_idx] {
110- // Exploit the fact that the character sets of todo and fixme
111- // are disjoint by adding else.
112- fixme_idx += 1 ;
113- if fixme_idx == FIX_ME_CHARS . len ( ) {
114- return Seeking :: Number {
115- issue : Issue {
116- issue_type : IssueType :: Fixme ,
117- missing_number : matches ! ( self . report_fixme, ReportTactic :: Unnumbered ) ,
118- } ,
119- part : NumberPart :: OpenParen ,
120- } ;
121- }
122- } else {
123- fixme_idx = 0 ;
124- }
103+ fixme_idx = 0 ;
125104 }
126105
127- Seeking :: Issue { fixme_idx }
106+ Seeking :: Issue { }
128107 }
129108
130109 fn inspect_number (
@@ -175,59 +154,32 @@ impl BadIssueSeeker {
175154#[ test]
176155fn find_unnumbered_issue ( ) {
177156 fn check_fail ( text : & str , failing_pos : usize ) {
178- let mut seeker = BadIssueSeeker :: new ( ReportTactic :: Unnumbered ) ;
157+ let mut seeker = BadIssueSeeker :: new ( ) ;
179158 assert_eq ! (
180159 Some ( failing_pos) ,
181160 text. find( |c| seeker. inspect( c) . is_some( ) )
182161 ) ;
183162 }
184163
185164 fn check_pass ( text : & str ) {
186- let mut seeker = BadIssueSeeker :: new ( ReportTactic :: Unnumbered ) ;
165+ let mut seeker = BadIssueSeeker :: new ( ) ;
187166 assert_eq ! ( None , text. find( |c| seeker. inspect( c) . is_some( ) ) ) ;
188167 }
189-
190- check_fail ( " \n FIXME\n " , 8 ) ;
191- check_fail ( "FIXME(\n " , 6 ) ;
192- check_fail ( "FIXME(#\n " , 7 ) ;
193- check_fail ( "FIXME(#1\n " , 8 ) ;
194- check_fail ( "FIXME(#)1\n " , 7 ) ;
195- check_pass ( "FIXME(#1222)\n " ) ;
196- check_fail ( "FIXME(#12\n 22)\n " , 9 ) ;
197- check_pass ( "FIXME(@maintainer, #1222, hello)\n " ) ;
198168}
199169
200170#[ test]
201171fn find_issue ( ) {
202- fn is_bad_issue ( text : & str , report_fixme : ReportTactic ) -> bool {
203- let mut seeker = BadIssueSeeker :: new ( report_fixme ) ;
172+ fn is_bad_issue ( text : & str ) -> bool {
173+ let mut seeker = BadIssueSeeker :: new ( ) ;
204174 text. chars ( ) . any ( |c| seeker. inspect ( c) . is_some ( ) )
205175 }
206-
207- assert ! ( is_bad_issue( "This is a FIXME(#1)\n " , ReportTactic :: Always ) ) ;
208-
209- assert ! ( is_bad_issue(
210- "This is a FixMe(#1) mixed case\n " ,
211- ReportTactic :: Always ,
212- ) ) ;
213-
214- assert ! ( !is_bad_issue( "bad FIXME\n " , ReportTactic :: Never ) ) ;
215176}
216177
217178#[ test]
218179fn issue_type ( ) {
219- let mut seeker = BadIssueSeeker :: new ( ReportTactic :: Unnumbered ) ;
180+ let seeker = BadIssueSeeker :: new ( ) ;
220181 let expected = Some ( Issue {
221- issue_type : IssueType :: Fixme ,
182+ issue_type : None ,
222183 missing_number : true ,
223184 } ) ;
224-
225- assert_eq ! (
226- expected,
227- "Test. FIXME: bad, bad, not good"
228- . chars( )
229- . map( |c| seeker. inspect( c) )
230- . find( Option :: is_some)
231- . unwrap( )
232- ) ;
233185}
0 commit comments