diff --git a/Cargo.toml b/Cargo.toml index e1b0054..2b07513 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ exclude = ["fuzz", "bitcoind-tests"] large_enum_variant = "allow" # docs say "measure before paying attention to this"; why is it on by default?? similar_names = "allow" # Too many (subjectively) false positives. uninlined_format_args = "allow" # This is a subjective style choice. +indexing_slicing = "allow" # Too many false positives ... would be cool though match_bool = "allow" # Adds extra indentation and LOC. match_same_arms = "allow" # Collapses things that are conceptually unrelated to each other. must_use_candidate = "allow" # Useful for audit but many false positives. @@ -65,7 +66,7 @@ cloned_instead_of_copied = "warn" copy_iterator = "warn" default_trait_access = "warn" doc_link_with_quotes = "warn" -doc_markdown = "allow" +doc_markdown = "warn" empty_enum = "warn" enum_glob_use = "allow" expl_impl_clone_on_copy = "warn" @@ -78,7 +79,7 @@ float_cmp = "warn" fn_params_excessive_bools = "warn" from_iter_instead_of_collect = "warn" if_not_else = "warn" -ignored_unit_patterns = "allow" +ignored_unit_patterns = "warn" implicit_clone = "warn" implicit_hasher = "warn" inconsistent_struct_constructor = "warn" @@ -87,7 +88,7 @@ inefficient_to_string = "allow" inline_always = "warn" into_iter_without_iter = "warn" invalid_upcast_comparisons = "warn" -items_after_statements = "allow" +items_after_statements = "warn" iter_filter_is_ok = "warn" iter_filter_is_some = "warn" iter_not_returning_iterator = "warn" @@ -98,16 +99,15 @@ large_stack_arrays = "warn" large_types_passed_by_value = "warn" linkedlist = "warn" macro_use_imports = "warn" -manual_assert = "allow" +manual_assert = "warn" manual_instant_elapsed = "warn" manual_is_power_of_two = "warn" manual_is_variant_and = "warn" -manual_let_else = "allow" +manual_let_else = "warn" manual_ok_or = "warn" manual_string_new = "warn" many_single_char_names = "warn" -map_unwrap_or = "allow" -match_on_vec_items = "warn" +map_unwrap_or = "warn" match_wild_err_arm = "warn" match_wildcard_for_single_variants = "allow" maybe_infinite_iter = "warn" diff --git a/src/compile.rs b/src/compile.rs index 41f01bb..01a1dc4 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -438,19 +438,6 @@ impl Call { /// takes the list of type `E^(<2^n)` and an initial accumulator of type `A`, /// and it produces the final accumulator of type `A`. fn list_fold(bound: NonZeroPow2Usize, f: &ProgNode) -> Result { - /* f_0 : E × A → A - * f_0 := f - */ - let mut f_array = f.clone(); - - /* (fold f)_1 : E^<2 × A → A - * (fold f)_1 := case IH f_0 - */ - let ctx = f.inference_context(); - let ioh = ProgNode::i().h(ctx); - let mut f_fold = ProgNode::case(ioh.as_ref(), &f_array)?; - let mut i = NonZeroPow2Usize::TWO; - fn next_f_array(f_array: &ProgNode) -> Result { /* f_(n + 1) : E^(2^(n + 1)) × A → A * f_(n + 1) := OIH ▵ (OOH ▵ IH; f_n); f_n @@ -487,6 +474,19 @@ fn list_fold(bound: NonZeroPow2Usize, f: &ProgNode) -> Result Self { - if line == 0 { - panic!("Line must not be zero"); - } + // assert_ne not available in constfn + assert!(line != 0, "line must not be zero",); // Safety: Checked above let line = unsafe { NonZeroUsize::new_unchecked(line) }; - if col == 0 { - panic!("Column must not be zero"); - } + assert!(col != 0, "column must not be zero",); // Safety: Checked above let col = unsafe { NonZeroUsize::new_unchecked(col) }; Self { line, col } @@ -236,7 +233,7 @@ impl fmt::Display for RichError { writeln!(f, "{:width$} |", " ", width = line_num_width)?; let mut lines = file.lines().skip(start_line_index).peekable(); - let start_line_len = lines.peek().map(|l| l.len()).unwrap_or(0); + let start_line_len = lines.peek().map_or(0, |l| l.len()); for (relative_line_index, line_str) in lines.take(n_spanned_lines).enumerate() { let line_num = start_line_index + relative_line_index + 1; diff --git a/src/lib.rs b/src/lib.rs index b16e31b..bdb0bf3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -238,7 +238,7 @@ macro_rules! impl_eq_hash { /// the initial budget. The budget prevents the generated structure from becoming too deep, which /// could cause issues in the code that processes these structures. /// -/// https://github.com/rust-fuzz/arbitrary/issues/78 +/// #[cfg(feature = "arbitrary")] trait ArbitraryRec: Sized { /// Generate a recursive structure from unstructured data. @@ -426,7 +426,7 @@ mod tests { pub fn assert_run_success(self) { match self.run() { - Ok(_) => {} + Ok(()) => {} Err(error) => panic!("Unexpected error: {error}"), } } @@ -620,9 +620,10 @@ fn main() { ) { Ok(_) => panic!("Accepted faulty program"), Err(error) => { - if !error.contains("Expected expression of type `bool`, found type `()`") { - panic!("Unexpected error: {error}") - } + assert!( + error.contains("Expected expression of type `bool`, found type `()`"), + "Unexpected error: {error}", + ); } } } diff --git a/src/witness.rs b/src/witness.rs index 7aa17ec..bb55fe6 100644 --- a/src/witness.rs +++ b/src/witness.rs @@ -114,9 +114,8 @@ impl WitnessValues { /// witnesses will be pruned and which won't be pruned. This check skips unassigned witnesses. pub fn is_consistent(&self, witness_types: &WitnessTypes) -> Result<(), Error> { for name in self.0.keys() { - let declared_ty = match witness_types.get(name) { - Some(ty) => ty, - None => continue, + let Some(declared_ty) = witness_types.get(name) else { + continue; }; let assigned_ty = self.0[name].ty(); if assigned_ty != declared_ty {