]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2014 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 | // Test that the types of distinct fn items are not compatible by | |
12 | // default. See also `run-pass/fn-item-type-*.rs`. | |
13 | ||
54a0048b SL |
14 | fn foo<T>(x: isize) -> isize { x * 2 } |
15 | fn bar<T>(x: isize) -> isize { x * 4 } | |
1a4d82fc JJ |
16 | |
17 | fn eq<T>(x: T, y: T) { } | |
18 | ||
54a0048b SL |
19 | trait Foo { fn foo() { /* this is a default fn */ } } |
20 | impl<T> Foo for T { /* `foo` is still default here */ } | |
21 | ||
1a4d82fc | 22 | fn main() { |
54a0048b | 23 | eq(foo::<u8>, bar::<u8>); |
85aaf69f | 24 | //~^ ERROR mismatched types |
54a0048b SL |
25 | //~| expected `fn(isize) -> isize {foo::<u8>}` |
26 | //~| found `fn(isize) -> isize {bar::<u8>}` | |
85aaf69f SL |
27 | //~| expected fn item |
28 | //~| found a different fn item | |
54a0048b SL |
29 | |
30 | eq(foo::<u8>, foo::<i8>); | |
31 | //~^ ERROR mismatched types | |
32 | //~| expected `fn(isize) -> isize {foo::<u8>}` | |
33 | //~| found `fn(isize) -> isize {foo::<i8>}` | |
34 | ||
35 | eq(bar::<String>, bar::<Vec<u8>>); | |
36 | //~^ ERROR mismatched types | |
37 | //~| expected `fn(isize) -> isize {bar::<std::string::String>}` | |
38 | //~| found `fn(isize) -> isize {bar::<std::vec::Vec<u8>>}` | |
39 | //~| expected struct `std::string::String` | |
40 | //~| found struct `std::vec::Vec` | |
41 | ||
42 | // Make sure we distinguish between trait methods correctly. | |
43 | eq(<u8 as Foo>::foo, <u16 as Foo>::foo); | |
44 | //~^ ERROR mismatched types | |
45 | //~| expected `fn() {<u8 as Foo>::foo}` | |
46 | //~| found `fn() {<u16 as Foo>::foo}` | |
1a4d82fc | 47 | } |