hr-fn-aaa-as-aba.rs 1.1 KB
Newer Older
N
Niko Matsakis 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Test that the NLL `relate_tys` code correctly deduces that a
// function returning either argument CANNOT be upcast to one
// that returns always its first argument.
//
// compile-flags:-Zno-leak-check

#![feature(nll)]

fn make_it() -> for<'a> fn(&'a u32, &'a u32) -> &'a u32 {
    panic!()
}

23
fn foo() {
N
Niko Matsakis 已提交
24 25 26 27
    let a: for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32 = make_it();
    //~^ ERROR higher-ranked subtype error
    drop(a);
}
28 29 30 31 32 33 34 35 36

fn bar() {
    // The code path for patterns is mildly different, so go ahead and
    // test that too:
    let _: for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32 = make_it();
    //~^ ERROR higher-ranked subtype error
}

fn main() { }