]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/issue-93874.rs
Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
[rust.git] / src / test / ui / generic-associated-types / issue-93874.rs
1 // check-pass
2
3 #![feature(generic_associated_types)]
4
5 pub trait Build {
6     type Output<O>;
7     fn build<O>(self, input: O) -> Self::Output<O>;
8 }
9
10 pub struct IdentityBuild;
11 impl Build for IdentityBuild {
12     type Output<O> = O;
13     fn build<O>(self, input: O) -> Self::Output<O> {
14         input
15     }
16 }
17
18 fn a() {
19     let _x: u8 = IdentityBuild.build(10);
20 }
21
22 fn b() {
23     let _x: Vec<u8> = IdentityBuild.build(Vec::new());
24 }
25
26 fn c() {
27     let mut f = IdentityBuild.build(|| ());
28     (f)();
29 }
30
31 pub fn main() {
32     a();
33     b();
34     c();
35 }