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
Closed

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

comex opened this issue Aug 26, 2018 · 1 comment

Comments

@comex
Copy link
Contributor

@comex 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

@withoutboats withoutboats commented Aug 26, 2018

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.

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
@bors bors closed this in #58678 Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants