-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
This is part of the Rust tutorial session. The whole purpose of the exercise was to find a mistake in the block expression.
See Exercise 2.1
http://pnkfelix.github.io/cyot/tutorial/exercises/ex_part_2
With rust compile this:
fn foo() -> i32 {
42
}
pub fn main() {
let the_sum :i32 = {
foo();
};
let the_other_sum = {
foo();
};
}
It outputs this error:
bug_block.rs:7:24: 9:6 error: mismatched types:
expected `i32`,
found `()`
(expected i32,
found ()) [E0308]
bug_block.rs:7 let the_sum :i32 = {
bug_block.rs:8 foo();
bug_block.rs:9 };
error: aborting due to previous error
It should also put a warning for line 12: "possibly missing return value". This would catch the bug.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.