2012-05-24 14:24:09 -07:00
|
|
|
// Test that various non const things are rejected.
|
|
|
|
|
|
|
|
fn foo<T: const>(_x: T) { }
|
|
|
|
|
2012-08-15 18:46:55 -07:00
|
|
|
struct r {
|
2012-06-01 20:21:59 -07:00
|
|
|
let x:int;
|
|
|
|
drop {}
|
|
|
|
}
|
|
|
|
|
2012-09-05 15:58:43 -07:00
|
|
|
fn r(x:int) -> r {
|
|
|
|
r {
|
|
|
|
x: x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-15 18:46:55 -07:00
|
|
|
struct r2 {
|
2012-06-01 20:21:59 -07:00
|
|
|
let x:@mut int;
|
|
|
|
drop {}
|
|
|
|
}
|
2012-05-24 14:24:09 -07:00
|
|
|
|
2012-09-05 15:58:43 -07:00
|
|
|
fn r2(x:@mut int) -> r2 {
|
|
|
|
r2 {
|
|
|
|
x: x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-24 14:24:09 -07:00
|
|
|
fn main() {
|
|
|
|
foo({f: 3});
|
2012-06-30 12:23:59 +01:00
|
|
|
foo({mut f: 3}); //~ ERROR missing `const`
|
2012-06-29 16:26:56 -07:00
|
|
|
foo(~[1]);
|
2012-07-02 14:44:31 -07:00
|
|
|
foo(~[mut 1]); //~ ERROR missing `const`
|
2012-05-24 14:24:09 -07:00
|
|
|
foo(~1);
|
2012-06-30 12:23:59 +01:00
|
|
|
foo(~mut 1); //~ ERROR missing `const`
|
2012-05-24 14:24:09 -07:00
|
|
|
foo(@1);
|
2012-06-30 12:23:59 +01:00
|
|
|
foo(@mut 1); //~ ERROR missing `const`
|
2012-05-31 10:51:58 -07:00
|
|
|
foo(r(1)); // this is okay now.
|
2012-06-30 12:23:59 +01:00
|
|
|
foo(r2(@mut 1)); //~ ERROR missing `const`
|
|
|
|
foo({f: {mut f: 1}}); //~ ERROR missing `const`
|
2012-05-24 14:24:09 -07:00
|
|
|
}
|