diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index e2ad21bba21..fc4f22ca4f4 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -166,7 +166,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type { inline::record_extern_fqn(cx, trait_ref.def_id, kind); let path = external_path( cx, - cx.tcx.item_name(trait_ref.def_id), + trait_ref.def_id, Some(trait_ref.def_id), true, bounds.to_vec(), @@ -1448,19 +1448,12 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type { AdtKind::Enum => ItemType::Enum, }; inline::record_extern_fqn(cx, did, kind); - let path = external_path(cx, cx.tcx.item_name(did), None, false, vec![], substs); + let path = external_path(cx, did, None, false, vec![], substs); ResolvedPath { path, did, is_generic: false } } ty::Foreign(did) => { inline::record_extern_fqn(cx, did, ItemType::ForeignType); - let path = external_path( - cx, - cx.tcx.item_name(did), - None, - false, - vec![], - InternalSubsts::empty(), - ); + let path = external_path(cx, did, None, false, vec![], InternalSubsts::empty()); ResolvedPath { path, did, is_generic: false } } ty::Dynamic(ref obj, ref reg) => { @@ -1484,8 +1477,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type { for did in dids { let empty = cx.tcx.intern_substs(&[]); - let path = - external_path(cx, cx.tcx.item_name(did), Some(did), false, vec![], empty); + let path = external_path(cx, did, Some(did), false, vec![], empty); inline::record_extern_fqn(cx, did, ItemType::Trait); let bound = PolyTrait { trait_: ResolvedPath { path, did, is_generic: false }, @@ -1502,8 +1494,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type { }); } - let path = - external_path(cx, cx.tcx.item_name(did), Some(did), false, bindings, substs); + let path = external_path(cx, did, Some(did), false, bindings, substs); bounds.insert( 0, PolyTrait { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 5eff56a2200..8d89fae6657 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1158,7 +1158,7 @@ impl GenericBound { crate fn maybe_sized(cx: &mut DocContext<'_>) -> GenericBound { let did = cx.tcx.require_lang_item(LangItem::Sized, None); let empty = cx.tcx.intern_substs(&[]); - let path = external_path(cx, cx.tcx.item_name(did), Some(did), false, vec![], empty); + let path = external_path(cx, did, Some(did), false, vec![], empty); inline::record_extern_fqn(cx, did, ItemType::Trait); GenericBound::TraitBound( PolyTrait { diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index a11b9c2af8a..b6911e88867 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -141,19 +141,21 @@ fn external_generic_args( } } -// trait_did should be set to a trait's DefId if called on a TraitRef, in order to sugar -// from Fn<(A, B,), C> to Fn(A, B) -> C +/// trait_did should be set to a trait's DefId if called on a TraitRef, in order to sugar +/// from `Fn<(A, B,), C>` to `Fn(A, B) -> C` pub(super) fn external_path( cx: &mut DocContext<'_>, - name: Symbol, + did: DefId, trait_did: Option, has_self: bool, bindings: Vec, substs: SubstsRef<'_>, ) -> Path { + let def_kind = cx.tcx.def_kind(did); + let name = cx.tcx.item_name(did); Path { global: false, - res: Res::Err, + res: Res::Def(def_kind, did), segments: vec![PathSegment { name, args: external_generic_args(cx, trait_did, has_self, bindings, substs), diff --git a/src/test/rustdoc/synthetic_auto/no-redundancy.rs b/src/test/rustdoc/synthetic_auto/no-redundancy.rs index f727c9a47f2..16ab876e829 100644 --- a/src/test/rustdoc/synthetic_auto/no-redundancy.rs +++ b/src/test/rustdoc/synthetic_auto/no-redundancy.rs @@ -10,7 +10,7 @@ unsafe impl Send for Inner // @has no_redundancy/struct.Outer.html // @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl has-srclink"]//h3[@class="code-header in-band"]' \ -// "impl Send for Outer where T: Copy + Send" +// "impl Send for Outer where T: Send + Copy" pub struct Outer { inner_field: Inner, }