Skip to content

Struct constness/mutability needs to be represented in metadata #3177

Closed
@bblum

Description

@bblum

Whether or not a struct is const is forgotten across crate boundaries. The compiler should reject this program:

const.rs:

use nonconst;
import nonconst::nonconst;

fn x<T: const>(_x: T) { }

fn main() { x(nonconst()) }

nonconst.rc:

#[crate_type = "lib"];

nonconst.rs:

struct nonconst { mut z: (); }
fn nonconst() -> nonconst { nonconst { mut z: () } }

If you change the type nonconst to be e.g. an old-style record type, the program is correctly rejected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions