]> git.proxmox.com Git - rustc.git/blob - src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-71955.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / higher-rank-trait-bounds / normalize-under-binder / issue-71955.rs
1 // check-fail
2 #![feature(rustc_attrs)]
3
4 trait Parser<'s> {
5 type Output;
6
7 fn call(&self, input: &'s str) -> (&'s str, Self::Output);
8 }
9
10 impl<'s, F, T> Parser<'s> for F
11 where F: Fn(&'s str) -> (&'s str, T) {
12 type Output = T;
13 fn call(&self, input: &'s str) -> (&'s str, T) {
14 self(input)
15 }
16 }
17
18 fn foo<F1, F2>(
19 f1: F1,
20 base: &'static str,
21 f2: F2
22 )
23 where
24 F1: for<'a> Parser<'a>,
25 F2: FnOnce(&<F1 as Parser>::Output) -> bool
26 {
27 let s: String = base.to_owned();
28 let str_ref = s.as_ref();
29 let (remaining, produced) = f1.call(str_ref);
30 assert!(f2(&produced));
31 assert_eq!(remaining.len(), 0);
32 }
33
34 struct Wrapper<'a>(&'a str);
35
36 fn main() {
37 fn bar<'a>(s: &'a str) -> (&'a str, &'a str) {
38 (&s[..1], &s[..])
39 }
40
41 fn baz<'a>(s: &'a str) -> (&'a str, Wrapper<'a>) {
42 (&s[..1], Wrapper(&s[..]))
43 }
44
45 foo(bar, "string", |s| s.len() == 5);
46 //~^ ERROR mismatched types
47 //~| ERROR mismatched types
48 foo(baz, "string", |s| s.0.len() == 5);
49 //~^ ERROR mismatched types
50 //~| ERROR mismatched types
51 }