Skip to content

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

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

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

    Development

    No branches or pull requests

    Issue actions