10389: fix: use the right `HirFileId` when expanding macros in fn parameters r=Veykril a=SkiFire13

Fixes #10388

Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
This commit is contained in:
bors[bot] 2021-09-29 19:20:12 +00:00 committed by GitHub
commit b21f15a237
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -299,7 +299,7 @@ impl GenericParams {
let macro_call = mc.to_node(db.upcast());
match expander.enter_expand::<ast::Type>(db, macro_call) {
Ok(ExpandResult { value: Some((mark, expanded)), .. }) => {
let ctx = LowerCtx::new(db, mc.file_id);
let ctx = LowerCtx::new(db, expander.current_file_id());
let type_ref = TypeRef::from_ast(&ctx, expanded);
self.fill_implicit_impl_trait_args(db, expander, &type_ref);
expander.exit(db, mark);

View file

@ -1198,3 +1198,26 @@ fn bar() {
"#,
)
}
#[test]
fn nested_macro_in_fn_params() {
check_no_mismatches(
r#"
macro_rules! U32Inner {
() => {
u32
};
}
macro_rules! U32 {
() => {
U32Inner!()
};
}
fn mamba(a: U32!(), p: u32) -> u32 {
a
}
"#,
)
}