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

Incomplete warning min_const_fn for unstable trait bounds other than Sized #54469

Closed
gnzlbg opened this issue Sep 22, 2018 · 3 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Sep 22, 2018

#![feature(min_const_fn)]
use std::marker::PhantomData;
pub struct Foo<T>(PhantomData<T>);
pub trait Bar {}
impl<T: Bar> Foo<T> {
    pub const fn foo() -> Self {
        Foo(PhantomData)
    }
}
fn main() {}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error: trait bounds other than `Sized` on const fn parameters are unstable
 --> src/main.rs:5:6
  |
5 | impl<T: Bar> Foo<T> {
  |      ^

error: aborting due to previous error

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

The error should mention which feature has to be enabled to make use of this. The feature is const_fn.

cc @oli-obk @eddyb

@csmoe csmoe added the A-diagnostics Area: Messages for errors, warnings, and lints label Sep 22, 2018
@Centril Centril added A-frontend Area: Compiler frontend (errors, parsing and HIR) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-compiler-front labels Sep 22, 2018
@eddyb
Copy link
Member

eddyb commented Sep 22, 2018

Also, it should point at the Bar, I would think?

@oli-obk
Copy link
Contributor

oli-obk commented Oct 1, 2018

Pointing at the Bar is hard. It might be multiple bound spread out through where bounds and generics.

We can change the message to "this generic parameter has nontrivial bounds which is not permitted in const fn"

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 1, 2018

FWIW I think that the bigger issue is that the message says that the feature is unstable, but doesn't mention how the feature is actually called. I guessed, and happened to guess just fine, but if min_const_fn becomes stable at some point, the error should properly mention which features users have to enable for this on nightly.

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-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants