Skip to content

Commit 4acfcd8

Browse files
committed
Improve error message for use of a non-pure-fn in a pred
Closes #1883
1 parent cb2f43c commit 4acfcd8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/comp/middle/resolve.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,9 @@ fn resolve_constr(e: @env, c: @ast::constr, sc: scopes, _v: vt<scopes>) {
681681
e.def_map.insert(c.node.id, d);
682682
}
683683
_ {
684-
e.sess.span_err(c.span,
685-
"Non-predicate in constraint: " +
686-
path_to_str(c.node.path));
684+
let s = path_to_str(c.node.path);
685+
e.sess.span_err(c.span, #fmt("%s is not declared pure. Try \
686+
`pure fn %s` instead of `fn %s`.", s, s, s));
687687
}
688688
}
689689
}

src/test/compile-fail/not-a-pred.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// -*- rust -*-
2-
// error-pattern: Non-predicate in constraint: lt
2+
// error-pattern: lt is not declared pure
33

44
fn f(a: int, b: int) : lt(a, b) { }
55

0 commit comments

Comments
 (0)