From a044ff0138d6bff9406b94de89fde43e7672ee1b Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Thu, 30 Jul 2020 11:07:13 -0400 Subject: Mark mutating functions with `mutable` modifier, and owning functions with `consuming`. --- crates/hir/src/code_model.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'crates/hir/src/code_model.rs') 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 { db.function_data(self.id).has_self_param } + pub fn mutability_of_self_param(self, db: &dyn HirDatabase) -> Option { + let func_data = db.function_data(self.id); + if !func_data.has_self_param { + return None; + } + + func_data.params.first().and_then(|param| { + if let TypeRef::Reference(_, mutability) = param { + Some(*mutability) + } else { + None + } + }) + } + pub fn params(self, db: &dyn HirDatabase) -> Vec { db.function_data(self.id).params.clone() } -- cgit v1.2.3