about summary refs log tree commit diff
path: root/tests/ui/impl-trait/non-defining-uses/impl-deref-function-call.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/impl-trait/non-defining-uses/impl-deref-function-call.rs')
-rw-r--r--tests/ui/impl-trait/non-defining-uses/impl-deref-function-call.rs56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/ui/impl-trait/non-defining-uses/impl-deref-function-call.rs b/tests/ui/impl-trait/non-defining-uses/impl-deref-function-call.rs
new file mode 100644
index 00000000000..5ff0dae55cc
--- /dev/null
+++ b/tests/ui/impl-trait/non-defining-uses/impl-deref-function-call.rs
@@ -0,0 +1,56 @@
+//@ revisions: current next
+//@[next] compile-flags: -Znext-solver
+//@ ignore-compare-mode-next-solver (explicit revisions)
+//@ check-pass
+
+// Regression test for trait-system-refactor-initiative#181. We want to
+// be able to step through `impl Deref` in its defining scope.
+use std::ops::{Deref, DerefMut};
+fn impl_deref_fn() -> impl Deref<Target = fn(fn(&str) -> usize)> {
+    if false {
+        let func = impl_deref_fn();
+        func(|s| s.len());
+    }
+
+    &((|_| ()) as fn(_))
+}
+
+fn impl_deref_impl_fn() -> impl Deref<Target = impl Fn()> {
+    if false {
+        let func = impl_deref_impl_fn();
+        func();
+    }
+
+    &|| ()
+}
+
+fn impl_deref_impl_deref_impl_fn() -> impl Deref<Target = impl Deref<Target = impl Fn()>> {
+    if false {
+        let func = impl_deref_impl_deref_impl_fn();
+        func();
+    }
+
+    &&|| ()
+}
+
+
+fn impl_deref_mut_impl_fn() -> impl DerefMut<Target = impl Fn()> {
+    if false {
+        let func = impl_deref_impl_fn();
+        func();
+    }
+
+    Box::new(|| ())
+}
+
+
+fn impl_deref_mut_impl_fn_mut() -> impl DerefMut<Target = impl FnMut()> {
+    if false {
+        let mut func = impl_deref_mut_impl_fn_mut();
+        func();
+    }
+
+    let mut state = 0;
+    Box::new(move || state += 1)
+}
+fn main() {}