aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r--crates/ra_hir_ty/src/tests.rs5
-rw-r--r--crates/ra_hir_ty/src/unsafe_validation.rs17
2 files changed, 5 insertions, 17 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index 496cb428b..2a85ce85d 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -580,7 +580,6 @@ fn missing_unsafe() {
580fn missing_unsafe_diagnostic_with_unsafe_method_call() { 580fn missing_unsafe_diagnostic_with_unsafe_method_call() {
581 let diagnostics = TestDB::with_files( 581 let diagnostics = TestDB::with_files(
582 r" 582 r"
583//- /lib.rs
584struct HasUnsafe; 583struct HasUnsafe;
585 584
586impl HasUnsafe { 585impl HasUnsafe {
@@ -606,7 +605,6 @@ fn missing_unsafe() {
606fn no_missing_unsafe_diagnostic_with_raw_ptr_in_unsafe_block() { 605fn no_missing_unsafe_diagnostic_with_raw_ptr_in_unsafe_block() {
607 let diagnostics = TestDB::with_files( 606 let diagnostics = TestDB::with_files(
608 r" 607 r"
609//- /lib.rs
610fn nothing_to_see_move_along() { 608fn nothing_to_see_move_along() {
611 let x = &5 as *const usize; 609 let x = &5 as *const usize;
612 unsafe { 610 unsafe {
@@ -625,7 +623,6 @@ fn nothing_to_see_move_along() {
625fn missing_unsafe_diagnostic_with_raw_ptr_outside_unsafe_block() { 623fn missing_unsafe_diagnostic_with_raw_ptr_outside_unsafe_block() {
626 let diagnostics = TestDB::with_files( 624 let diagnostics = TestDB::with_files(
627 r" 625 r"
628//- /lib.rs
629fn nothing_to_see_move_along() { 626fn nothing_to_see_move_along() {
630 let x = &5 as *const usize; 627 let x = &5 as *const usize;
631 unsafe { 628 unsafe {
@@ -645,7 +642,6 @@ fn nothing_to_see_move_along() {
645fn no_missing_unsafe_diagnostic_with_unsafe_call_in_unsafe_block() { 642fn no_missing_unsafe_diagnostic_with_unsafe_call_in_unsafe_block() {
646 let diagnostics = TestDB::with_files( 643 let diagnostics = TestDB::with_files(
647 r" 644 r"
648//- /lib.rs
649unsafe fn unsafe_fn() { 645unsafe fn unsafe_fn() {
650 let x = &5 as *const usize; 646 let x = &5 as *const usize;
651 let y = *x; 647 let y = *x;
@@ -668,7 +664,6 @@ fn nothing_to_see_move_along() {
668fn no_missing_unsafe_diagnostic_with_unsafe_method_call_in_unsafe_block() { 664fn no_missing_unsafe_diagnostic_with_unsafe_method_call_in_unsafe_block() {
669 let diagnostics = TestDB::with_files( 665 let diagnostics = TestDB::with_files(
670 r" 666 r"
671//- /lib.rs
672struct HasUnsafe; 667struct HasUnsafe;
673 668
674impl HasUnsafe { 669impl HasUnsafe {
diff --git a/crates/ra_hir_ty/src/unsafe_validation.rs b/crates/ra_hir_ty/src/unsafe_validation.rs
index f3ce7112a..e2353404b 100644
--- a/crates/ra_hir_ty/src/unsafe_validation.rs
+++ b/crates/ra_hir_ty/src/unsafe_validation.rs
@@ -3,7 +3,11 @@
3 3
4use std::sync::Arc; 4use std::sync::Arc;
5 5
6use hir_def::{DefWithBodyId, FunctionId}; 6use hir_def::{
7 body::Body,
8 expr::{Expr, ExprId, UnaryOp},
9 DefWithBodyId, FunctionId,
10};
7use hir_expand::diagnostics::DiagnosticSink; 11use hir_expand::diagnostics::DiagnosticSink;
8 12
9use crate::{ 13use crate::{
@@ -11,13 +15,6 @@ use crate::{
11 InferenceResult, Ty, TypeCtor, 15 InferenceResult, Ty, TypeCtor,
12}; 16};
13 17
14use rustc_hash::FxHashSet;
15
16use hir_def::{
17 body::Body,
18 expr::{Expr, ExprId, UnaryOp},
19};
20
21pub struct UnsafeValidator<'a, 'b: 'a> { 18pub struct UnsafeValidator<'a, 'b: 'a> {
22 func: FunctionId, 19 func: FunctionId,
23 infer: Arc<InferenceResult>, 20 infer: Arc<InferenceResult>,
@@ -75,13 +72,9 @@ pub fn unsafe_expressions(
75 def: DefWithBodyId, 72 def: DefWithBodyId,
76) -> Vec<UnsafeExpr> { 73) -> Vec<UnsafeExpr> {
77 let mut unsafe_exprs = vec![]; 74 let mut unsafe_exprs = vec![];
78 let mut unsafe_block_exprs = FxHashSet::default();
79 let body = db.body(def); 75 let body = db.body(def);
80 for (id, expr) in body.exprs.iter() { 76 for (id, expr) in body.exprs.iter() {
81 match expr { 77 match expr {
82 Expr::Unsafe { .. } => {
83 unsafe_block_exprs.insert(id);
84 }
85 Expr::Call { callee, .. } => { 78 Expr::Call { callee, .. } => {
86 let ty = &infer[*callee]; 79 let ty = &infer[*callee];
87 if let &Ty::Apply(ApplicationTy { 80 if let &Ty::Apply(ApplicationTy {