Skip to content

Commit f9fdf64

Browse files
committed
Auto merge of #73093 - Dylan-DPC:rollup-9gh5tyu, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #72764 (Be more careful around ty::Error in generators) - #72908 (rename FalseEdges -> FalseEdge) - #72970 (Properly handle feature-gated lints) - #72998 (Mention that some atomic operations may not be available on some platforms) - #73063 (Elide type on liballoc vec) Failed merges: r? @ghost
2 parents a2fc33e + a23b51e commit f9fdf64

Some content is hidden

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

45 files changed

+234
-116
lines changed

src/liballoc/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ impl<T> Vec<T> {
984984
// bounds check above succeeds there must be a last element (which
985985
// can be self[index] itself).
986986
let last = ptr::read(self.as_ptr().add(len - 1));
987-
let hole: *mut T = self.as_mut_ptr().add(index);
987+
let hole = self.as_mut_ptr().add(index);
988988
self.set_len(len - 1);
989989
ptr::replace(hole, last)
990990
}

src/libcore/sync/atomic.rs

+87
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ pub fn spin_loop_hint() {
153153
///
154154
/// This type has the same in-memory representation as a [`bool`].
155155
///
156+
/// **Note**: This type is only available on platforms that support atomic
157+
/// loads and stores of `u8`.
158+
///
156159
/// [`bool`]: ../../../std/primitive.bool.html
157160
#[cfg(target_has_atomic_load_store = "8")]
158161
#[stable(feature = "rust1", since = "1.0.0")]
@@ -178,6 +181,9 @@ unsafe impl Sync for AtomicBool {}
178181
/// A raw pointer type which can be safely shared between threads.
179182
///
180183
/// This type has the same in-memory representation as a `*mut T`.
184+
///
185+
/// **Note**: This type is only available on platforms that support atomic
186+
/// loads and stores of pointers. Its size depends on the target pointer's size.
181187
#[cfg(target_has_atomic_load_store = "ptr")]
182188
#[stable(feature = "rust1", since = "1.0.0")]
183189
#[cfg_attr(target_pointer_width = "16", repr(C, align(2)))]
@@ -447,6 +453,9 @@ impl AtomicBool {
447453
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
448454
/// using [`Release`] makes the load part [`Relaxed`].
449455
///
456+
/// **Note:** This method is only available on platforms that support atomic
457+
/// operations on `u8`.
458+
///
450459
/// [`Ordering`]: enum.Ordering.html
451460
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
452461
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -481,6 +490,9 @@ impl AtomicBool {
481490
/// Using [`Acquire`] makes the store part of this operation [`Relaxed`] if it
482491
/// happens, and using [`Release`] makes the load part [`Relaxed`].
483492
///
493+
/// **Note:** This method is only available on platforms that support atomic
494+
/// operations on `u8`.
495+
///
484496
/// [`Ordering`]: enum.Ordering.html
485497
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
486498
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -524,6 +536,8 @@ impl AtomicBool {
524536
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
525537
/// and must be equivalent to or weaker than the success ordering.
526538
///
539+
/// **Note:** This method is only available on platforms that support atomic
540+
/// operations on `u8`.
527541
///
528542
/// [`bool`]: ../../../std/primitive.bool.html
529543
/// [`Ordering`]: enum.Ordering.html
@@ -586,6 +600,9 @@ impl AtomicBool {
586600
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
587601
/// and must be equivalent to or weaker than the success ordering.
588602
///
603+
/// **Note:** This method is only available on platforms that support atomic
604+
/// operations on `u8`.
605+
///
589606
/// [`bool`]: ../../../std/primitive.bool.html
590607
/// [`compare_exchange`]: #method.compare_exchange
591608
/// [`Ordering`]: enum.Ordering.html
@@ -646,6 +663,9 @@ impl AtomicBool {
646663
/// [`Release`]: enum.Ordering.html#variant.Release
647664
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
648665
///
666+
/// **Note:** This method is only available on platforms that support atomic
667+
/// operations on `u8`.
668+
///
649669
/// # Examples
650670
///
651671
/// ```
@@ -683,6 +703,9 @@ impl AtomicBool {
683703
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
684704
/// using [`Release`] makes the load part [`Relaxed`].
685705
///
706+
/// **Note:** This method is only available on platforms that support atomic
707+
/// operations on `u8`.
708+
///
686709
/// [`Ordering`]: enum.Ordering.html
687710
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
688711
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -737,6 +760,9 @@ impl AtomicBool {
737760
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
738761
/// using [`Release`] makes the load part [`Relaxed`].
739762
///
763+
/// **Note:** This method is only available on platforms that support atomic
764+
/// operations on `u8`.
765+
///
740766
/// [`Ordering`]: enum.Ordering.html
741767
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
742768
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -779,6 +805,9 @@ impl AtomicBool {
779805
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
780806
/// using [`Release`] makes the load part [`Relaxed`].
781807
///
808+
/// **Note:** This method is only available on platforms that support atomic
809+
/// operations on `u8`.
810+
///
782811
/// [`Ordering`]: enum.Ordering.html
783812
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
784813
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -981,6 +1010,9 @@ impl<T> AtomicPtr<T> {
9811010
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
9821011
/// using [`Release`] makes the load part [`Relaxed`].
9831012
///
1013+
/// **Note:** This method is only available on platforms that support atomic
1014+
/// operations on pointers.
1015+
///
9841016
/// [`Ordering`]: enum.Ordering.html
9851017
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
9861018
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -1017,6 +1049,9 @@ impl<T> AtomicPtr<T> {
10171049
/// Using [`Acquire`] makes the store part of this operation [`Relaxed`] if it
10181050
/// happens, and using [`Release`] makes the load part [`Relaxed`].
10191051
///
1052+
/// **Note:** This method is only available on platforms that support atomic
1053+
/// operations on pointers.
1054+
///
10201055
/// [`Ordering`]: enum.Ordering.html
10211056
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
10221057
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -1058,6 +1093,9 @@ impl<T> AtomicPtr<T> {
10581093
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
10591094
/// and must be equivalent to or weaker than the success ordering.
10601095
///
1096+
/// **Note:** This method is only available on platforms that support atomic
1097+
/// operations on pointers.
1098+
///
10611099
/// [`Ordering`]: enum.Ordering.html
10621100
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
10631101
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -1118,6 +1156,9 @@ impl<T> AtomicPtr<T> {
11181156
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
11191157
/// and must be equivalent to or weaker than the success ordering.
11201158
///
1159+
/// **Note:** This method is only available on platforms that support atomic
1160+
/// operations on pointers.
1161+
///
11211162
/// [`compare_exchange`]: #method.compare_exchange
11221163
/// [`Ordering`]: enum.Ordering.html
11231164
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
@@ -1223,6 +1264,13 @@ macro_rules! atomic_int {
12231264
/// non-atomic types as well as information about the portability of
12241265
/// this type, please see the [module-level documentation].
12251266
///
1267+
/// **Note:** This type is only available on platforms that support
1268+
/// atomic loads and stores of [`
1269+
#[doc = $s_int_type]
1270+
/// `](
1271+
#[doc = $int_ref]
1272+
/// ).
1273+
///
12261274
/// [module-level documentation]: index.html
12271275
#[$stable]
12281276
#[repr(C, align($align))]
@@ -1408,6 +1456,9 @@ of this operation. All ordering modes are possible. Note that using
14081456
[`Acquire`] makes the store part of this operation [`Relaxed`], and
14091457
using [`Release`] makes the load part [`Relaxed`].
14101458
1459+
**Note**: This method is only available on platforms that support atomic
1460+
operations on [`", $s_int_type, "`](", $int_ref, ").
1461+
14111462
[`Ordering`]: enum.Ordering.html
14121463
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
14131464
[`Release`]: enum.Ordering.html#variant.Release
@@ -1444,6 +1495,9 @@ might fail and hence just perform an `Acquire` load, but not have `Release` sema
14441495
Using [`Acquire`] makes the store part of this operation [`Relaxed`] if it
14451496
happens, and using [`Release`] makes the load part [`Relaxed`].
14461497
1498+
**Note**: This method is only available on platforms that support atomic
1499+
operations on [`", $s_int_type, "`](", $int_ref, ").
1500+
14471501
[`Ordering`]: enum.Ordering.html
14481502
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
14491503
[`Release`]: enum.Ordering.html#variant.Release
@@ -1496,6 +1550,9 @@ of this operation [`Relaxed`], and using [`Release`] makes the successful load
14961550
[`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
14971551
and must be equivalent to or weaker than the success ordering.
14981552
1553+
**Note**: This method is only available on platforms that support atomic
1554+
operations on [`", $s_int_type, "`](", $int_ref, ").
1555+
14991556
[`Ordering`]: enum.Ordering.html
15001557
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
15011558
[`Release`]: enum.Ordering.html#variant.Release
@@ -1558,6 +1615,9 @@ and must be equivalent to or weaker than the success ordering.
15581615
[`Acquire`]: enum.Ordering.html#variant.Acquire
15591616
[`SeqCst`]: enum.Ordering.html#variant.SeqCst
15601617
1618+
**Note**: This method is only available on platforms that support atomic
1619+
operations on [`", $s_int_type, "`](", $int_ref, ").
1620+
15611621
# Examples
15621622
15631623
```
@@ -1599,6 +1659,9 @@ of this operation. All ordering modes are possible. Note that using
15991659
[`Acquire`] makes the store part of this operation [`Relaxed`], and
16001660
using [`Release`] makes the load part [`Relaxed`].
16011661
1662+
**Note**: This method is only available on platforms that support atomic
1663+
operations on [`", $s_int_type, "`](", $int_ref, ").
1664+
16021665
[`Ordering`]: enum.Ordering.html
16031666
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
16041667
[`Release`]: enum.Ordering.html#variant.Release
@@ -1632,6 +1695,9 @@ of this operation. All ordering modes are possible. Note that using
16321695
[`Acquire`] makes the store part of this operation [`Relaxed`], and
16331696
using [`Release`] makes the load part [`Relaxed`].
16341697
1698+
**Note**: This method is only available on platforms that support atomic
1699+
operations on [`", $s_int_type, "`](", $int_ref, ").
1700+
16351701
[`Ordering`]: enum.Ordering.html
16361702
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
16371703
[`Release`]: enum.Ordering.html#variant.Release
@@ -1668,6 +1734,9 @@ of this operation. All ordering modes are possible. Note that using
16681734
[`Acquire`] makes the store part of this operation [`Relaxed`], and
16691735
using [`Release`] makes the load part [`Relaxed`].
16701736
1737+
**Note**: This method is only available on platforms that support atomic
1738+
operations on [`", $s_int_type, "`](", $int_ref, ").
1739+
16711740
[`Ordering`]: enum.Ordering.html
16721741
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
16731742
[`Release`]: enum.Ordering.html#variant.Release
@@ -1704,6 +1773,9 @@ of this operation. All ordering modes are possible. Note that using
17041773
[`Acquire`] makes the store part of this operation [`Relaxed`], and
17051774
using [`Release`] makes the load part [`Relaxed`].
17061775
1776+
**Note**: This method is only available on platforms that support atomic
1777+
operations on [`", $s_int_type, "`](", $int_ref, ").
1778+
17071779
[`Ordering`]: enum.Ordering.html
17081780
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
17091781
[`Release`]: enum.Ordering.html#variant.Release
@@ -1741,6 +1813,9 @@ of this operation. All ordering modes are possible. Note that using
17411813
[`Acquire`] makes the store part of this operation [`Relaxed`], and
17421814
using [`Release`] makes the load part [`Relaxed`].
17431815
1816+
**Note**: This method is only available on platforms that support atomic
1817+
operations on [`", $s_int_type, "`](", $int_ref, ").
1818+
17441819
[`Ordering`]: enum.Ordering.html
17451820
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
17461821
[`Release`]: enum.Ordering.html#variant.Release
@@ -1777,6 +1852,9 @@ of this operation. All ordering modes are possible. Note that using
17771852
[`Acquire`] makes the store part of this operation [`Relaxed`], and
17781853
using [`Release`] makes the load part [`Relaxed`].
17791854
1855+
**Note**: This method is only available on platforms that support atomic
1856+
operations on [`", $s_int_type, "`](", $int_ref, ").
1857+
17801858
[`Ordering`]: enum.Ordering.html
17811859
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
17821860
[`Release`]: enum.Ordering.html#variant.Release
@@ -1819,6 +1897,9 @@ of this operation [`Relaxed`], and using [`Release`] makes the final successful
18191897
[`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
18201898
and must be equivalent to or weaker than the success ordering.
18211899
1900+
**Note**: This method is only available on platforms that support atomic
1901+
operations on [`", $s_int_type, "`](", $int_ref, ").
1902+
18221903
[`bool`]: ../../../std/primitive.bool.html
18231904
[`compare_exchange`]: #method.compare_exchange
18241905
[`Ordering`]: enum.Ordering.html
@@ -1870,6 +1951,9 @@ of this operation. All ordering modes are possible. Note that using
18701951
[`Acquire`] makes the store part of this operation [`Relaxed`], and
18711952
using [`Release`] makes the load part [`Relaxed`].
18721953
1954+
**Note**: This method is only available on platforms that support atomic
1955+
operations on [`", $s_int_type, "`](", $int_ref, ").
1956+
18731957
[`Ordering`]: enum.Ordering.html
18741958
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
18751959
[`Release`]: enum.Ordering.html#variant.Release
@@ -1917,6 +2001,9 @@ of this operation. All ordering modes are possible. Note that using
19172001
[`Acquire`] makes the store part of this operation [`Relaxed`], and
19182002
using [`Release`] makes the load part [`Relaxed`].
19192003
2004+
**Note**: This method is only available on platforms that support atomic
2005+
operations on [`", $s_int_type, "`](", $int_ref, ").
2006+
19202007
[`Ordering`]: enum.Ordering.html
19212008
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
19222009
[`Release`]: enum.Ordering.html#variant.Release

src/librustc_codegen_ssa/mir/analyze.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKi
357357
| TerminatorKind::Unreachable
358358
| TerminatorKind::SwitchInt { .. }
359359
| TerminatorKind::Yield { .. }
360-
| TerminatorKind::FalseEdges { .. }
360+
| TerminatorKind::FalseEdge { .. }
361361
| TerminatorKind::FalseUnwind { .. }
362362
| TerminatorKind::InlineAsm { .. } => { /* nothing to do */ }
363363
TerminatorKind::Call { cleanup: unwind, .. }

src/librustc_codegen_ssa/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10301030
mir::TerminatorKind::GeneratorDrop | mir::TerminatorKind::Yield { .. } => {
10311031
bug!("generator ops in codegen")
10321032
}
1033-
mir::TerminatorKind::FalseEdges { .. } | mir::TerminatorKind::FalseUnwind { .. } => {
1033+
mir::TerminatorKind::FalseEdge { .. } | mir::TerminatorKind::FalseUnwind { .. } => {
10341034
bug!("borrowck false edges in codegen")
10351035
}
10361036

src/librustc_lint/levels.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ impl<'s> LintLevelsBuilder<'s> {
214214
match store.check_lint_name(&name.as_str(), tool_name) {
215215
CheckLintNameResult::Ok(ids) => {
216216
let src = LintSource::Node(name, li.span(), reason);
217-
for id in ids {
218-
self.check_gated_lint(*id, attr.span);
219-
specs.insert(*id, (level, src));
217+
for &id in ids {
218+
self.check_gated_lint(id, attr.span);
219+
specs.insert(id, (level, src));
220220
}
221221
}
222222

@@ -386,17 +386,18 @@ impl<'s> LintLevelsBuilder<'s> {
386386
BuilderPush { prev, changed: prev != self.cur }
387387
}
388388

389-
fn check_gated_lint(&self, id: LintId, span: Span) {
390-
if id == LintId::of(builtin::UNSAFE_OP_IN_UNSAFE_FN)
391-
&& !self.sess.features_untracked().unsafe_block_in_unsafe_fn
392-
{
393-
feature_err(
394-
&self.sess.parse_sess,
395-
sym::unsafe_block_in_unsafe_fn,
396-
span,
397-
"the `unsafe_op_in_unsafe_fn` lint is unstable",
398-
)
399-
.emit();
389+
/// Checks if the lint is gated on a feature that is not enabled.
390+
fn check_gated_lint(&self, lint_id: LintId, span: Span) {
391+
if let Some(feature) = lint_id.lint.feature_gate {
392+
if !self.sess.features_untracked().enabled(feature) {
393+
feature_err(
394+
&self.sess.parse_sess,
395+
feature,
396+
span,
397+
&format!("the `{}` lint is unstable", lint_id.lint.name_lower()),
398+
)
399+
.emit();
400+
}
400401
}
401402
}
402403

0 commit comments

Comments
 (0)