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

Incorrect Error Reporting when Verifying Project containing Cargo Workspace #218

Closed
Patrick-6 opened this issue Mar 27, 2023 · 2 comments · Fixed by #253
Closed

Incorrect Error Reporting when Verifying Project containing Cargo Workspace #218

Patrick-6 opened this issue Mar 27, 2023 · 2 comments · Fixed by #253
Labels
bug Something isn't working

Comments

@Patrick-6
Copy link

Having a Rust project with a workspace and a subcrate, i.e., in Cargo.toml:

[workspace]
members = ["subcrate"]

Running verification with the Cargo.toml of the workspace in focus works as expected, but clicking Verify with Prusti when a file of the subcrate is in focus, will lead to incorrect error reporting by Prusti-Assistant:

Error when running from Cargo.toml:

lib.rs subcrate\src
[Prusti Verification Error] ...

Incorrect error when running on lib.rs directly:

lib.rs subcrate\subcrate\src
[Prusti Verification Error] ...

Clicking on the error will attempt to open the file subcrate/subcrate/src/lib.rs, which doesn't exist.

Running Cargo-Prusti from a terminal gives the same error message when running it from the outer or inner crate, which might be the cause for the problem in Prusti-Assistant:

error: [Prusti: verification error] the asserted expression might not hold
 --> subcrate/src/lib.rs:4:20
  |
4 |     prusti_assert!(x == 10);
  |                    ^^^^^^^
  |
@fpoli fpoli added the bug Something isn't working label Jun 26, 2023
@fpoli
Copy link
Member

fpoli commented Feb 22, 2024

To fix this, we would need to obtain from cargo the root path of the workspace, so that we can use it in place of rootPath on the following line:

primaryFilePath = path.join(rootPath, primaryCallSiteSpans[0].file_name);

For example: cargo metadata --no-deps --offline outputs a JSON with a workspace_root key that seems to be exactly what we need.

@fpoli
Copy link
Member

fpoli commented Feb 22, 2024

Even better, it would be nice to have rust-lang/cargo#9887

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants