|
12 | 12 |
|
13 | 13 | use std::collections::btree_map::{IterMut, OccupiedEntry, VacantEntry}; |
14 | 14 |
|
15 | | -macro_rules! test_invariant { |
16 | | - { $m:ident $t:ident } => { |
17 | | - mod $m { |
18 | | - use std::collections::btree_map::{IterMut, OccupiedEntry, VacantEntry}; |
19 | | - |
20 | | - fn not_covariant_key<'a, 'min,'max>(v: $t<'a, &'max (), ()>) |
21 | | - -> $t<'a, &'min (), ()> |
22 | | - where 'max : 'min |
23 | | - { |
24 | | - v //~ ERROR mismatched types |
25 | | - } |
26 | | - |
27 | | - fn not_contravariant_key<'a, 'min,'max>(v: $t<'a, &'min (), ()>) |
28 | | - -> $t<'a, &'max (), ()> |
29 | | - where 'max : 'min |
30 | | - { |
31 | | - v //~ ERROR mismatched types |
32 | | - } |
33 | | - |
34 | | - fn not_covariant_val<'a, 'min,'max>(v: $t<'a, (), &'max ()>) |
35 | | - -> $t<'a, (), &'min ()> |
36 | | - where 'max : 'min |
37 | | - { |
38 | | - v //~ ERROR mismatched types |
39 | | - } |
| 15 | +fn iter_cov_key<'a, 'new>(v: IterMut<'a, &'static (), ()>) -> IterMut<'a, &'new (), ()> { |
| 16 | + v //~ ERROR mismatched types |
| 17 | +} |
| 18 | +fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, (), &'new ()> { |
| 19 | + v //~ ERROR mismatched types |
| 20 | +} |
| 21 | +fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, &'static (), ()> { |
| 22 | + v //~ ERROR mismatched types |
| 23 | +} |
| 24 | +fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, (), &'static ()> { |
| 25 | + v //~ ERROR mismatched types |
| 26 | +} |
40 | 27 |
|
41 | | - fn not_contravariant_val<'a, 'min,'max>(v: $t<'a, (), &'min ()>) |
42 | | - -> $t<'a, (), &'max ()> |
43 | | - where 'max : 'min |
44 | | - { |
45 | | - v //~ ERROR mismatched types |
46 | | - } |
47 | | - } |
48 | | - } |
| 28 | +fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>) |
| 29 | + -> OccupiedEntry<'a, &'new (), ()> { |
| 30 | + v //~ ERROR mismatched types |
| 31 | +} |
| 32 | +fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>) |
| 33 | + -> OccupiedEntry<'a, (), &'new ()> { |
| 34 | + v //~ ERROR mismatched types |
| 35 | +} |
| 36 | +fn occ_contra_key<'a, 'new>(v: OccupiedEntry<'a, &'new (), ()>) |
| 37 | + -> OccupiedEntry<'a, &'static (), ()> { |
| 38 | + v //~ ERROR mismatched types |
| 39 | +} |
| 40 | +fn occ_contra_val<'a, 'new>(v: OccupiedEntry<'a, (), &'new ()>) |
| 41 | + -> OccupiedEntry<'a, (), &'static ()> { |
| 42 | + v //~ ERROR mismatched types |
49 | 43 | } |
50 | 44 |
|
51 | | -test_invariant! { foo IterMut } |
52 | | -test_invariant! { bar OccupiedEntry } |
53 | | -test_invariant! { baz VacantEntry } |
| 45 | +fn vac_cov_key<'a, 'new>(v: VacantEntry<'a, &'static (), ()>) |
| 46 | + -> VacantEntry<'a, &'new (), ()> { |
| 47 | + v //~ ERROR mismatched types |
| 48 | +} |
| 49 | +fn vac_cov_val<'a, 'new>(v: VacantEntry<'a, (), &'static ()>) |
| 50 | + -> VacantEntry<'a, (), &'new ()> { |
| 51 | + v //~ ERROR mismatched types |
| 52 | +} |
| 53 | +fn vac_contra_key<'a, 'new>(v: VacantEntry<'a, &'new (), ()>) |
| 54 | + -> VacantEntry<'a, &'static (), ()> { |
| 55 | + v //~ ERROR mismatched types |
| 56 | +} |
| 57 | +fn vac_contra_val<'a, 'new>(v: VacantEntry<'a, (), &'new ()>) |
| 58 | + -> VacantEntry<'a, (), &'static ()> { |
| 59 | + v //~ ERROR mismatched types |
| 60 | +} |
54 | 61 |
|
55 | 62 | #[rustc_error] |
56 | 63 | fn main() { } |
0 commit comments