diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-09-29 19:20:12 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-29 19:20:12 +0000 |
| commit | b21f15a23767c8d06ab5da60f59b8b197c45831a (patch) | |
| tree | f448c79bb3d4fc39d8b8e947d1cebca28c9972f5 | |
| parent | 9e3e98db8ac9374916e76de42e6710dc23caacbc (diff) | |
| parent | 034dd41ea81264a6cb3f4e84d49a99ecd4a96406 (diff) | |
| download | rust-b21f15a23767c8d06ab5da60f59b8b197c45831a.tar.gz rust-b21f15a23767c8d06ab5da60f59b8b197c45831a.zip | |
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 <giaco.stevanato@gmail.com>
| -rw-r--r-- | crates/hir_def/src/generics.rs | 2 | ||||
| -rw-r--r-- | crates/hir_ty/src/tests/regression.rs | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/crates/hir_def/src/generics.rs b/crates/hir_def/src/generics.rs index 8c5313fa458..8622357cd42 100644 --- a/crates/hir_def/src/generics.rs +++ b/crates/hir_def/src/generics.rs @@ -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); diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 2f38d584a12..67952edca38 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs @@ -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 +} + "#, + ) +} |
