File tree 3 files changed +45
-9
lines changed
3 files changed +45
-9
lines changed Original file line number Diff line number Diff line change @@ -533,16 +533,14 @@ trait UnusedDelimLint {
533
533
right_pos : Option < BytePos > ,
534
534
) {
535
535
let spans = match value. kind {
536
- ast:: ExprKind :: Block ( ref block, None ) if block. stmts . len ( ) > 0 => {
537
- let start = block. stmts [ 0 ] . span ;
538
- let end = block. stmts [ block. stmts . len ( ) - 1 ] . span ;
539
- if let Some ( start) = start. find_ancestor_inside ( value. span )
540
- && let Some ( end) = end. find_ancestor_inside ( value. span )
536
+ ast:: ExprKind :: Block ( ref block, None ) if block. stmts . len ( ) == 1 => {
537
+ if let StmtKind :: Expr ( expr) = & block. stmts [ 0 ] . kind
538
+ && let ExprKind :: Err = expr. kind
541
539
{
542
- Some ( (
543
- value . span . with_hi ( start . lo ( ) ) ,
544
- value . span . with_lo ( end . hi ( ) ) ,
545
- ) )
540
+ return
541
+ }
542
+ if let Some ( span ) = block . stmts [ 0 ] . span . find_ancestor_inside ( value . span ) {
543
+ Some ( ( value . span . with_hi ( span . lo ( ) ) , value . span . with_lo ( span . hi ( ) ) ) )
546
544
} else {
547
545
None
548
546
}
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ { unsafe 92 } //~ ERROR expected `{`, found `92`
3
+ }
4
+
5
+ fn foo ( ) {
6
+ { mod 92 } //~ ERROR expected identifier, found `92`
7
+ }
8
+
9
+ fn bar ( ) {
10
+ { trait 92 } //~ ERROR expected identifier, found `92`
11
+ }
Original file line number Diff line number Diff line change
1
+ error: expected `{`, found `92`
2
+ --> $DIR/issue-104392.rs:2:14
3
+ |
4
+ LL | { unsafe 92 }
5
+ | ------ ^^ expected `{`
6
+ | |
7
+ | while parsing this `unsafe` expression
8
+ |
9
+ help: try placing this code inside a block
10
+ |
11
+ LL | { unsafe { 92 } }
12
+ | + +
13
+
14
+ error: expected identifier, found `92`
15
+ --> $DIR/issue-104392.rs:6:11
16
+ |
17
+ LL | { mod 92 }
18
+ | ^^ expected identifier
19
+
20
+ error: expected identifier, found `92`
21
+ --> $DIR/issue-104392.rs:10:13
22
+ |
23
+ LL | { trait 92 }
24
+ | ^^ expected identifier
25
+
26
+ error: aborting due to 3 previous errors
27
+
You can’t perform that action at this time.
0 commit comments