]> git.lizzy.rs Git - rust.git/blob - src/test/ui/typeck/typeck_type_placeholder_item.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[rust.git] / src / test / ui / typeck / typeck_type_placeholder_item.rs
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 // This test checks that it is not possible to enable global type
12 // inference by using the `_` type placeholder.
13
14 fn test() -> _ { 5 }
15 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
16
17 fn test2() -> (_, _) { (5, 5) }
18 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
19 //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
20
21 static TEST3: _ = "test";
22 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
23
24 static TEST4: _ = 145;
25 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
26
27 static TEST5: (_, _) = (1, 2);
28 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
29 //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
30
31 fn test6(_: _) { }
32 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
33
34 fn test7(x: _) { let _x: usize = x; }
35 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
36
37 fn test8(_f: fn() -> _) { }
38 //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
39
40 struct Test9;
41
42 impl Test9 {
43     fn test9(&self) -> _ { () }
44     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
45
46     fn test10(&self, _x : _) { }
47     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
48 }
49
50 impl Clone for Test9 {
51     fn clone(&self) -> _ { Test9 }
52     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
53
54     fn clone_from(&mut self, other: _) { *self = Test9; }
55     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
56 }
57
58 struct Test10 {
59     a: _,
60     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
61     b: (_, _),
62     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
63     //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
64 }
65
66 pub fn main() {
67     fn fn_test() -> _ { 5 }
68     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
69
70     fn fn_test2() -> (_, _) { (5, 5) }
71     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
72     //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
73
74     static FN_TEST3: _ = "test";
75     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
76
77     static FN_TEST4: _ = 145;
78     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
79
80     static FN_TEST5: (_, _) = (1, 2);
81     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
82     //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
83
84     fn fn_test6(_: _) { }
85     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
86
87     fn fn_test7(x: _) { let _x: usize = x; }
88     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
89
90     fn fn_test8(_f: fn() -> _) { }
91     //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
92
93     struct FnTest9;
94
95     impl FnTest9 {
96         fn fn_test9(&self) -> _ { () }
97         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
98
99         fn fn_test10(&self, _x : _) { }
100         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
101     }
102
103     impl Clone for FnTest9 {
104         fn clone(&self) -> _ { FnTest9 }
105         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
106
107         fn clone_from(&mut self, other: _) { *self = FnTest9; }
108         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
109     }
110
111     struct FnTest10 {
112         a: _,
113         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
114         b: (_, _),
115         //~^ ERROR the type placeholder `_` is not allowed within types on item signatures
116         //~^^ ERROR the type placeholder `_` is not allowed within types on item signatures
117     }
118
119 }