Skip to content

Commit

Permalink
Update tests with the new error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Bukaj committed Oct 28, 2014
1 parent cca84e9 commit 7f523e7
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 33 deletions.
3 changes: 1 addition & 2 deletions src/test/compile-fail/bad-bang-ann-3.rs
Expand Up @@ -11,8 +11,7 @@
// Tests that a function with a ! annotation always actually fails

fn bad_bang(i: uint) -> ! {
return 7u;
//~^ ERROR expected `!`, found `uint`
return 7u; //~ ERROR `return` in a function declared as diverging [E0166]
}

fn main() { bad_bang(5u); }
3 changes: 1 addition & 2 deletions src/test/compile-fail/bad-bang-ann.rs
Expand Up @@ -10,9 +10,8 @@

// Tests that a function with a ! annotation always actually fails

fn bad_bang(i: uint) -> ! {
fn bad_bang(i: uint) -> ! { //~ ERROR computation may converge in a function marked as diverging
if i < 0u { } else { fail!(); }
//~^ ERROR expected `!`, found `()`
}

fn main() { bad_bang(5u); }
4 changes: 2 additions & 2 deletions src/test/compile-fail/bang-tailexpr.rs
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn f() -> ! {
3i //~ ERROR expected `!`, found `int`
fn f() -> ! { //~ ERROR computation may converge in a function marked as diverging
3i
}
fn main() { }
Expand Up @@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:quux
fn foo() -> ! { fail!("quux"); }
fn main() { foo() == foo(); }
fn main() {
foo() //~ ERROR the type of this value must be known in this context
==
foo();
}
6 changes: 3 additions & 3 deletions src/test/compile-fail/closure-that-fails.rs
Expand Up @@ -14,7 +14,7 @@ fn main() {
// Type inference didn't use to be able to handle this:
foo(|| fail!());
foo(|| -> ! fail!());
foo(|| 22); //~ ERROR mismatched types
foo(|| -> ! 22); //~ ERROR mismatched types
let x = || -> ! 1; //~ ERROR mismatched types
foo(|| 22i); //~ ERROR computation may converge in a function marked as diverging
foo(|| -> ! 22i); //~ ERROR computation may converge in a function marked as diverging
let x = || -> ! 1i; //~ ERROR computation may converge in a function marked as diverging
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/index-bot.rs
Expand Up @@ -9,5 +9,5 @@
// except according to those terms.

fn main() {
(return)[0u]; //~ ERROR cannot index a value of type `!`
(return)[0u]; //~ ERROR the type of this value must be known in this context
}
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-13847.rs
Expand Up @@ -9,5 +9,5 @@
// except according to those terms.

fn main() {
return.is_failure //~ ERROR unconstrained type variable
return.is_failure //~ ERROR the type of this value must be known in this context
}
6 changes: 5 additions & 1 deletion src/test/compile-fail/issue-15207.rs
Expand Up @@ -9,5 +9,9 @@
// except according to those terms.

fn main() {
loop { break.push(1); } //~ ERROR type `!` does not implement any method in scope named `push`
loop {
break.push(1) //~ ERROR the type of this value must be known in this context
//~^ ERROR multiple applicable methods in scope
;
}
}
7 changes: 6 additions & 1 deletion src/test/compile-fail/issue-15965.rs
Expand Up @@ -9,5 +9,10 @@
// except according to those terms.

fn main() {
return { return () } (); //~ ERROR expected function, found `!`
return
{ return () } //~ ERROR the type of this value must be known in this context
() //~^ ERROR the type of this value must be known in this context
//~^^ ERROR notation; the first type parameter for the function trait is neither a tuple nor unit
//~^^^ ERROR overloaded calls are experimental
;
}
3 changes: 2 additions & 1 deletion src/test/compile-fail/issue-17373.rs
Expand Up @@ -9,5 +9,6 @@
// except according to those terms.

fn main() {
*return; //~ ERROR type `!` cannot be dereferenced
*return //~ ERROR the type of this value must be known in this context
;
}
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-5100.rs
Expand Up @@ -27,13 +27,13 @@ fn main() {

match (true, false) {
box (true, false) => ()
//~^ ERROR mismatched types: expected `(bool,bool)`, found `Box<<generic #11>>`
//~^ ERROR mismatched types: expected `(bool,bool)`, found `Box<<generic #15>>`
// (expected tuple, found box)
}

match (true, false) {
&(true, false) => ()
//~^ ERROR mismatched types: expected `(bool,bool)`, found `&<generic #15>`
//~^ ERROR mismatched types: expected `(bool,bool)`, found `&<generic #21>`
// (expected tuple, found &-ptr)
}

Expand Down
Expand Up @@ -8,8 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:explicit failure

fn main() {
&fail!()
//~^ ERROR mismatched types: expected `()`, found `&<generic #2>` (expected (), found &-ptr)
}
8 changes: 6 additions & 2 deletions src/test/compile-fail/issue-897-2.rs
Expand Up @@ -12,8 +12,12 @@

fn g() -> ! { fail!(); }
fn f() -> ! {
return g();
g(); //~ ERROR: unreachable statement
return g(); //~ ERROR `return` in a function declared as diverging
g();
}
fn h() -> ! {
loop {}
g();
}

fn main() { f() }
4 changes: 1 addition & 3 deletions src/test/compile-fail/issue-897.rs
Expand Up @@ -8,12 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern: unreachable statement

#![deny(unreachable_code)]

fn f() -> ! {
return fail!();
return fail!(); //~ ERROR `return` in a function declared as diverging
fail!(); // the unreachable statement error is in <std macro>, at this line, there
// only is a note
}
Expand Down
5 changes: 3 additions & 2 deletions src/test/compile-fail/liveness-bad-bang-2.rs
Expand Up @@ -9,8 +9,9 @@
// except according to those terms.

// Tests that a function with a ! annotation always actually fails
// error-pattern: some control paths may return

fn bad_bang(i: uint) -> ! { println!("{}", 3i); }
fn bad_bang(i: uint) -> ! { //~ ERROR computation may converge in a function marked as diverging
println!("{}", 3i);
}

fn main() { bad_bang(5u); }
2 changes: 1 addition & 1 deletion src/test/compile-fail/loop-does-not-diverge.rs
Expand Up @@ -14,7 +14,7 @@ fn forever() -> ! {
loop {
break;
}
return 42i; //~ ERROR expected `!`, found `int`
return 42i; //~ ERROR `return` in a function declared as diverging
}

fn main() {
Expand Down
6 changes: 4 additions & 2 deletions src/test/compile-fail/lub-match.rs
Expand Up @@ -33,7 +33,8 @@ pub fn opt_str1<'a>(maybestr: &'a Option<String>) -> &'a str {
}

pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
match *maybestr { //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to
match *maybestr {
//~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements
None => "(none)",
Some(ref s) => {
let s: &'a str = s.as_slice();
Expand All @@ -43,7 +44,8 @@ pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
}

pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
match *maybestr { //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to
match *maybestr {
//~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements
Some(ref s) => {
let s: &'a str = s.as_slice();
s
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issue-13352.rs
Expand Up @@ -17,5 +17,4 @@ fn main() {
unsafe { libc::exit(0 as libc::c_int); }
});
2u + (loop {});
-(loop {});
}
2 changes: 0 additions & 2 deletions src/test/run-pass/unreachable-code.rs
Expand Up @@ -23,8 +23,6 @@ fn call_id_2() { id(true) && id(return); }

fn call_id_3() { id(return) && id(return); }

fn ret_ret() -> int { return (return 2i) + 3i; }

fn ret_guard() {
match 2i {
x if (return) => { x; }
Expand Down

0 comments on commit 7f523e7

Please sign in to comment.