about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform/coverage/debug.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-06-12 11:12:16 +0000
committerbors <bors@rust-lang.org>2021-06-12 11:12:16 +0000
commit60f1a2fc4b535ead9c85ce085fdce49b1b097531 (patch)
tree759d0461aad1a810641068a70fd73c18c17cce4d /compiler/rustc_mir/src/transform/coverage/debug.rs
parentd59b80d588368cdcfcc1d54e119374a3d78169ff (diff)
parent79dc9a76a6272dc2e080237de27406b1456d7c2c (diff)
downloadrust-60f1a2fc4b535ead9c85ce085fdce49b1b097531.tar.gz
rust-60f1a2fc4b535ead9c85ce085fdce49b1b097531.zip
Auto merge of #86215 - FabianWolff:unnameable-types, r=jackh726
Do not suggest to add type annotations for unnameable types

Consider this example:
```rust
const A = || 42;

struct S<T> { t: T }
const B: _ = S { t: || 42 };
```
This currently produces the following output:
```
error: missing type for `const` item
 --> src/lib.rs:1:7
  |
1 | const A = || 42;
  |       ^ help: provide a type for the item: `A: [closure@src/lib.rs:1:11: 1:16]`

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> src/lib.rs:4:10
  |
4 | const B: _ = S { t: || 42 };
  |          ^
  |          |
  |          not allowed in type signatures
  |          help: replace `_` with the correct type: `S<[closure@src/lib.rs:4:21: 4:26]>`

error: aborting due to 2 previous errors
```
However, these suggestions are obviously useless, because the suggested types cannot be written down. With my changes, the suggestion is replaced with a note, because there is no simple fix:
```
error: missing type for `const` item
 --> test.rs:1:7
  |
1 | const A = || 42;
  |       ^
  |
note: however, the inferred type `[closure@test.rs:1:11: 1:16]` cannot be named
 --> test.rs:1:11
  |
1 | const A = || 42;
  |           ^^^^^

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> test.rs:4:10
  |
4 | const B: _ = S { t: || 42 };
  |          ^ not allowed in type signatures
  |
note: however, the inferred type `S<[closure@test.rs:4:21: 4:26]>` cannot be named
 --> test.rs:4:14
  |
4 | const B: _ = S { t: || 42 };
  |              ^^^^^^^^^^^^^^

error: aborting due to 2 previous errors
```
Diffstat (limited to 'compiler/rustc_mir/src/transform/coverage/debug.rs')
0 files changed, 0 insertions, 0 deletions