Skip to content

Commit 6aa4947

Browse files
committed
Update expressions.rst
some minor edits
1 parent 9671a8a commit 6aa4947

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/coding-guidelines/expressions.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Expressions
77
===========
88

9-
109
.. guideline:: Avoid as underscore pointer casts
1110
:id: gui_HDnAZ7EZ4z6G
1211
:category: required
@@ -96,7 +95,7 @@ Expressions
9695
`integer type <https://rust-lang.github.io/fls/types-and-traits.html#integer-types>`_
9796
during a `division expression
9897
<https://rust-lang.github.io/fls/expressions.html#syntax_divisionexpression>`_ or `remainder expression
99-
<https://rust-lang.github.io/fls/expressions.html#syntax_remainderexpression>`_ is when the left operand also has integer type.
98+
<https://rust-lang.github.io/fls/expressions.html#syntax_remainderexpression>`_ when the left operand also has integer type.
10099

101100
This rule applies to the following primitive integer types:
102101

@@ -162,9 +161,10 @@ Expressions
162161
This compliant solution creates a divisor using :std:`std::num::NonZero`.
163162
:std:`std::num::NonZero` is a wrapper around primitive integer types that guarantees the contained value is never zero.
164163
:std:`std::num::NonZero::new` creates a new binding that represents a value that is known not to be zero.
165-
This in turn ensures that functions operating on its value can safely assume that they are not being given zero as their input.
164+
This ensures that functions operating on its value can correctly assume that they are not being given zero as their input.
166165

167-
Note that the test for arithmetic overflow in this compliant example (which is a possibility for non-zero negative divisors, namely, ``-1``) is unnecessary because ``divisor`` is an unsigned integer type.
166+
Note that the test for arithmetic overflow that occurs when dividing the minimum representable value by -1 is unnecessary
167+
in this compliant example because the result of the division expression is an unsigned integer type.
168168

169169
.. code-block:: rust
170170
@@ -191,7 +191,7 @@ Expressions
191191
Division and remainder expressions on signed integers are also susceptible to arithmetic overflow.
192192
Overflow is covered in full by the guideline `Ensure that integer operations do not result in arithmetic overflow`.
193193

194-
This rule applies to the following primitive integer types:
194+
This rule applies to the following primitive integer types:
195195

196196
* ``i8``
197197
* ``i16``
@@ -209,7 +209,6 @@ Expressions
209209
This rule does not apply to evaluation of the :std:`core::ops::Div` trait on types other than `integer
210210
types <https://rust-lang.github.io/fls/types-and-traits.html#integer-types>`_.
211211

212-
213212
This rule is a less strict version of `Do not use an integer type as a divisor during integer division`.
214213
All code that complies with that rule also complies with this rule.
215214

@@ -236,7 +235,7 @@ Expressions
236235
:status: draft
237236

238237
Compliant examples from `Do not use an integer type as a divisor during integer division` are also valid for this rule.
239-
Additionally, the check for zero can also be performed manually, as in this compliant example.
238+
Additionally, the check for zero can be performed manually, as in this compliant example.
240239
However, as the complexity of the control flow leading to the invariant increases,
241240
it becomes increasingly harder for both programmers and static analysis tools to reason about it.
242241

0 commit comments

Comments
 (0)