swc/common/tests/fold_bound.rs

30 lines
520 B
Rust
Raw Normal View History

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