]> git.proxmox.com Git - rustc.git/blame - src/test/ui/nll/relate_tys/hr-fn-aaa-as-aba.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / nll / relate_tys / hr-fn-aaa-as-aba.rs
CommitLineData
8faf50e0
XL
1// Test that the NLL `relate_tys` code correctly deduces that a
2// function returning either argument CANNOT be upcast to one
3// that returns always its first argument.
4//
5// compile-flags:-Zno-leak-check
ea8adc8c 6
8faf50e0
XL
7fn make_it() -> for<'a> fn(&'a u32, &'a u32) -> &'a u32 {
8 panic!()
223e47cc 9}
2c00a5a8 10
b7449926 11fn foo() {
8faf50e0 12 let a: for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32 = make_it();
94222f64 13 //~^ ERROR mismatched types [E0308]
8faf50e0
XL
14 drop(a);
15}
b7449926
XL
16
17fn bar() {
18 // The code path for patterns is mildly different, so go ahead and
19 // test that too:
20 let _: for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32 = make_it();
94222f64 21 //~^ ERROR mismatched types [E0308]
b7449926
XL
22}
23
94222f64 24fn main() {}