You may just want to enable the garbage-collection feature gate by
adding `#[feature(managed_boxes)];` to the top of the file. We have
currently made `@T` types "opt-in" because we expect the syntax to
change (as the message notes) and we expect the collector to change
from a ref-counting to a tracing collector, which has rather different
semantics (e.g., non-deterministic collection points). In other words,
we expect programs that use `@T` to require changes in the future as
Rust evolves, and we want to alert you to that fact.


Niko

On Mon, Oct 28, 2013 at 10:10:00PM +0530, Ramakrishnan Muthukrishnan wrote:
> Hello rust hackers,
> 
> In section 8.1.7 of the Rust manual ("Recursive types"), there is an
> example of a List definition which is recursive. Here I define a very
> simple arithmetic expression which consists of numbers and add
> expressions. When I compile it I get errors..
> 
> enum Expr
> {
>     Num(int),
>     Add(@Expr, @Expr),
> }
> 
> fn eval(e: Expr) -> int {
>     match e {
>         Num(x) => x,
>         Add(x, y) => eval(x) + eval(y),
>     }
> }
> 
> fn main() {
>     println(format!("eval 2 = {:d}", eval(Num(2))));
>     println(format!("eval 2 + 3 = {:d}", eval(Add(Num(2), Num(3)))));
> }
> 
> $ rustc arith.rs
> arith.rs:4:8: 4:13 error: The managed box syntax may be replaced by a
> library type, and a garbage collector is not yet implemented. Consider
> using the `std::rc` module as it performs much better as a reference
> counting implementation.
> arith.rs:4     Add(@Expr, @Expr),
>                    ^~~~~
> arith.rs:4:8: 4:13 note: add #[feature(managed_boxes)] to the crate
> attributes to enable
> arith.rs:4     Add(@Expr, @Expr),
>                    ^~~~~
> arith.rs:4:15: 4:20 error: The managed box syntax may be replaced by a
> library type, and a garbage collector is not yet implemented. Consider
> using the `std::rc` module as it performs much better as a reference
> counting implementation.
> arith.rs:4     Add(@Expr, @Expr),
>                           ^~~~~
> arith.rs:4:15: 4:20 note: add #[feature(managed_boxes)] to the crate
> attributes to enable
> arith.rs:4     Add(@Expr, @Expr),
>                           ^~~~~
> error: aborting due to 2 previous errors
> 
> I am running rust from master. What exactly is the compiler suggesting
> me to do? How can `std::rc' module help in this situation?
> 
> TIA
> -- 
>   Ramakrishnan
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to