about summary refs log tree commit diff
path: root/src/librustdoc/clean/utils.rs
diff options
context:
space:
mode:
authorNoah Lev <camelidcamel@gmail.com>2024-07-31 16:45:05 -0700
committerNoah Lev <camelidcamel@gmail.com>2024-08-04 12:49:27 -0700
commit664b3ffbe932d93677ac7dff52252e02aee60ef9 (patch)
treedd070d567793922f464194558382385c16e95eaa /src/librustdoc/clean/utils.rs
parent249d686c7005ebb4d05234e9db6d29c2923296e2 (diff)
downloadrust-664b3ffbe932d93677ac7dff52252e02aee60ef9.tar.gz
rust-664b3ffbe932d93677ac7dff52252e02aee60ef9.zip
rustdoc: Create `SelfTy` to replace `Generic(kw::SelfUpper)`
Rustdoc often has to special-case `Self` because it is, well, a special
type of generic parameter (although it also behaves as an alias in
concrete impls). Instead of spreading this special-casing throughout the
code base, create a new variant of the `clean::Type` enum that is for
`Self` types.

This is a refactoring that has almost no impact on rustdoc's behavior,
except that `&Self`, `(Self,)`, `&[Self]`, and other similar occurrences
of `Self` no longer link to the wrapping type (reference primitive,
tuple primitive, etc.) as regular generics do. I felt this made more
sense since users would expect `Self` to link to the containing trait or
aliased type (though those are usually expanded), not the primitive that
is wrapping it. For an example of the change, see the docs for
`std::alloc::Allocator::by_ref`.
Diffstat (limited to 'src/librustdoc/clean/utils.rs')
-rw-r--r--src/librustdoc/clean/utils.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs
index 2dd3041ab4c..68266f3506a 100644
--- a/src/librustdoc/clean/utils.rs
+++ b/src/librustdoc/clean/utils.rs
@@ -468,7 +468,7 @@ pub(crate) fn resolve_type(cx: &mut DocContext<'_>, path: Path) -> Type {
     match path.res {
         Res::PrimTy(p) => Primitive(PrimitiveType::from(p)),
         Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } if path.segments.len() == 1 => {
-            Generic(kw::SelfUpper)
+            Type::SelfTy
         }
         Res::Def(DefKind::TyParam, _) if path.segments.len() == 1 => Generic(path.segments[0].name),
         _ => {