Improve error message for use of a non-pure-fn in a pred

Closes #1883
This commit is contained in:
Tim Chevalier 2012-02-22 10:55:39 -08:00
parent cb2f43cbf4
commit 4acfcd8c2f
2 changed files with 4 additions and 4 deletions

View File

@ -681,9 +681,9 @@ fn resolve_constr(e: @env, c: @ast::constr, sc: scopes, _v: vt<scopes>) {
e.def_map.insert(c.node.id, d);
}
_ {
e.sess.span_err(c.span,
"Non-predicate in constraint: " +
path_to_str(c.node.path));
let s = path_to_str(c.node.path);
e.sess.span_err(c.span, #fmt("%s is not declared pure. Try \
`pure fn %s` instead of `fn %s`.", s, s, s));
}
}
}

View File

@ -1,5 +1,5 @@
// -*- rust -*-
// error-pattern: Non-predicate in constraint: lt
// error-pattern: lt is not declared pure
fn f(a: int, b: int) : lt(a, b) { }