Skip to content

Commit 0006216

Browse files
committed
rustc_apfloat: make the crate #![no_std] explicitly.
1 parent bbd48e6 commit 0006216

File tree

3 files changed

+31
-27
lines changed

3 files changed

+31
-27
lines changed

src/librustc_apfloat/ieee.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::{Category, ExpInt, IEK_INF, IEK_NAN, IEK_ZERO};
22
use crate::{Float, FloatConvert, ParseError, Round, Status, StatusAnd};
33

4+
use core::cmp::{self, Ordering};
5+
use core::convert::TryFrom;
6+
use core::fmt::{self, Write};
7+
use core::marker::PhantomData;
8+
use core::mem;
9+
use core::ops::Neg;
410
use smallvec::{SmallVec, smallvec};
5-
use std::cmp::{self, Ordering};
6-
use std::convert::TryFrom;
7-
use std::fmt::{self, Write};
8-
use std::marker::PhantomData;
9-
use std::mem;
10-
use std::ops::Neg;
1111

1212
#[must_use]
1313
pub struct IeeeFloat<S> {
@@ -2287,8 +2287,8 @@ impl Loss {
22872287
/// Implementation details of IeeeFloat significands, such as big integer arithmetic.
22882288
/// As a rule of thumb, no functions in this module should dynamically allocate.
22892289
mod sig {
2290-
use std::cmp::Ordering;
2291-
use std::mem;
2290+
use core::cmp::Ordering;
2291+
use core::mem;
22922292
use super::{ExpInt, Limb, LIMB_BITS, limbs_for_bits, Loss};
22932293

22942294
pub(super) fn is_all_zeros(limbs: &[Limb]) -> bool {

src/librustc_apfloat/lib.rs

+20-16
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@
3131
//! This API is completely unstable and subject to change.
3232
3333
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
34+
#![no_std]
3435
#![forbid(unsafe_code)]
3536

3637
#![feature(nll)]
3738

38-
use std::cmp::Ordering;
39-
use std::fmt;
40-
use std::ops::{Neg, Add, Sub, Mul, Div, Rem};
41-
use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign};
42-
use std::str::FromStr;
39+
#[macro_use]
40+
extern crate alloc;
41+
42+
use core::cmp::Ordering;
43+
use core::fmt;
44+
use core::ops::{Neg, Add, Sub, Mul, Div, Rem};
45+
use core::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign};
46+
use core::str::FromStr;
4347

4448
bitflags::bitflags! {
4549
/// IEEE-754R 7: Default exception handling.
@@ -587,7 +591,7 @@ macro_rules! float_common_impls {
587591
}
588592
}
589593

590-
impl<$t> ::std::str::FromStr for $ty<$t> where Self: Float {
594+
impl<$t> ::core::str::FromStr for $ty<$t> where Self: Float {
591595
type Err = ParseError;
592596
fn from_str(s: &str) -> Result<Self, ParseError> {
593597
Self::from_str_r(s, Round::NearestTiesToEven).map(|x| x.value)
@@ -596,66 +600,66 @@ macro_rules! float_common_impls {
596600

597601
// Rounding ties to the nearest even, by default.
598602

599-
impl<$t> ::std::ops::Add for $ty<$t> where Self: Float {
603+
impl<$t> ::core::ops::Add for $ty<$t> where Self: Float {
600604
type Output = StatusAnd<Self>;
601605
fn add(self, rhs: Self) -> StatusAnd<Self> {
602606
self.add_r(rhs, Round::NearestTiesToEven)
603607
}
604608
}
605609

606-
impl<$t> ::std::ops::Sub for $ty<$t> where Self: Float {
610+
impl<$t> ::core::ops::Sub for $ty<$t> where Self: Float {
607611
type Output = StatusAnd<Self>;
608612
fn sub(self, rhs: Self) -> StatusAnd<Self> {
609613
self.sub_r(rhs, Round::NearestTiesToEven)
610614
}
611615
}
612616

613-
impl<$t> ::std::ops::Mul for $ty<$t> where Self: Float {
617+
impl<$t> ::core::ops::Mul for $ty<$t> where Self: Float {
614618
type Output = StatusAnd<Self>;
615619
fn mul(self, rhs: Self) -> StatusAnd<Self> {
616620
self.mul_r(rhs, Round::NearestTiesToEven)
617621
}
618622
}
619623

620-
impl<$t> ::std::ops::Div for $ty<$t> where Self: Float {
624+
impl<$t> ::core::ops::Div for $ty<$t> where Self: Float {
621625
type Output = StatusAnd<Self>;
622626
fn div(self, rhs: Self) -> StatusAnd<Self> {
623627
self.div_r(rhs, Round::NearestTiesToEven)
624628
}
625629
}
626630

627-
impl<$t> ::std::ops::Rem for $ty<$t> where Self: Float {
631+
impl<$t> ::core::ops::Rem for $ty<$t> where Self: Float {
628632
type Output = StatusAnd<Self>;
629633
fn rem(self, rhs: Self) -> StatusAnd<Self> {
630634
self.c_fmod(rhs)
631635
}
632636
}
633637

634-
impl<$t> ::std::ops::AddAssign for $ty<$t> where Self: Float {
638+
impl<$t> ::core::ops::AddAssign for $ty<$t> where Self: Float {
635639
fn add_assign(&mut self, rhs: Self) {
636640
*self = (*self + rhs).value;
637641
}
638642
}
639643

640-
impl<$t> ::std::ops::SubAssign for $ty<$t> where Self: Float {
644+
impl<$t> ::core::ops::SubAssign for $ty<$t> where Self: Float {
641645
fn sub_assign(&mut self, rhs: Self) {
642646
*self = (*self - rhs).value;
643647
}
644648
}
645649

646-
impl<$t> ::std::ops::MulAssign for $ty<$t> where Self: Float {
650+
impl<$t> ::core::ops::MulAssign for $ty<$t> where Self: Float {
647651
fn mul_assign(&mut self, rhs: Self) {
648652
*self = (*self * rhs).value;
649653
}
650654
}
651655

652-
impl<$t> ::std::ops::DivAssign for $ty<$t> where Self: Float {
656+
impl<$t> ::core::ops::DivAssign for $ty<$t> where Self: Float {
653657
fn div_assign(&mut self, rhs: Self) {
654658
*self = (*self / rhs).value;
655659
}
656660
}
657661

658-
impl<$t> ::std::ops::RemAssign for $ty<$t> where Self: Float {
662+
impl<$t> ::core::ops::RemAssign for $ty<$t> where Self: Float {
659663
fn rem_assign(&mut self, rhs: Self) {
660664
*self = (*self % rhs).value;
661665
}

src/librustc_apfloat/ppc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::{Category, ExpInt, Float, FloatConvert, Round, ParseError, Status, StatusAnd};
22
use crate::ieee;
33

4-
use std::cmp::Ordering;
5-
use std::fmt;
6-
use std::ops::Neg;
4+
use core::cmp::Ordering;
5+
use core::fmt;
6+
use core::ops::Neg;
77

88
#[must_use]
99
#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)]

0 commit comments

Comments
 (0)