]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/nll/relate_tys/var-appears-twice.rs
02b3006c5315c49158668d0f9b49f1abeef88d73
1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that the NLL `relate_tys` code correctly deduces that a
12 // function returning always its first argument can be upcast to one
13 // that returns either first or second argument.
20 type DoubleCell
<A
> = Cell
<(A
, A
)>;
21 type DoublePair
<A
> = (A
, A
);
23 fn make_cell
<'b
>(x
: &'b
u32) -> Cell
<(&'
static u32, &'b
u32)> {
28 let a
: &'
static u32 = &22;
31 // Here we get an error because `DoubleCell<_>` requires the same type
32 // on both parts of the `Cell`, and we can't have that.
33 let x
: DoubleCell
<_
> = make_cell(&b
); //~ ERROR
35 // Here we do not get an error because `DoublePair<_>` permits
36 // variance on the lifetimes involved.
37 let y
: DoublePair
<_
> = make_cell(&b
).get();