mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
fix: Check whether a parameter can be converted to a local
This commit is contained in:
parent
399559e597
commit
15e7112da3
3 changed files with 41 additions and 24 deletions
|
@ -1506,10 +1506,15 @@ impl Param {
|
|||
db.function_data(self.func.id).params[self.idx].0.clone()
|
||||
}
|
||||
|
||||
pub fn as_local(&self, db: &dyn HirDatabase) -> Local {
|
||||
pub fn as_local(&self, db: &dyn HirDatabase) -> Option<Local> {
|
||||
let parent = DefWithBodyId::FunctionId(self.func.into());
|
||||
let body = db.body(parent);
|
||||
Local { parent, pat_id: body.params[self.idx] }
|
||||
let pat_id = body.params[self.idx];
|
||||
if let Pat::Bind { .. } = &body[pat_id] {
|
||||
Some(Local { parent, pat_id: body.params[self.idx] })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pattern_source(&self, db: &dyn HirDatabase) -> Option<ast::Pat> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue