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

Prusti attempts to verify local dependencies #713

Closed
emlaufer opened this issue Oct 12, 2021 · 7 comments · Fixed by #774
Closed

Prusti attempts to verify local dependencies #713

emlaufer opened this issue Oct 12, 2021 · 7 comments · Fixed by #774
Labels
enhancement New feature or request

Comments

@emlaufer
Copy link
Contributor

I am attempting to use Prusti to verify a crate that has other local crates as dependencies. Currently when I run the verifier, it is attempting to also validate the dependencies as they compile. Is it possible to treat the local crates like external libraries, such that they are not validated, and I can write external specifications for them instead.

@fpoli fpoli added the question label Oct 13, 2021
@fpoli
Copy link
Member

fpoli commented Oct 13, 2021

cargo-prusti is designed to behave like cargo check and in particular it should accept the same arguments. If I'm not mistaken by default cargo check checks all the local dependencies and you can select a specific package with cargo check -p <package_name>. So, could you try if cargo-prusti -p <package_name> does what you want?

@emlaufer
Copy link
Contributor Author

Unfortunately the -p argument doesn't seem to fix this. -p allows me to only check the dependency without the main package, however when specifying the main package it still ends up checking the dependency. It looks like there has been some discussion on the main cargo page about silencing warnings in path dependencies here, but I don't think it has been fixed yet. In any case, an easy work around is to just push the dependency to git and use the git repository to specify the dependency instead.

@fpoli
Copy link
Member

fpoli commented Oct 19, 2021

For the record, clippy builds on top of cargo check and had the same issue (rust-lang/rust-clippy#3025). They ended up adding a --no-deps command line argument (rust-lang/rust-clippy#6188). We could do something similar.

All our "skip verification of crate" logic is in these 11 lines:

// If the environment asks us to actually be rustc, or if lints have been disabled (which
// indicates that an upstream dependency is being compiled), then run `rustc` instead of Prusti.
let prusti_be_rustc = config::be_rustc();
let are_lints_disabled =
arg_value(&original_rustc_args, "--cap-lints", |val| val == "allow").is_some();
let is_prusti_package = env::var("CARGO_PKG_NAME")
.map(|name| PRUSTI_PACKAGES.contains(&name.as_str()))
.unwrap_or(false);
if prusti_be_rustc || are_lints_disabled || is_prusti_package {
rustc_driver::main();
}

@fpoli fpoli added enhancement New feature or request and removed question labels Oct 19, 2021
@Pointerbender
Copy link
Contributor

@fpoli I have been playing with the rustc arguments over the weekend and got a little more familiar with it :) This enhancement seems like something I could add. What would be the best way to add this to Prusti? As a --no-deps CLI argument to Prusti or as a new NO_VERIFY_DEPS configuration flag?

@Pointerbender
Copy link
Contributor

Created PR #774 just now with a proposal for how a solution for this enhancement could look like.

@fpoli
Copy link
Member

fpoli commented Nov 23, 2021

A configuration flag sounds good to me. They can be enabled in many ways (with an environment variable, with the Prusti.toml and even with a -P<flag> special argument to rustc).

@Pointerbender
Copy link
Contributor

Pointerbender commented Nov 23, 2021

@emlaufer please try if it works for you by either adding this line to your Prusti.toml:

no_verify_deps = true

or by setting an environment variable when running cargo-prusti on the command line:

PRUSTI_NO_VERIFY_DEPS=true cargo-prusti

(this new configuration flag was just merged to the master branch today)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants