Mark mutating functions with mutable modifier, and owning functions with consuming.
This commit is contained in:
@@ -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<Mutability> {
|
||||
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<TypeRef> {
|
||||
db.function_data(self.id).params.clone()
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
|
||||
self.imp.assert_contains_node(node)
|
||||
}
|
||||
|
||||
pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> bool {
|
||||
pub fn is_unsafe_method_call(&self, method_call_expr: &ast::MethodCallExpr) -> bool {
|
||||
self.imp.is_unsafe_method_call(method_call_expr)
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ impl<'db> SemanticsImpl<'db> {
|
||||
InFile::new(file_id, node)
|
||||
}
|
||||
|
||||
pub fn is_unsafe_method_call(&self, method_call_expr: ast::MethodCallExpr) -> bool {
|
||||
pub fn is_unsafe_method_call(&self, method_call_expr: &ast::MethodCallExpr) -> bool {
|
||||
method_call_expr
|
||||
.expr()
|
||||
.and_then(|expr| {
|
||||
|
||||
Reference in New Issue
Block a user