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

Error message inconsistent #26576

Closed
hfiguiere opened this issue Jun 25, 2015 · 6 comments
Closed

Error message inconsistent #26576

hfiguiere opened this issue Jun 25, 2015 · 6 comments
Labels
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.

Comments

@hfiguiere
Copy link

Try to compile the following message:

fn foo () -> i32 {
22;
}

fn foo2 () -> u32 {
22;
}

pub fn main() {
}
rust_bug.rs:1:1: 3:2 error: not all control paths return a value [E0269]
rust_bug.rs:1 fn foo () -> i32 {
rust_bug.rs:2 22;
rust_bug.rs:3 }
rust_bug.rs:2:3: 2:4 help: consider removing this semicolon:
rust_bug.rs:2 22;
                ^
rust_bug.rs:5:1: 7:2 error: not all control paths return a value [E0269]
rust_bug.rs:5 fn foo2 () -> u32 {
rust_bug.rs:6 22;
rust_bug.rs:7 }
error: aborting due to 2 previous errors

@hfiguiere
Copy link
Author

Same error, one case give help message. The other doesn't. It all depend of the return type.

Expected: to get the help message.

@hfiguiere
Copy link
Author

This was found during the Tutorial session at #mozwww

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 25, 2015
@steveklabnik
Copy link
Member

Tricky!

@arielb1
Copy link
Contributor

arielb1 commented Jun 26, 2015

This occurs because of integer fallback (22 falls back to 22i32). May still want to fix that through.

@apasel422 apasel422 changed the title Error message inconsitent. Error message inconsistent May 26, 2016
@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@estebank
Copy link
Contributor

This is fixed in stable:

rustc 1.15.1 (021bd294c 2017-02-08)
error[E0308]: mismatched types
 --> <anon>:1:17
  |
1 |   fn foo() -> i32 {
  |  _________________^ starting here...
2 | |     22;
3 | | }
  | |_^ ...ending here: expected i32, found ()
  |
  = note: expected type `i32`
  = note:    found type `()`
help: consider removing this semicolon:
 --> <anon>:2:7
  |
2 |     22;
  |       ^

error[E0308]: mismatched types
 --> <anon>:5:18
  |
5 |   fn foo2() -> u32 {
  |  __________________^ starting here...
6 | |     22;
7 | | }
  | |_^ ...ending here: expected u32, found ()
  |
  = note: expected type `u32`
  = note:    found type `()`
help: consider removing this semicolon:
 --> <anon>:6:7
  |
6 |     22;
  |       ^

error: aborting due to 2 previous errors

@Mark-Simulacrum
Copy link
Member

Closing as per the previous comment; this is now fixed.

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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants