@@ -3,6 +3,7 @@ use std::mem;
3
3
4
4
use hir_expand:: name:: Name ;
5
5
use rustc_dependencies:: parse_format as parse;
6
+ use stdx:: TupleExt ;
6
7
use syntax:: {
7
8
ast:: { self , IsString } ,
8
9
SmolStr , TextRange , TextSize ,
@@ -14,6 +15,7 @@ use crate::hir::ExprId;
14
15
pub struct FormatArgs {
15
16
pub template : Box < [ FormatArgsPiece ] > ,
16
17
pub arguments : FormatArguments ,
18
+ pub orphans : Vec < ExprId > ,
17
19
}
18
20
19
21
#[ derive( Debug , Clone , PartialEq , Eq ) ]
@@ -196,7 +198,11 @@ pub(crate) fn parse(
196
198
let is_source_literal = parser. is_source_literal ;
197
199
if !parser. errors . is_empty ( ) {
198
200
// 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
+ } ;
200
206
}
201
207
202
208
let to_span = |inner_span : parse:: InnerSpan | {
@@ -419,7 +425,11 @@ pub(crate) fn parse(
419
425
// FIXME: Diagnose
420
426
}
421
427
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
+ }
423
433
}
424
434
425
435
#[ derive( Debug , Clone , PartialEq , Eq ) ]
0 commit comments