mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Fixed option_env! type
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()).
This commit is contained in:
parent
63c62bea3a
commit
f3a79cf667
@ -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)
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user