Skip to content

Mismatched integer types with a block causes an error with incorrect names of types #84976

Closed
@ohadravid

Description

@ohadravid

Given the following code: (playground)

fn foo(length: &u32) -> i32 {
    0
}

fn main() {
    let length = 0;
    
    // Expected error:
    // length = foo(&length); 
    
    // expected `U32`, found `I32`
    length = { foo(&length) }; 
}

The current output is:

error[E0308]: mismatched types
  --> src/main.rs:12:16
   |
12 |     length = { foo(&length) }; 
   |                ^^^^^^^^^^^^ expected `U32`, found `I32`

Ideally the output should use the expected name of u32 and i32.
(This happened to me when using an length = unsafe { ... }).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-type-systemArea: Type systemC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions