From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/hr-subtype/placeholder-pattern-fail.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/ui/hr-subtype/placeholder-pattern-fail.rs (limited to 'tests/ui/hr-subtype/placeholder-pattern-fail.rs') diff --git a/tests/ui/hr-subtype/placeholder-pattern-fail.rs b/tests/ui/hr-subtype/placeholder-pattern-fail.rs new file mode 100644 index 000000000..bd4533e04 --- /dev/null +++ b/tests/ui/hr-subtype/placeholder-pattern-fail.rs @@ -0,0 +1,25 @@ +// Check that incorrect higher ranked subtyping +// causes an error. +struct Inv<'a>(fn(&'a ()) -> &'a ()); +fn hr_subtype<'c>(f: for<'a, 'b> fn(Inv<'a>, Inv<'a>)) { + // ok + let _: for<'a> fn(Inv<'a>, Inv<'a>) = f; + let sub: for<'a> fn(Inv<'a>, Inv<'a>) = f; + // no + let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub; + //~^ ERROR mismatched types +} + +fn simple1<'c>(x: (&'c i32,)) { + let _x: (&'static i32,) = x; +} + +fn simple2<'c>(x: (&'c i32,)) { + let _: (&'static i32,) = x; +} + +fn main() { + hr_subtype(|_, _| {}); + simple1((&3,)); + simple2((&3,)); +} -- cgit v1.2.3