]>
Commit | Line | Data |
---|---|---|
62682a34 SL |
1 | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | // Check that when there are vacuous predicates in the environment | |
12 | // (which make a fn uncallable) we don't erroneously cache those and | |
13 | // then consider them satisfied elsewhere. The current technique for | |
14 | // doing this is just to filter "global" predicates out of the | |
15 | // environment, which means that we wind up with an error in the | |
16 | // function `vacuous`, because even though `i32: Bar<u32>` is implied | |
17 | // by its where clause, that where clause never holds. | |
18 | ||
19 | trait Foo<X,Y>: Bar<X> { | |
20 | } | |
21 | ||
22 | trait Bar<X> { } | |
23 | ||
9cc50fc6 SL |
24 | // We don't always check where clauses for sanity, but in this case |
25 | // wfcheck does report an error here: | |
54a0048b | 26 | fn vacuous<A>() //~ ERROR the trait bound `i32: Bar<u32>` is not satisfied |
62682a34 SL |
27 | where i32: Foo<u32, A> |
28 | { | |
9cc50fc6 SL |
29 | // ... the original intention was to check that we don't use that |
30 | // vacuous where clause (which could never be satisfied) to accept | |
31 | // the following line and then mess up calls elsewhere. | |
62682a34 | 32 | require::<i32, u32>(); |
62682a34 SL |
33 | } |
34 | ||
35 | fn require<A,B>() | |
36 | where A: Bar<B> | |
37 | { | |
38 | } | |
39 | ||
40 | fn main() { | |
41 | require::<i32, u32>(); | |
42 | } |