Parse alternative incorrect uses of await and recover by estebank · Pull Request #60873 · rust-lang/rust (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some people ignore the error message entirely and focus exclusively on the spans. I agree that unnecessary text is suboptimal, but I do not

error[E0728]: `await` is only allowed inside `async` functions and blocks
  --> $DIR/issue-51751.rs:11:20
   |
LL |     let finished = result.await;
   |                    ^^^^^^^^^^^^

vs

error[E0728]: `await` is only allowed inside `async` functions and blocks
  --> $DIR/issue-51751.rs:11:20
   |
LL |     let finished = result.await;
   |                    ^^^^^^^^^^^^ only allowed inside `async` functions and blocks

vs

error[E0728]: `await` is only allowed inside `async` functions and blocks
  --> $DIR/issue-51751.rs:11:20
   |
LL | fn main() {
   |    ---- this is not `async`
LL |     let result = inc(10000);
LL |     let finished = result.await;
   |                    ^^^^^^^^^^^^ only allowed inside `async` functions and blocks

vs

error[E0728]: `await` is only allowed inside `async` functions and blocks
  --> $DIR/issue-51751.rs:11:20
   |
LL | fn main() {
   |    ---- this is not `async`
LL |     let result = inc(10000);
LL |     let finished = result.await;
   |                    ^^^^^^^^^^^^

The last case is what this would be like if we remove the label, which has some text in the secondary label, but no text on the primary label, which I feel is suboptimal.