提交 7f523e72 编写于 作者: J Jakub Bukaj

Update tests with the new error messages

上级 cca84e9e
......@@ -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); }
......@@ -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); }
......@@ -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() { }
......@@ -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();
}
......@@ -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
}
......@@ -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
}
......@@ -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
}
......@@ -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
;
}
}
......@@ -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
;
}
......@@ -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
;
}
......@@ -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)
}
......
......@@ -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)
}
......@@ -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() }
......@@ -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
}
......
......@@ -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); }
......@@ -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() {
......
......@@ -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();
......@@ -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
......
......@@ -17,5 +17,4 @@ fn main() {
unsafe { libc::exit(0 as libc::c_int); }
});
2u + (loop {});
-(loop {});
}
......@@ -23,8 +23,6 @@ fn call_id() {
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; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册