return when expr has errors
add ui tests
This commit is contained in:
parent
061610640c
commit
1cf4132a16
3 changed files with 43 additions and 0 deletions
|
@ -518,6 +518,11 @@ trait UnusedDelimLint {
|
|||
) {
|
||||
let spans = match value.kind {
|
||||
ast::ExprKind::Block(ref block, None) if block.stmts.len() == 1 => {
|
||||
if let StmtKind::Expr(expr) = &block.stmts[0].kind
|
||||
&& let ExprKind::Err = expr.kind
|
||||
{
|
||||
return
|
||||
}
|
||||
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 {
|
||||
|
|
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