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

Don't use types as traits in macros #5

Merged
merged 1 commit into from
Mar 8, 2018
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
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#[macro_export]
macro_rules! guilty {
// These are the user facing invocations:

// 1. define a private trait
($(#[$attr:meta])* trait $traitname:ident $body:tt) => {
guilty!(INTERNAL: DEFINE TRAIT, [$(#[$attr])*] [trait] [$traitname], $body);
Expand Down Expand Up @@ -143,7 +143,7 @@ macro_rules! guilty {
// calls on to:
// - itself if there is another const
// - def-impl-fn/def-impl-ty if there are no more consts
(INTERNAL: DEFINE IMPL, $traitname:ty, $structname:ident,
(INTERNAL: DEFINE IMPL, $traitname:path, $structname:ident,
{
$(#[$cattr:meta])* const $constname:ident : $consttype:ty = $constvalue:expr;
$($body:tt)*
Expand All @@ -156,22 +156,22 @@ macro_rules! guilty {
};
// def-impl-fn: output an impl that has no consts at the beginning (starts with fn)
// indirection through item-redir
(INTERNAL: DEFINE IMPL, $traitname:ty, $structname:ident,
(INTERNAL: DEFINE IMPL, $traitname:path, $structname:ident,
{
$(#[$fattr:meta])* fn $($body:tt)*
}) => {
guilty!(INTERNAL: AS ITEM, impl $traitname for $structname { $(#[$fattr])* fn $($body)* });
};
// def-impl-ty: output an impl that has no consts at the beginning (starts with type)
// indirection through item-redir
(INTERNAL: DEFINE IMPL, $traitname:ty, $structname:ident,
(INTERNAL: DEFINE IMPL, $traitname:path, $structname:ident,
{
$(#[$tattr:meta])* type $($body:tt)*
}) => {
guilty!(INTERNAL: AS ITEM, impl $traitname for $structname { $(#[$tattr])* type $($body)* });
};
// def-impl-empty: output an impl that has no items in it
(INTERNAL: DEFINE IMPL, $traitname:ty, $structname:ident,
(INTERNAL: DEFINE IMPL, $traitname:path, $structname:ident,
{
}) => {
guilty!(INTERNAL: AS ITEM, impl $traitname for $structname { });
Expand Down Expand Up @@ -245,7 +245,7 @@ mod tests {
const WithDefault: i32 = 42;
/// An associated const without a default
const NoDefault: Self = Struct { i: 42 };

/// An associated type
type Type = bool;

Expand Down