File tree 3 files changed +21
-0
lines changed
ide-diagnostics/src/handlers
3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,9 @@ impl ExpressionStore {
282
282
}
283
283
}
284
284
285
+ /// Walks the immediate children expressions and calls `f` for each child expression.
286
+ ///
287
+ /// Note that this does not walk const blocks.
285
288
pub fn walk_child_exprs ( & self , expr_id : ExprId , mut f : impl FnMut ( ExprId ) ) {
286
289
let expr = & self [ expr_id] ;
287
290
match expr {
@@ -415,6 +418,10 @@ impl ExpressionStore {
415
418
}
416
419
}
417
420
421
+ /// Walks the immediate children expressions and calls `f` for each child expression but does
422
+ /// not walk expressions within patterns.
423
+ ///
424
+ /// Note that this does not walk const blocks.
418
425
pub fn walk_child_exprs_without_pats ( & self , expr_id : ExprId , mut f : impl FnMut ( ExprId ) ) {
419
426
let expr = & self [ expr_id] ;
420
427
match expr {
Original file line number Diff line number Diff line change @@ -348,6 +348,7 @@ impl<'a> UnsafeVisitor<'a> {
348
348
Expr :: Closure { args, .. } => {
349
349
self . walk_pats_top ( args. iter ( ) . copied ( ) , current) ;
350
350
}
351
+ Expr :: Const ( e) => self . walk_expr ( * e) ,
351
352
_ => { }
352
353
}
353
354
Original file line number Diff line number Diff line change @@ -874,6 +874,19 @@ fn baz() {
874
874
fn f(it: unsafe fn()){
875
875
it();
876
876
// ^^^^ 💡 error: call to unsafe function is unsafe and requires an unsafe function or block
877
+ }
878
+ "# ,
879
+ ) ;
880
+ }
881
+
882
+ #[ test]
883
+ fn unsafe_call_in_const_expr ( ) {
884
+ check_diagnostics (
885
+ r#"
886
+ unsafe fn f() {}
887
+ fn main() {
888
+ const { f(); };
889
+ // ^^^ 💡 error: call to unsafe function is unsafe and requires an unsafe function or block
877
890
}
878
891
"# ,
879
892
) ;
You can’t perform that action at this time.
0 commit comments