diff options
| author | bors <bors@rust-lang.org> | 2013-08-14 04:41:20 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-14 04:41:20 -0700 |
| commit | ac49e656111cdd1727988bbbf3d3b9be554ae391 (patch) | |
| tree | 34f5a3f840468e51f05827f0d228d041f0015487 /src | |
| parent | cd656c74f67a289bb14c7758847a0fdd2e61d9a1 (diff) | |
| parent | f3a79cf66722a917a59376b0ad60a0a370c48b8b (diff) | |
| download | rust-ac49e656111cdd1727988bbbf3d3b9be554ae391.tar.gz rust-ac49e656111cdd1727988bbbf3d3b9be554ae391.zip | |
auto merge of #8440 : sfackler/rust/env-fix, r=pcwalton
The type of the result of option_env! was not fully specified in the
None case, leading to type check failures in the case where the variable
was not defined (e.g. option_env!("FOO").is_none()).
Also cleaned up some compilation warnings.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libsyntax/ext/env.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/extoption_env-not-defined.rs | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index c9e01b0f0d5..cb2d4f8ba24 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -27,7 +27,7 @@ pub fn expand_option_env(ext_cx: @ExtCtxt, sp: span, tts: &[ast::token_tree]) let var = get_single_str_from_tts(ext_cx, sp, tts, "option_env!"); let e = match os::getenv(var) { - None => quote_expr!(::std::option::None), + None => quote_expr!(::std::option::None::<&'static str>), Some(s) => quote_expr!(::std::option::Some($s)) }; MRExpr(e) diff --git a/src/test/run-pass/extoption_env-not-defined.rs b/src/test/run-pass/extoption_env-not-defined.rs index 412efcc25a8..cbf4c36c5df 100644 --- a/src/test/run-pass/extoption_env-not-defined.rs +++ b/src/test/run-pass/extoption_env-not-defined.rs @@ -9,6 +9,5 @@ // except according to those terms. fn main() { - let opt: Option<&'static str> = option_env!("__HOPEFULLY_DOESNT_EXIST__"); - assert!(opt.is_none()); + assert!(option_env!("__HOPEFULLY_DOESNT_EXIST__").is_none()); } |
