diff options
author | Paul Daniel Faria <[email protected]> | 2020-07-30 16:07:13 +0100 |
---|---|---|
committer | Paul Daniel Faria <[email protected]> | 2020-08-16 15:22:51 +0100 |
commit | a044ff0138d6bff9406b94de89fde43e7672ee1b (patch) | |
tree | c90b7a41f15d86b6bf7b6bd4fd4c9c8496197ae3 /crates/hir/src | |
parent | 7009d5ee2bff53b9beb555b1572c97ab3882cd98 (diff) |
Mark mutating functions with `mutable` modifier, and owning functions with `consuming`.
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/code_model.rs | 15 | ||||
-rw-r--r-- | crates/hir/src/semantics.rs | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index c442654dd..31d5276b0 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs | |||
@@ -670,6 +670,21 @@ impl Function { | |||
670 | db.function_data(self.id).has_self_param | 670 | db.function_data(self.id).has_self_param |
671 | } | 671 | } |
672 | 672 | ||
673 | pub fn mutability_of_self_param(self, db: &dyn HirDatabase) -> Option<Mutability> { | ||
674 | let func_data = db.function_data(self.id); | ||
675 | if !func_data.has_self_param { | ||
676 | return None; | ||
677 | } | ||
678 | |||
679 | func_data.params.first().and_then(|param| { | ||
680 | if let TypeRef::Reference(_, mutability) = param { | ||
681 | Some(*mutability) | ||
682 | } else { | ||
683 | None | ||
684 | } | ||
685 | }) | ||
686 | } | ||
687 | |||
673 | pub fn params(self, db: &dyn HirDatabase) -> Vec<TypeRef> { | 688 | pub fn params(self, db: &dyn HirDatabase) -> Vec<TypeRef> { |
674 | db.function_data(self.id).params.clone() | 689 | db.function_data(self.id).params.clone() |
675 | } | 690 | } |
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index c693176fa..9f23315c3 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs | |||
@@ -267,7 +267,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
267 | self.imp.assert_contains_node(node) | 267 | self.imp.assert_contains_node(node) |
268 | } | 268 | } |
269 | 269 | ||
270 | pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> bool { | 270 | pub fn is_unsafe_method_call(&self, method_call_expr: &ast::MethodCallExpr) -> bool { |
271 | self.imp.is_unsafe_method_call(method_call_expr) | 271 | self.imp.is_unsafe_method_call(method_call_expr) |
272 | } | 272 | } |
273 | 273 | ||
@@ -571,7 +571,7 @@ impl<'db> SemanticsImpl<'db> { | |||
571 | InFile::new(file_id, node) | 571 | InFile::new(file_id, node) |
572 | } | 572 | } |
573 | 573 | ||
574 | pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> bool { | 574 | pub fn is_unsafe_method_call(&self, method_call_expr: &ast::MethodCallExpr) -> bool { |
575 | method_call_expr | 575 | method_call_expr |
576 | .expr() | 576 | .expr() |
577 | .and_then(|expr| { | 577 | .and_then(|expr| { |