Skip to content

Commit 1572c43

Browse files
committed
Auto merge of #69986 - JohnTitor:rollup-h0809mf, r=JohnTitor
Rollup of 12 pull requests Successful merges: - #69403 (Implement `Copy` for `IoSlice`) - #69460 (Move some `build-pass` tests to `check-pass`) - #69723 (Added doc on keyword Pub.) - #69802 (fix more clippy findings) - #69809 (remove lifetimes that can be elided (clippy::needless_lifetimes)) - #69947 (Clean up E0423 explanation) - #69949 (triagebot.toml: add ping aliases) - #69954 (rename panic_if_ intrinsics to assert_) - #69960 (miri engine: fix treatment of abort intrinsic) - #69966 (Add more regression tests) - #69973 (Update stable-since version for const_int_conversion) - #69974 (Clean up E0434 explanation) Failed merges: r? @ghost
2 parents d607231 + 1d8f5f0 commit 1572c43

File tree

106 files changed

+358
-237
lines changed

Some content is hidden

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

106 files changed

+358
-237
lines changed

src/liballoc/collections/linked_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ impl<'a, T> CursorMut<'a, T> {
14271427
/// `CursorMut`, which means it cannot outlive the `CursorMut` and that the
14281428
/// `CursorMut` is frozen for the lifetime of the `Cursor`.
14291429
#[unstable(feature = "linked_list_cursors", issue = "58533")]
1430-
pub fn as_cursor<'cm>(&'cm self) -> Cursor<'cm, T> {
1430+
pub fn as_cursor(&self) -> Cursor<'_, T> {
14311431
Cursor { list: self.list, current: self.current, index: self.index }
14321432
}
14331433
}

src/libcore/intrinsics.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,17 +1005,23 @@ extern "rust-intrinsic" {
10051005

10061006
/// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
10071007
/// This will statically either panic, or do nothing.
1008+
#[cfg(bootstrap)]
10081009
pub fn panic_if_uninhabited<T>();
10091010

1011+
/// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
1012+
/// This will statically either panic, or do nothing.
1013+
#[cfg(not(bootstrap))]
1014+
pub fn assert_inhabited<T>();
1015+
10101016
/// A guard for unsafe functions that cannot ever be executed if `T` does not permit
10111017
/// zero-initialization: This will statically either panic, or do nothing.
10121018
#[cfg(not(bootstrap))]
1013-
pub fn panic_if_zero_invalid<T>();
1019+
pub fn assert_zero_valid<T>();
10141020

10151021
/// A guard for unsafe functions that cannot ever be executed if `T` has invalid
10161022
/// bit patterns: This will statically either panic, or do nothing.
10171023
#[cfg(not(bootstrap))]
1018-
pub fn panic_if_any_invalid<T>();
1024+
pub fn assert_uninit_valid<T>();
10191025

10201026
/// Gets a reference to a static `Location` indicating where it was called.
10211027
#[rustc_const_unstable(feature = "const_caller_location", issue = "47809")]

src/libcore/mem/maybe_uninit.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,10 @@ impl<T> MaybeUninit<T> {
495495
#[inline(always)]
496496
#[rustc_diagnostic_item = "assume_init"]
497497
pub unsafe fn assume_init(self) -> T {
498+
#[cfg(bootstrap)]
498499
intrinsics::panic_if_uninhabited::<T>();
500+
#[cfg(not(bootstrap))]
501+
intrinsics::assert_inhabited::<T>();
499502
ManuallyDrop::into_inner(self.value)
500503
}
501504

@@ -559,7 +562,10 @@ impl<T> MaybeUninit<T> {
559562
#[unstable(feature = "maybe_uninit_extra", issue = "63567")]
560563
#[inline(always)]
561564
pub unsafe fn read(&self) -> T {
565+
#[cfg(bootstrap)]
562566
intrinsics::panic_if_uninhabited::<T>();
567+
#[cfg(not(bootstrap))]
568+
intrinsics::assert_inhabited::<T>();
563569
self.as_ptr().read()
564570
}
565571

@@ -621,7 +627,10 @@ impl<T> MaybeUninit<T> {
621627
#[unstable(feature = "maybe_uninit_ref", issue = "63568")]
622628
#[inline(always)]
623629
pub unsafe fn get_ref(&self) -> &T {
630+
#[cfg(bootstrap)]
624631
intrinsics::panic_if_uninhabited::<T>();
632+
#[cfg(not(bootstrap))]
633+
intrinsics::assert_inhabited::<T>();
625634
&*self.value
626635
}
627636

@@ -739,7 +748,10 @@ impl<T> MaybeUninit<T> {
739748
#[unstable(feature = "maybe_uninit_ref", issue = "63568")]
740749
#[inline(always)]
741750
pub unsafe fn get_mut(&mut self) -> &mut T {
751+
#[cfg(bootstrap)]
742752
intrinsics::panic_if_uninhabited::<T>();
753+
#[cfg(not(bootstrap))]
754+
intrinsics::assert_inhabited::<T>();
743755
&mut *self.value
744756
}
745757

src/libcore/mem/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ pub const fn needs_drop<T>() -> bool {
497497
#[rustc_diagnostic_item = "mem_zeroed"]
498498
pub unsafe fn zeroed<T>() -> T {
499499
#[cfg(not(bootstrap))]
500-
intrinsics::panic_if_zero_invalid::<T>();
500+
intrinsics::assert_zero_valid::<T>();
501501
#[cfg(bootstrap)]
502502
intrinsics::panic_if_uninhabited::<T>();
503503
intrinsics::init()
@@ -533,7 +533,7 @@ pub unsafe fn zeroed<T>() -> T {
533533
#[rustc_diagnostic_item = "mem_uninitialized"]
534534
pub unsafe fn uninitialized<T>() -> T {
535535
#[cfg(not(bootstrap))]
536-
intrinsics::panic_if_any_invalid::<T>();
536+
intrinsics::assert_uninit_valid::<T>();
537537
#[cfg(bootstrap)]
538538
intrinsics::panic_if_uninhabited::<T>();
539539
intrinsics::uninit()

src/libcore/num/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,7 +2154,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
21542154
assert_eq!(bytes, ", $be_bytes, ");
21552155
```"),
21562156
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
2157-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
2157+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
21582158
#[inline]
21592159
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
21602160
self.to_be().to_ne_bytes()
@@ -2174,7 +2174,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
21742174
assert_eq!(bytes, ", $le_bytes, ");
21752175
```"),
21762176
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
2177-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
2177+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
21782178
#[inline]
21792179
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
21802180
self.to_le().to_ne_bytes()
@@ -2209,7 +2209,7 @@ assert_eq!(
22092209
);
22102210
```"),
22112211
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
2212-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
2212+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
22132213
// SAFETY: const sound because integers are plain old datatypes so we can always
22142214
// transmute them to arrays of bytes
22152215
#[allow_internal_unstable(const_fn_union)]
@@ -2251,7 +2251,7 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
22512251
}
22522252
```"),
22532253
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
2254-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
2254+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
22552255
#[inline]
22562256
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
22572257
Self::from_be(Self::from_ne_bytes(bytes))
@@ -2284,7 +2284,7 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
22842284
}
22852285
```"),
22862286
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
2287-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
2287+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
22882288
#[inline]
22892289
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
22902290
Self::from_le(Self::from_ne_bytes(bytes))
@@ -2327,7 +2327,7 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
23272327
}
23282328
```"),
23292329
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
2330-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
2330+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
23312331
// SAFETY: const sound because integers are plain old datatypes so we can always
23322332
// transmute to them
23332333
#[allow_internal_unstable(const_fn_union)]
@@ -4115,7 +4115,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
41154115
assert_eq!(bytes, ", $be_bytes, ");
41164116
```"),
41174117
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
4118-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
4118+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
41194119
#[inline]
41204120
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
41214121
self.to_be().to_ne_bytes()
@@ -4135,7 +4135,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
41354135
assert_eq!(bytes, ", $le_bytes, ");
41364136
```"),
41374137
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
4138-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
4138+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
41394139
#[inline]
41404140
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
41414141
self.to_le().to_ne_bytes()
@@ -4170,7 +4170,7 @@ assert_eq!(
41704170
);
41714171
```"),
41724172
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
4173-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
4173+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
41744174
// SAFETY: const sound because integers are plain old datatypes so we can always
41754175
// transmute them to arrays of bytes
41764176
#[allow_internal_unstable(const_fn_union)]
@@ -4212,7 +4212,7 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
42124212
}
42134213
```"),
42144214
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
4215-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
4215+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
42164216
#[inline]
42174217
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
42184218
Self::from_be(Self::from_ne_bytes(bytes))
@@ -4245,7 +4245,7 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
42454245
}
42464246
```"),
42474247
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
4248-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
4248+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
42494249
#[inline]
42504250
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
42514251
Self::from_le(Self::from_ne_bytes(bytes))
@@ -4288,7 +4288,7 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
42884288
}
42894289
```"),
42904290
#[stable(feature = "int_to_from_bytes", since = "1.32.0")]
4291-
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")]
4291+
#[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
42924292
// SAFETY: const sound because integers are plain old datatypes so we can always
42934293
// transmute to them
42944294
#[allow_internal_unstable(const_fn_union)]

src/libcore/str/pattern.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,7 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> {
365365
let haystack = self.haystack.as_bytes();
366366
loop {
367367
// get the haystack up to but not including the last character searched
368-
let bytes = if let Some(slice) = haystack.get(self.finger..self.finger_back) {
369-
slice
370-
} else {
371-
return None;
372-
};
368+
let bytes = haystack.get(self.finger..self.finger_back)?;
373369
// the last byte of the utf8 encoded needle
374370
// SAFETY: we have an invariant that `utf8_size < 5`
375371
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size - 1) };
@@ -575,11 +571,12 @@ macro_rules! pattern_methods {
575571

576572
#[inline]
577573
fn is_suffix_of(self, haystack: &'a str) -> bool
578-
where $t: ReverseSearcher<'a>
574+
where
575+
$t: ReverseSearcher<'a>,
579576
{
580577
($pmap)(self).is_suffix_of(haystack)
581578
}
582-
}
579+
};
583580
}
584581

585582
macro_rules! searcher_methods {
@@ -614,7 +611,7 @@ macro_rules! searcher_methods {
614611
fn next_reject_back(&mut self) -> Option<(usize, usize)> {
615612
self.0.next_reject_back()
616613
}
617-
}
614+
};
618615
}
619616

620617
/////////////////////////////////////////////////////////////////////////////

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ macro_rules! define_dep_nodes {
179179
$(
180180
#[inline(always)]
181181
#[allow(unreachable_code, non_snake_case)]
182-
pub fn $variant<'tcx>(_tcx: TyCtxt<'tcx>, $(arg: $tuple_arg_ty)*) -> DepNode {
182+
pub fn $variant(_tcx: TyCtxt<'_>, $(arg: $tuple_arg_ty)*) -> DepNode {
183183
// tuple args
184184
$({
185185
erase!($tuple_arg_ty);

src/librustc/hir/map/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
340340
/// deep walking so that we walk nested items in the context of
341341
/// their outer items.
342342
343-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> {
343+
fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
344344
panic!("`visit_nested_xxx` must be manually implemented in this visitor");
345345
}
346346

src/librustc/hir/map/hir_id_validator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
135135
impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
136136
type Map = Map<'hir>;
137137

138-
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> {
138+
fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
139139
intravisit::NestedVisitorMap::OnlyBodies(self.hir_map)
140140
}
141141

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl<'hir> Map<'hir> {
298298
}
299299

300300
pub fn def_kind(&self, hir_id: HirId) -> Option<DefKind> {
301-
let node = if let Some(node) = self.find(hir_id) { node } else { return None };
301+
let node = self.find(hir_id)?;
302302

303303
Some(match node {
304304
Node::Item(item) => match item.kind {

0 commit comments

Comments
 (0)