-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
env! syntax extension changes #8362
Conversation
pub fn version(argv0: &str) { | ||
let vers = match env!("CFG_VERSION") { | ||
Some(vers) => vers, | ||
None => "unknown_version" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
went from "unknown version" to "unknown_version"
Just tiny nitpicks, otherwise r+, thanks! |
Could the commits be squashed together for just one? |
Incidentally, it seems to me from a usability perspective that syntax extensions are processed too early in the pipeline. Dealing with the raw AST causes some super weird stuff, like I realize that it's probably not something that would be reasonable to do at this point. A version of |
@alexcrichton squashed |
Incidentally these sorts of ast details / differences are exactly what the quasiquoter is there to gloss over. Though I realize it's incomplete and not always effective, I'd suggest directing energies at improving it. |
I didn't realize that the quasiquoter even existed! I'll play around with that, thanks! |
Re the quasiquoter: #7727 is open as the bug for improving it. Also, I feel like in many cases one wants a compile time error if the env-var doesn't exist. Maybe |
That seems pretty reasonable to me. |
In case anyone's curios, @sfackler and I discussed this on IRC and agree with @huonw that there should be two versions:
|
@@ -0,0 +1,13 @@ | |||
// file at the top-level directory of this distribution and at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this lost the first line of the license
Would you mind changing the Also, I'm a little worried about requiring these variables for rustc. Personally more than once I've compiled rustc by hand (mostly to check syntax/types). I never use the resulting library, but it would be a little annoying to have to make sure these variables are defined. That being said, I'm probably only one of few who does this, and I could have some shell startup stuff which sets these variables, so I'm not that worried. Basically r+ with the test changes. And if you're at it, would you mind changing the copyright years on the files to 2013 instead of 2012? Thanks again for doing this! |
env! aborts compilation of the specified environment variable is not defined and takes an optional second argument containing a custom error message. option_env! creates an Option<&'static str> containing the value of the environment variable. There are no run-pass tests that check the behavior when the environment variable is defined since the test framework doesn't support setting environment variables at compile time as opposed to runtime. However, both env! and option_env! are used inside of rustc itself, which should act as a sufficient test. Close rust-lang#2248
env! aborts compilation of the specified environment variable is not defined and takes an optional second argument containing a custom error message. option_env! creates an Option<&'static str> containing the value of the environment variable. There are no run-pass tests that check the behavior when the environment variable is defined since the test framework doesn't support setting environment variables at compile time as opposed to runtime. However, both env! and option_env! are used inside of rustc itself, which should act as a sufficient test. Fixes #2248.
env! aborts compilation of the specified environment variable is not
defined and takes an optional second argument containing a custom
error message. option_env! creates an Option<&'static str> containing
the value of the environment variable.
There are no run-pass tests that check the behavior when the environment
variable is defined since the test framework doesn't support setting
environment variables at compile time as opposed to runtime. However,
both env! and option_env! are used inside of rustc itself, which should
act as a sufficient test.
Fixes #2248.