Skip to content

Make Polonius report any found errors by default #193

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ slower) -- these are the exact rules described in [the
blogpost][post]. You can also use `-a LocationInsensitive` to use a
location insensitive analysis (faster, but may yield spurious errors).

By default, `cargo run` just prints timing. If you also want to see
the results, try `--show-tuples` (which will show errors) and maybe
`-v` (to show more intermediate computations). You can supply `--help`
to get more docs.
By default, `cargo run` will print any errors found, but otherwise
just prints timing. If you also want to see successful results, try
`--show-tuples` and maybe `-v` (to show more intermediate computations).
You can supply `--help` to get more docs.

### How to generate your own inputs

Expand Down
8 changes: 4 additions & 4 deletions book/src/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ slower) -- these are the exact rules described in [the
blogpost][post]. You can also use `-a LocationInsensitive` to use a
location insensitive analysis (faster, but may yield spurious errors).

By default, `cargo run` just prints timing. If you also want to see
the results, try `--show-tuples` (which will show errors) and maybe
`-v` (to show more intermediate computations). You can supply `--help`
to get more docs.
By default, `cargo run` will print any errors found, but otherwise
just prints timing. If you also want to see successful results, try
`--show-tuples` and maybe `-v` (to show more intermediate computations).
You can supply `--help` to get more docs.

[post]: http://smallcultfollowing.com/babysteps/blog/2018/04/27/an-alias-based-formulation-of-the-borrow-checker/
4 changes: 4 additions & 0 deletions polonius-engine/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ impl<T: FactTypes> Output<T> {
None => Cow::Owned(BTreeMap::default()),
}
}

pub fn has_errors(&self) -> bool {
!(self.errors.is_empty() && self.move_errors.is_empty() && self.subset_errors.is_empty())
}
}

/// Compares errors reported by Naive implementation with the errors
Expand Down
22 changes: 14 additions & 8 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const PKG_DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION");
#[derive(Debug)]
pub struct Options {
algorithm: Algorithm,
show_tuples: bool,
show_tuples: Option<bool>,
skip_timing: bool,
verbose: bool,
graphviz_file: Option<String>,
Expand Down Expand Up @@ -81,7 +81,7 @@ pub fn main(opt: Options) -> Result<(), Error> {
let millis = f64::from(duration.subsec_nanos()) * 0.000_000_001_f64;
println!("Time: {:0.3}s", seconds + millis);
}
if opt.show_tuples {
if opt.show_tuples.unwrap_or_else(|| output.has_errors()) {
dump::dump_output(&output, &output_directory, tables)
.expect("Failed to write output");
}
Expand Down Expand Up @@ -131,11 +131,11 @@ USAGE:
polonius [FLAGS] [OPTIONS] <fact_dirs>...

FLAGS:
-h, --help Prints help information
--show-tuples Show output tuples on stdout
--skip-timing Do not display timing results
-V, --version Prints version information
-v, --verbose Show intermediate output tuples and not just errors
-h, --help Prints help information
--[no-]show-tuples Show output tuples on stdout, or suppress errors
--skip-timing Do not display timing results
-V, --version Prints version information
-v, --verbose Show intermediate output tuples and not just errors

OPTIONS:
-a <algorithm> [default: Naive]
Expand Down Expand Up @@ -163,7 +163,13 @@ ARGS:
// 2) parse args
let options = Options {
algorithm: arg_from_str(&mut args, "-a")?.unwrap_or(Algorithm::Naive),
show_tuples: args.contains("--show-tuples"),
show_tuples: if args.contains("--show-tuples") {
Some(true)
} else if args.contains("--no-show-tuples") {
Some(false)
} else {
None
},
skip_timing: args.contains("--skip-timing"),
verbose: args.contains(["-v", "--verbose"]),
graphviz_file: arg_from_str(&mut args, "--graphviz-file")?,
Expand Down