Skip to content

Parenthesised part of type mismatch error message sometimes prints back-to-front #11771

@nmsmith

Description

@nmsmith

As the title says, the parenthesised part sometimes prints backwards. At least, I've found one case where it does - when one of the operands is a reference provided by an iterator:

Test code:

fn main() {
    let i: [int, ..5] = [0, ..5];
    let n = &i[0];

    // Error prints correctly
    1 + n;

    // Error prints backwards
    for v in i.iter() {
        1 + v;
    }
}

Result:

test.rs:8:6: 8:7 error: mismatched types: expected `<generic integer #3>`
but found `&int` (expected integral variable but found &-ptr)
test.rs:8   1 + n;
                ^
test.rs:12:7: 12:8 error: mismatched types: expected `<generic integer #4>`
but found `&int` (expected &-ptr but found integral variable)
test.rs:12      1 + v;

Activity

ben0x539

ben0x539 commented on Jan 28, 2014

@ben0x539
Contributor

Slightly more minimal test case:

fn main() {
    let x = ();
    // Error prints correctly
    1 + x;

    let x: () = ();
    // Error prints backwards
    1 + x;
}

Weird~

nmsmith

nmsmith commented on Jan 28, 2014

@nmsmith
Author

Ah, that's interesting. Then it seems the problem might be related to type inference. I'm not familiar enough with the compiler internals to investigate it myself though.

ghost added
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Oct 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @ben0x539@nmsmith

      Issue actions

        Parenthesised part of type mismatch error message sometimes prints back-to-front · Issue #11771 · rust-lang/rust