Skip to content
Permalink
Browse files

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.
  • Loading branch information...
Mark-Simulacrum committed Jul 7, 2019
1 parent 57cf7a2 commit 4783d9eaa5488ad8ff2c49a17c14ab6f604e4e71
Showing with 4 additions and 16 deletions.
  1. +4 −16 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();

0 comments on commit 4783d9e

Please sign in to comment.
You can’t perform that action at this time.