From fdc1a87f471141de366045a212386af0cd83d44d Mon Sep 17 00:00:00 2001 From: klensy Date: Thu, 20 Jul 2023 17:23:56 +0300 Subject: [PATCH 1/3] edition 2018 --- Cargo.toml | 1 + src/arm.rs | 6 +++--- src/float/add.rs | 4 ++-- src/float/cmp.rs | 4 ++-- src/float/div.rs | 4 ++-- src/float/extend.rs | 4 ++-- src/float/mul.rs | 4 ++-- src/float/pow.rs | 4 ++-- src/float/sub.rs | 6 +++--- src/float/trunc.rs | 4 ++-- src/int/addsub.rs | 2 +- src/int/mul.rs | 2 +- src/int/sdiv.rs | 2 +- src/int/shift.rs | 2 +- src/int/udiv.rs | 4 ++-- src/macros.rs | 8 ++++---- src/math.rs | 1 + 17 files changed, 32 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dde57030..bc852808 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ readme = "README.md" repository = "https://github.com/rust-lang/compiler-builtins" homepage = "https://github.com/rust-lang/compiler-builtins" documentation = "https://docs.rs/compiler_builtins" +edition = "2018" description = """ Compiler intrinsics used by the Rust compiler. Also available for other targets if necessary! diff --git a/src/arm.rs b/src/arm.rs index a062a54e..cc67642e 100644 --- a/src/arm.rs +++ b/src/arm.rs @@ -91,7 +91,7 @@ intrinsics! { #[weak] #[cfg(not(target_os = "ios"))] pub unsafe extern "aapcs" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize) { - ::mem::memcpy(dest, src, n); + crate::mem::memcpy(dest, src, n); } #[weak] @@ -121,7 +121,7 @@ intrinsics! { #[weak] #[cfg(not(target_os = "ios"))] pub unsafe extern "aapcs" fn __aeabi_memmove(dest: *mut u8, src: *const u8, n: usize) { - ::mem::memmove(dest, src, n); + crate::mem::memmove(dest, src, n); } #[weak] @@ -140,7 +140,7 @@ intrinsics! { #[cfg(not(target_os = "ios"))] pub unsafe extern "aapcs" fn __aeabi_memset(dest: *mut u8, n: usize, c: i32) { // Note the different argument order - ::mem::memset(dest, c, n); + crate::mem::memset(dest, c, n); } #[weak] diff --git a/src/float/add.rs b/src/float/add.rs index 67f6c2c1..804f4b51 100644 --- a/src/float/add.rs +++ b/src/float/add.rs @@ -1,5 +1,5 @@ -use float::Float; -use int::{CastInto, Int}; +use crate::float::Float; +use crate::int::{CastInto, Int}; /// Returns `a + b` fn add(a: F, b: F) -> F diff --git a/src/float/cmp.rs b/src/float/cmp.rs index 1bd7aa28..1c8917af 100644 --- a/src/float/cmp.rs +++ b/src/float/cmp.rs @@ -1,7 +1,7 @@ #![allow(unreachable_code)] -use float::Float; -use int::Int; +use crate::float::Float; +use crate::int::Int; #[derive(Clone, Copy)] enum Result { diff --git a/src/float/div.rs b/src/float/div.rs index c0aae34f..8c4cf55b 100644 --- a/src/float/div.rs +++ b/src/float/div.rs @@ -2,8 +2,8 @@ // `return`s makes it clear where function exit points are #![allow(clippy::needless_return)] -use float::Float; -use int::{CastInto, DInt, HInt, Int}; +use crate::float::Float; +use crate::int::{CastInto, DInt, HInt, Int}; fn div32(a: F, b: F) -> F where diff --git a/src/float/extend.rs b/src/float/extend.rs index 39633773..cffc5751 100644 --- a/src/float/extend.rs +++ b/src/float/extend.rs @@ -1,5 +1,5 @@ -use float::Float; -use int::{CastInto, Int}; +use crate::float::Float; +use crate::int::{CastInto, Int}; /// Generic conversion from a narrower to a wider IEEE-754 floating-point type fn extend(a: F) -> R diff --git a/src/float/mul.rs b/src/float/mul.rs index c89f2275..1b8c6120 100644 --- a/src/float/mul.rs +++ b/src/float/mul.rs @@ -1,5 +1,5 @@ -use float::Float; -use int::{CastInto, DInt, HInt, Int}; +use crate::float::Float; +use crate::int::{CastInto, DInt, HInt, Int}; fn mul(a: F, b: F) -> F where diff --git a/src/float/pow.rs b/src/float/pow.rs index a75340c3..0232ef40 100644 --- a/src/float/pow.rs +++ b/src/float/pow.rs @@ -1,5 +1,5 @@ -use float::Float; -use int::Int; +use crate::float::Float; +use crate::int::Int; /// Returns `a` raised to the power `b` fn pow(a: F, b: i32) -> F { diff --git a/src/float/sub.rs b/src/float/sub.rs index 8d300e9d..0ea071b3 100644 --- a/src/float/sub.rs +++ b/src/float/sub.rs @@ -1,6 +1,6 @@ -use float::add::__adddf3; -use float::add::__addsf3; -use float::Float; +use crate::float::add::__adddf3; +use crate::float::add::__addsf3; +use crate::float::Float; intrinsics! { #[arm_aeabi_alias = __aeabi_fsub] diff --git a/src/float/trunc.rs b/src/float/trunc.rs index d7371308..9bc4d6e5 100644 --- a/src/float/trunc.rs +++ b/src/float/trunc.rs @@ -1,5 +1,5 @@ -use float::Float; -use int::{CastInto, Int}; +use crate::float::Float; +use crate::int::{CastInto, Int}; fn trunc(a: F) -> R where diff --git a/src/int/addsub.rs b/src/int/addsub.rs index f4841e90..f31eff4b 100644 --- a/src/int/addsub.rs +++ b/src/int/addsub.rs @@ -1,4 +1,4 @@ -use int::{DInt, Int}; +use crate::int::{DInt, Int}; trait UAddSub: DInt { fn uadd(self, other: Self) -> Self { diff --git a/src/int/mul.rs b/src/int/mul.rs index 07ce061c..2538e2f4 100644 --- a/src/int/mul.rs +++ b/src/int/mul.rs @@ -1,4 +1,4 @@ -use int::{DInt, HInt, Int}; +use crate::int::{DInt, HInt, Int}; trait Mul: DInt where diff --git a/src/int/sdiv.rs b/src/int/sdiv.rs index f1822f0f..9d316c76 100644 --- a/src/int/sdiv.rs +++ b/src/int/sdiv.rs @@ -1,4 +1,4 @@ -use int::udiv::*; +use crate::int::udiv::*; macro_rules! sdivmod { ( diff --git a/src/int/shift.rs b/src/int/shift.rs index c90cf1de..dbd04018 100644 --- a/src/int/shift.rs +++ b/src/int/shift.rs @@ -1,4 +1,4 @@ -use int::{DInt, HInt, Int}; +use crate::int::{DInt, HInt, Int}; trait Ashl: DInt { /// Returns `a << b`, requires `b < Self::BITS` diff --git a/src/int/udiv.rs b/src/int/udiv.rs index fb09f87d..c891eede 100644 --- a/src/int/udiv.rs +++ b/src/int/udiv.rs @@ -1,8 +1,8 @@ #[cfg(not(feature = "public-test-deps"))] -pub(crate) use int::specialized_div_rem::*; +pub(crate) use crate::int::specialized_div_rem::*; #[cfg(feature = "public-test-deps")] -pub use int::specialized_div_rem::*; +pub use crate::int::specialized_div_rem::*; intrinsics! { #[maybe_use_optimized_c_shim] diff --git a/src/macros.rs b/src/macros.rs index b11114f1..d2b5734d 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -321,10 +321,10 @@ macro_rules! intrinsics { #[cfg_attr(not(feature = "mangled-names"), no_mangle)] #[cfg_attr(feature = "weak-intrinsics", linkage = "weak")] pub extern $abi fn $name( $($argname: $ty),* ) - -> ::macros::win64_128bit_abi_hack::U64x2 + -> $crate::macros::win64_128bit_abi_hack::U64x2 { let e: $($ret)? = super::$name($($argname),*); - ::macros::win64_128bit_abi_hack::U64x2::from(e) + $crate::macros::win64_128bit_abi_hack::U64x2::from(e) } } @@ -540,7 +540,7 @@ pub mod win64_128bit_abi_hack { impl From for U64x2 { fn from(i: i128) -> U64x2 { - use int::DInt; + use crate::int::DInt; let j = i as u128; U64x2(j.lo(), j.hi()) } @@ -548,7 +548,7 @@ pub mod win64_128bit_abi_hack { impl From for U64x2 { fn from(i: u128) -> U64x2 { - use int::DInt; + use crate::int::DInt; U64x2(i.lo(), i.hi()) } } diff --git a/src/math.rs b/src/math.rs index 4e255ca1..21d23ff9 100644 --- a/src/math.rs +++ b/src/math.rs @@ -2,6 +2,7 @@ #[path = "../libm/src/math/mod.rs"] mod libm; +#[allow(unused_macros)] macro_rules! no_mangle { ($(fn $fun:ident($($iid:ident : $ity:ty),+) -> $oty:ty;)+) => { intrinsics! { From f9beeba4b78d5fe4711af0ae23d3aa29058ebd70 Mon Sep 17 00:00:00 2001 From: klensy Date: Mon, 7 Aug 2023 17:52:27 +0300 Subject: [PATCH 2/3] allow internal_features, added in https://github.com/rust-lang/rust/pull/108955 --- examples/intrinsics.rs | 1 + src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/intrinsics.rs b/examples/intrinsics.rs index 19bb569b..54b703df 100644 --- a/examples/intrinsics.rs +++ b/examples/intrinsics.rs @@ -5,6 +5,7 @@ #![allow(unused_features)] #![allow(stable_features)] // bench_black_box feature is stable, leaving for backcompat +#![allow(internal_features)] #![cfg_attr(thumb, no_main)] #![deny(dead_code)] #![feature(bench_black_box)] diff --git a/src/lib.rs b/src/lib.rs index 73cb3d50..2ef28fc6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ #![no_builtins] #![no_std] #![allow(unused_features)] +#![allow(internal_features)] // We use `u128` in a whole bunch of places which we currently agree with the // compiler on ABIs and such, so we should be "good enough" for now and changes // to the `u128` ABI will be reflected here. From 1ac3230ed8036c8c48657e6b2d046b96d76513c7 Mon Sep 17 00:00:00 2001 From: klensy Date: Mon, 7 Aug 2023 21:19:25 +0300 Subject: [PATCH 3/3] impl_binary_long allow to pass attribute --- src/int/specialized_div_rem/binary_long.rs | 4 ++++ src/int/specialized_div_rem/mod.rs | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/int/specialized_div_rem/binary_long.rs b/src/int/specialized_div_rem/binary_long.rs index 0d782288..2c61a45e 100644 --- a/src/int/specialized_div_rem/binary_long.rs +++ b/src/int/specialized_div_rem/binary_long.rs @@ -13,9 +13,13 @@ macro_rules! impl_binary_long { $n:tt, // the number of bits in a $iX or $uX $uX:ident, // unsigned integer type for the inputs and outputs of `$fn` $iX:ident // signed integer type with same bitwidth as `$uX` + $(, $fun_attr:meta)* // attributes for the function ) => { /// Computes the quotient and remainder of `duo` divided by `div` and returns them as a /// tuple. + $( + #[$fun_attr] + )* pub fn $fn(duo: $uX, div: $uX) -> ($uX, $uX) { let mut duo = duo; // handle edge cases before calling `$normalization_shift` diff --git a/src/int/specialized_div_rem/mod.rs b/src/int/specialized_div_rem/mod.rs index 1ff1d19d..760f5f5b 100644 --- a/src/int/specialized_div_rem/mod.rs +++ b/src/int/specialized_div_rem/mod.rs @@ -306,5 +306,6 @@ impl_binary_long!( u32_normalization_shift, 32, u32, - i32 + i32, + allow(dead_code) );