]> git.lizzy.rs Git - rust.git/commitdiff
Remove is_begin/is_end functions from PrintState
authorMark Rousskov <mark.simulacrum@gmail.com>
Sun, 7 Jul 2019 14:51:18 +0000 (10:51 -0400)
committerMark Rousskov <mark.simulacrum@gmail.com>
Wed, 10 Jul 2019 11:12:29 +0000 (07:12 -0400)
These are somewhat ambiguous (beginning/end of what?) so it's better to
inline their one use into the code.

src/libsyntax/print/pprust.rs

index 54672d9da2e2b8ffffc70366b2befa89b597176d..2d110aab8798e6b7971dae5ada491f6ae78b9860 100644 (file)
@@ -445,20 +445,6 @@ fn popen(&mut self) { self.writer().word("(") }
 
     fn pclose(&mut self) { self.writer().word(")") }
 
-    fn is_begin(&mut self) -> bool {
-        match self.writer().last_token() {
-            pp::Token::Begin(_) => true,
-            _ => false,
-        }
-    }
-
-    fn is_end(&mut self) -> bool {
-        match self.writer().last_token() {
-            pp::Token::End => true,
-            _ => false,
-        }
-    }
-
     // is this the beginning of a line?
     fn is_bol(&mut self) -> bool {
         self.writer().last_token().is_eof() || self.writer().last_token().is_hardbreak_tok()
@@ -545,11 +531,13 @@ fn print_comment(&mut self,
             }
             comments::BlankLine => {
                 // We need to do at least one, possibly two hardbreaks.
-                let is_semi = match self.writer().last_token() {
+                let twice = match self.writer().last_token() {
                     pp::Token::String(s, _) => ";" == s,
+                    pp::Token::Begin(_) => true,
+                    pp::Token::End => true,
                     _ => false
                 };
-                if is_semi || self.is_begin() || self.is_end() {
+                if twice {
                     self.writer().hardbreak();
                 }
                 self.writer().hardbreak();