rust-analyzer version: 0.0.300
As far as I understand generated getters in ast classes take the first child that matches the required type. However since AsmExpr is now also an Item (and therefore a Stmt), this can lead to overlaps where the last element of ast::MacroStmts::statements() will be a duplicate of ast::MacroStmts::expr(). This can be reproduced by any use of asm!, for example this one coming from https://doc.rust-lang.org/reference/inline-assembly.html
code snippet to reproduce:
use std::arch::asm;
let mut x: u64 = 4;
unsafe {
asm!(
"mov {tmp}, {x}",
"shl {tmp}, 1",
"shl {x}, 2",
"add {x}, {tmp}",
x = inout(reg) x,
tmp = out(reg) _,
);
}
When expanding macros, this will result in a MacroStmts instance that exhibits this duplication. I don't know if this could cause any issues elsewhere in the library.
Theoretically this problem could also appear in StmtList, which is
'{'
Attr*
statements:Stmt*
tail_expr:Expr?
'}'
but I think that can't happen in practice yet, as there's no other way to produce an AsmExpr (and therefore something that is both an Expr and a Stmt) than by asm! or similar inline assembly macros, so an AsmExpr won't show up as a tail_expr in any StmtList instance.
rust-analyzer version: 0.0.300
As far as I understand generated getters in
astclasses take the first child that matches the required type. However sinceAsmExpris now also anItem(and therefore aStmt), this can lead to overlaps where the last element ofast::MacroStmts::statements()will be a duplicate ofast::MacroStmts::expr(). This can be reproduced by any use ofasm!, for example this one coming from https://doc.rust-lang.org/reference/inline-assembly.htmlcode snippet to reproduce:
When expanding macros, this will result in a
MacroStmtsinstance that exhibits this duplication. I don't know if this could cause any issues elsewhere in the library.Theoretically this problem could also appear in
StmtList, which isbut I think that can't happen in practice yet, as there's no other way to produce an
AsmExpr(and therefore something that is both anExprand aStmt) than byasm!or similar inline assembly macros, so anAsmExprwon't show up as atail_exprin anyStmtListinstance.