2012-12-10 19:32:48 -06:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2013-02-21 17:19:40 -06:00
|
|
|
struct box<T> {
|
2013-02-22 18:08:16 -06:00
|
|
|
f: T
|
2013-02-21 17:19:40 -06:00
|
|
|
}
|
2013-02-22 18:08:16 -06:00
|
|
|
|
2013-02-21 17:19:40 -06:00
|
|
|
enum box_impl<T> = box<T>;
|
2012-04-06 10:16:20 -05:00
|
|
|
|
|
|
|
fn set_box_impl<T>(b: box_impl<@const T>, v: @const T) {
|
|
|
|
b.f = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2013-02-22 18:08:16 -06:00
|
|
|
let b = box_impl::<@int>(box::<@int> {f: @3});
|
2012-04-06 10:16:20 -05:00
|
|
|
set_box_impl(b, @mut 5);
|
2012-06-30 06:23:59 -05:00
|
|
|
//~^ ERROR values differ in mutability
|
2012-04-06 10:16:20 -05:00
|
|
|
|
|
|
|
// No error when type of parameter actually IS @const int
|
|
|
|
let x: @const int = @3; // only way I could find to upcast
|
2013-02-22 18:08:16 -06:00
|
|
|
let b = box_impl::<@const int>(box::<@const int>{f: x});
|
2012-04-06 10:16:20 -05:00
|
|
|
set_box_impl(b, @mut 5);
|
2013-02-14 13:47:00 -06:00
|
|
|
}
|