Skip to content

Commit 1717d51

Browse files
committed
Add tests ensuring mutable refs are not Copy/Clone
1 parent 7a60ab7 commit 1717d51

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

tests/test/refs.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn refs_are_sized() {
3030
}
3131

3232
#[test]
33-
fn refs_are_copy() {
33+
fn immut_refs_are_copy() {
3434
test! {
3535
program {
3636
#[lang(copy)]
@@ -46,7 +46,7 @@ fn refs_are_copy() {
4646
}
4747

4848
#[test]
49-
fn refs_are_clone() {
49+
fn immut_refs_are_clone() {
5050
test! {
5151
program {
5252
#[lang(clone)]
@@ -60,3 +60,35 @@ fn refs_are_clone() {
6060
}
6161
}
6262
}
63+
64+
#[test]
65+
fn mut_refs_are_not_copy() {
66+
test! {
67+
program {
68+
#[lang(copy)]
69+
trait Copy { }
70+
}
71+
72+
goal {
73+
forall<'a, T> { not { &'a mut T: Copy } }
74+
} yields {
75+
"Unique; substitution [], lifetime constraints []"
76+
}
77+
}
78+
}
79+
80+
#[test]
81+
fn mut_refs_are_not_clone() {
82+
test! {
83+
program {
84+
#[lang(clone)]
85+
trait Clone { }
86+
}
87+
88+
goal {
89+
forall<'a, T> { not { &'a mut T: Clone } }
90+
} yields {
91+
"Unique; substitution [], lifetime constraints []"
92+
}
93+
}
94+
}

0 commit comments

Comments
 (0)