Skip to content

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

@ghost

Description

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

Activity

ghost added
A-diagnosticsArea: Messages for errors, warnings, and lints
on Nov 5, 2021
ghost added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Nov 5, 2021
added 3 commits that reference this issue on Nov 8, 2021
9399216
fb94698
967eb27
added a commit that references this issue on Nov 9, 2021
f1fef6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      No participants

      Issue actions

        rustc doesn't suggest adding feature gate attribute to resolve an error · Issue #90615 · rust-lang/rust