internal: Add public direct_supertraits(…)
& all_supertraits(…)
accessor methods to hir::Trait
#18482
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @Veykril,
I need to access a trait's supertraits (as external user of
ra_ap
's APIs) and whilehir_ty::all_super_traits()
already provides such capabilities to a limited degree I'd like to propose the following accessors onhir::Trait
itself, it only does provide access to the entire trait hierarchy (while I only want the direct supertraits) and requires a descent intohir_ty
land. I'd thus like to propose adding the following methods:hir::Trait::direct_supertraits(db)
&hir::Trait::all_supertraits(db)
.There seems to be some naming inconsistency with regard to
supertrait
(43 occurrences) vs.super_trait
(53 occurrences) in the codebase. (I'd be happy to open a follow-up PR unifying the project-wide naming, if so desired.)I went with
supertraits
in this PR since that's what the already existinghir::Trait::items_with_supertraits(…)
uses in close proximity to the newly added methods.