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

Commit b25b2f0

Browse files
committed
Migrate all crates except libm to edition 2024
Unfortunately this means we lose use of the convenient name `gen`, so this includes a handful of renaming. We can't increase the edition for `libm` yet due to MSRV, but we can enable `unsafe_op_in_unsafe_fn` to help make that change smoother in the future.
1 parent 9064743 commit b25b2f0

File tree

23 files changed

+31
-26
lines changed

23 files changed

+31
-26
lines changed

.github/workflows/main.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ jobs:
219219
- name: Install Rust
220220
run: rustup update "$MSRV" --no-self-update && rustup default "$MSRV"
221221
- uses: Swatinem/rust-cache@v2
222-
- run: cargo build -p libm
222+
- run: |
223+
# FIXME(msrv): Remove the workspace Cargo.toml so 1.63 cargo doesn't see
224+
# `edition = "2024"` and get spooked.
225+
rm Cargo.toml
226+
cargo build -p libm
223227
224228
rustfmt:
225229
name: Rustfmt

crates/compiler-builtins-smoke-test/src/math.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ macro_rules! no_mangle {
1414

1515
// Handle simple functions with single return types
1616
(@inner $name:ident( $($arg:ident: $aty:ty),+ ) -> $ret:ty) => {
17-
#[no_mangle]
17+
#[unsafe(no_mangle)]
1818
extern "C" fn $name($($arg: $aty),+) -> $ret {
1919
libm::$name($($arg),+)
2020
}
@@ -26,7 +26,7 @@ macro_rules! no_mangle {
2626
(
2727
@inner $name:ident( $($arg:ident: $aty:ty),+ | $($rarg:ident: $rty:ty),+) -> $ret:ty
2828
) => {
29-
#[no_mangle]
29+
#[unsafe(no_mangle)]
3030
extern "C" fn $name($($arg: $aty,)+ $($rarg: $rty),+) -> $ret {
3131
let ret;
3232
(ret, $(*$rarg),+) = libm::$name($($arg),+);
@@ -166,12 +166,12 @@ no_mangle! {
166166

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

169-
#[no_mangle]
169+
#[unsafe(no_mangle)]
170170
extern "C" fn sincos(x: f64, s: &mut f64, c: &mut f64) {
171171
(*s, *c) = libm::sincos(x);
172172
}
173173

174-
#[no_mangle]
174+
#[unsafe(no_mangle)]
175175
extern "C" fn sincosf(x: f32, s: &mut f32, c: &mut f32) {
176176
(*s, *c) = libm::sincosf(x);
177177
}

crates/libm-macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "libm-macros"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[lib]

crates/libm-test/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "libm-test"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[features]

crates/libm-test/benches/icount.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::hint::black_box;
44

55
use iai_callgrind::{library_benchmark, library_benchmark_group, main};
66
use libm::support::{HInt, u256};
7-
use libm_test::gen::spaced;
7+
use libm_test::generate::spaced;
88
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, OpRustArgs, TupleCall, op};
99

1010
const BENCH_ITER_ITEMS: u64 = 500;

crates/libm-test/benches/random.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::hint::black_box;
22
use std::time::Duration;
33

44
use criterion::{Criterion, criterion_main};
5-
use libm_test::gen::random;
6-
use libm_test::gen::random::RandomInput;
5+
use libm_test::generate::random;
6+
use libm_test::generate::random::RandomInput;
77
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, TupleCall};
88

99
/// Benchmark with this many items to get a variety

crates/libm-test/examples/plot_domains.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use std::path::Path;
1212
use std::process::Command;
1313
use std::{env, fs};
1414

15-
use libm_test::gen::spaced::SpacedInput;
16-
use libm_test::gen::{edge_cases, spaced};
15+
use libm_test::generate::spaced::SpacedInput;
16+
use libm_test::generate::{edge_cases, spaced};
1717
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, op};
1818

1919
const JL_PLOT: &str = "examples/plot_file.jl";
@@ -73,7 +73,7 @@ fn plot_one_generator(
7373
ctx: &CheckCtx,
7474
gen_name: &str,
7575
config: &mut String,
76-
gen: impl Iterator<Item = (f32,)>,
76+
generator: impl Iterator<Item = (f32,)>,
7777
) {
7878
let fn_name = ctx.base_name_str;
7979
let text_file = out_dir.join(format!("input-{fn_name}-{gen_name}.txt"));
@@ -82,7 +82,7 @@ fn plot_one_generator(
8282
let mut w = BufWriter::new(f);
8383
let mut count = 0u64;
8484

85-
for input in gen {
85+
for input in generator {
8686
writeln!(w, "{:e}", input.0).unwrap();
8787
count += 1;
8888
}
File renamed without changes.

crates/libm-test/src/gen/edge_cases.rs renamed to crates/libm-test/src/generate/edge_cases.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use libm::support::{CastInto, Float, Int, MinInt};
44

55
use crate::domain::get_domain;
6-
use crate::gen::KnownSize;
6+
use crate::generate::KnownSize;
77
use crate::op::OpITy;
88
use crate::run_cfg::{check_near_count, check_point_count};
99
use crate::{BaseName, CheckCtx, FloatExt, FloatTy, MathOp, test_log};

crates/libm-test/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
pub mod domain;
66
mod f8_impl;
7-
pub mod gen;
7+
pub mod generate;
88
#[cfg(feature = "build-mpfr")]
99
pub mod mpfloat;
1010
mod num;

crates/libm-test/src/run_cfg.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::ops::RangeInclusive;
44
use std::sync::LazyLock;
55
use std::{env, str};
66

7-
use crate::gen::random::{SEED, SEED_ENV};
7+
use crate::generate::random::{SEED, SEED_ENV};
88
use crate::{BaseName, FloatTy, Identifier, test_log};
99

1010
/// The environment variable indicating which extensive tests should be run.
@@ -241,7 +241,7 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
241241
// Some tests are significantly slower than others and need to be further reduced.
242242
if let Some((_id, _gen, scale)) = EXTEMELY_SLOW_TESTS
243243
.iter()
244-
.find(|(id, gen, _scale)| *id == ctx.fn_ident && *gen == ctx.gen_kind)
244+
.find(|(id, generator, _scale)| *id == ctx.fn_ident && *generator == ctx.gen_kind)
245245
{
246246
// However, do not override if the extensive iteration count has been manually set.
247247
if !(ctx.gen_kind == GeneratorKind::Extensive && EXTENSIVE_ITER_OVERRIDE.is_some()) {

crates/libm-test/tests/compare_built_musl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// There are some targets we can't build musl for
1010
#![cfg(feature = "build-musl")]
1111

12-
use libm_test::gen::{case_list, edge_cases, random, spaced};
12+
use libm_test::generate::{case_list, edge_cases, random, spaced};
1313
use libm_test::{CheckBasis, CheckCtx, CheckOutput, GeneratorKind, MathOp, TupleCall};
1414

1515
const BASIS: CheckBasis = CheckBasis::Musl;

crates/libm-test/tests/multiprecision.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![cfg(feature = "build-mpfr")]
44

5-
use libm_test::gen::{case_list, edge_cases, random, spaced};
5+
use libm_test::generate::{case_list, edge_cases, random, spaced};
66
use libm_test::mpfloat::MpOp;
77
use libm_test::{CheckBasis, CheckCtx, CheckOutput, GeneratorKind, MathOp, TupleCall};
88

crates/libm-test/tests/standalone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Test cases that have both an input and an output, so do not require a basis.
22
3-
use libm_test::gen::case_list;
3+
use libm_test::generate::case_list;
44
use libm_test::{CheckBasis, CheckCtx, CheckOutput, GeneratorKind, MathOp, TupleCall};
55

66
const BASIS: CheckBasis = CheckBasis::None;

crates/libm-test/tests/u256.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use libm::support::{HInt, u256};
99
type BigInt = rug::Integer;
1010

1111
use libm_test::bigint_fuzz_iteration_count;
12-
use libm_test::gen::random::SEED;
12+
use libm_test::generate::random::SEED;
1313
use rand::{Rng, SeedableRng};
1414
use rand_chacha::ChaCha8Rng;
1515
use rug::Assign;

crates/libm-test/tests/z_extensive/run.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::sync::atomic::{AtomicU64, Ordering};
66
use std::time::Duration;
77

88
use indicatif::{ProgressBar, ProgressStyle};
9-
use libm_test::gen::spaced;
9+
use libm_test::generate::spaced;
1010
use libm_test::mpfloat::MpOp;
1111
use libm_test::{
1212
CheckBasis, CheckCtx, CheckOutput, GeneratorKind, MathOp, TestResult, TupleCall,

crates/musl-math-sys/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "musl-math-sys"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[dependencies]

crates/musl-math-sys/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ macro_rules! functions {
1010
$( #[$meta:meta] )*
1111
$pfx_name:ident: $name:ident( $($arg:ident: $aty:ty),+ ) -> $rty:ty;
1212
)* ) => {
13-
extern "C" {
13+
unsafe extern "C" {
1414
$( fn $pfx_name( $($arg: $aty),+ ) -> $rty; )*
1515
}
1616

crates/util/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "util"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55
publish = false
66

77
[features]

libm/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#![allow(clippy::needless_return)]
1818
#![allow(clippy::unreadable_literal)]
1919
#![allow(clippy::zero_divided_by_zero)]
20+
#![forbid(unsafe_op_in_unsafe_fn)]
2021

2122
mod libm_helper;
2223
mod math;

0 commit comments

Comments
 (0)