summary refs log tree commit diff
path: root/tests/ui/traits/fnonce-repro-trait-impl-13434.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/traits/fnonce-repro-trait-impl-13434.rs')
-rw-r--r--tests/ui/traits/fnonce-repro-trait-impl-13434.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/traits/fnonce-repro-trait-impl-13434.rs b/tests/ui/traits/fnonce-repro-trait-impl-13434.rs
new file mode 100644
index 00000000000..61d5a1d74ae
--- /dev/null
+++ b/tests/ui/traits/fnonce-repro-trait-impl-13434.rs
@@ -0,0 +1,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)));
+}