Skip to content

Use get_diagnostic_name #7784

Open
Open
@camsteffen

Description

@camsteffen

A new function tcx.get_diagnostic_name is available (after the next sync) and we should migrate existing code to use it in any case that multiple queries can be reduced to one.

For example (this is just one of a few different patterns that can be refactored):

// before
cx.tcx.is_diagnostic_item(sym::Vec, def_id)
    || cx.tcx.is_diagnostic_item(sym::HashMap, def_id)
    || cx.tcx.is_diagnostic_item(sym::HashSet, def_id)

// after
matches!(cx.tcx.get_diagnostic_name(def_id), Some(sym::Vec | sym::HashMap | sym::HashSet))

Also look for type_is_diagnotic_item calls which can be refactored using ty.ty_adt_def()?.did.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions