rustc: Fail better when the first argument to #fmt is not a string literal
This commit is contained in:
parent
c4e9d8fb91
commit
29a801565a
2 changed files with 12 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
9
src/test/compile-fail/extfmt-non-literal.rs
Normal file
9
src/test/compile-fail/extfmt-non-literal.rs
Normal 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");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue