Unnamed repository; edit this file 'description' to name the repository.
add test case with marco reference
Young-Flash 2024-01-18
parent bd26403 · commit 0bf986d
-rw-r--r--crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs
index 4961e05e2f..dde2b497fb 100644
--- a/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs
+++ b/crates/ide-assists/src/handlers/extract_struct_from_enum_variant.rs
@@ -441,6 +441,45 @@ mod tests {
use super::*;
#[test]
+ fn test_with_marco() {
+ check_assist(
+ extract_struct_from_enum_variant,
+ r#"
+macro_rules! foo {
+ ($x:expr) => {
+ $x
+ };
+}
+
+enum TheEnum {
+ TheVariant$0 { the_field: u8 },
+}
+
+fn main() {
+ foo![TheEnum::TheVariant { the_field: 42 }];
+}
+"#,
+ r#"
+macro_rules! foo {
+ ($x:expr) => {
+ $x
+ };
+}
+
+struct TheVariant{ the_field: u8 }
+
+enum TheEnum {
+ TheVariant(TheVariant),
+}
+
+fn main() {
+ foo![TheEnum::TheVariant { the_field: 42 }];
+}
+"#,
+ );
+ }
+
+ #[test]
fn issue_16197() {
check_assist(
extract_struct_from_enum_variant,