about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/explicit-tail-calls/become-outside.array.stderr9
-rw-r--r--tests/ui/explicit-tail-calls/become-outside.constant.stderr9
-rw-r--r--tests/ui/explicit-tail-calls/become-outside.rs15
-rw-r--r--tests/ui/explicit-tail-calls/return-lifetime-sub.rs13
-rw-r--r--tests/ui/explicit-tail-calls/return-mismatches.rs28
-rw-r--r--tests/ui/explicit-tail-calls/return-mismatches.stderr27
-rw-r--r--tests/ui/issues/issue-51714.rs10
-rw-r--r--tests/ui/issues/issue-51714.stderr6
-rw-r--r--tests/ui/return/issue-64620.rs2
-rw-r--r--tests/ui/return/issue-64620.stderr2
-rw-r--r--tests/ui/return/issue-86188-return-not-in-fn-body.rs12
-rw-r--r--tests/ui/return/tail-expr-as-potential-return.rs4
-rw-r--r--tests/ui/typeck/issue-86721-return-expr-ice.rs2
13 files changed, 120 insertions, 19 deletions
diff --git a/tests/ui/explicit-tail-calls/become-outside.array.stderr b/tests/ui/explicit-tail-calls/become-outside.array.stderr
new file mode 100644
index 00000000000..839c20509fe
--- /dev/null
+++ b/tests/ui/explicit-tail-calls/become-outside.array.stderr
@@ -0,0 +1,9 @@
+error[E0572]: become statement outside of function body
+  --> $DIR/become-outside.rs:11:17
+   |
+LL | struct Bad([(); become f()]);
+   |                 ^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0572`.
diff --git a/tests/ui/explicit-tail-calls/become-outside.constant.stderr b/tests/ui/explicit-tail-calls/become-outside.constant.stderr
new file mode 100644
index 00000000000..9b67f08af3a
--- /dev/null
+++ b/tests/ui/explicit-tail-calls/become-outside.constant.stderr
@@ -0,0 +1,9 @@
+error[E0572]: become statement outside of function body
+  --> $DIR/become-outside.rs:7:5
+   |
+LL |     become f();
+   |     ^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0572`.
diff --git a/tests/ui/explicit-tail-calls/become-outside.rs b/tests/ui/explicit-tail-calls/become-outside.rs
new file mode 100644
index 00000000000..51b4389c88f
--- /dev/null
+++ b/tests/ui/explicit-tail-calls/become-outside.rs
@@ -0,0 +1,15 @@
+// revisions: constant array
+#![allow(incomplete_features)]
+#![feature(explicit_tail_calls)]
+
+#[cfg(constant)]
+const _: () = {
+    become f(); //[constant]~ error: become statement outside of function body
+};
+
+#[cfg(array)]
+struct Bad([(); become f()]); //[array]~ error: become statement outside of function body
+
+fn f() {}
+
+fn main() {}
diff --git a/tests/ui/explicit-tail-calls/return-lifetime-sub.rs b/tests/ui/explicit-tail-calls/return-lifetime-sub.rs
new file mode 100644
index 00000000000..8a3f43d4b92
--- /dev/null
+++ b/tests/ui/explicit-tail-calls/return-lifetime-sub.rs
@@ -0,0 +1,13 @@
+// check-pass
+#![allow(incomplete_features)]
+#![feature(explicit_tail_calls)]
+
+fn _f<'a>() -> &'a [u8] {
+    become _g();
+}
+
+fn _g() -> &'static [u8] {
+    &[0, 1, 2, 3]
+}
+
+fn main() {}
diff --git a/tests/ui/explicit-tail-calls/return-mismatches.rs b/tests/ui/explicit-tail-calls/return-mismatches.rs
new file mode 100644
index 00000000000..935a1a1d28b
--- /dev/null
+++ b/tests/ui/explicit-tail-calls/return-mismatches.rs
@@ -0,0 +1,28 @@
+#![allow(incomplete_features)]
+#![feature(explicit_tail_calls)]
+
+fn _f0<'a>() -> &'static [u8] {
+    become _g0(); //~ error: mismatched types
+}
+
+fn _g0() -> &'static [u8; 1] {
+    &[0]
+}
+
+fn _f1() {
+    become _g1(); //~ error: mismatched types
+}
+
+fn _g1() -> ! {
+    become _g1();
+}
+
+fn _f2() -> u32 {
+    become _g2(); //~ error: mismatched types
+}
+
+fn _g2() -> u16 {
+    0
+}
+
+fn main() {}
diff --git a/tests/ui/explicit-tail-calls/return-mismatches.stderr b/tests/ui/explicit-tail-calls/return-mismatches.stderr
new file mode 100644
index 00000000000..1dcc35797c1
--- /dev/null
+++ b/tests/ui/explicit-tail-calls/return-mismatches.stderr
@@ -0,0 +1,27 @@
+error[E0308]: mismatched types
+  --> $DIR/return-mismatches.rs:5:5
+   |
+LL |     become _g0();
+   |     ^^^^^^^^^^^^ expected `&[u8]`, found `&[u8; 1]`
+   |
+   = note: expected reference `&'static [u8]`
+              found reference `&'static [u8; 1]`
+
+error[E0308]: mismatched types
+  --> $DIR/return-mismatches.rs:13:5
+   |
+LL |     become _g1();
+   |     ^^^^^^^^^^^^ expected `()`, found `!`
+   |
+   = note: expected unit type `()`
+                   found type `!`
+
+error[E0308]: mismatched types
+  --> $DIR/return-mismatches.rs:21:5
+   |
+LL |     become _g2();
+   |     ^^^^^^^^^^^^ expected `u32`, found `u16`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/issues/issue-51714.rs b/tests/ui/issues/issue-51714.rs
index 8716524d6f4..03b50b7963e 100644
--- a/tests/ui/issues/issue-51714.rs
+++ b/tests/ui/issues/issue-51714.rs
@@ -1,9 +1,9 @@
 fn main() {
-//~^ NOTE: not the enclosing function body
-//~| NOTE: not the enclosing function body
-//~| NOTE: not the enclosing function body
-//~| NOTE: not the enclosing function body
-    |_:  [_; return || {}] | {};
+    //~^ NOTE: not the enclosing function body
+    //~| NOTE: not the enclosing function body
+    //~| NOTE: not the enclosing function body
+    //~| NOTE: not the enclosing function body
+    |_: [_; return || {}]| {};
     //~^ ERROR: return statement outside of function body [E0572]
     //~| NOTE: the return is part of this body...
 
diff --git a/tests/ui/issues/issue-51714.stderr b/tests/ui/issues/issue-51714.stderr
index 514d69c1c7d..e53e10afcaf 100644
--- a/tests/ui/issues/issue-51714.stderr
+++ b/tests/ui/issues/issue-51714.stderr
@@ -1,13 +1,13 @@
 error[E0572]: return statement outside of function body
-  --> $DIR/issue-51714.rs:6:14
+  --> $DIR/issue-51714.rs:6:13
    |
 LL | / fn main() {
 LL | |
 LL | |
 LL | |
 LL | |
-LL | |     |_:  [_; return || {}] | {};
-   | |              ^^^^^^^^^^^^ the return is part of this body...
+LL | |     |_: [_; return || {}]| {};
+   | |             ^^^^^^^^^^^^ the return is part of this body...
 ...  |
 LL | |
 LL | | }
diff --git a/tests/ui/return/issue-64620.rs b/tests/ui/return/issue-64620.rs
index a62e5bf8d3c..ab293165195 100644
--- a/tests/ui/return/issue-64620.rs
+++ b/tests/ui/return/issue-64620.rs
@@ -1,5 +1,5 @@
 enum Bug {
-    V1 = return [0][0] //~ERROR return statement outside of function body
+    V1 = return [0][0], //~ERROR return statement outside of function body
 }
 
 fn main() {}
diff --git a/tests/ui/return/issue-64620.stderr b/tests/ui/return/issue-64620.stderr
index f40ac4de32d..3210a67d418 100644
--- a/tests/ui/return/issue-64620.stderr
+++ b/tests/ui/return/issue-64620.stderr
@@ -1,7 +1,7 @@
 error[E0572]: return statement outside of function body
   --> $DIR/issue-64620.rs:2:10
    |
-LL |     V1 = return [0][0]
+LL |     V1 = return [0][0],
    |          ^^^^^^^^^^^^^
 
 error: aborting due to previous error
diff --git a/tests/ui/return/issue-86188-return-not-in-fn-body.rs b/tests/ui/return/issue-86188-return-not-in-fn-body.rs
index 4f076fa0693..3117cf3fd91 100644
--- a/tests/ui/return/issue-86188-return-not-in-fn-body.rs
+++ b/tests/ui/return/issue-86188-return-not-in-fn-body.rs
@@ -7,7 +7,7 @@
 
 const C: [(); 42] = {
     [(); return || {
-    //~^ ERROR: return statement outside of function body [E0572]
+        //~^ ERROR: return statement outside of function body [E0572]
         let tx;
     }]
 };
@@ -16,7 +16,7 @@ struct S {}
 trait Tr {
     fn foo();
     fn bar() {
-    //~^ NOTE: ...not the enclosing function body
+        //~^ NOTE: ...not the enclosing function body
         [(); return];
         //~^ ERROR: return statement outside of function body [E0572]
         //~| NOTE: the return is part of this body...
@@ -24,7 +24,7 @@ trait Tr {
 }
 impl Tr for S {
     fn foo() {
-    //~^ NOTE: ...not the enclosing function body
+        //~^ NOTE: ...not the enclosing function body
         [(); return];
         //~^ ERROR: return statement outside of function body [E0572]
         //~| NOTE: the return is part of this body...
@@ -32,10 +32,10 @@ impl Tr for S {
 }
 
 fn main() {
-//~^ NOTE: ...not the enclosing function body
+    //~^ NOTE: ...not the enclosing function body
     [(); return || {
-    //~^ ERROR: return statement outside of function body [E0572]
-    //~| NOTE: the return is part of this body...
+        //~^ ERROR: return statement outside of function body [E0572]
+        //~| NOTE: the return is part of this body...
         let tx;
     }];
 }
diff --git a/tests/ui/return/tail-expr-as-potential-return.rs b/tests/ui/return/tail-expr-as-potential-return.rs
index f46e088b85f..2046d6680dd 100644
--- a/tests/ui/return/tail-expr-as-potential-return.rs
+++ b/tests/ui/return/tail-expr-as-potential-return.rs
@@ -1,8 +1,8 @@
-// > Suggest `return`ing tail expressions that match return type
+// > Suggest returning tail expressions that match return type
 // >
 // > Some newcomers are confused by the behavior of tail expressions,
 // > interpreting that "leaving out the `;` makes it the return value".
-// > To help them go in the right direction, suggest using `return` instead
+// > To help them go in the right direction, suggest using return instead
 // > when applicable.
 // (original commit description for this test)
 //
diff --git a/tests/ui/typeck/issue-86721-return-expr-ice.rs b/tests/ui/typeck/issue-86721-return-expr-ice.rs
index cd7135f18b1..4f882f7a3f1 100644
--- a/tests/ui/typeck/issue-86721-return-expr-ice.rs
+++ b/tests/ui/typeck/issue-86721-return-expr-ice.rs
@@ -2,7 +2,7 @@
 
 // revisions: rev1 rev2
 #![cfg_attr(any(), rev1, rev2)]
-#![crate_type="lib"]
+#![crate_type = "lib"]
 
 #[cfg(any(rev1))]
 trait T {