Skip to content

Hint the generic type and possible bounds on the unimplemented trait error #28660

Closed
@lifthrasiir

Description

@lifthrasiir
fn f<T>(x: T) { x + 4; }
fn g<T>(x: T) { println!("{}", x); }
fn h<T>(x: T) { trait X {} fn hh<T:X>(x: T) {} hh(x); }

Codes like these currently do not point to the original declaration of T for missing trait bounds. In some cases rustc even does not indicate which trait is unimplemented (f). Hinting T: Trait bounds would be helpful for those cases.
#19950 (Provide better error reporting for unimplemented traits) is related and in principle would be a superset, but the issue currently only discusses about nominal types and not generic types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions