@@ -28,26 +28,7 @@ use core::iter;
2828use crate :: tokenizer:: Span ;
2929
3030use super :: {
31- comments, dcl:: SecondaryRoles , value:: ValueWithSpan , AccessExpr , AlterColumnOperation ,
32- AlterIndexOperation , AlterTableOperation , Analyze , Array , Assignment , AssignmentTarget ,
33- AttachedToken , BeginEndStatements , CaseStatement , CloseCursor , ClusteredIndex , ColumnDef ,
34- ColumnOption , ColumnOptionDef , ConditionalStatementBlock , ConditionalStatements ,
35- ConflictTarget , ConnectByKind , ConstraintCharacteristics , CopySource , CreateIndex , CreateTable ,
36- CreateTableOptions , Cte , Delete , DoUpdate , ExceptSelectItem , ExcludeSelectItem , Expr ,
37- ExprWithAlias , Fetch , ForValues , FromTable , Function , FunctionArg , FunctionArgExpr ,
38- FunctionArgumentClause , FunctionArgumentList , FunctionArguments , GroupByExpr , HavingBound ,
39- IfStatement , IlikeSelectItem , IndexColumn , Insert , Interpolate , InterpolateExpr , Join ,
40- JoinConstraint , JoinOperator , JsonPath , JsonPathElem , LateralView , LimitClause ,
41- MatchRecognizePattern , Measure , Merge , MergeAction , MergeClause , MergeInsertExpr ,
42- MergeInsertKind , MergeUpdateExpr , NamedParenthesizedList , NamedWindowDefinition , ObjectName ,
43- ObjectNamePart , Offset , OnConflict , OnConflictAction , OnInsert , OpenStatement , OrderBy ,
44- OrderByExpr , OrderByKind , OutputClause , Partition , PartitionBoundValue , PivotValueSource ,
45- ProjectionSelect , Query , RaiseStatement , RaiseStatementValue , ReferentialAction ,
46- RenameSelectItem , ReplaceSelectElement , ReplaceSelectItem , Select , SelectInto , SelectItem ,
47- SetExpr , SqlOption , Statement , Subscript , SymbolDefinition , TableAlias , TableAliasColumnDef ,
48- TableConstraint , TableFactor , TableObject , TableOptionsClustered , TableWithJoins , Update ,
49- UpdateTableFromKind , Use , Values , ViewColumnDef , WhileStatement , WildcardAdditionalOptions ,
50- With , WithFill ,
31+ AccessExpr , AlterColumnOperation , AlterIndexOperation , AlterTableOperation , Analyze , Array , Assignment , AssignmentTarget , AttachedToken , BeginEndStatements , CaseStatement , CloseCursor , ClusteredIndex , ColumnDef , ColumnOption , ColumnOptionDef , ConditionalStatementBlock , ConditionalStatements , ConflictTarget , ConnectByKind , ConstraintCharacteristics , CopySource , CreateIndex , CreateTable , CreateTableOptions , Cte , Delete , DoUpdate , ExceptSelectItem , ExcludeSelectItem , Expr , ExprWithAlias , Fetch , ForValues , FromTable , Function , FunctionArg , FunctionArgExpr , FunctionArgumentClause , FunctionArgumentList , FunctionArguments , GroupByExpr , HavingBound , IfStatement , IlikeSelectItem , IndexColumn , Insert , Interpolate , InterpolateExpr , Join , JoinConstraint , JoinOperator , JsonPath , JsonPathElem , LateralView , LimitClause , MatchRecognizePattern , Measure , Merge , MergeAction , MergeClause , MergeInsertExpr , MergeInsertKind , MergeUpdateExpr , NamedParenthesizedList , NamedWindowDefinition , ObjectName , ObjectNamePart , Offset , OnConflict , OnConflictAction , OnInsert , OpenStatement , OrderBy , OrderByExpr , OrderByKind , OutputClause , Parens , Partition , PartitionBoundValue , PivotValueSource , ProjectionSelect , Query , RaiseStatement , RaiseStatementValue , ReferentialAction , RenameSelectItem , ReplaceSelectElement , ReplaceSelectItem , Select , SelectInto , SelectItem , SetExpr , SqlOption , Statement , Subscript , SymbolDefinition , TableAlias , TableAliasColumnDef , TableConstraint , TableFactor , TableObject , TableOptionsClustered , TableWithJoins , Update , UpdateTableFromKind , Use , Values , ViewColumnDef , WhileStatement , WildcardAdditionalOptions , With , WithFill , comments, dcl:: SecondaryRoles , value:: ValueWithSpan
5132} ;
5233
5334/// Given an iterator of spans, return the [Span::union] of all spans.
@@ -106,6 +87,12 @@ impl Spanned for TokenWithSpan {
10687 }
10788}
10889
90+ impl < T > Spanned for Parens < T > {
91+ fn span ( & self ) -> Span {
92+ union_spans ( [ self . opening_token . 0 . span , self . closing_token . 0 . span ] . into_iter ( ) )
93+ }
94+ }
95+
10996impl Spanned for Query {
11097 fn span ( & self ) -> Span {
11198 let Query {
@@ -239,10 +226,11 @@ impl Spanned for Values {
239226 rows,
240227 } = self ;
241228
242- union_spans (
243- rows. iter ( )
244- . map ( |row| union_spans ( row. iter ( ) . map ( |expr| expr. span ( ) ) ) ) ,
245- )
229+ match & rows[ ..] {
230+ [ ] => Span :: empty ( ) ,
231+ [ f] => f. span ( ) ,
232+ [ f, .., l] => union_spans ( [ f. span ( ) , l. span ( ) ] . into_iter ( ) ) ,
233+ }
246234 }
247235}
248236
0 commit comments