Add trait ast::TypeBoundsOwner

This commit is contained in:
Ville Penttinen 2019-03-31 10:56:48 +03:00
parent 245c0d8584
commit 55dcdb7d09
3 changed files with 21 additions and 5 deletions

View file

@ -110,6 +110,12 @@ pub trait TypeParamsOwner: AstNode {
}
}
pub trait TypeBoundsOwner: AstNode {
fn type_bound_list(&self) -> Option<&TypeBoundList> {
child_opt(self)
}
}
pub trait AttrsOwner: AstNode {
fn attrs(&self) -> AstChildren<Attr> {
children(self)

View file

@ -685,6 +685,7 @@ impl ToOwned for DynTraitType {
}
impl ast::TypeBoundsOwner for DynTraitType {}
impl DynTraitType {}
// EnumDef
@ -1581,6 +1582,7 @@ impl ToOwned for ImplTraitType {
}
impl ast::TypeBoundsOwner for ImplTraitType {}
impl ImplTraitType {}
// IndexExpr
@ -4061,6 +4063,7 @@ impl ast::NameOwner for TraitDef {}
impl ast::AttrsOwner for TraitDef {}
impl ast::DocCommentsOwner for TraitDef {}
impl ast::TypeParamsOwner for TraitDef {}
impl ast::TypeBoundsOwner for TraitDef {}
impl TraitDef {
pub fn item_list(&self) -> Option<&ItemList> {
super::child_opt(self)
@ -4291,6 +4294,7 @@ impl ast::NameOwner for TypeAliasDef {}
impl ast::TypeParamsOwner for TypeAliasDef {}
impl ast::AttrsOwner for TypeAliasDef {}
impl ast::DocCommentsOwner for TypeAliasDef {}
impl ast::TypeBoundsOwner for TypeAliasDef {}
impl TypeAliasDef {
pub fn type_ref(&self) -> Option<&TypeRef> {
super::child_opt(self)
@ -4465,6 +4469,7 @@ impl ToOwned for TypeParam {
impl ast::NameOwner for TypeParam {}
impl ast::AttrsOwner for TypeParam {}
impl ast::TypeBoundsOwner for TypeParam {}
impl TypeParam {}
// TypeParamList

View file

@ -295,7 +295,7 @@ Grammar(
"EnumVariantList": ( collections: [["variants", "EnumVariant"]] ),
"EnumVariant": ( traits: ["NameOwner", "DocCommentsOwner", "AttrsOwner"], options: ["Expr"] ),
"TraitDef": (
traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner"],
traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner", "TypeParamsOwner", "TypeBoundsOwner"],
options: ["ItemList"]
),
"Module": (
@ -332,7 +332,8 @@ Grammar(
"NameOwner",
"TypeParamsOwner",
"AttrsOwner",
"DocCommentsOwner"
"DocCommentsOwner",
"TypeBoundsOwner",
],
options: ["TypeRef"]
),
@ -349,8 +350,12 @@ Grammar(
"PlaceholderType": (),
"FnPointerType": (options: ["ParamList", "RetType"]),
"ForType": (options: ["TypeRef"]),
"ImplTraitType": (),
"DynTraitType": (),
"ImplTraitType": (
traits: ["TypeBoundsOwner"],
),
"DynTraitType": (
traits: ["TypeBoundsOwner"],
),
"TypeRef": ( enum: [
"ParenType",
@ -573,7 +578,7 @@ Grammar(
["lifetime_params", "LifetimeParam" ],
]
),
"TypeParam": ( traits: ["NameOwner", "AttrsOwner"] ),
"TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"] ),
"LifetimeParam": (
options: [ "Lifetime"],
traits: ["AttrsOwner"],