From 8d022925458e074b8667fade010e3212b1fa129e Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Fri, 6 Sep 2024 09:56:14 +0200 Subject: [PATCH] Add #[coverage(off)] to Display impls --- Cargo.toml | 5 +++++ src/distribution/beta.rs | 1 + src/distribution/binomial.rs | 1 + src/distribution/categorical.rs | 1 + src/distribution/cauchy.rs | 1 + src/distribution/chi.rs | 1 + src/distribution/dirac.rs | 1 + src/distribution/dirichlet.rs | 1 + src/distribution/discrete_uniform.rs | 1 + src/distribution/exponential.rs | 1 + src/distribution/fisher_snedecor.rs | 1 + src/distribution/gamma.rs | 1 + src/distribution/geometric.rs | 1 + src/distribution/hypergeometric.rs | 1 + src/distribution/inverse_gamma.rs | 1 + src/distribution/laplace.rs | 1 + src/distribution/log_normal.rs | 1 + src/distribution/multinomial.rs | 1 + src/distribution/multivariate_normal.rs | 1 + src/distribution/multivariate_students_t.rs | 1 + src/distribution/negative_binomial.rs | 1 + src/distribution/normal.rs | 1 + src/distribution/pareto.rs | 1 + src/distribution/poisson.rs | 1 + src/distribution/students_t.rs | 1 + src/distribution/triangular.rs | 1 + src/distribution/uniform.rs | 1 + src/distribution/weibull.rs | 1 + src/lib.rs | 1 + src/stats_tests/fisher.rs | 1 + 30 files changed, 34 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 15b06e4e..b295a5fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,3 +44,8 @@ anyhow = "1.0" version = "0.32" default-features = false features = ["macros"] + +[lints.rust.unexpected_cfgs] +level = "warn" +# Set by cargo-llvm-cov when running on nightly +check-cfg = ['cfg(coverage_nightly)'] diff --git a/src/distribution/beta.rs b/src/distribution/beta.rs index db10bf9d..28b05e71 100644 --- a/src/distribution/beta.rs +++ b/src/distribution/beta.rs @@ -36,6 +36,7 @@ pub enum BetaError { } impl std::fmt::Display for BetaError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { BetaError::ShapeAInvalid => write!(f, "Shape A is NaN, zero, or negative"), diff --git a/src/distribution/binomial.rs b/src/distribution/binomial.rs index ea0a6071..3b9601ab 100644 --- a/src/distribution/binomial.rs +++ b/src/distribution/binomial.rs @@ -32,6 +32,7 @@ pub enum BinomialError { } impl std::fmt::Display for BinomialError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { BinomialError::ProbabilityInvalid => write!(f, "Probability is NaN or not in [0, 1]"), diff --git a/src/distribution/categorical.rs b/src/distribution/categorical.rs index a034416f..08135a0e 100644 --- a/src/distribution/categorical.rs +++ b/src/distribution/categorical.rs @@ -39,6 +39,7 @@ pub enum CategoricalError { } impl std::fmt::Display for CategoricalError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { CategoricalError::ProbMassEmpty => write!(f, "Probability mass is empty"), diff --git a/src/distribution/cauchy.rs b/src/distribution/cauchy.rs index 7103796a..37bffaac 100644 --- a/src/distribution/cauchy.rs +++ b/src/distribution/cauchy.rs @@ -32,6 +32,7 @@ pub enum CauchyError { } impl std::fmt::Display for CauchyError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { CauchyError::LocationInvalid => write!(f, "Location is NaN"), diff --git a/src/distribution/chi.rs b/src/distribution/chi.rs index 53b24446..a73f8f81 100644 --- a/src/distribution/chi.rs +++ b/src/distribution/chi.rs @@ -30,6 +30,7 @@ pub enum ChiError { } impl std::fmt::Display for ChiError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { ChiError::FreedomInvalid => { diff --git a/src/distribution/dirac.rs b/src/distribution/dirac.rs index ab6de495..7a53284c 100644 --- a/src/distribution/dirac.rs +++ b/src/distribution/dirac.rs @@ -24,6 +24,7 @@ pub enum DiracError { } impl std::fmt::Display for DiracError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { DiracError::ValueInvalid => write!(f, "Value v is NaN"), diff --git a/src/distribution/dirichlet.rs b/src/distribution/dirichlet.rs index 2441adf7..aa16ed5b 100644 --- a/src/distribution/dirichlet.rs +++ b/src/distribution/dirichlet.rs @@ -41,6 +41,7 @@ pub enum DirichletError { } impl std::fmt::Display for DirichletError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { DirichletError::AlphaTooShort => write!(f, "Alpha contains less than two elements"), diff --git a/src/distribution/discrete_uniform.rs b/src/distribution/discrete_uniform.rs index 322ae1bb..8cd2ef9f 100644 --- a/src/distribution/discrete_uniform.rs +++ b/src/distribution/discrete_uniform.rs @@ -29,6 +29,7 @@ pub enum DiscreteUniformError { } impl std::fmt::Display for DiscreteUniformError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { DiscreteUniformError::MinMaxInvalid => write!(f, "Maximum is less than minimum"), diff --git a/src/distribution/exponential.rs b/src/distribution/exponential.rs index e40cc615..2951b57e 100644 --- a/src/distribution/exponential.rs +++ b/src/distribution/exponential.rs @@ -31,6 +31,7 @@ pub enum ExpError { } impl std::fmt::Display for ExpError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { ExpError::RateInvalid => write!(f, "Rate is NaN, zero, or less than zero"), diff --git a/src/distribution/fisher_snedecor.rs b/src/distribution/fisher_snedecor.rs index 12045995..4b91cf4b 100644 --- a/src/distribution/fisher_snedecor.rs +++ b/src/distribution/fisher_snedecor.rs @@ -35,6 +35,7 @@ pub enum FisherSnedecorError { } impl std::fmt::Display for FisherSnedecorError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { FisherSnedecorError::Freedom1Invalid => { diff --git a/src/distribution/gamma.rs b/src/distribution/gamma.rs index 5c97269b..14939791 100644 --- a/src/distribution/gamma.rs +++ b/src/distribution/gamma.rs @@ -37,6 +37,7 @@ pub enum GammaError { } impl std::fmt::Display for GammaError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { GammaError::ShapeInvalid => write!(f, "Shape is NaN, zero, or less than zero."), diff --git a/src/distribution/geometric.rs b/src/distribution/geometric.rs index 5743b844..6e728056 100644 --- a/src/distribution/geometric.rs +++ b/src/distribution/geometric.rs @@ -31,6 +31,7 @@ pub enum GeometricError { } impl std::fmt::Display for GeometricError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { GeometricError::ProbabilityInvalid => write!(f, "Probability is NaN or not in (0, 1]"), diff --git a/src/distribution/hypergeometric.rs b/src/distribution/hypergeometric.rs index 7952fccd..328fa991 100644 --- a/src/distribution/hypergeometric.rs +++ b/src/distribution/hypergeometric.rs @@ -26,6 +26,7 @@ pub enum HypergeometricError { } impl std::fmt::Display for HypergeometricError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { HypergeometricError::TooManySuccesses => write!(f, "successes > population"), diff --git a/src/distribution/inverse_gamma.rs b/src/distribution/inverse_gamma.rs index cb8bfa0d..0007cbc0 100644 --- a/src/distribution/inverse_gamma.rs +++ b/src/distribution/inverse_gamma.rs @@ -35,6 +35,7 @@ pub enum InverseGammaError { } impl std::fmt::Display for InverseGammaError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { InverseGammaError::ShapeInvalid => { diff --git a/src/distribution/laplace.rs b/src/distribution/laplace.rs index ced4b239..7246758d 100644 --- a/src/distribution/laplace.rs +++ b/src/distribution/laplace.rs @@ -32,6 +32,7 @@ pub enum LaplaceError { } impl std::fmt::Display for LaplaceError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { LaplaceError::LocationInvalid => write!(f, "Location is NaN"), diff --git a/src/distribution/log_normal.rs b/src/distribution/log_normal.rs index 3405551e..f31d3c74 100644 --- a/src/distribution/log_normal.rs +++ b/src/distribution/log_normal.rs @@ -36,6 +36,7 @@ pub enum LogNormalError { } impl std::fmt::Display for LogNormalError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { LogNormalError::LocationInvalid => write!(f, "Location is NaN"), diff --git a/src/distribution/multinomial.rs b/src/distribution/multinomial.rs index d1d78863..d809819a 100644 --- a/src/distribution/multinomial.rs +++ b/src/distribution/multinomial.rs @@ -45,6 +45,7 @@ pub enum MultinomialError { } impl std::fmt::Display for MultinomialError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { MultinomialError::NotEnoughProbabilities => write!(f, "Fewer than two probabilities"), diff --git a/src/distribution/multivariate_normal.rs b/src/distribution/multivariate_normal.rs index 909a7d17..8f66af5e 100644 --- a/src/distribution/multivariate_normal.rs +++ b/src/distribution/multivariate_normal.rs @@ -125,6 +125,7 @@ pub enum MultivariateNormalError { } impl std::fmt::Display for MultivariateNormalError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { MultivariateNormalError::CovInvalid => { diff --git a/src/distribution/multivariate_students_t.rs b/src/distribution/multivariate_students_t.rs index 3a69d02d..13f5faaf 100644 --- a/src/distribution/multivariate_students_t.rs +++ b/src/distribution/multivariate_students_t.rs @@ -59,6 +59,7 @@ pub enum MultivariateStudentError { } impl std::fmt::Display for MultivariateStudentError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { MultivariateStudentError::ScaleInvalid => { diff --git a/src/distribution/negative_binomial.rs b/src/distribution/negative_binomial.rs index 6b5379a3..9001833d 100644 --- a/src/distribution/negative_binomial.rs +++ b/src/distribution/negative_binomial.rs @@ -50,6 +50,7 @@ pub enum NegativeBinomialError { } impl std::fmt::Display for NegativeBinomialError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { NegativeBinomialError::RInvalid => write!(f, "r is NaN or less than zero"), diff --git a/src/distribution/normal.rs b/src/distribution/normal.rs index 2223d6f0..10cfed3f 100644 --- a/src/distribution/normal.rs +++ b/src/distribution/normal.rs @@ -34,6 +34,7 @@ pub enum NormalError { } impl std::fmt::Display for NormalError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { NormalError::MeanInvalid => write!(f, "Mean is NaN"), diff --git a/src/distribution/pareto.rs b/src/distribution/pareto.rs index 90dc79b9..3299e6b4 100644 --- a/src/distribution/pareto.rs +++ b/src/distribution/pareto.rs @@ -34,6 +34,7 @@ pub enum ParetoError { } impl std::fmt::Display for ParetoError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { ParetoError::ScaleInvalid => write!(f, "Scale is NaN, zero, or less than zero"), diff --git a/src/distribution/poisson.rs b/src/distribution/poisson.rs index d3284713..4d477532 100644 --- a/src/distribution/poisson.rs +++ b/src/distribution/poisson.rs @@ -30,6 +30,7 @@ pub enum PoissonError { } impl std::fmt::Display for PoissonError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { PoissonError::LambdaInvalid => write!(f, "Lambda is NaN, zero, or less than zero"), diff --git a/src/distribution/students_t.rs b/src/distribution/students_t.rs index 00902a16..dd492184 100644 --- a/src/distribution/students_t.rs +++ b/src/distribution/students_t.rs @@ -38,6 +38,7 @@ pub enum StudentsTError { } impl std::fmt::Display for StudentsTError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { StudentsTError::LocationInvalid => write!(f, "Location is NaN"), diff --git a/src/distribution/triangular.rs b/src/distribution/triangular.rs index aee3e435..64d6d081 100644 --- a/src/distribution/triangular.rs +++ b/src/distribution/triangular.rs @@ -43,6 +43,7 @@ pub enum TriangularError { } impl std::fmt::Display for TriangularError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { TriangularError::MinInvalid => write!(f, "Minimum is NaN or infinite."), diff --git a/src/distribution/uniform.rs b/src/distribution/uniform.rs index 97a8e27d..eb186fc6 100644 --- a/src/distribution/uniform.rs +++ b/src/distribution/uniform.rs @@ -38,6 +38,7 @@ pub enum UniformError { } impl std::fmt::Display for UniformError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { UniformError::MinInvalid => write!(f, "Minimum is NaN or infinite"), diff --git a/src/distribution/weibull.rs b/src/distribution/weibull.rs index f22fbaff..e5c2225f 100644 --- a/src/distribution/weibull.rs +++ b/src/distribution/weibull.rs @@ -37,6 +37,7 @@ pub enum WeibullError { } impl std::fmt::Display for WeibullError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { WeibullError::ShapeInvalid => write!(f, "Shape is NaN, zero, or less than zero."), diff --git a/src/lib.rs b/src/lib.rs index 56f9b162..7ca3157c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,6 +48,7 @@ #![allow(clippy::excessive_precision)] #![allow(clippy::many_single_char_names)] #![forbid(unsafe_code)] +#![cfg_attr(coverage_nightly, feature(coverage_attribute))] #[macro_use] extern crate approx; diff --git a/src/stats_tests/fisher.rs b/src/stats_tests/fisher.rs index 767de1d3..28f71d65 100644 --- a/src/stats_tests/fisher.rs +++ b/src/stats_tests/fisher.rs @@ -104,6 +104,7 @@ pub enum FishersExactTestError { } impl std::fmt::Display for FishersExactTestError { + #[cfg_attr(coverage_nightly, coverage(off))] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { FishersExactTestError::TableInvalidForHypergeometric(hg_err) => {