diff options
| author | Jakub Wieczorek <jakub@jakub.cc> | 2014-10-13 22:26:23 +0200 |
|---|---|---|
| committer | Jakub Wieczorek <jakub@jakub.cc> | 2014-10-13 22:48:29 +0200 |
| commit | 43e5d10428dd2b74e8afe367c46bb0f2b6c37246 (patch) | |
| tree | 79ed633bef6682933311064290f7346a711d7c3e /src/test | |
| parent | 4a382d7c4743775e9ee87735ed606b0a673d8ed5 (diff) | |
| download | rust-43e5d10428dd2b74e8afe367c46bb0f2b6c37246.tar.gz rust-43e5d10428dd2b74e8afe367c46bb0f2b6c37246.zip | |
Improve the error message for missing else clauses in if expressions
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/if-without-else-result.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-4201.rs | 18 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/test/compile-fail/if-without-else-result.rs b/src/test/compile-fail/if-without-else-result.rs index c22a8e3f782..0754d273a9b 100644 --- a/src/test/compile-fail/if-without-else-result.rs +++ b/src/test/compile-fail/if-without-else-result.rs @@ -8,11 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:mismatched types: expected `()`, found `bool` - extern crate debug; fn main() { let a = if true { true }; +//~^ ERROR if may be missing an else clause: expected `()`, found `bool` (expected (), found bool) println!("{:?}", a); } diff --git a/src/test/compile-fail/issue-4201.rs b/src/test/compile-fail/issue-4201.rs new file mode 100644 index 00000000000..4b2be9e58ac --- /dev/null +++ b/src/test/compile-fail/issue-4201.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let a = if true { + 0 + } else if false { +//~^ ERROR if may be missing an else clause: expected `()`, found `<generic integer #1>` + 1 + }; +} |
