Skip to content

ToSource implementation is incorrect for signed integers #18091

Closed
@apasel422

Description

@apasel422

It appears that the syntax::ext::quote::rt::ToSource implementation for signed integer types omits the sign.

test.rs:

extern crate syntax;

#[test]
fn test() {
    use syntax::ext::quote::rt::ToSource;

    let n = -5i32;
    let s = n.to_source();
    assert_eq!(s, "-5i32".to_string());
}

Output after compiling with rustc 0.13.0-nightly (40b244973 2014-10-14 23:22:20 +0000):

task 'test' failed at 'assertion failed: `(left == right) && (right == left)` (left: `5i32`, right: `-5i32`)'

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensionsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions