[RFC PATCH 5/5] doc: rust: safety standard: add justifications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add standardized justifications that are used to justify the safety
requirements.

Signed-off-by: Benno Lossin <benno.lossin@xxxxxxxxx>
---
 Documentation/rust/safety-standard/index.rst  |  5 +++
 .../rust/safety-standard/justifications.rst   | 40 +++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 Documentation/rust/safety-standard/justifications.rst

diff --git a/Documentation/rust/safety-standard/index.rst b/Documentation/rust/safety-standard/index.rst
index 2ef82d7dfbd8..db62ad01ebe0 100644
--- a/Documentation/rust/safety-standard/index.rst
+++ b/Documentation/rust/safety-standard/index.rst
@@ -191,6 +191,8 @@ block. For example::
 
 In this case it is more readable to not split the block into multiple parts.
 
+See justifications.rst for a full list of standardized justifications.
+
 ``unsafe`` Traits
 -----------------
 
@@ -225,6 +227,8 @@ similarly to :ref:`unsafe-Blocks`::
     // SAFETY: <justification>
     unsafe impl Foo for Bar {}
 
+See justifications.rst for a full list of standardized justifications.
+
 Guarantees
 ==========
 
@@ -267,6 +271,7 @@ Further Pages
    guarantee
    type-invariants
    requirements
+   justifications
 
 .. only::  subproject and html
 
diff --git a/Documentation/rust/safety-standard/justifications.rst b/Documentation/rust/safety-standard/justifications.rst
new file mode 100644
index 000000000000..72b6943f3d40
--- /dev/null
+++ b/Documentation/rust/safety-standard/justifications.rst
@@ -0,0 +1,40 @@
+.. SPDX-License-Identifier: GPL-2.0
+.. highlight:: rust
+
+==============
+Justifications
+==============
+
+Since there are so many different safety-requirements.rst, there are also many different ways to
+justify them.
+
+Justifications are listed in an unordered markdown list in the ``SAFETY`` comments on ``unsafe``
+blocks and ``unsafe impl``. The order and elements of the list must match the list present in the
+``# Safety`` section on the respective ``unsafe`` item (e.g. the function or the trait).
+
+Common Justifications
+=====================
+
+In order to use the justifications from the table below, first repeat the safety requirement and
+then write ``by <justification>`` where justification is from the table below.
+If you need the conjunction of multiple justifications, then you just intersperse them with "and".
+
+The term "goal safety requirement" is referring to the requirement that you are trying to justify.
+
++---------------------------+----------------------------------------------------------------------+
+| Syntax                    | Meaning/Justified Safety Requirement                                 |
++===========================+======================================================================+
+| function requirements     | The goal safety requirement is provided by the surrounding function, |
+|                           | as it also has it (or a stronger statement) as a safety requirement. |
++---------------------------+----------------------------------------------------------------------+
+| type invariant of ``T``   | The given safety requirement is provided by the type invariant of    |
+|                           | ``T``, as it also has it (or a stronger statement) as a type         |
+|                           | invariant.                                                           |
++---------------------------+----------------------------------------------------------------------+
+| reference validity        | When turning a (mutable) reference into a pointer, that pointer will |
+|                           | be valid for reads (and writes).                                     |
++---------------------------+----------------------------------------------------------------------+
+| function guarantee of     | The goal safety requirement is provided by the called function       |
+| ``$function``             | ``$function``, as it has it (or a stronger statement) listed as a    |
+|                           | :doc:`guarantee <guarantee>`.                                        |
++---------------------------+----------------------------------------------------------------------+
-- 
2.45.1







[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux