Skip to content

Commit bd007f2

Browse files
committed
rustdoc: Rename SelfTy to ReceiverTy
`SelfTy` makes it sound like it is literally the `Self` type, whereas in fact it may be `&Self` or other types. Plus, I want to use the name `SelfTy` for a new variant of `clean::Type`. Having both causes resolution conflicts or at least confusion.
1 parent 83dcdb3 commit bd007f2

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/librustdoc/clean/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use thin_vec::ThinVec;
3434
use {rustc_ast as ast, rustc_hir as hir};
3535

3636
pub(crate) use self::ItemKind::*;
37-
pub(crate) use self::SelfTy::*;
37+
pub(crate) use self::ReceiverTy::*;
3838
pub(crate) use self::Type::{
3939
Array, BareFunction, BorrowedRef, DynTrait, Generic, ImplTrait, Infer, Primitive, QPath,
4040
RawPointer, Slice, Tuple,
@@ -1387,8 +1387,8 @@ pub(crate) struct FnDecl {
13871387
}
13881388

13891389
impl FnDecl {
1390-
pub(crate) fn self_type(&self) -> Option<SelfTy> {
1391-
self.inputs.values.get(0).and_then(|v| v.to_self())
1390+
pub(crate) fn receiver_type(&self) -> Option<ReceiverTy> {
1391+
self.inputs.values.get(0).and_then(|v| v.to_receiver())
13921392
}
13931393
}
13941394

@@ -1407,14 +1407,14 @@ pub(crate) struct Argument {
14071407
}
14081408

14091409
#[derive(Clone, PartialEq, Debug)]
1410-
pub(crate) enum SelfTy {
1410+
pub(crate) enum ReceiverTy {
14111411
SelfValue,
14121412
SelfBorrowed(Option<Lifetime>, Mutability),
14131413
SelfExplicit(Type),
14141414
}
14151415

14161416
impl Argument {
1417-
pub(crate) fn to_self(&self) -> Option<SelfTy> {
1417+
pub(crate) fn to_receiver(&self) -> Option<ReceiverTy> {
14181418
if self.name != kw::SelfLower {
14191419
return None;
14201420
}

src/librustdoc/html/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ impl clean::FnDecl {
14521452

14531453
let last_input_index = self.inputs.values.len().checked_sub(1);
14541454
for (i, input) in self.inputs.values.iter().enumerate() {
1455-
if let Some(selfty) = input.to_self() {
1455+
if let Some(selfty) = input.to_receiver() {
14561456
match selfty {
14571457
clean::SelfValue => {
14581458
write!(f, "self")?;

src/librustdoc/html/render/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ use serde::{Serialize, Serializer};
5858

5959
pub(crate) use self::context::*;
6060
pub(crate) use self::span_map::{collect_spans_and_sources, LinkFromSrc};
61-
use crate::clean::{self, ItemId, RenderedLink, SelfTy};
61+
use crate::clean::{self, ItemId, ReceiverTy, RenderedLink};
6262
use crate::error::Error;
6363
use crate::formats::cache::Cache;
6464
use crate::formats::item_type::ItemType;
@@ -1379,21 +1379,21 @@ fn render_deref_methods(
13791379

13801380
fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) -> bool {
13811381
let self_type_opt = match *item.kind {
1382-
clean::MethodItem(ref method, _) => method.decl.self_type(),
1383-
clean::TyMethodItem(ref method) => method.decl.self_type(),
1382+
clean::MethodItem(ref method, _) => method.decl.receiver_type(),
1383+
clean::TyMethodItem(ref method) => method.decl.receiver_type(),
13841384
_ => None,
13851385
};
13861386

13871387
if let Some(self_ty) = self_type_opt {
13881388
let (by_mut_ref, by_box, by_value) = match self_ty {
1389-
SelfTy::SelfBorrowed(_, mutability)
1390-
| SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
1389+
ReceiverTy::SelfBorrowed(_, mutability)
1390+
| ReceiverTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
13911391
(mutability == Mutability::Mut, false, false)
13921392
}
1393-
SelfTy::SelfExplicit(clean::Type::Path { path }) => {
1393+
ReceiverTy::SelfExplicit(clean::Type::Path { path }) => {
13941394
(false, Some(path.def_id()) == tcx.lang_items().owned_box(), false)
13951395
}
1396-
SelfTy::SelfValue => (false, false, true),
1396+
ReceiverTy::SelfValue => (false, false, true),
13971397
_ => (false, false, false),
13981398
};
13991399

0 commit comments

Comments
 (0)