-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add Upcase ident in Macro #8210
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
Conversation
Huh. I'm not so sure about this one. Synthesizing or modifying identifiers between source code and compiled form, in general, goes against the grep test (http://jamie-wong.com/2013/07/12/grep-test/) which I generally think of as worth trying to pass. Why not just pass the actual identifier |
It kind of sucks if you have to write Then there is the other part of it which is macro-izing the giant match statement to parse color names. We were hoping to do Is there another way around this such that we don't have to repeat the same characters multiple times? |
Obviously one way around it is to write a Python script that parses a simple text file and generates the Rust code, but I was hoping to leverage the macro system instead. |
If this is something that requires procedural macros but isn't appropriate for rustc maybe we could namespace it in a way that is obvious that it's not for general use, until dynamically loadable syntax extensions work, then remove it from rustc. |
Or maybe we could add some macros with other support functionality such that this could be written as a macro-by-example. |
Oh, I didn't realize the string name repeated it. That's .. More ok? I just thought I'd raise the concern, generally synthetic idents are a bit of an anti feature. Not a hard r-, if it's really needed. |
Sorry, I slightly misspoke here. The I suppose we could pass the grep test if we instead downcased the ident to make the string. But it would involve a very similar function to this one to turn ALICEBLUE into aliceblue and then we'd put it in quotes. |
Maybe a variant on stringify then, yeah? |
I have written SVG parsers in the past and it appears to me that defining HTML color names is a one-off job which can be automated (in my case using copy/paste and search/replace). Beyond rust-css where do we see this being used? |
I think we should just close this pull request. The conversation between graydon and metajack shows a path towards a alternate (if similar) solution for color names that does not break the grep test: namely, a variant on stringify that downcases. (Unless someone comes up with a real-world use case that cannot be re-encoded in a reasonable way given that hypothetical |
Closing per @pnkfelix |
Add borrow_as_ptr lint Closes: rust-lang#6995 - \[x] Followed [lint naming conventions][lint_naming] - \[x] Added passing UI tests (including committed `.stderr` file) - \[x] `cargo test` passes locally - \[x] Executed `cargo dev update_lints` - \[x] Added lint documentation - \[x] Run `cargo dev fmt` --- changelog: new lint: [`borrow_as_ptr`]
This feature is for rust-css colors.
see : servo/rust-css#22
something like:
which would expand to:
when is use upcaseident!(aliceblue), it can become ALICEBLUE(uppercase).
ex))