Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate all crates except libm to edition 2024 #531

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ exclude = [
]

[dev-dependencies]
no-panic = "0.1.33"

no-panic = "0.1.35"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
Expand Down
2 changes: 1 addition & 1 deletion crates/compiler-builtins-smoke-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "cb"
version = "0.1.0"
authors = ["Jorge Aparicio <jorge@japaric.io>"]
edition = "2021"
edition = "2024"
publish = false

[lib]
Expand Down
8 changes: 4 additions & 4 deletions crates/libm-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
name = "libm-macros"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[lib]
proc-macro = true

[dependencies]
heck = "0.5.0"
proc-macro2 = "1.0.93"
quote = "1.0.38"
syn = { version = "2.0.96", features = ["full", "extra-traits", "visit-mut"] }
proc-macro2 = "1.0.94"
quote = "1.0.40"
syn = { version = "2.0.100", features = ["full", "extra-traits", "visit-mut"] }

[lints.rust]
# Values used during testing
Expand Down
16 changes: 6 additions & 10 deletions crates/libm-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "libm-test"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[features]
Expand All @@ -27,26 +27,22 @@ icount = ["dep:iai-callgrind"]
short-benchmarks = []

[dependencies]
anyhow = "1.0.95"
anyhow = "1.0.97"
# This is not directly used but is required so we can enable `gmp-mpfr-sys/force-cross`.
gmp-mpfr-sys = { version = "1.6.4", optional = true, default-features = false }
iai-callgrind = { version = "0.14.0", optional = true }
indicatif = { version = "0.17.9", default-features = false }
indicatif = { version = "0.17.11", default-features = false }
libm = { path = "../..", features = ["unstable-public-internals"] }
libm-macros = { path = "../libm-macros" }
musl-math-sys = { path = "../musl-math-sys", optional = true }
paste = "1.0.15"
rand = "0.8.5"
rand_chacha = "0.3.1"
rand = "0.9.0"
rand_chacha = "0.9.0"
rayon = "1.10.0"
rug = { version = "1.27.0", optional = true, default-features = false, features = ["float", "integer", "std"] }

[target.'cfg(target_family = "wasm")'.dependencies]
# Enable randomness on WASM
getrandom = { version = "0.2", features = ["js"] }

[build-dependencies]
rand = { version = "0.8.5", optional = true }
rand = { version = "0.9.0", optional = true }

[dev-dependencies]
criterion = { version = "0.5.1", default-features = false, features = ["cargo_bench_support"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/libm-test/benches/icount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::hint::black_box;

use iai_callgrind::{library_benchmark, library_benchmark_group, main};
use libm::support::{HInt, u256};
use libm_test::gen::spaced;
use libm_test::generate::spaced;
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, OpRustArgs, TupleCall, op};

const BENCH_ITER_ITEMS: u64 = 500;
Expand Down
4 changes: 2 additions & 2 deletions crates/libm-test/benches/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::hint::black_box;
use std::time::Duration;

use criterion::{Criterion, criterion_main};
use libm_test::gen::random;
use libm_test::gen::random::RandomInput;
use libm_test::generate::random;
use libm_test::generate::random::RandomInput;
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, TupleCall};

/// Benchmark with this many items to get a variety
Expand Down
8 changes: 4 additions & 4 deletions crates/libm-test/examples/plot_domains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use std::path::Path;
use std::process::Command;
use std::{env, fs};

use libm_test::gen::spaced::SpacedInput;
use libm_test::gen::{edge_cases, spaced};
use libm_test::generate::spaced::SpacedInput;
use libm_test::generate::{edge_cases, spaced};
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, op};

const JL_PLOT: &str = "examples/plot_file.jl";
Expand Down Expand Up @@ -73,7 +73,7 @@ fn plot_one_generator(
ctx: &CheckCtx,
gen_name: &str,
config: &mut String,
gen: impl Iterator<Item = (f32,)>,
generator: impl Iterator<Item = (f32,)>,
) {
let fn_name = ctx.base_name_str;
let text_file = out_dir.join(format!("input-{fn_name}-{gen_name}.txt"));
Expand All @@ -82,7 +82,7 @@ fn plot_one_generator(
let mut w = BufWriter::new(f);
let mut count = 0u64;

for input in gen {
for input in generator {
writeln!(w, "{:e}", input.0).unwrap();
count += 1;
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use libm::support::{CastInto, Float, Int, MinInt};

use crate::domain::get_domain;
use crate::gen::KnownSize;
use crate::generate::KnownSize;
use crate::op::OpITy;
use crate::run_cfg::{check_near_count, check_point_count};
use crate::{BaseName, CheckCtx, FloatExt, FloatTy, MathOp, test_log};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::RangeInclusive;
use std::sync::LazyLock;

use libm::support::Float;
use rand::distributions::{Alphanumeric, Standard};
use rand::distr::{Alphanumeric, StandardUniform};
use rand::prelude::Distribution;
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha8Rng;
Expand All @@ -16,7 +16,7 @@ pub(crate) const SEED_ENV: &str = "LIBM_SEED";

pub static SEED: LazyLock<[u8; 32]> = LazyLock::new(|| {
let s = env::var(SEED_ENV).unwrap_or_else(|_| {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
(0..32).map(|_| rng.sample(Alphanumeric) as char).collect()
});

Expand All @@ -33,19 +33,19 @@ pub trait RandomInput: Sized {
/// Generate a sequence of deterministically random floats.
fn random_floats<F: Float>(count: u64) -> impl Iterator<Item = F>
where
Standard: Distribution<F::Int>,
StandardUniform: Distribution<F::Int>,
{
let mut rng = ChaCha8Rng::from_seed(*SEED);

// Generate integers to get a full range of bitpatterns (including NaNs), then convert back
// to the float type.
(0..count).map(move |_| F::from_bits(rng.gen::<F::Int>()))
(0..count).map(move |_| F::from_bits(rng.random::<F::Int>()))
}

/// Generate a sequence of deterministically random `i32`s within a specified range.
fn random_ints(count: u64, range: RangeInclusive<i32>) -> impl Iterator<Item = i32> {
let mut rng = ChaCha8Rng::from_seed(*SEED);
(0..count).map(move |_| rng.gen_range::<i32, _>(range.clone()))
(0..count).map(move |_| rng.random_range::<i32, _>(range.clone()))
}

macro_rules! impl_random_input {
Expand Down
2 changes: 1 addition & 1 deletion crates/libm-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

pub mod domain;
mod f8_impl;
pub mod gen;
pub mod generate;
#[cfg(feature = "build-mpfr")]
pub mod mpfloat;
mod num;
Expand Down
4 changes: 2 additions & 2 deletions crates/libm-test/src/run_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::ops::RangeInclusive;
use std::sync::LazyLock;
use std::{env, str};

use crate::gen::random::{SEED, SEED_ENV};
use crate::generate::random::{SEED, SEED_ENV};
use crate::{BaseName, FloatTy, Identifier, test_log};

/// The environment variable indicating which extensive tests should be run.
Expand Down Expand Up @@ -241,7 +241,7 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
// Some tests are significantly slower than others and need to be further reduced.
if let Some((_id, _gen, scale)) = EXTEMELY_SLOW_TESTS
.iter()
.find(|(id, gen, _scale)| *id == ctx.fn_ident && *gen == ctx.gen_kind)
.find(|(id, generator, _scale)| *id == ctx.fn_ident && *generator == ctx.gen_kind)
{
// However, do not override if the extensive iteration count has been manually set.
if !(ctx.gen_kind == GeneratorKind::Extensive && EXTENSIVE_ITER_OVERRIDE.is_some()) {
Expand Down
2 changes: 1 addition & 1 deletion crates/libm-test/tests/compare_built_musl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// There are some targets we can't build musl for
#![cfg(feature = "build-musl")]

use libm_test::gen::{case_list, edge_cases, random, spaced};
use libm_test::generate::{case_list, edge_cases, random, spaced};
use libm_test::{CheckBasis, CheckCtx, CheckOutput, GeneratorKind, MathOp, TupleCall};

const BASIS: CheckBasis = CheckBasis::Musl;
Expand Down
2 changes: 1 addition & 1 deletion crates/libm-test/tests/multiprecision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![cfg(feature = "build-mpfr")]

use libm_test::gen::{case_list, edge_cases, random, spaced};
use libm_test::generate::{case_list, edge_cases, random, spaced};
use libm_test::mpfloat::MpOp;
use libm_test::{CheckBasis, CheckCtx, CheckOutput, GeneratorKind, MathOp, TupleCall};

Expand Down
2 changes: 1 addition & 1 deletion crates/libm-test/tests/standalone.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Test cases that have both an input and an output, so do not require a basis.

use libm_test::gen::case_list;
use libm_test::generate::case_list;
use libm_test::{CheckBasis, CheckCtx, CheckOutput, GeneratorKind, MathOp, TupleCall};

const BASIS: CheckBasis = CheckBasis::None;
Expand Down
12 changes: 6 additions & 6 deletions crates/libm-test/tests/u256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use libm::support::{HInt, u256};
type BigInt = rug::Integer;

use libm_test::bigint_fuzz_iteration_count;
use libm_test::gen::random::SEED;
use libm_test::generate::random::SEED;
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha8Rng;
use rug::Assign;
Expand All @@ -25,8 +25,8 @@ fn hexu(v: u256) -> String {
}

fn random_u256(rng: &mut ChaCha8Rng) -> u256 {
let lo: u128 = rng.gen();
let hi: u128 = rng.gen();
let lo: u128 = rng.random();
let hi: u128 = rng.random();
u256 { lo, hi }
}

Expand Down Expand Up @@ -121,7 +121,7 @@ fn mp_u256_shr() {

for _ in 0..bigint_fuzz_iteration_count() {
let x = random_u256(&mut rng);
let shift: u32 = rng.gen_range(0..255);
let shift: u32 = rng.random_range(0..255);
assign_bigint(&mut bx, x);
let actual = x >> shift;
bx >>= shift;
Expand All @@ -136,8 +136,8 @@ fn mp_u256_widen_mul() {
let mut by = BigInt::new();

for _ in 0..bigint_fuzz_iteration_count() {
let x: u128 = rng.gen();
let y: u128 = rng.gen();
let x: u128 = rng.random();
let y: u128 = rng.random();
bx.assign(x);
by.assign(y);
let actual = x.widen_mul(y);
Expand Down
2 changes: 1 addition & 1 deletion crates/libm-test/tests/z_extensive/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::atomic::{AtomicU64, Ordering};
use std::time::Duration;

use indicatif::{ProgressBar, ProgressStyle};
use libm_test::gen::spaced;
use libm_test::generate::spaced;
use libm_test::mpfloat::MpOp;
use libm_test::{
CheckBasis, CheckCtx, CheckOutput, GeneratorKind, MathOp, TestResult, TupleCall,
Expand Down
4 changes: 2 additions & 2 deletions crates/musl-math-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "musl-math-sys"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[dependencies]
Expand All @@ -10,4 +10,4 @@ publish = false
libm = { path = "../../" }

[build-dependencies]
cc = "1.2.10"
cc = "1.2.16"
2 changes: 1 addition & 1 deletion crates/musl-math-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ macro_rules! functions {
$( #[$meta:meta] )*
$pfx_name:ident: $name:ident( $($arg:ident: $aty:ty),+ ) -> $rty:ty;
)* ) => {
extern "C" {
unsafe extern "C" {
$( fn $pfx_name( $($arg: $aty),+ ) -> $rty; )*
}

Expand Down
2 changes: 1 addition & 1 deletion crates/util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "util"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[features]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#![allow(clippy::needless_return)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::zero_divided_by_zero)]
#![forbid(unsafe_op_in_unsafe_fn)]

mod libm_helper;
mod math;
Expand Down
Loading