File tree Expand file tree Collapse file tree 3 files changed +12
-23
lines changed
Expand file tree Collapse file tree 3 files changed +12
-23
lines changed Original file line number Diff line number Diff line change @@ -2273,7 +2273,7 @@ impl fmt::Display for ConditionalStatementBlock {
22732273 write ! ( f, " THEN" ) ?;
22742274 }
22752275
2276- if conditional_statements. statements ( ) . len ( ) > 0 {
2276+ if ! conditional_statements. statements ( ) . is_empty ( ) {
22772277 write ! ( f, " {conditional_statements}" ) ?;
22782278 }
22792279
@@ -2309,7 +2309,7 @@ impl fmt::Display for ConditionalStatements {
23092309 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
23102310 match self {
23112311 ConditionalStatements :: Sequence { statements } => {
2312- if statements. len ( ) > 0 {
2312+ if ! statements. is_empty ( ) {
23132313 format_statement_list ( f, statements) ?;
23142314 }
23152315 Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -761,13 +761,8 @@ impl Spanned for IfStatement {
761761 union_spans (
762762 iter:: once ( if_block. span ( ) )
763763 . chain ( elseif_blocks. iter ( ) . map ( |b| b. span ( ) ) )
764- . chain ( else_block. as_ref ( ) . map ( |b| b. span ( ) ) . into_iter ( ) )
765- . chain (
766- end_token
767- . as_ref ( )
768- . map ( |AttachedToken ( t) | t. span )
769- . into_iter ( ) ,
770- ) ,
764+ . chain ( else_block. as_ref ( ) . map ( |b| b. span ( ) ) )
765+ . chain ( end_token. as_ref ( ) . map ( |AttachedToken ( t) | t. span ) ) ,
771766 )
772767 }
773768}
@@ -798,13 +793,8 @@ impl Spanned for ConditionalStatementBlock {
798793
799794 union_spans (
800795 iter:: once ( start_token. span )
801- . chain ( condition. as_ref ( ) . map ( |c| c. span ( ) ) . into_iter ( ) )
802- . chain (
803- then_token
804- . as_ref ( )
805- . map ( |AttachedToken ( t) | t. span )
806- . into_iter ( ) ,
807- )
796+ . chain ( condition. as_ref ( ) . map ( |c| c. span ( ) ) )
797+ . chain ( then_token. as_ref ( ) . map ( |AttachedToken ( t) | t. span ) )
808798 . chain ( iter:: once ( conditional_statements. span ( ) ) ) ,
809799 )
810800 }
Original file line number Diff line number Diff line change @@ -139,12 +139,11 @@ impl MsSqlDialect {
139139
140140 let condition = parser. parse_expr ( ) ?;
141141
142- let if_block;
143- if parser. peek_keyword ( Keyword :: BEGIN ) {
142+ let if_block = if parser. peek_keyword ( Keyword :: BEGIN ) {
144143 let begin_token = parser. expect_keyword ( Keyword :: BEGIN ) ?;
145144 let statements = self . parse_statement_list ( parser, Some ( Keyword :: END ) ) ?;
146145 let end_token = parser. expect_keyword ( Keyword :: END ) ?;
147- if_block = ConditionalStatementBlock {
146+ ConditionalStatementBlock {
148147 start_token : AttachedToken ( if_token) ,
149148 condition : Some ( condition) ,
150149 then_token : None ,
@@ -153,18 +152,18 @@ impl MsSqlDialect {
153152 statements,
154153 end_token : AttachedToken ( end_token) ,
155154 } ,
156- } ;
155+ }
157156 } else {
158157 let stmt = parser. parse_statement ( ) ?;
159- if_block = ConditionalStatementBlock {
158+ ConditionalStatementBlock {
160159 start_token : AttachedToken ( if_token) ,
161160 condition : Some ( condition) ,
162161 then_token : None ,
163162 conditional_statements : ConditionalStatements :: Sequence {
164163 statements : vec ! [ stmt] ,
165164 } ,
166- } ;
167- }
165+ }
166+ } ;
168167
169168 while let Token :: SemiColon = parser. peek_token_ref ( ) . token {
170169 parser. advance_token ( ) ;
You can’t perform that action at this time.
0 commit comments