// 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); }
// 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); }
// 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() { }
--- /dev/null
+// Copyright 2013 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 foo() -> ! { fail!("quux"); }
+fn main() {
+ foo() //~ ERROR the type of this value must be known in this context
+ ==
+ foo();
+}
// 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
}
// 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
}
// 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
}
// 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
+ ;
+ }
}
// 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
+ ;
}
// 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
+ ;
}
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)
}
--- /dev/null
+// Copyright 2013 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() {
+ &fail!()
+ //~^ ERROR mismatched types: expected `()`, found `&<generic #2>` (expected (), found &-ptr)
+}
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() }
// 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
}
// 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); }
loop {
break;
}
- return 42i; //~ ERROR expected `!`, found `int`
+ return 42i; //~ ERROR `return` in a function declared as diverging
}
fn main() {
}
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();
}
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
+++ /dev/null
-// Copyright 2013 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.
-
-// error-pattern:quux
-fn foo() -> ! { fail!("quux"); }
-fn main() { foo() == foo(); }
+++ /dev/null
-// Copyright 2013 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.
-
-// error-pattern:explicit failure
-
-fn main() {
- &fail!()
-}
unsafe { libc::exit(0 as libc::c_int); }
});
2u + (loop {});
- -(loop {});
}
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; }