about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-07-07 10:51:18 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2019-07-10 07:12:29 -0400
commit4783d9eaa5488ad8ff2c49a17c14ab6f604e4e71 (patch)
tree7c833a891ef0e1f9dd9193187d7ac2599e8db886 /src/libsyntax/print
parent57cf7a2e5728e5b4d77230ffb1e372385f4f24dd (diff)
downloadrust-4783d9eaa5488ad8ff2c49a17c14ab6f604e4e71.tar.gz
rust-4783d9eaa5488ad8ff2c49a17c14ab6f604e4e71.zip
Remove is_begin/is_end functions from PrintState
These are somewhat ambiguous (beginning/end of what?) so it's better to
inline their one use into the code.
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 54672d9da2e..2d110aab879 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -445,20 +445,6 @@ pub trait PrintState<'a> {
 
     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 @@ pub trait PrintState<'a> {
             }
             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();