Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-expand/src/builtin/fn_macro.rs')
| -rw-r--r-- | crates/hir-expand/src/builtin/fn_macro.rs | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/crates/hir-expand/src/builtin/fn_macro.rs b/crates/hir-expand/src/builtin/fn_macro.rs index d04225b872..4894c7a931 100644 --- a/crates/hir-expand/src/builtin/fn_macro.rs +++ b/crates/hir-expand/src/builtin/fn_macro.rs @@ -5,19 +5,20 @@ use cfg::CfgExpr; use either::Either; use intern::{sym, Symbol}; use mbe::{expect_fragment, DelimiterKind}; -use span::{Edition, EditionedFileId, Span, SpanAnchor, SyntaxContextId, ROOT_ERASED_FILE_AST_ID}; +use span::{Edition, EditionedFileId, Span}; use stdx::format_to; use syntax::{ format_smolstr, unescape::{unescape_byte, unescape_char, unescape_unicode, Mode}, }; -use syntax_bridge::parse_to_token_tree; +use syntax_bridge::syntax_node_to_token_tree; use crate::{ builtin::quote::{dollar_crate, quote}, db::ExpandDatabase, hygiene::{span_with_call_site_ctxt, span_with_def_site_ctxt}, name, + span_map::SpanMap, tt::{self, DelimSpan}, ExpandError, ExpandResult, HirFileIdExt, Lookup as _, MacroCallId, }; @@ -739,18 +740,14 @@ fn include_expand( return ExpandResult::new(tt::Subtree::empty(DelimSpan { open: span, close: span }), e) } }; - match parse_to_token_tree( - file_id.edition(), - SpanAnchor { file_id, ast_id: ROOT_ERASED_FILE_AST_ID }, - SyntaxContextId::ROOT, - &db.file_text(file_id.file_id()), - ) { - Some(it) => ExpandResult::ok(it), - None => ExpandResult::new( - tt::Subtree::empty(DelimSpan { open: span, close: span }), - ExpandError::other(span, "failed to parse included file"), - ), - } + let span_map = db.real_span_map(file_id); + // FIXME: Parse errors + ExpandResult::ok(syntax_node_to_token_tree( + &db.parse(file_id).syntax_node(), + SpanMap::RealSpanMap(span_map), + span, + syntax_bridge::DocCommentDesugarMode::ProcMacro, + )) } pub fn include_input_to_file_id( |