mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
fix: Fix multiple derives in one attribute not expanding all in expand_macro
This commit is contained in:
parent
3f9f63c1bd
commit
0f3617f76f
6 changed files with 59 additions and 19 deletions
|
@ -37,10 +37,11 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<
|
|||
if path == "derive" {
|
||||
let mut tt = tt.syntax().children_with_tokens().skip(1).join("");
|
||||
tt.pop();
|
||||
return sema
|
||||
.expand_derive_macro(&attr)
|
||||
.map(insert_whitespaces)
|
||||
.map(|expansion| ExpandedMacro { name: tt, expansion });
|
||||
let expansions = sema.expand_derive_macro(&attr)?;
|
||||
return Some(ExpandedMacro {
|
||||
name: tt,
|
||||
expansion: expansions.into_iter().map(insert_whitespaces).join(""),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,4 +383,26 @@ struct Foo {}
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn macro_expand_derive_multi() {
|
||||
check(
|
||||
r#"
|
||||
#[rustc_builtin_macro]
|
||||
pub macro Clone {}
|
||||
#[rustc_builtin_macro]
|
||||
pub macro Copy {}
|
||||
|
||||
#[derive(Cop$0y, Clone)]
|
||||
struct Foo {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
Copy, Clone
|
||||
impl< >crate::marker::Copy for Foo< >{}
|
||||
|
||||
impl< >crate::clone::Clone for Foo< >{}
|
||||
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue