Skip to content

[question] Why some code compile error? #139

Closed
@fawdlstty

Description

@fawdlstty

I had a compiler crash while compiling a piece of code #79783, after fix the bug, I found that the same piece of code failed to compile after using async-trait. Example:

struct A {}
impl A {
    async fn xx_test (&self) {
        match actix_web::HttpServer::new (|| {
            actix_web::App::new ()
        }).bind ("127.0.0.1:8080") {
            Ok (mut _server) => { _server.run ().await; () },
            Err (_e) => println! ("http listen failed: {}", _e.to_string ()),
        }
    }
}

#[async_trait]
pub trait B: Send + Sync {
    async fn test_func (&self);
}
struct C {}
#[async_trait]
impl B for C {
    async fn test_func (&self) {
        // compile error
        match actix_web::HttpServer::new (|| {
            actix_web::App::new ()
        }).bind ("127.0.0.1:8080") {
            Ok (mut _server) => { _server.run ().await; () },
            Err (_e) => println! ("http listen failed: {}", _e.to_string ()),
        }
    }
}

Why is that? How to fix it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions