Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ohadravid opened this issue May 6, 2021 · 0 comments · Fixed by #85187
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-type-system Area: Type system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ohadravid
Copy link
Contributor

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 { ... }).

@ohadravid ohadravid added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 6, 2021
@jonas-schievink jonas-schievink added A-type-system Area: Type system C-bug Category: This is a bug. labels May 6, 2021
@ohadravid ohadravid changed the title Mismatched integer types with a block causes and error with incorrect names of types Mismatched integer types with a block causes an error with incorrect names of types May 11, 2021
@bors bors closed this as completed in c4c654f May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-type-system Area: Type system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants