Skip to content

Commit

Permalink
librustc_mir: use ? in impl_snapshot_for! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Feb 10, 2019
1 parent c3d2490 commit 6156def
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/librustc_mir/interpret/snapshot.rs
Expand Up @@ -101,9 +101,8 @@ macro_rules! __impl_snapshot_field {
// This assumes the type has two type parameters, first for the tag (set to `()`),
// then for the id
macro_rules! impl_snapshot_for {
// FIXME(mark-i-m): Some of these should be `?` rather than `*`.
(enum $enum_name:ident {
$( $variant:ident $( ( $($field:ident $(-> $delegate:expr)*),* ) )* ),* $(,)*
$( $variant:ident $( ( $($field:ident $(-> $delegate:expr)?),* ) )? ),* $(,)?
}) => {

impl<'a, Ctx> self::Snapshot<'a, Ctx> for $enum_name
Expand All @@ -115,18 +114,17 @@ macro_rules! impl_snapshot_for {
fn snapshot(&self, __ctx: &'a Ctx) -> Self::Item {
match *self {
$(
$enum_name::$variant $( ( $(ref $field),* ) )* =>
$enum_name::$variant $( ( $(ref $field),* ) )? =>
$enum_name::$variant $(
( $( __impl_snapshot_field!($field, __ctx $(, $delegate)*) ),* ),
)*
( $( __impl_snapshot_field!($field, __ctx $(, $delegate)?) ),* ),
)?
)*
}
}
}
};

// FIXME(mark-i-m): same here.
(struct $struct_name:ident { $($field:ident $(-> $delegate:expr)*),* $(,)* }) => {
(struct $struct_name:ident { $($field:ident $(-> $delegate:expr)?),* $(,)? }) => {
impl<'a, Ctx> self::Snapshot<'a, Ctx> for $struct_name
where Ctx: self::SnapshotContext<'a>,
{
Expand All @@ -139,7 +137,7 @@ macro_rules! impl_snapshot_for {
} = *self;

$struct_name {
$( $field: __impl_snapshot_field!($field, __ctx $(, $delegate)*) ),*
$( $field: __impl_snapshot_field!($field, __ctx $(, $delegate)?) ),*
}
}
}
Expand Down

0 comments on commit 6156def

Please sign in to comment.