Skip to content

Allow customising ty::TraitRef's printing behavior. #59188

Closed
@eddyb

Description

@eddyb

(Originally discussed in #58140 (comment))
Right now a TraitRef prints as <T as Trait<U>> via "debug" ({:?}) and Trait<U> via "display" ({}) - this is used all over rustc to indicate what printed form of the trait is desired.

However, it would be overall cleaner for "display" and "debug" printing to match (or even for fmt::Display to not be implemented at all, perhaps?), and provide all the information that exists (i.e. including the Self type).

We would then need a replacement for printing "just the trait path with its parameters", and I think we can have a method, .print_only_trait_path(), that returns a wrapper which has the different formatting behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-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