2018-03-04 09:17:52 +03:00
|
|
|
//! Ensures that #[derive(Fold)] works with generic types.
|
2018-01-12 10:53:06 +03:00
|
|
|
|
2018-11-10 11:44:35 +03:00
|
|
|
#![feature(specialization)]
|
2018-01-12 10:53:06 +03:00
|
|
|
|
|
|
|
use std::fmt::Debug;
|
2018-03-04 09:17:52 +03:00
|
|
|
use swc_common::{AstNode, Fold};
|
2018-01-12 10:53:06 +03:00
|
|
|
|
|
|
|
pub trait Ast: Copy + Eq + Debug {
|
|
|
|
type CustomExpr: AstNode;
|
|
|
|
}
|
|
|
|
|
2018-03-04 09:17:52 +03:00
|
|
|
#[derive(Fold)]
|
2018-01-12 10:53:06 +03:00
|
|
|
pub struct Stmt<A: Ast> {
|
|
|
|
#[fold(bound)]
|
|
|
|
pub expr: Expr<A>,
|
|
|
|
}
|
|
|
|
|
2018-03-04 09:17:52 +03:00
|
|
|
#[derive(Fold)]
|
2018-01-12 10:53:06 +03:00
|
|
|
pub struct Expr<A: Ast> {
|
|
|
|
#[fold(bound)]
|
|
|
|
pub node: ExprKind<A>,
|
|
|
|
}
|
|
|
|
|
2018-03-04 09:17:52 +03:00
|
|
|
#[derive(Fold)]
|
2018-01-12 10:53:06 +03:00
|
|
|
pub enum ExprKind<A: Ast> {
|
2018-01-16 14:03:16 +03:00
|
|
|
Custom(#[fold(bound)] A::CustomExpr),
|
2018-01-12 10:53:06 +03:00
|
|
|
/// Recursive
|
|
|
|
Stmt(Box<Stmt<A>>),
|
|
|
|
}
|