@@ -225,43 +225,45 @@ pub fn expand_speculative(
225225
226226 // Do the actual expansion, we need to directly expand the proc macro due to the attribute args
227227 // Otherwise the expand query will fetch the non speculative attribute args and pass those instead.
228- let mut speculative_expansion = match loc. def . kind {
229- MacroDefKind :: ProcMacro ( expander, _, ast) => {
230- let span = db. proc_macro_span ( ast) ;
231- tt. delimiter = tt:: Delimiter :: invisible_spanned ( span) ;
232- expander. expand (
233- db,
234- loc. def . krate ,
235- loc. krate ,
236- & tt,
237- attr_arg. as_ref ( ) ,
238- span_with_def_site_ctxt ( db, span, actual_macro_call) ,
239- span_with_call_site_ctxt ( db, span, actual_macro_call) ,
240- span_with_mixed_site_ctxt ( db, span, actual_macro_call) ,
241- )
242- }
243- MacroDefKind :: BuiltInAttr ( BuiltinAttrExpander :: Derive , _) => {
244- pseudo_derive_attr_expansion ( & tt, attr_arg. as_ref ( ) ?, span)
245- }
246- MacroDefKind :: Declarative ( it) => {
247- db. decl_macro_expander ( loc. krate , it) . expand_unhygienic ( db, tt, loc. def . krate , span)
248- }
249- MacroDefKind :: BuiltIn ( it, _) => {
250- it. expand ( db, actual_macro_call, & tt, span) . map_err ( Into :: into)
251- }
252- MacroDefKind :: BuiltInDerive ( it, ..) => {
253- it. expand ( db, actual_macro_call, & tt, span) . map_err ( Into :: into)
254- }
255- MacroDefKind :: BuiltInEager ( it, _) => {
256- it. expand ( db, actual_macro_call, & tt, span) . map_err ( Into :: into)
257- }
258- MacroDefKind :: BuiltInAttr ( it, _) => it. expand ( db, actual_macro_call, & tt, span) ,
259- } ;
228+ let mut speculative_expansion =
229+ match loc. def . kind {
230+ MacroDefKind :: ProcMacro ( expander, _, ast) => {
231+ let span = db. proc_macro_span ( ast) ;
232+ tt. delimiter = tt:: Delimiter :: invisible_spanned ( span) ;
233+ expander. expand (
234+ db,
235+ loc. def . krate ,
236+ loc. krate ,
237+ & tt,
238+ attr_arg. as_ref ( ) ,
239+ span_with_def_site_ctxt ( db, span, actual_macro_call) ,
240+ span_with_call_site_ctxt ( db, span, actual_macro_call) ,
241+ span_with_mixed_site_ctxt ( db, span, actual_macro_call) ,
242+ )
243+ }
244+ MacroDefKind :: BuiltInAttr ( BuiltinAttrExpander :: Derive , _) => {
245+ pseudo_derive_attr_expansion ( & tt, attr_arg. as_ref ( ) ?, span)
246+ }
247+ MacroDefKind :: Declarative ( it) => db
248+ . decl_macro_expander ( loc. krate , it)
249+ . expand_unhygienic ( db, tt, loc. def . krate , span, loc. def . edition ) ,
250+ MacroDefKind :: BuiltIn ( it, _) => {
251+ it. expand ( db, actual_macro_call, & tt, span) . map_err ( Into :: into)
252+ }
253+ MacroDefKind :: BuiltInDerive ( it, ..) => {
254+ it. expand ( db, actual_macro_call, & tt, span) . map_err ( Into :: into)
255+ }
256+ MacroDefKind :: BuiltInEager ( it, _) => {
257+ it. expand ( db, actual_macro_call, & tt, span) . map_err ( Into :: into)
258+ }
259+ MacroDefKind :: BuiltInAttr ( it, _) => it. expand ( db, actual_macro_call, & tt, span) ,
260+ } ;
260261
261262 let expand_to = loc. expand_to ( ) ;
262263
263264 fixup:: reverse_fixups ( & mut speculative_expansion. value , & undo_info) ;
264- let ( node, rev_tmap) = token_tree_to_syntax_node ( & speculative_expansion. value , expand_to) ;
265+ let ( node, rev_tmap) =
266+ token_tree_to_syntax_node ( & speculative_expansion. value , expand_to, loc. def . edition ) ;
265267
266268 let syntax_node = node. syntax_node ( ) ;
267269 let token = rev_tmap
@@ -309,6 +311,7 @@ fn parse_macro_expansion(
309311) -> ExpandResult < ( Parse < SyntaxNode > , Arc < ExpansionSpanMap > ) > {
310312 let _p = tracing:: span!( tracing:: Level :: INFO , "parse_macro_expansion" ) . entered ( ) ;
311313 let loc = db. lookup_intern_macro_call ( macro_file. macro_call_id ) ;
314+ let edition = loc. def . edition ;
312315 let expand_to = loc. expand_to ( ) ;
313316 let mbe:: ValueResult { value : tt, err } = macro_expand ( db, macro_file. macro_call_id , loc) ;
314317
@@ -318,6 +321,7 @@ fn parse_macro_expansion(
318321 CowArc :: Owned ( it) => it,
319322 } ,
320323 expand_to,
324+ edition,
321325 ) ;
322326
323327 ExpandResult { value : ( parse, Arc :: new ( rev_token_map) ) , err }
@@ -668,6 +672,7 @@ fn expand_proc_macro(db: &dyn ExpandDatabase, id: MacroCallId) -> ExpandResult<A
668672fn token_tree_to_syntax_node (
669673 tt : & tt:: Subtree ,
670674 expand_to : ExpandTo ,
675+ edition : parser:: Edition ,
671676) -> ( Parse < SyntaxNode > , ExpansionSpanMap ) {
672677 let entry_point = match expand_to {
673678 ExpandTo :: Statements => mbe:: TopEntryPoint :: MacroStmts ,
@@ -676,7 +681,7 @@ fn token_tree_to_syntax_node(
676681 ExpandTo :: Type => mbe:: TopEntryPoint :: Type ,
677682 ExpandTo :: Expr => mbe:: TopEntryPoint :: Expr ,
678683 } ;
679- mbe:: token_tree_to_syntax_node ( tt, entry_point, parser :: Edition :: CURRENT )
684+ mbe:: token_tree_to_syntax_node ( tt, entry_point, edition )
680685}
681686
682687fn check_tt_count ( tt : & tt:: Subtree ) -> Result < ( ) , ExpandResult < ( ) > > {
0 commit comments