Skip to content

Commit 7a9c4a4

Browse files
committed
Expand the macro in variance-btree-invariant-types.rs to make compiletest recognize that it should error
1 parent fae75c9 commit 7a9c4a4

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

src/test/compile-fail/variance-btree-invariant-types.rs

+43-36
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,52 @@
1212

1313
use std::collections::btree_map::{IterMut, OccupiedEntry, VacantEntry};
1414

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+
}
4027

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
4943
}
5044

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+
}
5461

5562
#[rustc_error]
5663
fn main() { }

0 commit comments

Comments
 (0)