Skip to content

Commit 825561d

Browse files
feat: remove report_fixme option
1 parent 4c8db85 commit 825561d

File tree

5 files changed

+19
-83
lines changed

5 files changed

+19
-83
lines changed

Diff for: Configurations.md

-12
Original file line numberDiff line numberDiff line change
@@ -2168,18 +2168,6 @@ mod sit;
21682168
**Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantics
21692169
of the original source code.
21702170

2171-
## `report_fixme`
2172-
2173-
Report `FIXME` items in comments.
2174-
2175-
- **Default value**: `"Never"`
2176-
- **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
2177-
- **Stable**: No (tracking issue: [#3394](https://github.com/rust-lang/rustfmt/issues/3394))
2178-
2179-
Warns about any comments containing `FIXME` in them when set to `"Always"`. If
2180-
it contains a `#X` (with `X` being a number) in parentheses following the
2181-
`FIXME`, `"Unnumbered"` will ignore it.
2182-
21832171
## `required_version`
21842172

21852173
Require a specific version of rustfmt. If you want to make sure that the

Diff for: src/config/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ create_config! {
164164
error_on_unformatted: bool, false, false,
165165
"Error if unable to get comments or string literals within max_width, \
166166
or they are left with trailing whitespaces";
167-
report_fixme: ReportTactic, ReportTactic::Never, false,
168-
"Report all, none or unnumbered occurrences of FIXME in source file comments";
169167
ignore: IgnoreList, IgnoreList::default(), false,
170168
"Skip formatting the specified files and directories";
171169

@@ -623,7 +621,6 @@ skip_children = false
623621
hide_parse_errors = false
624622
error_on_line_overflow = false
625623
error_on_unformatted = false
626-
report_fixme = "Never"
627624
ignore = []
628625
emit_mode = "Files"
629626
make_backup = false

Diff for: src/formatting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ impl<'a> FormatLines<'a> {
497497
skipped_range: &'a [(usize, usize)],
498498
config: &'a Config,
499499
) -> FormatLines<'a> {
500-
let issue_seeker = BadIssueSeeker::new(config.report_fixme());
500+
let issue_seeker = BadIssueSeeker::new();
501501
FormatLines {
502502
name,
503503
skipped_range,

Diff for: src/issues.rs

+18-66
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ use std::fmt;
66

77
use 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
1311
fn is_enabled(report_tactic: ReportTactic) -> bool {
@@ -16,7 +14,7 @@ fn is_enabled(report_tactic: ReportTactic) -> bool {
1614

1715
#[derive(Clone, Copy)]
1816
enum 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)]
3230
pub 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 {
3937
impl 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

5955
enum IssueClassification {
6056
Good,
@@ -64,27 +60,25 @@ enum IssueClassification {
6460

6561
pub(crate) struct BadIssueSeeker {
6662
state: Seeking,
67-
report_fixme: ReportTactic,
6863
}
6964

7065
impl 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]
176155
fn 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\n22)\n", 9);
197-
check_pass("FIXME(@maintainer, #1222, hello)\n");
198168
}
199169

200170
#[test]
201171
fn 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]
218179
fn 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
}

Diff for: tests/config/small_tabs.toml

-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ brace_style = "SameLineWhere"
66
fn_args_layout = "Tall"
77
trailing_comma = "Vertical"
88
indent_style = "Block"
9-
report_fixme = "Never"
109
reorder_imports = false
1110
format_strings = true

0 commit comments

Comments
 (0)