Skip to content

Self initialization doesn't work #248

Description

@jrmuizel
struct list_head {
    struct list_head *next;
};

void f() {
        struct list_head list = { &list };
}

compiles to:

#[derive(Default)]
pub struct list_head {
    pub next: Value<Ptr<list_head>>,
}


pub fn f_0() {
    let list: Value<list_head> = Rc::new(RefCell::new(list_head {
        next: Rc::new(RefCell::new((list.as_pointer()))),
    }));
}

which fails to build with:

error[E0425]: cannot find value `list` in this scope
  --> src/main.rs:35:37
   |
35 |         next: Rc::new(RefCell::new((list.as_pointer()))),
   |                                     ^^^^ not found in this scope

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions