@@ -8,7 +8,6 @@ use base_db::{AnchoredPath, Edition, FileId};
88use cfg:: CfgExpr ;
99use either:: Either ;
1010use mbe:: { parse_exprs_with_sep, parse_to_token_tree, ExpandResult } ;
11- use parser:: FragmentKind ;
1211use syntax:: ast:: { self , AstToken } ;
1312
1413macro_rules! register_builtin {
@@ -47,7 +46,7 @@ macro_rules! register_builtin {
4746 let expander = match * self {
4847 $( EagerExpander :: $e_kind => $e_expand, ) *
4948 } ;
50- expander( db, arg_id, tt)
49+ expander( db, arg_id, tt)
5150 }
5251 }
5352
@@ -64,14 +63,13 @@ macro_rules! register_builtin {
6463#[ derive( Debug ) ]
6564pub struct ExpandedEager {
6665 pub ( crate ) subtree : tt:: Subtree ,
67- pub ( crate ) fragment : FragmentKind ,
6866 /// The included file ID of the include macro.
6967 pub ( crate ) included_file : Option < FileId > ,
7068}
7169
7270impl ExpandedEager {
73- fn new ( subtree : tt:: Subtree , fragment : FragmentKind ) -> Self {
74- ExpandedEager { subtree, fragment , included_file : None }
71+ fn new ( subtree : tt:: Subtree ) -> Self {
72+ ExpandedEager { subtree, included_file : None }
7573 }
7674}
7775
@@ -340,7 +338,7 @@ fn compile_error_expand(
340338 _ => mbe:: ExpandError :: BindingError ( "`compile_error!` argument must be a string" . into ( ) ) ,
341339 } ;
342340
343- ExpandResult { value : Some ( ExpandedEager :: new ( quote ! { } , FragmentKind :: Items ) ) , err : Some ( err) }
341+ ExpandResult { value : Some ( ExpandedEager :: new ( quote ! { } ) ) , err : Some ( err) }
344342}
345343
346344fn concat_expand (
@@ -371,7 +369,7 @@ fn concat_expand(
371369 }
372370 }
373371 }
374- ExpandResult { value : Some ( ExpandedEager :: new ( quote ! ( #text) , FragmentKind :: Expr ) ) , err }
372+ ExpandResult { value : Some ( ExpandedEager :: new ( quote ! ( #text) ) ) , err }
375373}
376374
377375fn concat_idents_expand (
@@ -393,7 +391,7 @@ fn concat_idents_expand(
393391 }
394392 }
395393 let ident = tt:: Ident { text : ident. into ( ) , id : tt:: TokenId :: unspecified ( ) } ;
396- ExpandResult { value : Some ( ExpandedEager :: new ( quote ! ( #ident) , FragmentKind :: Expr ) ) , err }
394+ ExpandResult { value : Some ( ExpandedEager :: new ( quote ! ( #ident) ) ) , err }
397395}
398396
399397fn relative_file (
@@ -442,14 +440,7 @@ fn include_expand(
442440
443441 match res {
444442 Ok ( ( subtree, file_id) ) => {
445- // FIXME:
446- // Handle include as expression
447-
448- ExpandResult :: ok ( Some ( ExpandedEager {
449- subtree,
450- fragment : FragmentKind :: Items ,
451- included_file : Some ( file_id) ,
452- } ) )
443+ ExpandResult :: ok ( Some ( ExpandedEager { subtree, included_file : Some ( file_id) } ) )
453444 }
454445 Err ( e) => ExpandResult :: only_err ( e) ,
455446 }
@@ -472,7 +463,7 @@ fn include_bytes_expand(
472463 id: tt:: TokenId :: unspecified( ) ,
473464 } ) ) ] ,
474465 } ;
475- ExpandResult :: ok ( Some ( ExpandedEager :: new ( res, FragmentKind :: Expr ) ) )
466+ ExpandResult :: ok ( Some ( ExpandedEager :: new ( res) ) )
476467}
477468
478469fn include_str_expand (
@@ -492,14 +483,14 @@ fn include_str_expand(
492483 let file_id = match relative_file ( db, arg_id. into ( ) , & path, true ) {
493484 Ok ( file_id) => file_id,
494485 Err ( _) => {
495- return ExpandResult :: ok ( Some ( ExpandedEager :: new ( quote ! ( "" ) , FragmentKind :: Expr ) ) ) ;
486+ return ExpandResult :: ok ( Some ( ExpandedEager :: new ( quote ! ( "" ) ) ) ) ;
496487 }
497488 } ;
498489
499490 let text = db. file_text ( file_id) ;
500491 let text = & * text;
501492
502- ExpandResult :: ok ( Some ( ExpandedEager :: new ( quote ! ( #text) , FragmentKind :: Expr ) ) )
493+ ExpandResult :: ok ( Some ( ExpandedEager :: new ( quote ! ( #text) ) ) )
503494}
504495
505496fn get_env_inner ( db : & dyn AstDatabase , arg_id : MacroCallId , key : & str ) -> Option < String > {
@@ -535,7 +526,7 @@ fn env_expand(
535526 } ) ;
536527 let expanded = quote ! { #s } ;
537528
538- ExpandResult { value : Some ( ExpandedEager :: new ( expanded, FragmentKind :: Expr ) ) , err }
529+ ExpandResult { value : Some ( ExpandedEager :: new ( expanded) ) , err }
539530}
540531
541532fn option_env_expand (
@@ -553,7 +544,7 @@ fn option_env_expand(
553544 Some ( s) => quote ! { std:: option:: Some ( #s) } ,
554545 } ;
555546
556- ExpandResult :: ok ( Some ( ExpandedEager :: new ( expanded, FragmentKind :: Expr ) ) )
547+ ExpandResult :: ok ( Some ( ExpandedEager :: new ( expanded) ) )
557548}
558549
559550#[ cfg( test) ]
@@ -565,6 +556,7 @@ mod tests {
565556 } ;
566557 use base_db:: { fixture:: WithFixture , SourceDatabase } ;
567558 use expect_test:: { expect, Expect } ;
559+ use parser:: FragmentKind ;
568560 use std:: sync:: Arc ;
569561 use syntax:: ast:: NameOwner ;
570562
@@ -617,6 +609,7 @@ mod tests {
617609 local_inner : false ,
618610 } ;
619611
612+ let fragment = crate :: to_fragment_kind ( & macro_call) ;
620613 let args = macro_call. token_tree ( ) . unwrap ( ) ;
621614 let parsed_args = mbe:: ast_to_token_tree ( & args) . 0 ;
622615 let call_id = AstId :: new ( file_id. into ( ) , ast_id_map. ast_id ( & macro_call) ) ;
@@ -639,7 +632,7 @@ mod tests {
639632 arg_or_expansion : Arc :: new ( expanded. subtree ) ,
640633 included_file : expanded. included_file ,
641634 } ) ,
642- kind : MacroCallKind :: FnLike { ast_id : call_id, fragment : expanded . fragment } ,
635+ kind : MacroCallKind :: FnLike { ast_id : call_id, fragment } ,
643636 } ;
644637
645638 let id: MacroCallId = db. intern_macro ( loc) . into ( ) ;
0 commit comments