Skip to content

Commit 249d686

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 ab1527f commit 249d686

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,
@@ -1384,8 +1384,8 @@ pub(crate) struct FnDecl {
13841384
}
13851385

13861386
impl FnDecl {
1387-
pub(crate) fn self_type(&self) -> Option<SelfTy> {
1388-
self.inputs.values.get(0).and_then(|v| v.to_self())
1387+
pub(crate) fn receiver_type(&self) -> Option<ReceiverTy> {
1388+
self.inputs.values.get(0).and_then(|v| v.to_receiver())
13891389
}
13901390
}
13911391

@@ -1404,14 +1404,14 @@ pub(crate) struct Argument {
14041404
}
14051405

14061406
#[derive(Clone, PartialEq, Debug)]
1407-
pub(crate) enum SelfTy {
1407+
pub(crate) enum ReceiverTy {
14081408
SelfValue,
14091409
SelfBorrowed(Option<Lifetime>, Mutability),
14101410
SelfExplicit(Type),
14111411
}
14121412

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

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;
@@ -1372,21 +1372,21 @@ fn render_deref_methods(
13721372

13731373
fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) -> bool {
13741374
let self_type_opt = match *item.kind {
1375-
clean::MethodItem(ref method, _) => method.decl.self_type(),
1376-
clean::TyMethodItem(ref method) => method.decl.self_type(),
1375+
clean::MethodItem(ref method, _) => method.decl.receiver_type(),
1376+
clean::TyMethodItem(ref method) => method.decl.receiver_type(),
13771377
_ => None,
13781378
};
13791379

13801380
if let Some(self_ty) = self_type_opt {
13811381
let (by_mut_ref, by_box, by_value) = match self_ty {
1382-
SelfTy::SelfBorrowed(_, mutability)
1383-
| SelfTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
1382+
ReceiverTy::SelfBorrowed(_, mutability)
1383+
| ReceiverTy::SelfExplicit(clean::BorrowedRef { mutability, .. }) => {
13841384
(mutability == Mutability::Mut, false, false)
13851385
}
1386-
SelfTy::SelfExplicit(clean::Type::Path { path }) => {
1386+
ReceiverTy::SelfExplicit(clean::Type::Path { path }) => {
13871387
(false, Some(path.def_id()) == tcx.lang_items().owned_box(), false)
13881388
}
1389-
SelfTy::SelfValue => (false, false, true),
1389+
ReceiverTy::SelfValue => (false, false, true),
13901390
_ => (false, false, false),
13911391
};
13921392

0 commit comments

Comments
 (0)