]> git.proxmox.com Git - rustc.git/blob - src/test/ui/impl-trait/issues/issue-70877.rs
New upstream version 1.52.0~beta.3+dfsg1
[rustc.git] / src / test / ui / impl-trait / issues / issue-70877.rs
1 // revisions: min_tait full_tait
2 #![feature(min_type_alias_impl_trait)]
3 #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
4 #![feature(impl_trait_in_bindings)]
5 #![allow(incomplete_features)]
6
7 type FooArg<'a> = &'a dyn ToString;
8 type FooRet = impl std::fmt::Debug;
9
10 type FooItem = Box<dyn Fn(FooArg) -> FooRet>;
11 type Foo = impl Iterator<Item = FooItem>; //~ ERROR: type mismatch
12
13 #[repr(C)]
14 struct Bar(u8);
15
16 impl Iterator for Bar {
17 type Item = FooItem;
18
19 fn next(&mut self) -> Option<Self::Item> {
20 Some(Box::new(quux))
21 }
22 }
23
24 fn quux(st: FooArg) -> FooRet {
25 Some(st.to_string())
26 }
27
28 fn ham() -> Foo {
29 Bar(1)
30 }
31
32 fn oof() -> impl std::fmt::Debug {
33 let mut bar = ham();
34 let func = bar.next().unwrap();
35 return func(&"oof");
36 }
37
38 fn main() {
39 let _ = oof();
40 }