diff options
| author | Brian Anderson <andersrb@gmail.com> | 2011-06-04 17:08:50 -0400 |
|---|---|---|
| committer | Brian Anderson <andersrb@gmail.com> | 2011-06-04 17:14:32 -0400 |
| commit | 3ca5fff195cfb37e102d5686bbce4b570eb6fda2 (patch) | |
| tree | 4de1c7c6dda9cdb2396f040e24aeb2d486fa404c /src/comp | |
| parent | ac83e34dc6c2bb3b5f181f923560d810dcdb558c (diff) | |
| download | rust-3ca5fff195cfb37e102d5686bbce4b570eb6fda2.tar.gz rust-3ca5fff195cfb37e102d5686bbce4b570eb6fda2.zip | |
rustc: Use spans for #env errors
Issue #444
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/front/extenv.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/comp/front/extenv.rs b/src/comp/front/extenv.rs index fc7d889d8f6..d92c5eb7dbd 100644 --- a/src/comp/front/extenv.rs +++ b/src/comp/front/extenv.rs @@ -23,13 +23,13 @@ fn expand_syntax_ext(&ext_ctxt cx, option::t[str] body) -> @ast::expr { if (vec::len[@ast::expr](args) != 1u) { - p.err("malformed #env call"); + cx.span_err(sp, "malformed #env call"); } // FIXME: if this was more thorough it would manufacture an // option::t[str] rather than just an maybe-empty string. - auto var = expr_to_str(p, args.(0)); + auto var = expr_to_str(cx, p, args.(0)); alt (generic_os::getenv(var)) { case (option::none) { ret make_new_str(p, sp, ""); @@ -42,7 +42,7 @@ fn expand_syntax_ext(&ext_ctxt cx, // FIXME: duplicate code copied from extfmt: -fn expr_to_str(parser::parser p, +fn expr_to_str(&ext_ctxt cx, parser::parser p, @ast::expr expr) -> str { alt (expr.node) { case (ast::expr_lit(?l, _)) { @@ -50,11 +50,15 @@ fn expr_to_str(parser::parser p, case (ast::lit_str(?s)) { ret s; } + case (_) { + cx.span_err(l.span, "malformed #env call"); + } } } + case (_) { + cx.span_err(expr.span, "malformed #env call"); + } } - p.err("malformed #env call"); - fail; } fn make_new_lit(parser::parser p, common::span sp, ast::lit_ lit) |
