Auto merge of #70826 - Centril:rollup-yn0hc1h, r=Centril
Rollup of 7 pull requests Successful merges: - #70553 (move OS constants to platform crate) - #70665 (Do not lose or reorder user-provided linker arguments) - #70750 (Match options directly in the Fuse implementation) - #70782 (Stop importing the float modules in documentation) - #70798 ("cannot resolve" → "cannot satisfy") - #70808 (Simplify dtor registration for HermitCore by using a list of destructors) - #70824 (Remove marker comments in libstd/lib.rs macro imports) Failed merges: r? @ghost
This commit is contained in:
commit
83f8c02eb9
36 changed files with 217 additions and 366 deletions
|
@ -1377,9 +1377,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.8"
|
version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
|
checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"compiler_builtins",
|
"compiler_builtins",
|
||||||
"libc",
|
"libc",
|
||||||
|
|
|
@ -28,6 +28,22 @@ impl<I> Fuse<I> {
|
||||||
#[stable(feature = "fused", since = "1.26.0")]
|
#[stable(feature = "fused", since = "1.26.0")]
|
||||||
impl<I> FusedIterator for Fuse<I> where I: Iterator {}
|
impl<I> FusedIterator for Fuse<I> where I: Iterator {}
|
||||||
|
|
||||||
|
/// Fuse the iterator if the expression is `None`.
|
||||||
|
macro_rules! fuse {
|
||||||
|
($self:ident . iter . $($call:tt)+) => {
|
||||||
|
match $self.iter {
|
||||||
|
Some(ref mut iter) => match iter.$($call)+ {
|
||||||
|
None => {
|
||||||
|
$self.iter = None;
|
||||||
|
None
|
||||||
|
}
|
||||||
|
item => item,
|
||||||
|
},
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<I> Iterator for Fuse<I>
|
impl<I> Iterator for Fuse<I>
|
||||||
where
|
where
|
||||||
|
@ -37,35 +53,36 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
default fn next(&mut self) -> Option<<I as Iterator>::Item> {
|
default fn next(&mut self) -> Option<<I as Iterator>::Item> {
|
||||||
let next = self.iter.as_mut()?.next();
|
fuse!(self.iter.next())
|
||||||
if next.is_none() {
|
|
||||||
self.iter = None;
|
|
||||||
}
|
|
||||||
next
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
default fn nth(&mut self, n: usize) -> Option<I::Item> {
|
default fn nth(&mut self, n: usize) -> Option<I::Item> {
|
||||||
let nth = self.iter.as_mut()?.nth(n);
|
fuse!(self.iter.nth(n))
|
||||||
if nth.is_none() {
|
|
||||||
self.iter = None;
|
|
||||||
}
|
|
||||||
nth
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
default fn last(self) -> Option<I::Item> {
|
default fn last(self) -> Option<I::Item> {
|
||||||
self.iter?.last()
|
match self.iter {
|
||||||
|
Some(iter) => iter.last(),
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
default fn count(self) -> usize {
|
default fn count(self) -> usize {
|
||||||
self.iter.map_or(0, I::count)
|
match self.iter {
|
||||||
|
Some(iter) => iter.count(),
|
||||||
|
None => 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
default fn size_hint(&self) -> (usize, Option<usize>) {
|
default fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
self.iter.as_ref().map_or((0, Some(0)), I::size_hint)
|
match self.iter {
|
||||||
|
Some(ref iter) => iter.size_hint(),
|
||||||
|
None => (0, Some(0)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -98,11 +115,7 @@ where
|
||||||
where
|
where
|
||||||
P: FnMut(&Self::Item) -> bool,
|
P: FnMut(&Self::Item) -> bool,
|
||||||
{
|
{
|
||||||
let found = self.iter.as_mut()?.find(predicate);
|
fuse!(self.iter.find(predicate))
|
||||||
if found.is_none() {
|
|
||||||
self.iter = None;
|
|
||||||
}
|
|
||||||
found
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,20 +126,12 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
default fn next_back(&mut self) -> Option<<I as Iterator>::Item> {
|
default fn next_back(&mut self) -> Option<<I as Iterator>::Item> {
|
||||||
let next = self.iter.as_mut()?.next_back();
|
fuse!(self.iter.next_back())
|
||||||
if next.is_none() {
|
|
||||||
self.iter = None;
|
|
||||||
}
|
|
||||||
next
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
default fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
|
default fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
|
||||||
let nth = self.iter.as_mut()?.nth_back(n);
|
fuse!(self.iter.nth_back(n))
|
||||||
if nth.is_none() {
|
|
||||||
self.iter = None;
|
|
||||||
}
|
|
||||||
nth
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -159,11 +164,7 @@ where
|
||||||
where
|
where
|
||||||
P: FnMut(&Self::Item) -> bool,
|
P: FnMut(&Self::Item) -> bool,
|
||||||
{
|
{
|
||||||
let found = self.iter.as_mut()?.rfind(predicate);
|
fuse!(self.iter.rfind(predicate))
|
||||||
if found.is_none() {
|
|
||||||
self.iter = None;
|
|
||||||
}
|
|
||||||
found
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,42 +174,30 @@ where
|
||||||
I: ExactSizeIterator,
|
I: ExactSizeIterator,
|
||||||
{
|
{
|
||||||
default fn len(&self) -> usize {
|
default fn len(&self) -> usize {
|
||||||
self.iter.as_ref().map_or(0, I::len)
|
match self.iter {
|
||||||
|
Some(ref iter) => iter.len(),
|
||||||
|
None => 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default fn is_empty(&self) -> bool {
|
default fn is_empty(&self) -> bool {
|
||||||
self.iter.as_ref().map_or(true, I::is_empty)
|
match self.iter {
|
||||||
|
Some(ref iter) => iter.is_empty(),
|
||||||
|
None => true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: for `I: FusedIterator`, we assume that the iterator is always `Some`
|
// NOTE: for `I: FusedIterator`, we assume that the iterator is always `Some`.
|
||||||
impl<I: FusedIterator> Fuse<I> {
|
// Implementing this as a directly-expanded macro helps codegen performance.
|
||||||
#[inline(always)]
|
macro_rules! unchecked {
|
||||||
fn as_inner(&self) -> &I {
|
($self:ident) => {
|
||||||
match self.iter {
|
match $self {
|
||||||
Some(ref iter) => iter,
|
Fuse { iter: Some(iter) } => iter,
|
||||||
// SAFETY: the specialized iterator never sets `None`
|
// SAFETY: the specialized iterator never sets `None`
|
||||||
None => unsafe { intrinsics::unreachable() },
|
Fuse { iter: None } => unsafe { intrinsics::unreachable() },
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn as_inner_mut(&mut self) -> &mut I {
|
|
||||||
match self.iter {
|
|
||||||
Some(ref mut iter) => iter,
|
|
||||||
// SAFETY: the specialized iterator never sets `None`
|
|
||||||
None => unsafe { intrinsics::unreachable() },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn into_inner(self) -> I {
|
|
||||||
match self.iter {
|
|
||||||
Some(iter) => iter,
|
|
||||||
// SAFETY: the specialized iterator never sets `None`
|
|
||||||
None => unsafe { intrinsics::unreachable() },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "fused", since = "1.26.0")]
|
#[stable(feature = "fused", since = "1.26.0")]
|
||||||
|
@ -218,27 +207,27 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> Option<<I as Iterator>::Item> {
|
fn next(&mut self) -> Option<<I as Iterator>::Item> {
|
||||||
self.as_inner_mut().next()
|
unchecked!(self).next()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn nth(&mut self, n: usize) -> Option<I::Item> {
|
fn nth(&mut self, n: usize) -> Option<I::Item> {
|
||||||
self.as_inner_mut().nth(n)
|
unchecked!(self).nth(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn last(self) -> Option<I::Item> {
|
fn last(self) -> Option<I::Item> {
|
||||||
self.into_inner().last()
|
unchecked!(self).last()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn count(self) -> usize {
|
fn count(self) -> usize {
|
||||||
self.into_inner().count()
|
unchecked!(self).count()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
self.as_inner().size_hint()
|
unchecked!(self).size_hint()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -248,7 +237,7 @@ where
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: Try<Ok = Acc>,
|
||||||
{
|
{
|
||||||
self.as_inner_mut().try_fold(init, fold)
|
unchecked!(self).try_fold(init, fold)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -256,7 +245,7 @@ where
|
||||||
where
|
where
|
||||||
Fold: FnMut(Acc, Self::Item) -> Acc,
|
Fold: FnMut(Acc, Self::Item) -> Acc,
|
||||||
{
|
{
|
||||||
self.into_inner().fold(init, fold)
|
unchecked!(self).fold(init, fold)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -264,7 +253,7 @@ where
|
||||||
where
|
where
|
||||||
P: FnMut(&Self::Item) -> bool,
|
P: FnMut(&Self::Item) -> bool,
|
||||||
{
|
{
|
||||||
self.as_inner_mut().find(predicate)
|
unchecked!(self).find(predicate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,12 +264,12 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next_back(&mut self) -> Option<<I as Iterator>::Item> {
|
fn next_back(&mut self) -> Option<<I as Iterator>::Item> {
|
||||||
self.as_inner_mut().next_back()
|
unchecked!(self).next_back()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
|
fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
|
||||||
self.as_inner_mut().nth_back(n)
|
unchecked!(self).nth_back(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -290,7 +279,7 @@ where
|
||||||
Fold: FnMut(Acc, Self::Item) -> R,
|
Fold: FnMut(Acc, Self::Item) -> R,
|
||||||
R: Try<Ok = Acc>,
|
R: Try<Ok = Acc>,
|
||||||
{
|
{
|
||||||
self.as_inner_mut().try_rfold(init, fold)
|
unchecked!(self).try_rfold(init, fold)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -298,7 +287,7 @@ where
|
||||||
where
|
where
|
||||||
Fold: FnMut(Acc, Self::Item) -> Acc,
|
Fold: FnMut(Acc, Self::Item) -> Acc,
|
||||||
{
|
{
|
||||||
self.into_inner().rfold(init, fold)
|
unchecked!(self).rfold(init, fold)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -306,7 +295,7 @@ where
|
||||||
where
|
where
|
||||||
P: FnMut(&Self::Item) -> bool,
|
P: FnMut(&Self::Item) -> bool,
|
||||||
{
|
{
|
||||||
self.as_inner_mut().rfind(predicate)
|
unchecked!(self).rfind(predicate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,11 +305,11 @@ where
|
||||||
I: ExactSizeIterator + FusedIterator,
|
I: ExactSizeIterator + FusedIterator,
|
||||||
{
|
{
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
self.as_inner().len()
|
unchecked!(self).len()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_empty(&self) -> bool {
|
fn is_empty(&self) -> bool {
|
||||||
self.as_inner().is_empty()
|
unchecked!(self).is_empty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,9 +394,7 @@ impl f32 {
|
||||||
/// Converts radians to degrees.
|
/// Converts radians to degrees.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32::consts;
|
/// let angle = std::f32::consts::PI;
|
||||||
///
|
|
||||||
/// let angle = consts::PI;
|
|
||||||
///
|
///
|
||||||
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
|
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
|
||||||
///
|
///
|
||||||
|
@ -413,11 +411,9 @@ impl f32 {
|
||||||
/// Converts degrees to radians.
|
/// Converts degrees to radians.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32::consts;
|
|
||||||
///
|
|
||||||
/// let angle = 180.0f32;
|
/// let angle = 180.0f32;
|
||||||
///
|
///
|
||||||
/// let abs_difference = (angle.to_radians() - consts::PI).abs();
|
/// let abs_difference = (angle.to_radians() - std::f32::consts::PI).abs();
|
||||||
///
|
///
|
||||||
/// assert!(abs_difference <= f32::EPSILON);
|
/// assert!(abs_difference <= f32::EPSILON);
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -407,9 +407,7 @@ impl f64 {
|
||||||
/// Converts radians to degrees.
|
/// Converts radians to degrees.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64::consts;
|
/// let angle = std::f64::consts::PI;
|
||||||
///
|
|
||||||
/// let angle = consts::PI;
|
|
||||||
///
|
///
|
||||||
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
|
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
|
||||||
///
|
///
|
||||||
|
@ -427,11 +425,9 @@ impl f64 {
|
||||||
/// Converts degrees to radians.
|
/// Converts degrees to radians.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64::consts;
|
|
||||||
///
|
|
||||||
/// let angle = 180.0_f64;
|
/// let angle = 180.0_f64;
|
||||||
///
|
///
|
||||||
/// let abs_difference = (angle.to_radians() - consts::PI).abs();
|
/// let abs_difference = (angle.to_radians() - std::f64::consts::PI).abs();
|
||||||
///
|
///
|
||||||
/// assert!(abs_difference < 1e-10);
|
/// assert!(abs_difference < 1e-10);
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -98,8 +98,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// assert!(!(3..5).contains(&2));
|
/// assert!(!(3..5).contains(&2));
|
||||||
/// assert!( (3..5).contains(&3));
|
/// assert!( (3..5).contains(&3));
|
||||||
/// assert!( (3..5).contains(&4));
|
/// assert!( (3..5).contains(&4));
|
||||||
|
@ -198,8 +196,6 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// assert!(!(3..).contains(&2));
|
/// assert!(!(3..).contains(&2));
|
||||||
/// assert!( (3..).contains(&3));
|
/// assert!( (3..).contains(&3));
|
||||||
/// assert!( (3..).contains(&1_000_000_000));
|
/// assert!( (3..).contains(&1_000_000_000));
|
||||||
|
@ -282,8 +278,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// assert!( (..5).contains(&-1_000_000_000));
|
/// assert!( (..5).contains(&-1_000_000_000));
|
||||||
/// assert!( (..5).contains(&4));
|
/// assert!( (..5).contains(&4));
|
||||||
/// assert!(!(..5).contains(&5));
|
/// assert!(!(..5).contains(&5));
|
||||||
|
@ -453,8 +447,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// assert!(!(3..=5).contains(&2));
|
/// assert!(!(3..=5).contains(&2));
|
||||||
/// assert!( (3..=5).contains(&3));
|
/// assert!( (3..=5).contains(&3));
|
||||||
/// assert!( (3..=5).contains(&4));
|
/// assert!( (3..=5).contains(&4));
|
||||||
|
@ -581,8 +573,6 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// assert!( (..=5).contains(&-1_000_000_000));
|
/// assert!( (..=5).contains(&-1_000_000_000));
|
||||||
/// assert!( (..=5).contains(&5));
|
/// assert!( (..=5).contains(&5));
|
||||||
/// assert!(!(..=5).contains(&6));
|
/// assert!(!(..=5).contains(&6));
|
||||||
|
@ -721,8 +711,6 @@ pub trait RangeBounds<T: ?Sized> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// assert!( (3..5).contains(&4));
|
/// assert!( (3..5).contains(&4));
|
||||||
/// assert!(!(3..5).contains(&2));
|
/// assert!(!(3..5).contains(&2));
|
||||||
///
|
///
|
||||||
|
|
|
@ -505,10 +505,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
||||||
cmd.args(args);
|
cmd.args(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(ref args) = sess.opts.debugging_opts.pre_link_args {
|
cmd.args(&sess.opts.debugging_opts.pre_link_args);
|
||||||
cmd.args(args);
|
|
||||||
}
|
|
||||||
cmd.args(&sess.opts.debugging_opts.pre_link_arg);
|
|
||||||
|
|
||||||
if sess.target.target.options.is_like_fuchsia {
|
if sess.target.target.options.is_like_fuchsia {
|
||||||
let prefix = match sess.opts.debugging_opts.sanitizer {
|
let prefix = match sess.opts.debugging_opts.sanitizer {
|
||||||
|
@ -1302,18 +1299,17 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(
|
||||||
cmd.gc_sections(keep_metadata);
|
cmd.gc_sections(keep_metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
let used_link_args = &codegen_results.crate_info.link_args;
|
let attr_link_args = codegen_results.crate_info.link_args.iter();
|
||||||
|
let user_link_args: Vec<_> =
|
||||||
|
sess.opts.cg.link_args.iter().chain(attr_link_args).cloned().collect();
|
||||||
|
|
||||||
if crate_type == config::CrateType::Executable {
|
if crate_type == config::CrateType::Executable {
|
||||||
let mut position_independent_executable = false;
|
let mut position_independent_executable = false;
|
||||||
|
|
||||||
if t.options.position_independent_executables {
|
if t.options.position_independent_executables {
|
||||||
let empty_vec = Vec::new();
|
if is_pic(sess)
|
||||||
let args = sess.opts.cg.link_args.as_ref().unwrap_or(&empty_vec);
|
&& !sess.crt_static(Some(crate_type))
|
||||||
let more_args = &sess.opts.cg.link_arg;
|
&& !user_link_args.iter().any(|x| x == "-static")
|
||||||
let mut args = args.iter().chain(more_args.iter()).chain(used_link_args.iter());
|
|
||||||
|
|
||||||
if is_pic(sess) && !sess.crt_static(Some(crate_type)) && !args.any(|x| *x == "-static")
|
|
||||||
{
|
{
|
||||||
position_independent_executable = true;
|
position_independent_executable = true;
|
||||||
}
|
}
|
||||||
|
@ -1444,11 +1440,7 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(
|
||||||
|
|
||||||
// Finally add all the linker arguments provided on the command line along
|
// Finally add all the linker arguments provided on the command line along
|
||||||
// with any #[link_args] attributes found inside the crate
|
// with any #[link_args] attributes found inside the crate
|
||||||
if let Some(ref args) = sess.opts.cg.link_args {
|
cmd.args(&user_link_args);
|
||||||
cmd.args(args);
|
|
||||||
}
|
|
||||||
cmd.args(&sess.opts.cg.link_arg);
|
|
||||||
cmd.args(&used_link_args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// # Native library linking
|
// # Native library linking
|
||||||
|
|
|
@ -382,7 +382,7 @@ fn test_codegen_options_tracking_hash() {
|
||||||
opts.cg.linker = Some(PathBuf::from("linker"));
|
opts.cg.linker = Some(PathBuf::from("linker"));
|
||||||
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
|
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
|
||||||
|
|
||||||
opts.cg.link_args = Some(vec![String::from("abc"), String::from("def")]);
|
opts.cg.link_args = vec![String::from("abc"), String::from("def")];
|
||||||
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
|
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
|
||||||
|
|
||||||
opts.cg.link_dead_code = true;
|
opts.cg.link_dead_code = true;
|
||||||
|
|
|
@ -296,9 +296,17 @@ macro_rules! options {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
// Sometimes different options need to build a common structure.
|
||||||
|
// That structure can kept in one of the options' fields, the others become dummy.
|
||||||
|
macro_rules! redirect_field {
|
||||||
|
($cg:ident.link_arg) => { $cg.link_args };
|
||||||
|
($cg:ident.pre_link_arg) => { $cg.pre_link_args };
|
||||||
|
($cg:ident.$field:ident) => { $cg.$field };
|
||||||
|
}
|
||||||
|
|
||||||
$(
|
$(
|
||||||
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
|
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
|
||||||
$parse(&mut cg.$opt, v)
|
$parse(&mut redirect_field!(cg.$opt), v)
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
|
|
||||||
|
@ -643,9 +651,9 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
||||||
"this option is deprecated and does nothing"),
|
"this option is deprecated and does nothing"),
|
||||||
linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
|
linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
|
||||||
"system linker to link outputs with"),
|
"system linker to link outputs with"),
|
||||||
link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
|
link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
|
||||||
"a single extra argument to append to the linker invocation (can be used several times)"),
|
"a single extra argument to append to the linker invocation (can be used several times)"),
|
||||||
link_args: Option<Vec<String>> = (None, parse_opt_list, [UNTRACKED],
|
link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
|
||||||
"extra arguments to append to the linker invocation (space separated)"),
|
"extra arguments to append to the linker invocation (space separated)"),
|
||||||
link_dead_code: bool = (false, parse_bool, [UNTRACKED],
|
link_dead_code: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"don't let linker strip dead code (turning it on can be used for code coverage)"),
|
"don't let linker strip dead code (turning it on can be used for code coverage)"),
|
||||||
|
@ -876,9 +884,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||||
"make rustc print the total optimization fuel used by a crate"),
|
"make rustc print the total optimization fuel used by a crate"),
|
||||||
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
|
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
|
||||||
"force all crates to be `rustc_private` unstable"),
|
"force all crates to be `rustc_private` unstable"),
|
||||||
pre_link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
|
pre_link_arg: (/* redirected to pre_link_args */) = ((), parse_string_push, [UNTRACKED],
|
||||||
"a single extra argument to prepend the linker invocation (can be used several times)"),
|
"a single extra argument to prepend the linker invocation (can be used several times)"),
|
||||||
pre_link_args: Option<Vec<String>> = (None, parse_opt_list, [UNTRACKED],
|
pre_link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
|
||||||
"extra arguments to prepend to the linker invocation (space separated)"),
|
"extra arguments to prepend to the linker invocation (space separated)"),
|
||||||
profile: bool = (false, parse_bool, [TRACKED],
|
profile: bool = (false, parse_bool, [TRACKED],
|
||||||
"insert profiling code"),
|
"insert profiling code"),
|
||||||
|
|
|
@ -1377,7 +1377,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0283);
|
let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0283);
|
||||||
err.note(&format!("cannot resolve `{}`", predicate));
|
err.note(&format!("cannot satisfy `{}`", predicate));
|
||||||
if let ObligationCauseCode::ItemObligation(def_id) = obligation.cause.code {
|
if let ObligationCauseCode::ItemObligation(def_id) = obligation.cause.code {
|
||||||
self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id());
|
self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id());
|
||||||
} else if let (
|
} else if let (
|
||||||
|
@ -1407,7 +1407,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
// LL | const fn const_val<T: Sized>() -> usize {
|
// LL | const fn const_val<T: Sized>() -> usize {
|
||||||
// | --------- - required by this bound in `Tt::const_val`
|
// | --------- - required by this bound in `Tt::const_val`
|
||||||
// |
|
// |
|
||||||
// = note: cannot resolve `_: Tt`
|
// = note: cannot satisfy `_: Tt`
|
||||||
|
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
span.shrink_to_hi(),
|
span.shrink_to_hi(),
|
||||||
|
@ -1457,7 +1457,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0284);
|
let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0284);
|
||||||
err.note(&format!("cannot resolve `{}`", predicate));
|
err.note(&format!("cannot satisfy `{}`", predicate));
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1469,10 +1469,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||||
self.tcx.sess,
|
self.tcx.sess,
|
||||||
span,
|
span,
|
||||||
E0284,
|
E0284,
|
||||||
"type annotations needed: cannot resolve `{}`",
|
"type annotations needed: cannot satisfy `{}`",
|
||||||
predicate,
|
predicate,
|
||||||
);
|
);
|
||||||
err.span_label(span, &format!("cannot resolve `{}`", predicate));
|
err.span_label(span, &format!("cannot satisfy `{}`", predicate));
|
||||||
err
|
err
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,7 +41,7 @@ dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }
|
||||||
fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }
|
fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }
|
||||||
|
|
||||||
[target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies]
|
[target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies]
|
||||||
hermit-abi = { version = "0.1", features = ['rustc-dep-of-std'] }
|
hermit-abi = { version = "0.1.10", features = ['rustc-dep-of-std'] }
|
||||||
|
|
||||||
[target.wasm32-wasi.dependencies]
|
[target.wasm32-wasi.dependencies]
|
||||||
wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false }
|
wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false }
|
||||||
|
|
|
@ -112,8 +112,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let x = 3.6_f32;
|
/// let x = 3.6_f32;
|
||||||
/// let y = -3.6_f32;
|
/// let y = -3.6_f32;
|
||||||
/// let abs_difference_x = (x.fract() - 0.6).abs();
|
/// let abs_difference_x = (x.fract() - 0.6).abs();
|
||||||
|
@ -135,8 +133,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let x = 3.5_f32;
|
/// let x = 3.5_f32;
|
||||||
/// let y = -3.5_f32;
|
/// let y = -3.5_f32;
|
||||||
///
|
///
|
||||||
|
@ -164,8 +160,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let f = 3.5_f32;
|
/// let f = 3.5_f32;
|
||||||
///
|
///
|
||||||
/// assert_eq!(f.signum(), 1.0);
|
/// assert_eq!(f.signum(), 1.0);
|
||||||
|
@ -190,8 +184,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let f = 3.5_f32;
|
/// let f = 3.5_f32;
|
||||||
///
|
///
|
||||||
/// assert_eq!(f.copysign(0.42), 3.5_f32);
|
/// assert_eq!(f.copysign(0.42), 3.5_f32);
|
||||||
|
@ -217,8 +209,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let m = 10.0_f32;
|
/// let m = 10.0_f32;
|
||||||
/// let x = 4.0_f32;
|
/// let x = 4.0_f32;
|
||||||
/// let b = 60.0_f32;
|
/// let b = 60.0_f32;
|
||||||
|
@ -301,8 +291,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let x = 2.0_f32;
|
/// let x = 2.0_f32;
|
||||||
/// let abs_difference = (x.powi(2) - (x * x)).abs();
|
/// let abs_difference = (x.powi(2) - (x * x)).abs();
|
||||||
///
|
///
|
||||||
|
@ -320,8 +308,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let x = 2.0_f32;
|
/// let x = 2.0_f32;
|
||||||
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
|
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
|
||||||
///
|
///
|
||||||
|
@ -341,8 +327,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let positive = 4.0_f32;
|
/// let positive = 4.0_f32;
|
||||||
/// let negative = -4.0_f32;
|
/// let negative = -4.0_f32;
|
||||||
///
|
///
|
||||||
|
@ -363,8 +347,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let one = 1.0f32;
|
/// let one = 1.0f32;
|
||||||
/// // e^1
|
/// // e^1
|
||||||
/// let e = one.exp();
|
/// let e = one.exp();
|
||||||
|
@ -386,8 +368,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let f = 2.0f32;
|
/// let f = 2.0f32;
|
||||||
///
|
///
|
||||||
/// // 2^2 - 4 == 0
|
/// // 2^2 - 4 == 0
|
||||||
|
@ -407,8 +387,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let one = 1.0f32;
|
/// let one = 1.0f32;
|
||||||
/// // e^1
|
/// // e^1
|
||||||
/// let e = one.exp();
|
/// let e = one.exp();
|
||||||
|
@ -434,8 +412,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let five = 5.0f32;
|
/// let five = 5.0f32;
|
||||||
///
|
///
|
||||||
/// // log5(5) - 1 == 0
|
/// // log5(5) - 1 == 0
|
||||||
|
@ -455,8 +431,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let two = 2.0f32;
|
/// let two = 2.0f32;
|
||||||
///
|
///
|
||||||
/// // log2(2) - 1 == 0
|
/// // log2(2) - 1 == 0
|
||||||
|
@ -479,8 +453,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let ten = 10.0f32;
|
/// let ten = 10.0f32;
|
||||||
///
|
///
|
||||||
/// // log10(10) - 1 == 0
|
/// // log10(10) - 1 == 0
|
||||||
|
@ -503,8 +475,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let x = 3.0f32;
|
/// let x = 3.0f32;
|
||||||
/// let y = -3.0f32;
|
/// let y = -3.0f32;
|
||||||
///
|
///
|
||||||
|
@ -536,8 +506,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let x = 8.0f32;
|
/// let x = 8.0f32;
|
||||||
///
|
///
|
||||||
/// // x^(1/3) - 2 == 0
|
/// // x^(1/3) - 2 == 0
|
||||||
|
@ -558,8 +526,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let x = 2.0f32;
|
/// let x = 2.0f32;
|
||||||
/// let y = 3.0f32;
|
/// let y = 3.0f32;
|
||||||
///
|
///
|
||||||
|
@ -580,9 +546,7 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let x = std::f32::consts::FRAC_PI_2;
|
||||||
///
|
|
||||||
/// let x = f32::consts::FRAC_PI_2;
|
|
||||||
///
|
///
|
||||||
/// let abs_difference = (x.sin() - 1.0).abs();
|
/// let abs_difference = (x.sin() - 1.0).abs();
|
||||||
///
|
///
|
||||||
|
@ -600,9 +564,7 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let x = 2.0 * std::f32::consts::PI;
|
||||||
///
|
|
||||||
/// let x = 2.0 * f32::consts::PI;
|
|
||||||
///
|
///
|
||||||
/// let abs_difference = (x.cos() - 1.0).abs();
|
/// let abs_difference = (x.cos() - 1.0).abs();
|
||||||
///
|
///
|
||||||
|
@ -620,9 +582,7 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let x = std::f32::consts::FRAC_PI_4;
|
||||||
///
|
|
||||||
/// let x = f32::consts::FRAC_PI_4;
|
|
||||||
/// let abs_difference = (x.tan() - 1.0).abs();
|
/// let abs_difference = (x.tan() - 1.0).abs();
|
||||||
///
|
///
|
||||||
/// assert!(abs_difference <= f32::EPSILON);
|
/// assert!(abs_difference <= f32::EPSILON);
|
||||||
|
@ -641,12 +601,10 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let f = std::f32::consts::FRAC_PI_2;
|
||||||
///
|
|
||||||
/// let f = f32::consts::FRAC_PI_2;
|
|
||||||
///
|
///
|
||||||
/// // asin(sin(pi/2))
|
/// // asin(sin(pi/2))
|
||||||
/// let abs_difference = (f.sin().asin() - f32::consts::FRAC_PI_2).abs();
|
/// let abs_difference = (f.sin().asin() - std::f32::consts::FRAC_PI_2).abs();
|
||||||
///
|
///
|
||||||
/// assert!(abs_difference <= f32::EPSILON);
|
/// assert!(abs_difference <= f32::EPSILON);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -664,12 +622,10 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let f = std::f32::consts::FRAC_PI_4;
|
||||||
///
|
|
||||||
/// let f = f32::consts::FRAC_PI_4;
|
|
||||||
///
|
///
|
||||||
/// // acos(cos(pi/4))
|
/// // acos(cos(pi/4))
|
||||||
/// let abs_difference = (f.cos().acos() - f32::consts::FRAC_PI_4).abs();
|
/// let abs_difference = (f.cos().acos() - std::f32::consts::FRAC_PI_4).abs();
|
||||||
///
|
///
|
||||||
/// assert!(abs_difference <= f32::EPSILON);
|
/// assert!(abs_difference <= f32::EPSILON);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -686,8 +642,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let f = 1.0f32;
|
/// let f = 1.0f32;
|
||||||
///
|
///
|
||||||
/// // atan(tan(1))
|
/// // atan(tan(1))
|
||||||
|
@ -712,8 +666,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// // Positive angles measured counter-clockwise
|
/// // Positive angles measured counter-clockwise
|
||||||
/// // from positive x axis
|
/// // from positive x axis
|
||||||
/// // -pi/4 radians (45 deg clockwise)
|
/// // -pi/4 radians (45 deg clockwise)
|
||||||
|
@ -724,8 +676,8 @@ impl f32 {
|
||||||
/// let x2 = -3.0f32;
|
/// let x2 = -3.0f32;
|
||||||
/// let y2 = 3.0f32;
|
/// let y2 = 3.0f32;
|
||||||
///
|
///
|
||||||
/// let abs_difference_1 = (y1.atan2(x1) - (-f32::consts::FRAC_PI_4)).abs();
|
/// let abs_difference_1 = (y1.atan2(x1) - (-std::f32::consts::FRAC_PI_4)).abs();
|
||||||
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * f32::consts::FRAC_PI_4)).abs();
|
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * std::f32::consts::FRAC_PI_4)).abs();
|
||||||
///
|
///
|
||||||
/// assert!(abs_difference_1 <= f32::EPSILON);
|
/// assert!(abs_difference_1 <= f32::EPSILON);
|
||||||
/// assert!(abs_difference_2 <= f32::EPSILON);
|
/// assert!(abs_difference_2 <= f32::EPSILON);
|
||||||
|
@ -743,9 +695,7 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let x = std::f32::consts::FRAC_PI_4;
|
||||||
///
|
|
||||||
/// let x = f32::consts::FRAC_PI_4;
|
|
||||||
/// let f = x.sin_cos();
|
/// let f = x.sin_cos();
|
||||||
///
|
///
|
||||||
/// let abs_difference_0 = (f.0 - x.sin()).abs();
|
/// let abs_difference_0 = (f.0 - x.sin()).abs();
|
||||||
|
@ -766,8 +716,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let x = 6.0f32;
|
/// let x = 6.0f32;
|
||||||
///
|
///
|
||||||
/// // e^(ln(6)) - 1
|
/// // e^(ln(6)) - 1
|
||||||
|
@ -788,9 +736,7 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let x = std::f32::consts::E - 1.0;
|
||||||
///
|
|
||||||
/// let x = f32::consts::E - 1.0;
|
|
||||||
///
|
///
|
||||||
/// // ln(1 + (e - 1)) == ln(e) == 1
|
/// // ln(1 + (e - 1)) == ln(e) == 1
|
||||||
/// let abs_difference = (x.ln_1p() - 1.0).abs();
|
/// let abs_difference = (x.ln_1p() - 1.0).abs();
|
||||||
|
@ -809,9 +755,7 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let e = std::f32::consts::E;
|
||||||
///
|
|
||||||
/// let e = f32::consts::E;
|
|
||||||
/// let x = 1.0f32;
|
/// let x = 1.0f32;
|
||||||
///
|
///
|
||||||
/// let f = x.sinh();
|
/// let f = x.sinh();
|
||||||
|
@ -833,9 +777,7 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let e = std::f32::consts::E;
|
||||||
///
|
|
||||||
/// let e = f32::consts::E;
|
|
||||||
/// let x = 1.0f32;
|
/// let x = 1.0f32;
|
||||||
/// let f = x.cosh();
|
/// let f = x.cosh();
|
||||||
/// // Solving cosh() at 1 gives this result
|
/// // Solving cosh() at 1 gives this result
|
||||||
|
@ -857,9 +799,7 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let e = std::f32::consts::E;
|
||||||
///
|
|
||||||
/// let e = f32::consts::E;
|
|
||||||
/// let x = 1.0f32;
|
/// let x = 1.0f32;
|
||||||
///
|
///
|
||||||
/// let f = x.tanh();
|
/// let f = x.tanh();
|
||||||
|
@ -881,8 +821,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let x = 1.0f32;
|
/// let x = 1.0f32;
|
||||||
/// let f = x.sinh().asinh();
|
/// let f = x.sinh().asinh();
|
||||||
///
|
///
|
||||||
|
@ -906,8 +844,6 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
|
||||||
///
|
|
||||||
/// let x = 1.0f32;
|
/// let x = 1.0f32;
|
||||||
/// let f = x.cosh().acosh();
|
/// let f = x.cosh().acosh();
|
||||||
///
|
///
|
||||||
|
@ -927,9 +863,7 @@ impl f32 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// let e = std::f32::consts::E;
|
||||||
///
|
|
||||||
/// let e = f32::consts::E;
|
|
||||||
/// let f = e.tanh().atanh();
|
/// let f = e.tanh().atanh();
|
||||||
///
|
///
|
||||||
/// let abs_difference = (f - e).abs();
|
/// let abs_difference = (f - e).abs();
|
||||||
|
|
|
@ -133,8 +133,6 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
|
||||||
///
|
|
||||||
/// let x = 3.5_f64;
|
/// let x = 3.5_f64;
|
||||||
/// let y = -3.5_f64;
|
/// let y = -3.5_f64;
|
||||||
///
|
///
|
||||||
|
@ -162,8 +160,6 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
|
||||||
///
|
|
||||||
/// let f = 3.5_f64;
|
/// let f = 3.5_f64;
|
||||||
///
|
///
|
||||||
/// assert_eq!(f.signum(), 1.0);
|
/// assert_eq!(f.signum(), 1.0);
|
||||||
|
@ -188,8 +184,6 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
|
||||||
///
|
|
||||||
/// let f = 3.5_f64;
|
/// let f = 3.5_f64;
|
||||||
///
|
///
|
||||||
/// assert_eq!(f.copysign(0.42), 3.5_f64);
|
/// assert_eq!(f.copysign(0.42), 3.5_f64);
|
||||||
|
@ -554,9 +548,7 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let x = std::f64::consts::FRAC_PI_2;
|
||||||
///
|
|
||||||
/// let x = f64::consts::FRAC_PI_2;
|
|
||||||
///
|
///
|
||||||
/// let abs_difference = (x.sin() - 1.0).abs();
|
/// let abs_difference = (x.sin() - 1.0).abs();
|
||||||
///
|
///
|
||||||
|
@ -574,9 +566,7 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let x = 2.0 * std::f64::consts::PI;
|
||||||
///
|
|
||||||
/// let x = 2.0 * f64::consts::PI;
|
|
||||||
///
|
///
|
||||||
/// let abs_difference = (x.cos() - 1.0).abs();
|
/// let abs_difference = (x.cos() - 1.0).abs();
|
||||||
///
|
///
|
||||||
|
@ -594,9 +584,7 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let x = std::f64::consts::FRAC_PI_4;
|
||||||
///
|
|
||||||
/// let x = f64::consts::FRAC_PI_4;
|
|
||||||
/// let abs_difference = (x.tan() - 1.0).abs();
|
/// let abs_difference = (x.tan() - 1.0).abs();
|
||||||
///
|
///
|
||||||
/// assert!(abs_difference < 1e-14);
|
/// assert!(abs_difference < 1e-14);
|
||||||
|
@ -615,12 +603,10 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let f = std::f64::consts::FRAC_PI_2;
|
||||||
///
|
|
||||||
/// let f = f64::consts::FRAC_PI_2;
|
|
||||||
///
|
///
|
||||||
/// // asin(sin(pi/2))
|
/// // asin(sin(pi/2))
|
||||||
/// let abs_difference = (f.sin().asin() - f64::consts::FRAC_PI_2).abs();
|
/// let abs_difference = (f.sin().asin() - std::f64::consts::FRAC_PI_2).abs();
|
||||||
///
|
///
|
||||||
/// assert!(abs_difference < 1e-10);
|
/// assert!(abs_difference < 1e-10);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -638,12 +624,10 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let f = std::f64::consts::FRAC_PI_4;
|
||||||
///
|
|
||||||
/// let f = f64::consts::FRAC_PI_4;
|
|
||||||
///
|
///
|
||||||
/// // acos(cos(pi/4))
|
/// // acos(cos(pi/4))
|
||||||
/// let abs_difference = (f.cos().acos() - f64::consts::FRAC_PI_4).abs();
|
/// let abs_difference = (f.cos().acos() - std::f64::consts::FRAC_PI_4).abs();
|
||||||
///
|
///
|
||||||
/// assert!(abs_difference < 1e-10);
|
/// assert!(abs_difference < 1e-10);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -684,8 +668,6 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
|
||||||
///
|
|
||||||
/// // Positive angles measured counter-clockwise
|
/// // Positive angles measured counter-clockwise
|
||||||
/// // from positive x axis
|
/// // from positive x axis
|
||||||
/// // -pi/4 radians (45 deg clockwise)
|
/// // -pi/4 radians (45 deg clockwise)
|
||||||
|
@ -696,8 +678,8 @@ impl f64 {
|
||||||
/// let x2 = -3.0_f64;
|
/// let x2 = -3.0_f64;
|
||||||
/// let y2 = 3.0_f64;
|
/// let y2 = 3.0_f64;
|
||||||
///
|
///
|
||||||
/// let abs_difference_1 = (y1.atan2(x1) - (-f64::consts::FRAC_PI_4)).abs();
|
/// let abs_difference_1 = (y1.atan2(x1) - (-std::f64::consts::FRAC_PI_4)).abs();
|
||||||
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * f64::consts::FRAC_PI_4)).abs();
|
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * std::f64::consts::FRAC_PI_4)).abs();
|
||||||
///
|
///
|
||||||
/// assert!(abs_difference_1 < 1e-10);
|
/// assert!(abs_difference_1 < 1e-10);
|
||||||
/// assert!(abs_difference_2 < 1e-10);
|
/// assert!(abs_difference_2 < 1e-10);
|
||||||
|
@ -715,9 +697,7 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let x = std::f64::consts::FRAC_PI_4;
|
||||||
///
|
|
||||||
/// let x = f64::consts::FRAC_PI_4;
|
|
||||||
/// let f = x.sin_cos();
|
/// let f = x.sin_cos();
|
||||||
///
|
///
|
||||||
/// let abs_difference_0 = (f.0 - x.sin()).abs();
|
/// let abs_difference_0 = (f.0 - x.sin()).abs();
|
||||||
|
@ -758,9 +738,7 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let x = std::f64::consts::E - 1.0;
|
||||||
///
|
|
||||||
/// let x = f64::consts::E - 1.0;
|
|
||||||
///
|
///
|
||||||
/// // ln(1 + (e - 1)) == ln(e) == 1
|
/// // ln(1 + (e - 1)) == ln(e) == 1
|
||||||
/// let abs_difference = (x.ln_1p() - 1.0).abs();
|
/// let abs_difference = (x.ln_1p() - 1.0).abs();
|
||||||
|
@ -779,9 +757,7 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let e = std::f64::consts::E;
|
||||||
///
|
|
||||||
/// let e = f64::consts::E;
|
|
||||||
/// let x = 1.0_f64;
|
/// let x = 1.0_f64;
|
||||||
///
|
///
|
||||||
/// let f = x.sinh();
|
/// let f = x.sinh();
|
||||||
|
@ -803,9 +779,7 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let e = std::f64::consts::E;
|
||||||
///
|
|
||||||
/// let e = f64::consts::E;
|
|
||||||
/// let x = 1.0_f64;
|
/// let x = 1.0_f64;
|
||||||
/// let f = x.cosh();
|
/// let f = x.cosh();
|
||||||
/// // Solving cosh() at 1 gives this result
|
/// // Solving cosh() at 1 gives this result
|
||||||
|
@ -827,9 +801,7 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let e = std::f64::consts::E;
|
||||||
///
|
|
||||||
/// let e = f64::consts::E;
|
|
||||||
/// let x = 1.0_f64;
|
/// let x = 1.0_f64;
|
||||||
///
|
///
|
||||||
/// let f = x.tanh();
|
/// let f = x.tanh();
|
||||||
|
@ -893,9 +865,7 @@ impl f64 {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f64;
|
/// let e = std::f64::consts::E;
|
||||||
///
|
|
||||||
/// let e = f64::consts::E;
|
|
||||||
/// let f = e.tanh().atanh();
|
/// let f = e.tanh().atanh();
|
||||||
///
|
///
|
||||||
/// let abs_difference = (f - e).abs();
|
/// let abs_difference = (f - e).abs();
|
||||||
|
|
|
@ -517,20 +517,8 @@ pub use std_detect::detect;
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[allow(deprecated, deprecated_in_future)]
|
#[allow(deprecated, deprecated_in_future)]
|
||||||
pub use core::{
|
pub use core::{
|
||||||
// Stable
|
assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, r#try, todo,
|
||||||
assert_eq,
|
unimplemented, unreachable, write, writeln,
|
||||||
assert_ne,
|
|
||||||
debug_assert,
|
|
||||||
debug_assert_eq,
|
|
||||||
debug_assert_ne,
|
|
||||||
// Unstable
|
|
||||||
matches,
|
|
||||||
r#try,
|
|
||||||
todo,
|
|
||||||
unimplemented,
|
|
||||||
unreachable,
|
|
||||||
write,
|
|
||||||
writeln,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Re-export built-in macros defined through libcore.
|
// Re-export built-in macros defined through libcore.
|
||||||
|
|
|
@ -1,4 +1,36 @@
|
||||||
#![cfg(target_thread_local)]
|
#![cfg(target_thread_local)]
|
||||||
#![unstable(feature = "thread_local_internals", issue = "none")]
|
#![unstable(feature = "thread_local_internals", issue = "none")]
|
||||||
|
|
||||||
pub use crate::sys_common::thread_local::register_dtor_fallback as register_dtor;
|
// Simplify dtor registration by using a list of destructors.
|
||||||
|
// The this solution works like the implementation of macOS and
|
||||||
|
// doesn't additional OS support
|
||||||
|
|
||||||
|
use crate::cell::Cell;
|
||||||
|
use crate::ptr;
|
||||||
|
|
||||||
|
#[thread_local]
|
||||||
|
static DTORS: Cell<*mut List> = Cell::new(ptr::null_mut());
|
||||||
|
|
||||||
|
type List = Vec<(*mut u8, unsafe extern "C" fn(*mut u8))>;
|
||||||
|
|
||||||
|
pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
|
||||||
|
if DTORS.get().is_null() {
|
||||||
|
let v: Box<List> = box Vec::new();
|
||||||
|
DTORS.set(Box::into_raw(v));
|
||||||
|
}
|
||||||
|
|
||||||
|
let list: &mut List = &mut *DTORS.get();
|
||||||
|
list.push((t, dtor));
|
||||||
|
}
|
||||||
|
|
||||||
|
// every thread call this function to run through all possible destructors
|
||||||
|
pub unsafe fn run_dtors() {
|
||||||
|
let mut ptr = DTORS.replace(ptr::null_mut());
|
||||||
|
while !ptr.is_null() {
|
||||||
|
let list = Box::from_raw(ptr);
|
||||||
|
for (ptr, dtor) in list.into_iter() {
|
||||||
|
dtor(ptr);
|
||||||
|
}
|
||||||
|
ptr = DTORS.replace(ptr::null_mut());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ use crate::io::{IoSlice, IoSliceMut, SeekFrom};
|
||||||
use crate::path::{Path, PathBuf};
|
use crate::path::{Path, PathBuf};
|
||||||
use crate::sys::cvt;
|
use crate::sys::cvt;
|
||||||
use crate::sys::hermit::abi;
|
use crate::sys::hermit::abi;
|
||||||
|
use crate::sys::hermit::abi::{O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
|
||||||
use crate::sys::hermit::fd::FileDesc;
|
use crate::sys::hermit::fd::FileDesc;
|
||||||
use crate::sys::time::SystemTime;
|
use crate::sys::time::SystemTime;
|
||||||
use crate::sys::{unsupported, Void};
|
use crate::sys::{unsupported, Void};
|
||||||
|
@ -17,14 +18,6 @@ pub use crate::sys_common::fs::copy;
|
||||||
fn cstr(path: &Path) -> io::Result<CString> {
|
fn cstr(path: &Path) -> io::Result<CString> {
|
||||||
Ok(CString::new(path.as_os_str().as_bytes())?)
|
Ok(CString::new(path.as_os_str().as_bytes())?)
|
||||||
}
|
}
|
||||||
//const O_ACCMODE: i32 = 00000003;
|
|
||||||
const O_RDONLY: i32 = 00000000;
|
|
||||||
const O_WRONLY: i32 = 00000001;
|
|
||||||
const O_RDWR: i32 = 00000002;
|
|
||||||
const O_CREAT: i32 = 00000100;
|
|
||||||
const O_EXCL: i32 = 00000200;
|
|
||||||
const O_TRUNC: i32 = 00001000;
|
|
||||||
const O_APPEND: i32 = 00002000;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct File(FileDesc);
|
pub struct File(FileDesc);
|
||||||
|
|
|
@ -103,6 +103,7 @@ pub unsafe extern "C" fn runtime_entry(
|
||||||
argv: *const *const c_char,
|
argv: *const *const c_char,
|
||||||
env: *const *const c_char,
|
env: *const *const c_char,
|
||||||
) -> ! {
|
) -> ! {
|
||||||
|
use crate::sys::hermit::fast_thread_local::run_dtors;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn main(argc: isize, argv: *const *const c_char) -> i32;
|
fn main(argc: isize, argv: *const *const c_char) -> i32;
|
||||||
}
|
}
|
||||||
|
@ -112,6 +113,7 @@ pub unsafe extern "C" fn runtime_entry(
|
||||||
|
|
||||||
let result = main(argc as isize, argv);
|
let result = main(argc as isize, argv);
|
||||||
|
|
||||||
|
run_dtors();
|
||||||
abi::exit(result);
|
abi::exit(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,36 +1,14 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use crate::ffi::CStr;
|
use crate::ffi::CStr;
|
||||||
use crate::fmt;
|
|
||||||
use crate::io;
|
use crate::io;
|
||||||
use crate::mem;
|
use crate::mem;
|
||||||
use crate::sys::hermit::abi;
|
use crate::sys::hermit::abi;
|
||||||
|
use crate::sys::hermit::fast_thread_local::run_dtors;
|
||||||
use crate::time::Duration;
|
use crate::time::Duration;
|
||||||
|
|
||||||
pub type Tid = abi::Tid;
|
pub type Tid = abi::Tid;
|
||||||
|
|
||||||
/// Priority of a task
|
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy)]
|
|
||||||
pub struct Priority(u8);
|
|
||||||
|
|
||||||
impl Priority {
|
|
||||||
pub const fn into(self) -> u8 {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const fn from(x: u8) -> Self {
|
|
||||||
Priority(x)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for Priority {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
write!(f, "{}", self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const NORMAL_PRIO: Priority = Priority::from(2);
|
|
||||||
|
|
||||||
pub struct Thread {
|
pub struct Thread {
|
||||||
tid: Tid,
|
tid: Tid,
|
||||||
}
|
}
|
||||||
|
@ -51,8 +29,8 @@ impl Thread {
|
||||||
let ret = abi::spawn(
|
let ret = abi::spawn(
|
||||||
&mut tid as *mut Tid,
|
&mut tid as *mut Tid,
|
||||||
thread_start,
|
thread_start,
|
||||||
p as usize,
|
&*p as *const _ as *const u8 as usize,
|
||||||
Priority::into(NORMAL_PRIO),
|
abi::Priority::into(abi::NORMAL_PRIO),
|
||||||
core_id,
|
core_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -69,6 +47,9 @@ impl Thread {
|
||||||
unsafe {
|
unsafe {
|
||||||
// Finally, let's run some code.
|
// Finally, let's run some code.
|
||||||
Box::from_raw(main as *mut Box<dyn FnOnce()>)();
|
Box::from_raw(main as *mut Box<dyn FnOnce()>)();
|
||||||
|
|
||||||
|
// run all destructors
|
||||||
|
run_dtors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,60 +1,26 @@
|
||||||
#![allow(dead_code)] // not used on all platforms
|
|
||||||
|
|
||||||
use crate::collections::BTreeMap;
|
|
||||||
use crate::ptr;
|
|
||||||
use crate::sync::atomic::{AtomicUsize, Ordering};
|
|
||||||
use crate::sys_common::mutex::Mutex;
|
|
||||||
|
|
||||||
pub type Key = usize;
|
pub type Key = usize;
|
||||||
|
|
||||||
type Dtor = unsafe extern "C" fn(*mut u8);
|
#[inline]
|
||||||
|
pub unsafe fn create(_dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key {
|
||||||
static NEXT_KEY: AtomicUsize = AtomicUsize::new(0);
|
panic!("should not be used on the wasm target");
|
||||||
|
|
||||||
static mut KEYS: *mut BTreeMap<Key, Option<Dtor>> = ptr::null_mut();
|
|
||||||
static KEYS_LOCK: Mutex = Mutex::new();
|
|
||||||
|
|
||||||
#[thread_local]
|
|
||||||
static mut LOCALS: *mut BTreeMap<Key, *mut u8> = ptr::null_mut();
|
|
||||||
|
|
||||||
unsafe fn keys() -> &'static mut BTreeMap<Key, Option<Dtor>> {
|
|
||||||
if KEYS.is_null() {
|
|
||||||
KEYS = Box::into_raw(Box::new(BTreeMap::new()));
|
|
||||||
}
|
|
||||||
&mut *KEYS
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn locals() -> &'static mut BTreeMap<Key, *mut u8> {
|
|
||||||
if LOCALS.is_null() {
|
|
||||||
LOCALS = Box::into_raw(Box::new(BTreeMap::new()));
|
|
||||||
}
|
|
||||||
&mut *LOCALS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn create(dtor: Option<Dtor>) -> Key {
|
pub unsafe fn set(_key: Key, _value: *mut u8) {
|
||||||
let key = NEXT_KEY.fetch_add(1, Ordering::SeqCst);
|
panic!("should not be used on the wasm target");
|
||||||
let _guard = KEYS_LOCK.lock();
|
|
||||||
keys().insert(key, dtor);
|
|
||||||
key
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn get(key: Key) -> *mut u8 {
|
pub unsafe fn get(_key: Key) -> *mut u8 {
|
||||||
if let Some(&entry) = locals().get(&key) { entry } else { ptr::null_mut() }
|
panic!("should not be used on the wasm target");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn set(key: Key, value: *mut u8) {
|
pub unsafe fn destroy(_key: Key) {
|
||||||
locals().insert(key, value);
|
panic!("should not be used on the wasm target");
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub unsafe fn destroy(key: Key) {
|
|
||||||
keys().remove(&key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn requires_synchronized_create() -> bool {
|
pub fn requires_synchronized_create() -> bool {
|
||||||
false
|
panic!("should not be used on the wasm target");
|
||||||
}
|
}
|
||||||
|
|
10
src/test/run-make-fulldeps/link-args-order/Makefile
Normal file
10
src/test/run-make-fulldeps/link-args-order/Makefile
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# ignore-msvc
|
||||||
|
|
||||||
|
-include ../tools.mk
|
||||||
|
|
||||||
|
RUSTC_FLAGS = -C linker-flavor=ld -C link-arg=a -C link-args="b c" -C link-args="d e" -C link-arg=f
|
||||||
|
RUSTC_FLAGS_PRE = -C linker-flavor=ld -Z pre-link-arg=a -Z pre-link-args="b c" -Z pre-link-args="d e" -Z pre-link-arg=f
|
||||||
|
|
||||||
|
all:
|
||||||
|
$(RUSTC) $(RUSTC_FLAGS) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f" "g"'
|
||||||
|
$(RUSTC) $(RUSTC_FLAGS_PRE) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
|
6
src/test/run-make-fulldeps/link-args-order/empty.rs
Normal file
6
src/test/run-make-fulldeps/link-args-order/empty.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#![feature(link_args)]
|
||||||
|
|
||||||
|
#[link_args = "g"]
|
||||||
|
extern "C" {}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -10,7 +10,7 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]);
|
||||||
| cannot infer type
|
| cannot infer type
|
||||||
| help: use the fully qualified path to an implementation: `<Type as A>::C`
|
| help: use the fully qualified path to an implementation: `<Type as A>::C`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `_: A`
|
= note: cannot satisfy `_: A`
|
||||||
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
|
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
|
||||||
|
|
||||||
error[E0283]: type annotations needed
|
error[E0283]: type annotations needed
|
||||||
|
@ -25,7 +25,7 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]);
|
||||||
| cannot infer type
|
| cannot infer type
|
||||||
| help: use the fully qualified path to an implementation: `<Type as A>::C`
|
| help: use the fully qualified path to an implementation: `<Type as A>::C`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `_: A`
|
= note: cannot satisfy `_: A`
|
||||||
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
|
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
|
@ -22,7 +22,7 @@ LL | fn return_n(&self) -> [u8; Bar::X];
|
||||||
| cannot infer type
|
| cannot infer type
|
||||||
| help: use the fully qualified path to an implementation: `<Type as Bar>::X`
|
| help: use the fully qualified path to an implementation: `<Type as Bar>::X`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `_: Bar`
|
= note: cannot satisfy `_: Bar`
|
||||||
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
|
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
|
@ -6,7 +6,7 @@ LL | trait Foo: Iterator<Item = i32> {}
|
||||||
LL | trait Bar: Foo<Item = u32> {}
|
LL | trait Bar: Foo<Item = u32> {}
|
||||||
| ^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
|
| ^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `<Self as std::iter::Iterator>::Item == i32`
|
= note: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
|
||||||
|
|
||||||
error[E0284]: type annotations needed
|
error[E0284]: type annotations needed
|
||||||
--> $DIR/associated-types-overridden-binding.rs:7:21
|
--> $DIR/associated-types-overridden-binding.rs:7:21
|
||||||
|
@ -16,7 +16,7 @@ LL | trait I32Iterator = Iterator<Item = i32>;
|
||||||
LL | trait U32Iterator = I32Iterator<Item = u32>;
|
LL | trait U32Iterator = I32Iterator<Item = u32>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
|
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `<Self as std::iter::Iterator>::Item == i32`
|
= note: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0284]: type annotations needed
|
||||||
LL | let x: isize = Foo::bar();
|
LL | let x: isize = Foo::bar();
|
||||||
| ^^^^^^^^ cannot infer type
|
| ^^^^^^^^ cannot infer type
|
||||||
|
|
|
|
||||||
= note: cannot resolve `<_ as Foo>::A == _`
|
= note: cannot satisfy `<_ as Foo>::A == _`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | fn create() -> u32;
|
||||||
LL | let cont: u32 = Generator::create();
|
LL | let cont: u32 = Generator::create();
|
||||||
| ^^^^^^^^^^^^^^^^^ cannot infer type
|
| ^^^^^^^^^^^^^^^^^ cannot infer type
|
||||||
|
|
|
|
||||||
= note: cannot resolve `_: Generator`
|
= note: cannot satisfy `_: Generator`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0284]: type annotations needed
|
||||||
LL | self.input_stream(&mut stream);
|
LL | self.input_stream(&mut stream);
|
||||||
| ^^^^^^^^^^^^ cannot infer type for type parameter `H` declared on the trait `StreamHash`
|
| ^^^^^^^^^^^^ cannot infer type for type parameter `H` declared on the trait `StreamHash`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `<_ as StreamHasher>::S == <H as StreamHasher>::S`
|
= note: cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | trait Foo {
|
||||||
LL | where &'a T : Foo,
|
LL | where &'a T : Foo,
|
||||||
| ^^^ cannot infer type for reference `&'a T`
|
| ^^^ cannot infer type for reference `&'a T`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `&'a T: Foo`
|
= note: cannot satisfy `&'a T: Foo`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL |
|
||||||
LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}
|
LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}
|
||||||
| ^^^^^^^^^^^ cannot infer type for type parameter `T0`
|
| ^^^^^^^^^^^ cannot infer type for type parameter `T0`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `T0: Trait0<'l0>`
|
= note: cannot satisfy `T0: Trait0<'l0>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | trait Foo { fn xxx(&self); }
|
||||||
LL | let _ = <S5<_>>::xxx;
|
LL | let _ = <S5<_>>::xxx;
|
||||||
| ^^^^^^^^^^^^ cannot infer type for struct `S5<_>`
|
| ^^^^^^^^^^^^ cannot infer type for struct `S5<_>`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `S5<_>: Foo`
|
= note: cannot satisfy `S5<_>: Foo`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ LL | const ARR_LEN: usize = Tt::const_val::<[i8; 123]>();
|
||||||
LL | const fn const_val<T: Sized>() -> usize {
|
LL | const fn const_val<T: Sized>() -> usize {
|
||||||
| --------- - required by this bound in `Tt::const_val`
|
| --------- - required by this bound in `Tt::const_val`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `_: Tt`
|
= note: cannot satisfy `_: Tt`
|
||||||
|
|
||||||
error[E0080]: evaluation of constant value failed
|
error[E0080]: evaluation of constant value failed
|
||||||
--> $DIR/issue-54954.rs:13:15
|
--> $DIR/issue-54954.rs:13:15
|
||||||
|
|
|
@ -16,7 +16,7 @@ LL | fn new(slice: &[u8; Foo::SIZE]) -> Self;
|
||||||
| cannot infer type
|
| cannot infer type
|
||||||
| help: use the fully qualified path to an implementation: `<Type as Foo>::SIZE`
|
| help: use the fully qualified path to an implementation: `<Type as Foo>::SIZE`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `_: Foo`
|
= note: cannot satisfy `_: Foo`
|
||||||
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
|
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0284]: type annotations needed
|
||||||
LL | l.iter().map(f).collect()?
|
LL | l.iter().map(f).collect()?
|
||||||
| ^^^^^^^ cannot infer type
|
| ^^^^^^^ cannot infer type
|
||||||
|
|
|
|
||||||
= note: cannot resolve `<_ as std::ops::Try>::Ok == _`
|
= note: cannot satisfy `<_ as std::ops::Try>::Ok == _`
|
||||||
help: consider specifying the type argument in the method call
|
help: consider specifying the type argument in the method call
|
||||||
|
|
|
|
||||||
LL | l.iter().map(f).collect::<B>()?
|
LL | l.iter().map(f).collect::<B>()?
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | fn new() -> T;
|
||||||
LL | let _f: base::Foo = base::HasNew::new();
|
LL | let _f: base::Foo = base::HasNew::new();
|
||||||
| ^^^^^^^^^^^^^^^^^ cannot infer type
|
| ^^^^^^^^^^^^^^^^^ cannot infer type
|
||||||
|
|
|
|
||||||
= note: cannot resolve `_: base::HasNew<base::Foo>`
|
= note: cannot satisfy `_: base::HasNew<base::Foo>`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,5 @@ fn main() {
|
||||||
foo(42);
|
foo(42);
|
||||||
//~^ ERROR type annotations needed
|
//~^ ERROR type annotations needed
|
||||||
//~| NOTE cannot infer type
|
//~| NOTE cannot infer type
|
||||||
//~| NOTE cannot resolve
|
//~| NOTE cannot satisfy
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | fn foo<T: Into<String>>(x: i32) {}
|
||||||
LL | foo(42);
|
LL | foo(42);
|
||||||
| ^^^ cannot infer type for type parameter `T` declared on the function `foo`
|
| ^^^ cannot infer type for type parameter `T` declared on the function `foo`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `_: std::convert::Into<std::string::String>`
|
= note: cannot satisfy `_: std::convert::Into<std::string::String>`
|
||||||
help: consider specifying the type argument in the function call
|
help: consider specifying the type argument in the function call
|
||||||
|
|
|
|
||||||
LL | foo::<T>(42);
|
LL | foo::<T>(42);
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | trait Foo: Sized {
|
||||||
LL | where &'a T : Foo,
|
LL | where &'a T : Foo,
|
||||||
| ^^^ cannot infer type for reference `&'a T`
|
| ^^^ cannot infer type for reference `&'a T`
|
||||||
|
|
|
|
||||||
= note: cannot resolve `&'a T: Foo`
|
= note: cannot satisfy `&'a T: Foo`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue