diff options
Diffstat (limited to 'tests/ui/trait-bounds/issue-95640.rs')
-rw-r--r-- | tests/ui/trait-bounds/issue-95640.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/trait-bounds/issue-95640.rs b/tests/ui/trait-bounds/issue-95640.rs new file mode 100644 index 000000000..e4e998b5d --- /dev/null +++ b/tests/ui/trait-bounds/issue-95640.rs @@ -0,0 +1,31 @@ +// build-pass +// compile-flags:-Zmir-opt-level=3 + +struct D; + +trait Tr { + type It; + fn foo(self) -> Option<Self::It>; +} + +impl<'a> Tr for &'a D { + type It = (); + fn foo(self) -> Option<()> { + None + } +} + +fn run<F>(f: F) +where + for<'a> &'a D: Tr, + F: Fn(<&D as Tr>::It), +{ + let d = &D; + while let Some(i) = d.foo() { + f(i); + } +} + +fn main() { + run(|_| {}); +} |