Skip to content

Struct inheritance goes wrong for unit-like and tuple structs #15096

Closed
@ben0x539

Description

@ben0x539

This compiles and segfaults (or anyway prints weird values):

#![feature(struct_inherit)]

virtual struct Foo {
    x: Box<int>
}

struct Bar : Foo;

fn main() {
    println!("{}", Bar.x);
}

An inheriting tuple struct (surprisingly spelled eg. struct Bar : Foo (int, int); too!) also compiles and does broken things.

Edit: The other way around is probably also wrong, with a non-record-like base struct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions