]> git.lizzy.rs Git - rust.git/blob - tests/ui/hr-subtype/placeholder-pattern-fail.rs
Rollup merge of #106707 - ehuss:remove-dupe-sha-1, r=Mark-Simulacrum
[rust.git] / tests / ui / hr-subtype / placeholder-pattern-fail.rs
1 // Check that incorrect higher ranked subtyping
2 // causes an error.
3 struct Inv<'a>(fn(&'a ()) -> &'a ());
4 fn hr_subtype<'c>(f: for<'a, 'b> fn(Inv<'a>, Inv<'a>)) {
5     // ok
6     let _: for<'a> fn(Inv<'a>, Inv<'a>) = f;
7     let sub: for<'a> fn(Inv<'a>, Inv<'a>) = f;
8     // no
9     let _: for<'a, 'b> fn(Inv<'a>, Inv<'b>) = sub;
10     //~^ ERROR mismatched types
11 }
12
13 fn simple1<'c>(x: (&'c i32,)) {
14     let _x: (&'static i32,) = x;
15 }
16
17 fn simple2<'c>(x: (&'c i32,)) {
18     let _: (&'static i32,) = x;
19 }
20
21 fn main() {
22     hr_subtype(|_, _| {});
23     simple1((&3,));
24     simple2((&3,));
25 }