diff options
| author | Noah Lev <camelidcamel@gmail.com> | 2024-07-31 16:45:05 -0700 |
|---|---|---|
| committer | Noah Lev <camelidcamel@gmail.com> | 2024-08-04 12:49:27 -0700 |
| commit | 664b3ffbe932d93677ac7dff52252e02aee60ef9 (patch) | |
| tree | dd070d567793922f464194558382385c16e95eaa /src/librustdoc/clean/utils.rs | |
| parent | 249d686c7005ebb4d05234e9db6d29c2923296e2 (diff) | |
| download | rust-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.rs | 2 |
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), _ => { |
