Unsoundness: ~Trait is considered Const, but shouldn't be

565581e
Opened by bill-myers at 2013-08-22 04:41:30

It seems that in Rust ~Trait are Const but that seems wrong, because the implementation of Trait can contain non-Const structs, such as those annotated "mutable", like RcMut.

This seems allows to create an RcMut pointing to itself, like this.

extern mod std;
use std::rc::*;

trait Foo
{
    fn set(&mut self, v: RcMut<A>);
}

struct B
{
    v: Option<RcMut<A>>
}

impl Foo for B
{
    fn set(&mut self, v: RcMut<A>)
    {
        self.v = Some(v);
    }
}

struct A
{
    v: ~Foo,
}

fn main()
{
    let a = A {v: ~B{v: None} as ~Foo};
    let v = rc_mut_from_const(a);
    let w = v.clone();
    v.with_mut_borrow(|p| {p.v.set(w.clone());})
}
  1. triage bump; soon to be closed.

    emberian at 2013-08-19 17:35:10