diff options
author | Paul Daniel Faria <[email protected]> | 2020-06-27 16:20:02 +0100 |
---|---|---|
committer | Paul Daniel Faria <[email protected]> | 2020-06-27 16:38:34 +0100 |
commit | b1992b469cae689f7de01ea9031962735a409198 (patch) | |
tree | bd7cc9c0a70266ab3afac7a082bdd15a9c03fe68 /crates/ra_hir_ty | |
parent | 28bb8ed9cb0aa9f1efad252748ea189716355157 (diff) |
Remove unneeded code, filename from tests, fix rebasing issues
Diffstat (limited to 'crates/ra_hir_ty')
-rw-r--r-- | crates/ra_hir_ty/src/tests.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/unsafe_validation.rs | 17 |
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() { | |||
580 | fn missing_unsafe_diagnostic_with_unsafe_method_call() { | 580 | fn 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 | ||
584 | struct HasUnsafe; | 583 | struct HasUnsafe; |
585 | 584 | ||
586 | impl HasUnsafe { | 585 | impl HasUnsafe { |
@@ -606,7 +605,6 @@ fn missing_unsafe() { | |||
606 | fn no_missing_unsafe_diagnostic_with_raw_ptr_in_unsafe_block() { | 605 | fn 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 | ||
610 | fn nothing_to_see_move_along() { | 608 | fn 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() { | |||
625 | fn missing_unsafe_diagnostic_with_raw_ptr_outside_unsafe_block() { | 623 | fn 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 | ||
629 | fn nothing_to_see_move_along() { | 626 | fn 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() { | |||
645 | fn no_missing_unsafe_diagnostic_with_unsafe_call_in_unsafe_block() { | 642 | fn 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 | ||
649 | unsafe fn unsafe_fn() { | 645 | unsafe 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() { | |||
668 | fn no_missing_unsafe_diagnostic_with_unsafe_method_call_in_unsafe_block() { | 664 | fn 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 | ||
672 | struct HasUnsafe; | 667 | struct HasUnsafe; |
673 | 668 | ||
674 | impl HasUnsafe { | 669 | impl 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 | ||
4 | use std::sync::Arc; | 4 | use std::sync::Arc; |
5 | 5 | ||
6 | use hir_def::{DefWithBodyId, FunctionId}; | 6 | use hir_def::{ |
7 | body::Body, | ||
8 | expr::{Expr, ExprId, UnaryOp}, | ||
9 | DefWithBodyId, FunctionId, | ||
10 | }; | ||
7 | use hir_expand::diagnostics::DiagnosticSink; | 11 | use hir_expand::diagnostics::DiagnosticSink; |
8 | 12 | ||
9 | use crate::{ | 13 | use crate::{ |
@@ -11,13 +15,6 @@ use crate::{ | |||
11 | InferenceResult, Ty, TypeCtor, | 15 | InferenceResult, Ty, TypeCtor, |
12 | }; | 16 | }; |
13 | 17 | ||
14 | use rustc_hash::FxHashSet; | ||
15 | |||
16 | use hir_def::{ | ||
17 | body::Body, | ||
18 | expr::{Expr, ExprId, UnaryOp}, | ||
19 | }; | ||
20 | |||
21 | pub struct UnsafeValidator<'a, 'b: 'a> { | 18 | pub 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 { |