Skip to content

Commit b21f15a

Browse files
bors[bot]SkiFire13
andauthored
Merge #10389
10389: fix: use the right `HirFileId` when expanding macros in fn parameters r=Veykril a=SkiFire13 Fixes #10388 Co-authored-by: Giacomo Stevanato <[email protected]>
2 parents 9e3e98d + 034dd41 commit b21f15a

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

crates/hir_def/src/generics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ impl GenericParams {
299299
let macro_call = mc.to_node(db.upcast());
300300
match expander.enter_expand::<ast::Type>(db, macro_call) {
301301
Ok(ExpandResult { value: Some((mark, expanded)), .. }) => {
302-
let ctx = LowerCtx::new(db, mc.file_id);
302+
let ctx = LowerCtx::new(db, expander.current_file_id());
303303
let type_ref = TypeRef::from_ast(&ctx, expanded);
304304
self.fill_implicit_impl_trait_args(db, expander, &type_ref);
305305
expander.exit(db, mark);

crates/hir_ty/src/tests/regression.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,3 +1198,26 @@ fn bar() {
11981198
"#,
11991199
)
12001200
}
1201+
1202+
#[test]
1203+
fn nested_macro_in_fn_params() {
1204+
check_no_mismatches(
1205+
r#"
1206+
macro_rules! U32Inner {
1207+
() => {
1208+
u32
1209+
};
1210+
}
1211+
1212+
macro_rules! U32 {
1213+
() => {
1214+
U32Inner!()
1215+
};
1216+
}
1217+
1218+
fn mamba(a: U32!(), p: u32) -> u32 {
1219+
a
1220+
}
1221+
"#,
1222+
)
1223+
}

0 commit comments

Comments
 (0)