Mark CondCode's functions #[must_use].

It's easy to forget whether they mutate the value in place or return a
new value. Marking them #[must_use] will catch cases where they are used
incorrectly.
This commit is contained in:
Dan Gohman
2018-03-27 14:12:06 -07:00
parent 79f02e42dd
commit 0b5bb313cb

View File

@@ -13,12 +13,14 @@ pub trait CondCode: Copy {
/// ///
/// The inverse condition code produces the opposite result for all comparisons. /// The inverse condition code produces the opposite result for all comparisons.
/// That is, `cmp CC, x, y` is true if and only if `cmp CC.inverse(), x, y` is false. /// That is, `cmp CC, x, y` is true if and only if `cmp CC.inverse(), x, y` is false.
#[must_use]
fn inverse(self) -> Self; fn inverse(self) -> Self;
/// Get the reversed condition code for `self`. /// Get the reversed condition code for `self`.
/// ///
/// The reversed condition code produces the same result as swapping `x` and `y` in the /// The reversed condition code produces the same result as swapping `x` and `y` in the
/// comparison. That is, `cmp CC, x, y` is the same as `cmp CC.reverse(), y, x`. /// comparison. That is, `cmp CC, x, y` is the same as `cmp CC.reverse(), y, x`.
#[must_use]
fn reverse(self) -> Self; fn reverse(self) -> Self;
} }