Raise required rustc from 1.31 to 1.36

This commit is contained in:
David Tolnay
2021-12-10 18:06:04 -08:00
parent a41ed2b91d
commit 1af098f3fe
6 changed files with 12 additions and 99 deletions
+2 -2
View File
@@ -23,11 +23,11 @@ jobs:
if: matrix.rust == 'nightly'
msrv:
name: Rust 1.31.0
name: Rust 1.36.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@1.31.0
- uses: dtolnay/rust-toolchain@1.36.0
- run: cargo build
- run: cargo build --features small
+1 -1
View File
@@ -8,7 +8,7 @@ repository = "https://github.com/dtolnay/ryu"
documentation = "https://docs.rs/ryu"
readme = "README.md"
edition = "2018"
rust-version = "1.31"
rust-version = "1.36"
[features]
# Use smaller lookup tables. Instead of storing every required power of
+1 -1
View File
@@ -15,7 +15,7 @@ under the creative commons CC-BY-SA license.
This Rust implementation is a line-by-line port of Ulf Adams' implementation in
C, [https://github.com/ulfjack/ryu][upstream].
*Requirements: this crate supports any compiler version back to rustc 1.31; it
*Requirements: this crate supports any compiler version back to rustc 1.36; it
uses nothing from the Rust standard library so is usable from no_std crates.*
[paper]: https://dl.acm.org/citation.cfm?id=3192369
-31
View File
@@ -1,31 +0,0 @@
use std::env;
use std::process::Command;
use std::str::{self, FromStr};
// The rustc-cfg strings below are *not* public API. Please let us know by
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
fn main() {
let minor = match rustc_minor_version() {
Some(minor) => minor,
None => return,
};
// MaybeUninit<T> stabilized in Rust 1.36:
// https://blog.rust-lang.org/2019/07/04/Rust-1.36.0.html
if minor >= 36 {
println!("cargo:rustc-cfg=maybe_uninit");
}
}
fn rustc_minor_version() -> Option<u32> {
let rustc = env::var_os("RUSTC")?;
let output = Command::new(rustc).arg("--version").output().ok()?;
let version = str::from_utf8(&output.stdout).ok()?;
let mut pieces = version.split('.');
if pieces.next() != Some("rustc 1") {
return None;
}
let next = pieces.next()?;
u32::from_str(next).ok()
}
-12
View File
@@ -1,7 +1,4 @@
use crate::raw;
#[cfg(not(maybe_uninit))]
use core::mem;
#[cfg(maybe_uninit)]
use core::mem::MaybeUninit;
use core::{slice, str};
#[cfg(feature = "no-panic")]
@@ -21,10 +18,7 @@ const NEG_INFINITY: &str = "-inf";
/// assert_eq!(printed, "1.234");
/// ```
pub struct Buffer {
#[cfg(maybe_uninit)]
bytes: [MaybeUninit<u8>; 24],
#[cfg(not(maybe_uninit))]
bytes: [u8; 24],
}
impl Buffer {
@@ -33,13 +27,7 @@ impl Buffer {
#[inline]
#[cfg_attr(feature = "no-panic", no_panic)]
pub fn new() -> Self {
// assume_init is safe here, since this is an array of MaybeUninit, which does not need
// to be initialized.
#[cfg(maybe_uninit)]
let bytes = [MaybeUninit::<u8>::uninit(); 24];
#[cfg(not(maybe_uninit))]
let bytes = unsafe { mem::uninitialized() };
Buffer { bytes }
}
+8 -52
View File
@@ -24,9 +24,6 @@ pub use crate::d2s_full_table::*;
use crate::d2s_intrinsics::*;
#[cfg(feature = "small")]
pub use crate::d2s_small_table::*;
#[cfg(not(maybe_uninit))]
use core::mem;
#[cfg(maybe_uninit)]
use core::mem::MaybeUninit;
pub const DOUBLE_MANTISSA_BITS: u32 = 52;
@@ -117,14 +114,7 @@ pub fn d2d(ieee_mantissa: u64, ieee_exponent: u32) -> FloatingDecimal64 {
let mut vr: u64;
let mut vp: u64;
let mut vm: u64;
#[cfg(not(maybe_uninit))]
{
vp = unsafe { mem::uninitialized() };
vm = unsafe { mem::uninitialized() };
}
#[cfg(maybe_uninit)]
let mut vp_uninit: MaybeUninit<u64> = MaybeUninit::uninit();
#[cfg(maybe_uninit)]
let mut vm_uninit: MaybeUninit<u64> = MaybeUninit::uninit();
let e10: i32;
let mut vm_is_trailing_zeros = false;
@@ -147,30 +137,13 @@ pub fn d2d(ieee_mantissa: u64, ieee_exponent: u32) -> FloatingDecimal64 {
DOUBLE_POW5_INV_SPLIT.get_unchecked(q as usize)
},
i as u32,
#[cfg(maybe_uninit)]
{
vp_uninit.as_mut_ptr()
},
#[cfg(not(maybe_uninit))]
{
&mut vp
},
#[cfg(maybe_uninit)]
{
vm_uninit.as_mut_ptr()
},
#[cfg(not(maybe_uninit))]
{
&mut vm
},
vp_uninit.as_mut_ptr(),
vm_uninit.as_mut_ptr(),
mm_shift,
)
};
#[cfg(maybe_uninit)]
{
vp = unsafe { vp_uninit.assume_init() };
vm = unsafe { vm_uninit.assume_init() };
}
vp = unsafe { vp_uninit.assume_init() };
vm = unsafe { vm_uninit.assume_init() };
if q <= 21 {
// This should use q <= 22, but I think 21 is also safe. Smaller values
// may still be safe, but it's more difficult to reason about them.
@@ -206,30 +179,13 @@ pub fn d2d(ieee_mantissa: u64, ieee_exponent: u32) -> FloatingDecimal64 {
DOUBLE_POW5_SPLIT.get_unchecked(i as usize)
},
j as u32,
#[cfg(maybe_uninit)]
{
vp_uninit.as_mut_ptr()
},
#[cfg(not(maybe_uninit))]
{
&mut vp
},
#[cfg(maybe_uninit)]
{
vm_uninit.as_mut_ptr()
},
#[cfg(not(maybe_uninit))]
{
&mut vm
},
vp_uninit.as_mut_ptr(),
vm_uninit.as_mut_ptr(),
mm_shift,
)
};
#[cfg(maybe_uninit)]
{
vp = unsafe { vp_uninit.assume_init() };
vm = unsafe { vm_uninit.assume_init() };
}
vp = unsafe { vp_uninit.assume_init() };
vm = unsafe { vm_uninit.assume_init() };
if q <= 1 {
// {vr,vp,vm} is trailing zeros if {mv,mp,mm} has at least q trailing 0 bits.
// mv = 4 * m2, so it always has at least two trailing 0 bits.