Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async/await error does not have line information #68466

Closed
swilcox3 opened this issue Jan 22, 2020 · 1 comment
Closed

Async/await error does not have line information #68466

swilcox3 opened this issue Jan 22, 2020 · 1 comment

Comments

@swilcox3
Copy link

I was porting over my actix-web server to 2.0.0 and async-await and ran into this error while rewriting a test.

The code:

#[actix_rt::test]
async fn test_get_all_files() {
    let test_db = test_setup("test_get_all_files", "test_files", "");
    let mut app = test::init_service(
        App::new()
            .data(ServerGlobals::new_test(&test_db.db))
            .service(web::resource("/get-all-files").to(get_files_and_folders)),
    )
    .await;
    let resp = call_request!(app, "/get-all-files");
    assert_eq!(resp.status(), http::StatusCode::OK);
    let body = test::read_body(resp);
    let paths: Vec<ps_database::DirEntry> = serde_json::from_slice(&body).unwrap();

    let mut answers = std::collections::HashSet::new();
    answers.insert(PathBuf::from("test_files/"));
    answers.insert(PathBuf::from("test_files/write_file"));
    answers.insert(PathBuf::from("test_files/test_original.vwxp"));
    answers.insert(PathBuf::from("test_files/write_file/test_write_file.vwxp"));
    for dir in paths {
        dir.iterate_paths(&mut |path| {
            assert!(path.is_dir() || path.extension().unwrap() == "vwxp");
            answers.remove(path);
        });
    }
    assert_eq!(answers.len(), 0);
}

I received this error message:

error[E0308]: mismatched types
  |
  = note: expected type `&[u8]`
             found type `&impl futures::Future`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

This bug is not about the error itself, I figured out what the error is. test::read_body(resp) needs a .await after it. The issue is that the error had no line information included, so I had to go commenting out sections of code to find out which test had the error. My VSCode showed the red squiggly on the very first character of my main.rs.

@jonas-schievink
Copy link
Contributor

Presumably a duplicate of #68430, so closing in favor of that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants