2022-02-28 10:12:28 +03:00
|
|
|
#![allow(clippy::ptr_arg)]
|
|
|
|
|
2021-12-07 08:34:16 +03:00
|
|
|
use std::sync::Arc;
|
2022-02-09 09:33:32 +03:00
|
|
|
|
2020-12-08 09:21:15 +03:00
|
|
|
use swc_visit::define;
|
|
|
|
|
2022-07-05 07:38:27 +03:00
|
|
|
#[derive(Debug, PartialEq)]
|
2020-12-08 09:21:15 +03:00
|
|
|
pub struct Item {
|
|
|
|
pub item: Option<Arc<Item>>,
|
|
|
|
pub ref_to_enum: Option<Arc<Enum>>,
|
|
|
|
}
|
2022-07-05 07:38:27 +03:00
|
|
|
#[derive(Debug, PartialEq)]
|
2020-12-08 09:21:15 +03:00
|
|
|
pub enum Enum {
|
|
|
|
Item(Arc<Item>),
|
|
|
|
Items(Arc<Vec<Item>>),
|
|
|
|
Enum(Arc<Enum>),
|
|
|
|
Enums(Arc<Vec<Enum>>),
|
|
|
|
}
|
|
|
|
|
|
|
|
define!({
|
|
|
|
pub struct Item {
|
|
|
|
pub item: Option<Arc<Item>>,
|
|
|
|
pub ref_to_enum: Option<Arc<Enum>>,
|
|
|
|
}
|
|
|
|
pub enum Enum {
|
|
|
|
Item(Arc<Item>),
|
|
|
|
Items(Arc<Vec<Item>>),
|
|
|
|
Enum(Arc<Enum>),
|
|
|
|
Enums(Arc<Vec<Enum>>),
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
struct Panic;
|
|
|
|
|
|
|
|
impl Visit for Panic {
|
2021-12-07 08:34:16 +03:00
|
|
|
fn visit_item(&mut self, _: &Item) {
|
2020-12-08 09:21:15 +03:00
|
|
|
panic!("Success")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[should_panic(expected = "Success")]
|
|
|
|
fn test_panic() {
|
|
|
|
Enum::Item(Arc::new(Item {
|
|
|
|
item: None,
|
|
|
|
ref_to_enum: None,
|
|
|
|
}))
|
|
|
|
.visit_children_with(&mut Panic)
|
|
|
|
}
|