Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 83f8c02

Browse files
committedApr 5, 2020
Auto merge of rust-lang#70826 - Centril:rollup-yn0hc1h, r=Centril
Rollup of 7 pull requests Successful merges: - rust-lang#70553 (move OS constants to platform crate) - rust-lang#70665 (Do not lose or reorder user-provided linker arguments) - rust-lang#70750 (Match options directly in the Fuse implementation) - rust-lang#70782 (Stop importing the float modules in documentation) - rust-lang#70798 ("cannot resolve" → "cannot satisfy") - rust-lang#70808 (Simplify dtor registration for HermitCore by using a list of destructors) - rust-lang#70824 (Remove marker comments in libstd/lib.rs macro imports) Failed merges: r? @ghost
2 parents b543afc + 23acf87 commit 83f8c02

36 files changed

+214
-363
lines changed
 

‎Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,9 +1377,9 @@ dependencies = [
13771377

13781378
[[package]]
13791379
name = "hermit-abi"
1380-
version = "0.1.8"
1380+
version = "0.1.10"
13811381
source = "registry+https://github.com/rust-lang/crates.io-index"
1382-
checksum = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8"
1382+
checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
13831383
dependencies = [
13841384
"compiler_builtins",
13851385
"libc",

‎src/libcore/iter/adapters/fuse.rs

Lines changed: 63 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ impl<I> Fuse<I> {
2828
#[stable(feature = "fused", since = "1.26.0")]
2929
impl<I> FusedIterator for Fuse<I> where I: Iterator {}
3030

31+
/// Fuse the iterator if the expression is `None`.
32+
macro_rules! fuse {
33+
($self:ident . iter . $($call:tt)+) => {
34+
match $self.iter {
35+
Some(ref mut iter) => match iter.$($call)+ {
36+
None => {
37+
$self.iter = None;
38+
None
39+
}
40+
item => item,
41+
},
42+
None => None,
43+
}
44+
};
45+
}
46+
3147
#[stable(feature = "rust1", since = "1.0.0")]
3248
impl<I> Iterator for Fuse<I>
3349
where
@@ -37,35 +53,36 @@ where
3753

3854
#[inline]
3955
default fn next(&mut self) -> Option<<I as Iterator>::Item> {
40-
let next = self.iter.as_mut()?.next();
41-
if next.is_none() {
42-
self.iter = None;
43-
}
44-
next
56+
fuse!(self.iter.next())
4557
}
4658

4759
#[inline]
4860
default fn nth(&mut self, n: usize) -> Option<I::Item> {
49-
let nth = self.iter.as_mut()?.nth(n);
50-
if nth.is_none() {
51-
self.iter = None;
52-
}
53-
nth
61+
fuse!(self.iter.nth(n))
5462
}
5563

5664
#[inline]
5765
default fn last(self) -> Option<I::Item> {
58-
self.iter?.last()
66+
match self.iter {
67+
Some(iter) => iter.last(),
68+
None => None,
69+
}
5970
}
6071

6172
#[inline]
6273
default fn count(self) -> usize {
63-
self.iter.map_or(0, I::count)
74+
match self.iter {
75+
Some(iter) => iter.count(),
76+
None => 0,
77+
}
6478
}
6579

6680
#[inline]
6781
default fn size_hint(&self) -> (usize, Option<usize>) {
68-
self.iter.as_ref().map_or((0, Some(0)), I::size_hint)
82+
match self.iter {
83+
Some(ref iter) => iter.size_hint(),
84+
None => (0, Some(0)),
85+
}
6986
}
7087

7188
#[inline]
@@ -98,11 +115,7 @@ where
98115
where
99116
P: FnMut(&Self::Item) -> bool,
100117
{
101-
let found = self.iter.as_mut()?.find(predicate);
102-
if found.is_none() {
103-
self.iter = None;
104-
}
105-
found
118+
fuse!(self.iter.find(predicate))
106119
}
107120
}
108121

@@ -113,20 +126,12 @@ where
113126
{
114127
#[inline]
115128
default fn next_back(&mut self) -> Option<<I as Iterator>::Item> {
116-
let next = self.iter.as_mut()?.next_back();
117-
if next.is_none() {
118-
self.iter = None;
119-
}
120-
next
129+
fuse!(self.iter.next_back())
121130
}
122131

123132
#[inline]
124133
default fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
125-
let nth = self.iter.as_mut()?.nth_back(n);
126-
if nth.is_none() {
127-
self.iter = None;
128-
}
129-
nth
134+
fuse!(self.iter.nth_back(n))
130135
}
131136

132137
#[inline]
@@ -159,11 +164,7 @@ where
159164
where
160165
P: FnMut(&Self::Item) -> bool,
161166
{
162-
let found = self.iter.as_mut()?.rfind(predicate);
163-
if found.is_none() {
164-
self.iter = None;
165-
}
166-
found
167+
fuse!(self.iter.rfind(predicate))
167168
}
168169
}
169170

@@ -173,42 +174,30 @@ where
173174
I: ExactSizeIterator,
174175
{
175176
default fn len(&self) -> usize {
176-
self.iter.as_ref().map_or(0, I::len)
177-
}
178-
179-
default fn is_empty(&self) -> bool {
180-
self.iter.as_ref().map_or(true, I::is_empty)
181-
}
182-
}
183-
184-
// NOTE: for `I: FusedIterator`, we assume that the iterator is always `Some`
185-
impl<I: FusedIterator> Fuse<I> {
186-
#[inline(always)]
187-
fn as_inner(&self) -> &I {
188177
match self.iter {
189-
Some(ref iter) => iter,
190-
// SAFETY: the specialized iterator never sets `None`
191-
None => unsafe { intrinsics::unreachable() },
178+
Some(ref iter) => iter.len(),
179+
None => 0,
192180
}
193181
}
194182

195-
#[inline(always)]
196-
fn as_inner_mut(&mut self) -> &mut I {
183+
default fn is_empty(&self) -> bool {
197184
match self.iter {
198-
Some(ref mut iter) => iter,
199-
// SAFETY: the specialized iterator never sets `None`
200-
None => unsafe { intrinsics::unreachable() },
185+
Some(ref iter) => iter.is_empty(),
186+
None => true,
201187
}
202188
}
189+
}
203190

204-
#[inline(always)]
205-
fn into_inner(self) -> I {
206-
match self.iter {
207-
Some(iter) => iter,
191+
// NOTE: for `I: FusedIterator`, we assume that the iterator is always `Some`.
192+
// Implementing this as a directly-expanded macro helps codegen performance.
193+
macro_rules! unchecked {
194+
($self:ident) => {
195+
match $self {
196+
Fuse { iter: Some(iter) } => iter,
208197
// SAFETY: the specialized iterator never sets `None`
209-
None => unsafe { intrinsics::unreachable() },
198+
Fuse { iter: None } => unsafe { intrinsics::unreachable() },
210199
}
211-
}
200+
};
212201
}
213202

214203
#[stable(feature = "fused", since = "1.26.0")]
@@ -218,27 +207,27 @@ where
218207
{
219208
#[inline]
220209
fn next(&mut self) -> Option<<I as Iterator>::Item> {
221-
self.as_inner_mut().next()
210+
unchecked!(self).next()
222211
}
223212

224213
#[inline]
225214
fn nth(&mut self, n: usize) -> Option<I::Item> {
226-
self.as_inner_mut().nth(n)
215+
unchecked!(self).nth(n)
227216
}
228217

229218
#[inline]
230219
fn last(self) -> Option<I::Item> {
231-
self.into_inner().last()
220+
unchecked!(self).last()
232221
}
233222

234223
#[inline]
235224
fn count(self) -> usize {
236-
self.into_inner().count()
225+
unchecked!(self).count()
237226
}
238227

239228
#[inline]
240229
fn size_hint(&self) -> (usize, Option<usize>) {
241-
self.as_inner().size_hint()
230+
unchecked!(self).size_hint()
242231
}
243232

244233
#[inline]
@@ -248,23 +237,23 @@ where
248237
Fold: FnMut(Acc, Self::Item) -> R,
249238
R: Try<Ok = Acc>,
250239
{
251-
self.as_inner_mut().try_fold(init, fold)
240+
unchecked!(self).try_fold(init, fold)
252241
}
253242

254243
#[inline]
255244
fn fold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
256245
where
257246
Fold: FnMut(Acc, Self::Item) -> Acc,
258247
{
259-
self.into_inner().fold(init, fold)
248+
unchecked!(self).fold(init, fold)
260249
}
261250

262251
#[inline]
263252
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
264253
where
265254
P: FnMut(&Self::Item) -> bool,
266255
{
267-
self.as_inner_mut().find(predicate)
256+
unchecked!(self).find(predicate)
268257
}
269258
}
270259

@@ -275,12 +264,12 @@ where
275264
{
276265
#[inline]
277266
fn next_back(&mut self) -> Option<<I as Iterator>::Item> {
278-
self.as_inner_mut().next_back()
267+
unchecked!(self).next_back()
279268
}
280269

281270
#[inline]
282271
fn nth_back(&mut self, n: usize) -> Option<<I as Iterator>::Item> {
283-
self.as_inner_mut().nth_back(n)
272+
unchecked!(self).nth_back(n)
284273
}
285274

286275
#[inline]
@@ -290,23 +279,23 @@ where
290279
Fold: FnMut(Acc, Self::Item) -> R,
291280
R: Try<Ok = Acc>,
292281
{
293-
self.as_inner_mut().try_rfold(init, fold)
282+
unchecked!(self).try_rfold(init, fold)
294283
}
295284

296285
#[inline]
297286
fn rfold<Acc, Fold>(self, init: Acc, fold: Fold) -> Acc
298287
where
299288
Fold: FnMut(Acc, Self::Item) -> Acc,
300289
{
301-
self.into_inner().rfold(init, fold)
290+
unchecked!(self).rfold(init, fold)
302291
}
303292

304293
#[inline]
305294
fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item>
306295
where
307296
P: FnMut(&Self::Item) -> bool,
308297
{
309-
self.as_inner_mut().rfind(predicate)
298+
unchecked!(self).rfind(predicate)
310299
}
311300
}
312301

@@ -316,11 +305,11 @@ where
316305
I: ExactSizeIterator + FusedIterator,
317306
{
318307
fn len(&self) -> usize {
319-
self.as_inner().len()
308+
unchecked!(self).len()
320309
}
321310

322311
fn is_empty(&self) -> bool {
323-
self.as_inner().is_empty()
312+
unchecked!(self).is_empty()
324313
}
325314
}
326315

‎src/libcore/num/f32.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,7 @@ impl f32 {
394394
/// Converts radians to degrees.
395395
///
396396
/// ```
397-
/// use std::f32::consts;
398-
///
399-
/// let angle = consts::PI;
397+
/// let angle = std::f32::consts::PI;
400398
///
401399
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
402400
///
@@ -413,11 +411,9 @@ impl f32 {
413411
/// Converts degrees to radians.
414412
///
415413
/// ```
416-
/// use std::f32::consts;
417-
///
418414
/// let angle = 180.0f32;
419415
///
420-
/// let abs_difference = (angle.to_radians() - consts::PI).abs();
416+
/// let abs_difference = (angle.to_radians() - std::f32::consts::PI).abs();
421417
///
422418
/// assert!(abs_difference <= f32::EPSILON);
423419
/// ```

‎src/libcore/num/f64.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,7 @@ impl f64 {
407407
/// Converts radians to degrees.
408408
///
409409
/// ```
410-
/// use std::f64::consts;
411-
///
412-
/// let angle = consts::PI;
410+
/// let angle = std::f64::consts::PI;
413411
///
414412
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
415413
///
@@ -427,11 +425,9 @@ impl f64 {
427425
/// Converts degrees to radians.
428426
///
429427
/// ```
430-
/// use std::f64::consts;
431-
///
432428
/// let angle = 180.0_f64;
433429
///
434-
/// let abs_difference = (angle.to_radians() - consts::PI).abs();
430+
/// let abs_difference = (angle.to_radians() - std::f64::consts::PI).abs();
435431
///
436432
/// assert!(abs_difference < 1e-10);
437433
/// ```

‎src/libcore/ops/range.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
9898
/// # Examples
9999
///
100100
/// ```
101-
/// use std::f32;
102-
///
103101
/// assert!(!(3..5).contains(&2));
104102
/// assert!( (3..5).contains(&3));
105103
/// assert!( (3..5).contains(&4));
@@ -198,8 +196,6 @@ impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
198196
/// # Examples
199197
///
200198
/// ```
201-
/// use std::f32;
202-
///
203199
/// assert!(!(3..).contains(&2));
204200
/// assert!( (3..).contains(&3));
205201
/// assert!( (3..).contains(&1_000_000_000));
@@ -282,8 +278,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
282278
/// # Examples
283279
///
284280
/// ```
285-
/// use std::f32;
286-
///
287281
/// assert!( (..5).contains(&-1_000_000_000));
288282
/// assert!( (..5).contains(&4));
289283
/// assert!(!(..5).contains(&5));
@@ -453,8 +447,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
453447
/// # Examples
454448
///
455449
/// ```
456-
/// use std::f32;
457-
///
458450
/// assert!(!(3..=5).contains(&2));
459451
/// assert!( (3..=5).contains(&3));
460452
/// assert!( (3..=5).contains(&4));
@@ -581,8 +573,6 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
581573
/// # Examples
582574
///
583575
/// ```
584-
/// use std::f32;
585-
///
586576
/// assert!( (..=5).contains(&-1_000_000_000));
587577
/// assert!( (..=5).contains(&5));
588578
/// assert!(!(..=5).contains(&6));
@@ -721,8 +711,6 @@ pub trait RangeBounds<T: ?Sized> {
721711
/// # Examples
722712
///
723713
/// ```
724-
/// use std::f32;
725-
///
726714
/// assert!( (3..5).contains(&4));
727715
/// assert!(!(3..5).contains(&2));
728716
///

‎src/librustc_codegen_ssa/back/link.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
505505
cmd.args(args);
506506
}
507507
}
508-
if let Some(ref args) = sess.opts.debugging_opts.pre_link_args {
509-
cmd.args(args);
510-
}
511-
cmd.args(&sess.opts.debugging_opts.pre_link_arg);
508+
cmd.args(&sess.opts.debugging_opts.pre_link_args);
512509

513510
if sess.target.target.options.is_like_fuchsia {
514511
let prefix = match sess.opts.debugging_opts.sanitizer {
@@ -1302,18 +1299,17 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(
13021299
cmd.gc_sections(keep_metadata);
13031300
}
13041301

1305-
let used_link_args = &codegen_results.crate_info.link_args;
1302+
let attr_link_args = codegen_results.crate_info.link_args.iter();
1303+
let user_link_args: Vec<_> =
1304+
sess.opts.cg.link_args.iter().chain(attr_link_args).cloned().collect();
13061305

13071306
if crate_type == config::CrateType::Executable {
13081307
let mut position_independent_executable = false;
13091308

13101309
if t.options.position_independent_executables {
1311-
let empty_vec = Vec::new();
1312-
let args = sess.opts.cg.link_args.as_ref().unwrap_or(&empty_vec);
1313-
let more_args = &sess.opts.cg.link_arg;
1314-
let mut args = args.iter().chain(more_args.iter()).chain(used_link_args.iter());
1315-
1316-
if is_pic(sess) && !sess.crt_static(Some(crate_type)) && !args.any(|x| *x == "-static")
1310+
if is_pic(sess)
1311+
&& !sess.crt_static(Some(crate_type))
1312+
&& !user_link_args.iter().any(|x| x == "-static")
13171313
{
13181314
position_independent_executable = true;
13191315
}
@@ -1444,11 +1440,7 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(
14441440

14451441
// Finally add all the linker arguments provided on the command line along
14461442
// with any #[link_args] attributes found inside the crate
1447-
if let Some(ref args) = sess.opts.cg.link_args {
1448-
cmd.args(args);
1449-
}
1450-
cmd.args(&sess.opts.cg.link_arg);
1451-
cmd.args(&used_link_args);
1443+
cmd.args(&user_link_args);
14521444
}
14531445

14541446
// # Native library linking

‎src/librustc_interface/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ fn test_codegen_options_tracking_hash() {
382382
opts.cg.linker = Some(PathBuf::from("linker"));
383383
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
384384

385-
opts.cg.link_args = Some(vec![String::from("abc"), String::from("def")]);
385+
opts.cg.link_args = vec![String::from("abc"), String::from("def")];
386386
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
387387

388388
opts.cg.link_dead_code = true;

‎src/librustc_session/options.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,17 @@ macro_rules! options {
296296
use std::path::PathBuf;
297297
use std::str::FromStr;
298298

299+
// Sometimes different options need to build a common structure.
300+
// That structure can kept in one of the options' fields, the others become dummy.
301+
macro_rules! redirect_field {
302+
($cg:ident.link_arg) => { $cg.link_args };
303+
($cg:ident.pre_link_arg) => { $cg.pre_link_args };
304+
($cg:ident.$field:ident) => { $cg.$field };
305+
}
306+
299307
$(
300308
pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool {
301-
$parse(&mut cg.$opt, v)
309+
$parse(&mut redirect_field!(cg.$opt), v)
302310
}
303311
)*
304312

@@ -643,9 +651,9 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
643651
"this option is deprecated and does nothing"),
644652
linker: Option<PathBuf> = (None, parse_opt_pathbuf, [UNTRACKED],
645653
"system linker to link outputs with"),
646-
link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
654+
link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
647655
"a single extra argument to append to the linker invocation (can be used several times)"),
648-
link_args: Option<Vec<String>> = (None, parse_opt_list, [UNTRACKED],
656+
link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
649657
"extra arguments to append to the linker invocation (space separated)"),
650658
link_dead_code: bool = (false, parse_bool, [UNTRACKED],
651659
"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,
876884
"make rustc print the total optimization fuel used by a crate"),
877885
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
878886
"force all crates to be `rustc_private` unstable"),
879-
pre_link_arg: Vec<String> = (vec![], parse_string_push, [UNTRACKED],
887+
pre_link_arg: (/* redirected to pre_link_args */) = ((), parse_string_push, [UNTRACKED],
880888
"a single extra argument to prepend the linker invocation (can be used several times)"),
881-
pre_link_args: Option<Vec<String>> = (None, parse_opt_list, [UNTRACKED],
889+
pre_link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
882890
"extra arguments to prepend to the linker invocation (space separated)"),
883891
profile: bool = (false, parse_bool, [TRACKED],
884892
"insert profiling code"),

‎src/librustc_trait_selection/traits/error_reporting/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
13771377
return;
13781378
}
13791379
let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0283);
1380-
err.note(&format!("cannot resolve `{}`", predicate));
1380+
err.note(&format!("cannot satisfy `{}`", predicate));
13811381
if let ObligationCauseCode::ItemObligation(def_id) = obligation.cause.code {
13821382
self.suggest_fully_qualified_path(&mut err, def_id, span, trait_ref.def_id());
13831383
} else if let (
@@ -1407,7 +1407,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
14071407
// LL | const fn const_val<T: Sized>() -> usize {
14081408
// | --------- - required by this bound in `Tt::const_val`
14091409
// |
1410-
// = note: cannot resolve `_: Tt`
1410+
// = note: cannot satisfy `_: Tt`
14111411

14121412
err.span_suggestion_verbose(
14131413
span.shrink_to_hi(),
@@ -1457,7 +1457,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
14571457
return;
14581458
}
14591459
let mut err = self.need_type_info_err(body_id, span, self_ty, ErrorCode::E0284);
1460-
err.note(&format!("cannot resolve `{}`", predicate));
1460+
err.note(&format!("cannot satisfy `{}`", predicate));
14611461
err
14621462
}
14631463

@@ -1469,10 +1469,10 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
14691469
self.tcx.sess,
14701470
span,
14711471
E0284,
1472-
"type annotations needed: cannot resolve `{}`",
1472+
"type annotations needed: cannot satisfy `{}`",
14731473
predicate,
14741474
);
1475-
err.span_label(span, &format!("cannot resolve `{}`", predicate));
1475+
err.span_label(span, &format!("cannot satisfy `{}`", predicate));
14761476
err
14771477
}
14781478
};

‎src/libstd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }
4141
fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }
4242

4343
[target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies]
44-
hermit-abi = { version = "0.1", features = ['rustc-dep-of-std'] }
44+
hermit-abi = { version = "0.1.10", features = ['rustc-dep-of-std'] }
4545

4646
[target.wasm32-wasi.dependencies]
4747
wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false }

‎src/libstd/f32.rs

Lines changed: 15 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ impl f32 {
112112
/// # Examples
113113
///
114114
/// ```
115-
/// use std::f32;
116-
///
117115
/// let x = 3.6_f32;
118116
/// let y = -3.6_f32;
119117
/// let abs_difference_x = (x.fract() - 0.6).abs();
@@ -135,8 +133,6 @@ impl f32 {
135133
/// # Examples
136134
///
137135
/// ```
138-
/// use std::f32;
139-
///
140136
/// let x = 3.5_f32;
141137
/// let y = -3.5_f32;
142138
///
@@ -164,8 +160,6 @@ impl f32 {
164160
/// # Examples
165161
///
166162
/// ```
167-
/// use std::f32;
168-
///
169163
/// let f = 3.5_f32;
170164
///
171165
/// assert_eq!(f.signum(), 1.0);
@@ -190,8 +184,6 @@ impl f32 {
190184
/// # Examples
191185
///
192186
/// ```
193-
/// use std::f32;
194-
///
195187
/// let f = 3.5_f32;
196188
///
197189
/// assert_eq!(f.copysign(0.42), 3.5_f32);
@@ -217,8 +209,6 @@ impl f32 {
217209
/// # Examples
218210
///
219211
/// ```
220-
/// use std::f32;
221-
///
222212
/// let m = 10.0_f32;
223213
/// let x = 4.0_f32;
224214
/// let b = 60.0_f32;
@@ -301,8 +291,6 @@ impl f32 {
301291
/// # Examples
302292
///
303293
/// ```
304-
/// use std::f32;
305-
///
306294
/// let x = 2.0_f32;
307295
/// let abs_difference = (x.powi(2) - (x * x)).abs();
308296
///
@@ -320,8 +308,6 @@ impl f32 {
320308
/// # Examples
321309
///
322310
/// ```
323-
/// use std::f32;
324-
///
325311
/// let x = 2.0_f32;
326312
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
327313
///
@@ -341,8 +327,6 @@ impl f32 {
341327
/// # Examples
342328
///
343329
/// ```
344-
/// use std::f32;
345-
///
346330
/// let positive = 4.0_f32;
347331
/// let negative = -4.0_f32;
348332
///
@@ -363,8 +347,6 @@ impl f32 {
363347
/// # Examples
364348
///
365349
/// ```
366-
/// use std::f32;
367-
///
368350
/// let one = 1.0f32;
369351
/// // e^1
370352
/// let e = one.exp();
@@ -386,8 +368,6 @@ impl f32 {
386368
/// # Examples
387369
///
388370
/// ```
389-
/// use std::f32;
390-
///
391371
/// let f = 2.0f32;
392372
///
393373
/// // 2^2 - 4 == 0
@@ -407,8 +387,6 @@ impl f32 {
407387
/// # Examples
408388
///
409389
/// ```
410-
/// use std::f32;
411-
///
412390
/// let one = 1.0f32;
413391
/// // e^1
414392
/// let e = one.exp();
@@ -434,8 +412,6 @@ impl f32 {
434412
/// # Examples
435413
///
436414
/// ```
437-
/// use std::f32;
438-
///
439415
/// let five = 5.0f32;
440416
///
441417
/// // log5(5) - 1 == 0
@@ -455,8 +431,6 @@ impl f32 {
455431
/// # Examples
456432
///
457433
/// ```
458-
/// use std::f32;
459-
///
460434
/// let two = 2.0f32;
461435
///
462436
/// // log2(2) - 1 == 0
@@ -479,8 +453,6 @@ impl f32 {
479453
/// # Examples
480454
///
481455
/// ```
482-
/// use std::f32;
483-
///
484456
/// let ten = 10.0f32;
485457
///
486458
/// // log10(10) - 1 == 0
@@ -503,8 +475,6 @@ impl f32 {
503475
/// # Examples
504476
///
505477
/// ```
506-
/// use std::f32;
507-
///
508478
/// let x = 3.0f32;
509479
/// let y = -3.0f32;
510480
///
@@ -536,8 +506,6 @@ impl f32 {
536506
/// # Examples
537507
///
538508
/// ```
539-
/// use std::f32;
540-
///
541509
/// let x = 8.0f32;
542510
///
543511
/// // x^(1/3) - 2 == 0
@@ -558,8 +526,6 @@ impl f32 {
558526
/// # Examples
559527
///
560528
/// ```
561-
/// use std::f32;
562-
///
563529
/// let x = 2.0f32;
564530
/// let y = 3.0f32;
565531
///
@@ -580,9 +546,7 @@ impl f32 {
580546
/// # Examples
581547
///
582548
/// ```
583-
/// use std::f32;
584-
///
585-
/// let x = f32::consts::FRAC_PI_2;
549+
/// let x = std::f32::consts::FRAC_PI_2;
586550
///
587551
/// let abs_difference = (x.sin() - 1.0).abs();
588552
///
@@ -600,9 +564,7 @@ impl f32 {
600564
/// # Examples
601565
///
602566
/// ```
603-
/// use std::f32;
604-
///
605-
/// let x = 2.0 * f32::consts::PI;
567+
/// let x = 2.0 * std::f32::consts::PI;
606568
///
607569
/// let abs_difference = (x.cos() - 1.0).abs();
608570
///
@@ -620,9 +582,7 @@ impl f32 {
620582
/// # Examples
621583
///
622584
/// ```
623-
/// use std::f32;
624-
///
625-
/// let x = f32::consts::FRAC_PI_4;
585+
/// let x = std::f32::consts::FRAC_PI_4;
626586
/// let abs_difference = (x.tan() - 1.0).abs();
627587
///
628588
/// assert!(abs_difference <= f32::EPSILON);
@@ -641,12 +601,10 @@ impl f32 {
641601
/// # Examples
642602
///
643603
/// ```
644-
/// use std::f32;
645-
///
646-
/// let f = f32::consts::FRAC_PI_2;
604+
/// let f = std::f32::consts::FRAC_PI_2;
647605
///
648606
/// // asin(sin(pi/2))
649-
/// let abs_difference = (f.sin().asin() - f32::consts::FRAC_PI_2).abs();
607+
/// let abs_difference = (f.sin().asin() - std::f32::consts::FRAC_PI_2).abs();
650608
///
651609
/// assert!(abs_difference <= f32::EPSILON);
652610
/// ```
@@ -664,12 +622,10 @@ impl f32 {
664622
/// # Examples
665623
///
666624
/// ```
667-
/// use std::f32;
668-
///
669-
/// let f = f32::consts::FRAC_PI_4;
625+
/// let f = std::f32::consts::FRAC_PI_4;
670626
///
671627
/// // acos(cos(pi/4))
672-
/// let abs_difference = (f.cos().acos() - f32::consts::FRAC_PI_4).abs();
628+
/// let abs_difference = (f.cos().acos() - std::f32::consts::FRAC_PI_4).abs();
673629
///
674630
/// assert!(abs_difference <= f32::EPSILON);
675631
/// ```
@@ -686,8 +642,6 @@ impl f32 {
686642
/// # Examples
687643
///
688644
/// ```
689-
/// use std::f32;
690-
///
691645
/// let f = 1.0f32;
692646
///
693647
/// // atan(tan(1))
@@ -712,8 +666,6 @@ impl f32 {
712666
/// # Examples
713667
///
714668
/// ```
715-
/// use std::f32;
716-
///
717669
/// // Positive angles measured counter-clockwise
718670
/// // from positive x axis
719671
/// // -pi/4 radians (45 deg clockwise)
@@ -724,8 +676,8 @@ impl f32 {
724676
/// let x2 = -3.0f32;
725677
/// let y2 = 3.0f32;
726678
///
727-
/// let abs_difference_1 = (y1.atan2(x1) - (-f32::consts::FRAC_PI_4)).abs();
728-
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * f32::consts::FRAC_PI_4)).abs();
679+
/// let abs_difference_1 = (y1.atan2(x1) - (-std::f32::consts::FRAC_PI_4)).abs();
680+
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * std::f32::consts::FRAC_PI_4)).abs();
729681
///
730682
/// assert!(abs_difference_1 <= f32::EPSILON);
731683
/// assert!(abs_difference_2 <= f32::EPSILON);
@@ -743,9 +695,7 @@ impl f32 {
743695
/// # Examples
744696
///
745697
/// ```
746-
/// use std::f32;
747-
///
748-
/// let x = f32::consts::FRAC_PI_4;
698+
/// let x = std::f32::consts::FRAC_PI_4;
749699
/// let f = x.sin_cos();
750700
///
751701
/// let abs_difference_0 = (f.0 - x.sin()).abs();
@@ -766,8 +716,6 @@ impl f32 {
766716
/// # Examples
767717
///
768718
/// ```
769-
/// use std::f32;
770-
///
771719
/// let x = 6.0f32;
772720
///
773721
/// // e^(ln(6)) - 1
@@ -788,9 +736,7 @@ impl f32 {
788736
/// # Examples
789737
///
790738
/// ```
791-
/// use std::f32;
792-
///
793-
/// let x = f32::consts::E - 1.0;
739+
/// let x = std::f32::consts::E - 1.0;
794740
///
795741
/// // ln(1 + (e - 1)) == ln(e) == 1
796742
/// let abs_difference = (x.ln_1p() - 1.0).abs();
@@ -809,9 +755,7 @@ impl f32 {
809755
/// # Examples
810756
///
811757
/// ```
812-
/// use std::f32;
813-
///
814-
/// let e = f32::consts::E;
758+
/// let e = std::f32::consts::E;
815759
/// let x = 1.0f32;
816760
///
817761
/// let f = x.sinh();
@@ -833,9 +777,7 @@ impl f32 {
833777
/// # Examples
834778
///
835779
/// ```
836-
/// use std::f32;
837-
///
838-
/// let e = f32::consts::E;
780+
/// let e = std::f32::consts::E;
839781
/// let x = 1.0f32;
840782
/// let f = x.cosh();
841783
/// // Solving cosh() at 1 gives this result
@@ -857,9 +799,7 @@ impl f32 {
857799
/// # Examples
858800
///
859801
/// ```
860-
/// use std::f32;
861-
///
862-
/// let e = f32::consts::E;
802+
/// let e = std::f32::consts::E;
863803
/// let x = 1.0f32;
864804
///
865805
/// let f = x.tanh();
@@ -881,8 +821,6 @@ impl f32 {
881821
/// # Examples
882822
///
883823
/// ```
884-
/// use std::f32;
885-
///
886824
/// let x = 1.0f32;
887825
/// let f = x.sinh().asinh();
888826
///
@@ -906,8 +844,6 @@ impl f32 {
906844
/// # Examples
907845
///
908846
/// ```
909-
/// use std::f32;
910-
///
911847
/// let x = 1.0f32;
912848
/// let f = x.cosh().acosh();
913849
///
@@ -927,9 +863,7 @@ impl f32 {
927863
/// # Examples
928864
///
929865
/// ```
930-
/// use std::f32;
931-
///
932-
/// let e = f32::consts::E;
866+
/// let e = std::f32::consts::E;
933867
/// let f = e.tanh().atanh();
934868
///
935869
/// let abs_difference = (f - e).abs();

‎src/libstd/f64.rs

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ impl f64 {
133133
/// # Examples
134134
///
135135
/// ```
136-
/// use std::f64;
137-
///
138136
/// let x = 3.5_f64;
139137
/// let y = -3.5_f64;
140138
///
@@ -162,8 +160,6 @@ impl f64 {
162160
/// # Examples
163161
///
164162
/// ```
165-
/// use std::f64;
166-
///
167163
/// let f = 3.5_f64;
168164
///
169165
/// assert_eq!(f.signum(), 1.0);
@@ -188,8 +184,6 @@ impl f64 {
188184
/// # Examples
189185
///
190186
/// ```
191-
/// use std::f64;
192-
///
193187
/// let f = 3.5_f64;
194188
///
195189
/// assert_eq!(f.copysign(0.42), 3.5_f64);
@@ -554,9 +548,7 @@ impl f64 {
554548
/// # Examples
555549
///
556550
/// ```
557-
/// use std::f64;
558-
///
559-
/// let x = f64::consts::FRAC_PI_2;
551+
/// let x = std::f64::consts::FRAC_PI_2;
560552
///
561553
/// let abs_difference = (x.sin() - 1.0).abs();
562554
///
@@ -574,9 +566,7 @@ impl f64 {
574566
/// # Examples
575567
///
576568
/// ```
577-
/// use std::f64;
578-
///
579-
/// let x = 2.0 * f64::consts::PI;
569+
/// let x = 2.0 * std::f64::consts::PI;
580570
///
581571
/// let abs_difference = (x.cos() - 1.0).abs();
582572
///
@@ -594,9 +584,7 @@ impl f64 {
594584
/// # Examples
595585
///
596586
/// ```
597-
/// use std::f64;
598-
///
599-
/// let x = f64::consts::FRAC_PI_4;
587+
/// let x = std::f64::consts::FRAC_PI_4;
600588
/// let abs_difference = (x.tan() - 1.0).abs();
601589
///
602590
/// assert!(abs_difference < 1e-14);
@@ -615,12 +603,10 @@ impl f64 {
615603
/// # Examples
616604
///
617605
/// ```
618-
/// use std::f64;
619-
///
620-
/// let f = f64::consts::FRAC_PI_2;
606+
/// let f = std::f64::consts::FRAC_PI_2;
621607
///
622608
/// // asin(sin(pi/2))
623-
/// let abs_difference = (f.sin().asin() - f64::consts::FRAC_PI_2).abs();
609+
/// let abs_difference = (f.sin().asin() - std::f64::consts::FRAC_PI_2).abs();
624610
///
625611
/// assert!(abs_difference < 1e-10);
626612
/// ```
@@ -638,12 +624,10 @@ impl f64 {
638624
/// # Examples
639625
///
640626
/// ```
641-
/// use std::f64;
642-
///
643-
/// let f = f64::consts::FRAC_PI_4;
627+
/// let f = std::f64::consts::FRAC_PI_4;
644628
///
645629
/// // acos(cos(pi/4))
646-
/// let abs_difference = (f.cos().acos() - f64::consts::FRAC_PI_4).abs();
630+
/// let abs_difference = (f.cos().acos() - std::f64::consts::FRAC_PI_4).abs();
647631
///
648632
/// assert!(abs_difference < 1e-10);
649633
/// ```
@@ -684,8 +668,6 @@ impl f64 {
684668
/// # Examples
685669
///
686670
/// ```
687-
/// use std::f64;
688-
///
689671
/// // Positive angles measured counter-clockwise
690672
/// // from positive x axis
691673
/// // -pi/4 radians (45 deg clockwise)
@@ -696,8 +678,8 @@ impl f64 {
696678
/// let x2 = -3.0_f64;
697679
/// let y2 = 3.0_f64;
698680
///
699-
/// let abs_difference_1 = (y1.atan2(x1) - (-f64::consts::FRAC_PI_4)).abs();
700-
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * f64::consts::FRAC_PI_4)).abs();
681+
/// let abs_difference_1 = (y1.atan2(x1) - (-std::f64::consts::FRAC_PI_4)).abs();
682+
/// let abs_difference_2 = (y2.atan2(x2) - (3.0 * std::f64::consts::FRAC_PI_4)).abs();
701683
///
702684
/// assert!(abs_difference_1 < 1e-10);
703685
/// assert!(abs_difference_2 < 1e-10);
@@ -715,9 +697,7 @@ impl f64 {
715697
/// # Examples
716698
///
717699
/// ```
718-
/// use std::f64;
719-
///
720-
/// let x = f64::consts::FRAC_PI_4;
700+
/// let x = std::f64::consts::FRAC_PI_4;
721701
/// let f = x.sin_cos();
722702
///
723703
/// let abs_difference_0 = (f.0 - x.sin()).abs();
@@ -758,9 +738,7 @@ impl f64 {
758738
/// # Examples
759739
///
760740
/// ```
761-
/// use std::f64;
762-
///
763-
/// let x = f64::consts::E - 1.0;
741+
/// let x = std::f64::consts::E - 1.0;
764742
///
765743
/// // ln(1 + (e - 1)) == ln(e) == 1
766744
/// let abs_difference = (x.ln_1p() - 1.0).abs();
@@ -779,9 +757,7 @@ impl f64 {
779757
/// # Examples
780758
///
781759
/// ```
782-
/// use std::f64;
783-
///
784-
/// let e = f64::consts::E;
760+
/// let e = std::f64::consts::E;
785761
/// let x = 1.0_f64;
786762
///
787763
/// let f = x.sinh();
@@ -803,9 +779,7 @@ impl f64 {
803779
/// # Examples
804780
///
805781
/// ```
806-
/// use std::f64;
807-
///
808-
/// let e = f64::consts::E;
782+
/// let e = std::f64::consts::E;
809783
/// let x = 1.0_f64;
810784
/// let f = x.cosh();
811785
/// // Solving cosh() at 1 gives this result
@@ -827,9 +801,7 @@ impl f64 {
827801
/// # Examples
828802
///
829803
/// ```
830-
/// use std::f64;
831-
///
832-
/// let e = f64::consts::E;
804+
/// let e = std::f64::consts::E;
833805
/// let x = 1.0_f64;
834806
///
835807
/// let f = x.tanh();
@@ -893,9 +865,7 @@ impl f64 {
893865
/// # Examples
894866
///
895867
/// ```
896-
/// use std::f64;
897-
///
898-
/// let e = f64::consts::E;
868+
/// let e = std::f64::consts::E;
899869
/// let f = e.tanh().atanh();
900870
///
901871
/// let abs_difference = (f - e).abs();

‎src/libstd/lib.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -517,20 +517,8 @@ pub use std_detect::detect;
517517
#[stable(feature = "rust1", since = "1.0.0")]
518518
#[allow(deprecated, deprecated_in_future)]
519519
pub use core::{
520-
// Stable
521-
assert_eq,
522-
assert_ne,
523-
debug_assert,
524-
debug_assert_eq,
525-
debug_assert_ne,
526-
// Unstable
527-
matches,
528-
r#try,
529-
todo,
530-
unimplemented,
531-
unreachable,
532-
write,
533-
writeln,
520+
assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, r#try, todo,
521+
unimplemented, unreachable, write, writeln,
534522
};
535523

536524
// Re-export built-in macros defined through libcore.
Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
11
#![cfg(target_thread_local)]
22
#![unstable(feature = "thread_local_internals", issue = "none")]
33

4-
pub use crate::sys_common::thread_local::register_dtor_fallback as register_dtor;
4+
// Simplify dtor registration by using a list of destructors.
5+
// The this solution works like the implementation of macOS and
6+
// doesn't additional OS support
7+
8+
use crate::cell::Cell;
9+
use crate::ptr;
10+
11+
#[thread_local]
12+
static DTORS: Cell<*mut List> = Cell::new(ptr::null_mut());
13+
14+
type List = Vec<(*mut u8, unsafe extern "C" fn(*mut u8))>;
15+
16+
pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
17+
if DTORS.get().is_null() {
18+
let v: Box<List> = box Vec::new();
19+
DTORS.set(Box::into_raw(v));
20+
}
21+
22+
let list: &mut List = &mut *DTORS.get();
23+
list.push((t, dtor));
24+
}
25+
26+
// every thread call this function to run through all possible destructors
27+
pub unsafe fn run_dtors() {
28+
let mut ptr = DTORS.replace(ptr::null_mut());
29+
while !ptr.is_null() {
30+
let list = Box::from_raw(ptr);
31+
for (ptr, dtor) in list.into_iter() {
32+
dtor(ptr);
33+
}
34+
ptr = DTORS.replace(ptr::null_mut());
35+
}
36+
}

‎src/libstd/sys/hermit/fs.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::io::{IoSlice, IoSliceMut, SeekFrom};
66
use crate::path::{Path, PathBuf};
77
use crate::sys::cvt;
88
use crate::sys::hermit::abi;
9+
use crate::sys::hermit::abi::{O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
910
use crate::sys::hermit::fd::FileDesc;
1011
use crate::sys::time::SystemTime;
1112
use crate::sys::{unsupported, Void};
@@ -17,14 +18,6 @@ pub use crate::sys_common::fs::copy;
1718
fn cstr(path: &Path) -> io::Result<CString> {
1819
Ok(CString::new(path.as_os_str().as_bytes())?)
1920
}
20-
//const O_ACCMODE: i32 = 00000003;
21-
const O_RDONLY: i32 = 00000000;
22-
const O_WRONLY: i32 = 00000001;
23-
const O_RDWR: i32 = 00000002;
24-
const O_CREAT: i32 = 00000100;
25-
const O_EXCL: i32 = 00000200;
26-
const O_TRUNC: i32 = 00001000;
27-
const O_APPEND: i32 = 00002000;
2821

2922
#[derive(Debug)]
3023
pub struct File(FileDesc);

‎src/libstd/sys/hermit/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub unsafe extern "C" fn runtime_entry(
103103
argv: *const *const c_char,
104104
env: *const *const c_char,
105105
) -> ! {
106+
use crate::sys::hermit::fast_thread_local::run_dtors;
106107
extern "C" {
107108
fn main(argc: isize, argv: *const *const c_char) -> i32;
108109
}
@@ -112,6 +113,7 @@ pub unsafe extern "C" fn runtime_entry(
112113

113114
let result = main(argc as isize, argv);
114115

116+
run_dtors();
115117
abi::exit(result);
116118
}
117119

‎src/libstd/sys/hermit/thread.rs

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,14 @@
11
#![allow(dead_code)]
22

33
use crate::ffi::CStr;
4-
use crate::fmt;
54
use crate::io;
65
use crate::mem;
76
use crate::sys::hermit::abi;
7+
use crate::sys::hermit::fast_thread_local::run_dtors;
88
use crate::time::Duration;
99

1010
pub type Tid = abi::Tid;
1111

12-
/// Priority of a task
13-
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy)]
14-
pub struct Priority(u8);
15-
16-
impl Priority {
17-
pub const fn into(self) -> u8 {
18-
self.0
19-
}
20-
21-
pub const fn from(x: u8) -> Self {
22-
Priority(x)
23-
}
24-
}
25-
26-
impl fmt::Display for Priority {
27-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28-
write!(f, "{}", self.0)
29-
}
30-
}
31-
32-
pub const NORMAL_PRIO: Priority = Priority::from(2);
33-
3412
pub struct Thread {
3513
tid: Tid,
3614
}
@@ -51,8 +29,8 @@ impl Thread {
5129
let ret = abi::spawn(
5230
&mut tid as *mut Tid,
5331
thread_start,
54-
p as usize,
55-
Priority::into(NORMAL_PRIO),
32+
&*p as *const _ as *const u8 as usize,
33+
abi::Priority::into(abi::NORMAL_PRIO),
5634
core_id,
5735
);
5836

@@ -69,6 +47,9 @@ impl Thread {
6947
unsafe {
7048
// Finally, let's run some code.
7149
Box::from_raw(main as *mut Box<dyn FnOnce()>)();
50+
51+
// run all destructors
52+
run_dtors();
7253
}
7354
}
7455
}

‎src/libstd/sys/hermit/thread_local.rs

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,26 @@
1-
#![allow(dead_code)] // not used on all platforms
2-
3-
use crate::collections::BTreeMap;
4-
use crate::ptr;
5-
use crate::sync::atomic::{AtomicUsize, Ordering};
6-
use crate::sys_common::mutex::Mutex;
7-
81
pub type Key = usize;
92

10-
type Dtor = unsafe extern "C" fn(*mut u8);
11-
12-
static NEXT_KEY: AtomicUsize = AtomicUsize::new(0);
13-
14-
static mut KEYS: *mut BTreeMap<Key, Option<Dtor>> = ptr::null_mut();
15-
static KEYS_LOCK: Mutex = Mutex::new();
16-
17-
#[thread_local]
18-
static mut LOCALS: *mut BTreeMap<Key, *mut u8> = ptr::null_mut();
19-
20-
unsafe fn keys() -> &'static mut BTreeMap<Key, Option<Dtor>> {
21-
if KEYS.is_null() {
22-
KEYS = Box::into_raw(Box::new(BTreeMap::new()));
23-
}
24-
&mut *KEYS
25-
}
26-
27-
unsafe fn locals() -> &'static mut BTreeMap<Key, *mut u8> {
28-
if LOCALS.is_null() {
29-
LOCALS = Box::into_raw(Box::new(BTreeMap::new()));
30-
}
31-
&mut *LOCALS
32-
}
33-
343
#[inline]
35-
pub unsafe fn create(dtor: Option<Dtor>) -> Key {
36-
let key = NEXT_KEY.fetch_add(1, Ordering::SeqCst);
37-
let _guard = KEYS_LOCK.lock();
38-
keys().insert(key, dtor);
39-
key
4+
pub unsafe fn create(_dtor: Option<unsafe extern "C" fn(*mut u8)>) -> Key {
5+
panic!("should not be used on the wasm target");
406
}
417

428
#[inline]
43-
pub unsafe fn get(key: Key) -> *mut u8 {
44-
if let Some(&entry) = locals().get(&key) { entry } else { ptr::null_mut() }
9+
pub unsafe fn set(_key: Key, _value: *mut u8) {
10+
panic!("should not be used on the wasm target");
4511
}
4612

4713
#[inline]
48-
pub unsafe fn set(key: Key, value: *mut u8) {
49-
locals().insert(key, value);
14+
pub unsafe fn get(_key: Key) -> *mut u8 {
15+
panic!("should not be used on the wasm target");
5016
}
5117

5218
#[inline]
53-
pub unsafe fn destroy(key: Key) {
54-
keys().remove(&key);
19+
pub unsafe fn destroy(_key: Key) {
20+
panic!("should not be used on the wasm target");
5521
}
5622

5723
#[inline]
5824
pub fn requires_synchronized_create() -> bool {
59-
false
25+
panic!("should not be used on the wasm target");
6026
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# ignore-msvc
2+
3+
-include ../tools.mk
4+
5+
RUSTC_FLAGS = -C linker-flavor=ld -C link-arg=a -C link-args="b c" -C link-args="d e" -C link-arg=f
6+
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
7+
8+
all:
9+
$(RUSTC) $(RUSTC_FLAGS) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f" "g"'
10+
$(RUSTC) $(RUSTC_FLAGS_PRE) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![feature(link_args)]
2+
3+
#[link_args = "g"]
4+
extern "C" {}
5+
6+
fn main() {}

‎src/test/ui/associated-const/issue-63496.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]);
1010
| cannot infer type
1111
| help: use the fully qualified path to an implementation: `<Type as A>::C`
1212
|
13-
= note: cannot resolve `_: A`
13+
= note: cannot satisfy `_: A`
1414
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
1515

1616
error[E0283]: type annotations needed
@@ -25,7 +25,7 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]);
2525
| cannot infer type
2626
| help: use the fully qualified path to an implementation: `<Type as A>::C`
2727
|
28-
= note: cannot resolve `_: A`
28+
= note: cannot satisfy `_: A`
2929
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
3030

3131
error: aborting due to 2 previous errors

‎src/test/ui/associated-item/issue-48027.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ LL | fn return_n(&self) -> [u8; Bar::X];
2222
| cannot infer type
2323
| help: use the fully qualified path to an implementation: `<Type as Bar>::X`
2424
|
25-
= note: cannot resolve `_: Bar`
25+
= note: cannot satisfy `_: Bar`
2626
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
2727

2828
error: aborting due to 2 previous errors

‎src/test/ui/associated-types/associated-types-overridden-binding.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | trait Foo: Iterator<Item = i32> {}
66
LL | trait Bar: Foo<Item = u32> {}
77
| ^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
88
|
9-
= note: cannot resolve `<Self as std::iter::Iterator>::Item == i32`
9+
= note: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
1010

1111
error[E0284]: type annotations needed
1212
--> $DIR/associated-types-overridden-binding.rs:7:21
@@ -16,7 +16,7 @@ LL | trait I32Iterator = Iterator<Item = i32>;
1616
LL | trait U32Iterator = I32Iterator<Item = u32>;
1717
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self`
1818
|
19-
= note: cannot resolve `<Self as std::iter::Iterator>::Item == i32`
19+
= note: cannot satisfy `<Self as std::iter::Iterator>::Item == i32`
2020

2121
error: aborting due to 2 previous errors
2222

‎src/test/ui/associated-types/associated-types-unconstrained.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0284]: type annotations needed
44
LL | let x: isize = Foo::bar();
55
| ^^^^^^^^ cannot infer type
66
|
7-
= note: cannot resolve `<_ as Foo>::A == _`
7+
= note: cannot satisfy `<_ as Foo>::A == _`
88

99
error: aborting due to previous error
1010

‎src/test/ui/error-codes/E0283.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | fn create() -> u32;
77
LL | let cont: u32 = Generator::create();
88
| ^^^^^^^^^^^^^^^^^ cannot infer type
99
|
10-
= note: cannot resolve `_: Generator`
10+
= note: cannot satisfy `_: Generator`
1111

1212
error: aborting due to previous error
1313

‎src/test/ui/issues/issue-12028.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0284]: type annotations needed
44
LL | self.input_stream(&mut stream);
55
| ^^^^^^^^^^^^ cannot infer type for type parameter `H` declared on the trait `StreamHash`
66
|
7-
= note: cannot resolve `<_ as StreamHasher>::S == <H as StreamHasher>::S`
7+
= note: cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S`
88

99
error: aborting due to previous error
1010

‎src/test/ui/issues/issue-21974.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | trait Foo {
77
LL | where &'a T : Foo,
88
| ^^^ cannot infer type for reference `&'a T`
99
|
10-
= note: cannot resolve `&'a T: Foo`
10+
= note: cannot satisfy `&'a T: Foo`
1111

1212
error: aborting due to previous error
1313

‎src/test/ui/issues/issue-24424.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL |
77
LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {}
88
| ^^^^^^^^^^^ cannot infer type for type parameter `T0`
99
|
10-
= note: cannot resolve `T0: Trait0<'l0>`
10+
= note: cannot satisfy `T0: Trait0<'l0>`
1111

1212
error: aborting due to previous error
1313

‎src/test/ui/issues/issue-29147.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | trait Foo { fn xxx(&self); }
77
LL | let _ = <S5<_>>::xxx;
88
| ^^^^^^^^^^^^ cannot infer type for struct `S5<_>`
99
|
10-
= note: cannot resolve `S5<_>: Foo`
10+
= note: cannot satisfy `S5<_>: Foo`
1111

1212
error: aborting due to previous error
1313

‎src/test/ui/issues/issue-54954.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | const ARR_LEN: usize = Tt::const_val::<[i8; 123]>();
1313
LL | const fn const_val<T: Sized>() -> usize {
1414
| --------- - required by this bound in `Tt::const_val`
1515
|
16-
= note: cannot resolve `_: Tt`
16+
= note: cannot satisfy `_: Tt`
1717

1818
error[E0080]: evaluation of constant value failed
1919
--> $DIR/issue-54954.rs:13:15

‎src/test/ui/issues/issue-58022.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | fn new(slice: &[u8; Foo::SIZE]) -> Self;
1616
| cannot infer type
1717
| help: use the fully qualified path to an implementation: `<Type as Foo>::SIZE`
1818
|
19-
= note: cannot resolve `_: Foo`
19+
= note: cannot satisfy `_: Foo`
2020
= note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl`
2121

2222
error: aborting due to 2 previous errors

‎src/test/ui/question-mark-type-infer.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0284]: type annotations needed
44
LL | l.iter().map(f).collect()?
55
| ^^^^^^^ cannot infer type
66
|
7-
= note: cannot resolve `<_ as std::ops::Try>::Ok == _`
7+
= note: cannot satisfy `<_ as std::ops::Try>::Ok == _`
88
help: consider specifying the type argument in the method call
99
|
1010
LL | l.iter().map(f).collect::<B>()?

‎src/test/ui/traits/trait-static-method-generic-inference.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | fn new() -> T;
77
LL | let _f: base::Foo = base::HasNew::new();
88
| ^^^^^^^^^^^^^^^^^ cannot infer type
99
|
10-
= note: cannot resolve `_: base::HasNew<base::Foo>`
10+
= note: cannot satisfy `_: base::HasNew<base::Foo>`
1111

1212
error: aborting due to previous error
1313

‎src/test/ui/type/type-annotation-needed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ fn main() {
66
foo(42);
77
//~^ ERROR type annotations needed
88
//~| NOTE cannot infer type
9-
//~| NOTE cannot resolve
9+
//~| NOTE cannot satisfy
1010
}

‎src/test/ui/type/type-annotation-needed.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | fn foo<T: Into<String>>(x: i32) {}
77
LL | foo(42);
88
| ^^^ cannot infer type for type parameter `T` declared on the function `foo`
99
|
10-
= note: cannot resolve `_: std::convert::Into<std::string::String>`
10+
= note: cannot satisfy `_: std::convert::Into<std::string::String>`
1111
help: consider specifying the type argument in the function call
1212
|
1313
LL | foo::<T>(42);

‎src/test/ui/type/type-check/issue-40294.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | trait Foo: Sized {
77
LL | where &'a T : Foo,
88
| ^^^ cannot infer type for reference `&'a T`
99
|
10-
= note: cannot resolve `&'a T: Foo`
10+
= note: cannot satisfy `&'a T: Foo`
1111

1212
error: aborting due to previous error
1313

0 commit comments

Comments
 (0)
This repository has been archived.