File tree Expand file tree Collapse file tree 2 files changed +46
-2
lines changed
ide-diagnostics/src/handlers Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ impl ExprValidator {
117
117
Expr :: If { .. } => {
118
118
self . check_for_unnecessary_else ( id, expr, db) ;
119
119
}
120
- Expr :: Block { .. } => {
120
+ Expr :: Block { .. } | Expr :: Async { .. } | Expr :: Unsafe { .. } => {
121
121
self . validate_block ( db, expr) ;
122
122
}
123
123
_ => { }
@@ -254,7 +254,12 @@ impl ExprValidator {
254
254
}
255
255
256
256
fn validate_block ( & mut self , db : & dyn HirDatabase , expr : & Expr ) {
257
- let Expr :: Block { statements, .. } = expr else { return } ;
257
+ let ( Expr :: Block { statements, .. }
258
+ | Expr :: Async { statements, .. }
259
+ | Expr :: Unsafe { statements, .. } ) = expr
260
+ else {
261
+ return ;
262
+ } ;
258
263
let pattern_arena = Arena :: new ( ) ;
259
264
let cx = MatchCheckCtx :: new ( self . owner . module ( db. upcast ( ) ) , self . owner , db) ;
260
265
for stmt in & * * statements {
Original file line number Diff line number Diff line change @@ -41,6 +41,45 @@ fn main() {
41
41
fn main() {
42
42
let Some(_) | None = Some(5);
43
43
}
44
+ "# ,
45
+ ) ;
46
+ }
47
+
48
+ #[ test]
49
+ fn option_nonexhaustive_inside_blocks ( ) {
50
+ check_diagnostics (
51
+ r#"
52
+ //- minicore: option
53
+ fn main() {
54
+ '_a: {
55
+ let None = Some(5);
56
+ //^^^^ error: non-exhaustive pattern: `Some(_)` not covered
57
+ }
58
+ }
59
+ "# ,
60
+ ) ;
61
+
62
+ check_diagnostics (
63
+ r#"
64
+ //- minicore: future, option
65
+ fn main() {
66
+ let _ = async {
67
+ let None = Some(5);
68
+ //^^^^ error: non-exhaustive pattern: `Some(_)` not covered
69
+ };
70
+ }
71
+ "# ,
72
+ ) ;
73
+
74
+ check_diagnostics (
75
+ r#"
76
+ //- minicore: option
77
+ fn main() {
78
+ unsafe {
79
+ let None = Some(5);
80
+ //^^^^ error: non-exhaustive pattern: `Some(_)` not covered
81
+ }
82
+ }
44
83
"# ,
45
84
) ;
46
85
}
You can’t perform that action at this time.
0 commit comments