]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/issues/issue-70877.rs
Merge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into sync_cg_clif-2022-10-23
[rust.git] / src / test / ui / impl-trait / issues / issue-70877.rs
1 #![feature(type_alias_impl_trait)]
2
3 type FooArg<'a> = &'a dyn ToString;
4 type FooRet = impl std::fmt::Debug;
5
6 type FooItem = Box<dyn Fn(FooArg) -> FooRet>;
7 type Foo = impl Iterator<Item = FooItem>;
8
9 #[repr(C)]
10 struct Bar(u8);
11
12 impl Iterator for Bar {
13     type Item = FooItem;
14
15     fn next(&mut self) -> Option<Self::Item> {
16         Some(Box::new(quux))
17     }
18 }
19
20 fn quux(st: FooArg) -> FooRet {
21     Some(st.to_string())
22 }
23
24 fn ham() -> Foo {
25     Bar(1)
26 }
27
28 fn oof() -> impl std::fmt::Debug {
29     let mut bar = ham();
30     let func = bar.next().unwrap();
31     return func(&"oof"); //~ ERROR opaque type's hidden type cannot be another opaque type
32 }
33
34 fn main() {
35     let _ = oof();
36 }