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

+1-1
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

+8-2
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

+12
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

+2-2
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

+12-12
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

+5-8
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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 {

src/librustc/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ pub enum ClearCrossCrate<T> {
403403
}
404404

405405
impl<T> ClearCrossCrate<T> {
406-
pub fn as_ref(&'a self) -> ClearCrossCrate<&'a T> {
406+
pub fn as_ref(&self) -> ClearCrossCrate<&T> {
407407
match self {
408408
ClearCrossCrate::Clear => ClearCrossCrate::Clear,
409409
ClearCrossCrate::Set(v) => ClearCrossCrate::Set(v),
@@ -2503,7 +2503,7 @@ impl UserTypeProjection {
25032503

25042504
pub(crate) fn variant(
25052505
mut self,
2506-
adt_def: &'tcx AdtDef,
2506+
adt_def: &AdtDef,
25072507
variant_index: VariantIdx,
25082508
field: Field,
25092509
) -> Self {

src/librustc/ty/util.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,7 @@ impl<'tcx> TyCtxt<'tcx> {
346346
adt_did: DefId,
347347
validate: &mut dyn FnMut(Self, DefId) -> Result<(), ErrorReported>,
348348
) -> Option<ty::Destructor> {
349-
let drop_trait = if let Some(def_id) = self.lang_items().drop_trait() {
350-
def_id
351-
} else {
352-
return None;
353-
};
354-
349+
let drop_trait = self.lang_items().drop_trait()?;
355350
self.ensure().coherent_trait(drop_trait);
356351

357352
let mut dtor_did = None;

src/librustc_codegen_llvm/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
323323
}
324324
}
325325

326-
pub fn val_ty(v: &'ll Value) -> &'ll Type {
326+
pub fn val_ty(v: &Value) -> &Type {
327327
unsafe { llvm::LLVMTypeOf(v) }
328328
}
329329

@@ -345,6 +345,6 @@ fn hi_lo_to_u128(lo: u64, hi: u64) -> u128 {
345345
((hi as u128) << 64) | (lo as u128)
346346
}
347347

348-
fn try_as_const_integral(v: &'ll Value) -> Option<&'ll ConstantInt> {
348+
fn try_as_const_integral(v: &Value) -> Option<&ConstantInt> {
349349
unsafe { llvm::LLVMIsAConstantInt(v) }
350350
}

src/librustc_codegen_llvm/llvm/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ impl Drop for SectionIter<'a> {
185185
}
186186
}
187187

188-
pub fn mk_section_iter(llof: &'a ffi::ObjectFile) -> SectionIter<'a> {
188+
pub fn mk_section_iter(llof: &ffi::ObjectFile) -> SectionIter<'_> {
189189
unsafe { SectionIter { llsi: LLVMGetSections(llof) } }
190190
}
191191

192192
/// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
193-
pub fn get_param(llfn: &'a Value, index: c_uint) -> &'a Value {
193+
pub fn get_param(llfn: &Value, index: c_uint) -> &Value {
194194
unsafe {
195195
assert!(
196196
index < LLVMCountParams(llfn),
@@ -203,7 +203,7 @@ pub fn get_param(llfn: &'a Value, index: c_uint) -> &'a Value {
203203
}
204204

205205
/// Safe wrapper for `LLVMGetValueName2` into a byte slice
206-
pub fn get_value_name(value: &'a Value) -> &'a [u8] {
206+
pub fn get_value_name(value: &Value) -> &[u8] {
207207
unsafe {
208208
let mut len = 0;
209209
let data = LLVMGetValueName2(value, &mut len);

src/librustc_codegen_llvm/type_.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl Type {
240240
unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) }
241241
}
242242

243-
pub fn i8p_llcx(llcx: &'ll llvm::Context) -> &'ll Type {
243+
pub fn i8p_llcx(llcx: &llvm::Context) -> &Type {
244244
Type::i8_llcx(llcx).ptr_to()
245245
}
246246

0 commit comments

Comments
 (0)