mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 04:55:22 +03:00
Remove unnecessary is_trait argument
It was only used for sugaring `Fn` trait bounds, and rustdoc already checks that the `did` is for a `Fn` (or `FnMut`, `FnOnce`) lang item, so it's not necessary to also check that the `did` belongs to a trait.
This commit is contained in:
@@ -164,8 +164,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
|
||||
);
|
||||
}
|
||||
inline::record_extern_fqn(cx, trait_ref.def_id, kind);
|
||||
let path =
|
||||
external_path(cx, trait_ref.def_id, true, true, bounds.to_vec(), trait_ref.substs);
|
||||
let path = external_path(cx, trait_ref.def_id, true, bounds.to_vec(), trait_ref.substs);
|
||||
|
||||
debug!("ty::TraitRef\n subst: {:?}\n", trait_ref.substs);
|
||||
|
||||
@@ -1442,12 +1441,12 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
|
||||
AdtKind::Enum => ItemType::Enum,
|
||||
};
|
||||
inline::record_extern_fqn(cx, did, kind);
|
||||
let path = external_path(cx, did, false, false, vec![], substs);
|
||||
let path = external_path(cx, did, 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, did, false, false, vec![], InternalSubsts::empty());
|
||||
let path = external_path(cx, did, false, vec![], InternalSubsts::empty());
|
||||
ResolvedPath { path, did, is_generic: false }
|
||||
}
|
||||
ty::Dynamic(ref obj, ref reg) => {
|
||||
@@ -1471,7 +1470,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
|
||||
|
||||
for did in dids {
|
||||
let empty = cx.tcx.intern_substs(&[]);
|
||||
let path = external_path(cx, did, true, false, vec![], empty);
|
||||
let path = external_path(cx, did, false, vec![], empty);
|
||||
inline::record_extern_fqn(cx, did, ItemType::Trait);
|
||||
let bound = PolyTrait {
|
||||
trait_: ResolvedPath { path, did, is_generic: false },
|
||||
@@ -1488,7 +1487,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
|
||||
});
|
||||
}
|
||||
|
||||
let path = external_path(cx, did, true, false, bindings, substs);
|
||||
let path = external_path(cx, did, false, bindings, substs);
|
||||
bounds.insert(
|
||||
0,
|
||||
PolyTrait {
|
||||
|
||||
@@ -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, did, true, false, vec![], empty);
|
||||
let path = external_path(cx, did, false, vec![], empty);
|
||||
inline::record_extern_fqn(cx, did, ItemType::Trait);
|
||||
GenericBound::TraitBound(
|
||||
PolyTrait {
|
||||
|
||||
@@ -94,7 +94,6 @@
|
||||
fn external_generic_args(
|
||||
cx: &mut DocContext<'_>,
|
||||
did: DefId,
|
||||
is_trait: bool,
|
||||
has_self: bool,
|
||||
bindings: Vec<TypeBinding>,
|
||||
substs: SubstsRef<'_>,
|
||||
@@ -122,7 +121,7 @@ fn external_generic_args(
|
||||
})
|
||||
.collect();
|
||||
|
||||
if is_trait && cx.tcx.fn_trait_kind_from_lang_item(did).is_some() {
|
||||
if cx.tcx.fn_trait_kind_from_lang_item(did).is_some() {
|
||||
assert!(ty_kind.is_some());
|
||||
let inputs = match ty_kind {
|
||||
Some(ty::Tuple(ref tys)) => tys.iter().map(|t| t.expect_ty().clean(cx)).collect(),
|
||||
@@ -140,12 +139,9 @@ fn external_generic_args(
|
||||
}
|
||||
}
|
||||
|
||||
/// `is_trait` should be set to `true` 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<'_>,
|
||||
did: DefId,
|
||||
is_trait: bool,
|
||||
has_self: bool,
|
||||
bindings: Vec<TypeBinding>,
|
||||
substs: SubstsRef<'_>,
|
||||
@@ -157,7 +153,7 @@ pub(super) fn external_path(
|
||||
res: Res::Def(def_kind, did),
|
||||
segments: vec![PathSegment {
|
||||
name,
|
||||
args: external_generic_args(cx, did, is_trait, has_self, bindings, substs),
|
||||
args: external_generic_args(cx, did, has_self, bindings, substs),
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user