Skip to content

Commit

Permalink
Add #[coverage(off)] to Display impls
Browse files Browse the repository at this point in the history
  • Loading branch information
FreezyLemon committed Sep 6, 2024
1 parent 6faaabf commit 8d02292
Show file tree
Hide file tree
Showing 30 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)']
1 change: 1 addition & 0 deletions src/distribution/beta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/binomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/categorical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/cauchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/chi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
1 change: 1 addition & 0 deletions src/distribution/dirac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/dirichlet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/discrete_uniform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/exponential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/fisher_snedecor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
1 change: 1 addition & 0 deletions src/distribution/gamma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/geometric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/hypergeometric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/inverse_gamma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
1 change: 1 addition & 0 deletions src/distribution/laplace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/log_normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/multinomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/multivariate_normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
1 change: 1 addition & 0 deletions src/distribution/multivariate_students_t.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
1 change: 1 addition & 0 deletions src/distribution/negative_binomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/pareto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/poisson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/students_t.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/triangular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/uniform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions src/distribution/weibull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/stats_tests/fisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 8d02292

Please sign in to comment.