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:
Steven Fackler 2013-08-10 11:09:30 -07:00
parent 63c62bea3a
commit f3a79cf667
2 changed files with 2 additions and 3 deletions

View File

@ -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)

View File

@ -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());
}