@@ -4,7 +4,7 @@ use base_db::AnchoredPath;
4
4
use cfg:: CfgExpr ;
5
5
use either:: Either ;
6
6
use 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 } ;
8
8
use span:: { Edition , EditionedFileId , Span , SpanAnchor , SyntaxContextId , ROOT_ERASED_FILE_AST_ID } ;
9
9
use stdx:: format_to;
10
10
use syntax:: {
@@ -34,15 +34,15 @@ macro_rules! register_builtin {
34
34
}
35
35
36
36
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 > {
38
38
match * self {
39
39
$( BuiltinFnLikeExpander :: $kind => $expand, ) *
40
40
}
41
41
}
42
42
}
43
43
44
44
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 > {
46
46
match * self {
47
47
$( EagerExpander :: $e_kind => $e_expand, ) *
48
48
}
@@ -711,6 +711,20 @@ fn parse_string(tt: &tt::Subtree) -> Result<(Symbol, Span), ExpandError> {
711
711
kind : tt:: LitKind :: Str ,
712
712
suffix : _,
713
713
} ) ) => 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
+ }
714
728
_ => None ,
715
729
} )
716
730
. ok_or ( mbe:: ExpandError :: ConversionError . into ( ) )
0 commit comments