about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/coverage/query.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-01-28 09:46:22 +0000
committerbors <bors@rust-lang.org>2022-01-28 09:46:22 +0000
commite0e70c0c2c4fc8d150a56c181994e3a3b3e9999a (patch)
tree0b7df5ec78235f4f7280b7bab5d7157bda5b208e /compiler/rustc_mir_transform/src/coverage/query.rs
parent312a7995e73e390646bc61920ffead7a640addc6 (diff)
parenta8bac9879a36d01c1fc325ed85d6a992deab88fa (diff)
downloadrust-e0e70c0c2c4fc8d150a56c181994e3a3b3e9999a.tar.gz
rust-e0e70c0c2c4fc8d150a56c181994e3a3b3e9999a.zip
Auto merge of #90677 - bobrippling:suggest-tuple-parens, r=camelid
Suggest tuple-parentheses for enum variants

This follows on from #86493 / #86481, making the parentheses suggestion. To summarise, given the following code:

```rust
fn f() -> Option<(i32, i8)> {
    Some(1, 2)
}
```

The current output is:

```
error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied
 --> b.rs:2:5
  |
2 |     Some(1, 2)
  |     ^^^^ -  - supplied 2 arguments
  |     |
  |     expected 1 argument

error: aborting due to previous error

For more information about this error, try `rustc --explain E0061`.
```

With this change, `rustc` will now suggest parentheses when:
- The callee is expecting a single tuple argument
- The number of arguments passed matches the element count in the above tuple
- The arguments' types match the tuple's fields

```
error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied
 --> b.rs:2:5
  |
2 |     Some(1, 2)
  |     ^^^^ -  - supplied 2 arguments
  |
help: use parentheses to construct a tuple
  |
2 |     Some((1, 2))
  |          +    +
```
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/query.rs')
0 files changed, 0 insertions, 0 deletions