Rollup merge of #104433 - TaKO8Ki:fix-104392, r=estebank
Fix `emit_unused_delims_expr` ICE Fixes #104392
This commit is contained in:
commit
c9ccb0ba28
3 changed files with 45 additions and 9 deletions
|
@ -533,16 +533,14 @@ trait UnusedDelimLint {
|
||||||
right_pos: Option<BytePos>,
|
right_pos: Option<BytePos>,
|
||||||
) {
|
) {
|
||||||
let spans = match value.kind {
|
let spans = match value.kind {
|
||||||
ast::ExprKind::Block(ref block, None) if block.stmts.len() > 0 => {
|
ast::ExprKind::Block(ref block, None) if block.stmts.len() == 1 => {
|
||||||
let start = block.stmts[0].span;
|
if let StmtKind::Expr(expr) = &block.stmts[0].kind
|
||||||
let end = block.stmts[block.stmts.len() - 1].span;
|
&& let ExprKind::Err = expr.kind
|
||||||
if let Some(start) = start.find_ancestor_inside(value.span)
|
|
||||||
&& let Some(end) = end.find_ancestor_inside(value.span)
|
|
||||||
{
|
{
|
||||||
Some((
|
return
|
||||||
value.span.with_hi(start.lo()),
|
}
|
||||||
value.span.with_lo(end.hi()),
|
if let Some(span) = block.stmts[0].span.find_ancestor_inside(value.span) {
|
||||||
))
|
Some((value.span.with_hi(span.lo()), value.span.with_lo(span.hi())))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
11
src/test/ui/lint/issue-104392.rs
Normal file
11
src/test/ui/lint/issue-104392.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fn main() {
|
||||||
|
{ unsafe 92 } //~ ERROR expected `{`, found `92`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo() {
|
||||||
|
{ mod 92 } //~ ERROR expected identifier, found `92`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bar() {
|
||||||
|
{ trait 92 } //~ ERROR expected identifier, found `92`
|
||||||
|
}
|
27
src/test/ui/lint/issue-104392.stderr
Normal file
27
src/test/ui/lint/issue-104392.stderr
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
error: expected `{`, found `92`
|
||||||
|
--> $DIR/issue-104392.rs:2:14
|
||||||
|
|
|
||||||
|
LL | { unsafe 92 }
|
||||||
|
| ------ ^^ expected `{`
|
||||||
|
| |
|
||||||
|
| while parsing this `unsafe` expression
|
||||||
|
|
|
||||||
|
help: try placing this code inside a block
|
||||||
|
|
|
||||||
|
LL | { unsafe { 92 } }
|
||||||
|
| + +
|
||||||
|
|
||||||
|
error: expected identifier, found `92`
|
||||||
|
--> $DIR/issue-104392.rs:6:11
|
||||||
|
|
|
||||||
|
LL | { mod 92 }
|
||||||
|
| ^^ expected identifier
|
||||||
|
|
||||||
|
error: expected identifier, found `92`
|
||||||
|
--> $DIR/issue-104392.rs:10:13
|
||||||
|
|
|
||||||
|
LL | { trait 92 }
|
||||||
|
| ^^ expected identifier
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue