Drop obsolete contains_newline method

This commit is contained in:
Richard Feldman 2020-05-23 21:41:11 -04:00
parent 5b6be39007
commit 4d8cbc4811
2 changed files with 8 additions and 13 deletions

View file

@ -423,7 +423,10 @@ pub fn empty_line_before_expr<'a>(expr: &'a Expr<'a>) -> bool {
pub fn is_multiline_pattern<'a>(pattern: &'a Pattern<'a>) -> bool { pub fn is_multiline_pattern<'a>(pattern: &'a Pattern<'a>) -> bool {
match pattern { match pattern {
Pattern::SpaceBefore(_, spaces) | Pattern::SpaceAfter(_, spaces) => { Pattern::SpaceBefore(_, spaces) | Pattern::SpaceAfter(_, spaces) => {
spaces.iter().any(|space| space.contains_newline()) debug_assert!(!spaces.is_empty());
// "spaces" always contain either a newline or comment, and comments have newlines
true
} }
Pattern::Nested(nested_pat) => is_multiline_pattern(nested_pat), Pattern::Nested(nested_pat) => is_multiline_pattern(nested_pat),
@ -452,7 +455,10 @@ pub fn is_multiline_expr<'a>(expr: &'a Expr<'a>) -> bool {
match expr { match expr {
// Return whether these spaces contain any Newlines // Return whether these spaces contain any Newlines
SpaceBefore(_, spaces) | SpaceAfter(_, spaces) => { SpaceBefore(_, spaces) | SpaceAfter(_, spaces) => {
spaces.iter().any(|space| space.contains_newline()) debug_assert!(!spaces.is_empty());
// "spaces" always contain either a newline or comment, and comments have newlines
true
} }
// These expressions never have newlines // These expressions never have newlines

View file

@ -296,17 +296,6 @@ pub enum CommentOrNewline<'a> {
LineComment(&'a str), LineComment(&'a str),
} }
impl<'a> CommentOrNewline<'a> {
pub fn contains_newline(&self) -> bool {
use self::CommentOrNewline::*;
match self {
// Line comments have an implicit newline at the end
Newline | LineComment(_) => true,
}
}
}
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub enum Pattern<'a> { pub enum Pattern<'a> {
// Identifier // Identifier