diff options
Diffstat (limited to 'tests/ui/parser/issues/issue-87217-keyword-order')
10 files changed, 134 insertions, 0 deletions
diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.rs b/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.rs new file mode 100644 index 000000000..df0cd5439 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.rs @@ -0,0 +1,9 @@ +// edition:2018 + +// Test that even when `const` is already present, the proposed fix is to remove the second `const` + +const async const fn test() {} +//~^ ERROR expected one of `extern`, `fn`, or `unsafe`, found keyword `const` +//~| NOTE expected one of `extern`, `fn`, or `unsafe` +//~| HELP `const` already used earlier, remove this one +//~| NOTE `const` first seen here diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.stderr new file mode 100644 index 000000000..977c6ebfe --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/const-async-const.stderr @@ -0,0 +1,17 @@ +error: expected one of `extern`, `fn`, or `unsafe`, found keyword `const` + --> $DIR/const-async-const.rs:5:13 + | +LL | const async const fn test() {} + | ^^^^^ + | | + | expected one of `extern`, `fn`, or `unsafe` + | help: `const` already used earlier, remove this one + | +note: `const` first seen here + --> $DIR/const-async-const.rs:5:1 + | +LL | const async const fn test() {} + | ^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.rs b/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.rs new file mode 100644 index 000000000..bbebc99e9 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.rs @@ -0,0 +1,14 @@ +// edition:2018 + +// There is an order to respect for keywords before a function: +// `<visibility>, const, async, unsafe, extern, "<ABI>"` +// +// This test ensures the compiler is helpful about them being misplaced. +// Visibilities are tested elsewhere. + +async unsafe const fn test() {} +//~^ ERROR expected one of `extern` or `fn`, found keyword `const` +//~| NOTE expected one of `extern` or `fn` +//~| HELP `const` must come before `async unsafe` +//~| SUGGESTION const async unsafe +//~| NOTE keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.stderr new file mode 100644 index 000000000..f455caba1 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/several-kw-jump.stderr @@ -0,0 +1,13 @@ +error: expected one of `extern` or `fn`, found keyword `const` + --> $DIR/several-kw-jump.rs:9:14 + | +LL | async unsafe const fn test() {} + | -------------^^^^^ + | | | + | | expected one of `extern` or `fn` + | help: `const` must come before `async unsafe`: `const async unsafe` + | + = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.rs b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.rs new file mode 100644 index 000000000..4ff4cf5c8 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.rs @@ -0,0 +1,14 @@ +// edition:2018 + +// There is an order to respect for keywords before a function: +// `<visibility>, const, async, unsafe, extern, "<ABI>"` +// +// This test ensures the compiler is helpful about them being misplaced. +// Visibilities are tested elsewhere. + +unsafe async fn test() {} +//~^ ERROR expected one of `extern` or `fn`, found keyword `async` +//~| NOTE expected one of `extern` or `fn` +//~| HELP `async` must come before `unsafe` +//~| SUGGESTION async unsafe +//~| NOTE keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.stderr new file mode 100644 index 000000000..e9eb14bf0 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-async.stderr @@ -0,0 +1,13 @@ +error: expected one of `extern` or `fn`, found keyword `async` + --> $DIR/wrong-async.rs:9:8 + | +LL | unsafe async fn test() {} + | -------^^^^^ + | | | + | | 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: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.rs b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.rs new file mode 100644 index 000000000..2f5fbc513 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.rs @@ -0,0 +1,14 @@ +// edition:2018 + +// There is an order to respect for keywords before a function: +// `<visibility>, const, async, unsafe, extern, "<ABI>"` +// +// This test ensures the compiler is helpful about them being misplaced. +// Visibilities are tested elsewhere. + +unsafe const fn test() {} +//~^ ERROR expected one of `extern` or `fn`, found keyword `const` +//~| NOTE expected one of `extern` or `fn` +//~| HELP `const` must come before `unsafe` +//~| SUGGESTION const unsafe +//~| NOTE keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.stderr new file mode 100644 index 000000000..0d2bc3472 --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-const.stderr @@ -0,0 +1,13 @@ +error: expected one of `extern` or `fn`, found keyword `const` + --> $DIR/wrong-const.rs:9:8 + | +LL | unsafe const fn test() {} + | -------^^^^^ + | | | + | | 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: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs new file mode 100644 index 000000000..df2412e3e --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs @@ -0,0 +1,14 @@ +// edition:2018 + +// There is an order to respect for keywords before a function: +// `<visibility>, const, async, unsafe, extern, "<ABI>"` +// +// This test ensures the compiler is helpful about them being misplaced. +// Visibilities are tested elsewhere. + +extern unsafe fn test() {} +//~^ ERROR expected `fn`, found keyword `unsafe` +//~| NOTE expected `fn` +//~| HELP `unsafe` must come before `extern` +//~| SUGGESTION unsafe extern +//~| NOTE keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr new file mode 100644 index 000000000..4224713cc --- /dev/null +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr @@ -0,0 +1,13 @@ +error: expected `fn`, found keyword `unsafe` + --> $DIR/wrong-unsafe.rs:9:8 + | +LL | extern unsafe fn test() {} + | -------^^^^^^ + | | | + | | expected `fn` + | help: `unsafe` must come before `extern`: `unsafe extern` + | + = note: keyword order for functions declaration is `pub`, `default`, `const`, `async`, `unsafe`, `extern` + +error: aborting due to previous error + |