diff options
| author | dswij <dswijj@gmail.com> | 2021-09-07 06:07:50 +0800 |
|---|---|---|
| committer | dswij <dswijj@gmail.com> | 2021-09-08 11:00:27 +0800 |
| commit | dc6f7dc6bf13295d5249c7f2a9aa71024b6555ad (patch) | |
| tree | dd4bf8a2d7a6d3883840bac54faaf3565090a648 | |
| parent | 7515d9c6f77a3325e6142c45ebe1bc78f580b894 (diff) | |
Add known problems to `mut_range_bound` docs
| -rw-r--r-- | clippy_lints/src/loops/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index 97cbe2c53dd..2860cb68f42 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -397,6 +397,21 @@ declare_clippy_lint! { /// ### Why is this bad? /// One might think that modifying the mutable variable changes the loop bounds /// + /// ### Known problems + /// False positive when mutation is followed by a `break`, but the `break` is not immediately + /// after the mutation: + /// + /// ```rust + /// let mut x = 5; + /// for _ in 0..x { + /// x += 1; // x is a range bound that is mutated + /// ..; // some other expression + /// break; // leaves the loop, so mutation is not an issue + /// } + /// ``` + /// + /// False positive on nested loops ([#6072](https://github.com/rust-lang/rust-clippy/issues/6072)) + /// /// ### Example /// ```rust /// let mut foo = 42; |
