mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Merge #7133
7133: Proper handling $crate and local_inner_macros r=jonas-schievink a=edwin0cheng This PR introduces `HygineFrames` to store the macro definition/call site hierarchy in hyginee and when resolving `local_inner_macros` and `$crate`, we use the token to look up the corresponding frame and return the correct value. See also: https://rustc-dev-guide.rust-lang.org/macro-expansion.html#hygiene-and-hierarchies fixe #6890 and #6788 r? @jonas-schievink Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
commit
a88d4f8c72
7 changed files with 178 additions and 54 deletions
|
@ -370,6 +370,37 @@ expand!();
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_macro_with_dollar_crate_in_def_site() {
|
||||
check_types(
|
||||
r#"
|
||||
//- /main.rs crate:main deps:foo
|
||||
use foo::expand;
|
||||
|
||||
macro_rules! list {
|
||||
($($tt:tt)*) => { $($tt)* }
|
||||
}
|
||||
|
||||
fn test() {
|
||||
let r = expand!();
|
||||
r;
|
||||
//^ u128
|
||||
}
|
||||
|
||||
//- /lib.rs crate:foo
|
||||
#[macro_export]
|
||||
macro_rules! expand {
|
||||
() => { list!($crate::m!()) };
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! m {
|
||||
() => { 0u128 };
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn infer_type_value_non_legacy_macro_use_as() {
|
||||
check_infer(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue