fix: semicolon_outside_block suggests wrongly when inside macros
This commit is contained in:
parent
57cbadd68a
commit
12fc6c7cc9
3 changed files with 51 additions and 1 deletions
|
|
@ -143,7 +143,7 @@ impl LateLintPass<'_> for SemicolonBlock {
|
|||
StmtKind::Expr(Expr {
|
||||
kind: ExprKind::Block(block, _),
|
||||
..
|
||||
}) if !block.span.from_expansion() => {
|
||||
}) if !block.span.from_expansion() && stmt.span.contains(block.span) => {
|
||||
let Block {
|
||||
expr: None,
|
||||
stmts: [.., stmt],
|
||||
|
|
|
|||
|
|
@ -96,3 +96,28 @@ fn main() {
|
|||
|
||||
unit_fn_block()
|
||||
}
|
||||
|
||||
fn issue14926() {
|
||||
macro_rules! gen_code {
|
||||
[$l:lifetime: $b:block, $b2: block $(,)?] => {
|
||||
$l: loop {
|
||||
$b
|
||||
break $l;
|
||||
}
|
||||
$l: loop {
|
||||
$b2
|
||||
break $l;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
gen_code! {
|
||||
'root:
|
||||
{
|
||||
println!("Block1");
|
||||
},
|
||||
{
|
||||
println!("Block2");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,3 +96,28 @@ fn main() {
|
|||
|
||||
unit_fn_block()
|
||||
}
|
||||
|
||||
fn issue14926() {
|
||||
macro_rules! gen_code {
|
||||
[$l:lifetime: $b:block, $b2: block $(,)?] => {
|
||||
$l: loop {
|
||||
$b
|
||||
break $l;
|
||||
}
|
||||
$l: loop {
|
||||
$b2
|
||||
break $l;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
gen_code! {
|
||||
'root:
|
||||
{
|
||||
println!("Block1");
|
||||
},
|
||||
{
|
||||
println!("Block2");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue