tamer: asg::air::ir::sum_ir: impl Token for IR sum type

This is necessary for the commit that follows.  Maybe it wasn't worth
separating this into its own commit.

DEV-13708
main
Mike Gerwitz 2023-03-06 15:13:47 -05:00
parent b6d0569b99
commit e2714ce73f
1 changed files with 25 additions and 0 deletions

View File

@ -250,6 +250,17 @@ macro_rules! sum_ir {
}
}
impl std::fmt::Display for $sumty {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
$(
#[allow(unused_variables)]
$sumty::$subty(x) => std::fmt::Display::fmt(x, f),
)+
}
}
}
$(
impl std::fmt::Display for $subty {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
@ -283,6 +294,20 @@ macro_rules! sum_ir {
}
}
impl crate::parse::Token for $sumty {
fn ir_name() -> &'static str {
$irname
}
fn span(&self) -> crate::span::Span {
match self {
$(
$sumty::$subty(x) => x.span(),
)+
}
}
}
$(
impl crate::parse::Token for $subty {
fn ir_name() -> &'static str {