diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2025-06-05 16:03:22 +0200 |
|---|---|---|
| committer | León Orell Valerian Liehr <me@fmease.dev> | 2025-06-05 19:18:46 +0200 |
| commit | 911d4a0c06bad14c8320344175a82451d26cbdaf (patch) | |
| tree | 2dc6adef35c52e03226ffdaa17fd77170fee98f8 /src | |
| parent | 425e142686242c7e73f5e32c79071ae266f0f355 (diff) | |
Rename `should_show_cast` to `should_fully_qualify`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 23 | ||||
| -rw-r--r-- | src/librustdoc/clean/types.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/html/format.rs | 6 |
3 files changed, 16 insertions, 15 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index e8cf25b1906..0ddb0466c29 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -503,16 +503,16 @@ fn clean_projection<'tcx>( } else { self_type.def_id(&cx.cache) }; - let should_show_cast = compute_should_show_cast(self_def_id, &trait_, &self_type); + let should_fully_qualify = should_fully_qualify_path(self_def_id, &trait_, &self_type); Type::QPath(Box::new(QPathData { assoc: projection_to_path_segment(ty, cx), - should_show_cast, + should_fully_qualify, self_type, trait_: Some(trait_), })) } -fn compute_should_show_cast(self_def_id: Option<DefId>, trait_: &Path, self_type: &Type) -> bool { +fn should_fully_qualify_path(self_def_id: Option<DefId>, trait_: &Path, self_type: &Type) -> bool { !trait_.segments.is_empty() && self_def_id .zip(Some(trait_.def_id())) @@ -1695,10 +1695,11 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type register_res(cx, trait_.res); let self_def_id = DefId::local(qself.hir_id.owner.def_id.local_def_index); let self_type = clean_ty(qself, cx); - let should_show_cast = compute_should_show_cast(Some(self_def_id), &trait_, &self_type); + let should_fully_qualify = + should_fully_qualify_path(Some(self_def_id), &trait_, &self_type); Type::QPath(Box::new(QPathData { assoc: clean_path_segment(p.segments.last().expect("segments were empty"), cx), - should_show_cast, + should_fully_qualify, self_type, trait_: Some(trait_), })) @@ -1707,16 +1708,16 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type let ty = lower_ty(cx.tcx, hir_ty); let self_type = clean_ty(qself, cx); - let (trait_, should_show_cast) = match ty.kind() { + let (trait_, should_fully_qualify) = match ty.kind() { ty::Alias(ty::Projection, proj) => { let res = Res::Def(DefKind::Trait, proj.trait_ref(cx.tcx).def_id); let trait_ = clean_path(&hir::Path { span, res, segments: &[] }, cx); register_res(cx, trait_.res); let self_def_id = res.opt_def_id(); - let should_show_cast = - compute_should_show_cast(self_def_id, &trait_, &self_type); + let should_fully_qualify = + should_fully_qualify_path(self_def_id, &trait_, &self_type); - (Some(trait_), should_show_cast) + (Some(trait_), should_fully_qualify) } ty::Alias(ty::Inherent, _) => (None, false), // 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 Type::QPath(Box::new(QPathData { assoc: clean_path_segment(segment, cx), - should_show_cast, + should_fully_qualify, self_type, trait_, })) @@ -2207,7 +2208,7 @@ pub(crate) fn clean_middle_ty<'tcx>( constraints: Default::default(), }, }, - should_show_cast: false, + should_fully_qualify: false, self_type, trait_: None, })) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 9e46d0b47e9..8a6bcdff6f3 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1746,7 +1746,7 @@ pub(crate) struct QPathData { pub assoc: PathSegment, pub self_type: Type, /// FIXME: compute this field on demand. - pub should_show_cast: bool, + pub should_fully_qualify: bool, pub trait_: Option<Path>, } diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index e9a7f4367a3..31e3cb73fa2 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1023,14 +1023,14 @@ fn fmt_type( ref assoc, ref self_type, ref trait_, - should_show_cast, + should_fully_qualify, }) => { // FIXME(inherent_associated_types): Once we support non-ADT self-types (#106719), // we need to surround them with angle brackets in some cases (e.g. `<dyn …>::P`). if f.alternate() { if let Some(trait_) = trait_ - && should_show_cast + && should_fully_qualify { write!(f, "<{:#} as {:#}>::", self_type.print(cx), trait_.print(cx))? } else { @@ -1038,7 +1038,7 @@ fn fmt_type( } } else { if let Some(trait_) = trait_ - && should_show_cast + && should_fully_qualify { write!(f, "<{} as {}>::", self_type.print(cx), trait_.print(cx))? } else { |
