@@ -3,6 +3,7 @@ use std::mem;
33
44use hir_expand:: name:: Name ;
55use rustc_dependencies:: parse_format as parse;
6+ use stdx:: TupleExt ;
67use syntax:: {
78 ast:: { self , IsString } ,
89 SmolStr , TextRange , TextSize ,
@@ -14,6 +15,7 @@ use crate::hir::ExprId;
1415pub struct FormatArgs {
1516 pub template : Box < [ FormatArgsPiece ] > ,
1617 pub arguments : FormatArguments ,
18+ pub orphans : Vec < ExprId > ,
1719}
1820
1921#[ derive( Debug , Clone , PartialEq , Eq ) ]
@@ -196,7 +198,11 @@ pub(crate) fn parse(
196198 let is_source_literal = parser. is_source_literal ;
197199 if !parser. errors . is_empty ( ) {
198200 // FIXME: Diagnose
199- return FormatArgs { template : Default :: default ( ) , arguments : args. finish ( ) } ;
201+ return FormatArgs {
202+ template : Default :: default ( ) ,
203+ arguments : args. finish ( ) ,
204+ orphans : vec ! [ ] ,
205+ } ;
200206 }
201207
202208 let to_span = |inner_span : parse:: InnerSpan | {
@@ -419,7 +425,11 @@ pub(crate) fn parse(
419425 // FIXME: Diagnose
420426 }
421427
422- FormatArgs { template : template. into_boxed_slice ( ) , arguments : args. finish ( ) }
428+ FormatArgs {
429+ template : template. into_boxed_slice ( ) ,
430+ arguments : args. finish ( ) ,
431+ orphans : unused. into_iter ( ) . map ( TupleExt :: head) . collect ( ) ,
432+ }
423433}
424434
425435#[ derive( Debug , Clone , PartialEq , Eq ) ]
0 commit comments