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

rustc doesn't suggest adding feature gate attribute to resolve an error #90615

Closed
ghost opened this issue Nov 5, 2021 · 0 comments · Fixed by #90708
Closed

rustc doesn't suggest adding feature gate attribute to resolve an error #90615

ghost opened this issue Nov 5, 2021 · 0 comments · Fixed by #90708
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ghost
Copy link

ghost commented Nov 5, 2021

Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=3d9311fa97ed73994120865ed38185e8

trait Foo { }
trait Bar { }

struct A;
impl Foo for A { }

struct B;
impl Bar for B { }

fn func<T: Foo>(arg: impl Bar) { }

fn main() {
    func::<A>(B);
}

The current output is:

Compiling playground v0.0.1 (/playground)
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
  --> src/main.rs:14:12
   |
14 |     func::<A>(B);
   |            ^ explicit generic argument not allowed

For more information about this error, try `rustc --explain E0632`.
error: could not compile `playground` due to previous error

Ideally the output should look like:

Compiling playground v0.0.1 (/playground)
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
  --> src/main.rs:14:12
   |
14 |     func::<A>(B);
   |            ^ explicit generic argument not allowed
   = note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
   = help: add `#![feature(explicit_generic_args_with_impl_trait)]` to the crate attributes to enable
For more information about this error, try `rustc --explain E0632`.
error: could not compile `playground` due to previous error
@ghost ghost added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 5, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 8, 2021
Add a note about feature(explicit_generic_args_with_impl_trait) to the relevant error message

Fixes rust-lang#90615
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 8, 2021
Add a note about feature(explicit_generic_args_with_impl_trait) to the relevant error message

Fixes rust-lang#90615
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 8, 2021
Add a note about feature(explicit_generic_args_with_impl_trait) to the relevant error message

Fixes rust-lang#90615
@bors bors closed this as completed in f1fef6b Nov 9, 2021
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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
0 participants