diff options
| author | lcnr <rust@lcnr.de> | 2025-09-11 13:08:36 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-09-18 12:58:38 +0200 |
| commit | f4e19c68786211f3c3cf2593442629599678800a (patch) | |
| tree | e4eafc26e6dad3c7fb9bf418ab476ac64b555fab /tests/ui/impl-trait/non-defining-uses/impl-deref-function-call.rs | |
| parent | d1ed52b1f5b78bf66127b670af813b84d57aeedb (diff) | |
| download | rust-f4e19c68786211f3c3cf2593442629599678800a.tar.gz rust-f4e19c68786211f3c3cf2593442629599678800a.zip | |
support calls on opaque types :<
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.rs | 56 |
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() {} |
