mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-30 00:23:41 +00:00
Merge #1227
1227: Add `default_type` method in `TypeParam` Node r=matklad a=edwin0cheng This PR add a `default_type` method in `TypeParam` Node which allow future PR to handle #1099 case. Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
commit
b29f442c8b
@ -4038,6 +4038,7 @@ impl ToOwned for TypeParam {
|
||||
impl ast::NameOwner for TypeParam {}
|
||||
impl ast::AttrsOwner for TypeParam {}
|
||||
impl ast::TypeBoundsOwner for TypeParam {}
|
||||
impl ast::DefaultTypeParamOwner for TypeParam {}
|
||||
impl TypeParam {}
|
||||
|
||||
// TypeParamList
|
||||
|
@ -152,3 +152,9 @@ impl<'a> Iterator for CommentIter<'a> {
|
||||
self.iter.by_ref().find_map(|el| el.as_token().and_then(ast::Comment::cast))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait DefaultTypeParamOwner: AstNode {
|
||||
fn default_type(&self) -> Option<&ast::PathType> {
|
||||
child_opt(self)
|
||||
}
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ Grammar(
|
||||
["lifetime_params", "LifetimeParam" ],
|
||||
]
|
||||
),
|
||||
"TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner"] ),
|
||||
"TypeParam": ( traits: ["NameOwner", "AttrsOwner", "TypeBoundsOwner", "DefaultTypeParamOwner"] ),
|
||||
"LifetimeParam": (
|
||||
traits: ["AttrsOwner"],
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user