Add new trait TypeAscriptionOwner

This trait should be implemented for nodes which have an ascribed type,
e.g. thing : Type. Such as let, const, static, param, named struct fields.
This commit is contained in:
Ville Penttinen 2019-02-26 11:35:57 +02:00
parent 7c9acf2f83
commit 6eb070d661
3 changed files with 36 additions and 9 deletions

View file

@ -628,6 +628,7 @@ impl ast::NameOwner for ConstDef {}
impl ast::TypeParamsOwner for ConstDef {}
impl ast::AttrsOwner for ConstDef {}
impl ast::DocCommentsOwner for ConstDef {}
impl ast::TypeAscriptionOwner for ConstDef {}
impl ConstDef {
pub fn type_ref(&self) -> Option<&TypeRef> {
super::child_opt(self)
@ -1767,6 +1768,7 @@ impl ToOwned for LetStmt {
}
impl ast::TypeAscriptionOwner for LetStmt {}
impl LetStmt {
pub fn pat(&self) -> Option<&Pat> {
super::child_opt(self)
@ -2592,6 +2594,7 @@ impl ast::VisibilityOwner for NamedFieldDef {}
impl ast::NameOwner for NamedFieldDef {}
impl ast::AttrsOwner for NamedFieldDef {}
impl ast::DocCommentsOwner for NamedFieldDef {}
impl ast::TypeAscriptionOwner for NamedFieldDef {}
impl NamedFieldDef {
pub fn type_ref(&self) -> Option<&TypeRef> {
super::child_opt(self)
@ -2774,6 +2777,7 @@ impl ToOwned for Param {
}
impl ast::TypeAscriptionOwner for Param {}
impl Param {
pub fn pat(&self) -> Option<&Pat> {
super::child_opt(self)
@ -3685,6 +3689,7 @@ impl ToOwned for SelfParam {
}
impl ast::TypeAscriptionOwner for SelfParam {}
impl SelfParam {
pub fn type_ref(&self) -> Option<&TypeRef> {
super::child_opt(self)
@ -3820,6 +3825,7 @@ impl ast::NameOwner for StaticDef {}
impl ast::TypeParamsOwner for StaticDef {}
impl ast::AttrsOwner for StaticDef {}
impl ast::DocCommentsOwner for StaticDef {}
impl ast::TypeAscriptionOwner for StaticDef {}
impl StaticDef {
pub fn type_ref(&self) -> Option<&TypeRef> {
super::child_opt(self)