]> git.lizzy.rs Git - rust.git/commitdiff
Clean up
authortopecongiro <seuchida@gmail.com>
Mon, 19 Feb 2018 03:50:39 +0000 (12:50 +0900)
committertopecongiro <seuchida@gmail.com>
Mon, 19 Feb 2018 03:55:12 +0000 (12:55 +0900)
rustfmt-core/src/issues.rs
rustfmt-core/src/lib.rs
rustfmt-core/src/shape.rs

index fc04c1331972e3c9c5b777d92e78c84b5123efc3..75ad30b6f2a9202a2fa2a2e8b08ab050d99a99b5 100644 (file)
@@ -93,17 +93,13 @@ pub fn new(report_todo: ReportTactic, report_fixme: ReportTactic) -> BadIssueSee
         }
     }
 
-    fn is_disabled(&self) -> bool {
+    pub fn is_disabled(&self) -> bool {
         !is_enabled(self.report_todo) && !is_enabled(self.report_fixme)
     }
 
     // Check whether or not the current char is conclusive evidence for an
     // unnumbered TO-DO or FIX-ME.
     pub fn inspect(&mut self, c: char) -> Option<Issue> {
-        if self.is_disabled() {
-            return None;
-        }
-
         match self.state {
             Seeking::Issue {
                 todo_idx,
index 9d138a306880c82f5be3c6a44e7dd054b3cdca4d..b095d06abb816aa7cfdccc19023024b404bb693d 100644 (file)
@@ -352,7 +352,7 @@ fn format_ast<F>(
             visitor.format_separate_mod(module, &*filemap);
         };
 
-        assert_eq!(
+        debug_assert_eq!(
             visitor.line_number,
             ::utils::count_newlines(&format!("{}", visitor.buffer))
         );
@@ -420,13 +420,14 @@ fn format_lines(
     let mut line_buffer = String::with_capacity(config.max_width() * 2);
     let mut is_string = false; // true if the current line contains a string literal.
     let mut format_line = config.file_lines().contains_line(name, cur_line);
+    let allow_issue_seek = !issue_seeker.is_disabled();
 
     for (kind, (b, c)) in CharClasses::new(text.chars().enumerate()) {
         if c == '\r' {
             continue;
         }
 
-        if format_line {
+        if allow_issue_seek && format_line {
             // Add warnings for bad todos/ fixmes
             if let Some(issue) = issue_seeker.inspect(c) {
                 errors.push(FormattingError {
index 1c98052c493c6b2d171fa6f11d1e0a3e5e0f8fac..22d6a096efa4b2a3d49ec389d1c7d6f2ee30dc5b 100644 (file)
@@ -81,7 +81,7 @@ pub fn to_string_with_newline(&self, config: &Config) -> Cow<'static, str> {
         self.to_string_inner(config, 0)
     }
 
-    pub fn to_string_inner(&self, config: &Config, offset: usize) -> Cow<'static, str> {
+    fn to_string_inner(&self, config: &Config, offset: usize) -> Cow<'static, str> {
         let (num_tabs, num_spaces) = if config.hard_tabs() {
             (self.block_indent / config.tab_spaces(), self.alignment)
         } else {