Skip to content

Can't create box of parenthesised expression (documentation, error reporting) #15386

Closed
@ghost

Description

Contents of test.rs:

fn main() {
    let x: Box<int> = box (2 + 2);
}

in 0.11.0, this yields:

test.rs:2:31: 2:32 error: unexpected token: `;`
test.rs:2   let x: Box<int> = box (2 + 2);
                                         ^

However, the following code compiles:

fn main() {
    let temp = 2 + 2;
    let x: Box<int> = box temp;
}

Even doing box (2) is considered invalid syntax.

EDIT: Apparently, box()(2) is valid syntax, but this isn't written down anywhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions