Don't use an untyped String for ActiveParam tracking

This commit is contained in:
Lukas Wirth 2021-03-20 23:22:09 +01:00
parent 5cc8ad0c4a
commit 38048c35d8
5 changed files with 44 additions and 24 deletions

View file

@ -380,6 +380,15 @@ impl fmt::Display for NameOrNameRef {
}
}
impl NameOrNameRef {
pub fn text(&self) -> &str {
match self {
NameOrNameRef::Name(name) => name.text(),
NameOrNameRef::NameRef(name_ref) => name_ref.text(),
}
}
}
impl ast::RecordPatField {
pub fn for_field_name_ref(field_name: &ast::NameRef) -> Option<ast::RecordPatField> {
let candidate = field_name.syntax().parent().and_then(ast::RecordPatField::cast)?;