Skip to content

Commit 77f95a8

Browse files
committed
Auto merge of rust-lang#72727 - JohnTitor:rollup-nni16m2, r=JohnTitor
Rollup of 11 pull requests Successful merges: - rust-lang#71633 (Impl Error for Infallible) - rust-lang#71843 (Tweak and stabilize AtomicN::fetch_update) - rust-lang#72288 (Stabilization of weak-into-raw) - rust-lang#72324 (Stabilize AtomicN::fetch_min and AtomicN::fetch_max) - rust-lang#72452 (Clarified the documentation for Formatter::precision) - rust-lang#72495 (Improve E0601 explanation) - rust-lang#72534 (Improve missing `@` in slice binding pattern diagnostics) - rust-lang#72547 (Added a codegen test for a recent optimization for overflow-checks=on) - rust-lang#72711 (remove redundant `mk_const`) - rust-lang#72713 (Whitelist #[allow_internal_unstable]) - rust-lang#72720 (Clarify the documentation of `take`) Failed merges: r? @ghost
2 parents 9cd3f1c + fb506af commit 77f95a8

File tree

14 files changed

+112
-57
lines changed

14 files changed

+112
-57
lines changed

src/liballoc/rc.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,6 @@ impl<T: ?Sized> Rc<T> {
580580
/// # Examples
581581
///
582582
/// ```
583-
/// #![feature(weak_into_raw)]
584-
///
585583
/// use std::rc::Rc;
586584
///
587585
/// let x = Rc::new("hello".to_owned());
@@ -590,7 +588,7 @@ impl<T: ?Sized> Rc<T> {
590588
/// assert_eq!(x_ptr, Rc::as_ptr(&y));
591589
/// assert_eq!(unsafe { &*x_ptr }, "hello");
592590
/// ```
593-
#[unstable(feature = "weak_into_raw", issue = "60728")]
591+
#[stable(feature = "weak_into_raw", since = "1.45.0")]
594592
pub fn as_ptr(this: &Self) -> *const T {
595593
let ptr: *mut RcBox<T> = NonNull::as_ptr(this.ptr);
596594
let fake_ptr = ptr as *mut T;
@@ -1681,8 +1679,6 @@ impl<T> Weak<T> {
16811679
/// # Examples
16821680
///
16831681
/// ```
1684-
/// #![feature(weak_into_raw)]
1685-
///
16861682
/// use std::rc::Rc;
16871683
/// use std::ptr;
16881684
///
@@ -1700,7 +1696,7 @@ impl<T> Weak<T> {
17001696
/// ```
17011697
///
17021698
/// [`null`]: ../../std/ptr/fn.null.html
1703-
#[unstable(feature = "weak_into_raw", issue = "60728")]
1699+
#[stable(feature = "weak_into_raw", since = "1.45.0")]
17041700
pub fn as_ptr(&self) -> *const T {
17051701
let offset = data_offset_sized::<T>();
17061702
let ptr = self.ptr.cast::<u8>().as_ptr().wrapping_offset(offset);
@@ -1718,8 +1714,6 @@ impl<T> Weak<T> {
17181714
/// # Examples
17191715
///
17201716
/// ```
1721-
/// #![feature(weak_into_raw)]
1722-
///
17231717
/// use std::rc::{Rc, Weak};
17241718
///
17251719
/// let strong = Rc::new("hello".to_owned());
@@ -1735,7 +1729,7 @@ impl<T> Weak<T> {
17351729
///
17361730
/// [`from_raw`]: struct.Weak.html#method.from_raw
17371731
/// [`as_ptr`]: struct.Weak.html#method.as_ptr
1738-
#[unstable(feature = "weak_into_raw", issue = "60728")]
1732+
#[stable(feature = "weak_into_raw", since = "1.45.0")]
17391733
pub fn into_raw(self) -> *const T {
17401734
let result = self.as_ptr();
17411735
mem::forget(self);
@@ -1762,8 +1756,6 @@ impl<T> Weak<T> {
17621756
/// # Examples
17631757
///
17641758
/// ```
1765-
/// #![feature(weak_into_raw)]
1766-
///
17671759
/// use std::rc::{Rc, Weak};
17681760
///
17691761
/// let strong = Rc::new("hello".to_owned());
@@ -1788,7 +1780,7 @@ impl<T> Weak<T> {
17881780
/// [`Weak`]: struct.Weak.html
17891781
/// [`new`]: struct.Weak.html#method.new
17901782
/// [`forget`]: ../../std/mem/fn.forget.html
1791-
#[unstable(feature = "weak_into_raw", issue = "60728")]
1783+
#[stable(feature = "weak_into_raw", since = "1.45.0")]
17921784
pub unsafe fn from_raw(ptr: *const T) -> Self {
17931785
if ptr.is_null() {
17941786
Self::new()

src/liballoc/sync.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,6 @@ impl<T: ?Sized> Arc<T> {
579579
/// # Examples
580580
///
581581
/// ```
582-
/// #![feature(weak_into_raw)]
583-
///
584582
/// use std::sync::Arc;
585583
///
586584
/// let x = Arc::new("hello".to_owned());
@@ -589,7 +587,7 @@ impl<T: ?Sized> Arc<T> {
589587
/// assert_eq!(x_ptr, Arc::as_ptr(&y));
590588
/// assert_eq!(unsafe { &*x_ptr }, "hello");
591589
/// ```
592-
#[unstable(feature = "weak_into_raw", issue = "60728")]
590+
#[stable(feature = "weak_into_raw", since = "1.45.0")]
593591
pub fn as_ptr(this: &Self) -> *const T {
594592
let ptr: *mut ArcInner<T> = NonNull::as_ptr(this.ptr);
595593
let fake_ptr = ptr as *mut T;
@@ -1449,8 +1447,6 @@ impl<T> Weak<T> {
14491447
/// # Examples
14501448
///
14511449
/// ```
1452-
/// #![feature(weak_into_raw)]
1453-
///
14541450
/// use std::sync::Arc;
14551451
/// use std::ptr;
14561452
///
@@ -1468,7 +1464,7 @@ impl<T> Weak<T> {
14681464
/// ```
14691465
///
14701466
/// [`null`]: ../../std/ptr/fn.null.html
1471-
#[unstable(feature = "weak_into_raw", issue = "60728")]
1467+
#[stable(feature = "weak_into_raw", since = "1.45.0")]
14721468
pub fn as_ptr(&self) -> *const T {
14731469
let offset = data_offset_sized::<T>();
14741470
let ptr = self.ptr.cast::<u8>().as_ptr().wrapping_offset(offset);
@@ -1486,8 +1482,6 @@ impl<T> Weak<T> {
14861482
/// # Examples
14871483
///
14881484
/// ```
1489-
/// #![feature(weak_into_raw)]
1490-
///
14911485
/// use std::sync::{Arc, Weak};
14921486
///
14931487
/// let strong = Arc::new("hello".to_owned());
@@ -1503,7 +1497,7 @@ impl<T> Weak<T> {
15031497
///
15041498
/// [`from_raw`]: struct.Weak.html#method.from_raw
15051499
/// [`as_ptr`]: struct.Weak.html#method.as_ptr
1506-
#[unstable(feature = "weak_into_raw", issue = "60728")]
1500+
#[stable(feature = "weak_into_raw", since = "1.45.0")]
15071501
pub fn into_raw(self) -> *const T {
15081502
let result = self.as_ptr();
15091503
mem::forget(self);
@@ -1531,8 +1525,6 @@ impl<T> Weak<T> {
15311525
/// # Examples
15321526
///
15331527
/// ```
1534-
/// #![feature(weak_into_raw)]
1535-
///
15361528
/// use std::sync::{Arc, Weak};
15371529
///
15381530
/// let strong = Arc::new("hello".to_owned());
@@ -1557,7 +1549,7 @@ impl<T> Weak<T> {
15571549
/// [`Weak`]: struct.Weak.html
15581550
/// [`Arc`]: struct.Arc.html
15591551
/// [`forget`]: ../../std/mem/fn.forget.html
1560-
#[unstable(feature = "weak_into_raw", issue = "60728")]
1552+
#[stable(feature = "weak_into_raw", since = "1.45.0")]
15611553
pub unsafe fn from_raw(ptr: *const T) -> Self {
15621554
if ptr.is_null() {
15631555
Self::new()

src/libcore/fmt/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,8 @@ impl<'a> Formatter<'a> {
16181618
self.width
16191619
}
16201620

1621-
/// Optionally specified precision for numeric types.
1621+
/// Optionally specified precision for numeric types. Alternatively, the
1622+
/// maximum width for string types.
16221623
///
16231624
/// # Examples
16241625
///

src/libcore/iter/traits/iterator.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,17 @@ pub trait Iterator {
11801180
/// assert_eq!(iter.next(), Some(2));
11811181
/// assert_eq!(iter.next(), None);
11821182
/// ```
1183+
///
1184+
/// If less than `n` elements are available,
1185+
/// `take` will limit itself to the size of the underlying iterator:
1186+
///
1187+
/// ```
1188+
/// let v = vec![1, 2];
1189+
/// let mut iter = v.into_iter().take(5);
1190+
/// assert_eq!(iter.next(), Some(1));
1191+
/// assert_eq!(iter.next(), Some(2));
1192+
/// assert_eq!(iter.next(), None);
1193+
/// ```
11831194
#[inline]
11841195
#[stable(feature = "rust1", since = "1.0.0")]
11851196
fn take(self, n: usize) -> Take<Self>

src/libcore/sync/atomic.rs

+13-25
Original file line numberDiff line numberDiff line change
@@ -1807,13 +1807,12 @@ new value. Returns a `Result` of `Ok(previous_value)` if the function returned `
18071807
18081808
Note: This may call the function multiple times if the value has been changed from other threads in
18091809
the meantime, as long as the function returns `Some(_)`, but the function will have been applied
1810-
but once to the stored value.
1810+
only once to the stored value.
18111811
1812-
`fetch_update` takes two [`Ordering`] arguments to describe the memory
1813-
ordering of this operation. The first describes the required ordering for loads
1814-
and failed updates while the second describes the required ordering when the
1815-
operation finally succeeds. Beware that this is different from the two
1816-
modes in [`compare_exchange`]!
1812+
`fetch_update` takes two [`Ordering`] arguments to describe the memory ordering of this operation.
1813+
The first describes the required ordering for when the operation finally succeeds while the second
1814+
describes the required ordering for loads. These correspond to the success and failure orderings of
1815+
[`compare_exchange`] respectively.
18171816
18181817
Using [`Acquire`] as success ordering makes the store part
18191818
of this operation [`Relaxed`], and using [`Release`] makes the final successful load
@@ -1831,24 +1830,21 @@ and must be equivalent to or weaker than the success ordering.
18311830
# Examples
18321831
18331832
```rust
1834-
#![feature(no_more_cas)]
18351833
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};
18361834
18371835
let x = ", stringify!($atomic_type), "::new(7);
1838-
assert_eq!(x.fetch_update(|_| None, Ordering::SeqCst, Ordering::SeqCst), Err(7));
1839-
assert_eq!(x.fetch_update(|x| Some(x + 1), Ordering::SeqCst, Ordering::SeqCst), Ok(7));
1840-
assert_eq!(x.fetch_update(|x| Some(x + 1), Ordering::SeqCst, Ordering::SeqCst), Ok(8));
1836+
assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |_| None), Err(7));
1837+
assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(x + 1)), Ok(7));
1838+
assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(x + 1)), Ok(8));
18411839
assert_eq!(x.load(Ordering::SeqCst), 9);
18421840
```"),
18431841
#[inline]
1844-
#[unstable(feature = "no_more_cas",
1845-
reason = "no more CAS loops in user code",
1846-
issue = "48655")]
1842+
#[stable(feature = "no_more_cas", since = "1.45.0")]
18471843
#[$cfg_cas]
18481844
pub fn fetch_update<F>(&self,
1849-
mut f: F,
1845+
set_order: Ordering,
18501846
fetch_order: Ordering,
1851-
set_order: Ordering) -> Result<$int_type, $int_type>
1847+
mut f: F) -> Result<$int_type, $int_type>
18521848
where F: FnMut($int_type) -> Option<$int_type> {
18531849
let mut prev = self.load(fetch_order);
18541850
while let Some(next) = f(prev) {
@@ -1882,7 +1878,6 @@ using [`Release`] makes the load part [`Relaxed`].
18821878
# Examples
18831879
18841880
```
1885-
#![feature(atomic_min_max)]
18861881
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};
18871882
18881883
let foo = ", stringify!($atomic_type), "::new(23);
@@ -1893,7 +1888,6 @@ assert_eq!(foo.load(Ordering::SeqCst), 42);
18931888
If you want to obtain the maximum value in one step, you can use the following:
18941889
18951890
```
1896-
#![feature(atomic_min_max)]
18971891
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};
18981892
18991893
let foo = ", stringify!($atomic_type), "::new(23);
@@ -1902,9 +1896,7 @@ let max_foo = foo.fetch_max(bar, Ordering::SeqCst).max(bar);
19021896
assert!(max_foo == 42);
19031897
```"),
19041898
#[inline]
1905-
#[unstable(feature = "atomic_min_max",
1906-
reason = "easier and faster min/max than writing manual CAS loop",
1907-
issue = "48655")]
1899+
#[stable(feature = "atomic_min_max", since = "1.45.0")]
19081900
#[$cfg_cas]
19091901
pub fn fetch_max(&self, val: $int_type, order: Ordering) -> $int_type {
19101902
// SAFETY: data races are prevented by atomic intrinsics.
@@ -1933,7 +1925,6 @@ using [`Release`] makes the load part [`Relaxed`].
19331925
# Examples
19341926
19351927
```
1936-
#![feature(atomic_min_max)]
19371928
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};
19381929
19391930
let foo = ", stringify!($atomic_type), "::new(23);
@@ -1946,7 +1937,6 @@ assert_eq!(foo.load(Ordering::Relaxed), 22);
19461937
If you want to obtain the minimum value in one step, you can use the following:
19471938
19481939
```
1949-
#![feature(atomic_min_max)]
19501940
", $extra_feature, "use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};
19511941
19521942
let foo = ", stringify!($atomic_type), "::new(23);
@@ -1955,9 +1945,7 @@ let min_foo = foo.fetch_min(bar, Ordering::SeqCst).min(bar);
19551945
assert_eq!(min_foo, 12);
19561946
```"),
19571947
#[inline]
1958-
#[unstable(feature = "atomic_min_max",
1959-
reason = "easier and faster min/max than writing manual CAS loop",
1960-
issue = "48655")]
1948+
#[stable(feature = "atomic_min_max", since = "1.45.0")]
19611949
#[$cfg_cas]
19621950
pub fn fetch_min(&self, val: $int_type, order: Ordering) -> $int_type {
19631951
// SAFETY: data races are prevented by atomic intrinsics.

src/librustc_error_codes/error_codes/E0601.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
No `main` function was found in a binary crate. To fix this error, add a
2-
`main` function. For example:
1+
No `main` function was found in a binary crate.
2+
3+
To fix this error, add a `main` function:
34

45
```
56
fn main() {

src/librustc_feature/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
366366
// FIXME(#14407)
367367
ungated!(rustc_const_stable, Whitelisted, template!(List: r#"feature = "name""#)),
368368
gated!(
369-
allow_internal_unstable, Normal, template!(Word, List: "feat1, feat2, ..."),
369+
allow_internal_unstable, Whitelisted, template!(Word, List: "feat1, feat2, ..."),
370370
"allow_internal_unstable side-steps feature gating and stability checks",
371371
),
372372
gated!(

src/librustc_mir/transform/const_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
606606
Operand::Constant(Box::new(Constant {
607607
span,
608608
user_ty: None,
609-
literal: self.tcx.mk_const(*ty::Const::from_scalar(self.tcx, scalar, ty)),
609+
literal: ty::Const::from_scalar(self.tcx, scalar, ty),
610610
}))
611611
}
612612

src/librustc_parse/parser/mod.rs

+20
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,26 @@ impl<'a> Parser<'a> {
672672
}
673673
}
674674

675+
// If this was a missing `@` in a binding pattern
676+
// bail with a suggestion
677+
// https://github.com/rust-lang/rust/issues/72373
678+
if self.prev_token.is_ident() && &self.token.kind == &token::DotDot {
679+
let msg = format!(
680+
"if you meant to bind the contents of \
681+
the rest of the array pattern into `{}`, use `@`",
682+
pprust::token_to_string(&self.prev_token)
683+
);
684+
expect_err
685+
.span_suggestion_verbose(
686+
self.prev_token.span.shrink_to_hi().until(self.token.span),
687+
&msg,
688+
" @ ".to_string(),
689+
Applicability::MaybeIncorrect,
690+
)
691+
.emit();
692+
break;
693+
}
694+
675695
// Attempt to keep parsing if it was an omitted separator.
676696
match f(self) {
677697
Ok(t) => {

src/libstd/error.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// reconsider what crate these items belong in.
1515

1616
use core::array;
17+
use core::convert::Infallible;
1718

1819
use crate::alloc::{AllocErr, LayoutErr};
1920
use crate::any::TypeId;
@@ -474,7 +475,7 @@ impl Error for string::FromUtf16Error {
474475
}
475476

476477
#[stable(feature = "str_parse_error2", since = "1.8.0")]
477-
impl Error for string::ParseError {
478+
impl Error for Infallible {
478479
fn description(&self) -> &str {
479480
match *self {}
480481
}

src/test/codegen/integer-overflow.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// no-system-llvm
2+
// compile-flags: -O -C overflow-checks=on
3+
4+
#![crate_type = "lib"]
5+
6+
7+
pub struct S1<'a> {
8+
data: &'a [u8],
9+
position: usize,
10+
}
11+
12+
// CHECK-LABEL: @slice_no_index_order
13+
#[no_mangle]
14+
pub fn slice_no_index_order<'a>(s: &'a mut S1, n: usize) -> &'a [u8] {
15+
// CHECK-NOT: slice_index_order_fail
16+
let d = &s.data[s.position..s.position+n];
17+
s.position += n;
18+
return d;
19+
}
20+
21+
// CHECK-LABEL: @test_check
22+
#[no_mangle]
23+
pub fn test_check<'a>(s: &'a mut S1, x: usize, y: usize) -> &'a [u8] {
24+
// CHECK: slice_index_order_fail
25+
&s.data[x..y]
26+
}

src/test/ui/issues/issue-72373.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn foo(c: &[u32], n: u32) -> u32 {
2+
match *c {
3+
[h, ..] if h > n => 0,
4+
[h, ..] if h == n => 1,
5+
[h, ref ts..] => foo(c, n - h) + foo(ts, n),
6+
//~^ ERROR expected one of `,`, `@`, `]`, or `|`, found `..`
7+
[] => 0,
8+
}
9+
}

src/test/ui/issues/issue-72373.stderr

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error: expected one of `,`, `@`, `]`, or `|`, found `..`
2+
--> $DIR/issue-72373.rs:5:19
3+
|
4+
LL | [h, ref ts..] => foo(c, n - h) + foo(ts, n),
5+
| ^^ expected one of `,`, `@`, `]`, or `|`
6+
|
7+
help: if you meant to bind the contents of the rest of the array pattern into `ts`, use `@`
8+
|
9+
LL | [h, ref ts @ ..] => foo(c, n - h) + foo(ts, n),
10+
| ^
11+
12+
error: aborting due to previous error
13+

0 commit comments

Comments
 (0)