]> git.lizzy.rs Git - rust.git/commitdiff
feat: remove report_fixme option
authorCaleb Cartwright <caleb.cartwright@outlook.com>
Mon, 30 May 2022 02:48:59 +0000 (21:48 -0500)
committerCaleb Cartwright <calebcartwright@users.noreply.github.com>
Mon, 30 May 2022 13:56:09 +0000 (08:56 -0500)
Configurations.md
src/config/mod.rs
src/formatting.rs
src/issues.rs
tests/config/small_tabs.toml

index 72499618755e9a2fb40f3f4d902fb55d8a0a6637..edb2d1f757518fe886525283fed9562acae1db6d 100644 (file)
@@ -2168,18 +2168,6 @@ mod sit;
 **Note** `mod` with `#[macro_export]` will not be reordered since that could change the semantics
 of the original source code.
 
-## `report_fixme`
-
-Report `FIXME` items in comments.
-
-- **Default value**: `"Never"`
-- **Possible values**: `"Always"`, `"Unnumbered"`, `"Never"`
-- **Stable**: No (tracking issue: [#3394](https://github.com/rust-lang/rustfmt/issues/3394))
-
-Warns about any comments containing `FIXME` in them when set to `"Always"`. If
-it contains a `#X` (with `X` being a number) in parentheses following the
-`FIXME`, `"Unnumbered"` will ignore it.
-
 ## `required_version`
 
 Require a specific version of rustfmt. If you want to make sure that the
index 4c14d7356891d561d52562bf060eb568dd7ab083..fc724beae60a7ab0c8d99ce01fac25c7558bace6 100644 (file)
     error_on_unformatted: bool, false, false,
         "Error if unable to get comments or string literals within max_width, \
          or they are left with trailing whitespaces";
-    report_fixme: ReportTactic, ReportTactic::Never, false,
-        "Report all, none or unnumbered occurrences of FIXME in source file comments";
     ignore: IgnoreList, IgnoreList::default(), false,
         "Skip formatting the specified files and directories";
 
@@ -623,7 +621,6 @@ fn test_dump_default_config() {
 hide_parse_errors = false
 error_on_line_overflow = false
 error_on_unformatted = false
-report_fixme = "Never"
 ignore = []
 emit_mode = "Files"
 make_backup = false
index 8e6999643b1e5906adb65ad22505c93b3567f220..72bbe240f7b9c9d7c5d13763251ae6a07369d2fd 100644 (file)
@@ -497,7 +497,7 @@ fn new(
         skipped_range: &'a [(usize, usize)],
         config: &'a Config,
     ) -> FormatLines<'a> {
-        let issue_seeker = BadIssueSeeker::new(config.report_fixme());
+        let issue_seeker = BadIssueSeeker::new();
         FormatLines {
             name,
             skipped_range,
index 3c39d813a6f9d872c51b980865accc948a00db77..d95a80fe7fd952b0623ea14e1bbc64c1cab2b470 100644 (file)
@@ -6,8 +6,6 @@
 
 use crate::config::ReportTactic;
 
-const FIX_ME_CHARS: &[char] = &['f', 'i', 'x', 'm', 'e'];
-
 // Enabled implementation detail is here because it is
 // irrelevant outside the issues module
 fn is_enabled(report_tactic: ReportTactic) -> bool {
@@ -16,7 +14,7 @@ fn is_enabled(report_tactic: ReportTactic) -> bool {
 
 #[derive(Clone, Copy)]
 enum Seeking {
-    Issue { fixme_idx: usize },
+    Issue {},
     Number { issue: Issue, part: NumberPart },
 }
 
@@ -30,7 +28,7 @@ enum NumberPart {
 
 #[derive(PartialEq, Eq, Debug, Clone, Copy)]
 pub struct Issue {
-    issue_type: IssueType,
+    issue_type: Option<IssueType>,
     // Indicates whether we're looking for issues with missing numbers, or
     // all issues of this type.
     missing_number: bool,
@@ -39,7 +37,7 @@ pub struct Issue {
 impl fmt::Display for Issue {
     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         let msg = match self.issue_type {
-            IssueType::Fixme => "FIXME",
+            _ => "",
         };
         let details = if self.missing_number {
             " without issue number"
@@ -52,9 +50,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
 }
 
 #[derive(PartialEq, Eq, Debug, Clone, Copy)]
-enum IssueType {
-    Fixme,
-}
+enum IssueType {}
 
 enum IssueClassification {
     Good,
@@ -64,27 +60,25 @@ enum IssueClassification {
 
 pub(crate) struct BadIssueSeeker {
     state: Seeking,
-    report_fixme: ReportTactic,
 }
 
 impl BadIssueSeeker {
-    pub(crate) fn new(report_fixme: ReportTactic) -> BadIssueSeeker {
+    pub(crate) fn new() -> BadIssueSeeker {
         BadIssueSeeker {
-            state: Seeking::Issue { fixme_idx: 0 },
-            report_fixme,
+            state: Seeking::Issue {},
         }
     }
 
     pub(crate) fn is_disabled(&self) -> bool {
-        !is_enabled(self.report_fixme)
+        true
     }
 
     // Check whether or not the current char is conclusive evidence for an
     // unnumbered TO-DO or FIX-ME.
     pub(crate) fn inspect(&mut self, c: char) -> Option<Issue> {
         match self.state {
-            Seeking::Issue { fixme_idx } => {
-                self.state = self.inspect_issue(c, fixme_idx);
+            Seeking::Issue {} => {
+                self.state = self.inspect_issue(c, 0);
             }
             Seeking::Number { issue, part } => {
                 let result = self.inspect_number(c, issue, part);
@@ -93,7 +87,7 @@ pub(crate) fn inspect(&mut self, c: char) -> Option<Issue> {
                     return None;
                 }
 
-                self.state = Seeking::Issue { fixme_idx: 0 };
+                self.state = Seeking::Issue {};
 
                 if let IssueClassification::Bad(issue) = result {
                     return Some(issue);
@@ -106,25 +100,10 @@ pub(crate) fn inspect(&mut self, c: char) -> Option<Issue> {
 
     fn inspect_issue(&mut self, c: char, mut fixme_idx: usize) -> Seeking {
         if let Some(lower_case_c) = c.to_lowercase().next() {
-            if is_enabled(self.report_fixme) && lower_case_c == FIX_ME_CHARS[fixme_idx] {
-                // Exploit the fact that the character sets of todo and fixme
-                // are disjoint by adding else.
-                fixme_idx += 1;
-                if fixme_idx == FIX_ME_CHARS.len() {
-                    return Seeking::Number {
-                        issue: Issue {
-                            issue_type: IssueType::Fixme,
-                            missing_number: matches!(self.report_fixme, ReportTactic::Unnumbered),
-                        },
-                        part: NumberPart::OpenParen,
-                    };
-                }
-            } else {
-                fixme_idx = 0;
-            }
+            fixme_idx = 0;
         }
 
-        Seeking::Issue { fixme_idx }
+        Seeking::Issue {}
     }
 
     fn inspect_number(
@@ -175,7 +154,7 @@ fn inspect_number(
 #[test]
 fn find_unnumbered_issue() {
     fn check_fail(text: &str, failing_pos: usize) {
-        let mut seeker = BadIssueSeeker::new(ReportTactic::Unnumbered);
+        let mut seeker = BadIssueSeeker::new();
         assert_eq!(
             Some(failing_pos),
             text.find(|c| seeker.inspect(c).is_some())
@@ -183,51 +162,24 @@ fn check_fail(text: &str, failing_pos: usize) {
     }
 
     fn check_pass(text: &str) {
-        let mut seeker = BadIssueSeeker::new(ReportTactic::Unnumbered);
+        let mut seeker = BadIssueSeeker::new();
         assert_eq!(None, text.find(|c| seeker.inspect(c).is_some()));
     }
-
-    check_fail(" \n FIXME\n", 8);
-    check_fail("FIXME(\n", 6);
-    check_fail("FIXME(#\n", 7);
-    check_fail("FIXME(#1\n", 8);
-    check_fail("FIXME(#)1\n", 7);
-    check_pass("FIXME(#1222)\n");
-    check_fail("FIXME(#12\n22)\n", 9);
-    check_pass("FIXME(@maintainer, #1222, hello)\n");
 }
 
 #[test]
 fn find_issue() {
-    fn is_bad_issue(text: &str, report_fixme: ReportTactic) -> bool {
-        let mut seeker = BadIssueSeeker::new(report_fixme);
+    fn is_bad_issue(text: &str) -> bool {
+        let mut seeker = BadIssueSeeker::new();
         text.chars().any(|c| seeker.inspect(c).is_some())
     }
-
-    assert!(is_bad_issue("This is a FIXME(#1)\n", ReportTactic::Always));
-
-    assert!(is_bad_issue(
-        "This is a FixMe(#1) mixed case\n",
-        ReportTactic::Always,
-    ));
-
-    assert!(!is_bad_issue("bad FIXME\n", ReportTactic::Never));
 }
 
 #[test]
 fn issue_type() {
-    let mut seeker = BadIssueSeeker::new(ReportTactic::Unnumbered);
+    let seeker = BadIssueSeeker::new();
     let expected = Some(Issue {
-        issue_type: IssueType::Fixme,
+        issue_type: None,
         missing_number: true,
     });
-
-    assert_eq!(
-        expected,
-        "Test. FIXME: bad, bad, not good"
-            .chars()
-            .map(|c| seeker.inspect(c))
-            .find(Option::is_some)
-            .unwrap()
-    );
 }
index 598edda6abee45286f0291a160811d69809308b4..c3cfd34317a377132f034e8a22c028bfac0a932d 100644 (file)
@@ -6,6 +6,5 @@ brace_style = "SameLineWhere"
 fn_args_layout = "Tall"
 trailing_comma = "Vertical"
 indent_style = "Block"
-report_fixme = "Never"
 reorder_imports = false
 format_strings = true