Skip to content

Commit 6f4ce28

Browse files
committed
Add test mixed_indices_check_projection_bounds
1 parent 822a388 commit 6f4ce28

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

src/rules/wf/test.rs

+84
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,90 @@ fn bound_in_header_from_env() {
276276
}
277277
}
278278

279+
#[test]
280+
fn mixed_indices_check_projection_bounds() {
281+
lowering_success! {
282+
program {
283+
trait Foo<T> { }
284+
285+
trait Bar<T> {
286+
type Item: Foo<T>;
287+
}
288+
289+
struct Stuff<T, U> { }
290+
291+
impl<T, U> Bar<T> for Stuff<T, U> where U: Foo<T> {
292+
type Item = U;
293+
}
294+
}
295+
}
296+
297+
lowering_error! {
298+
program {
299+
trait Foo<T> { }
300+
trait Baz<T> { }
301+
302+
trait Bar<T> {
303+
type Item: Baz<T>;
304+
}
305+
306+
struct Stuff<T, U> { }
307+
308+
impl<T, U> Bar<T> for Stuff<T, U> where U: Foo<T> {
309+
type Item = U;
310+
}
311+
} error_msg {
312+
"trait impl for \"Bar\" does not meet well-formedness requirements"
313+
}
314+
}
315+
}
316+
317+
#[test]
318+
fn mixed_indices_check_generic_projection_bounds() {
319+
lowering_success! {
320+
program {
321+
struct Stuff<T, U> { }
322+
323+
trait Foo<T> { }
324+
325+
// A type that impls Foo<T> as long as U: Foo<T>.
326+
struct Fooey<U, V> { }
327+
impl<T, U, V> Foo<T> for Fooey<U, V> where U: Foo<T> { }
328+
329+
trait Bar<T> {
330+
type Item<V>: Foo<T> where V: Foo<T>;
331+
}
332+
333+
impl<T, U> Bar<T> for Stuff<T, U> where U: Foo<T> {
334+
type Item<V> = Fooey<U, V>;
335+
}
336+
}
337+
}
338+
339+
lowering_error! {
340+
program {
341+
struct Stuff<T, U> { }
342+
343+
trait Foo<T> { }
344+
trait Baz<T> { }
345+
346+
// A type that impls Foo<T> as long as U: Foo<T>.
347+
struct Fooey<U, V> { }
348+
impl<T, U, V> Foo<T> for Fooey<U, V> where U: Foo<T> { }
349+
350+
trait Bar<T> {
351+
type Item<V>: Baz<T> where V: Foo<T>;
352+
}
353+
354+
impl<T, U> Bar<T> for Stuff<T, U> where U: Foo<T> {
355+
type Item<V> = Fooey<U, V>;
356+
}
357+
} error_msg {
358+
"trait impl for \"Bar\" does not meet well-formedness requirements"
359+
}
360+
}
361+
}
362+
279363
#[test]
280364
fn generic_projection_where_clause() {
281365
lowering_success! {

0 commit comments

Comments
 (0)