diff options
author | Lukas Wirth <[email protected]> | 2020-10-06 22:46:26 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2020-10-06 22:52:00 +0100 |
commit | 6f38552edb7be10d526aa6510200b547a301593f (patch) | |
tree | b5598c947e104c7020ee590ff33bb1b7717861ec /crates/syntax/test_data | |
parent | 87cb840a4e140a49946235823384694da58c2a5a (diff) |
Add validation check for ambiguous trait objects
Diffstat (limited to 'crates/syntax/test_data')
4 files changed, 404 insertions, 0 deletions
diff --git a/crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rast b/crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rast new file mode 100644 index 000000000..592741cdb --- /dev/null +++ b/crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rast | |||
@@ -0,0 +1,192 @@ | |||
1 | [email protected] | ||
2 | [email protected] | ||
3 | [email protected] "type" | ||
4 | [email protected] " " | ||
5 | [email protected] | ||
6 | [email protected] "Foo" | ||
7 | [email protected] | ||
8 | [email protected] "<" | ||
9 | [email protected] | ||
10 | [email protected] "\'a" | ||
11 | [email protected] ">" | ||
12 | [email protected] " " | ||
13 | [email protected] "=" | ||
14 | [email protected] " " | ||
15 | [email protected] | ||
16 | [email protected] "&" | ||
17 | [email protected] "\'a" | ||
18 | [email protected] " " | ||
19 | [email protected] | ||
20 | [email protected] "dyn" | ||
21 | [email protected] " " | ||
22 | [email protected] | ||
23 | [email protected] | ||
24 | [email protected] | ||
25 | [email protected] | ||
26 | [email protected] | ||
27 | [email protected] | ||
28 | [email protected] "Send" | ||
29 | [email protected] " " | ||
30 | [email protected] "+" | ||
31 | [email protected] " " | ||
32 | [email protected] | ||
33 | [email protected] | ||
34 | [email protected] | ||
35 | [email protected] | ||
36 | [email protected] | ||
37 | [email protected] "Sync" | ||
38 | [email protected] ";" | ||
39 | [email protected] "\n" | ||
40 | [email protected] | ||
41 | [email protected] "type" | ||
42 | [email protected] " " | ||
43 | [email protected] | ||
44 | [email protected] "Foo" | ||
45 | [email protected] " " | ||
46 | [email protected] "=" | ||
47 | [email protected] " " | ||
48 | [email protected] | ||
49 | [email protected] "*" | ||
50 | [email protected] "const" | ||
51 | [email protected] " " | ||
52 | [email protected] | ||
53 | [email protected] "dyn" | ||
54 | [email protected] " " | ||
55 | [email protected] | ||
56 | [email protected] | ||
57 | [email protected] | ||
58 | [email protected] | ||
59 | [email protected] | ||
60 | [email protected] | ||
61 | [email protected] "Send" | ||
62 | [email protected] " " | ||
63 | [email protected] "+" | ||
64 | [email protected] " " | ||
65 | [email protected] | ||
66 | [email protected] | ||
67 | [email protected] | ||
68 | [email protected] | ||
69 | [email protected] | ||
70 | [email protected] "Sync" | ||
71 | [email protected] ";" | ||
72 | [email protected] "\n" | ||
73 | [email protected] | ||
74 | [email protected] "type" | ||
75 | [email protected] " " | ||
76 | [email protected] | ||
77 | [email protected] "Foo" | ||
78 | [email protected] " " | ||
79 | [email protected] "=" | ||
80 | [email protected] " " | ||
81 | [email protected] | ||
82 | [email protected] "fn" | ||
83 | [email protected] | ||
84 | [email protected] "(" | ||
85 | [email protected] ")" | ||
86 | [email protected] " " | ||
87 | [email protected] | ||
88 | [email protected] "->" | ||
89 | [email protected] " " | ||
90 | [email protected] | ||
91 | [email protected] "dyn" | ||
92 | [email protected] " " | ||
93 | [email protected] | ||
94 | [email protected] | ||
95 | [email protected] | ||
96 | [email protected] | ||
97 | [email protected] | ||
98 | [email protected] | ||
99 | [email protected] "Send" | ||
100 | [email protected] " " | ||
101 | [email protected] "+" | ||
102 | [email protected] " " | ||
103 | [email protected] | ||
104 | [email protected] "\'static" | ||
105 | [email protected] ";" | ||
106 | [email protected] "\n" | ||
107 | [email protected] | ||
108 | [email protected] "fn" | ||
109 | [email protected] " " | ||
110 | [email protected] | ||
111 | [email protected] "main" | ||
112 | [email protected] | ||
113 | [email protected] "(" | ||
114 | [email protected] ")" | ||
115 | [email protected] " " | ||
116 | [email protected] | ||
117 | [email protected] "{" | ||
118 | [email protected] "\n " | ||
119 | [email protected] | ||
120 | [email protected] "let" | ||
121 | [email protected] " " | ||
122 | [email protected] | ||
123 | [email protected] | ||
124 | [email protected] "b" | ||
125 | [email protected] " " | ||
126 | [email protected] "=" | ||
127 | [email protected] " " | ||
128 | [email protected] | ||
129 | [email protected] | ||
130 | [email protected] "(" | ||
131 | [email protected] | ||
132 | [email protected] "&" | ||
133 | [email protected] | ||
134 | [email protected] | ||
135 | [email protected] | ||
136 | [email protected] | ||
137 | [email protected] "a" | ||
138 | [email protected] ")" | ||
139 | [email protected] " " | ||
140 | [email protected] "as" | ||
141 | [email protected] " " | ||
142 | [email protected] | ||
143 | [email protected] "&" | ||
144 | [email protected] | ||
145 | [email protected] "dyn" | ||
146 | [email protected] " " | ||
147 | [email protected] | ||
148 | [email protected] | ||
149 | [email protected] | ||
150 | [email protected] | ||
151 | [email protected] | ||
152 | [email protected] | ||
153 | [email protected] "Add" | ||
154 | [email protected] | ||
155 | [email protected] "<" | ||
156 | [email protected] | ||
157 | [email protected] | ||
158 | [email protected] | ||
159 | [email protected] | ||
160 | [email protected] | ||
161 | [email protected] "Other" | ||
162 | [email protected] "," | ||
163 | [email protected] " " | ||
164 | [email protected] | ||
165 | [email protected] | ||
166 | [email protected] "Output" | ||
167 | [email protected] " " | ||
168 | [email protected] "=" | ||
169 | [email protected] " " | ||
170 | [email protected] | ||
171 | [email protected] | ||
172 | [email protected] | ||
173 | [email protected] | ||
174 | [email protected] "Addable" | ||
175 | [email protected] ">" | ||
176 | [email protected] " " | ||
177 | [email protected] "+" | ||
178 | [email protected] " " | ||
179 | [email protected] | ||
180 | [email protected] | ||
181 | [email protected] | ||
182 | [email protected] | ||
183 | [email protected] | ||
184 | [email protected] "Other" | ||
185 | [email protected] ";" | ||
186 | [email protected] "\n" | ||
187 | [email protected] "}" | ||
188 | [email protected] "\n" | ||
189 | error 19..34: ambiguous `+` in a type | ||
190 | error 54..69: ambiguous `+` in a type | ||
191 | error 90..108: ambiguous `+` in a type | ||
192 | error 143..183: ambiguous `+` in a type | ||
diff --git a/crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rs b/crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rs new file mode 100644 index 000000000..3a73d81bb --- /dev/null +++ b/crates/syntax/test_data/parser/err/0046_ambiguous_trait_object.rs | |||
@@ -0,0 +1,6 @@ | |||
1 | type Foo<'a> = &'a dyn Send + Sync; | ||
2 | type Foo = *const dyn Send + Sync; | ||
3 | type Foo = fn() -> dyn Send + 'static; | ||
4 | fn main() { | ||
5 | let b = (&a) as &dyn Add<Other, Output = Addable> + Other; | ||
6 | } | ||
diff --git a/crates/syntax/test_data/parser/ok/0069_multi_trait_object.rast b/crates/syntax/test_data/parser/ok/0069_multi_trait_object.rast new file mode 100644 index 000000000..0cd868a83 --- /dev/null +++ b/crates/syntax/test_data/parser/ok/0069_multi_trait_object.rast | |||
@@ -0,0 +1,200 @@ | |||
1 | [email protected] | ||
2 | [email protected] | ||
3 | [email protected] "type" | ||
4 | [email protected] " " | ||
5 | [email protected] | ||
6 | [email protected] "Foo" | ||
7 | [email protected] | ||
8 | [email protected] "<" | ||
9 | [email protected] | ||
10 | [email protected] "\'a" | ||
11 | [email protected] ">" | ||
12 | [email protected] " " | ||
13 | [email protected] "=" | ||
14 | [email protected] " " | ||
15 | [email protected] | ||
16 | [email protected] "&" | ||
17 | [email protected] "\'a" | ||
18 | [email protected] " " | ||
19 | [email protected] | ||
20 | [email protected] "(" | ||
21 | [email protected] | ||
22 | [email protected] "dyn" | ||
23 | [email protected] " " | ||
24 | [email protected] | ||
25 | [email protected] | ||
26 | [email protected] | ||
27 | [email protected] | ||
28 | [email protected] | ||
29 | [email protected] | ||
30 | [email protected] "Send" | ||
31 | [email protected] " " | ||
32 | [email protected] "+" | ||
33 | [email protected] " " | ||
34 | [email protected] | ||
35 | [email protected] | ||
36 | [email protected] | ||
37 | [email protected] | ||
38 | [email protected] | ||
39 | [email protected] "Sync" | ||
40 | [email protected] ")" | ||
41 | [email protected] ";" | ||
42 | [email protected] "\n" | ||
43 | [email protected] | ||
44 | [email protected] "type" | ||
45 | [email protected] " " | ||
46 | [email protected] | ||
47 | [email protected] "Foo" | ||
48 | [email protected] " " | ||
49 | [email protected] "=" | ||
50 | [email protected] " " | ||
51 | [email protected] | ||
52 | [email protected] "*" | ||
53 | [email protected] "const" | ||
54 | [email protected] " " | ||
55 | [email protected] | ||
56 | [email protected] "(" | ||
57 | [email protected] | ||
58 | [email protected] "dyn" | ||
59 | [email protected] " " | ||
60 | [email protected] | ||
61 | [email protected] | ||
62 | [email protected] | ||
63 | [email protected] | ||
64 | [email protected] | ||
65 | [email protected] | ||
66 | [email protected] "Send" | ||
67 | [email protected] " " | ||
68 | [email protected] "+" | ||
69 | [email protected] " " | ||
70 | [email protected] | ||
71 | [email protected] | ||
72 | [email protected] | ||
73 | [email protected] | ||
74 | [email protected] | ||
75 | [email protected] "Sync" | ||
76 | [email protected] ")" | ||
77 | [email protected] ";" | ||
78 | [email protected] "\n" | ||
79 | [email protected] | ||
80 | [email protected] "type" | ||
81 | [email protected] " " | ||
82 | [email protected] | ||
83 | [email protected] "Foo" | ||
84 | [email protected] " " | ||
85 | [email protected] "=" | ||
86 | [email protected] " " | ||
87 | [email protected] | ||
88 | [email protected] "fn" | ||
89 | [email protected] | ||
90 | [email protected] "(" | ||
91 | [email protected] ")" | ||
92 | [email protected] " " | ||
93 | [email protected] | ||
94 | [email protected] "->" | ||
95 | [email protected] " " | ||
96 | [email protected] | ||
97 | [email protected] "(" | ||
98 | [email protected] | ||
99 | [email protected] "dyn" | ||
100 | [email protected] " " | ||
101 | [email protected] | ||
102 | [email protected] | ||
103 | [email protected] | ||
104 | [email protected] | ||
105 | [email protected] | ||
106 | [email protected] | ||
107 | [email protected] "Send" | ||
108 | [email protected] " " | ||
109 | [email protected] "+" | ||
110 | [email protected] " " | ||
111 | [email protected] | ||
112 | [email protected] "\'static" | ||
113 | [email protected] ")" | ||
114 | [email protected] ";" | ||
115 | [email protected] "\n" | ||
116 | [email protected] | ||
117 | [email protected] "fn" | ||
118 | [email protected] " " | ||
119 | [email protected] | ||
120 | [email protected] "main" | ||
121 | [email protected] | ||
122 | [email protected] "(" | ||
123 | [email protected] ")" | ||
124 | [email protected] " " | ||
125 | [email protected] | ||
126 | [email protected] "{" | ||
127 | [email protected] "\n " | ||
128 | [email protected] | ||
129 | [email protected] "let" | ||
130 | [email protected] " " | ||
131 | [email protected] | ||
132 | [email protected] | ||
133 | [email protected] "b" | ||
134 | [email protected] " " | ||
135 | [email protected] "=" | ||
136 | [email protected] " " | ||
137 | [email protected] | ||
138 | [email protected] | ||
139 | [email protected] "(" | ||
140 | [email protected] | ||
141 | [email protected] "&" | ||
142 | [email protected] | ||
143 | [email protected] | ||
144 | [email protected] | ||
145 | [email protected] | ||
146 | [email protected] "a" | ||
147 | [email protected] ")" | ||
148 | [email protected] " " | ||
149 | [email protected] "as" | ||
150 | [email protected] " " | ||
151 | [email protected] | ||
152 | [email protected] "&" | ||
153 | [email protected] | ||
154 | [email protected] "(" | ||
155 | [email protected] | ||
156 | [email protected] "dyn" | ||
157 | [email protected] " " | ||
158 | [email protected] | ||
159 | [email protected] | ||
160 | [email protected] | ||
161 | [email protected] | ||
162 | [email protected] | ||
163 | [email protected] | ||
164 | [email protected] "Add" | ||
165 | [email protected] | ||
166 | [email protected] "<" | ||
167 | [email protected] | ||
168 | [email protected] | ||
169 | [email protected] | ||
170 | [email protected] | ||
171 | [email protected] | ||
172 | [email protected] "Other" | ||
173 | [email protected] "," | ||
174 | [email protected] " " | ||
175 | [email protected] | ||
176 | [email protected] | ||
177 | [email protected] "Output" | ||
178 | [email protected] " " | ||
179 | [email protected] "=" | ||
180 | [email protected] " " | ||
181 | [email protected] | ||
182 | [email protected] | ||
183 | [email protected] | ||
184 | [email protected] | ||
185 | [email protected] "Addable" | ||
186 | [email protected] ">" | ||
187 | [email protected] " " | ||
188 | [email protected] "+" | ||
189 | [email protected] " " | ||
190 | [email protected] | ||
191 | [email protected] | ||
192 | [email protected] | ||
193 | [email protected] | ||
194 | [email protected] | ||
195 | [email protected] "Other" | ||
196 | [email protected] ")" | ||
197 | [email protected] ";" | ||
198 | [email protected] "\n" | ||
199 | [email protected] "}" | ||
200 | [email protected] "\n" | ||
diff --git a/crates/syntax/test_data/parser/ok/0069_multi_trait_object.rs b/crates/syntax/test_data/parser/ok/0069_multi_trait_object.rs new file mode 100644 index 000000000..97eb79c48 --- /dev/null +++ b/crates/syntax/test_data/parser/ok/0069_multi_trait_object.rs | |||
@@ -0,0 +1,6 @@ | |||
1 | type Foo<'a> = &'a (dyn Send + Sync); | ||
2 | type Foo = *const (dyn Send + Sync); | ||
3 | type Foo = fn() -> (dyn Send + 'static); | ||
4 | fn main() { | ||
5 | let b = (&a) as &(dyn Add<Other, Output = Addable> + Other); | ||
6 | } | ||