summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-01-30 08:31:31 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-02-13 10:39:24 +0100
commit36a17e4067d2e67223cd9a172476ee5503d6b44b (patch)
tree27715b8214a734d40f705a0e9f48a0d50d8b6a62 /src/test/ui/parser
parentc30f068dc8b2ef58678b9846ba834dd6dea3fe44 (diff)
downloadrust-36a17e4067d2e67223cd9a172476ee5503d6b44b.tar.gz
rust-36a17e4067d2e67223cd9a172476ee5503d6b44b.zip
parser_fn_front_matter: allow `const .. extern`
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/fn-header-semantic-fail.rs15
-rw-r--r--src/test/ui/parser/fn-header-semantic-fail.stderr68
-rw-r--r--src/test/ui/parser/fn-header-syntactic-pass.rs12
3 files changed, 50 insertions, 45 deletions
diff --git a/src/test/ui/parser/fn-header-semantic-fail.rs b/src/test/ui/parser/fn-header-semantic-fail.rs
index c2b7e69c80d..98ff2b6d2e8 100644
--- a/src/test/ui/parser/fn-header-semantic-fail.rs
+++ b/src/test/ui/parser/fn-header-semantic-fail.rs
@@ -18,9 +18,9 @@ fn main() {
         unsafe fn ft2(); // OK.
         const fn ft3(); //~ ERROR trait fns cannot be declared const
         extern "C" fn ft4(); // OK.
-        /* const */ async unsafe extern "C" fn ft5();
+        const async unsafe extern "C" fn ft5();
         //~^ ERROR trait fns cannot be declared `async`
-        //^ FIXME(Centril): `const` should be legal syntactically, ensure it's illegal semantically.
+        //~| ERROR trait fns cannot be declared const
     }
 
     struct Y;
@@ -30,10 +30,10 @@ fn main() {
         unsafe fn ft2() {} // OK.
         const fn ft3() {} //~ ERROR trait fns cannot be declared const
         extern "C" fn ft4() {}
-        /* const */ async unsafe extern "C" fn ft5() {}
+        const async unsafe extern "C" fn ft5() {}
         //~^ ERROR trait fns cannot be declared `async`
+        //~| ERROR trait fns cannot be declared const
         //~| ERROR method `ft5` has an incompatible type for trait
-        //^ FIXME(Centril): `const` should be legal syntactically, ensure it's illegal semantically.
     }
 
     impl Y {
@@ -41,8 +41,7 @@ fn main() {
         unsafe fn fi2() {} // OK.
         const fn fi3() {} // OK.
         extern "C" fn fi4() {} // OK.
-        /* const */ async unsafe extern "C" fn fi5() {} // OK.
-        //^ FIXME(Centril): `const` should be legal syntactically, ensure it's illegal semantically.
+        const async unsafe extern "C" fn fi5() {} // OK.
     }
 
     extern {
@@ -50,8 +49,6 @@ fn main() {
         unsafe fn fe2(); //~ ERROR functions in `extern` blocks cannot have qualifiers
         const fn fe3(); //~ ERROR functions in `extern` blocks cannot have qualifiers
         extern "C" fn fe4(); //~ ERROR functions in `extern` blocks cannot have qualifiers
-        /* const */ async unsafe extern "C" fn fe5();
-        //~^ ERROR functions in `extern` blocks cannot have qualifiers
-        //^ FIXME(Centril): `const` should be legal syntactically, ensure it's illegal semantically.
+        const async unsafe extern "C" fn fe5(); //~ ERROR functions in `extern` blocks
     }
 }
diff --git a/src/test/ui/parser/fn-header-semantic-fail.stderr b/src/test/ui/parser/fn-header-semantic-fail.stderr
index 689bbdd8bab..1860106b255 100644
--- a/src/test/ui/parser/fn-header-semantic-fail.stderr
+++ b/src/test/ui/parser/fn-header-semantic-fail.stderr
@@ -15,13 +15,19 @@ error[E0379]: trait fns cannot be declared const
 LL |         const fn ft3();
    |         ^^^^^ trait fns cannot be const
 
+error[E0379]: trait fns cannot be declared const
+  --> $DIR/fn-header-semantic-fail.rs:21:9
+   |
+LL |         const async unsafe extern "C" fn ft5();
+   |         ^^^^^ trait fns cannot be const
+
 error[E0706]: trait fns cannot be declared `async`
-  --> $DIR/fn-header-semantic-fail.rs:21:21
+  --> $DIR/fn-header-semantic-fail.rs:21:9
    |
-LL |         /* const */ async unsafe extern "C" fn ft5();
-   |                     -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |                     |
-   |                     `async` because of this
+LL |         const async unsafe extern "C" fn ft5();
+   |         ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |               |
+   |               `async` because of this
    |
    = note: `async` trait functions are not currently supported
    = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
@@ -43,19 +49,25 @@ error[E0379]: trait fns cannot be declared const
 LL |         const fn ft3() {}
    |         ^^^^^ trait fns cannot be const
 
+error[E0379]: trait fns cannot be declared const
+  --> $DIR/fn-header-semantic-fail.rs:33:9
+   |
+LL |         const async unsafe extern "C" fn ft5() {}
+   |         ^^^^^ trait fns cannot be const
+
 error[E0706]: trait fns cannot be declared `async`
-  --> $DIR/fn-header-semantic-fail.rs:33:21
+  --> $DIR/fn-header-semantic-fail.rs:33:9
    |
-LL |         /* const */ async unsafe extern "C" fn ft5() {}
-   |                     -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |                     |
-   |                     `async` because of this
+LL |         const async unsafe extern "C" fn ft5() {}
+   |         ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |               |
+   |               `async` because of this
    |
    = note: `async` trait functions are not currently supported
    = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
 
 error: functions in `extern` blocks cannot have qualifiers
-  --> $DIR/fn-header-semantic-fail.rs:49:18
+  --> $DIR/fn-header-semantic-fail.rs:48:18
    |
 LL |     extern {
    |     ------ in this `extern` block
@@ -65,7 +77,7 @@ LL |         async fn fe1();
    |         help: remove the qualifiers: `fn`
 
 error: functions in `extern` blocks cannot have qualifiers
-  --> $DIR/fn-header-semantic-fail.rs:50:19
+  --> $DIR/fn-header-semantic-fail.rs:49:19
    |
 LL |     extern {
    |     ------ in this `extern` block
@@ -76,7 +88,7 @@ LL |         unsafe fn fe2();
    |         help: remove the qualifiers: `fn`
 
 error: functions in `extern` blocks cannot have qualifiers
-  --> $DIR/fn-header-semantic-fail.rs:51:18
+  --> $DIR/fn-header-semantic-fail.rs:50:18
    |
 LL |     extern {
    |     ------ in this `extern` block
@@ -87,7 +99,7 @@ LL |         const fn fe3();
    |         help: remove the qualifiers: `fn`
 
 error: functions in `extern` blocks cannot have qualifiers
-  --> $DIR/fn-header-semantic-fail.rs:52:23
+  --> $DIR/fn-header-semantic-fail.rs:51:23
    |
 LL |     extern {
    |     ------ in this `extern` block
@@ -98,15 +110,15 @@ LL |         extern "C" fn fe4();
    |         help: remove the qualifiers: `fn`
 
 error: functions in `extern` blocks cannot have qualifiers
-  --> $DIR/fn-header-semantic-fail.rs:53:48
+  --> $DIR/fn-header-semantic-fail.rs:52:42
    |
 LL |     extern {
    |     ------ in this `extern` block
 ...
-LL |         /* const */ async unsafe extern "C" fn fe5();
-   |                     ---------------------------^^^
-   |                     |
-   |                     help: remove the qualifiers: `fn`
+LL |         const async unsafe extern "C" fn fe5();
+   |         ---------------------------------^^^
+   |         |
+   |         help: remove the qualifiers: `fn`
 
 error[E0053]: method `ft1` has an incompatible type for trait
   --> $DIR/fn-header-semantic-fail.rs:28:24
@@ -124,21 +136,21 @@ LL |         async fn ft1() {}
               found fn pointer `fn() -> impl std::future::Future`
 
 error[E0053]: method `ft5` has an incompatible type for trait
-  --> $DIR/fn-header-semantic-fail.rs:33:54
+  --> $DIR/fn-header-semantic-fail.rs:33:48
    |
-LL |         /* const */ async unsafe extern "C" fn ft5();
-   |                                                     - type in trait
+LL |         const async unsafe extern "C" fn ft5();
+   |                                               - type in trait
 ...
-LL |         /* const */ async unsafe extern "C" fn ft5() {}
-   |                                                      ^
-   |                                                      |
-   |                                                      the `Output` of this `async fn`'s found opaque type
-   |                                                      expected `()`, found opaque type
+LL |         const async unsafe extern "C" fn ft5() {}
+   |                                                ^
+   |                                                |
+   |                                                the `Output` of this `async fn`'s found opaque type
+   |                                                expected `()`, found opaque type
    |
    = note: expected fn pointer `unsafe extern "C" fn()`
               found fn pointer `unsafe extern "C" fn() -> impl std::future::Future`
 
-error: aborting due to 13 previous errors
+error: aborting due to 15 previous errors
 
 Some errors have detailed explanations: E0053, E0379, E0706.
 For more information about an error, try `rustc --explain E0053`.
diff --git a/src/test/ui/parser/fn-header-syntactic-pass.rs b/src/test/ui/parser/fn-header-syntactic-pass.rs
index 145a208cb24..0557b9ef6ca 100644
--- a/src/test/ui/parser/fn-header-syntactic-pass.rs
+++ b/src/test/ui/parser/fn-header-syntactic-pass.rs
@@ -22,8 +22,7 @@ fn syntax() {
         unsafe fn f();
         const fn f();
         extern "C" fn f();
-        /* const */ async unsafe extern "C" fn f();
-        //^ FIXME(Centril): `const` should be legal syntactically.
+        const async unsafe extern "C" fn f();
     }
 
     impl X for Y {
@@ -31,8 +30,7 @@ fn syntax() {
         unsafe fn f();
         const fn f();
         extern "C" fn f();
-        /* const */ async unsafe extern "C" fn f();
-        //^ FIXME(Centril): `const` should be legal syntactically.
+        const async unsafe extern "C" fn f();
     }
 
     impl Y {
@@ -40,8 +38,7 @@ fn syntax() {
         unsafe fn f();
         const fn f();
         extern "C" fn f();
-        /* const */ async unsafe extern "C" fn f();
-        //^ FIXME(Centril): `const` should be legal syntactically.
+        const async unsafe extern "C" fn f();
     }
 
     extern {
@@ -49,7 +46,6 @@ fn syntax() {
         unsafe fn f();
         const fn f();
         extern "C" fn f();
-        /* const */ async unsafe extern "C" fn f();
-        //^ FIXME(Centril): `const` should be legal syntactically.
+        const async unsafe extern "C" fn f();
     }
 }