From 2910280f5d3ecf698697471a6959ffc3f5208015 Mon Sep 17 00:00:00 2001 From: Jan Haller Date: Sun, 19 Dec 2021 23:47:58 +0100 Subject: [PATCH] Set MSRV to 1.51 Reason: --features on a workspace level is not supported before. Further complicating CI scripts, while we already have Rust 1.57, is questionable. Also removes the custom-built clamp(), which was introduced as f32::clamp() in Rust 1.50. --- .github/workflows/full-ci.yml | 12 ++++++++---- .../src/core_types/geom/transform2d.rs | 18 +----------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/full-ci.yml b/.github/workflows/full-ci.yml index b2052f1aa..706dc2d09 100644 --- a/.github/workflows/full-ci.yml +++ b/.github/workflows/full-ci.yml @@ -105,7 +105,7 @@ jobs: - rust: { toolchain: 'nightly' } testflags: '-- --skip ui_tests' - os: { id: ubuntu-latest, name: linux } - rust: { toolchain: '1.48', postfix: ' (msrv 1.48)' } + rust: { toolchain: '1.51', postfix: ' (msrv 1.51)' } testflags: '-- --skip ui_tests' runs-on: ${{ matrix.os.id }} steps: @@ -233,17 +233,21 @@ jobs: fail-fast: false # cancel all jobs as soon as one fails? matrix: include: + # Latest Godot with different Rust versions - rust: stable godot: "3.4.1" postfix: '' - rust: nightly godot: "3.4.1" postfix: ' (nightly)' - - rust: '1.48' + - rust: '1.51' godot: "3.4.1" - postfix: ' (msrv 1.48)' + postfix: ' (msrv 1.51)' + + # Test with older engine version + # Note: headless versions of Godot <= 3.3 may crash with a bug, see feature description in lib.rs - rust: stable - godot: "3.2" + godot: "3.3.1" postfix: '' build_args: '--features custom-godot' diff --git a/gdnative-core/src/core_types/geom/transform2d.rs b/gdnative-core/src/core_types/geom/transform2d.rs index d0be243fb..b2df576ec 100644 --- a/gdnative-core/src/core_types/geom/transform2d.rs +++ b/gdnative-core/src/core_types/geom/transform2d.rs @@ -1,21 +1,5 @@ use crate::core_types::Vector2; -/// Clamp method for f32. -/// NOTE: This method was copied as-is from std. This was done to avoid compatibility issues -/// with newer rustc versions and should be removed in favor of f32::clamp once that is stable. -#[inline] -fn clamp(num: f32, min: f32, max: f32) -> f32 { - assert!(min <= max); - let mut x = num; - if x < min { - x = min; - } - if x > max { - x = max; - } - x -} - /// Affine 2D transform (2x3 matrix). /// /// Represents transformations such as translation, rotation, or scaling. @@ -228,7 +212,7 @@ impl Transform2D { // slerp rotation let v1 = Vector2::new(f32::cos(r1), f32::sin(r1)); let v2 = Vector2::new(f32::cos(r2), f32::sin(r2)); - let dot = clamp(v1.dot(v2), -1.0, 1.0); + let dot = v1.dot(v2).clamp(-1.0, 1.0); let v = if dot > 0.9995 { //linearly interpolate to avoid numerical precision issues