Skip to content

Commit 10d7e55

Browse files
committed
Auto merge of #155166 - JonathanBrouwer:rollup-YH2oUIz, r=JonathanBrouwer
Rollup of 6 pull requests Successful merges: - #155057 (Update libc to v0.2.184) - #154967 (Test(lib/sync): Fix `test_rwlock_max_readers` for x86 Win7) - #154994 (don't leak internal temporaries from `dbg!`) - #155130 (Stabilize feature `isolate_most_least_significant_one`) - #154925 (Make Box/Rc/Arc::into_array allocator-aware (and add doctest)) - #155063 (`ty::Alias`: replace `def_id: did` with `def_id`)
2 parents bf4fbfb + 58ca4df commit 10d7e55

13 files changed

Lines changed: 150 additions & 92 deletions

File tree

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,22 +1134,22 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
11341134
fn lower_path_segment(
11351135
&self,
11361136
span: Span,
1137-
did: DefId,
1137+
def_id: DefId,
11381138
item_segment: &hir::PathSegment<'tcx>,
11391139
) -> Ty<'tcx> {
11401140
let tcx = self.tcx();
1141-
let args = self.lower_generic_args_of_path_segment(span, did, item_segment);
1141+
let args = self.lower_generic_args_of_path_segment(span, def_id, item_segment);
11421142

1143-
if let DefKind::TyAlias = tcx.def_kind(did)
1144-
&& tcx.type_alias_is_lazy(did)
1143+
if let DefKind::TyAlias = tcx.def_kind(def_id)
1144+
&& tcx.type_alias_is_lazy(def_id)
11451145
{
11461146
// Type aliases defined in crates that have the
11471147
// feature `lazy_type_alias` enabled get encoded as a type alias that normalization will
11481148
// then actually instantiate the where bounds of.
1149-
let alias_ty = ty::AliasTy::new_from_args(tcx, ty::Free { def_id: did }, args);
1149+
let alias_ty = ty::AliasTy::new_from_args(tcx, ty::Free { def_id }, args);
11501150
Ty::new_alias(tcx, alias_ty)
11511151
} else {
1152-
tcx.at(span).type_of(did).instantiate(tcx, args)
1152+
tcx.at(span).type_of(def_id).instantiate(tcx, args)
11531153
}
11541154
}
11551155

library/Cargo.lock

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

147147
[[package]]
148148
name = "libc"
149-
version = "0.2.183"
149+
version = "0.2.184"
150150
source = "registry+https://github.com/rust-lang/crates.io-index"
151-
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
151+
checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af"
152152
dependencies = [
153153
"rustc-std-workspace-core",
154154
]

library/alloc/src/boxed.rs

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,26 +1006,6 @@ impl<T> Box<[T]> {
10061006
};
10071007
unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, Global).into_box(len)) }
10081008
}
1009-
1010-
/// Converts the boxed slice into a boxed array.
1011-
///
1012-
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
1013-
///
1014-
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1015-
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
1016-
#[inline]
1017-
#[must_use]
1018-
pub fn into_array<const N: usize>(self) -> Option<Box<[T; N]>> {
1019-
if self.len() == N {
1020-
let ptr = Self::into_raw(self) as *mut [T; N];
1021-
1022-
// SAFETY: The underlying array of a slice has the exact same layout as an actual array `[T; N]` if `N` is equal to the slice's length.
1023-
let me = unsafe { Box::from_raw(ptr) };
1024-
Some(me)
1025-
} else {
1026-
None
1027-
}
1028-
}
10291009
}
10301010

10311011
impl<T, A: Allocator> Box<[T], A> {
@@ -1157,6 +1137,36 @@ impl<T, A: Allocator> Box<[T], A> {
11571137
};
11581138
unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, alloc).into_box(len)) }
11591139
}
1140+
1141+
/// Converts the boxed slice into a boxed array.
1142+
///
1143+
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
1144+
///
1145+
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1146+
///
1147+
/// # Examples
1148+
///
1149+
/// ```
1150+
/// #![feature(alloc_slice_into_array)]
1151+
/// let box_slice: Box<[i32]> = Box::new([1, 2, 3]);
1152+
///
1153+
/// let box_array: Box<[i32; 3]> = box_slice.into_array().unwrap();
1154+
/// ```
1155+
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
1156+
#[inline]
1157+
#[must_use]
1158+
pub fn into_array<const N: usize>(self) -> Option<Box<[T; N], A>> {
1159+
if self.len() == N {
1160+
let (ptr, alloc) = Self::into_raw_with_allocator(self);
1161+
let ptr = ptr as *mut [T; N];
1162+
1163+
// SAFETY: The underlying array of a slice has the exact same layout as an actual array `[T; N]` if `N` is equal to the slice's length.
1164+
let me = unsafe { Box::from_raw_in(ptr, alloc) };
1165+
Some(me)
1166+
} else {
1167+
None
1168+
}
1169+
}
11601170
}
11611171

11621172
impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {

library/alloc/src/rc.rs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,26 +1167,6 @@ impl<T> Rc<[T]> {
11671167
))
11681168
}
11691169
}
1170-
1171-
/// Converts the reference-counted slice into a reference-counted array.
1172-
///
1173-
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
1174-
///
1175-
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1176-
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
1177-
#[inline]
1178-
#[must_use]
1179-
pub fn into_array<const N: usize>(self) -> Option<Rc<[T; N]>> {
1180-
if self.len() == N {
1181-
let ptr = Self::into_raw(self) as *const [T; N];
1182-
1183-
// SAFETY: The underlying array of a slice has the exact same layout as an actual array `[T; N]` if `N` is equal to the slice's length.
1184-
let me = unsafe { Rc::from_raw(ptr) };
1185-
Some(me)
1186-
} else {
1187-
None
1188-
}
1189-
}
11901170
}
11911171

11921172
impl<T, A: Allocator> Rc<[T], A> {
@@ -1260,6 +1240,38 @@ impl<T, A: Allocator> Rc<[T], A> {
12601240
)
12611241
}
12621242
}
1243+
1244+
/// Converts the reference-counted slice into a reference-counted array.
1245+
///
1246+
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
1247+
///
1248+
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1249+
///
1250+
/// # Examples
1251+
///
1252+
/// ```
1253+
/// #![feature(alloc_slice_into_array)]
1254+
/// use std::rc::Rc;
1255+
///
1256+
/// let rc_slice: Rc<[i32]> = Rc::new([1, 2, 3]);
1257+
///
1258+
/// let rc_array: Rc<[i32; 3]> = rc_slice.into_array().unwrap();
1259+
/// ```
1260+
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
1261+
#[inline]
1262+
#[must_use]
1263+
pub fn into_array<const N: usize>(self) -> Option<Rc<[T; N], A>> {
1264+
if self.len() == N {
1265+
let (ptr, alloc) = Self::into_raw_with_allocator(self);
1266+
let ptr = ptr as *const [T; N];
1267+
1268+
// SAFETY: The underlying array of a slice has the exact same layout as an actual array `[T; N]` if `N` is equal to the slice's length.
1269+
let me = unsafe { Rc::from_raw_in(ptr, alloc) };
1270+
Some(me)
1271+
} else {
1272+
None
1273+
}
1274+
}
12631275
}
12641276

12651277
impl<T, A: Allocator> Rc<mem::MaybeUninit<T>, A> {

library/alloc/src/sync.rs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,26 +1313,6 @@ impl<T> Arc<[T]> {
13131313
))
13141314
}
13151315
}
1316-
1317-
/// Converts the reference-counted slice into a reference-counted array.
1318-
///
1319-
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
1320-
///
1321-
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1322-
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
1323-
#[inline]
1324-
#[must_use]
1325-
pub fn into_array<const N: usize>(self) -> Option<Arc<[T; N]>> {
1326-
if self.len() == N {
1327-
let ptr = Self::into_raw(self) as *const [T; N];
1328-
1329-
// SAFETY: The underlying array of a slice has the exact same layout as an actual array `[T; N]` if `N` is equal to the slice's length.
1330-
let me = unsafe { Arc::from_raw(ptr) };
1331-
Some(me)
1332-
} else {
1333-
None
1334-
}
1335-
}
13361316
}
13371317

13381318
impl<T, A: Allocator> Arc<[T], A> {
@@ -1407,6 +1387,38 @@ impl<T, A: Allocator> Arc<[T], A> {
14071387
)
14081388
}
14091389
}
1390+
1391+
/// Converts the reference-counted slice into a reference-counted array.
1392+
///
1393+
/// This operation does not reallocate; the underlying array of the slice is simply reinterpreted as an array type.
1394+
///
1395+
/// If `N` is not exactly equal to the length of `self`, then this method returns `None`.
1396+
///
1397+
/// # Examples
1398+
///
1399+
/// ```
1400+
/// #![feature(alloc_slice_into_array)]
1401+
/// use std::sync::Arc;
1402+
///
1403+
/// let arc_slice: Arc<[i32]> = Arc::new([1, 2, 3]);
1404+
///
1405+
/// let arc_array: Arc<[i32; 3]> = arc_slice.into_array().unwrap();
1406+
/// ```
1407+
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
1408+
#[inline]
1409+
#[must_use]
1410+
pub fn into_array<const N: usize>(self) -> Option<Arc<[T; N], A>> {
1411+
if self.len() == N {
1412+
let (ptr, alloc) = Self::into_raw_with_allocator(self);
1413+
let ptr = ptr as *const [T; N];
1414+
1415+
// SAFETY: The underlying array of a slice has the exact same layout as an actual array `[T; N]` if `N` is equal to the slice's length.
1416+
let me = unsafe { Arc::from_raw_in(ptr, alloc) };
1417+
Some(me)
1418+
} else {
1419+
None
1420+
}
1421+
}
14101422
}
14111423

14121424
impl<T, A: Allocator> Arc<mem::MaybeUninit<T>, A> {

library/core/src/num/int_macros.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,13 @@ macro_rules! int_impl {
173173
/// # Examples
174174
///
175175
/// ```
176-
/// #![feature(isolate_most_least_significant_one)]
177-
///
178176
#[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")]
179177
///
180178
/// assert_eq!(n.isolate_highest_one(), 0b_01000000);
181179
#[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_highest_one(), 0);")]
182180
/// ```
183-
#[unstable(feature = "isolate_most_least_significant_one", issue = "136909")]
181+
#[stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
182+
#[rustc_const_stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
184183
#[must_use = "this returns the result of the operation, \
185184
without modifying the original"]
186185
#[inline(always)]
@@ -194,14 +193,13 @@ macro_rules! int_impl {
194193
/// # Examples
195194
///
196195
/// ```
197-
/// #![feature(isolate_most_least_significant_one)]
198-
///
199196
#[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")]
200197
///
201198
/// assert_eq!(n.isolate_lowest_one(), 0b_00000100);
202199
#[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_lowest_one(), 0);")]
203200
/// ```
204-
#[unstable(feature = "isolate_most_least_significant_one", issue = "136909")]
201+
#[stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
202+
#[rustc_const_stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
205203
#[must_use = "this returns the result of the operation, \
206204
without modifying the original"]
207205
#[inline(always)]

library/core/src/num/nonzero.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,6 @@ macro_rules! nonzero_integer {
650650
/// # Example
651651
///
652652
/// ```
653-
/// #![feature(isolate_most_least_significant_one)]
654-
///
655653
/// # use core::num::NonZero;
656654
/// # fn main() { test().unwrap(); }
657655
/// # fn test() -> Option<()> {
@@ -662,7 +660,8 @@ macro_rules! nonzero_integer {
662660
/// # Some(())
663661
/// # }
664662
/// ```
665-
#[unstable(feature = "isolate_most_least_significant_one", issue = "136909")]
663+
#[stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
664+
#[rustc_const_stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
666665
#[must_use = "this returns the result of the operation, \
667666
without modifying the original"]
668667
#[inline(always)]
@@ -683,8 +682,6 @@ macro_rules! nonzero_integer {
683682
/// # Example
684683
///
685684
/// ```
686-
/// #![feature(isolate_most_least_significant_one)]
687-
///
688685
/// # use core::num::NonZero;
689686
/// # fn main() { test().unwrap(); }
690687
/// # fn test() -> Option<()> {
@@ -695,7 +692,8 @@ macro_rules! nonzero_integer {
695692
/// # Some(())
696693
/// # }
697694
/// ```
698-
#[unstable(feature = "isolate_most_least_significant_one", issue = "136909")]
695+
#[stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
696+
#[rustc_const_stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
699697
#[must_use = "this returns the result of the operation, \
700698
without modifying the original"]
701699
#[inline(always)]

library/core/src/num/uint_macros.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,13 @@ macro_rules! uint_impl {
253253
/// # Examples
254254
///
255255
/// ```
256-
/// #![feature(isolate_most_least_significant_one)]
257-
///
258256
#[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")]
259257
///
260258
/// assert_eq!(n.isolate_highest_one(), 0b_01000000);
261259
#[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_highest_one(), 0);")]
262260
/// ```
263-
#[unstable(feature = "isolate_most_least_significant_one", issue = "136909")]
261+
#[stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
262+
#[rustc_const_stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
264263
#[must_use = "this returns the result of the operation, \
265264
without modifying the original"]
266265
#[inline(always)]
@@ -274,14 +273,13 @@ macro_rules! uint_impl {
274273
/// # Examples
275274
///
276275
/// ```
277-
/// #![feature(isolate_most_least_significant_one)]
278-
///
279276
#[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")]
280277
///
281278
/// assert_eq!(n.isolate_lowest_one(), 0b_00000100);
282279
#[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_lowest_one(), 0);")]
283280
/// ```
284-
#[unstable(feature = "isolate_most_least_significant_one", issue = "136909")]
281+
#[stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
282+
#[rustc_const_stable(feature = "isolate_most_least_significant_one", since = "CURRENT_RUSTC_VERSION")]
285283
#[must_use = "this returns the result of the operation, \
286284
without modifying the original"]
287285
#[inline(always)]

library/coretests/tests/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
#![feature(int_roundings)]
7171
#![feature(ip)]
7272
#![feature(is_ascii_octdigit)]
73-
#![feature(isolate_most_least_significant_one)]
7473
#![feature(iter_advance_by)]
7574
#![feature(iter_array_chunks)]
7675
#![feature(iter_collect_into)]

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ miniz_oxide = { version = "0.8.0", optional = true, default-features = false }
3333
addr2line = { version = "0.25.0", optional = true, default-features = false }
3434

3535
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
36-
libc = { version = "0.2.183", default-features = false, features = [
36+
libc = { version = "0.2.184", default-features = false, features = [
3737
'rustc-dep-of-std',
3838
], public = true }
3939

0 commit comments

Comments
 (0)