From 566c8e321e89e5ff8996daa615cc47aea0012881 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 24 Jan 2019 18:56:38 +0300 Subject: migrate enums to new id --- crates/ra_syntax/src/ast.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index bcbd4c60c..fd65264b2 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -430,6 +430,13 @@ impl StructDef { } impl EnumVariant { + pub fn parent_enum(&self) -> &EnumDef { + self.syntax() + .parent() + .and_then(|it| it.parent()) + .and_then(EnumDef::cast) + .expect("EnumVariants are always nested in Enums") + } pub fn flavor(&self) -> StructFlavor { StructFlavor::from_node(self) } -- cgit v1.2.3