Skip to content

Commit

Permalink
Merge #420
Browse files Browse the repository at this point in the history
420: Specify what a valid receiver is r=tshepang a=Veykril

Closes #411

Co-authored-by: Lukas Wirth <[email protected]>
  • Loading branch information
bors-ferrocene[bot] and Veykril authored Aug 4, 2023
2 parents 250a237 + 96bf69d commit bd2964d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 22 deletions.
21 changes: 20 additions & 1 deletion src/associated-items.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,26 @@ 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_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<T> <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
Expand Down
8 changes: 6 additions & 2 deletions src/entities-and-resolution.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions src/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand All @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions src/implementations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/types-and-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit bd2964d

Please sign in to comment.