I get a compiler message saying the trait is not implemented while it is implemented

I am trying to migrate from actix 2 to actix 3. I have an Error type called Err which implements display and actix_web::ResponseError yet compiler complains that it doesnt implement ResponseError.

impl actix_web::ResponseError for Err {
    fn status_code(&self) -> StatusCode {
        StatusCode::FORBIDDEN
    }
    fn error_response(&self) -> actix_web::web::HttpResponse {
        HttpResponse::Forbidden().json(json!({"success":false,"reason":self}))
    }
}

Well without knowing more about your source code it might be quite likely that you don't have the mentioned trait in scope when accessing methods of it.

So in the file throwing the error you should have a use clause like this for the trait:

use actix_web::ResponseError;

using didnt help. I shared above the relevant part and in v2 this was no problem but this more looks like a rust error rather than actix error

so basically the problem was one of my workspace members depending on the previous version of actix.
The compiler apparently cannot detect that and gives error because actix_v3::ResponseError is really not implemented actix_V2 was

1 Like

I've run into this problem recently, and is a very frustrating one. I'd love to see better handling of this. It seems that this is one of the few cases where semantic versioning is likely to break. I believe I ran into a case where some crate (don't know which) bumped a version of a dependency that broke my program when another crate failed to do so. :frowning:

1 Like

Bumping a dependency for which something of it is publicly visible through your own crate is a semver breaking change.

Yes, but not everyone (including myself) will think about that, and even if they do, the result is that there will be an ever greater churn of minor version number bumps triggering this kind of issue as not every crate has yet coped with every other crate that just bumped their minor version.

RFC1977 should help with this once it is implemented: https://github.com/rust-lang/rust/issues/44663

1 Like

Yes, that sounds wonderful!