Skip to content

Commit 15fb630

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 deb6c91 commit 15fb630

File tree

23 files changed

+34
-30
lines changed

23 files changed

+34
-30
lines changed

libm/.github/workflows/main.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,17 @@ jobs:
212212
RUSTFLAGS: # No need to check warnings on old MSRV, unset `-Dwarnings`
213213
steps:
214214
- uses: actions/checkout@master
215-
- run: |
215+
- name: Install Rust
216+
run: |
216217
msrv="$(perl -ne 'print if s/rust-version\s*=\s*"(.*)"/\1/g' libm/Cargo.toml)"
217218
echo "MSRV: $msrv"
218-
echo "MSRV=$msrv" >> "$GITHUB_ENV"
219-
- name: Install Rust
220-
run: rustup update "$MSRV" --no-self-update && rustup default "$MSRV"
219+
rustup update "$msrv" --no-self-update && rustup default "$msrv"
221220
- uses: Swatinem/rust-cache@v2
222-
- run: cargo build -p libm
221+
- run: |
222+
# FIXME(msrv): Remove the workspace Cargo.toml so 1.63 cargo doesn't see
223+
# `edition = "2024"` and get spooked.
224+
rm Cargo.toml
225+
cargo build --manifest-path libm/Cargo.toml
223226
224227
rustfmt:
225228
name: Rustfmt

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

Lines changed: 4 additions & 4 deletions
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
}

libm/crates/libm-macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
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]

libm/crates/libm-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
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]

libm/crates/libm-test/benches/icount.rs

Lines changed: 1 addition & 1 deletion
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;

libm/crates/libm-test/benches/random.rs

Lines changed: 2 additions & 2 deletions
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

libm/crates/libm-test/examples/plot_domains.rs

Lines changed: 4 additions & 4 deletions
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
}

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

Lines changed: 1 addition & 1 deletion
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};

0 commit comments

Comments
 (0)