Skip to content

Commit 911d4a0

Browse files
committed
Rename should_show_cast to should_fully_qualify
1 parent 425e142 commit 911d4a0

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -503,16 +503,16 @@ fn clean_projection<'tcx>(
503503
} else {
504504
self_type.def_id(&cx.cache)
505505
};
506-
let should_show_cast = compute_should_show_cast(self_def_id, &trait_, &self_type);
506+
let should_fully_qualify = should_fully_qualify_path(self_def_id, &trait_, &self_type);
507507
Type::QPath(Box::new(QPathData {
508508
assoc: projection_to_path_segment(ty, cx),
509-
should_show_cast,
509+
should_fully_qualify,
510510
self_type,
511511
trait_: Some(trait_),
512512
}))
513513
}
514514

515-
fn compute_should_show_cast(self_def_id: Option<DefId>, trait_: &Path, self_type: &Type) -> bool {
515+
fn should_fully_qualify_path(self_def_id: Option<DefId>, trait_: &Path, self_type: &Type) -> bool {
516516
!trait_.segments.is_empty()
517517
&& self_def_id
518518
.zip(Some(trait_.def_id()))
@@ -1695,10 +1695,11 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
16951695
register_res(cx, trait_.res);
16961696
let self_def_id = DefId::local(qself.hir_id.owner.def_id.local_def_index);
16971697
let self_type = clean_ty(qself, cx);
1698-
let should_show_cast = compute_should_show_cast(Some(self_def_id), &trait_, &self_type);
1698+
let should_fully_qualify =
1699+
should_fully_qualify_path(Some(self_def_id), &trait_, &self_type);
16991700
Type::QPath(Box::new(QPathData {
17001701
assoc: clean_path_segment(p.segments.last().expect("segments were empty"), cx),
1701-
should_show_cast,
1702+
should_fully_qualify,
17021703
self_type,
17031704
trait_: Some(trait_),
17041705
}))
@@ -1707,16 +1708,16 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
17071708
let ty = lower_ty(cx.tcx, hir_ty);
17081709
let self_type = clean_ty(qself, cx);
17091710

1710-
let (trait_, should_show_cast) = match ty.kind() {
1711+
let (trait_, should_fully_qualify) = match ty.kind() {
17111712
ty::Alias(ty::Projection, proj) => {
17121713
let res = Res::Def(DefKind::Trait, proj.trait_ref(cx.tcx).def_id);
17131714
let trait_ = clean_path(&hir::Path { span, res, segments: &[] }, cx);
17141715
register_res(cx, trait_.res);
17151716
let self_def_id = res.opt_def_id();
1716-
let should_show_cast =
1717-
compute_should_show_cast(self_def_id, &trait_, &self_type);
1717+
let should_fully_qualify =
1718+
should_fully_qualify_path(self_def_id, &trait_, &self_type);
17181719

1719-
(Some(trait_), should_show_cast)
1720+
(Some(trait_), should_fully_qualify)
17201721
}
17211722
ty::Alias(ty::Inherent, _) => (None, false),
17221723
// Rustdoc handles `ty::Error`s by turning them into `Type::Infer`s.
@@ -1726,7 +1727,7 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
17261727

17271728
Type::QPath(Box::new(QPathData {
17281729
assoc: clean_path_segment(segment, cx),
1729-
should_show_cast,
1730+
should_fully_qualify,
17301731
self_type,
17311732
trait_,
17321733
}))
@@ -2207,7 +2208,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
22072208
constraints: Default::default(),
22082209
},
22092210
},
2210-
should_show_cast: false,
2211+
should_fully_qualify: false,
22112212
self_type,
22122213
trait_: None,
22132214
}))

src/librustdoc/clean/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ pub(crate) struct QPathData {
17461746
pub assoc: PathSegment,
17471747
pub self_type: Type,
17481748
/// FIXME: compute this field on demand.
1749-
pub should_show_cast: bool,
1749+
pub should_fully_qualify: bool,
17501750
pub trait_: Option<Path>,
17511751
}
17521752

src/librustdoc/html/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,22 +1023,22 @@ fn fmt_type(
10231023
ref assoc,
10241024
ref self_type,
10251025
ref trait_,
1026-
should_show_cast,
1026+
should_fully_qualify,
10271027
}) => {
10281028
// FIXME(inherent_associated_types): Once we support non-ADT self-types (#106719),
10291029
// we need to surround them with angle brackets in some cases (e.g. `<dyn …>::P`).
10301030

10311031
if f.alternate() {
10321032
if let Some(trait_) = trait_
1033-
&& should_show_cast
1033+
&& should_fully_qualify
10341034
{
10351035
write!(f, "<{:#} as {:#}>::", self_type.print(cx), trait_.print(cx))?
10361036
} else {
10371037
write!(f, "{:#}::", self_type.print(cx))?
10381038
}
10391039
} else {
10401040
if let Some(trait_) = trait_
1041-
&& should_show_cast
1041+
&& should_fully_qualify
10421042
{
10431043
write!(f, "&lt;{} as {}&gt;::", self_type.print(cx), trait_.print(cx))?
10441044
} else {

0 commit comments

Comments
 (0)