diff options
author | Paul Daniel Faria <[email protected]> | 2020-05-24 21:24:36 +0100 |
---|---|---|
committer | Paul Daniel Faria <[email protected]> | 2020-06-27 15:10:26 +0100 |
commit | 278cbf12cd0f76fc191d5ce7f130e6245596a578 (patch) | |
tree | 7c00307fbef82b45cbd0072a45819ea962bf8900 /crates/ra_hir_ty/src/tests.rs | |
parent | 3df0f9ce7e6eea48b67dae8b26e83aa7bd36ff24 (diff) |
Track unsafe blocks, don't trigger missing unsafe diagnostic when unsafe exprs within unsafe block
Diffstat (limited to 'crates/ra_hir_ty/src/tests.rs')
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 8889fa3ba..4bc2e8b27 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -608,10 +608,30 @@ fn no_missing_unsafe_diagnostic_with_raw_ptr_in_unsafe_block() { | |||
608 | r" | 608 | r" |
609 | //- /lib.rs | 609 | //- /lib.rs |
610 | fn nothing_to_see_move_along() { | 610 | fn nothing_to_see_move_along() { |
611 | let x = &5 as *const usize; | ||
612 | unsafe { | ||
613 | let y = *x; | ||
614 | } | ||
615 | } | ||
616 | ", | ||
617 | ) | ||
618 | .diagnostics() | ||
619 | .0; | ||
620 | |||
621 | assert_snapshot!(diagnostics, @""); | ||
622 | } | ||
623 | |||
624 | #[test] | ||
625 | fn missing_unsafe_diagnostic_with_raw_ptr_outside_unsafe_block() { | ||
626 | let diagnostics = TestDB::with_files( | ||
627 | r" | ||
628 | //- /lib.rs | ||
629 | fn nothing_to_see_move_along() { | ||
630 | let x = &5 as *const usize; | ||
611 | unsafe { | 631 | unsafe { |
612 | let x = &5 as *const usize; | ||
613 | let y = *x; | 632 | let y = *x; |
614 | } | 633 | } |
634 | let z = *x; | ||
615 | } | 635 | } |
616 | ", | 636 | ", |
617 | ) | 637 | ) |