mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
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.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user