11664: fix: Properly handle proc-macro crate types for nameres r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2022-03-09 21:45:42 +00:00 committed by GitHub
commit 5b51cb835a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 219 additions and 150 deletions

View file

@ -1244,6 +1244,7 @@ use mac::fn_macro;
fn_macro$0!();
//- /mac.rs crate:mac
#![crate_type="proc-macro"]
#[proc_macro]
fn fn_macro() {}
//^^^^^^^^

View file

@ -231,6 +231,7 @@ impl Analysis {
cfg_options,
Env::default(),
Default::default(),
false,
Default::default(),
);
change.change_file(file_id, Some(Arc::new(text)));

View file

@ -1501,16 +1501,15 @@ fn f() {
check(
r#"
//- proc_macros: identity
#[proc_macros::identity]
fn func$0() {
func();
}
"#,
expect![[r#"
func Function FileId(0) 26..51 29..33
func Function FileId(0) 25..50 28..32
FileId(0) 42..46
FileId(0) 41..45
"#]],
)
}
@ -1555,11 +1554,12 @@ fn func() {}
);
check(
r#"
#![crate_type="proc-macro"]
#[proc_macro_attribute]
fn func$0() {}
"#,
expect![[r#"
func Attribute FileId(0) 0..36 27..31
func Attribute FileId(0) 28..64 55..59
(no references)
"#]],
@ -1604,11 +1604,12 @@ struct Foo;
);
check(
r#"
#![crate_type="proc-macro"]
#[proc_macro_derive(Derive, attributes(x))]
pub fn deri$0ve(_stream: TokenStream) -> TokenStream {}
"#,
expect![[r#"
derive Derive FileId(0) 0..97 51..57
derive Derive FileId(0) 28..125 79..85
(no references)
"#]],

View file

@ -34,6 +34,7 @@ pub(crate) fn shuffle_crate_graph(db: &mut RootDatabase) {
data.potential_cfg_options.clone(),
data.env.clone(),
data.proc_macro.clone(),
data.is_proc_macro,
data.origin.clone(),
);
map.insert(old_id, new_id);