Allow some resources to be considered const.
This commit is contained in:
parent
3acc3c4d85
commit
0470abe1d2
2 changed files with 7 additions and 2 deletions
|
@ -1526,7 +1526,10 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
|||
}
|
||||
lowest
|
||||
}
|
||||
ty_res(did, inner, tps) { kind_send_only() }
|
||||
ty_res(did, inner, tps) {
|
||||
let inner = subst(cx, tps, inner);
|
||||
(kind_const() & type_kind(cx, inner)) | kind_send_only()
|
||||
}
|
||||
ty_param(_, did) {
|
||||
// FIXME: type params shouldn't be implicitly copyable (#2449)
|
||||
let k = param_bounds_to_kind(cx.ty_param_bounds.get(did.node));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
fn foo<T: const>(_x: T) { }
|
||||
|
||||
resource r(_x: int) {}
|
||||
resource r2(_x: @mut int) {}
|
||||
|
||||
fn main() {
|
||||
foo({f: 3});
|
||||
|
@ -13,7 +14,8 @@ fn main() {
|
|||
foo(~mut 1); //! ERROR missing `const`
|
||||
foo(@1);
|
||||
foo(@mut 1); //! ERROR missing `const`
|
||||
foo(r(1)); //! ERROR missing `const`
|
||||
foo(r(1)); // this is okay now.
|
||||
foo(r2(@mut 1)); //! ERROR missing `const`
|
||||
foo("123");
|
||||
foo({f: {mut f: 1}}); //! ERROR missing `const`
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue