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

make type modifiers usable for macro substitution #5748

Closed
metajack opened this issue Apr 5, 2013 · 6 comments
Closed

make type modifiers usable for macro substitution #5748

metajack opened this issue Apr 5, 2013 · 6 comments
Labels
A-syntaxext Area: Syntax extensions

Comments

@metajack
Copy link
Contributor

metajack commented Apr 5, 2013

Currently you can not pass @ or ~ or @mut to a macro by itself, but this would be useful in a few cases. I tried doing this to add Clone trait implementations without copying the code:

macro_rules! ptr_clone_impl(
    ($p:something) => {
        impl<T:Clone> Clone for $p T {
            #[inline(always)]
            fn clone(&self) -> $p T { $p (**self).clone() }
        }
    }
)

ptr_clone_impl!(~)
ptr_clone_impl!(@)
ptr_clone_impl!(@mut)

But as far as I can tell there is no fragment specifier that will work for those tokens.

@bstrie
Copy link
Contributor

bstrie commented May 28, 2013

I know that @pcwalton has been interested in making ~ and @ act just like any other type, so perhaps this is worth supporting (assuming that user-defined types would normally be valid in this context).

@pnkfelix
Copy link
Member

~ and @ are type-constructors, not types, no? (Still, it might be sense to add support for them to the macro-system. I.e. have some way to pass around these type -> type operators.)

@catamorphism
Copy link
Contributor

Bug triage: doesn't look like a release blocker to me.

@emberian
Copy link
Member

emberian commented Jan 6, 2014

cc @jbclements

I feel like this is tricky, although it shouldn't be too hard for just the sigils.

@emberian
Copy link
Member

Now that we have box and have removed those other types, this doesn't make quite as much sense. Once box itself infers the boxed-type this shouldn't be necessary. What's missing is to be able to have something like type level functions... I have Box, I want to apply it to T to get Box<T>, but our syntax doesn't really make that convenient.

Just some scattered thoughts..

@rust-highfive
Copy link
Collaborator

This issue has been moved to the RFCs repo: rust-lang/rfcs#285

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 14, 2020
Change a noun to a verb to make the sentence complete

changelog: Fixed some grammar in the documentation for `await_holding_lock`.

Just a tiny little thing I found while using clippy <3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions
Projects
None yet
Development

No branches or pull requests

6 participants