aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests.rs
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-05-24 07:10:34 +0100
committerPaul Daniel Faria <[email protected]>2020-06-27 15:09:29 +0100
commitb358fbfdf82409700a8a328794429ec790306fc2 (patch)
treec21ff40842d2141f2b3043d3ccef9e9222157ed8 /crates/ra_hir_ty/src/tests.rs
parentdaf1cac9f87023d37a4418ea24ed615c9706258b (diff)
Add tests covering unsafe blocks, more attempts to get call expr tests passing
Diffstat (limited to 'crates/ra_hir_ty/src/tests.rs')
-rw-r--r--crates/ra_hir_ty/src/tests.rs70
1 files changed, 70 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index 4ff2b2d4a..c1f6fbab8 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -603,6 +603,76 @@ fn missing_unsafe() {
603} 603}
604 604
605#[test] 605#[test]
606fn no_missing_unsafe_diagnostic_with_raw_ptr_in_unsafe_block() {
607 let diagnostics = TestDB::with_files(
608 r"
609//- /lib.rs
610fn nothing_to_see_move_along() {
611 unsafe {
612 let x = &5 as *usize;
613 let y = *x;
614 }
615}
616",
617 )
618 .diagnostics()
619 .0;
620
621 assert_snapshot!(diagnostics, @"");
622}
623
624#[test]
625fn no_missing_unsafe_diagnostic_with_unsafe_call_in_unsafe_block() {
626 let diagnostics = TestDB::with_files(
627 r"
628//- /lib.rs
629unsafe fn unsafe_fn() {
630 let x = &5 as *usize;
631 let y = *x;
632}
633
634fn nothing_to_see_move_along() {
635 unsafe {
636 unsafe_fn();
637 }
638}
639",
640 )
641 .diagnostics()
642 .0;
643
644 assert_snapshot!(diagnostics, @"");
645}
646
647#[test]
648fn no_missing_unsafe_diagnostic_with_unsafe_method_call_in_unsafe_block() {
649 let diagnostics = TestDB::with_files(
650 r"
651//- /lib.rs
652struct HasUnsafe;
653
654impl HasUnsafe {
655 unsafe fn unsafe_fn() {
656 let x = &5 as *usize;
657 let y = *x;
658 }
659}
660
661fn nothing_to_see_move_along() {
662 unsafe {
663 HasUnsafe.unsafe_fn();
664 }
665}
666
667",
668 )
669 .diagnostics()
670 .0;
671
672 assert_snapshot!(diagnostics, @"");
673}
674
675#[test]
606fn unnecessary_unsafe_diagnostic() { 676fn unnecessary_unsafe_diagnostic() {
607 let diagnostics = TestDB::with_files( 677 let diagnostics = TestDB::with_files(
608 r" 678 r"