Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #77013

Merged
merged 21 commits into from
Sep 21, 2020
Merged
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
69ffed7
Add error explanation for E0755
GuillaumeGomez Sep 7, 2020
a06edda
Fix segfault if pthread_getattr_np fails
tavianator Sep 9, 2020
a684153
Only call pthread_attr_destroy() after getattr_np() succeeds on all l…
tavianator Sep 9, 2020
026922a
make replace_prefix only take &str as arguments
matthiaskrgr Sep 17, 2020
65edf54
Add a regression test for copy propagation miscompilation
tmiasko Sep 20, 2020
5ef1db3
Revert adding Atomic::from_mut.
m-ou-se Sep 20, 2020
d99bb9d
liballoc bench use imported path Bencher
pickfire Sep 20, 2020
37ec045
BTreeMap: extra testing unveiling mistakes in future PR
ssomers Sep 19, 2020
fc20b78
Fix typo in rustc_lexer docs
LingMan Sep 21, 2020
9172e27
Dogfood total_cmp in the test crate
est31 Sep 21, 2020
57baec7
update Miri for another bugfix
RalfJung Sep 21, 2020
670e204
Rollup merge of #76439 - GuillaumeGomez:add-error-explanation-e0755, …
RalfJung Sep 21, 2020
ae4b677
Rollup merge of #76521 - tavianator:fix-pthread-getattr-destroy, r=Am…
RalfJung Sep 21, 2020
982c4a9
Rollup merge of #76835 - matthiaskrgr:replace_prefix, r=lcnr
RalfJung Sep 21, 2020
b0c2eab
Rollup merge of #76967 - fusion-engineering-forks:revert-atomic-from-…
RalfJung Sep 21, 2020
9c14ef5
Rollup merge of #76977 - tmiasko:issue-76740, r=wesleywiser
RalfJung Sep 21, 2020
4b362bb
Rollup merge of #76981 - pickfire:patch-5, r=Mark-Simulacrum
RalfJung Sep 21, 2020
4547ebb
Rollup merge of #76983 - ssomers:btree_extra_test, r=Mark-Simulacrum
RalfJung Sep 21, 2020
48fc20c
Rollup merge of #76996 - LingMan:patch-1, r=ecstatic-morse
RalfJung Sep 21, 2020
fb3cb14
Rollup merge of #77009 - est31:dogfood_total_cmp, r=lcnr
RalfJung Sep 21, 2020
6417eb0
Rollup merge of #77012 - RalfJung:miri, r=RalfJung
RalfJung Sep 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 0 additions & 90 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ use self::Ordering::*;
use crate::cell::UnsafeCell;
use crate::fmt;
use crate::intrinsics;
use crate::mem::align_of;

use crate::hint::spin_loop;

Expand Down Expand Up @@ -328,27 +327,6 @@ impl AtomicBool {
unsafe { &mut *(self.v.get() as *mut bool) }
}

/// Get atomic access to a `&mut bool`.
///
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut)]
/// use std::sync::atomic::{AtomicBool, Ordering};
///
/// let mut some_bool = true;
/// let a = AtomicBool::from_mut(&mut some_bool);
/// a.store(false, Ordering::Relaxed);
/// assert_eq!(some_bool, false);
/// ```
#[inline]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
pub fn from_mut(v: &mut bool) -> &Self {
// SAFETY: the mutable reference guarantees unique ownership, and
// alignment of both `bool` and `Self` is 1.
unsafe { &*(v as *mut bool as *mut Self) }
}

/// Consumes the atomic and returns the contained value.
///
/// This is safe because passing `self` by value guarantees that no other threads are
Expand Down Expand Up @@ -841,30 +819,6 @@ impl<T> AtomicPtr<T> {
self.p.get_mut()
}

/// Get atomic access to a pointer.
///
/// # Examples
///
/// ```
/// #![feature(atomic_from_mut)]
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
/// let mut some_ptr = &mut 123 as *mut i32;
/// let a = AtomicPtr::from_mut(&mut some_ptr);
/// a.store(&mut 456, Ordering::Relaxed);
/// assert_eq!(unsafe { *some_ptr }, 456);
/// ```
#[inline]
#[unstable(feature = "atomic_from_mut", issue = "76314")]
pub fn from_mut(v: &mut *mut T) -> &Self {
let [] = [(); align_of::<AtomicPtr<()>>() - align_of::<*mut ()>()];
// SAFETY:
// - the mutable reference guarantees unique ownership.
// - the alignment of `*mut T` and `Self` is the same on all platforms
// supported by rust, as verified above.
unsafe { &*(v as *mut *mut T as *mut Self) }
}

/// Consumes the atomic and returns the contained value.
///
/// This is safe because passing `self` by value guarantees that no other threads are
Expand Down Expand Up @@ -1167,7 +1121,6 @@ macro_rules! atomic_int {
$stable_nand:meta,
$const_stable:meta,
$stable_init_const:meta,
$(from_mut: cfg($from_mut_cfg:meta),)?
$s_int_type:literal, $int_ref:expr,
$extra_feature:expr,
$min_fn:ident, $max_fn:ident,
Expand Down Expand Up @@ -1278,45 +1231,6 @@ assert_eq!(some_var.load(Ordering::SeqCst), 5);
}
}

doc_comment! {
concat!("Get atomic access to a `&mut ", stringify!($int_type), "`.

",
if_not_8_bit! {
$int_type,
concat!(
"**Note:** This function is only available on targets where `",
stringify!($int_type), "` has an alignment of ", $align, " bytes."
)
},
"

# Examples

```
#![feature(atomic_from_mut)]
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};

let mut some_int = 123;
let a = ", stringify!($atomic_type), "::from_mut(&mut some_int);
a.store(100, Ordering::Relaxed);
assert_eq!(some_int, 100);
```
"),
#[inline]
$(#[cfg($from_mut_cfg)])?
#[unstable(feature = "atomic_from_mut", issue = "76314")]
pub fn from_mut(v: &mut $int_type) -> &Self {
let [] = [(); align_of::<Self>() - align_of::<$int_type>()];
// SAFETY:
// - the mutable reference guarantees unique ownership.
// - the alignment of `$int_type` and `Self` is the
// same on all platforms enabled by `$from_mut_cfg`
// as verified above.
unsafe { &*(v as *mut $int_type as *mut Self) }
}
}

doc_comment! {
concat!("Consumes the atomic and returns the contained value.

Expand Down Expand Up @@ -2075,7 +1989,6 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
from_mut: cfg(not(target_arch = "x86")),
"i64", "../../../std/primitive.i64.html",
"",
atomic_min, atomic_max,
Expand All @@ -2094,7 +2007,6 @@ atomic_int! {
stable(feature = "integer_atomics_stable", since = "1.34.0"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
from_mut: cfg(not(target_arch = "x86")),
"u64", "../../../std/primitive.u64.html",
"",
atomic_umin, atomic_umax,
Expand All @@ -2113,7 +2025,6 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
from_mut: cfg(not(target_arch = "x86_64")),
"i128", "../../../std/primitive.i128.html",
"#![feature(integer_atomics)]\n\n",
atomic_min, atomic_max,
Expand All @@ -2132,7 +2043,6 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
rustc_const_stable(feature = "const_integer_atomics", since = "1.34.0"),
unstable(feature = "integer_atomics", issue = "32976"),
from_mut: cfg(not(target_arch = "x86_64")),
"u128", "../../../std/primitive.u128.html",
"#![feature(integer_atomics)]\n\n",
atomic_umin, atomic_umax,
Expand Down