1
Fork 0

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
This commit is contained in:
bors 2020-03-13 19:16:03 +00:00
commit 1572c433ee
106 changed files with 358 additions and 237 deletions

View file

@ -1427,7 +1427,7 @@ impl<'a, T> CursorMut<'a, T> {
/// `CursorMut`, which means it cannot outlive the `CursorMut` and that the /// `CursorMut`, which means it cannot outlive the `CursorMut` and that the
/// `CursorMut` is frozen for the lifetime of the `Cursor`. /// `CursorMut` is frozen for the lifetime of the `Cursor`.
#[unstable(feature = "linked_list_cursors", issue = "58533")] #[unstable(feature = "linked_list_cursors", issue = "58533")]
pub fn as_cursor<'cm>(&'cm self) -> Cursor<'cm, T> { pub fn as_cursor(&self) -> Cursor<'_, T> {
Cursor { list: self.list, current: self.current, index: self.index } Cursor { list: self.list, current: self.current, index: self.index }
} }
} }

View file

@ -1005,17 +1005,23 @@ extern "rust-intrinsic" {
/// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
/// This will statically either panic, or do nothing. /// This will statically either panic, or do nothing.
#[cfg(bootstrap)]
pub fn panic_if_uninhabited<T>(); pub fn panic_if_uninhabited<T>();
/// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
/// This will statically either panic, or do nothing.
#[cfg(not(bootstrap))]
pub fn assert_inhabited<T>();
/// A guard for unsafe functions that cannot ever be executed if `T` does not permit /// A guard for unsafe functions that cannot ever be executed if `T` does not permit
/// zero-initialization: This will statically either panic, or do nothing. /// zero-initialization: This will statically either panic, or do nothing.
#[cfg(not(bootstrap))] #[cfg(not(bootstrap))]
pub fn panic_if_zero_invalid<T>(); pub fn assert_zero_valid<T>();
/// A guard for unsafe functions that cannot ever be executed if `T` has invalid /// A guard for unsafe functions that cannot ever be executed if `T` has invalid
/// bit patterns: This will statically either panic, or do nothing. /// bit patterns: This will statically either panic, or do nothing.
#[cfg(not(bootstrap))] #[cfg(not(bootstrap))]
pub fn panic_if_any_invalid<T>(); pub fn assert_uninit_valid<T>();
/// Gets a reference to a static `Location` indicating where it was called. /// Gets a reference to a static `Location` indicating where it was called.
#[rustc_const_unstable(feature = "const_caller_location", issue = "47809")] #[rustc_const_unstable(feature = "const_caller_location", issue = "47809")]

View file

@ -495,7 +495,10 @@ impl<T> MaybeUninit<T> {
#[inline(always)] #[inline(always)]
#[rustc_diagnostic_item = "assume_init"] #[rustc_diagnostic_item = "assume_init"]
pub unsafe fn assume_init(self) -> T { pub unsafe fn assume_init(self) -> T {
#[cfg(bootstrap)]
intrinsics::panic_if_uninhabited::<T>(); intrinsics::panic_if_uninhabited::<T>();
#[cfg(not(bootstrap))]
intrinsics::assert_inhabited::<T>();
ManuallyDrop::into_inner(self.value) ManuallyDrop::into_inner(self.value)
} }
@ -559,7 +562,10 @@ impl<T> MaybeUninit<T> {
#[unstable(feature = "maybe_uninit_extra", issue = "63567")] #[unstable(feature = "maybe_uninit_extra", issue = "63567")]
#[inline(always)] #[inline(always)]
pub unsafe fn read(&self) -> T { pub unsafe fn read(&self) -> T {
#[cfg(bootstrap)]
intrinsics::panic_if_uninhabited::<T>(); intrinsics::panic_if_uninhabited::<T>();
#[cfg(not(bootstrap))]
intrinsics::assert_inhabited::<T>();
self.as_ptr().read() self.as_ptr().read()
} }
@ -621,7 +627,10 @@ impl<T> MaybeUninit<T> {
#[unstable(feature = "maybe_uninit_ref", issue = "63568")] #[unstable(feature = "maybe_uninit_ref", issue = "63568")]
#[inline(always)] #[inline(always)]
pub unsafe fn get_ref(&self) -> &T { pub unsafe fn get_ref(&self) -> &T {
#[cfg(bootstrap)]
intrinsics::panic_if_uninhabited::<T>(); intrinsics::panic_if_uninhabited::<T>();
#[cfg(not(bootstrap))]
intrinsics::assert_inhabited::<T>();
&*self.value &*self.value
} }
@ -739,7 +748,10 @@ impl<T> MaybeUninit<T> {
#[unstable(feature = "maybe_uninit_ref", issue = "63568")] #[unstable(feature = "maybe_uninit_ref", issue = "63568")]
#[inline(always)] #[inline(always)]
pub unsafe fn get_mut(&mut self) -> &mut T { pub unsafe fn get_mut(&mut self) -> &mut T {
#[cfg(bootstrap)]
intrinsics::panic_if_uninhabited::<T>(); intrinsics::panic_if_uninhabited::<T>();
#[cfg(not(bootstrap))]
intrinsics::assert_inhabited::<T>();
&mut *self.value &mut *self.value
} }

View file

@ -497,7 +497,7 @@ pub const fn needs_drop<T>() -> bool {
#[rustc_diagnostic_item = "mem_zeroed"] #[rustc_diagnostic_item = "mem_zeroed"]
pub unsafe fn zeroed<T>() -> T { pub unsafe fn zeroed<T>() -> T {
#[cfg(not(bootstrap))] #[cfg(not(bootstrap))]
intrinsics::panic_if_zero_invalid::<T>(); intrinsics::assert_zero_valid::<T>();
#[cfg(bootstrap)] #[cfg(bootstrap)]
intrinsics::panic_if_uninhabited::<T>(); intrinsics::panic_if_uninhabited::<T>();
intrinsics::init() intrinsics::init()
@ -533,7 +533,7 @@ pub unsafe fn zeroed<T>() -> T {
#[rustc_diagnostic_item = "mem_uninitialized"] #[rustc_diagnostic_item = "mem_uninitialized"]
pub unsafe fn uninitialized<T>() -> T { pub unsafe fn uninitialized<T>() -> T {
#[cfg(not(bootstrap))] #[cfg(not(bootstrap))]
intrinsics::panic_if_any_invalid::<T>(); intrinsics::assert_uninit_valid::<T>();
#[cfg(bootstrap)] #[cfg(bootstrap)]
intrinsics::panic_if_uninhabited::<T>(); intrinsics::panic_if_uninhabited::<T>();
intrinsics::uninit() intrinsics::uninit()

View file

@ -2154,7 +2154,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
assert_eq!(bytes, ", $be_bytes, "); assert_eq!(bytes, ", $be_bytes, ");
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
#[inline] #[inline]
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] { pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_be().to_ne_bytes() self.to_be().to_ne_bytes()
@ -2174,7 +2174,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
assert_eq!(bytes, ", $le_bytes, "); assert_eq!(bytes, ", $le_bytes, ");
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
#[inline] #[inline]
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] { pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_le().to_ne_bytes() self.to_le().to_ne_bytes()
@ -2209,7 +2209,7 @@ assert_eq!(
); );
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
// SAFETY: const sound because integers are plain old datatypes so we can always // SAFETY: const sound because integers are plain old datatypes so we can always
// transmute them to arrays of bytes // transmute them to arrays of bytes
#[allow_internal_unstable(const_fn_union)] #[allow_internal_unstable(const_fn_union)]
@ -2251,7 +2251,7 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
} }
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
#[inline] #[inline]
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self { pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_be(Self::from_ne_bytes(bytes)) Self::from_be(Self::from_ne_bytes(bytes))
@ -2284,7 +2284,7 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
} }
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
#[inline] #[inline]
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self { pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_le(Self::from_ne_bytes(bytes)) Self::from_le(Self::from_ne_bytes(bytes))
@ -2327,7 +2327,7 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
} }
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
// SAFETY: const sound because integers are plain old datatypes so we can always // SAFETY: const sound because integers are plain old datatypes so we can always
// transmute to them // transmute to them
#[allow_internal_unstable(const_fn_union)] #[allow_internal_unstable(const_fn_union)]
@ -4115,7 +4115,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_be_bytes();
assert_eq!(bytes, ", $be_bytes, "); assert_eq!(bytes, ", $be_bytes, ");
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
#[inline] #[inline]
pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] { pub const fn to_be_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_be().to_ne_bytes() self.to_be().to_ne_bytes()
@ -4135,7 +4135,7 @@ let bytes = ", $swap_op, stringify!($SelfT), ".to_le_bytes();
assert_eq!(bytes, ", $le_bytes, "); assert_eq!(bytes, ", $le_bytes, ");
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
#[inline] #[inline]
pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] { pub const fn to_le_bytes(self) -> [u8; mem::size_of::<Self>()] {
self.to_le().to_ne_bytes() self.to_le().to_ne_bytes()
@ -4170,7 +4170,7 @@ assert_eq!(
); );
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
// SAFETY: const sound because integers are plain old datatypes so we can always // SAFETY: const sound because integers are plain old datatypes so we can always
// transmute them to arrays of bytes // transmute them to arrays of bytes
#[allow_internal_unstable(const_fn_union)] #[allow_internal_unstable(const_fn_union)]
@ -4212,7 +4212,7 @@ fn read_be_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
} }
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
#[inline] #[inline]
pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self { pub const fn from_be_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_be(Self::from_ne_bytes(bytes)) Self::from_be(Self::from_ne_bytes(bytes))
@ -4245,7 +4245,7 @@ fn read_le_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
} }
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
#[inline] #[inline]
pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self { pub const fn from_le_bytes(bytes: [u8; mem::size_of::<Self>()]) -> Self {
Self::from_le(Self::from_ne_bytes(bytes)) Self::from_le(Self::from_ne_bytes(bytes))
@ -4288,7 +4288,7 @@ fn read_ne_", stringify!($SelfT), "(input: &mut &[u8]) -> ", stringify!($SelfT),
} }
```"), ```"),
#[stable(feature = "int_to_from_bytes", since = "1.32.0")] #[stable(feature = "int_to_from_bytes", since = "1.32.0")]
#[rustc_const_stable(feature = "const_int_conversion", since = "1.43.0")] #[rustc_const_stable(feature = "const_int_conversion", since = "1.44.0")]
// SAFETY: const sound because integers are plain old datatypes so we can always // SAFETY: const sound because integers are plain old datatypes so we can always
// transmute to them // transmute to them
#[allow_internal_unstable(const_fn_union)] #[allow_internal_unstable(const_fn_union)]

View file

@ -365,11 +365,7 @@ unsafe impl<'a> ReverseSearcher<'a> for CharSearcher<'a> {
let haystack = self.haystack.as_bytes(); let haystack = self.haystack.as_bytes();
loop { loop {
// get the haystack up to but not including the last character searched // get the haystack up to but not including the last character searched
let bytes = if let Some(slice) = haystack.get(self.finger..self.finger_back) { let bytes = haystack.get(self.finger..self.finger_back)?;
slice
} else {
return None;
};
// the last byte of the utf8 encoded needle // the last byte of the utf8 encoded needle
// SAFETY: we have an invariant that `utf8_size < 5` // SAFETY: we have an invariant that `utf8_size < 5`
let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size - 1) }; let last_byte = unsafe { *self.utf8_encoded.get_unchecked(self.utf8_size - 1) };
@ -575,11 +571,12 @@ macro_rules! pattern_methods {
#[inline] #[inline]
fn is_suffix_of(self, haystack: &'a str) -> bool fn is_suffix_of(self, haystack: &'a str) -> bool
where $t: ReverseSearcher<'a> where
$t: ReverseSearcher<'a>,
{ {
($pmap)(self).is_suffix_of(haystack) ($pmap)(self).is_suffix_of(haystack)
} }
} };
} }
macro_rules! searcher_methods { macro_rules! searcher_methods {
@ -614,7 +611,7 @@ macro_rules! searcher_methods {
fn next_reject_back(&mut self) -> Option<(usize, usize)> { fn next_reject_back(&mut self) -> Option<(usize, usize)> {
self.0.next_reject_back() self.0.next_reject_back()
} }
} };
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View file

@ -179,7 +179,7 @@ macro_rules! define_dep_nodes {
$( $(
#[inline(always)] #[inline(always)]
#[allow(unreachable_code, non_snake_case)] #[allow(unreachable_code, non_snake_case)]
pub fn $variant<'tcx>(_tcx: TyCtxt<'tcx>, $(arg: $tuple_arg_ty)*) -> DepNode { pub fn $variant(_tcx: TyCtxt<'_>, $(arg: $tuple_arg_ty)*) -> DepNode {
// tuple args // tuple args
$({ $({
erase!($tuple_arg_ty); erase!($tuple_arg_ty);

View file

@ -340,7 +340,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
/// deep walking so that we walk nested items in the context of /// deep walking so that we walk nested items in the context of
/// their outer items. /// their outer items.
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
panic!("`visit_nested_xxx` must be manually implemented in this visitor"); panic!("`visit_nested_xxx` must be manually implemented in this visitor");
} }

View file

@ -135,7 +135,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> { impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
type Map = Map<'hir>; type Map = Map<'hir>;
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::OnlyBodies(self.hir_map) intravisit::NestedVisitorMap::OnlyBodies(self.hir_map)
} }

View file

@ -298,7 +298,7 @@ impl<'hir> Map<'hir> {
} }
pub fn def_kind(&self, hir_id: HirId) -> Option<DefKind> { pub fn def_kind(&self, hir_id: HirId) -> Option<DefKind> {
let node = if let Some(node) = self.find(hir_id) { node } else { return None }; let node = self.find(hir_id)?;
Some(match node { Some(match node {
Node::Item(item) => match item.kind { Node::Item(item) => match item.kind {

View file

@ -403,7 +403,7 @@ pub enum ClearCrossCrate<T> {
} }
impl<T> ClearCrossCrate<T> { impl<T> ClearCrossCrate<T> {
pub fn as_ref(&'a self) -> ClearCrossCrate<&'a T> { pub fn as_ref(&self) -> ClearCrossCrate<&T> {
match self { match self {
ClearCrossCrate::Clear => ClearCrossCrate::Clear, ClearCrossCrate::Clear => ClearCrossCrate::Clear,
ClearCrossCrate::Set(v) => ClearCrossCrate::Set(v), ClearCrossCrate::Set(v) => ClearCrossCrate::Set(v),
@ -2503,7 +2503,7 @@ impl UserTypeProjection {
pub(crate) fn variant( pub(crate) fn variant(
mut self, mut self,
adt_def: &'tcx AdtDef, adt_def: &AdtDef,
variant_index: VariantIdx, variant_index: VariantIdx,
field: Field, field: Field,
) -> Self { ) -> Self {

View file

@ -346,12 +346,7 @@ impl<'tcx> TyCtxt<'tcx> {
adt_did: DefId, adt_did: DefId,
validate: &mut dyn FnMut(Self, DefId) -> Result<(), ErrorReported>, validate: &mut dyn FnMut(Self, DefId) -> Result<(), ErrorReported>,
) -> Option<ty::Destructor> { ) -> Option<ty::Destructor> {
let drop_trait = if let Some(def_id) = self.lang_items().drop_trait() { let drop_trait = self.lang_items().drop_trait()?;
def_id
} else {
return None;
};
self.ensure().coherent_trait(drop_trait); self.ensure().coherent_trait(drop_trait);
let mut dtor_did = None; let mut dtor_did = None;

View file

@ -323,7 +323,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
} }
} }
pub fn val_ty(v: &'ll Value) -> &'ll Type { pub fn val_ty(v: &Value) -> &Type {
unsafe { llvm::LLVMTypeOf(v) } unsafe { llvm::LLVMTypeOf(v) }
} }
@ -345,6 +345,6 @@ fn hi_lo_to_u128(lo: u64, hi: u64) -> u128 {
((hi as u128) << 64) | (lo as u128) ((hi as u128) << 64) | (lo as u128)
} }
fn try_as_const_integral(v: &'ll Value) -> Option<&'ll ConstantInt> { fn try_as_const_integral(v: &Value) -> Option<&ConstantInt> {
unsafe { llvm::LLVMIsAConstantInt(v) } unsafe { llvm::LLVMIsAConstantInt(v) }
} }

View file

@ -185,12 +185,12 @@ impl Drop for SectionIter<'a> {
} }
} }
pub fn mk_section_iter(llof: &'a ffi::ObjectFile) -> SectionIter<'a> { pub fn mk_section_iter(llof: &ffi::ObjectFile) -> SectionIter<'_> {
unsafe { SectionIter { llsi: LLVMGetSections(llof) } } unsafe { SectionIter { llsi: LLVMGetSections(llof) } }
} }
/// Safe wrapper around `LLVMGetParam`, because segfaults are no fun. /// Safe wrapper around `LLVMGetParam`, because segfaults are no fun.
pub fn get_param(llfn: &'a Value, index: c_uint) -> &'a Value { pub fn get_param(llfn: &Value, index: c_uint) -> &Value {
unsafe { unsafe {
assert!( assert!(
index < LLVMCountParams(llfn), index < LLVMCountParams(llfn),
@ -203,7 +203,7 @@ pub fn get_param(llfn: &'a Value, index: c_uint) -> &'a Value {
} }
/// Safe wrapper for `LLVMGetValueName2` into a byte slice /// Safe wrapper for `LLVMGetValueName2` into a byte slice
pub fn get_value_name(value: &'a Value) -> &'a [u8] { pub fn get_value_name(value: &Value) -> &[u8] {
unsafe { unsafe {
let mut len = 0; let mut len = 0;
let data = LLVMGetValueName2(value, &mut len); let data = LLVMGetValueName2(value, &mut len);

View file

@ -240,7 +240,7 @@ impl Type {
unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) } unsafe { llvm::LLVMIntTypeInContext(llcx, num_bits as c_uint) }
} }
pub fn i8p_llcx(llcx: &'ll llvm::Context) -> &'ll Type { pub fn i8p_llcx(llcx: &llvm::Context) -> &Type {
Type::i8_llcx(llcx).ptr_to() Type::i8_llcx(llcx).ptr_to()
} }

View file

@ -449,38 +449,38 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
destination: &Option<(mir::Place<'tcx>, mir::BasicBlock)>, destination: &Option<(mir::Place<'tcx>, mir::BasicBlock)>,
cleanup: Option<mir::BasicBlock>, cleanup: Option<mir::BasicBlock>,
) -> bool { ) -> bool {
// Emit a panic or a no-op for `panic_if_uninhabited`. // Emit a panic or a no-op for `assert_*` intrinsics.
// These are intrinsics that compile to panics so that we can get a message // These are intrinsics that compile to panics so that we can get a message
// which mentions the offending type, even from a const context. // which mentions the offending type, even from a const context.
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
enum PanicIntrinsic { enum AssertIntrinsic {
IfUninhabited, Inhabited,
IfZeroInvalid, ZeroValid,
IfAnyInvalid, UninitValid,
}; };
let panic_intrinsic = intrinsic.and_then(|i| match i { let panic_intrinsic = intrinsic.and_then(|i| match i {
// FIXME: Move to symbols instead of strings. // FIXME: Move to symbols instead of strings.
"panic_if_uninhabited" => Some(PanicIntrinsic::IfUninhabited), "assert_inhabited" => Some(AssertIntrinsic::Inhabited),
"panic_if_zero_invalid" => Some(PanicIntrinsic::IfZeroInvalid), "assert_zero_valid" => Some(AssertIntrinsic::ZeroValid),
"panic_if_any_invalid" => Some(PanicIntrinsic::IfAnyInvalid), "assert_uninit_valid" => Some(AssertIntrinsic::UninitValid),
_ => None, _ => None,
}); });
if let Some(intrinsic) = panic_intrinsic { if let Some(intrinsic) = panic_intrinsic {
use PanicIntrinsic::*; use AssertIntrinsic::*;
let ty = instance.unwrap().substs.type_at(0); let ty = instance.unwrap().substs.type_at(0);
let layout = bx.layout_of(ty); let layout = bx.layout_of(ty);
let do_panic = match intrinsic { let do_panic = match intrinsic {
IfUninhabited => layout.abi.is_uninhabited(), Inhabited => layout.abi.is_uninhabited(),
// We unwrap as the error type is `!`. // We unwrap as the error type is `!`.
IfZeroInvalid => !layout.might_permit_raw_init(bx, /*zero:*/ true).unwrap(), ZeroValid => !layout.might_permit_raw_init(bx, /*zero:*/ true).unwrap(),
// We unwrap as the error type is `!`. // We unwrap as the error type is `!`.
IfAnyInvalid => !layout.might_permit_raw_init(bx, /*zero:*/ false).unwrap(), UninitValid => !layout.might_permit_raw_init(bx, /*zero:*/ false).unwrap(),
}; };
if do_panic { if do_panic {
let msg_str = if layout.abi.is_uninhabited() { let msg_str = if layout.abi.is_uninhabited() {
// Use this error even for the other intrinsics as it is more precise. // Use this error even for the other intrinsics as it is more precise.
format!("attempted to instantiate uninhabited type `{}`", ty) format!("attempted to instantiate uninhabited type `{}`", ty)
} else if intrinsic == IfZeroInvalid { } else if intrinsic == ZeroValid {
format!("attempted to zero-initialize type `{}`, which is invalid", ty) format!("attempted to zero-initialize type `{}`, which is invalid", ty)
} else { } else {
format!("attempted to leave type `{}` uninitialized, which is invalid", ty) format!("attempted to leave type `{}` uninitialized, which is invalid", ty)

View file

@ -97,7 +97,7 @@ impl<N: Idx, S: Idx> GraphSuccessors<'graph> for Sccs<N, S> {
} }
impl<N: Idx, S: Idx> WithSuccessors for Sccs<N, S> { impl<N: Idx, S: Idx> WithSuccessors for Sccs<N, S> {
fn successors<'graph>(&'graph self, node: S) -> <Self as GraphSuccessors<'graph>>::Iter { fn successors(&self, node: S) -> <Self as GraphSuccessors<'_>>::Iter {
self.successors(node).iter().cloned() self.successors(node).iter().cloned()
} }
} }

View file

@ -101,7 +101,7 @@ impl<N: Idx> GraphSuccessors<'graph> for VecGraph<N> {
} }
impl<N: Idx> WithSuccessors for VecGraph<N> { impl<N: Idx> WithSuccessors for VecGraph<N> {
fn successors<'graph>(&'graph self, node: N) -> <Self as GraphSuccessors<'graph>>::Iter { fn successors(&self, node: N) -> <Self as GraphSuccessors<'_>>::Iter {
self.successors(node).iter().cloned() self.successors(node).iter().cloned()
} }
} }

View file

@ -1124,12 +1124,7 @@ fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
return None; return None;
} }
let matches = if let Some(matches) = handle_options(&args) { let matches = handle_options(&args)?;
matches
} else {
return None;
};
let mut result = Vec::new(); let mut result = Vec::new();
let mut excluded_cargo_defaults = false; let mut excluded_cargo_defaults = false;
for flag in ICE_REPORT_COMPILER_FLAGS { for flag in ICE_REPORT_COMPILER_FLAGS {

View file

@ -96,7 +96,7 @@ trait PrinterSupport: pprust::PpAnn {
/// ///
/// (Rust does not yet support upcasting from a trait object to /// (Rust does not yet support upcasting from a trait object to
/// an object for one of its super-traits.) /// an object for one of its super-traits.)
fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn; fn pp_ann(&self) -> &dyn pprust::PpAnn;
} }
trait HirPrinterSupport<'hir>: pprust_hir::PpAnn { trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
@ -106,13 +106,13 @@ trait HirPrinterSupport<'hir>: pprust_hir::PpAnn {
/// Provides a uniform interface for re-extracting a reference to an /// Provides a uniform interface for re-extracting a reference to an
/// `hir_map::Map` from a value that now owns it. /// `hir_map::Map` from a value that now owns it.
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>>; fn hir_map(&self) -> Option<&hir_map::Map<'hir>>;
/// Produces the pretty-print annotation object. /// Produces the pretty-print annotation object.
/// ///
/// (Rust does not yet support upcasting from a trait object to /// (Rust does not yet support upcasting from a trait object to
/// an object for one of its super-traits.) /// an object for one of its super-traits.)
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn; fn pp_ann(&self) -> &dyn pprust_hir::PpAnn;
/// Computes an user-readable representation of a path, if possible. /// Computes an user-readable representation of a path, if possible.
fn node_path(&self, id: hir::HirId) -> Option<String> { fn node_path(&self, id: hir::HirId) -> Option<String> {
@ -132,7 +132,7 @@ impl<'hir> PrinterSupport for NoAnn<'hir> {
self.sess self.sess
} }
fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn { fn pp_ann(&self) -> &dyn pprust::PpAnn {
self self
} }
} }
@ -142,11 +142,11 @@ impl<'hir> HirPrinterSupport<'hir> for NoAnn<'hir> {
self.sess self.sess
} }
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> { fn hir_map(&self) -> Option<&hir_map::Map<'hir>> {
self.tcx.map(|tcx| *tcx.hir()) self.tcx.map(|tcx| *tcx.hir())
} }
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn { fn pp_ann(&self) -> &dyn pprust_hir::PpAnn {
self self
} }
} }
@ -170,7 +170,7 @@ impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> {
self.sess self.sess
} }
fn pp_ann<'a>(&'a self) -> &'a dyn pprust::PpAnn { fn pp_ann(&self) -> &dyn pprust::PpAnn {
self self
} }
} }
@ -216,11 +216,11 @@ impl<'hir> HirPrinterSupport<'hir> for IdentifiedAnnotation<'hir> {
self.sess self.sess
} }
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'hir>> { fn hir_map(&self) -> Option<&hir_map::Map<'hir>> {
self.tcx.map(|tcx| *tcx.hir()) self.tcx.map(|tcx| *tcx.hir())
} }
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn { fn pp_ann(&self) -> &dyn pprust_hir::PpAnn {
self self
} }
} }
@ -315,11 +315,11 @@ impl<'b, 'tcx> HirPrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> {
&self.tcx.sess &self.tcx.sess
} }
fn hir_map<'a>(&'a self) -> Option<&'a hir_map::Map<'tcx>> { fn hir_map(&self) -> Option<&hir_map::Map<'tcx>> {
Some(&self.tcx.hir()) Some(&self.tcx.hir())
} }
fn pp_ann<'a>(&'a self) -> &'a dyn pprust_hir::PpAnn { fn pp_ann(&self) -> &dyn pprust_hir::PpAnn {
self self
} }

View file

@ -1,8 +1,7 @@
An identifier was used like a function name or a value was expected and the An identifier was used like a function name or a value was expected and the
identifier exists but it belongs to a different namespace. identifier exists but it belongs to a different namespace.
For (an erroneous) example, here a `struct` variant name were used as a Erroneous code example:
function:
```compile_fail,E0423 ```compile_fail,E0423
struct Foo { a: bool }; struct Foo { a: bool };

View file

@ -1,6 +1,4 @@
This error indicates that a variable usage inside an inner function is invalid A variable used inside an inner function comes from a dynamic environment.
because the variable comes from a dynamic environment. Inner functions do not
have access to their containing environment.
Erroneous code example: Erroneous code example:
@ -14,8 +12,8 @@ fn foo() {
} }
``` ```
Functions do not capture local variables. To fix this error, you can replace the Inner functions do not have access to their containing environment. To fix this
function with a closure: error, you can replace the function with a closure:
``` ```
fn foo() { fn foo() {
@ -26,7 +24,7 @@ fn foo() {
} }
``` ```
or replace the captured variable with a constant or a static item: Or replace the captured variable with a constant or a static item:
``` ```
fn foo() { fn foo() {

View file

@ -284,7 +284,7 @@ pub trait Visitor<'v>: Sized {
/// If you use this, you probably don't want to process the /// If you use this, you probably don't want to process the
/// contents of nested item-like things, since the outer loop will /// contents of nested item-like things, since the outer loop will
/// visit them as well. /// visit them as well.
fn as_deep_visitor<'s>(&'s mut self) -> DeepVisitor<'s, Self> { fn as_deep_visitor(&mut self) -> DeepVisitor<'_, Self> {
DeepVisitor::new(self) DeepVisitor::new(self)
} }

View file

@ -162,7 +162,7 @@ impl IfThisChanged<'tcx> {
impl Visitor<'tcx> for IfThisChanged<'tcx> { impl Visitor<'tcx> for IfThisChanged<'tcx> {
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir()) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }

View file

@ -548,7 +548,7 @@ impl FindAllAttrs<'tcx> {
impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> { impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> {
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::All(&self.tcx.hir()) intravisit::NestedVisitorMap::All(&self.tcx.hir())
} }

View file

@ -69,7 +69,7 @@ impl<'a, 'tcx> FindLocalByTypeVisitor<'a, 'tcx> {
impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> { impl<'a, 'tcx> Visitor<'tcx> for FindLocalByTypeVisitor<'a, 'tcx> {
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.hir_map) NestedVisitorMap::OnlyBodies(&self.hir_map)
} }

View file

@ -93,7 +93,7 @@ struct FindNestedTypeVisitor<'tcx> {
impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> { impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir()) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }

View file

@ -113,7 +113,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
return AutoTraitResult::ExplicitImpl; return AutoTraitResult::ExplicitImpl;
} }
return tcx.infer_ctxt().enter(|mut infcx| { return tcx.infer_ctxt().enter(|infcx| {
let mut fresh_preds = FxHashSet::default(); let mut fresh_preds = FxHashSet::default();
// Due to the way projections are handled by SelectionContext, we need to run // Due to the way projections are handled by SelectionContext, we need to run
@ -164,7 +164,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
let (full_env, full_user_env) = self let (full_env, full_user_env) = self
.evaluate_predicates( .evaluate_predicates(
&mut infcx, &infcx,
trait_did, trait_did,
ty, ty,
new_env, new_env,

View file

@ -451,7 +451,7 @@ fn def_id_is_local(def_id: DefId, in_crate: InCrate) -> bool {
} }
} }
fn ty_is_non_local_constructor<'tcx>(ty: Ty<'tcx>, in_crate: InCrate) -> Option<Ty<'tcx>> { fn ty_is_non_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> Option<Ty<'_>> {
debug!("ty_is_non_local_constructor({:?})", ty); debug!("ty_is_non_local_constructor({:?})", ty);
match ty.kind { match ty.kind {

View file

@ -413,12 +413,7 @@ pub(super) fn specialization_graph_provider(
fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Option<String> { fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Option<String> {
use std::fmt::Write; use std::fmt::Write;
let trait_ref = if let Some(tr) = tcx.impl_trait_ref(impl_def_id) { let trait_ref = tcx.impl_trait_ref(impl_def_id)?;
tr
} else {
return None;
};
let mut w = "impl".to_owned(); let mut w = "impl".to_owned();
let substs = InternalSubsts::identity_for_item(tcx, impl_def_id); let substs = InternalSubsts::identity_for_item(tcx, impl_def_id);

View file

@ -33,7 +33,7 @@ use std::slice;
/// Extract the `LintStore` from the query context. /// Extract the `LintStore` from the query context.
/// This function exists because we've erased `LintStore` as `dyn Any` in the context. /// This function exists because we've erased `LintStore` as `dyn Any` in the context.
crate fn unerased_lint_store<'tcx>(tcx: TyCtxt<'tcx>) -> &'tcx LintStore { crate fn unerased_lint_store(tcx: TyCtxt<'_>) -> &LintStore {
let store: &dyn Any = &*tcx.lint_store; let store: &dyn Any = &*tcx.lint_store;
store.downcast_ref().unwrap() store.downcast_ref().unwrap()
} }
@ -99,7 +99,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> hir_visit::Visitor<'tcx>
/// Because lints are scoped lexically, we want to walk nested /// Because lints are scoped lexically, we want to walk nested
/// items in the context of the outer item, so enable /// items in the context of the outer item, so enable
/// deep-walking. /// deep-walking.
fn nested_visit_map<'this>(&'this mut self) -> hir_visit::NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> hir_visit::NestedVisitorMap<'_, Self::Map> {
hir_visit::NestedVisitorMap::All(&self.context.tcx.hir()) hir_visit::NestedVisitorMap::All(&self.context.tcx.hir())
} }

View file

@ -438,7 +438,7 @@ impl LintLevelMapBuilder<'_, '_> {
impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> { impl<'tcx> intravisit::Visitor<'tcx> for LintLevelMapBuilder<'_, 'tcx> {
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::All(&self.tcx.hir()) intravisit::NestedVisitorMap::All(&self.tcx.hir())
} }

View file

@ -43,7 +43,7 @@ pub(crate) fn const_field<'tcx>(
op_to_const(&ecx, field) op_to_const(&ecx, field)
} }
pub(crate) fn const_caller_location<'tcx>( pub(crate) fn const_caller_location(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
(file, line, col): (Symbol, u32, u32), (file, line, col): (Symbol, u32, u32),
) -> ConstValue<'tcx> { ) -> ConstValue<'tcx> {

View file

@ -84,14 +84,15 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let substs = instance.substs; let substs = instance.substs;
let intrinsic_name = self.tcx.item_name(instance.def_id()); let intrinsic_name = self.tcx.item_name(instance.def_id());
// We currently do not handle any intrinsics that are *allowed* to diverge, // First handle intrinsics without return place.
// but `transmute` could lack a return place in case of UB.
let (dest, ret) = match ret { let (dest, ret) = match ret {
Some(p) => p,
None => match intrinsic_name { None => match intrinsic_name {
sym::transmute => throw_ub!(Unreachable), sym::transmute => throw_ub_format!("transmuting to uninhabited type"),
sym::abort => M::abort(self)?,
// Unsupported diverging intrinsic.
_ => return Ok(false), _ => return Ok(false),
}, },
Some(p) => p,
}; };
// Keep the patterns in this match ordered the same as the list in // Keep the patterns in this match ordered the same as the list in
@ -103,10 +104,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
self.write_scalar(location.ptr, dest)?; self.write_scalar(location.ptr, dest)?;
} }
sym::abort => {
M::abort(self)?;
}
sym::min_align_of sym::min_align_of
| sym::pref_align_of | sym::pref_align_of
| sym::needs_drop | sym::needs_drop

View file

@ -34,7 +34,7 @@ fn is_stable(place: PlaceRef<'_>) -> bool {
} }
/// Determine whether this type may be a reference (or box), and thus needs retagging. /// Determine whether this type may be a reference (or box), and thus needs retagging.
fn may_be_reference<'tcx>(ty: Ty<'tcx>) -> bool { fn may_be_reference(ty: Ty<'tcx>) -> bool {
match ty.kind { match ty.kind {
// Primitive types that are not references // Primitive types that are not references
ty::Bool ty::Bool

View file

@ -453,7 +453,7 @@ struct UnusedUnsafeVisitor<'a> {
impl<'a, 'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> { impl<'a, 'tcx> intravisit::Visitor<'tcx> for UnusedUnsafeVisitor<'a> {
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
intravisit::NestedVisitorMap::None intravisit::NestedVisitorMap::None
} }

View file

@ -944,7 +944,7 @@ fn create_generator_drop_shim<'tcx>(
// unrelated code from the resume part of the function // unrelated code from the resume part of the function
simplify::remove_dead_blocks(&mut body); simplify::remove_dead_blocks(&mut body);
dump_mir(tcx, None, "generator_drop", &0, source, &mut body, |_, _| Ok(())); dump_mir(tcx, None, "generator_drop", &0, source, &body, |_, _| Ok(()));
body body
} }

View file

@ -87,7 +87,7 @@ fn mir_keys(tcx: TyCtxt<'_>, krate: CrateNum) -> &DefIdSet {
intravisit::walk_struct_def(self, v) intravisit::walk_struct_def(self, v)
} }
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'b>(&'b mut self) -> NestedVisitorMap<'b, Self::Map> { fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None NestedVisitorMap::None
} }
} }

View file

@ -293,7 +293,7 @@ fn dump_matched_mir_node<'tcx>(
writeln!(file, "// MIR local liveness analysis for `{}`", node_path)?; writeln!(file, "// MIR local liveness analysis for `{}`", node_path)?;
writeln!(file, "// source = {:?}", source)?; writeln!(file, "// source = {:?}", source)?;
writeln!(file, "// pass_name = {}", pass_name)?; writeln!(file, "// pass_name = {}", pass_name)?;
writeln!(file, "")?; writeln!(file)?;
write_mir_fn(tcx, source, body, &mut file, result)?; write_mir_fn(tcx, source, body, &mut file, result)?;
Ok(()) Ok(())
}); });
@ -316,7 +316,7 @@ pub fn write_mir_fn<'tcx>(
write_basic_block(tcx, block, body, &mut |_, _| Ok(()), w)?; write_basic_block(tcx, block, body, &mut |_, _| Ok(()), w)?;
print(w, " ", &result.outs)?; print(w, " ", &result.outs)?;
if block.index() + 1 != body.basic_blocks().len() { if block.index() + 1 != body.basic_blocks().len() {
writeln!(w, "")?; writeln!(w)?;
} }
} }

View file

@ -134,7 +134,7 @@ fn dump_matched_mir_node<'tcx, F>(
if let Some(ref layout) = body.generator_layout { if let Some(ref layout) = body.generator_layout {
writeln!(file, "// generator_layout = {:?}", layout)?; writeln!(file, "// generator_layout = {:?}", layout)?;
} }
writeln!(file, "")?; writeln!(file)?;
extra_data(PassWhere::BeforeCFG, &mut file)?; extra_data(PassWhere::BeforeCFG, &mut file)?;
write_user_type_annotations(body, &mut file)?; write_user_type_annotations(body, &mut file)?;
write_mir_fn(tcx, source, body, &mut extra_data, &mut file)?; write_mir_fn(tcx, source, body, &mut extra_data, &mut file)?;
@ -242,13 +242,13 @@ pub fn write_mir_pretty<'tcx>(
first = false; first = false;
} else { } else {
// Put empty lines between all items // Put empty lines between all items
writeln!(w, "")?; writeln!(w)?;
} }
write_mir_fn(tcx, MirSource::item(def_id), body, &mut |_, _| Ok(()), w)?; write_mir_fn(tcx, MirSource::item(def_id), body, &mut |_, _| Ok(()), w)?;
for (i, body) in tcx.promoted_mir(def_id).iter_enumerated() { for (i, body) in tcx.promoted_mir(def_id).iter_enumerated() {
writeln!(w, "")?; writeln!(w)?;
let src = MirSource { instance: ty::InstanceDef::Item(def_id), promoted: Some(i) }; let src = MirSource { instance: ty::InstanceDef::Item(def_id), promoted: Some(i) };
write_mir_fn(tcx, src, body, &mut |_, _| Ok(()), w)?; write_mir_fn(tcx, src, body, &mut |_, _| Ok(()), w)?;
} }
@ -271,7 +271,7 @@ where
extra_data(PassWhere::BeforeBlock(block), w)?; extra_data(PassWhere::BeforeBlock(block), w)?;
write_basic_block(tcx, block, body, extra_data, w)?; write_basic_block(tcx, block, body, extra_data, w)?;
if block.index() + 1 != body.basic_blocks().len() { if block.index() + 1 != body.basic_blocks().len() {
writeln!(w, "")?; writeln!(w)?;
} }
} }
@ -529,7 +529,7 @@ pub fn write_mir_intro<'tcx>(
write_scope_tree(tcx, body, &scope_tree, w, OUTERMOST_SOURCE_SCOPE, 1)?; write_scope_tree(tcx, body, &scope_tree, w, OUTERMOST_SOURCE_SCOPE, 1)?;
// Add an empty line before the first block is printed. // Add an empty line before the first block is printed.
writeln!(w, "")?; writeln!(w)?;
Ok(()) Ok(())
} }

View file

@ -271,11 +271,11 @@ pub fn stream_to_parser<'a>(
/// The main usage of this function is outside of rustc, for those who uses /// The main usage of this function is outside of rustc, for those who uses
/// librustc_ast as a library. Please do not remove this function while refactoring /// librustc_ast as a library. Please do not remove this function while refactoring
/// just because it is not used in rustc codebase! /// just because it is not used in rustc codebase!
pub fn stream_to_parser_with_base_dir<'a>( pub fn stream_to_parser_with_base_dir(
sess: &'a ParseSess, sess: &ParseSess,
stream: TokenStream, stream: TokenStream,
base_dir: Directory, base_dir: Directory,
) -> Parser<'a> { ) -> Parser<'_> {
Parser::new(sess, stream, Some(base_dir), true, false, None) Parser::new(sess, stream, Some(base_dir), true, false, None)
} }

View file

@ -418,7 +418,7 @@ impl CheckAttrVisitor<'tcx> {
impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir()) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }

View file

@ -143,7 +143,7 @@ impl LanguageItemCollector<'tcx> {
} }
/// Traverses and collects all the lang items in all crates. /// Traverses and collects all the lang items in all crates.
fn collect<'tcx>(tcx: TyCtxt<'tcx>) -> LanguageItems { fn collect(tcx: TyCtxt<'_>) -> LanguageItems {
// Initialize the collector. // Initialize the collector.
let mut collector = LanguageItemCollector::new(tcx); let mut collector = LanguageItemCollector::new(tcx);

View file

@ -46,7 +46,7 @@ struct LocalCollector {
impl Visitor<'tcx> for LocalCollector { impl Visitor<'tcx> for LocalCollector {
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None NestedVisitorMap::None
} }
@ -75,7 +75,7 @@ impl CaptureCollector<'_, '_> {
impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> { impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None NestedVisitorMap::None
} }

View file

@ -1107,11 +1107,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
} }
}; };
match ( match (lifetime_names.len(), lifetime_names.iter().next(), snippet.as_deref()) {
lifetime_names.len(),
lifetime_names.iter().next(),
snippet.as_ref().map(|s| s.as_str()),
) {
(1, Some(name), Some("&")) => { (1, Some(name), Some("&")) => {
suggest_existing(err, format!("&{} ", name)); suggest_existing(err, format!("&{} ", name));
} }

View file

@ -2773,12 +2773,8 @@ impl<'a> Resolver<'a> {
} else { } else {
let crate_id = if !speculative { let crate_id = if !speculative {
self.crate_loader.process_path_extern(ident.name, ident.span) self.crate_loader.process_path_extern(ident.name, ident.span)
} else if let Some(crate_id) =
self.crate_loader.maybe_process_path_extern(ident.name, ident.span)
{
crate_id
} else { } else {
return None; self.crate_loader.maybe_process_path_extern(ident.name, ident.span)?
}; };
let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX }); let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX });
Some( Some(

View file

@ -1147,11 +1147,7 @@ impl SourceFile {
} }
let begin = { let begin = {
let line = if let Some(line) = self.lines.get(line_number) { let line = self.lines.get(line_number)?;
line
} else {
return None;
};
let begin: BytePos = *line - self.start_pos; let begin: BytePos = *line - self.start_pos;
begin.to_usize() begin.to_usize()
}; };

View file

@ -603,7 +603,7 @@ impl ClauseDumper<'tcx> {
impl Visitor<'tcx> for ClauseDumper<'tcx> { impl Visitor<'tcx> for ClauseDumper<'tcx> {
type Map = Map<'tcx>; type Map = Map<'tcx>;
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, Self::Map> { fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::OnlyBodies(&self.tcx.hir()) NestedVisitorMap::OnlyBodies(&self.tcx.hir())
} }

View file

@ -210,7 +210,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
} }
} }
fn associated_items<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::AssociatedItems { fn associated_items(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::AssociatedItems {
let items = tcx.associated_item_def_ids(def_id).iter().map(|did| tcx.associated_item(*did)); let items = tcx.associated_item_def_ids(def_id).iter().map(|did| tcx.associated_item(*did));
tcx.arena.alloc(ty::AssociatedItems::new(items)) tcx.arena.alloc(ty::AssociatedItems::new(items))
} }

View file

@ -111,7 +111,7 @@ fn identity(_: Ty<'_>) -> Vec<Adjustment<'_>> {
vec![] vec![]
} }
fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> { fn simple(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> {
move |target| vec![Adjustment { kind, target }] move |target| vec![Adjustment { kind, target }]
} }

View file

@ -147,7 +147,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
), ),
"rustc_peek" => (1, vec![param(0)], param(0)), "rustc_peek" => (1, vec![param(0)], param(0)),
"caller_location" => (0, vec![], tcx.caller_location_ty()), "caller_location" => (0, vec![], tcx.caller_location_ty()),
"panic_if_uninhabited" | "panic_if_zero_invalid" | "panic_if_any_invalid" => { "assert_inhabited" | "assert_zero_valid" | "assert_uninit_valid" => {
(1, Vec::new(), tcx.mk_unit()) (1, Vec::new(), tcx.mk_unit())
} }
"init" => (1, Vec::new(), param(0)), "init" => (1, Vec::new(), param(0)),

View file

@ -860,7 +860,7 @@ enum Op {
} }
/// Dereferences a single level of immutable referencing. /// Dereferences a single level of immutable referencing.
fn deref_ty_if_possible<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> { fn deref_ty_if_possible(ty: Ty<'tcx>) -> Ty<'tcx> {
match ty.kind { match ty.kind {
ty::Ref(_, ty, hir::Mutability::Not) => ty, ty::Ref(_, ty, hir::Mutability::Not) => ty,
_ => ty, _ => ty,

View file

@ -322,7 +322,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: DefId) {
} }
} }
pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo { pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo {
debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did); debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did);
let coerce_unsized_trait = tcx.lang_items().coerce_unsized_trait().unwrap(); let coerce_unsized_trait = tcx.lang_items().coerce_unsized_trait().unwrap();

View file

@ -41,11 +41,7 @@ pub fn try_inline(
attrs: Option<Attrs<'_>>, attrs: Option<Attrs<'_>>,
visited: &mut FxHashSet<DefId>, visited: &mut FxHashSet<DefId>,
) -> Option<Vec<clean::Item>> { ) -> Option<Vec<clean::Item>> {
let did = if let Some(did) = res.opt_def_id() { let did = res.opt_def_id()?;
did
} else {
return None;
};
if did.is_local() { if did.is_local() {
return None; return None;
} }
@ -578,7 +574,7 @@ fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean:
name: ref _name, name: ref _name,
}, },
ref bounds, ref bounds,
} => !(*s == "Self" && did == trait_did) && !bounds.is_empty(), } => !(bounds.is_empty() || *s == "Self" && did == trait_did),
_ => true, _ => true,
}); });
g g

View file

@ -844,11 +844,7 @@ pub fn plain_summary_line(md: &str) -> String {
type Item = String; type Item = String;
fn next(&mut self) -> Option<String> { fn next(&mut self) -> Option<String> {
let next_event = self.inner.next(); let next_event = self.inner.next()?;
if next_event.is_none() {
return None;
}
let next_event = next_event.unwrap();
let (ret, is_in) = match next_event { let (ret, is_in) = match next_event {
Event::Start(Tag::Paragraph) => (None, 1), Event::Start(Tag::Paragraph) => (None, 1),
Event::Start(Tag::Heading(_)) => (None, 1), Event::Start(Tag::Heading(_)) => (None, 1),
@ -870,7 +866,7 @@ pub fn plain_summary_line(md: &str) -> String {
} }
let mut s = String::with_capacity(md.len() * 3 / 2); let mut s = String::with_capacity(md.len() * 3 / 2);
let p = ParserWrapper { inner: Parser::new(md), is_in: 0, is_first: true }; let p = ParserWrapper { inner: Parser::new(md), is_in: 0, is_first: true };
p.into_iter().filter(|t| !t.is_empty()).for_each(|i| s.push_str(&i)); p.filter(|t| !t.is_empty()).for_each(|i| s.push_str(&i));
s s
} }

View file

@ -1543,7 +1543,7 @@ impl Context {
} }
if self.shared.sort_modules_alphabetically { if self.shared.sort_modules_alphabetically {
for (_, items) in &mut map { for items in map.values_mut() {
items.sort(); items.sort();
} }
} }
@ -3396,10 +3396,8 @@ fn render_assoc_items(
let deref_impl = let deref_impl =
traits.iter().find(|t| t.inner_impl().trait_.def_id() == c.deref_trait_did); traits.iter().find(|t| t.inner_impl().trait_.def_id() == c.deref_trait_did);
if let Some(impl_) = deref_impl { if let Some(impl_) = deref_impl {
let has_deref_mut = traits let has_deref_mut =
.iter() traits.iter().any(|t| t.inner_impl().trait_.def_id() == c.deref_mut_trait_did);
.find(|t| t.inner_impl().trait_.def_id() == c.deref_mut_trait_did)
.is_some();
render_deref_methods(w, cx, impl_, containing_item, has_deref_mut); render_deref_methods(w, cx, impl_, containing_item, has_deref_mut);
} }
@ -3740,7 +3738,7 @@ fn render_impl(
) { ) {
for trait_item in &t.items { for trait_item in &t.items {
let n = trait_item.name.clone(); let n = trait_item.name.clone();
if i.items.iter().find(|m| m.name == n).is_some() { if i.items.iter().any(|m| m.name == n) {
continue; continue;
} }
let did = i.trait_.as_ref().unwrap().def_id().unwrap(); let did = i.trait_.as_ref().unwrap().def_id().unwrap();

View file

@ -8,106 +8,106 @@
//! directly written to a `Write` handle. //! directly written to a `Write` handle.
/// The file contents of the main `rustdoc.css` file, responsible for the core layout of the page. /// The file contents of the main `rustdoc.css` file, responsible for the core layout of the page.
pub static RUSTDOC_CSS: &'static str = include_str!("static/rustdoc.css"); pub static RUSTDOC_CSS: &str = include_str!("static/rustdoc.css");
/// The file contents of `settings.css`, responsible for the items on the settings page. /// The file contents of `settings.css`, responsible for the items on the settings page.
pub static SETTINGS_CSS: &'static str = include_str!("static/settings.css"); pub static SETTINGS_CSS: &str = include_str!("static/settings.css");
/// The file contents of the `noscript.css` file, used in case JS isn't supported or is disabled. /// The file contents of the `noscript.css` file, used in case JS isn't supported or is disabled.
pub static NOSCRIPT_CSS: &'static str = include_str!("static/noscript.css"); pub static NOSCRIPT_CSS: &str = include_str!("static/noscript.css");
/// The file contents of `normalize.css`, included to even out standard elements between browser /// The file contents of `normalize.css`, included to even out standard elements between browser
/// implementations. /// implementations.
pub static NORMALIZE_CSS: &'static str = include_str!("static/normalize.css"); pub static NORMALIZE_CSS: &str = include_str!("static/normalize.css");
/// The file contents of `main.js`, which contains the core JavaScript used on documentation pages, /// The file contents of `main.js`, which contains the core JavaScript used on documentation pages,
/// including search behavior and docblock folding, among others. /// including search behavior and docblock folding, among others.
pub static MAIN_JS: &'static str = include_str!("static/main.js"); pub static MAIN_JS: &str = include_str!("static/main.js");
/// The file contents of `settings.js`, which contains the JavaScript used to handle the settings /// The file contents of `settings.js`, which contains the JavaScript used to handle the settings
/// page. /// page.
pub static SETTINGS_JS: &'static str = include_str!("static/settings.js"); pub static SETTINGS_JS: &str = include_str!("static/settings.js");
/// The file contents of `storage.js`, which contains functionality related to browser Local /// The file contents of `storage.js`, which contains functionality related to browser Local
/// Storage, used to store documentation settings. /// Storage, used to store documentation settings.
pub static STORAGE_JS: &'static str = include_str!("static/storage.js"); pub static STORAGE_JS: &str = include_str!("static/storage.js");
/// The file contents of `brush.svg`, the icon used for the theme-switch button. /// The file contents of `brush.svg`, the icon used for the theme-switch button.
pub static BRUSH_SVG: &'static [u8] = include_bytes!("static/brush.svg"); pub static BRUSH_SVG: &[u8] = include_bytes!("static/brush.svg");
/// The file contents of `wheel.svg`, the icon used for the settings button. /// The file contents of `wheel.svg`, the icon used for the settings button.
pub static WHEEL_SVG: &'static [u8] = include_bytes!("static/wheel.svg"); pub static WHEEL_SVG: &[u8] = include_bytes!("static/wheel.svg");
/// The file contents of `down-arrow.svg`, the icon used for the crate choice combobox. /// The file contents of `down-arrow.svg`, the icon used for the crate choice combobox.
pub static DOWN_ARROW_SVG: &'static [u8] = include_bytes!("static/down-arrow.svg"); pub static DOWN_ARROW_SVG: &[u8] = include_bytes!("static/down-arrow.svg");
/// The contents of `COPYRIGHT.txt`, the license listing for files distributed with documentation /// The contents of `COPYRIGHT.txt`, the license listing for files distributed with documentation
/// output. /// output.
pub static COPYRIGHT: &'static [u8] = include_bytes!("static/COPYRIGHT.txt"); pub static COPYRIGHT: &[u8] = include_bytes!("static/COPYRIGHT.txt");
/// The contents of `LICENSE-APACHE.txt`, the text of the Apache License, version 2.0. /// The contents of `LICENSE-APACHE.txt`, the text of the Apache License, version 2.0.
pub static LICENSE_APACHE: &'static [u8] = include_bytes!("static/LICENSE-APACHE.txt"); pub static LICENSE_APACHE: &[u8] = include_bytes!("static/LICENSE-APACHE.txt");
/// The contents of `LICENSE-MIT.txt`, the text of the MIT License. /// The contents of `LICENSE-MIT.txt`, the text of the MIT License.
pub static LICENSE_MIT: &'static [u8] = include_bytes!("static/LICENSE-MIT.txt"); pub static LICENSE_MIT: &[u8] = include_bytes!("static/LICENSE-MIT.txt");
/// The contents of `rust-logo.png`, the default icon of the documentation. /// The contents of `rust-logo.png`, the default icon of the documentation.
pub static RUST_LOGO: &'static [u8] = include_bytes!("static/rust-logo.png"); pub static RUST_LOGO: &[u8] = include_bytes!("static/rust-logo.png");
/// The contents of `favicon.ico`, the default favicon of the documentation. /// The contents of `favicon.ico`, the default favicon of the documentation.
pub static RUST_FAVICON: &'static [u8] = include_bytes!("static/favicon.ico"); pub static RUST_FAVICON: &[u8] = include_bytes!("static/favicon.ico");
/// The built-in themes given to every documentation site. /// The built-in themes given to every documentation site.
pub mod themes { pub mod themes {
/// The "light" theme, selected by default when no setting is available. Used as the basis for /// The "light" theme, selected by default when no setting is available. Used as the basis for
/// the `--check-theme` functionality. /// the `--check-theme` functionality.
pub static LIGHT: &'static str = include_str!("static/themes/light.css"); pub static LIGHT: &str = include_str!("static/themes/light.css");
/// The "dark" theme. /// The "dark" theme.
pub static DARK: &'static str = include_str!("static/themes/dark.css"); pub static DARK: &str = include_str!("static/themes/dark.css");
} }
/// Files related to the Fira Sans font. /// Files related to the Fira Sans font.
pub mod fira_sans { pub mod fira_sans {
/// The file `FiraSans-Regular.woff`, the Regular variant of the Fira Sans font. /// The file `FiraSans-Regular.woff`, the Regular variant of the Fira Sans font.
pub static REGULAR: &'static [u8] = include_bytes!("static/FiraSans-Regular.woff"); pub static REGULAR: &[u8] = include_bytes!("static/FiraSans-Regular.woff");
/// The file `FiraSans-Medium.woff`, the Medium variant of the Fira Sans font. /// The file `FiraSans-Medium.woff`, the Medium variant of the Fira Sans font.
pub static MEDIUM: &'static [u8] = include_bytes!("static/FiraSans-Medium.woff"); pub static MEDIUM: &[u8] = include_bytes!("static/FiraSans-Medium.woff");
/// The file `FiraSans-LICENSE.txt`, the license text for the Fira Sans font. /// The file `FiraSans-LICENSE.txt`, the license text for the Fira Sans font.
pub static LICENSE: &'static [u8] = include_bytes!("static/FiraSans-LICENSE.txt"); pub static LICENSE: &[u8] = include_bytes!("static/FiraSans-LICENSE.txt");
} }
/// Files related to the Source Serif Pro font. /// Files related to the Source Serif Pro font.
pub mod source_serif_pro { pub mod source_serif_pro {
/// The file `SourceSerifPro-Regular.ttf.woff`, the Regular variant of the Source Serif Pro /// The file `SourceSerifPro-Regular.ttf.woff`, the Regular variant of the Source Serif Pro
/// font. /// font.
pub static REGULAR: &'static [u8] = include_bytes!("static/SourceSerifPro-Regular.ttf.woff"); pub static REGULAR: &[u8] = include_bytes!("static/SourceSerifPro-Regular.ttf.woff");
/// The file `SourceSerifPro-Bold.ttf.woff`, the Bold variant of the Source Serif Pro font. /// The file `SourceSerifPro-Bold.ttf.woff`, the Bold variant of the Source Serif Pro font.
pub static BOLD: &'static [u8] = include_bytes!("static/SourceSerifPro-Bold.ttf.woff"); pub static BOLD: &[u8] = include_bytes!("static/SourceSerifPro-Bold.ttf.woff");
/// The file `SourceSerifPro-It.ttf.woff`, the Italic variant of the Source Serif Pro font. /// The file `SourceSerifPro-It.ttf.woff`, the Italic variant of the Source Serif Pro font.
pub static ITALIC: &'static [u8] = include_bytes!("static/SourceSerifPro-It.ttf.woff"); pub static ITALIC: &[u8] = include_bytes!("static/SourceSerifPro-It.ttf.woff");
/// The file `SourceSerifPro-LICENSE.txt`, the license text for the Source Serif Pro font. /// The file `SourceSerifPro-LICENSE.txt`, the license text for the Source Serif Pro font.
pub static LICENSE: &'static [u8] = include_bytes!("static/SourceSerifPro-LICENSE.md"); pub static LICENSE: &[u8] = include_bytes!("static/SourceSerifPro-LICENSE.md");
} }
/// Files related to the Source Code Pro font. /// Files related to the Source Code Pro font.
pub mod source_code_pro { pub mod source_code_pro {
/// The file `SourceCodePro-Regular.woff`, the Regular variant of the Source Code Pro font. /// The file `SourceCodePro-Regular.woff`, the Regular variant of the Source Code Pro font.
pub static REGULAR: &'static [u8] = include_bytes!("static/SourceCodePro-Regular.woff"); pub static REGULAR: &[u8] = include_bytes!("static/SourceCodePro-Regular.woff");
/// The file `SourceCodePro-Semibold.woff`, the Semibold variant of the Source Code Pro font. /// The file `SourceCodePro-Semibold.woff`, the Semibold variant of the Source Code Pro font.
pub static SEMIBOLD: &'static [u8] = include_bytes!("static/SourceCodePro-Semibold.woff"); pub static SEMIBOLD: &[u8] = include_bytes!("static/SourceCodePro-Semibold.woff");
/// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font. /// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font.
pub static LICENSE: &'static [u8] = include_bytes!("static/SourceCodePro-LICENSE.txt"); pub static LICENSE: &[u8] = include_bytes!("static/SourceCodePro-LICENSE.txt");
} }
/// Files related to the sidebar in rustdoc sources. /// Files related to the sidebar in rustdoc sources.
pub mod sidebar { pub mod sidebar {
/// File script to handle sidebar. /// File script to handle sidebar.
pub static SOURCE_SCRIPT: &'static str = include_str!("static/source-script.js"); pub static SOURCE_SCRIPT: &str = include_str!("static/source-script.js");
} }

View file

@ -1050,6 +1050,7 @@ impl<'a> DerefMut for IoSliceMut<'a> {
/// ABI compatible with the `iovec` type on Unix platforms and `WSABUF` on /// ABI compatible with the `iovec` type on Unix platforms and `WSABUF` on
/// Windows. /// Windows.
#[stable(feature = "iovec", since = "1.36.0")] #[stable(feature = "iovec", since = "1.36.0")]
#[derive(Copy, Clone)]
#[repr(transparent)] #[repr(transparent)]
pub struct IoSlice<'a>(sys::io::IoSlice<'a>); pub struct IoSlice<'a>(sys::io::IoSlice<'a>);

View file

@ -925,9 +925,15 @@ mod mut_keyword {}
// //
/// Make an item visible to others. /// Make an item visible to others.
/// ///
/// The documentation for this keyword is [not yet complete]. Pull requests welcome! /// The keyword `pub` makes any module, function, or data structure accessible from inside
/// of external modules. The `pub` keyword may also be used in a `use` declaration to re-export
/// an identifier from a namespace.
/// ///
/// [not yet complete]: https://github.com/rust-lang/rust/issues/34601 /// For more information on the `pub` keyword, please see the visibility section
/// of the [reference] and for some examples, see [Rust by Example].
///
/// [reference]:../reference/visibility-and-privacy.html?highlight=pub#visibility-and-privacy
/// [Rust by Example]:../rust-by-example/mod/visibility.html
mod pub_keyword {} mod pub_keyword {}
#[doc(keyword = "ref")] #[doc(keyword = "ref")]

View file

@ -1,5 +1,6 @@
use crate::mem; use crate::mem;
#[derive(Copy, Clone)]
pub struct IoSlice<'a>(&'a [u8]); pub struct IoSlice<'a>(&'a [u8]);
impl<'a> IoSlice<'a> { impl<'a> IoSlice<'a> {

View file

@ -1,5 +1,6 @@
use crate::mem; use crate::mem;
#[derive(Copy, Clone)]
pub struct IoSlice<'a>(&'a [u8]); pub struct IoSlice<'a>(&'a [u8]);
impl<'a> IoSlice<'a> { impl<'a> IoSlice<'a> {

View file

@ -1,5 +1,6 @@
use crate::mem; use crate::mem;
#[derive(Copy, Clone)]
pub struct IoSlice<'a>(&'a [u8]); pub struct IoSlice<'a>(&'a [u8]);
impl<'a> IoSlice<'a> { impl<'a> IoSlice<'a> {

View file

@ -3,6 +3,7 @@ use crate::slice;
use libc::{c_void, iovec}; use libc::{c_void, iovec};
#[derive(Copy, Clone)]
#[repr(transparent)] #[repr(transparent)]
pub struct IoSlice<'a> { pub struct IoSlice<'a> {
vec: iovec, vec: iovec,

View file

@ -3,6 +3,7 @@ use crate::slice;
use libc::{c_void, iovec}; use libc::{c_void, iovec};
#[derive(Copy, Clone)]
#[repr(transparent)] #[repr(transparent)]
pub struct IoSlice<'a> { pub struct IoSlice<'a> {
vec: iovec, vec: iovec,

View file

@ -1,6 +1,7 @@
use crate::marker::PhantomData; use crate::marker::PhantomData;
use crate::slice; use crate::slice;
#[derive(Copy, Clone)]
#[repr(transparent)] #[repr(transparent)]
pub struct IoSlice<'a> { pub struct IoSlice<'a> {
vec: wasi::Ciovec, vec: wasi::Ciovec,

View file

@ -1,5 +1,6 @@
use crate::mem; use crate::mem;
#[derive(Copy, Clone)]
pub struct IoSlice<'a>(&'a [u8]); pub struct IoSlice<'a>(&'a [u8]);
impl<'a> IoSlice<'a> { impl<'a> IoSlice<'a> {

View file

@ -295,6 +295,7 @@ pub struct WSADATA {
pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1], pub szSystemStatus: [u8; WSASYS_STATUS_LEN + 1],
} }
#[derive(Copy, Clone)]
#[repr(C)] #[repr(C)]
pub struct WSABUF { pub struct WSABUF {
pub len: ULONG, pub len: ULONG,

View file

@ -2,6 +2,7 @@ use crate::marker::PhantomData;
use crate::slice; use crate::slice;
use crate::sys::c; use crate::sys::c;
#[derive(Copy, Clone)]
#[repr(transparent)] #[repr(transparent)]
pub struct IoSlice<'a> { pub struct IoSlice<'a> {
vec: c::WSABUF, vec: c::WSABUF,

View file

@ -70,7 +70,7 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::
let mut print_path = move |fmt: &mut fmt::Formatter<'_>, bows: BytesOrWideString<'_>| { let mut print_path = move |fmt: &mut fmt::Formatter<'_>, bows: BytesOrWideString<'_>| {
output_filename(fmt, bows, print_fmt, cwd.as_ref()) output_filename(fmt, bows, print_fmt, cwd.as_ref())
}; };
write!(fmt, "stack backtrace:\n")?; writeln!(fmt, "stack backtrace:")?;
let mut bt_fmt = BacktraceFmt::new(fmt, print_fmt, &mut print_path); let mut bt_fmt = BacktraceFmt::new(fmt, print_fmt, &mut print_path);
bt_fmt.add_context()?; bt_fmt.add_context()?;
let mut idx = 0; let mut idx = 0;

View file

@ -47,7 +47,7 @@ impl CommandEnv {
} }
} }
for (key, maybe_val) in self.vars.iter() { for (key, maybe_val) in self.vars.iter() {
if let &Some(ref val) = maybe_val { if let Some(ref val) = maybe_val {
env::set_var(key, val); env::set_var(key, val);
} else { } else {
env::remove_var(key); env::remove_var(key);

View file

@ -603,8 +603,8 @@ impl Wtf8 {
if len < 3 { if len < 3 {
return None; return None;
} }
match &self.bytes[(len - 3)..] { match self.bytes[(len - 3)..] {
&[0xED, b2 @ 0xA0..=0xAF, b3] => Some(decode_surrogate(b2, b3)), [0xED, b2 @ 0xA0..=0xAF, b3] => Some(decode_surrogate(b2, b3)),
_ => None, _ => None,
} }
} }
@ -615,8 +615,8 @@ impl Wtf8 {
if len < 3 { if len < 3 {
return None; return None;
} }
match &self.bytes[..3] { match self.bytes[..3] {
&[0xED, b2 @ 0xB0..=0xBF, b3] => Some(decode_surrogate(b2, b3)), [0xED, b2 @ 0xB0..=0xBF, b3] => Some(decode_surrogate(b2, b3)),
_ => None, _ => None,
} }
} }

View file

@ -169,7 +169,7 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Res
if !quiet { if !quiet {
if ntest != 0 || nbench != 0 { if ntest != 0 || nbench != 0 {
writeln!(output, "")?; writeln!(output)?;
} }
writeln!(output, "{}, {}", plural(ntest, "test"), plural(nbench, "benchmark"))?; writeln!(output, "{}, {}", plural(ntest, "test"), plural(nbench, "benchmark"))?;

View file

@ -36,5 +36,5 @@ pub(crate) fn write_stderr_delimiter(test_output: &mut Vec<u8>, test_name: &Test
Some(_) => test_output.push(b'\n'), Some(_) => test_output.push(b'\n'),
None => (), None => (),
} }
write!(test_output, "---- {} stderr ----\n", test_name).unwrap(); writeln!(test_output, "---- {} stderr ----", test_name).unwrap();
} }

View file

@ -204,7 +204,7 @@ impl Stats for [f64] {
} }
fn median(&self) -> f64 { fn median(&self) -> f64 {
self.percentile(50 as f64) self.percentile(50_f64)
} }
fn var(&self) -> f64 { fn var(&self) -> f64 {
@ -230,7 +230,7 @@ impl Stats for [f64] {
} }
fn std_dev_pct(&self) -> f64 { fn std_dev_pct(&self) -> f64 {
let hundred = 100 as f64; let hundred = 100_f64;
(self.std_dev() / self.mean()) * hundred (self.std_dev() / self.mean()) * hundred
} }
@ -244,7 +244,7 @@ impl Stats for [f64] {
} }
fn median_abs_dev_pct(&self) -> f64 { fn median_abs_dev_pct(&self) -> f64 {
let hundred = 100 as f64; let hundred = 100_f64;
(self.median_abs_dev() / self.median()) * hundred (self.median_abs_dev() / self.median()) * hundred
} }
@ -257,11 +257,11 @@ impl Stats for [f64] {
fn quartiles(&self) -> (f64, f64, f64) { fn quartiles(&self) -> (f64, f64, f64) {
let mut tmp = self.to_vec(); let mut tmp = self.to_vec();
local_sort(&mut tmp); local_sort(&mut tmp);
let first = 25f64; let first = 25_f64;
let a = percentile_of_sorted(&tmp, first); let a = percentile_of_sorted(&tmp, first);
let second = 50f64; let second = 50_f64;
let b = percentile_of_sorted(&tmp, second); let b = percentile_of_sorted(&tmp, second);
let third = 75f64; let third = 75_f64;
let c = percentile_of_sorted(&tmp, third); let c = percentile_of_sorted(&tmp, third);
(a, b, c) (a, b, c)
} }
@ -281,7 +281,7 @@ fn percentile_of_sorted(sorted_samples: &[f64], pct: f64) -> f64 {
} }
let zero: f64 = 0.0; let zero: f64 = 0.0;
assert!(zero <= pct); assert!(zero <= pct);
let hundred = 100f64; let hundred = 100_f64;
assert!(pct <= hundred); assert!(pct <= hundred);
if pct == hundred { if pct == hundred {
return sorted_samples[sorted_samples.len() - 1]; return sorted_samples[sorted_samples.len() - 1];
@ -307,7 +307,7 @@ pub fn winsorize(samples: &mut [f64], pct: f64) {
let mut tmp = samples.to_vec(); let mut tmp = samples.to_vec();
local_sort(&mut tmp); local_sort(&mut tmp);
let lo = percentile_of_sorted(&tmp, pct); let lo = percentile_of_sorted(&tmp, pct);
let hundred = 100 as f64; let hundred = 100_f64;
let hi = percentile_of_sorted(&tmp, hundred - pct); let hi = percentile_of_sorted(&tmp, hundred - pct);
for samp in samples { for samp in samples {
if *samp > hi { if *samp > hi {

View file

@ -59,10 +59,10 @@ impl TestName {
} }
pub fn with_padding(&self, padding: NamePadding) -> TestName { pub fn with_padding(&self, padding: NamePadding) -> TestName {
let name = match self { let name = match *self {
&TestName::StaticTestName(name) => Cow::Borrowed(name), TestName::StaticTestName(name) => Cow::Borrowed(name),
&TestName::DynTestName(ref name) => Cow::Owned(name.clone()), TestName::DynTestName(ref name) => Cow::Owned(name.clone()),
&TestName::AlignedTestName(ref name, _) => name.clone(), TestName::AlignedTestName(ref name, _) => name.clone(),
}; };
TestName::AlignedTestName(name, padding) TestName::AlignedTestName(name, padding)

View file

@ -0,0 +1,10 @@
// build-fail
// ignore-emscripten no asm! support
// Regression test for #69092
#![feature(asm)]
fn main() {
unsafe { asm!(".ascii \"Xen\0\""); }
//~^ ERROR: <inline asm>:1:9: error: expected string in '.ascii' directive
}

View file

@ -0,0 +1,11 @@
error: <inline asm>:1:9: error: expected string in '.ascii' directive
.ascii "Xen
^
--> $DIR/issue-69092.rs:8:14
|
LL | unsafe { asm!(".ascii \"Xen\0\""); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,25 @@
// Regression test for #62504
#![feature(const_generics)]
#![allow(incomplete_features)]
trait HasSize {
const SIZE: usize;
}
impl<const X: usize> HasSize for ArrayHolder<{ X }> {
const SIZE: usize = X;
}
struct ArrayHolder<const X: usize>([u32; X]);
impl<const X: usize> ArrayHolder<{ X }> {
pub const fn new() -> Self {
ArrayHolder([0; Self::SIZE])
//~^ ERROR: array lengths can't depend on generic parameters
}
}
fn main() {
let mut array = ArrayHolder::new();
}

View file

@ -0,0 +1,8 @@
error: array lengths can't depend on generic parameters
--> $DIR/issue-62504.rs:18:25
|
LL | ArrayHolder([0; Self::SIZE])
| ^^^^^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,18 @@
// Regression test for #67739
#![allow(incomplete_features)]
#![feature(const_generics)]
use std::mem;
pub trait Trait {
type Associated: Sized;
fn associated_size(&self) -> usize {
[0u8; mem::size_of::<Self::Associated>()];
//~^ ERROR: array lengths can't depend on generic parameters
0
}
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: array lengths can't depend on generic parameters
--> $DIR/issue-67739.rs:12:15
|
LL | [0u8; mem::size_of::<Self::Associated>()];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
pub trait Foo { pub trait Foo {
fn foo(self) -> u32; fn foo(self) -> u32;

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
fn main() { fn main() {
const MIN: i8 = -5; const MIN: i8 = -5;

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
enum Foo { enum Foo {
A = 5, A = 5,

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
#![feature(const_fn, rustc_attrs)] #![feature(const_fn, rustc_attrs)]

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
use std::time::Duration; use std::time::Duration;

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
#![feature(extern_types)] #![feature(extern_types)]

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
pub trait Nullable { pub trait Nullable {
const NULL: Self; const NULL: Self;

View file

@ -1,4 +1,7 @@
// build-pass (FIXME(62277): could be check-pass?) // Regression test for #50356: Compiler panic when using repr(packed)
// associated constant in a match arm
// check-pass
#[derive(Copy, Clone, PartialEq, Eq)] #[derive(Copy, Clone, PartialEq, Eq)]
#[repr(packed)] #[repr(packed)]
pub struct Num(u64); pub struct Num(u64);

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
struct S(pub &'static u32, pub u32); struct S(pub &'static u32, pub u32);

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
pub struct Stats; pub struct Stats;

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
// https://github.com/rust-lang/rust/issues/51300 // https://github.com/rust-lang/rust/issues/51300
#[derive(PartialEq, Eq, Clone, Copy)] #[derive(PartialEq, Eq, Clone, Copy)]

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
macro_rules! m { macro_rules! m {
() => {{ () => {{

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
pub const STATIC_TRAIT: &dyn Test = &(); pub const STATIC_TRAIT: &dyn Test = &();

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
// Test that we can handle newtypes wrapping extern types // Test that we can handle newtypes wrapping extern types

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
// if `X` were used instead of `x`, `X - 10` would result in a lint. // if `X` were used instead of `x`, `X - 10` would result in a lint.
// This file should never produce a lint, no matter how the const // This file should never produce a lint, no matter how the const

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
pub fn main() { pub fn main() {
let y: &'static mut [u8; 0] = &mut []; let y: &'static mut [u8; 0] = &mut [];

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
#![warn(const_err)] #![warn(const_err)]
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
#![warn(const_err)] #![warn(const_err)]
pub const Z: u32 = 0 - 1; pub const Z: u32 = 0 - 1;

View file

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?) // check-pass
const PARSE_BOOL: Option<&'static str> = None; const PARSE_BOOL: Option<&'static str> = None;
static FOO: (Option<&str>, u32) = (PARSE_BOOL, 42); static FOO: (Option<&str>, u32) = (PARSE_BOOL, 42);

Some files were not shown because too many files have changed in this diff Show more