Files
rust/tests/ui
Philipp Krones e1d13c34b0 Rollup merge of #5408 - dtolnay:matchbool, r=flip1995
Downgrade match_bool to pedantic

I don't quite buy the justification in https://rust-lang.github.io/rust-clippy/. The justification is:

> It makes the code less readable.

In the Rust codebases I've worked in, I have found people were comfortable using `match bool` (selectively) to make code more readable. For example, initializing struct fields is a place where the indentation of `match` can work better than the indentation of `if`:

```rust
let _ = Struct {
    v: {
        ...
    },
    w: match doing_w {
        true => ...,
        false => ...,
    },
    x: Nested {
        c: ...,
        b: ...,
        a: ...,
    },
    y: if doing_y {
        ...
    } else { // :(
        ...
    },
    z: ...,
};
```

Or sometimes people prefer something a bit less pithy than `if` when the meaning of the bool doesn't read off clearly from the condition:

```rust
if set.insert(...) {
    ... // ???
} else {
    ...
}

match set.insert(...) {
    // set.insert returns false if already present
    false => ...,
    true => ...,
}
```

Or `match` can be a better fit when the bool is playing the role more of a value than a branch condition:

```rust
impl ErrorCodes {
    pub fn from(b: bool) -> Self {
        match b {
            true => ErrorCodes::Yes,
            false => ErrorCodes::No,
        }
    }
}
```

And then there's plain old it's-1-line-shorter, which means we get 25% more content on a screen when stacking a sequence of conditions:

```rust
let old_noun = match old_binding.is_import() {
    true => "import",
    false => "definition",
};
let new_participle = match new_binding.is_import() {
    true => "imported",
    false => "defined",
};
```

Bottom line is I think this lint fits the bill better as a pedantic lint; I don't think linting on this by default is justified.

changelog: Remove match_bool from default set of enabled lints
2020-04-25 21:06:26 +02:00
..
2020-03-04 00:56:43 +01:00
2019-08-26 15:28:35 +02:00
2020-01-07 18:38:12 +09:00
2019-01-08 21:46:39 +01:00
2019-09-27 18:01:04 +02:00
2020-04-19 10:56:15 -04:00
2020-04-19 10:56:15 -04:00
2020-01-31 20:21:10 +01:00
2020-01-07 18:38:12 +09:00
2020-01-07 18:38:12 +09:00
2020-01-07 18:38:12 +09:00
2020-01-07 18:38:12 +09:00
2019-10-15 09:58:11 +02:00
2020-01-31 20:21:10 +01:00
2019-10-15 09:58:11 +02:00
2020-01-07 18:38:12 +09:00
2019-12-21 16:20:30 +01:00
2019-12-21 16:20:30 +01:00
2020-01-07 18:38:12 +09:00
2019-07-19 07:29:25 +02:00
2019-03-10 22:07:10 +01:00
2019-02-18 19:36:58 -07:00
2020-01-07 18:38:12 +09:00
2020-02-01 20:28:27 +09:00
2020-01-07 18:38:12 +09:00
2020-04-19 21:00:25 +02:00
2019-12-21 16:20:30 +01:00
2019-12-21 16:20:30 +01:00
2019-11-07 17:11:06 +01:00
2019-11-07 17:11:06 +01:00
2019-11-07 17:11:06 +01:00
2019-11-07 17:11:06 +01:00
2019-11-07 17:11:06 +01:00
2019-10-18 07:40:48 +02:00
2020-01-26 07:01:16 +09:00
2020-01-12 19:54:17 +08:00
2020-01-12 19:54:17 +08:00
2019-04-30 16:45:28 -03:00
2019-04-30 16:45:28 -03:00
2020-01-26 07:01:16 +09:00
2019-04-30 16:45:28 -03:00
2020-01-26 07:01:16 +09:00
2020-04-09 08:08:36 +02:00
2020-03-03 18:06:59 -08:00
2020-02-23 22:36:15 -08:00
2020-02-23 22:36:15 -08:00
2020-02-01 20:28:27 +09:00
2020-01-07 18:38:12 +09:00
2019-10-15 09:58:11 +02:00
2020-04-17 13:54:05 +02:00
2019-03-09 13:48:06 -08:00
2020-01-31 20:21:10 +01:00
2020-01-31 20:21:10 +01:00
2020-04-20 15:47:08 -04:00
2020-01-19 10:14:03 +09:00
2020-01-07 18:38:12 +09:00
2020-01-07 18:38:12 +09:00
2019-01-08 21:46:39 +01:00
2019-12-24 03:06:52 +07:00
2019-12-24 03:06:52 +07:00
2020-01-31 20:21:10 +01:00
2020-01-07 18:38:12 +09:00
2020-01-04 11:20:11 -06:00
2020-01-04 11:20:11 -06:00
2020-01-04 11:20:11 -06:00
2019-10-15 09:58:11 +02:00
2020-01-26 07:01:16 +09:00
2020-01-26 07:01:16 +09:00
2020-01-07 18:38:12 +09:00
2019-10-15 09:58:11 +02:00
2019-10-15 09:58:11 +02:00
2019-08-01 22:20:08 +09:00
2019-04-25 19:41:23 -07:00
2020-01-07 18:38:12 +09:00
2019-10-26 21:54:04 +02:00
2020-01-14 08:32:33 +09:00
2020-01-14 08:32:33 +09:00
2019-12-22 11:26:51 +02:00
2019-12-22 11:26:51 +02:00
2020-01-07 18:38:12 +09:00
2019-10-15 09:58:11 +02:00
2020-01-07 18:38:12 +09:00
2020-04-23 16:30:06 -07:00
2020-02-04 22:53:24 +01:00
2020-01-30 12:06:42 +09:00
2020-01-30 12:06:42 +09:00
2020-01-07 18:38:12 +09:00
2019-12-31 09:22:35 -08:00
2020-01-07 18:38:12 +09:00
2020-01-10 04:35:37 +09:00
2020-01-07 18:38:12 +09:00
2020-01-07 18:38:12 +09:00
2020-01-07 18:38:12 +09:00
2020-01-07 18:38:12 +09:00
2019-07-01 07:22:04 +02:00
2018-12-28 12:41:12 +01:00
2020-01-14 08:32:33 +09:00
2020-01-26 07:01:16 +09:00
2019-09-20 23:21:37 +09:00
2019-12-03 18:37:07 +01:00
2020-01-07 18:38:12 +09:00
2019-08-19 05:41:47 +00:00
2019-08-19 05:41:47 +00:00
2020-01-31 20:21:10 +01:00
2020-01-07 18:38:12 +09:00
2020-01-07 18:38:12 +09:00
2020-04-01 12:15:39 -07:00
2020-04-01 20:14:05 +02:00
2020-01-31 20:21:10 +01:00
2019-10-18 07:40:48 +02:00
2019-10-18 07:40:48 +02:00
2019-10-18 07:40:48 +02:00
2019-10-18 07:40:48 +02:00
2020-04-17 09:27:54 +02:00
2020-04-17 09:27:54 +02:00
2019-01-08 21:46:39 +01:00
2020-03-03 10:48:08 +01:00
2020-02-04 22:53:24 +01:00
2020-02-04 22:53:24 +01:00
2020-02-04 22:53:24 +01:00
2019-10-03 08:10:29 +09:00
2019-10-26 21:54:04 +02:00
2019-12-18 18:59:43 +02:00
2020-01-07 18:38:12 +09:00
2020-03-20 22:52:53 +00:00
2019-01-08 21:46:39 +01:00
2020-04-08 08:37:20 -07:00
2019-10-14 12:09:04 +02:00
2019-10-14 12:09:04 +02:00
2020-01-07 18:38:12 +09:00
2020-03-31 16:13:51 +05:30
2020-01-20 10:56:02 +09:00
2020-01-20 21:07:31 +09:00
2019-10-15 09:58:11 +02:00
2019-10-15 09:58:11 +02:00
2019-08-15 22:58:32 +02:00
2020-03-04 00:56:43 +01:00
2020-03-04 00:56:43 +01:00
2019-12-03 13:42:05 +01:00
2019-11-10 15:52:59 +02:00
2020-01-20 11:16:50 +09:00
2019-04-02 11:39:43 -03:00
2020-01-31 20:21:10 +01:00
2019-11-25 18:12:52 +03:00
2019-11-25 18:12:52 +03:00
2020-01-07 18:38:12 +09:00
2019-03-10 18:06:28 +00:00
2019-08-23 05:42:45 +00:00
2020-04-02 18:31:31 -07:00
2020-04-01 20:12:36 +02:00
2020-04-01 20:12:36 +02:00
2019-10-26 21:54:04 +02:00
2019-12-27 22:07:55 +09:00
2019-12-27 22:07:55 +09:00
2019-12-27 22:07:55 +09:00
2020-01-07 18:38:12 +09:00
2019-08-13 21:50:52 +02:00
2019-08-13 21:50:52 +02:00
2019-08-13 21:50:52 +02:00
2019-08-14 19:34:50 +02:00
2019-08-14 19:34:50 +02:00
2019-08-14 19:35:17 +02:00
2020-01-31 20:21:10 +01:00
2020-01-07 18:38:12 +09:00
2020-03-29 22:22:36 +02:00
2019-10-15 09:58:11 +02:00
2019-10-15 09:58:11 +02:00
2020-01-31 20:21:10 +01:00
2019-10-18 07:40:48 +02:00
2020-01-26 07:01:16 +09:00
2020-01-12 06:08:58 +09:00
2020-01-12 06:08:58 +09:00
2020-03-11 06:35:07 +09:00
2020-01-25 18:06:52 +03:00
2019-01-08 21:46:39 +01:00
2019-01-08 21:46:39 +01:00
2020-03-10 18:00:37 -04:00
2020-03-10 18:00:37 -04:00
2019-05-08 09:24:24 +02:00
2020-03-23 16:45:31 +00:00
2019-11-15 22:39:27 +01:00
2019-11-15 22:39:27 +01:00
2019-10-02 22:38:00 +07:00