Revert RIMOV to compile-fail tests
This commit is contained in:
parent
3e2ed18a4c
commit
df04bd6c6c
22 changed files with 59 additions and 59 deletions
|
|
@ -1,5 +1,5 @@
|
|||
fn main() {
|
||||
let mut a = [1, 2, 3, 4];
|
||||
let a = [mut 1, 2, 3, 4];
|
||||
let _ = match a {
|
||||
[1, 2, ..move tail] => tail,
|
||||
_ => core::util::unreachable()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let mut x: ~[int] = ~[3];
|
||||
let mut x: ~[mut int] = ~[mut 3];
|
||||
let y: ~[int] = ~[3];
|
||||
x = y; //~ ERROR values differ in mutability
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
type point = { x: int, y: int };
|
||||
|
||||
fn a() {
|
||||
let mut p = ~[1];
|
||||
let mut p = ~[mut 1];
|
||||
|
||||
// Create an immutable pointer into p's contents:
|
||||
let _q: &int = &p[0]; //~ NOTE loan of mutable vec content granted here
|
||||
|
|
@ -25,7 +25,7 @@ fn b() {
|
|||
// here we alias the mutable vector into an imm slice and try to
|
||||
// modify the original:
|
||||
|
||||
let mut p = ~[1];
|
||||
let mut p = ~[mut 1];
|
||||
|
||||
do borrow(p) { //~ NOTE loan of mutable vec content granted here
|
||||
p[0] = 5; //~ ERROR assigning to mutable vec content prohibited due to outstanding loan
|
||||
|
|
@ -35,7 +35,7 @@ fn b() {
|
|||
fn c() {
|
||||
// Legal because the scope of the borrow does not include the
|
||||
// modification:
|
||||
let mut p = ~[1];
|
||||
let mut p = ~[mut 1];
|
||||
borrow(p, ||{});
|
||||
p[0] = 5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@ fn takes_imm_elt(_v: &int, f: fn()) {
|
|||
}
|
||||
|
||||
fn has_mut_vec_and_does_not_try_to_change_it() {
|
||||
let mut v = ~[1, 2, 3];
|
||||
let v = ~[mut 1, 2, 3];
|
||||
do takes_imm_elt(&v[0]) {
|
||||
}
|
||||
}
|
||||
|
||||
fn has_mut_vec_but_tries_to_change_it() {
|
||||
let mut v = ~[1, 2, 3];
|
||||
let v = ~[mut 1, 2, 3];
|
||||
do takes_imm_elt(&v[0]) { //~ NOTE loan of mutable vec content granted here
|
||||
v[1] = 4; //~ ERROR assigning to mutable vec content prohibited due to outstanding loan
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ fn takes_const_elt(_v: &const int, f: fn()) {
|
|||
}
|
||||
|
||||
fn has_mut_vec_and_tries_to_change_it() {
|
||||
let mut v = ~[1, 2, 3];
|
||||
let v = ~[mut 1, 2, 3];
|
||||
do takes_const_elt(&const v[0]) {
|
||||
v[1] = 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn write(v: &mut [int]) {
|
||||
fn write(v: &[mut int]) {
|
||||
v[0] += 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ fn want_slice(v: &[int]) -> int {
|
|||
return sum;
|
||||
}
|
||||
|
||||
fn has_mut_vec(+v: @~[int]) -> int {
|
||||
fn has_mut_vec(+v: @~[mut int]) -> int {
|
||||
want_slice(*v) //~ ERROR illegal borrow unless pure
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert has_mut_vec(@~[1, 2, 3]) == 6;
|
||||
assert has_mut_vec(@~[mut 1, 2, 3]) == 6;
|
||||
}
|
||||
|
|
@ -33,8 +33,8 @@ fn main() {
|
|||
{
|
||||
let mut res = foo(x);
|
||||
|
||||
let mut v = ~[];
|
||||
v = move ~[(move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `&static`, missing `copy`)
|
||||
let mut v = ~[mut];
|
||||
v = move ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `&static`, missing `copy`)
|
||||
assert (v.len() == 2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
fn main()
|
||||
{
|
||||
// See #2969 -- error message should be improved
|
||||
let mut x = [1, 2, 4];
|
||||
let mut x = [mut 1, 2, 4];
|
||||
let v : &int = &x[2];
|
||||
x[2] = 6;
|
||||
assert *v == 6;
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
// except according to those terms.
|
||||
|
||||
// xfail-test
|
||||
fn function() -> &mut [int] {
|
||||
let mut x: &static/[int] = &[1,2,3];
|
||||
fn function() -> &[mut int] {
|
||||
let mut x: &static/[mut int] = &[mut 1,2,3];
|
||||
x[0] = 12345;
|
||||
x //~ ERROR bad
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
fn two_args<T>(x: T, y: T) { }
|
||||
|
||||
fn main() {
|
||||
let mut x: ~[int] = ~[3];
|
||||
let x: ~[mut int] = ~[mut 3];
|
||||
let y: ~[int] = ~[3];
|
||||
let a: @mut int = @mut 3;
|
||||
let b: @int = @3;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
let v = @mut ~[0];
|
||||
|
||||
fn f(&&v: @mut ~[const int]) {
|
||||
*v = ~[3]
|
||||
*v = ~[mut 3]
|
||||
}
|
||||
|
||||
f(v);
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@
|
|||
// error-pattern: mismatched types
|
||||
|
||||
fn main() {
|
||||
let mut v = ~[@mut ~mut ~[0]];
|
||||
let v = ~[mut @mut ~mut ~[0]];
|
||||
|
||||
fn f(&&v: ~[@mut ~mut ~[const int]]) {
|
||||
fn f(&&v: ~[mut @mut ~mut ~[const int]]) {
|
||||
}
|
||||
|
||||
f(v);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ fn main() {
|
|||
|
||||
fn f(&&v: *mut ~[const int]) {
|
||||
unsafe {
|
||||
*v = ~[3]
|
||||
*v = ~[mut 3]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
let v = {mut g: ~[0]};
|
||||
|
||||
fn f(&&v: {mut g: ~[const int]}) {
|
||||
v.g = ~[3]
|
||||
v.g = ~[mut 3]
|
||||
}
|
||||
|
||||
f(v);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
let v = ~mut ~[0];
|
||||
|
||||
fn f(&&v: ~mut ~[const int]) {
|
||||
*v = ~[3]
|
||||
*v = ~[mut 3]
|
||||
}
|
||||
|
||||
f(v);
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@
|
|||
fn main() {
|
||||
// Note: explicit type annot is required here
|
||||
// because otherwise the inference gets smart
|
||||
// and assigns a type of ~[~[const int]].
|
||||
let mut v: ~[~[int]] = ~[~[0]];
|
||||
// and assigns a type of ~[mut ~[const int]].
|
||||
let v: ~[mut ~[int]] = ~[mut ~[0]];
|
||||
|
||||
fn f(&&v: ~[~[const int]]) {
|
||||
v[0] = ~[3]
|
||||
fn f(&&v: ~[mut ~[const int]]) {
|
||||
v[0] = ~[mut 3]
|
||||
}
|
||||
|
||||
f(v); //~ ERROR (values differ in mutability)
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@
|
|||
fn main() {
|
||||
// Note: explicit type annot is required here
|
||||
// because otherwise the inference gets smart
|
||||
// and assigns a type of ~[~[const int]].
|
||||
let mut v: ~[~[int]] = ~[~[0]];
|
||||
// and assigns a type of ~[mut ~[const int]].
|
||||
let v: ~[mut ~[mut int]] = ~[mut ~[mut 0]];
|
||||
|
||||
fn f(&&v: ~[~[const int]]) {
|
||||
fn f(&&v: ~[mut ~[const int]]) {
|
||||
v[0] = ~[3]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@
|
|||
fn main() {
|
||||
// Note: explicit type annot is required here
|
||||
// because otherwise the inference gets smart
|
||||
// and assigns a type of ~[~[const int]].
|
||||
let mut v: ~[~[~[int]]] = ~[~[~[0]]];
|
||||
// and assigns a type of ~[mut ~[const int]].
|
||||
let v: ~[mut ~[mut ~[int]]] = ~[mut ~[mut ~[0]]];
|
||||
|
||||
fn f(&&v: ~[~[~[const int]]]) {
|
||||
v[0][1] = ~[3]
|
||||
fn f(&&v: ~[mut ~[mut ~[const int]]]) {
|
||||
v[0][1] = ~[mut 3]
|
||||
}
|
||||
|
||||
f(v); //~ ERROR (values differ in mutability)
|
||||
|
|
|
|||
|
|
@ -13,23 +13,23 @@ fn main() {
|
|||
// Note: here we do not have any type annotations
|
||||
// but we do express conflicting requirements:
|
||||
|
||||
let mut v = ~[~[0]];
|
||||
let mut w = ~[~[0]];
|
||||
let mut x = ~[~[0]];
|
||||
let v = ~[mut ~[0]];
|
||||
let w = ~[mut ~[mut 0]];
|
||||
let x = ~[mut ~[mut 0]];
|
||||
|
||||
fn f(&&v: ~[~[int]]) {
|
||||
fn f(&&v: ~[mut ~[int]]) {
|
||||
v[0] = ~[3]
|
||||
}
|
||||
|
||||
fn g(&&v: ~[const ~[const int]]) {
|
||||
}
|
||||
|
||||
fn h(&&v: ~[~[int]]) {
|
||||
v[0] = ~[3]
|
||||
fn h(&&v: ~[mut ~[mut int]]) {
|
||||
v[0] = ~[mut 3]
|
||||
}
|
||||
|
||||
fn i(&&v: ~[~[const int]]) {
|
||||
v[0] = ~[3]
|
||||
fn i(&&v: ~[mut ~[const int]]) {
|
||||
v[0] = ~[mut 3]
|
||||
}
|
||||
|
||||
fn j(&&v: ~[~[const int]]) {
|
||||
|
|
@ -48,7 +48,7 @@ fn main() {
|
|||
j(w); //~ ERROR (values differ in mutability)
|
||||
|
||||
// Note that without adding f() or h() to the mix, it is valid for
|
||||
// x to have the type ~[~[const int]], and thus we can safely
|
||||
// x to have the type ~[mut ~[const int]], and thus we can safely
|
||||
// call g() and i() but not j():
|
||||
g(x);
|
||||
i(x);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ fn main() {
|
|||
foo({f: 3});
|
||||
foo({mut f: 3}); //~ ERROR missing `const`
|
||||
foo(~[1]);
|
||||
foo(~[1]); //~ ERROR missing `const`
|
||||
foo(~[mut 1]); //~ ERROR missing `const`
|
||||
foo(~1);
|
||||
foo(~mut 1); //~ ERROR missing `const`
|
||||
foo(@1);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
struct invariant {
|
||||
f: @mut [&int]
|
||||
f: @[mut &int]
|
||||
}
|
||||
|
||||
fn to_same_lifetime(bi: invariant/&r) {
|
||||
|
|
@ -25,4 +25,4 @@ fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// the right hand side in all cases. We are getting compiler errors
|
||||
// about this now, so I'm xfailing the test for now. -eholk
|
||||
|
||||
fn add(i: ~[int], m: ~[int], c: ~[const int]) {
|
||||
fn add(i: ~[int], m: ~[mut int], c: ~[const int]) {
|
||||
|
||||
// Check that:
|
||||
// (1) vectors of any two mutabilities can be added
|
||||
|
|
@ -24,9 +24,9 @@ fn add(i: ~[int], m: ~[int], c: ~[const int]) {
|
|||
m + ~[3],
|
||||
~[3]);
|
||||
|
||||
add(i + ~[3],
|
||||
m + ~[3],
|
||||
~[3]);
|
||||
add(i + ~[mut 3],
|
||||
m + ~[mut 3],
|
||||
~[mut 3]);
|
||||
|
||||
add(i + i,
|
||||
m + i,
|
||||
|
|
@ -54,19 +54,19 @@ fn add(i: ~[int], m: ~[int], c: ~[const int]) {
|
|||
//~^ mismatched types
|
||||
~[3]);
|
||||
|
||||
add(m + ~[3], //~ ERROR mismatched types
|
||||
m + ~[3],
|
||||
m + ~[3]);
|
||||
add(m + ~[mut 3], //~ ERROR mismatched types
|
||||
m + ~[mut 3],
|
||||
m + ~[mut 3]);
|
||||
|
||||
add(i + ~[3],
|
||||
i + ~[3], //~ ERROR mismatched types
|
||||
i + ~[3]);
|
||||
add(i + ~[mut 3],
|
||||
i + ~[mut 3], //~ ERROR mismatched types
|
||||
i + ~[mut 3]);
|
||||
|
||||
add(c + ~[3], //~ ERROR binary operation + cannot be applied
|
||||
add(c + ~[mut 3], //~ ERROR binary operation + cannot be applied
|
||||
//~^ mismatched types
|
||||
c + ~[3], //~ ERROR binary operation + cannot be applied
|
||||
c + ~[mut 3], //~ ERROR binary operation + cannot be applied
|
||||
//~^ mismatched types
|
||||
~[3]);
|
||||
~[mut 3]);
|
||||
|
||||
add(m + i, //~ ERROR mismatched types
|
||||
m + i,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue