rustc: Fail better when the first argument to #fmt is not a string literal

This commit is contained in:
Brian Anderson 2011-05-25 23:49:52 -04:00
parent c4e9d8fb91
commit 29a801565a
2 changed files with 12 additions and 2 deletions

View file

@ -74,11 +74,12 @@ fn expr_to_str(@ast::expr expr) -> str {
case (ast::lit_str(?s)) {
ret s;
}
case (_) { /* fallthrough */ }
}
}
case (_) { /* fallthrough */ }
}
// FIXME: Handle error correctly.
log_err "malformed #fmt call";
log_err "first argument to #fmt must be a string literal";
fail;
}

View file

@ -0,0 +1,9 @@
// xfail-stage0
// error-pattern: literal
fn main() {
// #fmt's first argument must be a literal. Hopefully this
// restriction can be eased eventually to just require a
// compile-time constant.
auto x = #fmt("a" + "b");
}