Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Migrate all crates except libm to edition 2024 #531

Merged
merged 1 commit into from
Apr 18, 2025
Merged
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
13 changes: 8 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,17 @@ jobs:
RUSTFLAGS: # No need to check warnings on old MSRV, unset `-Dwarnings`
steps:
- uses: actions/checkout@master
- run: |
- name: Install Rust
run: |
msrv="$(perl -ne 'print if s/rust-version\s*=\s*"(.*)"/\1/g' libm/Cargo.toml)"
echo "MSRV: $msrv"
echo "MSRV=$msrv" >> "$GITHUB_ENV"
- name: Install Rust
run: rustup update "$MSRV" --no-self-update && rustup default "$MSRV"
rustup update "$msrv" --no-self-update && rustup default "$msrv"
- uses: Swatinem/rust-cache@v2
- run: cargo build -p libm
- run: |
# FIXME(msrv): Remove the workspace Cargo.toml so 1.63 cargo doesn't see
# `edition = "2024"` and get spooked.
rm Cargo.toml
cargo build --manifest-path libm/Cargo.toml

rustfmt:
name: Rustfmt
Expand Down
8 changes: 4 additions & 4 deletions crates/compiler-builtins-smoke-test/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ macro_rules! no_mangle {

// Handle simple functions with single return types
(@inner $name:ident( $($arg:ident: $aty:ty),+ ) -> $ret:ty) => {
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn $name($($arg: $aty),+) -> $ret {
libm::$name($($arg),+)
}
Expand All @@ -26,7 +26,7 @@ macro_rules! no_mangle {
(
@inner $name:ident( $($arg:ident: $aty:ty),+ | $($rarg:ident: $rty:ty),+) -> $ret:ty
) => {
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn $name($($arg: $aty,)+ $($rarg: $rty),+) -> $ret {
let ret;
(ret, $(*$rarg),+) = libm::$name($($arg),+);
Expand Down Expand Up @@ -166,12 +166,12 @@ no_mangle! {

/* sincos has no direct return type, not worth handling in the macro */

#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn sincos(x: f64, s: &mut f64, c: &mut f64) {
(*s, *c) = libm::sincos(x);
}

#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn sincosf(x: f32, s: &mut f32, c: &mut f32) {
(*s, *c) = libm::sincosf(x);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/libm-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "libm-macros"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[lib]
Expand Down
2 changes: 1 addition & 1 deletion 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 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
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
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
2 changes: 1 addition & 1 deletion 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 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
2 changes: 1 addition & 1 deletion 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 Down
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 libm/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