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

Instability warning for let bindings in const fn doesn't list requisite feature flag #57544

Closed
varkor opened this issue Jan 12, 2019 · 1 comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@varkor
Copy link
Member

varkor commented Jan 12, 2019

const fn foo() {
    let _x = 5;
}

reports:

error: local variables in const fn are unstable
 --> src/lib.rs:2:9
  |
2 |     let _x = 5;
  |         ^^

error: aborting due to previous error

This should report to the user which feature flag should be added to use this feature.

@varkor varkor added A-diagnostics Area: Messages for errors, warnings, and lints A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. labels Jan 12, 2019
@Centril
Copy link
Contributor

Centril commented Jan 13, 2019

They are stable on nightly anyways so there might not be anything to fix here?

Centril added a commit to Centril/rust that referenced this issue Feb 13, 2019
… r=oli-obk

Add specific feature gate error for const-unstable features

Before:
```
error: `impl Trait` in const fn is unstable
 --> src/lib.rs:7:19
  |
7 | const fn foo() -> impl T {
  |                   ^^^^^^

error: aborting due to previous error
```

After:
```
error[E0723]: `impl Trait` in const fn is unstable (see issue rust-lang#57563)
 --> src/lib.rs:7:19
  |
7 | const fn foo() -> impl T {
  |                   ^^^^^^
  = help: add #![feature(const_fn)] to the crate attributes to enable

error: aborting due to previous error
```

This improves the situation with rust-lang#57563. Fixes rust-lang#57544. Fixes rust-lang#54469.

r? @oli-obk
Centril added a commit to Centril/rust that referenced this issue Feb 13, 2019
… r=oli-obk

Add specific feature gate error for const-unstable features

Before:
```
error: `impl Trait` in const fn is unstable
 --> src/lib.rs:7:19
  |
7 | const fn foo() -> impl T {
  |                   ^^^^^^

error: aborting due to previous error
```

After:
```
error[E0723]: `impl Trait` in const fn is unstable (see issue rust-lang#57563)
 --> src/lib.rs:7:19
  |
7 | const fn foo() -> impl T {
  |                   ^^^^^^
  = help: add #![feature(const_fn)] to the crate attributes to enable

error: aborting due to previous error
```

This improves the situation with rust-lang#57563. Fixes rust-lang#57544. Fixes rust-lang#54469.

r? @oli-obk
Centril added a commit to Centril/rust that referenced this issue Feb 14, 2019
… r=oli-obk

Add specific feature gate error for const-unstable features

Before:
```
error: `impl Trait` in const fn is unstable
 --> src/lib.rs:7:19
  |
7 | const fn foo() -> impl T {
  |                   ^^^^^^

error: aborting due to previous error
```

After:
```
error[E0723]: `impl Trait` in const fn is unstable (see issue rust-lang#57563)
 --> src/lib.rs:7:19
  |
7 | const fn foo() -> impl T {
  |                   ^^^^^^
  = help: add #![feature(const_fn)] to the crate attributes to enable

error: aborting due to previous error
```

This improves the situation with rust-lang#57563. Fixes rust-lang#57544. Fixes rust-lang#54469.

r? @oli-obk
kennytm added a commit to kennytm/rust that referenced this issue Feb 16, 2019
… r=oli-obk

Add specific feature gate error for const-unstable features

Before:
```
error: `impl Trait` in const fn is unstable
 --> src/lib.rs:7:19
  |
7 | const fn foo() -> impl T {
  |                   ^^^^^^

error: aborting due to previous error
```

After:
```
error[E0723]: `impl Trait` in const fn is unstable (see issue rust-lang#57563)
 --> src/lib.rs:7:19
  |
7 | const fn foo() -> impl T {
  |                   ^^^^^^
  = help: add #![feature(const_fn)] to the crate attributes to enable

error: aborting due to previous error
```

This improves the situation with rust-lang#57563. Fixes rust-lang#57544. Fixes rust-lang#54469.

r? @oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

2 participants