Skip to content

Commit 913764d

Browse files
committed
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.
1 parent 5321b35 commit 913764d

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

Diff for: src/librustdoc/clean/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ impl Clean<Type> for (ty::TraitRef<'_>, &[TypeBinding]) {
164164
);
165165
}
166166
inline::record_extern_fqn(cx, trait_ref.def_id, kind);
167-
let path =
168-
external_path(cx, trait_ref.def_id, true, true, bounds.to_vec(), trait_ref.substs);
167+
let path = external_path(cx, trait_ref.def_id, true, bounds.to_vec(), trait_ref.substs);
169168

170169
debug!("ty::TraitRef\n subst: {:?}\n", trait_ref.substs);
171170

@@ -1442,12 +1441,12 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
14421441
AdtKind::Enum => ItemType::Enum,
14431442
};
14441443
inline::record_extern_fqn(cx, did, kind);
1445-
let path = external_path(cx, did, false, false, vec![], substs);
1444+
let path = external_path(cx, did, false, vec![], substs);
14461445
ResolvedPath { path, did, is_generic: false }
14471446
}
14481447
ty::Foreign(did) => {
14491448
inline::record_extern_fqn(cx, did, ItemType::ForeignType);
1450-
let path = external_path(cx, did, false, false, vec![], InternalSubsts::empty());
1449+
let path = external_path(cx, did, false, vec![], InternalSubsts::empty());
14511450
ResolvedPath { path, did, is_generic: false }
14521451
}
14531452
ty::Dynamic(ref obj, ref reg) => {
@@ -1471,7 +1470,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
14711470

14721471
for did in dids {
14731472
let empty = cx.tcx.intern_substs(&[]);
1474-
let path = external_path(cx, did, true, false, vec![], empty);
1473+
let path = external_path(cx, did, false, vec![], empty);
14751474
inline::record_extern_fqn(cx, did, ItemType::Trait);
14761475
let bound = PolyTrait {
14771476
trait_: ResolvedPath { path, did, is_generic: false },
@@ -1488,7 +1487,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
14881487
});
14891488
}
14901489

1491-
let path = external_path(cx, did, true, false, bindings, substs);
1490+
let path = external_path(cx, did, false, bindings, substs);
14921491
bounds.insert(
14931492
0,
14941493
PolyTrait {

Diff for: src/librustdoc/clean/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ impl GenericBound {
11581158
crate fn maybe_sized(cx: &mut DocContext<'_>) -> GenericBound {
11591159
let did = cx.tcx.require_lang_item(LangItem::Sized, None);
11601160
let empty = cx.tcx.intern_substs(&[]);
1161-
let path = external_path(cx, did, true, false, vec![], empty);
1161+
let path = external_path(cx, did, false, vec![], empty);
11621162
inline::record_extern_fqn(cx, did, ItemType::Trait);
11631163
GenericBound::TraitBound(
11641164
PolyTrait {

Diff for: src/librustdoc/clean/utils.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate {
9494
fn external_generic_args(
9595
cx: &mut DocContext<'_>,
9696
did: DefId,
97-
is_trait: bool,
9897
has_self: bool,
9998
bindings: Vec<TypeBinding>,
10099
substs: SubstsRef<'_>,
@@ -122,7 +121,7 @@ fn external_generic_args(
122121
})
123122
.collect();
124123

125-
if is_trait && cx.tcx.fn_trait_kind_from_lang_item(did).is_some() {
124+
if cx.tcx.fn_trait_kind_from_lang_item(did).is_some() {
126125
assert!(ty_kind.is_some());
127126
let inputs = match ty_kind {
128127
Some(ty::Tuple(ref tys)) => tys.iter().map(|t| t.expect_ty().clean(cx)).collect(),
@@ -140,12 +139,9 @@ fn external_generic_args(
140139
}
141140
}
142141

143-
/// `is_trait` should be set to `true` if called on a `TraitRef`, in order to sugar
144-
/// from `Fn<(A, B,), C>` to `Fn(A, B) -> C`
145142
pub(super) fn external_path(
146143
cx: &mut DocContext<'_>,
147144
did: DefId,
148-
is_trait: bool,
149145
has_self: bool,
150146
bindings: Vec<TypeBinding>,
151147
substs: SubstsRef<'_>,
@@ -157,7 +153,7 @@ pub(super) fn external_path(
157153
res: Res::Def(def_kind, did),
158154
segments: vec![PathSegment {
159155
name,
160-
args: external_generic_args(cx, did, is_trait, has_self, bindings, substs),
156+
args: external_generic_args(cx, did, has_self, bindings, substs),
161157
}],
162158
}
163159
}

0 commit comments

Comments
 (0)