From 14b4459e8ffc5e07b6261daf6839150d20b6d56b Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 3 Apr 2021 19:58:09 +0900 Subject: [PATCH] Add a regression test for issue-51446 --- .../associated_type_bound/issue-51446.rs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/ui/traits/associated_type_bound/issue-51446.rs diff --git a/src/test/ui/traits/associated_type_bound/issue-51446.rs b/src/test/ui/traits/associated_type_bound/issue-51446.rs new file mode 100644 index 0000000000000..7dd95de73ba41 --- /dev/null +++ b/src/test/ui/traits/associated_type_bound/issue-51446.rs @@ -0,0 +1,34 @@ +// Regression test for #51446. +// check-pass + +trait Foo { + type Item; + fn get(&self) -> Self::Item; +} + +fn blah(x: T, f: F) -> B +where + T: Foo, + F: Fn(T::Item), +{ + B { x: x.get(), f } +} + +pub struct B +where + F: Fn(T), +{ + pub x: T, + pub f: F, +} + +impl Foo for i32 { + type Item = i32; + fn get(&self) -> i32 { + *self + } +} + +fn main() { + let _ = blah(0, |_| ()); +}