about summary refs log tree commit diff
path: root/tests/ui/traits/fnonce-repro-trait-impl-13434.rs
blob: 61d5a1d74aeedcc87fd9795fc8808d2166121f76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Regression test for https://github.com/rust-lang/rust/issues/13434

//@ run-pass
#[derive(Debug)]
struct MyStruct;

trait Repro {
  fn repro(self, s: MyStruct) -> String;
}

impl<F> Repro for F where F: FnOnce(MyStruct) -> String {
  fn repro(self, s: MyStruct) -> String {
    self(s)
  }
}

fn do_stuff<R: Repro>(r: R) -> String {
  r.repro(MyStruct)
}

pub fn main() {
  assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s)));
}