Skip to content

Constant-folding error with negative constant on RHS of shift #26210

Closed
@eefriedman

Description

@eefriedman
fn main() {
    let a = -1+2isize;
    let _b = a<<(1isize-1);
    let _c = a<<(a+-1);
    let _d = a<<(1isize+-1);
}

Produces:

<anon>:5:25: 5:27 error: unary negation of unsigned integers may be removed in the future
<anon>:5     let _d = a<<(1isize+-1);
                                 ^~
error: aborting due to previous error

I would expect no error.

I think the error message is coming out of eval_const_expr_with_substs.

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