Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librustc_mir: use ? in impl_snapshot_for! macro #58359

Merged
merged 1 commit into from
Feb 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/librustc_mir/interpret/snapshot.rs
Original file line number Diff line number Diff line change
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