Skip to content

Commit e621e1c

Browse files
committed
Auto merge of #41357 - frewsxcv:rollup, r=frewsxcv
Rollup of 3 pull requests - Successful merges: #41262, #41310, #41344 - Failed merges:
2 parents 6b2aaaf + 8f65bb4 commit e621e1c

File tree

42 files changed

+452
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+452
-469
lines changed

src/Cargo.lock

-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/doc/unstable-book/src/SUMMARY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
- [collections](collections.md)
3939
- [collections_range](collections-range.md)
4040
- [command_envs](command-envs.md)
41-
- [compiler_barriers](compiler-barriers.md)
41+
- [compiler_fences](compiler-fences.md)
4242
- [compiler_builtins](compiler-builtins.md)
4343
- [compiler_builtins_lib](compiler-builtins-lib.md)
4444
- [concat_idents](concat-idents.md)

src/doc/unstable-book/src/compiler-barriers.md renamed to src/doc/unstable-book/src/compiler-fences.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# `compiler_barriers`
1+
# `compiler_fences`
22

33
The tracking issue for this feature is: [#41091]
44

55
[#41091]: https://github.com/rust-lang/rust/issues/41091
66

77
------------------------
88

9-
The `compiler_barriers` feature exposes the `compiler_barrier` function
9+
The `compiler_fences` feature exposes the `compiler_fence` function
1010
in `std::sync::atomic`. This function is conceptually similar to C++'s
1111
`atomic_signal_fence`, which can currently only be accessed in nightly
1212
Rust using the `atomic_singlethreadfence_*` instrinsic functions in
@@ -17,18 +17,18 @@ Rust using the `atomic_singlethreadfence_*` instrinsic functions in
1717
unsafe { asm!("" ::: "memory" : "volatile") };
1818
```
1919

20-
A `compiler_barrier` restricts the kinds of memory re-ordering the
20+
A `compiler_fence` restricts the kinds of memory re-ordering the
2121
compiler is allowed to do. Specifically, depending on the given ordering
2222
semantics, the compiler may be disallowed from moving reads or writes
2323
from before or after the call to the other side of the call to
24-
`compiler_barrier`. Note that it does **not** prevent the *hardware*
24+
`compiler_fence`. Note that it does **not** prevent the *hardware*
2525
from doing such re-ordering. This is not a problem in a single-threaded,
2626
execution context, but when other threads may modify memory at the same
2727
time, stronger synchronization primitives are required.
2828

2929
## Examples
3030

31-
`compiler_barrier` is generally only useful for preventing a thread from
31+
`compiler_fence` is generally only useful for preventing a thread from
3232
racing *with itself*. That is, if a given thread is executing one piece
3333
of code, and is then interrupted, and starts executing code elsewhere
3434
(while still in the same thread, and conceptually still on the same
@@ -37,7 +37,7 @@ handler is registered. In more low-level code, such situations can also
3737
arise when handling interrupts, when implementing green threads with
3838
pre-emption, etc.
3939

40-
To give a straightforward example of when a `compiler_barrier` is
40+
To give a straightforward example of when a `compiler_fence` is
4141
necessary, consider the following example:
4242

4343
```rust
@@ -67,22 +67,22 @@ remember that the compiler is free to swap the stores to
6767
after `IS_READY` is updated, then the signal handler will see
6868
`IS_READY=1`, but `IMPORTANT_VARIABLE=0`.
6969

70-
Using a `compiler_barrier`, we can remedy this situation:
70+
Using a `compiler_fence`, we can remedy this situation:
7171

7272
```rust
73-
#![feature(compiler_barriers)]
73+
#![feature(compiler_fences)]
7474
# use std::sync::atomic::{AtomicBool, AtomicUsize};
7575
# use std::sync::atomic::{ATOMIC_BOOL_INIT, ATOMIC_USIZE_INIT};
7676
# use std::sync::atomic::Ordering;
77-
use std::sync::atomic::compiler_barrier;
77+
use std::sync::atomic::compiler_fence;
7878

7979
static IMPORTANT_VARIABLE: AtomicUsize = ATOMIC_USIZE_INIT;
8080
static IS_READY: AtomicBool = ATOMIC_BOOL_INIT;
8181

8282
fn main() {
8383
IMPORTANT_VARIABLE.store(42, Ordering::Relaxed);
8484
// prevent earlier writes from being moved beyond this point
85-
compiler_barrier(Ordering::Release);
85+
compiler_fence(Ordering::Release);
8686
IS_READY.store(true, Ordering::Relaxed);
8787
}
8888

src/etc/natvis/libcollections.natvis

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
33
<Type Name="collections::vec::Vec&lt;*&gt;">
4-
    <DisplayString>{{ size={len} }}</DisplayString>
5-
    <Expand>
4+
<DisplayString>{{ size={len} }}</DisplayString>
5+
<Expand>
66
<Item Name="[size]" ExcludeView="simple">len</Item>
77
<Item Name="[capacity]" ExcludeView="simple">buf.cap</Item>
88
<ArrayItems>
99
<Size>len</Size>
1010
<ValuePointer>buf.ptr.pointer.__0</ValuePointer>
1111
</ArrayItems>
12-
    </Expand>
13-
  </Type>
12+
</Expand>
13+
</Type>
1414
<Type Name="collections::vec_deque::VecDeque&lt;*&gt;">
1515
<DisplayString>{{ size={tail &lt;= head ? head - tail : buf.cap - tail + head} }}</DisplayString>
1616
<Expand>

src/libcore/sync/atomic.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1591,11 +1591,11 @@ pub fn fence(order: Ordering) {
15911591
}
15921592

15931593

1594-
/// A compiler memory barrier.
1594+
/// A compiler memory fence.
15951595
///
1596-
/// `compiler_barrier` does not emit any machine code, but prevents the compiler from re-ordering
1596+
/// `compiler_fence` does not emit any machine code, but prevents the compiler from re-ordering
15971597
/// memory operations across this point. Which reorderings are disallowed is dictated by the given
1598-
/// [`Ordering`]. Note that `compiler_barrier` does *not* introduce inter-thread memory
1598+
/// [`Ordering`]. Note that `compiler_fence` does *not* introduce inter-thread memory
15991599
/// synchronization; for that, a [`fence`] is needed.
16001600
///
16011601
/// The re-ordering prevented by the different ordering semantics are:
@@ -1617,15 +1617,15 @@ pub fn fence(order: Ordering) {
16171617
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
16181618
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
16191619
#[inline]
1620-
#[unstable(feature = "compiler_barriers", issue = "41091")]
1621-
pub fn compiler_barrier(order: Ordering) {
1620+
#[unstable(feature = "compiler_fences", issue = "41091")]
1621+
pub fn compiler_fence(order: Ordering) {
16221622
unsafe {
16231623
match order {
16241624
Acquire => intrinsics::atomic_singlethreadfence_acq(),
16251625
Release => intrinsics::atomic_singlethreadfence_rel(),
16261626
AcqRel => intrinsics::atomic_singlethreadfence_acqrel(),
16271627
SeqCst => intrinsics::atomic_singlethreadfence(),
1628-
Relaxed => panic!("there is no such thing as a relaxed barrier"),
1628+
Relaxed => panic!("there is no such thing as a relaxed compiler fence"),
16291629
__Nonexhaustive => panic!("invalid memory ordering"),
16301630
}
16311631
}

src/librustc/diagnostics.rs

+19
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,25 @@ struct ListNode {
327327
This works because `Box` is a pointer, so its size is well-known.
328328
"##,
329329

330+
E0080: r##"
331+
This error indicates that the compiler was unable to sensibly evaluate an
332+
constant expression that had to be evaluated. Attempting to divide by 0
333+
or causing integer overflow are two ways to induce this error. For example:
334+
335+
```compile_fail,E0080
336+
enum Enum {
337+
X = (1 << 500),
338+
Y = (1 / 0)
339+
}
340+
```
341+
342+
Ensure that the expressions given can be evaluated as the desired integer type.
343+
See the FFI section of the Reference for more information about using a custom
344+
integer type:
345+
346+
https://doc.rust-lang.org/reference.html#ffi-attributes
347+
"##,
348+
330349
E0106: r##"
331350
This error indicates that a lifetime is missing from a type. If it is an error
332351
inside a function signature, the problem may be with failing to adhere to the

0 commit comments

Comments
 (0)