]> git.lizzy.rs Git - rust.git/blobdiff - src/minmax.rs
added wiki comments + wiki-generating python script
[rust.git] / src / minmax.rs
index 9eb8a030e15357e09f748b3846a2f352924917de..ac8d6f05272070e5e785d18a4a335afa5b7e8d69 100644 (file)
@@ -8,6 +8,13 @@
 use utils::{match_def_path, span_lint};
 use self::MinMax::{Min, Max};
 
+/// **What it does:** This lint checks for expressions where `std::cmp::min` and `max` are used to clamp values, but switched so that the result is constant.
+///
+/// **Why is this bad?** This is in all probability not the intended outcome. At the least it hurts readability of the code.
+///
+/// **Known problems:** None
+///
+/// **Example:** `min(0, max(100, x))` will always be equal to `0`. Probably the author meant to clamp the value between 0 and 100, but has erroneously swapped `min` and `max`.
 declare_lint!(pub MIN_MAX, Warn,
     "`min(_, max(_, _))` (or vice versa) with bounds clamping the result \
     to a constant");