@@ -42,7 +42,7 @@ macro_rules! register_builtin {
42
42
db: & dyn AstDatabase ,
43
43
arg_id: MacroCallId ,
44
44
tt: & tt:: Subtree ,
45
- ) -> ExpandResult <Option < ExpandedEager > > {
45
+ ) -> ExpandResult <ExpandedEager > {
46
46
let expander = match * self {
47
47
$( EagerExpander :: $e_kind => $e_expand, ) *
48
48
} ;
@@ -60,7 +60,7 @@ macro_rules! register_builtin {
60
60
} ;
61
61
}
62
62
63
- #[ derive( Debug ) ]
63
+ #[ derive( Debug , Default ) ]
64
64
pub struct ExpandedEager {
65
65
pub ( crate ) subtree : tt:: Subtree ,
66
66
/// The included file ID of the include macro.
@@ -362,7 +362,7 @@ fn compile_error_expand(
362
362
_db : & dyn AstDatabase ,
363
363
_id : MacroCallId ,
364
364
tt : & tt:: Subtree ,
365
- ) -> ExpandResult < Option < ExpandedEager > > {
365
+ ) -> ExpandResult < ExpandedEager > {
366
366
let err = match & * tt. token_trees {
367
367
[ tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( it) ) ] => {
368
368
let text = it. text . as_str ( ) ;
@@ -376,14 +376,14 @@ fn compile_error_expand(
376
376
_ => mbe:: ExpandError :: BindingError ( "`compile_error!` argument must be a string" . into ( ) ) ,
377
377
} ;
378
378
379
- ExpandResult { value : Some ( ExpandedEager :: new ( quote ! { } ) ) , err : Some ( err) }
379
+ ExpandResult { value : ExpandedEager :: new ( quote ! { } ) , err : Some ( err) }
380
380
}
381
381
382
382
fn concat_expand (
383
383
_db : & dyn AstDatabase ,
384
384
_arg_id : MacroCallId ,
385
385
tt : & tt:: Subtree ,
386
- ) -> ExpandResult < Option < ExpandedEager > > {
386
+ ) -> ExpandResult < ExpandedEager > {
387
387
let mut err = None ;
388
388
let mut text = String :: new ( ) ;
389
389
for ( i, mut t) in tt. token_trees . iter ( ) . enumerate ( ) {
@@ -418,14 +418,14 @@ fn concat_expand(
418
418
}
419
419
}
420
420
}
421
- ExpandResult { value : Some ( ExpandedEager :: new ( quote ! ( #text) ) ) , err }
421
+ ExpandResult { value : ExpandedEager :: new ( quote ! ( #text) ) , err }
422
422
}
423
423
424
424
fn concat_idents_expand (
425
425
_db : & dyn AstDatabase ,
426
426
_arg_id : MacroCallId ,
427
427
tt : & tt:: Subtree ,
428
- ) -> ExpandResult < Option < ExpandedEager > > {
428
+ ) -> ExpandResult < ExpandedEager > {
429
429
let mut err = None ;
430
430
let mut ident = String :: new ( ) ;
431
431
for ( i, t) in tt. token_trees . iter ( ) . enumerate ( ) {
@@ -440,7 +440,7 @@ fn concat_idents_expand(
440
440
}
441
441
}
442
442
let ident = tt:: Ident { text : ident. into ( ) , id : tt:: TokenId :: unspecified ( ) } ;
443
- ExpandResult { value : Some ( ExpandedEager :: new ( quote ! ( #ident) ) ) , err }
443
+ ExpandResult { value : ExpandedEager :: new ( quote ! ( #ident) ) , err }
444
444
}
445
445
446
446
fn relative_file (
@@ -476,7 +476,7 @@ fn include_expand(
476
476
db : & dyn AstDatabase ,
477
477
arg_id : MacroCallId ,
478
478
tt : & tt:: Subtree ,
479
- ) -> ExpandResult < Option < ExpandedEager > > {
479
+ ) -> ExpandResult < ExpandedEager > {
480
480
let res = ( || {
481
481
let path = parse_string ( tt) ?;
482
482
let file_id = relative_file ( db, arg_id, & path, false ) ?;
@@ -488,7 +488,7 @@ fn include_expand(
488
488
489
489
match res {
490
490
Ok ( ( subtree, file_id) ) => {
491
- ExpandResult :: ok ( Some ( ExpandedEager { subtree, included_file : Some ( file_id) } ) )
491
+ ExpandResult :: ok ( ExpandedEager { subtree, included_file : Some ( file_id) } )
492
492
}
493
493
Err ( e) => ExpandResult :: only_err ( e) ,
494
494
}
@@ -498,7 +498,7 @@ fn include_bytes_expand(
498
498
_db : & dyn AstDatabase ,
499
499
_arg_id : MacroCallId ,
500
500
tt : & tt:: Subtree ,
501
- ) -> ExpandResult < Option < ExpandedEager > > {
501
+ ) -> ExpandResult < ExpandedEager > {
502
502
if let Err ( e) = parse_string ( tt) {
503
503
return ExpandResult :: only_err ( e) ;
504
504
}
@@ -511,14 +511,14 @@ fn include_bytes_expand(
511
511
id: tt:: TokenId :: unspecified( ) ,
512
512
} ) ) ] ,
513
513
} ;
514
- ExpandResult :: ok ( Some ( ExpandedEager :: new ( res) ) )
514
+ ExpandResult :: ok ( ExpandedEager :: new ( res) )
515
515
}
516
516
517
517
fn include_str_expand (
518
518
db : & dyn AstDatabase ,
519
519
arg_id : MacroCallId ,
520
520
tt : & tt:: Subtree ,
521
- ) -> ExpandResult < Option < ExpandedEager > > {
521
+ ) -> ExpandResult < ExpandedEager > {
522
522
let path = match parse_string ( tt) {
523
523
Ok ( it) => it,
524
524
Err ( e) => return ExpandResult :: only_err ( e) ,
@@ -531,14 +531,14 @@ fn include_str_expand(
531
531
let file_id = match relative_file ( db, arg_id, & path, true ) {
532
532
Ok ( file_id) => file_id,
533
533
Err ( _) => {
534
- return ExpandResult :: ok ( Some ( ExpandedEager :: new ( quote ! ( "" ) ) ) ) ;
534
+ return ExpandResult :: ok ( ExpandedEager :: new ( quote ! ( "" ) ) ) ;
535
535
}
536
536
} ;
537
537
538
538
let text = db. file_text ( file_id) ;
539
539
let text = & * text;
540
540
541
- ExpandResult :: ok ( Some ( ExpandedEager :: new ( quote ! ( #text) ) ) )
541
+ ExpandResult :: ok ( ExpandedEager :: new ( quote ! ( #text) ) )
542
542
}
543
543
544
544
fn get_env_inner ( db : & dyn AstDatabase , arg_id : MacroCallId , key : & str ) -> Option < String > {
@@ -550,7 +550,7 @@ fn env_expand(
550
550
db : & dyn AstDatabase ,
551
551
arg_id : MacroCallId ,
552
552
tt : & tt:: Subtree ,
553
- ) -> ExpandResult < Option < ExpandedEager > > {
553
+ ) -> ExpandResult < ExpandedEager > {
554
554
let key = match parse_string ( tt) {
555
555
Ok ( it) => it,
556
556
Err ( e) => return ExpandResult :: only_err ( e) ,
@@ -574,14 +574,14 @@ fn env_expand(
574
574
} ) ;
575
575
let expanded = quote ! { #s } ;
576
576
577
- ExpandResult { value : Some ( ExpandedEager :: new ( expanded) ) , err }
577
+ ExpandResult { value : ExpandedEager :: new ( expanded) , err }
578
578
}
579
579
580
580
fn option_env_expand (
581
581
db : & dyn AstDatabase ,
582
582
arg_id : MacroCallId ,
583
583
tt : & tt:: Subtree ,
584
- ) -> ExpandResult < Option < ExpandedEager > > {
584
+ ) -> ExpandResult < ExpandedEager > {
585
585
let key = match parse_string ( tt) {
586
586
Ok ( it) => it,
587
587
Err ( e) => return ExpandResult :: only_err ( e) ,
@@ -592,5 +592,5 @@ fn option_env_expand(
592
592
Some ( s) => quote ! { std:: option:: Some ( #s) } ,
593
593
} ;
594
594
595
- ExpandResult :: ok ( Some ( ExpandedEager :: new ( expanded) ) )
595
+ ExpandResult :: ok ( ExpandedEager :: new ( expanded) )
596
596
}
0 commit comments