-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"cycle detected" with "const async" fn #102796
Comments
Fixed, needs a test: https://godbolt.org/z/64TxYTTnd |
how would i be able to add a test? on the godbolt it still fails and seems to have the same output as the issue. @rustbot claim |
the dev guide has information on how to add a test. The think we are testing for here is that when a const async function is declaired inside another function, the compiller has a parser error, but not a cycle detected error. That's the difference between the two outputs. |
the stderr from this example in the rest test suite: error: expected one of `:`, `;`, `<`, `=`, or `where`, found keyword `fn`
--> $DIR/const-async-fn-in-main.rs:4:17
|
LL | const async fn a() {}
| ^^ expected one of `:`, `;`, `<`, `=`, or `where`
error: missing type for `const` item
--> $DIR/const-async-fn-in-main.rs:4:16
|
LL | const async fn a() {}
| ^ help: provide a type for the item: `: <type>`
error: aborting due to 2 previous errors the code: // Check what happens when a const async fn is in the main function (#102796)
fn main() {
const async fn a() {}
}
the comand: x test tests/ui/const-async/const-async-fn-in-main.rs --stage 1 --bless |
I think you need to set the edition to 2018 or later, otherwise async isn't a keyword. If I remember correctly you need |
error: functions cannot be both `const` and `async`
--> $DIR/const-async-fn-in-main.rs:5:5
|
LL | const async fn a() {};
| ^^^^^-^^^^^----------
| | |
| | `async` because of this
| `const` because of this
error: aborting due to previous error error now looks like this. will pr. |
…-async-function-in-main, r=wesleywiser Add test for `const async fn` This adds a test for rust-lang#102796
Rollup merge of rust-lang#116178 - Milo123459:milo/add-test-for-const-async-function-in-main, r=wesleywiser Add test for `const async fn` This adds a test for rust-lang#102796
this can be closed now, my pr has been merged |
thanks! |
Seems a bit surprising that we don't bail out immediately when jumping from a function to itself? 🤔
The text was updated successfully, but these errors were encountered: