diff --git a/src/comp/front/extfmt.rs b/src/comp/front/extfmt.rs index 58949518649c..64fe7b6df5d3 100644 --- a/src/comp/front/extfmt.rs +++ b/src/comp/front/extfmt.rs @@ -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; } diff --git a/src/test/compile-fail/extfmt-non-literal.rs b/src/test/compile-fail/extfmt-non-literal.rs new file mode 100644 index 000000000000..4b85498c1ab0 --- /dev/null +++ b/src/test/compile-fail/extfmt-non-literal.rs @@ -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"); +}