Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

ices/99914.rs: fixed with errors #1405

Merged
merged 1 commit into from
Aug 31, 2022
Merged

ices/99914.rs: fixed with errors #1405

merged 1 commit into from
Aug 31, 2022

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#99914

struct Error;

fn foo() {
    let initial_exchange: Result<usize, Error> = todo!();
    initial_exchange.and_then(|_|
        serve_udp_tunnel()
    ).await;
}

async fn serve_udp_tunnel() {}
=== stdout ===
=== stderr ===
error[E0728]: `await` is only allowed inside `async` functions and blocks
 --> /home/runner/work/glacier/glacier/ices/99914.rs:7:6
  |
3 | fn foo() {
  |    --- this is not `async`
...
7 |     ).await;
  |      ^^^^^^ only allowed inside `async` functions and blocks

error[E0601]: `main` function not found in crate `99914`
  --> /home/runner/work/glacier/glacier/ices/99914.rs:10:31
   |
10 | async fn serve_udp_tunnel() {}
   |                               ^ consider adding a `main` function to `/home/runner/work/glacier/glacier/ices/99914.rs`

warning: unreachable statement
 --> /home/runner/work/glacier/glacier/ices/99914.rs:5:5
  |
4 |       let initial_exchange: Result<usize, Error> = todo!();
  |                                                    ------- any code following this expression is unreachable
5 | /     initial_exchange.and_then(|_|
6 | |         serve_udp_tunnel()
7 | |     ).await;
  | |____________^ unreachable statement
  |
  = note: `#[warn(unreachable_code)]` on by default

error[E0308]: mismatched types
  --> /home/runner/work/glacier/glacier/ices/99914.rs:6:9
   |
6  |         serve_udp_tunnel()
   |         ^^^^^^^^^^^^^^^^^^ expected enum `Result`, found opaque type
   |
note: while checking the return type of the `async fn`
  --> /home/runner/work/glacier/glacier/ices/99914.rs:10:29
   |
10 | async fn serve_udp_tunnel() {}
   |                             ^ checked the `Output` of this `async fn`, found opaque type
   = note:     expected enum `Result<_, Error>`
           found opaque type `impl Future<Output = ()>`
help: try wrapping the expression in `Ok`
   |
6  |         Ok(serve_udp_tunnel())
   |         +++                  +

error[E0277]: `Result<_, Error>` is not a future
 --> /home/runner/work/glacier/glacier/ices/99914.rs:7:6
  |
7 |     ).await;
  |      ^^^^^^ `Result<_, Error>` is not a future
  |
  = help: the trait `Future` is not implemented for `Result<_, Error>`
  = note: Result<_, Error> must be a future or must implement `IntoFuture` to be awaited
  = note: required for `Result<_, Error>` to implement `IntoFuture`
help: remove the `.await`
  |
7 -     ).await;
7 +     );
  |

error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0277, E0308, E0601, E0728.
For more information about an error, try `rustc --explain E0277`.
==============

=== stdout ===
=== stderr ===
error[E0728]: `await` is only allowed inside `async` functions and blocks
 --> /home/runner/work/glacier/glacier/ices/99914.rs:7:6
  |
3 | fn foo() {
  |    --- this is not `async`
...
7 |     ).await;
  |      ^^^^^^ only allowed inside `async` functions and blocks

error[E0601]: `main` function not found in crate `99914`
  --> /home/runner/work/glacier/glacier/ices/99914.rs:10:31
   |
10 | async fn serve_udp_tunnel() {}
   |                               ^ consider adding a `main` function to `/home/runner/work/glacier/glacier/ices/99914.rs`

warning: unreachable statement
 --> /home/runner/work/glacier/glacier/ices/99914.rs:5:5
  |
4 |       let initial_exchange: Result<usize, Error> = todo!();
  |                                                    ------- any code following this expression is unreachable
5 | /     initial_exchange.and_then(|_|
6 | |         serve_udp_tunnel()
7 | |     ).await;
  | |____________^ unreachable statement
  |
  = note: `#[warn(unreachable_code)]` on by default

error[E0308]: mismatched types
  --> /home/runner/work/glacier/glacier/ices/99914.rs:6:9
   |
6  |         serve_udp_tunnel()
   |         ^^^^^^^^^^^^^^^^^^ expected enum `Result`, found opaque type
   |
note: while checking the return type of the `async fn`
  --> /home/runner/work/glacier/glacier/ices/99914.rs:10:29
   |
10 | async fn serve_udp_tunnel() {}
   |                             ^ checked the `Output` of this `async fn`, found opaque type
   = note:     expected enum `Result<_, Error>`
           found opaque type `impl Future<Output = ()>`
help: try wrapping the expression in `Ok`
   |
6  |         Ok(serve_udp_tunnel())
   |         +++                  +

error[E0277]: `Result<_, Error>` is not a future
 --> /home/runner/work/glacier/glacier/ices/99914.rs:7:6
  |
7 |     ).await;
  |      ^^^^^^ `Result<_, Error>` is not a future
  |
  = help: the trait `Future` is not implemented for `Result<_, Error>`
  = note: Result<_, Error> must be a future or must implement `IntoFuture` to be awaited
  = note: required for `Result<_, Error>` to implement `IntoFuture`
help: remove the `.await`
  |
7 -     ).await;
7 +     );
  |

error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0277, E0308, E0601, E0728.
For more information about an error, try `rustc --explain E0277`.
==============
@JohnTitor JohnTitor merged commit f3fd0fe into master Aug 31, 2022
@JohnTitor JohnTitor deleted the autofix/ices/99914.rs branch August 31, 2022 10:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants