about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/ui/parser/bad-fn-ptr-qualifier.rs11
-rw-r--r--tests/ui/parser/bad-fn-ptr-qualifier.stderr77
-rw-r--r--tests/ui/parser/recover/recover-const-async-fn-ptr.rs11
-rw-r--r--tests/ui/parser/recover/recover-const-async-fn-ptr.stderr79
4 files changed, 175 insertions, 3 deletions
diff --git a/tests/ui/parser/bad-fn-ptr-qualifier.rs b/tests/ui/parser/bad-fn-ptr-qualifier.rs
index f2611c93b17..748852a76e1 100644
--- a/tests/ui/parser/bad-fn-ptr-qualifier.rs
+++ b/tests/ui/parser/bad-fn-ptr-qualifier.rs
@@ -23,4 +23,15 @@ pub type FTT6 = for<'a> const async unsafe extern "C" fn();
 //~^ ERROR an `fn` pointer type cannot be `const`
 //~| ERROR an `fn` pointer type cannot be `async`
 
+// Tests with qualifiers in the wrong order
+pub type W1 = unsafe const fn();
+//~^ ERROR an `fn` pointer type cannot be `const`
+//~| ERROR expected one of `extern` or `fn`, found keyword `const`
+pub type W2 = unsafe async fn();
+//~^ ERROR an `fn` pointer type cannot be `async`
+//~| ERROR expected one of `extern` or `fn`, found keyword `async`
+pub type W3 = for<'a> unsafe const fn();
+//~^ ERROR an `fn` pointer type cannot be `const`
+//~| ERROR expected one of `extern` or `fn`, found keyword `const`
+
 fn main() {}
diff --git a/tests/ui/parser/bad-fn-ptr-qualifier.stderr b/tests/ui/parser/bad-fn-ptr-qualifier.stderr
index b9d2625d9f4..a0bd3f974ab 100644
--- a/tests/ui/parser/bad-fn-ptr-qualifier.stderr
+++ b/tests/ui/parser/bad-fn-ptr-qualifier.stderr
@@ -222,5 +222,80 @@ LL - pub type FTT6 = for<'a> const async unsafe extern "C" fn();
 LL + pub type FTT6 = for<'a> const unsafe extern "C" fn();
    |
 
-error: aborting due to 16 previous errors
+error: expected one of `extern` or `fn`, found keyword `const`
+  --> $DIR/bad-fn-ptr-qualifier.rs:27:22
+   |
+LL | pub type W1 = unsafe const fn();
+   |               -------^^^^^
+   |               |      |
+   |               |      expected one of `extern` or `fn`
+   |               help: `const` must come before `unsafe`: `const unsafe`
+   |
+   = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`
+
+error: an `fn` pointer type cannot be `const`
+  --> $DIR/bad-fn-ptr-qualifier.rs:27:15
+   |
+LL | pub type W1 = unsafe const fn();
+   |               ^^^^^^^-----^^^^^
+   |                      |
+   |                      `const` because of this
+   |
+help: remove the `const` qualifier
+   |
+LL - pub type W1 = unsafe const fn();
+LL + pub type W1 = const fn();
+   |
+
+error: expected one of `extern` or `fn`, found keyword `async`
+  --> $DIR/bad-fn-ptr-qualifier.rs:30:22
+   |
+LL | pub type W2 = unsafe async fn();
+   |               -------^^^^^
+   |               |      |
+   |               |      expected one of `extern` or `fn`
+   |               help: `async` must come before `unsafe`: `async unsafe`
+   |
+   = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`
+
+error: an `fn` pointer type cannot be `async`
+  --> $DIR/bad-fn-ptr-qualifier.rs:30:15
+   |
+LL | pub type W2 = unsafe async fn();
+   |               ^^^^^^^-----^^^^^
+   |                      |
+   |                      `async` because of this
+   |
+help: remove the `async` qualifier
+   |
+LL - pub type W2 = unsafe async fn();
+LL + pub type W2 = async fn();
+   |
+
+error: expected one of `extern` or `fn`, found keyword `const`
+  --> $DIR/bad-fn-ptr-qualifier.rs:33:30
+   |
+LL | pub type W3 = for<'a> unsafe const fn();
+   |                       -------^^^^^
+   |                       |      |
+   |                       |      expected one of `extern` or `fn`
+   |                       help: `const` must come before `unsafe`: `const unsafe`
+   |
+   = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`
+
+error: an `fn` pointer type cannot be `const`
+  --> $DIR/bad-fn-ptr-qualifier.rs:33:15
+   |
+LL | pub type W3 = for<'a> unsafe const fn();
+   |               ^^^^^^^^^^^^^^^-----^^^^^
+   |                              |
+   |                              `const` because of this
+   |
+help: remove the `const` qualifier
+   |
+LL - pub type W3 = for<'a> unsafe const fn();
+LL + pub type W3 = for<'a> const fn();
+   |
+
+error: aborting due to 22 previous errors
 
diff --git a/tests/ui/parser/recover/recover-const-async-fn-ptr.rs b/tests/ui/parser/recover/recover-const-async-fn-ptr.rs
index 45d75349599..8e4c6e92412 100644
--- a/tests/ui/parser/recover/recover-const-async-fn-ptr.rs
+++ b/tests/ui/parser/recover/recover-const-async-fn-ptr.rs
@@ -20,6 +20,17 @@ type FT6 = for<'a> const async unsafe extern "C" fn();
 //~^ ERROR an `fn` pointer type cannot be `const`
 //~| ERROR an `fn` pointer type cannot be `async`
 
+// Tests with qualifiers in the wrong order
+type W1 = unsafe const fn();
+//~^ ERROR an `fn` pointer type cannot be `const`
+//~| ERROR expected one of `extern` or `fn`, found keyword `const`
+type W2 = unsafe async fn();
+//~^ ERROR an `fn` pointer type cannot be `async`
+//~| ERROR expected one of `extern` or `fn`, found keyword `async`
+type W3 = for<'a> unsafe const fn();
+//~^ ERROR an `fn` pointer type cannot be `const`
+//~| ERROR expected one of `extern` or `fn`, found keyword `const`
+
 fn main() {
     let _recovery_witness: () = 0; //~ ERROR mismatched types
 }
diff --git a/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr b/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr
index 4e5927914cc..82b9162cfdc 100644
--- a/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr
+++ b/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr
@@ -222,14 +222,89 @@ LL - type FT6 = for<'a> const async unsafe extern "C" fn();
 LL + type FT6 = for<'a> const unsafe extern "C" fn();
    |
 
+error: expected one of `extern` or `fn`, found keyword `const`
+  --> $DIR/recover-const-async-fn-ptr.rs:24:18
+   |
+LL | type W1 = unsafe const fn();
+   |           -------^^^^^
+   |           |      |
+   |           |      expected one of `extern` or `fn`
+   |           help: `const` must come before `unsafe`: `const unsafe`
+   |
+   = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`
+
+error: an `fn` pointer type cannot be `const`
+  --> $DIR/recover-const-async-fn-ptr.rs:24:11
+   |
+LL | type W1 = unsafe const fn();
+   |           ^^^^^^^-----^^^^^
+   |                  |
+   |                  `const` because of this
+   |
+help: remove the `const` qualifier
+   |
+LL - type W1 = unsafe const fn();
+LL + type W1 = const fn();
+   |
+
+error: expected one of `extern` or `fn`, found keyword `async`
+  --> $DIR/recover-const-async-fn-ptr.rs:27:18
+   |
+LL | type W2 = unsafe async fn();
+   |           -------^^^^^
+   |           |      |
+   |           |      expected one of `extern` or `fn`
+   |           help: `async` must come before `unsafe`: `async unsafe`
+   |
+   = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`
+
+error: an `fn` pointer type cannot be `async`
+  --> $DIR/recover-const-async-fn-ptr.rs:27:11
+   |
+LL | type W2 = unsafe async fn();
+   |           ^^^^^^^-----^^^^^
+   |                  |
+   |                  `async` because of this
+   |
+help: remove the `async` qualifier
+   |
+LL - type W2 = unsafe async fn();
+LL + type W2 = async fn();
+   |
+
+error: expected one of `extern` or `fn`, found keyword `const`
+  --> $DIR/recover-const-async-fn-ptr.rs:30:26
+   |
+LL | type W3 = for<'a> unsafe const fn();
+   |                   -------^^^^^
+   |                   |      |
+   |                   |      expected one of `extern` or `fn`
+   |                   help: `const` must come before `unsafe`: `const unsafe`
+   |
+   = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern`
+
+error: an `fn` pointer type cannot be `const`
+  --> $DIR/recover-const-async-fn-ptr.rs:30:11
+   |
+LL | type W3 = for<'a> unsafe const fn();
+   |           ^^^^^^^^^^^^^^^-----^^^^^
+   |                          |
+   |                          `const` because of this
+   |
+help: remove the `const` qualifier
+   |
+LL - type W3 = for<'a> unsafe const fn();
+LL + type W3 = for<'a> const fn();
+   |
+
 error[E0308]: mismatched types
-  --> $DIR/recover-const-async-fn-ptr.rs:24:33
+  --> $DIR/recover-const-async-fn-ptr.rs:35:33
    |
 LL |     let _recovery_witness: () = 0;
    |                            --   ^ expected `()`, found integer
    |                            |
    |                            expected due to this
 
-error: aborting due to 17 previous errors
+error: aborting due to 23 previous errors
 
 For more information about this error, try `rustc --explain E0308`.