Make impl HirDisplay for TraitRef provide just the trait type

This commit is contained in:
Michael Sloan 2024-12-30 13:33:12 -07:00
parent 34dc94bb2d
commit 03cb63cc75
4 changed files with 24 additions and 68 deletions

View file

@ -3,10 +3,7 @@
use core::fmt;
use hir::{
Adt, AsAssocItem, Crate, HirDisplay, MacroKind, Semantics, TraitRefDisplayWrapper,
TraitRefFormat,
};
use hir::{Adt, AsAssocItem, Crate, HirDisplay, MacroKind, Semantics};
use ide_db::{
base_db::{CrateOrigin, LangCrateOrigin},
defs::{Definition, IdentClass},
@ -312,15 +309,13 @@ fn def_to_non_local_moniker(
match def {
Definition::SelfType(impl_) => {
if let Some(trait_ref) = impl_.trait_ref(db) {
// Trait impls use `trait_type` constraint syntax for the 2nd parameter.
let trait_ref_for_display =
TraitRefDisplayWrapper { trait_ref, format: TraitRefFormat::OnlyTrait };
// Trait impls use the trait type for the 2nd parameter.
reverse_description.push(MonikerDescriptor {
name: display(db, edition, module, trait_ref_for_display),
name: display(db, edition, module, trait_ref),
desc: MonikerDescriptorKind::TypeParameter,
});
}
// Both inherent and trait impls use `self_type` as the first parameter.
// Both inherent and trait impls use the self type for the first parameter.
reverse_description.push(MonikerDescriptor {
name: display(db, edition, module, impl_.self_ty(db)),
desc: MonikerDescriptorKind::TypeParameter,