7ba519ec50
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 |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |
For high-level intro to how type checking works in rustc, see the type checking chapter of the rustc dev guide.