Skip to content

Commit

Permalink
Forbid the default numeric fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
stepchowfun committed Jan 9, 2024
1 parent 6683c91 commit 3de12de
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 157 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ readme = "README.md"

[lints]
clippy.all = "deny"
clippy.default_numeric_fallback = "deny"
clippy.pedantic = "deny"
rust.warnings = "deny"

Expand Down
1 change: 1 addition & 0 deletions benchmarks/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2018"

[lints]
clippy.all = "deny"
clippy.default_numeric_fallback = "deny"
clippy.pedantic = "deny"
rust.warnings = "deny"

Expand Down
6 changes: 3 additions & 3 deletions benchmarks/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ fn main() -> io::Result<()> {
s: vec![vec![], vec![()], vec![(), ()], vec![(), (), ()]],
t: vec![
vec![],
vec![0.0],
vec![0.0, PI],
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64],
vec![0.0_f64, PI],
vec![0.0_f64, PI, f64::EPSILON],
F64_TEST_VALUES.to_owned(),
],
u: vec![
Expand Down
1 change: 1 addition & 0 deletions examples/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2018"

[lints]
clippy.all = "deny"
clippy.default_numeric_fallback = "deny"
clippy.pedantic = "deny"
rust.warnings = "deny"

Expand Down
1 change: 1 addition & 0 deletions integration_tests/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2018"

[lints]
clippy.all = "deny"
clippy.default_numeric_fallback = "deny"
clippy.pedantic = "deny"
rust.warnings = "deny"

Expand Down
75 changes: 39 additions & 36 deletions integration_tests/rust/src/comprehensive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ pub fn run() -> io::Result<()> {
s_required: vec![vec![], vec![()], vec![(), ()], vec![(), (), ()]],
t_required: vec![
vec![],
vec![0.0],
vec![0.0, PI],
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64],
vec![0.0_f64, PI],
vec![0.0_f64, PI, f64::EPSILON],
F64_TEST_VALUES.to_owned(),
],
u_required: vec![
Expand Down Expand Up @@ -171,9 +171,9 @@ pub fn run() -> io::Result<()> {
s_asymmetric: vec![vec![], vec![()], vec![(), ()], vec![(), (), ()]],
t_asymmetric: vec![
vec![],
vec![0.0],
vec![0.0, PI],
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64],
vec![0.0_f64, PI],
vec![0.0_f64, PI, f64::EPSILON],
F64_TEST_VALUES.to_owned(),
],
u_asymmetric: vec![
Expand Down Expand Up @@ -280,9 +280,9 @@ pub fn run() -> io::Result<()> {
s_required: vec![vec![], vec![()], vec![(), ()], vec![(), (), ()]],
t_required: vec![
vec![],
vec![0.0],
vec![0.0, PI],
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64],
vec![0.0_f64, PI],
vec![0.0_f64, PI, f64::EPSILON],
F64_TEST_VALUES.to_owned(),
],
u_required: vec![
Expand Down Expand Up @@ -357,9 +357,9 @@ pub fn run() -> io::Result<()> {
s_asymmetric: vec![vec![], vec![()], vec![(), ()], vec![(), (), ()]],
t_asymmetric: vec![
vec![],
vec![0.0],
vec![0.0, PI],
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64],
vec![0.0_f64, PI],
vec![0.0_f64, PI, f64::EPSILON],
F64_TEST_VALUES.to_owned(),
],
u_asymmetric: vec![
Expand Down Expand Up @@ -442,9 +442,9 @@ pub fn run() -> io::Result<()> {
s_optional: Some(vec![vec![], vec![()], vec![(), ()], vec![(), (), ()]]),
t_optional: Some(vec![
vec![],
vec![0.0],
vec![0.0, PI],
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64],
vec![0.0_f64, PI],
vec![0.0_f64, PI, f64::EPSILON],
F64_TEST_VALUES.to_owned(),
]),
u_optional: Some(vec![
Expand Down Expand Up @@ -534,9 +534,9 @@ pub fn run() -> io::Result<()> {
assert_round_trip::<BarOut, BarIn>(&BarOut::JRequired(vec![(), (), ()]))?;

assert_round_trip::<BarOut, BarIn>(&BarOut::KRequired(vec![]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KRequired(vec![0.0]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KRequired(vec![0.0, PI]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KRequired(vec![0.0, PI, f64::EPSILON]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KRequired(vec![0.0_f64]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KRequired(vec![0.0_f64, PI]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KRequired(vec![0.0_f64, PI, f64::EPSILON]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KRequired(F64_TEST_VALUES.to_owned()))?;

assert_round_trip::<BarOut, BarIn>(&BarOut::LRequired(vec![]))?;
Expand Down Expand Up @@ -615,14 +615,14 @@ pub fn run() -> io::Result<()> {

assert_round_trip::<BarOut, BarIn>(&BarOut::TRequired(vec![]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::TRequired(vec![vec![]]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::TRequired(vec![vec![0.0]]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::TRequired(vec![vec![0.0_f64]]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::TRequired(vec![vec![], vec![], vec![]]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::TRequired(vec![F64_TEST_VALUES.to_owned()]))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::TRequired(vec![
vec![],
vec![0.0],
vec![0.0, PI],
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64],
vec![0.0_f64, PI],
vec![0.0_f64, PI, f64::EPSILON],
]))?;

assert_round_trip::<BarOut, BarIn>(&BarOut::URequired(vec![]))?;
Expand Down Expand Up @@ -804,15 +804,15 @@ pub fn run() -> io::Result<()> {

assert_round_trip::<BarOut, BarIn>(&BarOut::KAsymmetric(vec![], Box::new(fallback.clone())))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KAsymmetric(
vec![0.0],
vec![0.0_f64],
Box::new(fallback.clone()),
))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KAsymmetric(
vec![0.0, PI],
vec![0.0_f64, PI],
Box::new(fallback.clone()),
))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KAsymmetric(
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64, PI, f64::EPSILON],
Box::new(fallback.clone()),
))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KAsymmetric(
Expand Down Expand Up @@ -958,7 +958,7 @@ pub fn run() -> io::Result<()> {
Box::new(fallback.clone()),
))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::TAsymmetric(
vec![vec![0.0]],
vec![vec![0.0_f64]],
Box::new(fallback.clone()),
))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::TAsymmetric(
Expand All @@ -972,9 +972,9 @@ pub fn run() -> io::Result<()> {
assert_round_trip::<BarOut, BarIn>(&BarOut::TAsymmetric(
vec![
vec![],
vec![0.0],
vec![0.0, PI],
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64],
vec![0.0_f64, PI],
vec![0.0_f64, PI, f64::EPSILON],
],
Box::new(fallback.clone()),
))?;
Expand Down Expand Up @@ -1247,13 +1247,16 @@ pub fn run() -> io::Result<()> {
))?;

assert_round_trip::<BarOut, BarIn>(&BarOut::KOptional(vec![], Box::new(fallback.clone())))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KOptional(vec![0.0], Box::new(fallback.clone())))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KOptional(
vec![0.0, PI],
vec![0.0_f64],
Box::new(fallback.clone()),
))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KOptional(
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64, PI],
Box::new(fallback.clone()),
))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KOptional(
vec![0.0_f64, PI, f64::EPSILON],
Box::new(fallback.clone()),
))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::KOptional(
Expand Down Expand Up @@ -1399,7 +1402,7 @@ pub fn run() -> io::Result<()> {
Box::new(fallback.clone()),
))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::TOptional(
vec![vec![0.0]],
vec![vec![0.0_f64]],
Box::new(fallback.clone()),
))?;
assert_round_trip::<BarOut, BarIn>(&BarOut::TOptional(
Expand All @@ -1413,9 +1416,9 @@ pub fn run() -> io::Result<()> {
assert_round_trip::<BarOut, BarIn>(&BarOut::TOptional(
vec![
vec![],
vec![0.0],
vec![0.0, PI],
vec![0.0, PI, f64::EPSILON],
vec![0.0_f64],
vec![0.0_f64, PI],
vec![0.0_f64, PI, f64::EPSILON],
],
Box::new(fallback.clone()),
))?;
Expand Down
4 changes: 2 additions & 2 deletions src/assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ mod tests {

#[test]
fn assert_same_match() {
assert_same!(42, 42);
assert_same!(42_i32, 42_i32);
}

#[test]
#[should_panic(expected = "42")]
fn assert_same_mismatch() {
assert_same!(42, 43);
assert_same!(42_i32, 43_i32);
}
}
Loading

0 comments on commit 3de12de

Please sign in to comment.