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 763945d6..e20ea302 100644 --- a/src/distribution/beta.rs +++ b/src/distribution/beta.rs @@ -38,6 +38,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 9f5ffc47..1d86283d 100644 --- a/src/distribution/binomial.rs +++ b/src/distribution/binomial.rs @@ -34,6 +34,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 9cd95a9d..cb3c7ea8 100644 --- a/src/distribution/categorical.rs +++ b/src/distribution/categorical.rs @@ -41,6 +41,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 a8815349..5ba7f69f 100644 --- a/src/distribution/cauchy.rs +++ b/src/distribution/cauchy.rs @@ -34,6 +34,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 cce8535f..796fcd23 100644 --- a/src/distribution/chi.rs +++ b/src/distribution/chi.rs @@ -32,6 +32,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 142f8c12..18e70f9b 100644 --- a/src/distribution/dirac.rs +++ b/src/distribution/dirac.rs @@ -26,6 +26,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 b8aaad86..2670929a 100644 --- a/src/distribution/dirichlet.rs +++ b/src/distribution/dirichlet.rs @@ -43,6 +43,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 be851b62..524bc2a3 100644 --- a/src/distribution/discrete_uniform.rs +++ b/src/distribution/discrete_uniform.rs @@ -31,6 +31,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 1389b1e4..ec30d1f7 100644 --- a/src/distribution/exponential.rs +++ b/src/distribution/exponential.rs @@ -33,6 +33,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 a50ed42a..610da130 100644 --- a/src/distribution/fisher_snedecor.rs +++ b/src/distribution/fisher_snedecor.rs @@ -37,6 +37,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 201d0cfd..b6055c77 100644 --- a/src/distribution/gamma.rs +++ b/src/distribution/gamma.rs @@ -39,6 +39,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 dfb28ef6..41e35f52 100644 --- a/src/distribution/geometric.rs +++ b/src/distribution/geometric.rs @@ -33,6 +33,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 c3ba5a3a..7da6f45a 100644 --- a/src/distribution/hypergeometric.rs +++ b/src/distribution/hypergeometric.rs @@ -28,6 +28,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 1f1bee4b..a36c7e17 100644 --- a/src/distribution/inverse_gamma.rs +++ b/src/distribution/inverse_gamma.rs @@ -37,6 +37,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 d4f6fc16..13f03a55 100644 --- a/src/distribution/laplace.rs +++ b/src/distribution/laplace.rs @@ -34,6 +34,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 9075bfd2..49380d2b 100644 --- a/src/distribution/log_normal.rs +++ b/src/distribution/log_normal.rs @@ -38,6 +38,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 4fcaca1a..aca82a2a 100644 --- a/src/distribution/multinomial.rs +++ b/src/distribution/multinomial.rs @@ -47,6 +47,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 0da93cd4..68b8d098 100644 --- a/src/distribution/multivariate_normal.rs +++ b/src/distribution/multivariate_normal.rs @@ -127,6 +127,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 143237b8..8bcb1d78 100644 --- a/src/distribution/multivariate_students_t.rs +++ b/src/distribution/multivariate_students_t.rs @@ -61,6 +61,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 a3f4ffed..6ed557be 100644 --- a/src/distribution/negative_binomial.rs +++ b/src/distribution/negative_binomial.rs @@ -52,6 +52,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 71f50eda..b536c101 100644 --- a/src/distribution/normal.rs +++ b/src/distribution/normal.rs @@ -36,6 +36,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 06f9e176..886db43b 100644 --- a/src/distribution/pareto.rs +++ b/src/distribution/pareto.rs @@ -36,6 +36,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 0780cf55..33e8f8a2 100644 --- a/src/distribution/poisson.rs +++ b/src/distribution/poisson.rs @@ -32,6 +32,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 b9543cc1..cc88707f 100644 --- a/src/distribution/students_t.rs +++ b/src/distribution/students_t.rs @@ -40,6 +40,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 9115e3c4..eb3cb93d 100644 --- a/src/distribution/triangular.rs +++ b/src/distribution/triangular.rs @@ -45,6 +45,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 588413cb..55bd7884 100644 --- a/src/distribution/uniform.rs +++ b/src/distribution/uniform.rs @@ -40,6 +40,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 e0d856c5..71aa30ef 100644 --- a/src/distribution/weibull.rs +++ b/src/distribution/weibull.rs @@ -39,6 +39,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 31d07173..909b4e7b 100644 --- a/src/stats_tests/fisher.rs +++ b/src/stats_tests/fisher.rs @@ -105,6 +105,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) => {