]> git.lizzy.rs Git - rust.git/blob - tests/ui/associated-types/bound-lifetime-constrained.rs
Rollup merge of #106715 - BoxyUwU:new_solver_triagebot, r=lcnr
[rust.git] / tests / ui / associated-types / bound-lifetime-constrained.rs
1 // revisions: func object clause
2
3 #![allow(dead_code)]
4 #![feature(rustc_attrs)]
5
6 trait Foo<'a> {
7     type Item;
8 }
9
10 impl<'a> Foo<'a> for() {
11     type Item = ();
12 }
13
14 // Check that appearing in a projection input in the argument is not enough:
15 #[cfg(func)]
16 fn func1(_: for<'a> fn(<() as Foo<'a>>::Item) -> &'a i32) {
17     //[func]~^ ERROR E0581
18 }
19
20 // Check that appearing in a projection input in the return still
21 // causes an error:
22 #[cfg(func)]
23 fn func2(_: for<'a> fn() -> <() as Foo<'a>>::Item) {
24     //[func]~^ ERROR E0581
25 }
26
27 #[cfg(object)]
28 fn object1(_: Box<dyn for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32>) {
29     //[object]~^ ERROR E0582
30 }
31
32 #[cfg(object)]
33 fn object2(_: Box<dyn for<'a> Fn() -> <() as Foo<'a>>::Item>) {
34     //[object]~^ ERROR E0582
35 }
36
37 #[cfg(clause)]
38 fn clause1<T>() where T: for<'a> Fn(<() as Foo<'a>>::Item) -> &'a i32 {
39     //[clause]~^ ERROR `Output` references lifetime `'a`
40 }
41
42 #[cfg(clause)]
43 fn clause2<T>() where T: for<'a> Fn() -> <() as Foo<'a>>::Item {
44     //[clause]~^ ERROR `Output` references lifetime `'a`
45 }
46
47 #[rustc_error]
48 fn main() { } //[ok]~ ERROR fatal error triggered by #[rustc_error]