api-guidelines icon indicating copy to clipboard operation
api-guidelines copied to clipboard

Type macros may follow a different naming convention

Open dtolnay opened this issue 6 years ago • 9 comments

https://github.com/rust-lang-nursery/api-guidelines/issues/135#issuecomment-343698387 suggests a nice one:

I've been using PascalCase! for macros that expand into types. (e.g. Array![i32; 5; 4; 3] which expands into [[[i32; 3]; 4]; 5])

I did not consider type macros when adding a case convention for macros in C-CASE. I have also never used a type macro myself. Will need to survey the ecosystem and see whether PascalCase! for type macros would be a good recommendation.

dtolnay avatar Nov 11 '17 22:11 dtolnay

This seems like an amendment we'd want to make now. In the intervening years I think PascalCase has emerged as a standard for type macros (like syn::Token!).

KodrAus avatar Dec 22 '20 02:12 KodrAus

@rfcbot fcp merge

KodrAus avatar Dec 22 '20 05:12 KodrAus

@rfcbot fcp merge

This proposes amending our naming conventions to recommend type macros use PascalCase naming instead of snake_case.

KodrAus avatar Dec 22 '20 11:12 KodrAus

Team member @KodrAus has proposed to merge this. The next step is review by the rest of the tagged team members:

  • [x] @Amanieu
  • [x] @BurntSushi
  • [x] @KodrAus
  • [x] @dtolnay
  • [ ] @m-ou-se
  • [x] @sfackler
  • [ ] @withoutboats

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

rfcbot avatar Dec 22 '20 12:12 rfcbot

Are there any type macros in the standard library already?

CodesInChaos avatar Dec 25 '20 09:12 CodesInChaos

Yes, there's vec! and format_args!, both using snake case instead of pascal case.

Edit: oops, misunderstood the issue

PlasmaPower avatar Dec 25 '20 18:12 PlasmaPower

Both of those macros expand into values, not types.

sfackler avatar Dec 25 '20 19:12 sfackler

:bell: This is now entering its final comment period, as per the review above. :bell:

psst @KodrAus, I wasn't able to add the final-comment-period label, please do so.

rfcbot avatar Dec 31 '20 16:12 rfcbot

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

psst @KodrAus, I wasn't able to add the finished-final-comment-period label, please do so.

rfcbot avatar Jan 10 '21 16:01 rfcbot