@@ -697,6 +697,7 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
697
697
"block" => parser:: PrefixEntryPoint :: Block ,
698
698
"meta" => parser:: PrefixEntryPoint :: MetaItem ,
699
699
"item" => parser:: PrefixEntryPoint :: Item ,
700
+ "vis" => parser:: PrefixEntryPoint :: Vis ,
700
701
"expr" => {
701
702
return input
702
703
. expect_fragment ( parser:: PrefixEntryPoint :: Expr )
@@ -706,33 +707,29 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
706
707
let tt_result = match kind {
707
708
"ident" => input
708
709
. expect_ident ( )
709
- . map ( |ident| Some ( tt:: Leaf :: from ( ident. clone ( ) ) . into ( ) ) )
710
+ . map ( |ident| tt:: Leaf :: from ( ident. clone ( ) ) . into ( ) )
710
711
. map_err ( |( ) | err ! ( "expected ident" ) ) ,
711
- "tt" => input. expect_tt ( ) . map ( Some ) . map_err ( |( ) | err ! ( ) ) ,
712
- "lifetime" => {
713
- input. expect_lifetime ( ) . map ( Some ) . map_err ( |( ) | err ! ( "expected lifetime" ) )
714
- }
712
+ "tt" => input. expect_tt ( ) . map_err ( |( ) | err ! ( ) ) ,
713
+ "lifetime" => input. expect_lifetime ( ) . map_err ( |( ) | err ! ( "expected lifetime" ) ) ,
715
714
"literal" => {
716
715
let neg = input. eat_char ( '-' ) ;
717
716
input
718
717
. expect_literal ( )
719
718
. map ( |literal| {
720
719
let lit = literal. clone ( ) ;
721
720
match neg {
722
- None => Some ( lit. into ( ) ) ,
723
- Some ( neg) => Some ( tt:: TokenTree :: Subtree ( tt:: Subtree {
721
+ None => lit. into ( ) ,
722
+ Some ( neg) => tt:: TokenTree :: Subtree ( tt:: Subtree {
724
723
delimiter : None ,
725
724
token_trees : vec ! [ neg, lit. into( ) ] ,
726
- } ) ) ,
725
+ } ) ,
727
726
}
728
727
} )
729
728
. map_err ( |( ) | err ! ( ) )
730
729
}
731
- // `vis` is optional
732
- "vis" => Ok ( input. expect_fragment ( parser:: PrefixEntryPoint :: Vis ) . value ) ,
733
730
_ => Err ( ExpandError :: UnexpectedToken ) ,
734
731
} ;
735
- return tt_result. map ( |it| it . map ( Fragment :: Tokens ) ) . into ( ) ;
732
+ return tt_result. map ( |it| Some ( Fragment :: Tokens ( it ) ) ) . into ( ) ;
736
733
}
737
734
} ;
738
735
input. expect_fragment ( fragment) . map ( |it| it. map ( Fragment :: Tokens ) )
0 commit comments