Skip to content

Compilation error in src/controllers/auth.rs on fresh project (Type Inference) #33

@imaazkhalid

Description

@imaazkhalid

After creating a new project using the kit CLI, the application fails to compile due to type inference errors in the generated src/controllers/auth.rs file.
This occurs specifically when using the inertia_response! macro inside an Ok(...)? block with a status code override.

Error Output

     error[E0282]: type annotations needed
       --> src/controllers/auth.rs:41:19
        |
     41 |           return Ok(inertia_response!(
        |  ___________________^
     42 | |             "auth/Login",
     43 | |             LoginProps {
     44 | |                 errors: Some(serde_json::json!(errors))
     45 | |             }
     46 | |         )?
        | |_________^ cannot infer type
   
    error[E0283]: type annotations needed
      --> src/controllers/auth.rs:46:10
       |
    46 |         )?
       |          ^ cannot infer type
       |
       = note: multiple `impl`s satisfying `HttpResponse: From<_>` found in the following crates: `core`, `kit_rs`:
               - impl From<AppError> for HttpResponse;
               - impl From<FrameworkError> for HttpResponse;

Affected Code
The boilerplate code looks like this:

1 return Ok(inertia_response!(
2     "auth/Login",
3     LoginProps {
4         errors: Some(serde_json::json!(errors))
5     }
6 )?
7 .status(422));

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