// NOTE(flaper87): As of now, it keeps track of the whole error
// chain. Ideally, we should have a way to configure this either
// by using -Z verbose or just a CLI argument.
- if obligation.recursion_depth >= 0 {
- let derived_cause = DerivedObligationCause {
- parent_trait_ref: obligation.predicate.to_poly_trait_ref(),
- parent_code: Rc::new(obligation.cause.code.clone()),
- };
- let derived_code = variant(derived_cause);
- ObligationCause::new(obligation.cause.span, obligation.cause.body_id, derived_code)
- } else {
- obligation.cause.clone()
- }
+ let derived_cause = DerivedObligationCause {
+ parent_trait_ref: obligation.predicate.to_poly_trait_ref(),
+ parent_code: Rc::new(obligation.cause.code.clone()),
+ };
+ let derived_code = variant(derived_cause);
+ ObligationCause::new(obligation.cause.span, obligation.cause.body_id, derived_code)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn floor(self) -> f32 {
- // On MSVC LLVM will lower many math intrinsics to a call to the
- // corresponding function. On MSVC, however, many of these functions
- // aren't actually available as symbols to call, but rather they are all
- // `static inline` functions in header files. This means that from a C
- // perspective it's "compatible", but not so much from an ABI
- // perspective (which we're worried about).
- //
- // The inline header functions always just cast to a f64 and do their
- // operation, so we do that here as well, but only for MSVC targets.
- //
- // Note that there are many MSVC-specific float operations which
- // redirect to this comment, so `floorf` is just one case of a missing
- // function on MSVC, but there are many others elsewhere.
- #[cfg(target_env = "msvc")]
- return (self as f64).floor() as f32;
- #[cfg(not(target_env = "msvc"))]
- return unsafe { intrinsics::floorf32(self) };
+ unsafe { intrinsics::floorf32(self) }
}
/// Returns the smallest integer greater than or equal to a number.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn ceil(self) -> f32 {
- // see notes above in `floor`
- #[cfg(target_env = "msvc")]
- return (self as f64).ceil() as f32;
- #[cfg(not(target_env = "msvc"))]
- return unsafe { intrinsics::ceilf32(self) };
+ unsafe { intrinsics::ceilf32(self) }
}
/// Returns the nearest integer to a number. Round half-way cases away from
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn powf(self, n: f32) -> f32 {
- // see notes above in `floor`
- #[cfg(target_env = "msvc")]
- return (self as f64).powf(n as f64) as f32;
- #[cfg(not(target_env = "msvc"))]
- return unsafe { intrinsics::powf32(self, n) };
+ unsafe { intrinsics::powf32(self, n) }
}
/// Returns the square root of a number.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn exp(self) -> f32 {
- // see notes above in `floor`
- #[cfg(target_env = "msvc")]
- return (self as f64).exp() as f32;
- #[cfg(not(target_env = "msvc"))]
- return unsafe { intrinsics::expf32(self) };
+ unsafe { intrinsics::expf32(self) }
}
/// Returns `2^(self)`.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn ln(self) -> f32 {
- // see notes above in `floor`
- #[cfg(target_env = "msvc")]
- return (self as f64).ln() as f32;
- #[cfg(not(target_env = "msvc"))]
- return unsafe { intrinsics::logf32(self) };
+ unsafe { intrinsics::logf32(self) }
}
/// Returns the logarithm of the number with respect to an arbitrary base.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn log10(self) -> f32 {
- // see notes above in `floor`
- #[cfg(target_env = "msvc")]
- return (self as f64).log10() as f32;
- #[cfg(not(target_env = "msvc"))]
- return unsafe { intrinsics::log10f32(self) };
+ unsafe { intrinsics::log10f32(self) }
}
/// The positive difference of two numbers.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn sin(self) -> f32 {
- // see notes in `core::f32::Float::floor`
- #[cfg(target_env = "msvc")]
- return (self as f64).sin() as f32;
- #[cfg(not(target_env = "msvc"))]
- return unsafe { intrinsics::sinf32(self) };
+ unsafe { intrinsics::sinf32(self) }
}
/// Computes the cosine of a number (in radians).
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn cos(self) -> f32 {
- // see notes in `core::f32::Float::floor`
- #[cfg(target_env = "msvc")]
- return (self as f64).cos() as f32;
- #[cfg(not(target_env = "msvc"))]
- return unsafe { intrinsics::cosf32(self) };
+ unsafe { intrinsics::cosf32(self) }
}
/// Computes the tangent of a number (in radians).