File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
ide-diagnostics/src/handlers Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -282,6 +282,9 @@ impl ExpressionStore {
282282 }
283283 }
284284
285+ /// Walks the immediate children expressions and calls `f` for each child expression.
286+ ///
287+ /// Note that this does not walk const blocks.
285288 pub fn walk_child_exprs ( & self , expr_id : ExprId , mut f : impl FnMut ( ExprId ) ) {
286289 let expr = & self [ expr_id] ;
287290 match expr {
@@ -415,6 +418,10 @@ impl ExpressionStore {
415418 }
416419 }
417420
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.
418425 pub fn walk_child_exprs_without_pats ( & self , expr_id : ExprId , mut f : impl FnMut ( ExprId ) ) {
419426 let expr = & self [ expr_id] ;
420427 match expr {
Original file line number Diff line number Diff line change @@ -348,6 +348,7 @@ impl<'a> UnsafeVisitor<'a> {
348348 Expr :: Closure { args, .. } => {
349349 self . walk_pats_top ( args. iter ( ) . copied ( ) , current) ;
350350 }
351+ Expr :: Const ( e) => self . walk_expr ( * e) ,
351352 _ => { }
352353 }
353354
Original file line number Diff line number Diff line change @@ -874,6 +874,19 @@ fn baz() {
874874fn f(it: unsafe fn()){
875875 it();
876876 // ^^^^ 💡 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
877890}
878891 "# ,
879892 ) ;
You can’t perform that action at this time.
0 commit comments