mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Infer result of struct literals, and recurse into their child expressions
This commit is contained in:
parent
4ff1618520
commit
6fcd38cc81
6 changed files with 143 additions and 49 deletions
|
@ -2142,7 +2142,15 @@ impl<R: TreeRoot<RaTypes>> NamedFieldNode<R> {
|
|||
}
|
||||
|
||||
|
||||
impl<'a> NamedField<'a> {}
|
||||
impl<'a> NamedField<'a> {
|
||||
pub fn name_ref(self) -> Option<NameRef<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
|
||||
pub fn expr(self) -> Option<Expr<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
}
|
||||
|
||||
// NamedFieldDef
|
||||
#[derive(Debug, Clone, Copy,)]
|
||||
|
@ -2218,7 +2226,11 @@ impl<R: TreeRoot<RaTypes>> NamedFieldListNode<R> {
|
|||
}
|
||||
|
||||
|
||||
impl<'a> NamedFieldList<'a> {}
|
||||
impl<'a> NamedFieldList<'a> {
|
||||
pub fn fields(self) -> impl Iterator<Item = NamedField<'a>> + 'a {
|
||||
super::children(self)
|
||||
}
|
||||
}
|
||||
|
||||
// NeverType
|
||||
#[derive(Debug, Clone, Copy,)]
|
||||
|
@ -3467,7 +3479,15 @@ impl<R: TreeRoot<RaTypes>> StructLitNode<R> {
|
|||
}
|
||||
|
||||
|
||||
impl<'a> StructLit<'a> {}
|
||||
impl<'a> StructLit<'a> {
|
||||
pub fn path(self) -> Option<Path<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
|
||||
pub fn named_field_list(self) -> Option<NamedFieldList<'a>> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
}
|
||||
|
||||
// StructPat
|
||||
#[derive(Debug, Clone, Copy,)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue