From 042593b7015ed4850ad5abd5d2cb51b93239c606 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 3 Aug 2023 14:38:54 +0200 Subject: [PATCH 1/2] Remove `receiver` and replace it with `self parameter` --- src/associated-items.rst | 2 +- src/entities-and-resolution.rst | 8 ++++++-- src/functions.rst | 4 ++-- src/glossary.rst | 12 ++---------- src/types-and-traits.rst | 10 +++++----- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/associated-items.rst b/src/associated-items.rst index 0139ca15..fbba5ca4 100644 --- a/src/associated-items.rst +++ b/src/associated-items.rst @@ -137,7 +137,7 @@ is equivalent to a :t:`where clause` of the following form: } :dp:`fls_oy92gzxgc273` -A :t:`method` is an :t:`associated function` with a :t:`receiver`. +A :t:`method` is an :t:`associated function` with a :t:`self parameter`. :dp:`fls_oHxzyaiT7Qm6` The :t:`visibility modifier` of an :t:`associated trait item` or :t:`associated diff --git a/src/entities-and-resolution.rst b/src/entities-and-resolution.rst index ee62091e..0183046e 100644 --- a/src/entities-and-resolution.rst +++ b/src/entities-and-resolution.rst @@ -1236,6 +1236,10 @@ Method Resolution :t:`Method resolution` is a kind of :t:`resolution` that applies to a :t:`method call expression`. +:dp:`fls_mbdS0xiNlj92` +A :dt:`receiver type` is the :t:`type` of the :t:`receiver operand` +of a :t:`method call expression`. + :dp:`fls_z80ylmlu1f3q` A :dt:`candidate receiver type` is the :t:`type` of the :t:`receiver operand` of a :t:`method call expression` :t:`under resolution`. @@ -1655,8 +1659,8 @@ in left-to-right order, as follows: :t:`path segment`. #. :dp:`fls_q0jt6n2j1hsx` - If such a :t:`constant` or :t:`function` exists, then the - :t:`path segment` resolves to that :t:`constant` or :t:`function` and + If such a :t:`constant` or :t:`function` exists, then the + :t:`path segment` resolves to that :t:`constant` or :t:`function` and :t:`path expression resolution` stops. .. _fls_1h0olpc7vbui: diff --git a/src/functions.rst b/src/functions.rst index 3b98995f..ad4cd1f1 100644 --- a/src/functions.rst +++ b/src/functions.rst @@ -68,8 +68,8 @@ A :t:`function parameter` is a :t:`construct` that yields a set of site of a :t:`call expression` or a :t:`method call expression`. :dp:`fls_ymeo93t4mz4` -A :t:`self parameter` or a :t:`receiver` is a :t:`function parameter` expressed -by :t:`keyword` ``self``. +A :t:`self parameter` is a :t:`function parameter` expressed by :t:`keyword` +``self``. :dp:`fls_ijbt4tgnl95n` A :t:`function` shall not specify a :t:`self parameter` unless it is an diff --git a/src/glossary.rst b/src/glossary.rst index 5150a614..f4227044 100644 --- a/src/glossary.rst +++ b/src/glossary.rst @@ -4118,7 +4118,7 @@ method ^^^^^^ :dp:`fls_n4opbiofu9q6` -A :dt:`method` is an :t:`associated function` with a :t:`receiver`. +A :dt:`method` is an :t:`associated function` with a :t:`self parameter`. .. _fls_l4wel2551cw9: @@ -5314,14 +5314,6 @@ recognize :t:`[escaped character]s`. :dp:`fls_26ol7lrnux94` See :s:`RawStringLiteral`. -.. _fls_ar3zb025d0t7: - -receiver -^^^^^^^^ - -:dp:`fls_7043m672z8w` -For :dt:`receiver`, see :t:`self parameter`. - .. _fls_nfb3ciarl50w: receiver operand @@ -5340,7 +5332,7 @@ receiver type ^^^^^^^^^^^^^ :dp:`fls_vgQmMlpFas5t` -A :dt:`receiver type` is the :t:`type` of a :t:`receiver`. +A :dt:`receiver type` is the :t:`type` of a :t:`receiver operand`. .. _fls_nG6ikjLsCW7m: diff --git a/src/types-and-traits.rst b/src/types-and-traits.rst index 88b99c54..7f88bf42 100644 --- a/src/types-and-traits.rst +++ b/src/types-and-traits.rst @@ -2702,7 +2702,7 @@ A dispatchable :t:`function` is :t:`object safe` when: * :dp:`fls_k1vc9vd8at92` Is a :t:`method` that does not use :c:`Self` in its :t:`function signature` - except in the :t:`type` of its :t:`receiver` or as the :t:`type` of a + except in the :t:`type` of its :t:`self parameter` or as the :t:`type` of a :t:`type bound predicate`, and * :dp:`fls_kqylg31sm5wv` @@ -3144,10 +3144,10 @@ An :dt:`output lifetime` is one of the following :t:`[lifetime]s`: :t:`lifetime` is assigned to all :t:`elided` :t:`[output lifetime]s`. #. :dp:`fls_crb6m6b3cdwh` - If a :t:`function` has a :t:`receiver` of the form ``&self``, ``&mut self``, - or ``self: T`` where ``T`` is a :t:`type` with a :t:`lifetime`, then the - :t:`lifetime` of the :t:`receiver` is assigned to all :t:`elided` - :t:`[output lifetime]s`. + If a :t:`function` has a :t:`self parameter` of the form ``&self``, + ``&mut self``, or ``self: T`` where ``T`` is a :t:`type` with a + :t:`lifetime`, then the :t:`lifetime` of the :t:`self parameter` is assigned + to all :t:`elided` :t:`[output lifetime]s`. #. :dp:`fls_ac9tdlfwp5et` Otherwise this is a static error. From 96bf69d896c8fab8b0dcca4998538e3bcb9a473f Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 3 Aug 2023 15:04:21 +0200 Subject: [PATCH 2/2] Specify what a valid receiver is --- src/associated-items.rst | 19 +++++++++++++++++++ src/implementations.rst | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/associated-items.rst b/src/associated-items.rst index fbba5ca4..0d7978a3 100644 --- a/src/associated-items.rst +++ b/src/associated-items.rst @@ -139,6 +139,25 @@ is equivalent to a :t:`where clause` of the following form: :dp:`fls_oy92gzxgc273` A :t:`method` is an :t:`associated function` with a :t:`self parameter`. +:dp:`fls_WXnCWfJGoQx3` +The type of a :t:`self parameter` shall be one of the following: + +* :dp:`fls_OaszUw4IFobz` + A :t:`type specification` resolving to the :t:`implementing type` of the + related :t:`implementation`, or + +* :dp:`fls_Wd2FZRomB5yn` + ``&T`` where ``T`` is one of the the :t:`[type]s` listed in this enumeration, + or + +* :dp:`fls_lcEyToYIlcmf` + ``&mut T`` where ``T`` is one of the the :t:`[type]s` listed in this + enumeration, or + +* :dp:`fls_IKSPR7ZQMErU` + :std:`core::pin::Pin ` where ``T`` is one of the the :t:`[type]s` listed in this + enumeration. + :dp:`fls_oHxzyaiT7Qm6` The :t:`visibility modifier` of an :t:`associated trait item` or :t:`associated trait implementation item` is rejected, but may still be consumed by diff --git a/src/implementations.rst b/src/implementations.rst index 41934d62..ac4ee5c0 100644 --- a/src/implementations.rst +++ b/src/implementations.rst @@ -37,8 +37,8 @@ Implementations .. rubric:: Legality Rules :dp:`fls_ivxpoxggy7s6` -An :t:`implementation` is an :t:`item` that supplements an :t:`implementing -type` by extending its functionality. +An :t:`implementation` is an :t:`item` that supplements an +:t:`implementing type` by extending its functionality. :dp:`fls_yopmjbnw8tbl` An :t:`implementing type` is the :t:`type` that the :t:`[associated item]s` of