#Removing "unreachable" code makes compilation fail.

8 messages · Page 1 of 1 (latest)

north aurora
pseudo oracle
#

In both cases rustc is correct, it's unreachable, and by removing it you make rustc infer the block returns a () because of the current fallback rules of !

sour idol
#

That's neat. I didn't know you could use ? to return from an async block. In this case you should just add #[allow(unreachable_code)] to the last line. If this was a closure, I'd say to specify the return type, but you can't here. Assuming you're doing other things after this, at least. Taking the entire function into account, you should just remove the spawn and async blocks entirely.

north aurora
#

this is just a small cut-out, theres more things happening after spawn

sour idol
#

Another layer to this is that there's a subconscious assumption that all rust warnings indicate a fixable problem, which really shows the quality of warnings in rust. If this was another language, people would put the allow on there without a second thought.

wanton gyro
#

can you annotate async block return types?

pseudo oracle
#

Not currently, there have been ideas for a syntax to do it