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 | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/crates/hir-expand/src/builtin/fn_macro.rs b/crates/hir-expand/src/builtin/fn_macro.rs index ca06979190..b99eac7aea 100644 --- a/crates/hir-expand/src/builtin/fn_macro.rs +++ b/crates/hir-expand/src/builtin/fn_macro.rs @@ -8,7 +8,7 @@ use intern::{ sym::{self}, }; use mbe::{DelimiterKind, expect_fragment}; -use span::{Edition, EditionedFileId, FileId, Span}; +use span::{Edition, FileId, Span}; use stdx::format_to; use syntax::{ format_smolstr, @@ -17,7 +17,7 @@ use syntax::{ use syntax_bridge::syntax_node_to_token_tree; use crate::{ - ExpandError, ExpandResult, HirFileIdExt, Lookup as _, MacroCallId, + EditionedFileId, ExpandError, ExpandResult, Lookup as _, MacroCallId, builtin::quote::{WithDelimiter, dollar_crate, quote}, db::ExpandDatabase, hygiene::{span_with_call_site_ctxt, span_with_def_site_ctxt}, @@ -72,7 +72,7 @@ impl BuiltinFnLikeExpander { tt: &tt::TopSubtree, span: Span, ) -> ExpandResult<tt::TopSubtree> { - let span = span_with_def_site_ctxt(db, span, id, Edition::CURRENT); + let span = span_with_def_site_ctxt(db, span, id.into(), Edition::CURRENT); self.expander()(db, id, tt, span) } @@ -89,7 +89,7 @@ impl EagerExpander { tt: &tt::TopSubtree, span: Span, ) -> ExpandResult<tt::TopSubtree> { - let span = span_with_def_site_ctxt(db, span, id, Edition::CURRENT); + let span = span_with_def_site_ctxt(db, span, id.into(), Edition::CURRENT); self.expander()(db, id, tt, span) } @@ -224,7 +224,7 @@ fn assert_expand( tt: &tt::TopSubtree, span: Span, ) -> ExpandResult<tt::TopSubtree> { - let call_site_span = span_with_call_site_ctxt(db, span, id, Edition::CURRENT); + let call_site_span = span_with_call_site_ctxt(db, span, id.into(), Edition::CURRENT); let mut iter = tt.iter(); @@ -345,7 +345,7 @@ fn panic_expand( span: Span, ) -> ExpandResult<tt::TopSubtree> { let dollar_crate = dollar_crate(span); - let call_site_span = span_with_call_site_ctxt(db, span, id, Edition::CURRENT); + let call_site_span = span_with_call_site_ctxt(db, span, id.into(), Edition::CURRENT); let mac = if use_panic_2021(db, call_site_span) { sym::panic_2021.clone() @@ -376,7 +376,7 @@ fn unreachable_expand( span: Span, ) -> ExpandResult<tt::TopSubtree> { let dollar_crate = dollar_crate(span); - let call_site_span = span_with_call_site_ctxt(db, span, id, Edition::CURRENT); + let call_site_span = span_with_call_site_ctxt(db, span, id.into(), Edition::CURRENT); let mac = if use_panic_2021(db, call_site_span) { sym::unreachable_2021.clone() @@ -407,7 +407,7 @@ fn use_panic_2021(db: &dyn ExpandDatabase, span: Span) -> bool { let Some(expn) = span.ctx.outer_expn(db) else { break false; }; - let expn = db.lookup_intern_macro_call(expn); + let expn = db.lookup_intern_macro_call(expn.into()); // FIXME: Record allow_internal_unstable in the macro def (not been done yet because it // would consume quite a bit extra memory for all call locs...) // if let Some(features) = expn.def.allow_internal_unstable { @@ -663,7 +663,7 @@ fn relative_file( err_span: Span, ) -> Result<EditionedFileId, ExpandError> { let lookup = db.lookup_intern_macro_call(call_id); - let call_site = lookup.kind.file_id().original_file_respecting_includes(db).file_id(); + let call_site = lookup.kind.file_id().original_file_respecting_includes(db).file_id(db); let path = AnchoredPath { anchor: call_site, path: path_str }; let res: FileId = db .resolve_path(path) @@ -672,7 +672,7 @@ fn relative_file( if res == call_site && !allow_recursion { Err(ExpandError::other(err_span, format!("recursive inclusion of `{path_str}`"))) } else { - Ok(EditionedFileId::new(res, lookup.krate.data(db).edition)) + Ok(EditionedFileId::new(db, res, lookup.krate.data(db).edition)) } } @@ -731,10 +731,8 @@ fn include_expand( tt: &tt::TopSubtree, span: Span, ) -> ExpandResult<tt::TopSubtree> { - let (file_id_wrapper, editioned_file_id) = match include_input_to_file_id(db, arg_id, tt) { - Ok(editioned_file_id) => { - (base_db::EditionedFileId::new(db, editioned_file_id), editioned_file_id) - } + let editioned_file_id = match include_input_to_file_id(db, arg_id, tt) { + Ok(editioned_file_id) => editioned_file_id, Err(e) => { return ExpandResult::new( tt::TopSubtree::empty(DelimSpan { open: span, close: span }), @@ -745,7 +743,7 @@ fn include_expand( let span_map = db.real_span_map(editioned_file_id); // FIXME: Parse errors ExpandResult::ok(syntax_node_to_token_tree( - &db.parse(file_id_wrapper).syntax_node(), + &db.parse(editioned_file_id).syntax_node(), SpanMap::RealSpanMap(span_map), span, syntax_bridge::DocCommentDesugarMode::ProcMacro, @@ -807,7 +805,7 @@ fn include_str_expand( } }; - let text = db.file_text(file_id.file_id()); + let text = db.file_text(file_id.file_id(db)); let text = &*text.text(db); ExpandResult::ok(quote!(call_site =>#text)) |