Yuki Okushi
7ba519ec50
Rollup merge of #78255 - dtolnay:match, r=lcnr
Reduce diagram mess in 'match arms have incompatible types' error
I noticed this wild diagram in https://twitter.com/a_hoverbear/status/1318960787105353728 which I think does not benefit from the big outer vertical span.
This PR shrinks the outer span to cover just the `match` keyword and scrutinee expression *if* at least one of the highlighted match arms involved in the error is multiline.
**Before:**
<pre>
<b>error[E0308]: `match` arms have incompatible types</b>
<b>--></b> src/topology/builder.rs:141:35
<b>|</b>
<b>120 |</b> let transform = match transform {
<b>| _________________________-</b>
<b>121 | |</b> Transform::Function(t) => {
<b>| _|_______________________________________-</b>
<b>122 | | |</b> filter_event_type(input_rx, input_type).compat().flat_map(|v| {
<b>123 | | |</b> futures::stream::iter(match v {
<b>124 | | |</b> Err(e) => {
<b>... | |</b>
<b>139 | | |</b> .compat();
<b>140 | | |</b> }
<b>| |_|_____________- this is found to be of type `()`</b>
<b>141 | |</b> Transform::Task(t) => t
<b>| _|___________________________________^</b>
<b>142 | | |</b> .transform(filter_event_type(input_rx, input_type))
<b>143 | | |</b> .forward(output)
<b>144 | | |</b> .map(|_| debug!("Finished"))
<b>145 | | |</b> .compat(),
<b>| |_|_________________________^ expected `()`, found struct `futures::compat::Compat01As03`</b>
<b>146 | |</b> };
<b>| |_________- `match` arms have incompatible types</b>
<b>|</b>
<b>= note:</b> expected type `<b>()</b>`
found struct `<b>futures::compat::Compat01As03<futures::Map<futures::stream::Forward<std::boxed::Box<dyn futures::Stream<Error = (), Item = event::Event> + std::marker::Send>, topology::fanout::Fanout>, [closure@src/topology/builder.rs:144:22: 144:44]>></b>`
</pre>
**After:**
<pre>
<b>error[E0308]: `match` arms have incompatible types</b>
<b>--></b> src/topology/builder.rs:141:35
<b>|</b>
<b>120 |</b> let transform = match transform {
<b>| --------------- `match` arms have incompatible types</b>
<b>121 |</b> Transform::Function(t) => {
<b>| _________________________________________-</b>
<b>122 | |</b> filter_event_type(input_rx, input_type).compat().flat_map(|v| {
<b>123 | |</b> futures::stream::iter(match v {
<b>124 | |</b> Err(e) => {
<b>... |</b>
<b>139 | |</b> .compat();
<b>140 | |</b> }
<b>| |_______________- this is found to be of type `()`</b>
<b>141 |</b> Transform::Task(t) => t
<b>| _____________________________________^</b>
<b>142 | |</b> .transform(filter_event_type(input_rx, input_type))
<b>143 | |</b> .forward(output)
<b>144 | |</b> .map(|_| debug!("Finished"))
<b>145 | |</b> .compat(),
<b>| |___________________________^ expected `()`, found struct `futures::compat::Compat01As03`</b>
<b>|</b>
<b>= note:</b> expected type `<b>()</b>`
found struct `<b>futures::compat::Compat01As03<futures::Map<futures::stream::Forward<std::boxed::Box<dyn futures::Stream<Error = (), Item = event::Event> + std::marker::Send>, topology::fanout::Fanout>, [closure@src/topology/builder.rs:144:22: 144:44]>></b>`
</pre>
FYI @Hoverbear
2020-10-23 18:26:40 +09:00
..
2020-10-04 02:02:25 +02:00
2020-10-20 17:01:51 +02:00
2020-10-21 15:03:14 +00:00
2020-10-18 13:50:31 +00:00
2020-10-16 15:21:16 -03:00
2020-10-20 16:42:51 +02:00
2020-10-11 11:11:33 -04:00
2020-10-15 12:02:24 +02:00
2020-10-21 21:11:11 +01:00
2020-10-17 13:28:58 +02:00
2020-10-19 15:14:15 +00:00
2020-10-16 02:10:09 +02:00
2020-10-17 05:36:49 +09:00
2020-10-14 04:14:32 +02:00
2020-10-19 12:30:41 -04:00
2020-10-21 23:41:26 +01:00
2020-10-14 04:14:32 +02:00
2020-10-19 11:57:50 +03:00
2020-10-19 16:26:13 -03:00
2020-10-22 16:16:02 -07:00
2020-10-14 02:30:38 +02:00
2020-10-09 11:12:54 +02:00
2020-10-22 09:45:38 +09:00
2020-10-11 20:50:02 +00:00
2020-10-21 23:59:35 +02:00
2020-10-19 11:57:50 +03:00
2020-10-23 18:26:40 +09:00
2020-10-22 01:35:05 +00:00
2020-10-23 18:26:28 +09:00
2020-10-22 13:22:12 -03:00
2020-10-22 09:45:33 +09:00
2020-10-19 11:57:50 +03:00
2020-10-22 12:24:55 +00:00
2020-10-22 07:05:21 +00:00
2020-10-13 14:16:45 +02:00
2020-10-15 12:02:24 +02:00
2020-10-16 15:13:28 -03:00
2020-10-21 21:11:11 +01:00
2020-10-15 12:02:24 +02:00
2020-10-22 08:18:29 +01:00
2020-10-16 12:58:50 -04:00
2020-10-19 11:57:50 +03:00
2020-10-23 18:26:40 +09:00