utoipauto icon indicating copy to clipboard operation
utoipauto copied to clipboard

Workspace path mismatch with Rust Analyzer

Open jssblck opened this issue 6 months ago • 4 comments

Hello! Thanks for taking the time to make this library, it's great!

In #9, an issue was observed with "workspace usage". The decision was that this wasn't truly broken, which is fair, but a problem when the code interacts with Rust Analyzer.

Specifically, I have code like this:

// Workspace is at `/project`, e.g. `/project/Cargo.toml` is the workspace root.

// In `/project/server/src/api.rs`, Rust Analyzer displays an error:
#[utoipauto::utoipauto(paths = "./server/src")]
#[derive(OpenApi)]
#[openapi(
    info(
        description = include_str!("../../docs/api.md"),
    ),
    modifiers(&InfoAddon, &SecurityAddon),
)]
struct ApiDoc;

This causes Rust Analyzer to report the error "Failed to parse file: ./server/src": error

However, the build succeeds:

; cargo clean && cargo build
     Removed 8110 files, 4.5GiB total
   Compiling proc-macro2 v1.0.86
   ...
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 25.44s

Obviously, this isn't a case where the library is broken, but I think this is a case where the library makes assumptions about how the macro is executed that aren't compatible with Rust Analyzer.

Do you have any suggestions for steps I could take to resolve this issue?

jssblck avatar Aug 07 '24 23:08 jssblck