Skip to content
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

async fn inside inherent impl produces generic parse error on 2015 edition #53714

Closed
comex opened this issue Aug 26, 2018 · 1 comment · Fixed by #58678
Closed

async fn inside inherent impl produces generic parse error on 2015 edition #53714

comex opened this issue Aug 26, 2018 · 1 comment · Fixed by #58678
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@comex
Copy link
Contributor

comex commented Aug 26, 2018

When compiling for the 2018 edition, rustc allows async fn both outside of an impl and within an inherent impl.

When compiling for the 2015 edition, async fn works outside of an impl, but putting one inside an inherent impl produces this error:

error: missing `fn`, `type`, or `const` for impl-item declaration
 --> src/lib.rs:4:9
  |
4 | impl A { async fn inside_impl() {} }
  |         ^ missing `fn`, `type`, or `const`

Either this should be allowed, or it should result in a better error message that recommends switching to the 2018 edition.

@withoutboats
Copy link
Contributor

Since async blocks and some versions of the final await syntax cannot be permitted (for backward compatibility reasons), it seems preferable to disallow all async/await features on 2015 to simplifier the user story: async/await works on 2018.

@jonas-schievink jonas-schievink added the A-async-await Area: Async & Await label Jan 27, 2019
@withoutboats withoutboats added the A-diagnostics Area: Messages for errors, warnings, and lints label Feb 22, 2019
Centril added a commit to Centril/rust that referenced this issue Feb 27, 2019
…n, r=varkor

Deny `async fn` in 2015 edition

This commit prevents code using `async fn` from being compiled in Rust 2015 edition.

Compiling code of the form:

```rust
async fn foo() {}
```

Will now result in the error:

```
error[E0670]: `async fn` is not permitted in the 2015 edition
 --> async.rs:1:1
  |
1 | async fn foo() {}
  | ^^^^^

error: aborting due to error

For more information about an error, try `rustc --explain E0670`.
```

This resolves rust-lang#58652 and also resolves rust-lang#53714.

r? @varkor
Centril added a commit to Centril/rust that referenced this issue Feb 27, 2019
…n, r=varkor

Deny `async fn` in 2015 edition

This commit prevents code using `async fn` from being compiled in Rust 2015 edition.

Compiling code of the form:

```rust
async fn foo() {}
```

Will now result in the error:

```
error[E0670]: `async fn` is not permitted in the 2015 edition
 --> async.rs:1:1
  |
1 | async fn foo() {}
  | ^^^^^

error: aborting due to error

For more information about an error, try `rustc --explain E0670`.
```

This resolves rust-lang#58652 and also resolves rust-lang#53714.

r? @varkor
Centril added a commit to Centril/rust that referenced this issue Feb 27, 2019
…n, r=varkor

Deny `async fn` in 2015 edition

This commit prevents code using `async fn` from being compiled in Rust 2015 edition.

Compiling code of the form:

```rust
async fn foo() {}
```

Will now result in the error:

```
error[E0670]: `async fn` is not permitted in the 2015 edition
 --> async.rs:1:1
  |
1 | async fn foo() {}
  | ^^^^^

error: aborting due to error

For more information about an error, try `rustc --explain E0670`.
```

This resolves rust-lang#58652 and also resolves rust-lang#53714.

r? @varkor
Centril added a commit to Centril/rust that referenced this issue Feb 27, 2019
…n, r=varkor

Deny `async fn` in 2015 edition

This commit prevents code using `async fn` from being compiled in Rust 2015 edition.

Compiling code of the form:

```rust
async fn foo() {}
```

Will now result in the error:

```
error[E0670]: `async fn` is not permitted in the 2015 edition
 --> async.rs:1:1
  |
1 | async fn foo() {}
  | ^^^^^

error: aborting due to error

For more information about an error, try `rustc --explain E0670`.
```

This resolves rust-lang#58652 and also resolves rust-lang#53714.

r? @varkor
Centril added a commit to Centril/rust that referenced this issue Feb 27, 2019
…n, r=varkor

Deny `async fn` in 2015 edition

This commit prevents code using `async fn` from being compiled in Rust 2015 edition.

Compiling code of the form:

```rust
async fn foo() {}
```

Will now result in the error:

```
error[E0670]: `async fn` is not permitted in the 2015 edition
 --> async.rs:1:1
  |
1 | async fn foo() {}
  | ^^^^^

error: aborting due to error

For more information about an error, try `rustc --explain E0670`.
```

This resolves rust-lang#58652 and also resolves rust-lang#53714.

r? @varkor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants