mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
simplify
This commit is contained in:
parent
065a8e87cd
commit
6bdf505d7c
2 changed files with 56 additions and 40 deletions
|
@ -973,6 +973,14 @@ impl SelfParam {
|
|||
Access::Owned => "self",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn source(&self, db: &dyn HirDatabase) -> Option<InFile<ast::SelfParam>> {
|
||||
let InFile { file_id, value } = Function::from(self.func).source(db)?;
|
||||
value
|
||||
.param_list()
|
||||
.and_then(|params| params.self_param())
|
||||
.map(|value| InFile { file_id, value })
|
||||
}
|
||||
}
|
||||
|
||||
impl HasVisibility for Function {
|
||||
|
@ -1348,6 +1356,13 @@ impl Local {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn as_self_param(self, db: &dyn HirDatabase) -> Option<SelfParam> {
|
||||
match self.parent {
|
||||
DefWithBodyId::FunctionId(func) if self.is_self(db) => Some(SelfParam { func }),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: why is this an option? It shouldn't be?
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
|
||||
let body = db.body(self.parent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue