@@ -4,7 +4,7 @@ use base_db::AnchoredPath;
44use cfg:: CfgExpr ;
55use either:: Either ;
66use intern:: { sym, Symbol } ;
7- use mbe:: { parse_exprs_with_sep, parse_to_token_tree} ;
7+ use mbe:: { parse_exprs_with_sep, parse_to_token_tree, DelimiterKind } ;
88use span:: { Edition , EditionedFileId , Span , SpanAnchor , SyntaxContextId , ROOT_ERASED_FILE_AST_ID } ;
99use stdx:: format_to;
1010use syntax:: {
@@ -34,15 +34,15 @@ macro_rules! register_builtin {
3434 }
3535
3636 impl BuiltinFnLikeExpander {
37- pub fn expander( & self ) -> fn ( & dyn ExpandDatabase , MacroCallId , & tt:: Subtree , Span ) -> ExpandResult <tt:: Subtree > {
37+ fn expander( & self ) -> fn ( & dyn ExpandDatabase , MacroCallId , & tt:: Subtree , Span ) -> ExpandResult <tt:: Subtree > {
3838 match * self {
3939 $( BuiltinFnLikeExpander :: $kind => $expand, ) *
4040 }
4141 }
4242 }
4343
4444 impl EagerExpander {
45- pub fn expander( & self ) -> fn ( & dyn ExpandDatabase , MacroCallId , & tt:: Subtree , Span ) -> ExpandResult <tt:: Subtree > {
45+ fn expander( & self ) -> fn ( & dyn ExpandDatabase , MacroCallId , & tt:: Subtree , Span ) -> ExpandResult <tt:: Subtree > {
4646 match * self {
4747 $( EagerExpander :: $e_kind => $e_expand, ) *
4848 }
@@ -711,6 +711,20 @@ fn parse_string(tt: &tt::Subtree) -> Result<(Symbol, Span), ExpandError> {
711711 kind : tt:: LitKind :: Str ,
712712 suffix : _,
713713 } ) ) => Some ( ( unescape_str ( text) , * span) ) ,
714+ // FIXME: We wrap expression fragments in parentheses which can break this expectation
715+ // here
716+ // Remove this once we handle none delims correctly
717+ tt:: TokenTree :: Subtree ( t) if t. delimiter . kind == DelimiterKind :: Parenthesis => {
718+ t. token_trees . first ( ) . and_then ( |tt| match tt {
719+ tt:: TokenTree :: Leaf ( tt:: Leaf :: Literal ( tt:: Literal {
720+ symbol : text,
721+ span,
722+ kind : tt:: LitKind :: Str ,
723+ suffix : _,
724+ } ) ) => Some ( ( unescape_str ( text) , * span) ) ,
725+ _ => None ,
726+ } )
727+ }
714728 _ => None ,
715729 } )
716730 . ok_or ( mbe:: ExpandError :: ConversionError . into ( ) )
0 commit comments