mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Mark mutating functions with mutable
modifier, and owning functions with consuming
.
This commit is contained in:
parent
7009d5ee2b
commit
a044ff0138
5 changed files with 70 additions and 15 deletions
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue