use the included file as the source of expanded include macro

Signed-off-by: Yilin Chen <sticnarf@gmail.com>
This commit is contained in:
Yilin Chen 2021-03-21 23:02:01 +08:00
parent a0ed87ff56
commit 3bb9efb6b7
No known key found for this signature in database
GPG key ID: 353E7ED34BF326E0
5 changed files with 107 additions and 28 deletions

View file

@ -124,6 +124,7 @@ pub fn expand_eager_macro(
subtree: Arc::new(parsed_args.clone()),
krate,
call: call_id,
included_file: None,
}
});
let arg_file_id: MacroCallId = arg_id.into();
@ -143,9 +144,15 @@ pub fn expand_eager_macro(
if let MacroDefKind::BuiltInEager(eager, _) = def.kind {
let res = eager.expand(db, arg_id, &subtree);
let (subtree, fragment) = diagnostic_sink.expand_result_option(res)?;
let eager =
EagerCallLoc { def, fragment, subtree: Arc::new(subtree), krate, call: call_id };
let expanded = diagnostic_sink.expand_result_option(res)?;
let eager = EagerCallLoc {
def,
fragment: expanded.fragment,
subtree: Arc::new(expanded.subtree),
krate,
call: call_id,
included_file: expanded.included_file,
};
Ok(db.intern_eager_expansion(eager))
} else {