Skip to content

Commit 4c8db85

Browse files
feat: remove report_todo option
1 parent 3e38399 commit 4c8db85

File tree

6 files changed

+20
-120
lines changed

6 files changed

+20
-120
lines changed

Diff for: Configurations.md

-17
Original file line numberDiff line numberDiff line change
@@ -2180,23 +2180,6 @@ Warns about any comments containing `FIXME` in them when set to `"Always"`. If
21802180
it contains a `#X` (with `X` being a number) in parentheses following the
21812181
`FIXME`, `"Unnumbered"` will ignore it.
21822182

2183-
See also [`report_todo`](#report_todo).
2184-
2185-
2186-
## `report_todo`
2187-
2188-
Report `TODO` items in comments.
2189-
2190-
- **Default value**: `"Never"`
2191-
- **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
2192-
- **Stable**: No (tracking issue: [#3393](https://github.com/rust-lang/rustfmt/issues/3393))
2193-
2194-
Warns about any comments containing `TODO` in them when set to `"Always"`. If
2195-
it contains a `#X` (with `X` being a number) in parentheses following the
2196-
`TODO`, `"Unnumbered"` will ignore it.
2197-
2198-
See also [`report_fixme`](#report_fixme).
2199-
22002183
## `required_version`
22012184

22022185
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_todo: ReportTactic, ReportTactic::Never, false,
168-
"Report all, none or unnumbered occurrences of TODO in source file comments";
169167
report_fixme: ReportTactic, ReportTactic::Never, false,
170168
"Report all, none or unnumbered occurrences of FIXME in source file comments";
171169
ignore: IgnoreList, IgnoreList::default(), false,
@@ -625,7 +623,6 @@ skip_children = false
625623
hide_parse_errors = false
626624
error_on_line_overflow = false
627625
error_on_unformatted = false
628-
report_todo = "Never"
629626
report_fixme = "Never"
630627
ignore = []
631628
emit_mode = "Files"

Diff for: src/formatting.rs

+2-2
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_todo(), config.report_fixme());
500+
let issue_seeker = BadIssueSeeker::new(config.report_fixme());
501501
FormatLines {
502502
name,
503503
skipped_range,
@@ -537,7 +537,7 @@ impl<'a> FormatLines<'a> {
537537
}
538538

539539
if self.allow_issue_seek && self.format_line {
540-
// Add warnings for bad todos/ fixmes
540+
// Add warnings for bad fixmes
541541
if let Some(issue) = self.issue_seeker.inspect(c) {
542542
self.push_err(ErrorKind::BadIssue(issue), false, false);
543543
}

Diff for: src/issues.rs

+17-93
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::fmt;
66

77
use crate::config::ReportTactic;
88

9-
const TO_DO_CHARS: &[char] = &['t', 'o', 'd', 'o'];
109
const FIX_ME_CHARS: &[char] = &['f', 'i', 'x', 'm', 'e'];
1110

1211
// Enabled implementation detail is here because it is
@@ -17,7 +16,7 @@ fn is_enabled(report_tactic: ReportTactic) -> bool {
1716

1817
#[derive(Clone, Copy)]
1918
enum Seeking {
20-
Issue { todo_idx: usize, fixme_idx: usize },
19+
Issue { fixme_idx: usize },
2120
Number { issue: Issue, part: NumberPart },
2221
}
2322

@@ -40,7 +39,6 @@ pub struct Issue {
4039
impl fmt::Display for Issue {
4140
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
4241
let msg = match self.issue_type {
43-
IssueType::Todo => "TODO",
4442
IssueType::Fixme => "FIXME",
4543
};
4644
let details = if self.missing_number {
@@ -55,7 +53,6 @@ impl fmt::Display for Issue {
5553

5654
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
5755
enum IssueType {
58-
Todo,
5956
Fixme,
6057
}
6158

@@ -67,35 +64,27 @@ enum IssueClassification {
6764

6865
pub(crate) struct BadIssueSeeker {
6966
state: Seeking,
70-
report_todo: ReportTactic,
7167
report_fixme: ReportTactic,
7268
}
7369

7470
impl BadIssueSeeker {
75-
pub(crate) fn new(report_todo: ReportTactic, report_fixme: ReportTactic) -> BadIssueSeeker {
71+
pub(crate) fn new(report_fixme: ReportTactic) -> BadIssueSeeker {
7672
BadIssueSeeker {
77-
state: Seeking::Issue {
78-
todo_idx: 0,
79-
fixme_idx: 0,
80-
},
81-
report_todo,
73+
state: Seeking::Issue { fixme_idx: 0 },
8274
report_fixme,
8375
}
8476
}
8577

8678
pub(crate) fn is_disabled(&self) -> bool {
87-
!is_enabled(self.report_todo) && !is_enabled(self.report_fixme)
79+
!is_enabled(self.report_fixme)
8880
}
8981

9082
// Check whether or not the current char is conclusive evidence for an
9183
// unnumbered TO-DO or FIX-ME.
9284
pub(crate) fn inspect(&mut self, c: char) -> Option<Issue> {
9385
match self.state {
94-
Seeking::Issue {
95-
todo_idx,
96-
fixme_idx,
97-
} => {
98-
self.state = self.inspect_issue(c, todo_idx, fixme_idx);
86+
Seeking::Issue { fixme_idx } => {
87+
self.state = self.inspect_issue(c, fixme_idx);
9988
}
10089
Seeking::Number { issue, part } => {
10190
let result = self.inspect_number(c, issue, part);
@@ -104,10 +93,7 @@ impl BadIssueSeeker {
10493
return None;
10594
}
10695

107-
self.state = Seeking::Issue {
108-
todo_idx: 0,
109-
fixme_idx: 0,
110-
};
96+
self.state = Seeking::Issue { fixme_idx: 0 };
11197

11298
if let IssueClassification::Bad(issue) = result {
11399
return Some(issue);
@@ -118,21 +104,9 @@ impl BadIssueSeeker {
118104
None
119105
}
120106

121-
fn inspect_issue(&mut self, c: char, mut todo_idx: usize, mut fixme_idx: usize) -> Seeking {
107+
fn inspect_issue(&mut self, c: char, mut fixme_idx: usize) -> Seeking {
122108
if let Some(lower_case_c) = c.to_lowercase().next() {
123-
if is_enabled(self.report_todo) && lower_case_c == TO_DO_CHARS[todo_idx] {
124-
todo_idx += 1;
125-
if todo_idx == TO_DO_CHARS.len() {
126-
return Seeking::Number {
127-
issue: Issue {
128-
issue_type: IssueType::Todo,
129-
missing_number: matches!(self.report_todo, ReportTactic::Unnumbered),
130-
},
131-
part: NumberPart::OpenParen,
132-
};
133-
}
134-
fixme_idx = 0;
135-
} else if is_enabled(self.report_fixme) && lower_case_c == FIX_ME_CHARS[fixme_idx] {
109+
if is_enabled(self.report_fixme) && lower_case_c == FIX_ME_CHARS[fixme_idx] {
136110
// Exploit the fact that the character sets of todo and fixme
137111
// are disjoint by adding else.
138112
fixme_idx += 1;
@@ -145,17 +119,12 @@ impl BadIssueSeeker {
145119
part: NumberPart::OpenParen,
146120
};
147121
}
148-
todo_idx = 0;
149122
} else {
150-
todo_idx = 0;
151123
fixme_idx = 0;
152124
}
153125
}
154126

155-
Seeking::Issue {
156-
todo_idx,
157-
fixme_idx,
158-
}
127+
Seeking::Issue { fixme_idx }
159128
}
160129

161130
fn inspect_number(
@@ -206,20 +175,18 @@ impl BadIssueSeeker {
206175
#[test]
207176
fn find_unnumbered_issue() {
208177
fn check_fail(text: &str, failing_pos: usize) {
209-
let mut seeker = BadIssueSeeker::new(ReportTactic::Unnumbered, ReportTactic::Unnumbered);
178+
let mut seeker = BadIssueSeeker::new(ReportTactic::Unnumbered);
210179
assert_eq!(
211180
Some(failing_pos),
212181
text.find(|c| seeker.inspect(c).is_some())
213182
);
214183
}
215184

216185
fn check_pass(text: &str) {
217-
let mut seeker = BadIssueSeeker::new(ReportTactic::Unnumbered, ReportTactic::Unnumbered);
186+
let mut seeker = BadIssueSeeker::new(ReportTactic::Unnumbered);
218187
assert_eq!(None, text.find(|c| seeker.inspect(c).is_some()));
219188
}
220189

221-
check_fail("TODO\n", 4);
222-
check_pass(" TO FIX DOME\n");
223190
check_fail(" \n FIXME\n", 8);
224191
check_fail("FIXME(\n", 6);
225192
check_fail("FIXME(#\n", 7);
@@ -228,71 +195,28 @@ fn find_unnumbered_issue() {
228195
check_pass("FIXME(#1222)\n");
229196
check_fail("FIXME(#12\n22)\n", 9);
230197
check_pass("FIXME(@maintainer, #1222, hello)\n");
231-
check_fail("TODO(#22) FIXME\n", 15);
232198
}
233199

234200
#[test]
235201
fn find_issue() {
236-
fn is_bad_issue(text: &str, report_todo: ReportTactic, report_fixme: ReportTactic) -> bool {
237-
let mut seeker = BadIssueSeeker::new(report_todo, report_fixme);
202+
fn is_bad_issue(text: &str, report_fixme: ReportTactic) -> bool {
203+
let mut seeker = BadIssueSeeker::new(report_fixme);
238204
text.chars().any(|c| seeker.inspect(c).is_some())
239205
}
240206

241-
assert!(is_bad_issue(
242-
"TODO(@maintainer, #1222, hello)\n",
243-
ReportTactic::Always,
244-
ReportTactic::Never,
245-
));
246-
247-
assert!(!is_bad_issue(
248-
"TODO: no number\n",
249-
ReportTactic::Never,
250-
ReportTactic::Always,
251-
));
252-
253-
assert!(!is_bad_issue(
254-
"Todo: mixed case\n",
255-
ReportTactic::Never,
256-
ReportTactic::Always,
257-
));
258-
259-
assert!(is_bad_issue(
260-
"This is a FIXME(#1)\n",
261-
ReportTactic::Never,
262-
ReportTactic::Always,
263-
));
207+
assert!(is_bad_issue("This is a FIXME(#1)\n", ReportTactic::Always));
264208

265209
assert!(is_bad_issue(
266210
"This is a FixMe(#1) mixed case\n",
267-
ReportTactic::Never,
268211
ReportTactic::Always,
269212
));
270213

271-
assert!(!is_bad_issue(
272-
"bad FIXME\n",
273-
ReportTactic::Always,
274-
ReportTactic::Never,
275-
));
214+
assert!(!is_bad_issue("bad FIXME\n", ReportTactic::Never));
276215
}
277216

278217
#[test]
279218
fn issue_type() {
280-
let mut seeker = BadIssueSeeker::new(ReportTactic::Always, ReportTactic::Never);
281-
let expected = Some(Issue {
282-
issue_type: IssueType::Todo,
283-
missing_number: false,
284-
});
285-
286-
assert_eq!(
287-
expected,
288-
"TODO(#100): more awesomeness"
289-
.chars()
290-
.map(|c| seeker.inspect(c))
291-
.find(Option::is_some)
292-
.unwrap()
293-
);
294-
295-
let mut seeker = BadIssueSeeker::new(ReportTactic::Never, ReportTactic::Unnumbered);
219+
let mut seeker = BadIssueSeeker::new(ReportTactic::Unnumbered);
296220
let expected = Some(Issue {
297221
issue_type: IssueType::Fixme,
298222
missing_number: true,

Diff for: src/test/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::process::{Command, Stdio};
99
use std::str::Chars;
1010
use std::thread;
1111

12-
use crate::config::{Color, Config, EmitMode, FileName, NewlineStyle, ReportTactic};
12+
use crate::config::{Color, Config, EmitMode, FileName, NewlineStyle};
1313
use crate::formatting::{ReportedErrors, SourceFile};
1414
use crate::rustfmt_diff::{make_diff, print_diff, DiffLine, Mismatch, ModifiedChunk, OutputWriter};
1515
use crate::source_file;
@@ -688,9 +688,6 @@ fn read_config(filename: &Path) -> Config {
688688
}
689689
}
690690

691-
// Don't generate warnings for to-do items.
692-
config.set().report_todo(ReportTactic::Never);
693-
694691
config
695692
}
696693

Diff for: tests/config/small_tabs.toml

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

0 commit comments

Comments
 (0)