-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Allow item macros to take type parameters #3190
Comments
retagged as enhancement; can you give some background on how you'd expect this to work? How would the type terms be bound in the macro environment? |
Maybe we could do something like have macro patterns specify the whole pattern, instead of just the arguments. For example, you might write:
Then the name and type variables would be bound just like any other macro pattern variable. |
Just to clarify; this is an aesthetic request, right? The parameters would behave the same way as |
That seems right to me. It's just to make the macro invocations look more like other items that can have type parameters. |
I oppose this on syntactic purity/simplicity grounds, unless we could find some super-nifty way to define rust's set of supported syntactic forms in such a way that the macro code and the non-macro code were actually using the same parsing code, a la Honu. Just my opinion, of course. |
Triage: no change; #10413 would make this less important (although rather ugly, with the type parameters inside the |
Closing this as wishlist / RFC. It's something to consider alongside the "item macro sugar" that was proposed (and rejected) for RFC 453. |
test Miri on 32bit FreeBSD
test Miri on 32bit FreeBSD
This PR reintroduces the `Invariant` trait as a mechanism for the specification of type safety invariants. The trait is defined in the Kani library where we also provide `Invariant` implementations for primitive types. In contrast to the previous `Invariant` trait, this version doesn't require the `Arbitrary` bound (i.e., it has the same requirements as `Arbitrary`). This way, the user isn't required to provide an `Arbitrary` implementation in addition to the `Invariant` one. Related rust-lang#3095
It might be able to write item macros that have type parameters associated with their identifier, such as:
Especially in cases where we are making macros that expand into functions, enums, types, etc., it might be nice to have a single set of type parameters for all of the generated code.
This issue is relevant to #3165.
The text was updated successfully, but these errors were encountered: