Merge pull request #21490 from ChayimFriedman2/expand-derive-builtin
fix: Do not mix the order of builtin/regular derives in "Expand macro recursively"
This commit is contained in:
commit
fd80a3eded
2 changed files with 21 additions and 3 deletions
|
|
@ -641,11 +641,14 @@ impl<'db> SemanticsImpl<'db> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn expand_derive_macro(&self, attr: &ast::Attr) -> Option<Vec<ExpandResult<SyntaxNode>>> {
|
||||
pub fn expand_derive_macro(
|
||||
&self,
|
||||
attr: &ast::Attr,
|
||||
) -> Option<Vec<Option<ExpandResult<SyntaxNode>>>> {
|
||||
let res: Vec<_> = self
|
||||
.derive_macro_calls(attr)?
|
||||
.into_iter()
|
||||
.flat_map(|call| {
|
||||
.map(|call| {
|
||||
let file_id = call?.left()?;
|
||||
let ExpandResult { value, err } = self.db.parse_macro_expansion(file_id);
|
||||
let root_node = value.0.syntax_node();
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<
|
|||
.take_while(|it| it != &token)
|
||||
.filter(|it| it.kind() == T![,])
|
||||
.count();
|
||||
let ExpandResult { err, value: expansion } = expansions.get(idx)?.clone();
|
||||
let ExpandResult { err, value: expansion } = expansions.get(idx)?.clone()?;
|
||||
let expansion_file_id = sema.hir_file_for(&expansion).macro_file()?;
|
||||
let expansion_span_map = db.expansion_span_map(expansion_file_id);
|
||||
let mut expansion = format(
|
||||
|
|
@ -848,4 +848,19 @@ struct S {
|
|||
u32"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_21489() {
|
||||
check(
|
||||
r#"
|
||||
//- proc_macros: derive_identity
|
||||
//- minicore: derive, fmt
|
||||
#[derive(Debug, proc_macros::DeriveIdentity$0)]
|
||||
struct Foo;
|
||||
"#,
|
||||
expect![[r#"
|
||||
proc_macros::DeriveIdentity
|
||||
struct Foo;"#]],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue