Skip to content

Prevent storing and passing DST values #13376

Closed
@nrc

Description

@nrc

We must forbid storing or passing DST values. I.e., DST values may not be l-values.

The following should be illegal:

fn g<type X>(x: X) {...}
fn f(x: ~[T]) {
    let y = *x; //~ERROR lvalue is dynamically sized
    g(*x); //~ERROR lvalue is dynamically sized
}

I think we can enforce this by preventing storage locations having DST, rather than checking de-references.

Note that pointers to DST values are themselves sized, so may be lvalues. As a follow-up, we may allow DST values to be passed as arguments, but that will involve some pretty gross hacks.

We already prevent DST values being stored in fields.

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