1
Fork 0

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:
bors 2020-04-05 23:08:44 +00:00
commit 83f8c02eb9
36 changed files with 217 additions and 366 deletions

View file

@ -1377,9 +1377,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.1.8"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
dependencies = [
"compiler_builtins",
"libc",

View file

@ -28,6 +28,22 @@ impl<I> Fuse<I> {
#[stable(feature = "fused", since = "1.26.0")]
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")]
impl<I> Iterator for Fuse<I>
where
@ -37,35 +53,36 @@ where
#[inline]
default fn next(&mut self) -> Option<<I as Iterator>::Item> {
let next = self.iter.as_mut()?.next();
if next.is_none() {
self.iter = None;
}
next
fuse!(self.iter.next())
}
#[inline]
default fn nth(&mut self, n: usize) -> Option<I::Item> {
let nth = self.iter.as_mut()?.nth(n);
if nth.is_none() {
self.iter = None;
}
nth
fuse!(self.iter.nth(n))
}
#[inline]
default fn last(self) -> Option<I::Item> {
self.iter?.last()
match self.iter {
Some(iter) => iter.last(),
None => None,
}
}
#[inline]
default fn count(self) -> usize {
self.iter.map_or(0, I::count)
match self.iter {
Some(iter) => iter.count(),
None => 0,
}
}
#[inline]
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]
@ -98,11 +115,7 @@ where
where
P: FnMut(&Self::Item) -> bool,
{
let found = self.iter.as_mut()?.find(predicate);
if found.is_none() {
self.iter = None;
}
found
fuse!(self.iter.find(predicate))
}
}
@ -113,20 +126,12 @@ where
{
#[inline]
default fn next_back(&mut self) -> Option<<I as Iterator>::Item> {
let next = self.iter.as_mut()?.next_back();
if next.is_none() {
self.iter = None;
}
next
fuse!(self.iter.next_back())
}
#[inline]
default fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
let nth = self.iter.as_mut()?.nth_back(n);
if nth.is_none() {
self.iter = None;
}
nth
fuse!(self.iter.nth_back(n))
}
#[inline]
@ -159,11 +164,7 @@ where
where
P: FnMut(&Self::Item) -> bool,
{
let found = self.iter.as_mut()?.rfind(predicate);
if found.is_none() {
self.iter = None;
}
found
fuse!(self.iter.rfind(predicate))
}
}
@ -173,42 +174,30 @@ where
I: ExactSizeIterator,
{
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 {
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`
impl<I: FusedIterator> Fuse<I> {
#[inline(always)]
fn as_inner(&self) -> &I {
match self.iter {
Some(ref iter) => iter,
// NOTE: for `I: FusedIterator`, we assume that the iterator is always `Some`.
// Implementing this as a directly-expanded macro helps codegen performance.
macro_rules! unchecked {
($self:ident) => {
match $self {
Fuse { iter: Some(iter) } => iter,
// 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")]
@ -218,27 +207,27 @@ where
{
#[inline]
fn next(&mut self) -> Option<<I as Iterator>::Item> {
self.as_inner_mut().next()
unchecked!(self).next()
}
#[inline]
fn nth(&mut self, n: usize) -> Option<I::Item> {
self.as_inner_mut().nth(n)
unchecked!(self).nth(n)
}
#[inline]
fn last(self) -> Option<I::Item> {
self.into_inner().last()
unchecked!(self).last()
}
#[inline]
fn count(self) -> usize {
self.into_inner().count()
unchecked!(self).count()
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.as_inner().size_hint()
unchecked!(self).size_hint()
}
#[inline]
@ -248,7 +237,7 @@ where
Fold: FnMut(Acc, Self::Item) -> R,
R: Try<Ok = Acc>,
{
self.as_inner_mut().try_fold(init, fold)
unchecked!(self).try_fold(init, fold)
}
#[inline]
@ -256,7 +245,7 @@ where
where
Fold: FnMut(Acc, Self::Item) -> Acc,
{
self.into_inner().fold(init, fold)
unchecked!(self).fold(init, fold)
}
#[inline]
@ -264,7 +253,7 @@ where
where
P: FnMut(&Self::Item) -> bool,
{
self.as_inner_mut().find(predicate)
unchecked!(self).find(predicate)
}
}
@ -275,12 +264,12 @@ where
{
#[inline]
fn next_back(&mut self) -> Option<<I as Iterator>::Item> {
self.as_inner_mut().next_back()
unchecked!(self).next_back()
}
#[inline]
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]
@ -290,7 +279,7 @@ where
Fold: FnMut(Acc, Self::Item) -> R,
R: Try<Ok = Acc>,
{
self.as_inner_mut().try_rfold(init, fold)
unchecked!(self).try_rfold(init, fold)
}
#[inline]
@ -298,7 +287,7 @@ where
where
Fold: FnMut(Acc, Self::Item) -> Acc,
{
self.into_inner().rfold(init, fold)
unchecked!(self).rfold(init, fold)
}
#[inline]
@ -306,7 +295,7 @@ where
where
P: FnMut(&Self::Item) -> bool,
{
self.as_inner_mut().rfind(predicate)
unchecked!(self).rfind(predicate)
}
}
@ -316,11 +305,11 @@ where
I: ExactSizeIterator + FusedIterator,
{
fn len(&self) -> usize {
self.as_inner().len()
unchecked!(self).len()
}
fn is_empty(&self) -> bool {
self.as_inner().is_empty()
unchecked!(self).is_empty()
}
}

View file

@ -394,9 +394,7 @@ impl f32 {
/// Converts radians to degrees.
///
/// ```
/// use std::f32::consts;
///
/// let angle = consts::PI;
/// let angle = std::f32::consts::PI;
///
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
///
@ -413,11 +411,9 @@ impl f32 {
/// Converts degrees to radians.
///
/// ```
/// use std::f32::consts;
///
/// 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);
/// ```

View file

@ -407,9 +407,7 @@ impl f64 {
/// Converts radians to degrees.
///
/// ```
/// use std::f64::consts;
///
/// let angle = consts::PI;
/// let angle = std::f64::consts::PI;
///
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
///
@ -427,11 +425,9 @@ impl f64 {
/// Converts degrees to radians.
///
/// ```
/// use std::f64::consts;
///
/// 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);
/// ```

View file

@ -98,8 +98,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!(!(3..5).contains(&2));
/// assert!( (3..5).contains(&3));
/// assert!( (3..5).contains(&4));
@ -198,8 +196,6 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!(!(3..).contains(&2));
/// assert!( (3..).contains(&3));
/// assert!( (3..).contains(&1_000_000_000));
@ -282,8 +278,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!( (..5).contains(&-1_000_000_000));
/// assert!( (..5).contains(&4));
/// assert!(!(..5).contains(&5));
@ -453,8 +447,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!(!(3..=5).contains(&2));
/// assert!( (3..=5).contains(&3));
/// assert!( (3..=5).contains(&4));
@ -581,8 +573,6 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!( (..=5).contains(&-1_000_000_000));
/// assert!( (..=5).contains(&5));
/// assert!(!(..=5).contains(&6));
@ -721,8 +711,6 @@ pub trait RangeBounds<T: ?Sized> {
/// # Examples
///
/// ```
/// use std::f32;
///
/// assert!( (3..5).contains(&4));
/// assert!(!(3..5).contains(&2));
///

View file

@ -505,10 +505,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
cmd.args(args);
}
}
if let Some(ref args) = sess.opts.debugging_opts.pre_link_args {
cmd.args(args);
}
cmd.args(&sess.opts.debugging_opts.pre_link_arg);
cmd.args(&sess.opts.debugging_opts.pre_link_args);
if sess.target.target.options.is_like_fuchsia {
let prefix = match sess.opts.debugging_opts.sanitizer {
@ -1302,18 +1299,17 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(
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 {
let mut position_independent_executable = false;
if t.options.position_independent_executables {
let empty_vec = Vec::new();
let args = sess.opts.cg.link_args.as_ref().unwrap_or(&empty_vec);
let more_args = &sess.opts.cg.link_arg;
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")
if is_pic(sess)
&& !sess.crt_static(Some(crate_type))
&& !user_link_args.iter().any(|x| x == "-static")
{
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
// with any #[link_args] attributes found inside the crate
if let Some(ref args) = sess.opts.cg.link_args {
cmd.args(args);
}
cmd.args(&sess.opts.cg.link_arg);
cmd.args(&used_link_args);
cmd.args(&user_link_args);
}
// # Native library linking

View file

@ -382,7 +382,7 @@ fn test_codegen_options_tracking_hash() {
opts.cg.linker = Some(PathBuf::from("linker"));
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());
opts.cg.link_dead_code = true;

View file

@ -296,9 +296,17 @@ macro_rules! options {
use std::path::PathBuf;
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 {
$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"),
linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
"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)"),
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)"),
link_dead_code: bool = (false, parse_bool, [UNTRACKED],
"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"),
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
"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)"),
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)"),
profile: bool = (false, parse_bool, [TRACKED],
"insert profiling code"),

View file

@ -1377,7 +1377,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
return;
}
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 {
self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id());
} else if let (
@ -1407,7 +1407,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
// LL | const fn const_val<T: Sized>() -> usize {
// | --------- - required by this bound in `Tt::const_val`
// |
// = note: cannot resolve `_: Tt`
// = note: cannot satisfy `_: Tt`
err.span_suggestion_verbose(
span.shrink_to_hi(),
@ -1457,7 +1457,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
return;
}
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
}
@ -1469,10 +1469,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
self.tcx.sess,
span,
E0284,
"type annotations needed: cannot resolve `{}`",
"type annotations needed: cannot satisfy `{}`",
predicate,
);
err.span_label(span, &format!("cannot resolve `{}`", predicate));
err.span_label(span, &format!("cannot satisfy `{}`", predicate));
err
}
};

View file

@ -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'] }
[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]
wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false }

View file

@ -112,8 +112,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 3.6_f32;
/// let y = -3.6_f32;
/// let abs_difference_x = (x.fract() - 0.6).abs();
@ -135,8 +133,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 3.5_f32;
/// let y = -3.5_f32;
///
@ -164,8 +160,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let f = 3.5_f32;
///
/// assert_eq!(f.signum(), 1.0);
@ -190,8 +184,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let f = 3.5_f32;
///
/// assert_eq!(f.copysign(0.42), 3.5_f32);
@ -217,8 +209,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let m = 10.0_f32;
/// let x = 4.0_f32;
/// let b = 60.0_f32;
@ -301,8 +291,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 2.0_f32;
/// let abs_difference = (x.powi(2) - (x * x)).abs();
///
@ -320,8 +308,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 2.0_f32;
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
///
@ -341,8 +327,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let positive = 4.0_f32;
/// let negative = -4.0_f32;
///
@ -363,8 +347,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let one = 1.0f32;
/// // e^1
/// let e = one.exp();
@ -386,8 +368,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let f = 2.0f32;
///
/// // 2^2 - 4 == 0
@ -407,8 +387,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let one = 1.0f32;
/// // e^1
/// let e = one.exp();
@ -434,8 +412,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let five = 5.0f32;
///
/// // log5(5) - 1 == 0
@ -455,8 +431,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let two = 2.0f32;
///
/// // log2(2) - 1 == 0
@ -479,8 +453,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let ten = 10.0f32;
///
/// // log10(10) - 1 == 0
@ -503,8 +475,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 3.0f32;
/// let y = -3.0f32;
///
@ -536,8 +506,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 8.0f32;
///
/// // x^(1/3) - 2 == 0
@ -558,8 +526,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 2.0f32;
/// let y = 3.0f32;
///
@ -580,9 +546,7 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = f32::consts::FRAC_PI_2;
/// let x = std::f32::consts::FRAC_PI_2;
///
/// let abs_difference = (x.sin() - 1.0).abs();
///
@ -600,9 +564,7 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 2.0 * f32::consts::PI;
/// let x = 2.0 * std::f32::consts::PI;
///
/// let abs_difference = (x.cos() - 1.0).abs();
///
@ -620,9 +582,7 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = f32::consts::FRAC_PI_4;
/// let x = std::f32::consts::FRAC_PI_4;
/// let abs_difference = (x.tan() - 1.0).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
@ -641,12 +601,10 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let f = f32::consts::FRAC_PI_2;
/// let f = std::f32::consts::FRAC_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);
/// ```
@ -664,12 +622,10 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let f = f32::consts::FRAC_PI_4;
/// let f = std::f32::consts::FRAC_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);
/// ```
@ -686,8 +642,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let f = 1.0f32;
///
/// // atan(tan(1))
@ -712,8 +666,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// // Positive angles measured counter-clockwise
/// // from positive x axis
/// // -pi/4 radians (45 deg clockwise)
@ -724,8 +676,8 @@ impl f32 {
/// let x2 = -3.0f32;
/// let y2 = 3.0f32;
///
/// let abs_difference_1 = (y1.atan2(x1) - (-f32::consts::FRAC_PI_4)).abs();
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * 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 * std::f32::consts::FRAC_PI_4)).abs();
///
/// assert!(abs_difference_1 <= f32::EPSILON);
/// assert!(abs_difference_2 <= f32::EPSILON);
@ -743,9 +695,7 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = f32::consts::FRAC_PI_4;
/// let x = std::f32::consts::FRAC_PI_4;
/// let f = x.sin_cos();
///
/// let abs_difference_0 = (f.0 - x.sin()).abs();
@ -766,8 +716,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 6.0f32;
///
/// // e^(ln(6)) - 1
@ -788,9 +736,7 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = f32::consts::E - 1.0;
/// let x = std::f32::consts::E - 1.0;
///
/// // ln(1 + (e - 1)) == ln(e) == 1
/// let abs_difference = (x.ln_1p() - 1.0).abs();
@ -809,9 +755,7 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let e = f32::consts::E;
/// let e = std::f32::consts::E;
/// let x = 1.0f32;
///
/// let f = x.sinh();
@ -833,9 +777,7 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let e = f32::consts::E;
/// let e = std::f32::consts::E;
/// let x = 1.0f32;
/// let f = x.cosh();
/// // Solving cosh() at 1 gives this result
@ -857,9 +799,7 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let e = f32::consts::E;
/// let e = std::f32::consts::E;
/// let x = 1.0f32;
///
/// let f = x.tanh();
@ -881,8 +821,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 1.0f32;
/// let f = x.sinh().asinh();
///
@ -906,8 +844,6 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let x = 1.0f32;
/// let f = x.cosh().acosh();
///
@ -927,9 +863,7 @@ impl f32 {
/// # Examples
///
/// ```
/// use std::f32;
///
/// let e = f32::consts::E;
/// let e = std::f32::consts::E;
/// let f = e.tanh().atanh();
///
/// let abs_difference = (f - e).abs();

View file

@ -133,8 +133,6 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let x = 3.5_f64;
/// let y = -3.5_f64;
///
@ -162,8 +160,6 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let f = 3.5_f64;
///
/// assert_eq!(f.signum(), 1.0);
@ -188,8 +184,6 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let f = 3.5_f64;
///
/// assert_eq!(f.copysign(0.42), 3.5_f64);
@ -554,9 +548,7 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let x = f64::consts::FRAC_PI_2;
/// let x = std::f64::consts::FRAC_PI_2;
///
/// let abs_difference = (x.sin() - 1.0).abs();
///
@ -574,9 +566,7 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let x = 2.0 * f64::consts::PI;
/// let x = 2.0 * std::f64::consts::PI;
///
/// let abs_difference = (x.cos() - 1.0).abs();
///
@ -594,9 +584,7 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let x = f64::consts::FRAC_PI_4;
/// let x = std::f64::consts::FRAC_PI_4;
/// let abs_difference = (x.tan() - 1.0).abs();
///
/// assert!(abs_difference < 1e-14);
@ -615,12 +603,10 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let f = f64::consts::FRAC_PI_2;
/// let f = std::f64::consts::FRAC_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);
/// ```
@ -638,12 +624,10 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let f = f64::consts::FRAC_PI_4;
/// let f = std::f64::consts::FRAC_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);
/// ```
@ -684,8 +668,6 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// // Positive angles measured counter-clockwise
/// // from positive x axis
/// // -pi/4 radians (45 deg clockwise)
@ -696,8 +678,8 @@ impl f64 {
/// let x2 = -3.0_f64;
/// let y2 = 3.0_f64;
///
/// let abs_difference_1 = (y1.atan2(x1) - (-f64::consts::FRAC_PI_4)).abs();
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * 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 * std::f64::consts::FRAC_PI_4)).abs();
///
/// assert!(abs_difference_1 < 1e-10);
/// assert!(abs_difference_2 < 1e-10);
@ -715,9 +697,7 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let x = f64::consts::FRAC_PI_4;
/// let x = std::f64::consts::FRAC_PI_4;
/// let f = x.sin_cos();
///
/// let abs_difference_0 = (f.0 - x.sin()).abs();
@ -758,9 +738,7 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let x = f64::consts::E - 1.0;
/// let x = std::f64::consts::E - 1.0;
///
/// // ln(1 + (e - 1)) == ln(e) == 1
/// let abs_difference = (x.ln_1p() - 1.0).abs();
@ -779,9 +757,7 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let e = f64::consts::E;
/// let e = std::f64::consts::E;
/// let x = 1.0_f64;
///
/// let f = x.sinh();
@ -803,9 +779,7 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let e = f64::consts::E;
/// let e = std::f64::consts::E;
/// let x = 1.0_f64;
/// let f = x.cosh();
/// // Solving cosh() at 1 gives this result
@ -827,9 +801,7 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let e = f64::consts::E;
/// let e = std::f64::consts::E;
/// let x = 1.0_f64;
///
/// let f = x.tanh();
@ -893,9 +865,7 @@ impl f64 {
/// # Examples
///
/// ```
/// use std::f64;
///
/// let e = f64::consts::E;
/// let e = std::f64::consts::E;
/// let f = e.tanh().atanh();
///
/// let abs_difference = (f - e).abs();

View file

@ -517,20 +517,8 @@ pub use std_detect::detect;
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated, deprecated_in_future)]
pub use core::{
// Stable
assert_eq,
assert_ne,
debug_assert,
debug_assert_eq,
debug_assert_ne,
// Unstable
matches,
r#try,
todo,
unimplemented,
unreachable,
write,
writeln,
assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, r#try, todo,
unimplemented, unreachable, write, writeln,
};
// Re-export built-in macros defined through libcore.

View file

@ -1,4 +1,36 @@
#![cfg(target_thread_local)]
#![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());
}
}

View file

@ -6,6 +6,7 @@ use crate::io::{IoSlice, IoSliceMut, SeekFrom};
use crate::path::{Path, PathBuf};
use crate::sys::cvt;
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::time::SystemTime;
use crate::sys::{unsupported, Void};
@ -17,14 +18,6 @@ pub use crate::sys_common::fs::copy;
fn cstr(path: &Path) -> io::Result<CString> {
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)]
pub struct File(FileDesc);

View file

@ -103,6 +103,7 @@ pub unsafe extern "C" fn runtime_entry(
argv: *const *const c_char,
env: *const *const c_char,
) -> ! {
use crate::sys::hermit::fast_thread_local::run_dtors;
extern "C" {
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);
run_dtors();
abi::exit(result);
}

View file

@ -1,36 +1,14 @@
#![allow(dead_code)]
use crate::ffi::CStr;
use crate::fmt;
use crate::io;
use crate::mem;
use crate::sys::hermit::abi;
use crate::sys::hermit::fast_thread_local::run_dtors;
use crate::time::Duration;
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 {
tid: Tid,
}
@ -51,8 +29,8 @@ impl Thread {
let ret = abi::spawn(
&mut tid as *mut Tid,
thread_start,
p as usize,
Priority::into(NORMAL_PRIO),
&*p as *const _ as *const u8 as usize,
abi::Priority::into(abi::NORMAL_PRIO),
core_id,
);
@ -69,6 +47,9 @@ impl Thread {
unsafe {
// Finally, let's run some code.
Box::from_raw(main as *mut Box<dyn FnOnce()>)();
// run all destructors
run_dtors();
}
}
}

View file

@ -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;
type Dtor = unsafe extern "C" fn(*mut u8);
static NEXT_KEY: AtomicUsize = AtomicUsize::new(0);
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]
pub unsafe fn create(_dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key {
panic!("should not be used on the wasm target");
}
#[inline]
pub unsafe fn create(dtor: Option<Dtor>) -> Key {
let key = NEXT_KEY.fetch_add(1, Ordering::SeqCst);
let _guard = KEYS_LOCK.lock();
keys().insert(key, dtor);
key
pub unsafe fn set(_key: Key, _value: *mut u8) {
panic!("should not be used on the wasm target");
}
#[inline]
pub unsafe fn get(key: Key) -> *mut u8 {
if let Some(&entry) = locals().get(&key) { entry } else { ptr::null_mut() }
pub unsafe fn get(_key: Key) -> *mut u8 {
panic!("should not be used on the wasm target");
}
#[inline]
pub unsafe fn set(key: Key, value: *mut u8) {
locals().insert(key, value);
}
#[inline]
pub unsafe fn destroy(key: Key) {
keys().remove(&key);
pub unsafe fn destroy(_key: Key) {
panic!("should not be used on the wasm target");
}
#[inline]
pub fn requires_synchronized_create() -> bool {
false
panic!("should not be used on the wasm target");
}

View 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"'

View file

@ -0,0 +1,6 @@
#![feature(link_args)]
#[link_args = "g"]
extern "C" {}
fn main() {}

View file

@ -10,7 +10,7 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]);
| cannot infer type
| 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`
error[E0283]: type annotations needed
@ -25,7 +25,7 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]);
| cannot infer type
| 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`
error: aborting due to 2 previous errors

View file

@ -22,7 +22,7 @@ LL | fn return_n(&self) -> [u8; Bar::X];
| cannot infer type
| 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`
error: aborting due to 2 previous errors

View file

@ -6,7 +6,7 @@ LL | trait Foo: Iterator<Item = i32> {}
LL | trait Bar: Foo<Item = u32> {}
| ^^^^^^^^^^^^^^^ 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
--> $DIR/associated-types-overridden-binding.rs:7:21
@ -16,7 +16,7 @@ LL | trait I32Iterator = Iterator<Item = i32>;
LL | trait U32Iterator = I32Iterator<Item = u32>;
| ^^^^^^^^^^^^^^^^^^^^^^^ 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

View file

@ -4,7 +4,7 @@ error[E0284]: type annotations needed
LL | let x: isize = Foo::bar();
| ^^^^^^^^ cannot infer type
|
= note: cannot resolve `<_ as Foo>::A == _`
= note: cannot satisfy `<_ as Foo>::A == _`
error: aborting due to previous error

View file

@ -7,7 +7,7 @@ LL | fn create() -> u32;
LL | let cont: u32 = Generator::create();
| ^^^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot resolve `_: Generator`
= note: cannot satisfy `_: Generator`
error: aborting due to previous error

View file

@ -4,7 +4,7 @@ error[E0284]: type annotations needed
LL | self.input_stream(&mut stream);
| ^^^^^^^^^^^^ 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

View file

@ -7,7 +7,7 @@ LL | trait Foo {
LL | where &'a T : Foo,
| ^^^ 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

View file

@ -7,7 +7,7 @@ LL |
LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}
| ^^^^^^^^^^^ 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

View file

@ -7,7 +7,7 @@ LL | trait Foo { fn xxx(&self); }
LL | let _ = <S5<_>>::xxx;
| ^^^^^^^^^^^^ cannot infer type for struct `S5<_>`
|
= note: cannot resolve `S5<_>: Foo`
= note: cannot satisfy `S5<_>: Foo`
error: aborting due to previous error

View file

@ -13,7 +13,7 @@ LL | const ARR_LEN: usize = Tt::const_val::<[i8; 123]>();
LL | const fn const_val<T: Sized>() -> usize {
| --------- - required by this bound in `Tt::const_val`
|
= note: cannot resolve `_: Tt`
= note: cannot satisfy `_: Tt`
error[E0080]: evaluation of constant value failed
--> $DIR/issue-54954.rs:13:15

View file

@ -16,7 +16,7 @@ LL | fn new(slice: &[u8; Foo::SIZE]) -> Self;
| cannot infer type
| 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`
error: aborting due to 2 previous errors

View file

@ -4,7 +4,7 @@ error[E0284]: type annotations needed
LL | l.iter().map(f).collect()?
| ^^^^^^^ 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
|
LL | l.iter().map(f).collect::<B>()?

View file

@ -7,7 +7,7 @@ LL | fn new() -> T;
LL | let _f: base::Foo = base::HasNew::new();
| ^^^^^^^^^^^^^^^^^ cannot infer type
|
= note: cannot resolve `_: base::HasNew<base::Foo>`
= note: cannot satisfy `_: base::HasNew<base::Foo>`
error: aborting due to previous error

View file

@ -6,5 +6,5 @@ fn main() {
foo(42);
//~^ ERROR type annotations needed
//~| NOTE cannot infer type
//~| NOTE cannot resolve
//~| NOTE cannot satisfy
}

View file

@ -7,7 +7,7 @@ LL | fn foo<T: Into<String>>(x: i32) {}
LL | foo(42);
| ^^^ 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
|
LL | foo::<T>(42);

View file

@ -7,7 +7,7 @@ LL | trait Foo: Sized {
LL | where &'a T : Foo,
| ^^^ 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