Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use get_diagnostic_name #7784

Open
camsteffen opened this issue Oct 7, 2021 · 0 comments
Open

Use get_diagnostic_name #7784

camsteffen opened this issue Oct 7, 2021 · 0 comments
Labels
C-tracking-issue Category: Tracking Issue

Comments

@camsteffen
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: Tracking Issue
Projects
None yet
Development

No branches or pull requests

1 participant