Auto merge of #151490 - JonathanBrouwer:rollup-ovStnQE, r=JonathanBrouwer

Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#151001 (rustdoc: render doc(hidden) as a code attribute)
 - rust-lang/rust#151042 (fix fallback impl for select_unpredictable intrinsic)
 - rust-lang/rust#151220 (option: Use Option::map in Option::cloned)
 - rust-lang/rust#151260 (Handle unevaluated ConstKind in in_operand)
 - rust-lang/rust#151296 (MGCA: Fix incorrect pretty printing of valtree arrays)
 - rust-lang/rust#151423 (Move assert_matches to planned stable path)
 - rust-lang/rust#151441 (Fix ICE: Don't try to evaluate type_consts when eagerly collecting items)
 - rust-lang/rust#151465 (codegen: clarify some variable names around function calls)
 - rust-lang/rust#151468 (fix `f16` doctest FIXMEs)
 - rust-lang/rust#151469 (llvm: Tolerate dead_on_return attribute changes)
 - rust-lang/rust#151476 (Avoid `-> ()` in derived functions.)

r? @ghost
This commit is contained in:
bors 2026-01-22 14:53:11 +00:00
commit 0f145634fc
55 changed files with 388 additions and 246 deletions

View file

@ -986,16 +986,6 @@ impl<'a> MethodDef<'a> {
f(cx, span, &substructure)
}
fn get_ret_ty(
&self,
cx: &ExtCtxt<'_>,
trait_: &TraitDef<'_>,
generics: &Generics,
type_ident: Ident,
) -> Box<ast::Ty> {
self.ret_ty.to_ty(cx, trait_.span, type_ident, generics)
}
fn is_static(&self) -> bool {
!self.explicit_self
}
@ -1068,10 +1058,14 @@ impl<'a> MethodDef<'a> {
self_arg.into_iter().chain(nonself_args).collect()
};
let ret_type = self.get_ret_ty(cx, trait_, generics, type_ident);
let ret_type = if let Ty::Unit = &self.ret_ty {
ast::FnRetTy::Default(span)
} else {
ast::FnRetTy::Ty(self.ret_ty.to_ty(cx, span, type_ident, generics))
};
let method_ident = Ident::new(self.name, span);
let fn_decl = cx.fn_decl(args, ast::FnRetTy::Ty(ret_type));
let fn_decl = cx.fn_decl(args, ret_type);
let body_block = body.into_block(cx, span);
let trait_lo_sp = span.shrink_to_lo();

View file

@ -1397,12 +1397,12 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
fn call(
&mut self,
llty: &'ll Type,
fn_call_attrs: Option<&CodegenFnAttrs>,
caller_attrs: Option<&CodegenFnAttrs>,
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
llfn: &'ll Value,
args: &[&'ll Value],
funclet: Option<&Funclet<'ll>>,
instance: Option<Instance<'tcx>>,
callee_instance: Option<Instance<'tcx>>,
) -> &'ll Value {
debug!("call {:?} with args ({:?})", llfn, args);
@ -1414,10 +1414,10 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
}
// Emit CFI pointer type membership test
self.cfi_type_test(fn_call_attrs, fn_abi, instance, llfn);
self.cfi_type_test(caller_attrs, fn_abi, callee_instance, llfn);
// Emit KCFI operand bundle
let kcfi_bundle = self.kcfi_operand_bundle(fn_call_attrs, fn_abi, instance, llfn);
let kcfi_bundle = self.kcfi_operand_bundle(caller_attrs, fn_abi, callee_instance, llfn);
if let Some(kcfi_bundle) = kcfi_bundle.as_ref().map(|b| b.as_ref()) {
bundles.push(kcfi_bundle);
}
@ -1435,17 +1435,17 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
)
};
if let Some(instance) = instance {
if let Some(callee_instance) = callee_instance {
// Attributes on the function definition being called
let fn_defn_attrs = self.cx.tcx.codegen_fn_attrs(instance.def_id());
if let Some(fn_call_attrs) = fn_call_attrs
let callee_attrs = self.cx.tcx.codegen_fn_attrs(callee_instance.def_id());
if let Some(caller_attrs) = caller_attrs
// If there is an inline attribute and a target feature that matches
// we will add the attribute to the callsite otherwise we'll omit
// this and not add the attribute to prevent soundness issues.
&& let Some(inlining_rule) = attributes::inline_attr(&self.cx, self.cx.tcx, instance)
&& let Some(inlining_rule) = attributes::inline_attr(&self.cx, self.cx.tcx, callee_instance)
&& self.cx.tcx.is_target_feature_call_safe(
&fn_defn_attrs.target_features,
&fn_call_attrs.target_features.iter().cloned().chain(
&callee_attrs.target_features,
&caller_attrs.target_features.iter().cloned().chain(
self.cx.tcx.sess.target_features.iter().map(|feat| TargetFeature {
name: *feat,
kind: TargetFeatureKind::Implied,
@ -1470,14 +1470,15 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
fn tail_call(
&mut self,
llty: Self::Type,
fn_attrs: Option<&CodegenFnAttrs>,
caller_attrs: Option<&CodegenFnAttrs>,
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
llfn: Self::Value,
args: &[Self::Value],
funclet: Option<&Self::Funclet>,
instance: Option<Instance<'tcx>>,
callee_instance: Option<Instance<'tcx>>,
) {
let call = self.call(llty, fn_attrs, Some(fn_abi), llfn, args, funclet, instance);
let call =
self.call(llty, caller_attrs, Some(fn_abi), llfn, args, funclet, callee_instance);
llvm::LLVMSetTailCallKind(call, llvm::TailCallKind::MustTail);
match &fn_abi.ret.mode {

View file

@ -199,12 +199,12 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
// do an invoke, otherwise do a call.
let fn_ty = bx.fn_decl_backend_type(fn_abi);
let fn_attrs = if bx.tcx().def_kind(fx.instance.def_id()).has_codegen_attrs() {
let caller_attrs = if bx.tcx().def_kind(fx.instance.def_id()).has_codegen_attrs() {
Some(bx.tcx().codegen_instance_attrs(fx.instance.def))
} else {
None
};
let fn_attrs = fn_attrs.as_deref();
let caller_attrs = caller_attrs.as_deref();
if !fn_abi.can_unwind {
unwind = mir::UnwindAction::Unreachable;
@ -233,7 +233,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
};
if kind == CallKind::Tail {
bx.tail_call(fn_ty, fn_attrs, fn_abi, fn_ptr, llargs, self.funclet(fx), instance);
bx.tail_call(fn_ty, caller_attrs, fn_abi, fn_ptr, llargs, self.funclet(fx), instance);
return MergingSucc::False;
}
@ -245,7 +245,7 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
};
let invokeret = bx.invoke(
fn_ty,
fn_attrs,
caller_attrs,
Some(fn_abi),
fn_ptr,
llargs,
@ -268,8 +268,15 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
}
MergingSucc::False
} else {
let llret =
bx.call(fn_ty, fn_attrs, Some(fn_abi), fn_ptr, llargs, self.funclet(fx), instance);
let llret = bx.call(
fn_ty,
caller_attrs,
Some(fn_abi),
fn_ptr,
llargs,
self.funclet(fx),
instance,
);
if fx.mir[self.bb].is_cleanup {
bx.apply_attrs_to_cleanup_callsite(llret);
}

View file

@ -600,10 +600,13 @@ pub trait BuilderMethods<'a, 'tcx>:
///
/// ## Arguments
///
/// The `fn_attrs`, `fn_abi`, and `instance` arguments are Options because they are advisory.
/// They relate to optional codegen enhancements like LLVM CFI, and do not affect ABI per se.
/// Any ABI-related transformations should be handled by different, earlier stages of codegen.
/// For instance, in the caller of `BuilderMethods::call`.
/// `caller_attrs` are the attributes of the surrounding caller; they have nothing to do with
/// the callee.
///
/// The `caller_attrs`, `fn_abi`, and `callee_instance` arguments are Options because they are
/// advisory. They relate to optional codegen enhancements like LLVM CFI, and do not affect ABI
/// per se. Any ABI-related transformations should be handled by different, earlier stages of
/// codegen. For instance, in the caller of `BuilderMethods::call`.
///
/// This means that a codegen backend which disregards `fn_attrs`, `fn_abi`, and `instance`
/// should still do correct codegen, and code should not be miscompiled if they are omitted.
@ -620,23 +623,23 @@ pub trait BuilderMethods<'a, 'tcx>:
fn call(
&mut self,
llty: Self::Type,
fn_attrs: Option<&CodegenFnAttrs>,
caller_attrs: Option<&CodegenFnAttrs>,
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
fn_val: Self::Value,
args: &[Self::Value],
funclet: Option<&Self::Funclet>,
instance: Option<Instance<'tcx>>,
callee_instance: Option<Instance<'tcx>>,
) -> Self::Value;
fn tail_call(
&mut self,
llty: Self::Type,
fn_attrs: Option<&CodegenFnAttrs>,
caller_attrs: Option<&CodegenFnAttrs>,
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
llfn: Self::Value,
args: &[Self::Value],
funclet: Option<&Self::Funclet>,
instance: Option<Instance<'tcx>>,
callee_instance: Option<Instance<'tcx>>,
);
fn zext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;

View file

@ -343,17 +343,18 @@ where
// Check the qualifs of the value of `const` items.
let uneval = match constant.const_ {
Const::Ty(_, ct)
if matches!(
ct.kind(),
ty::ConstKind::Param(_) | ty::ConstKind::Error(_) | ty::ConstKind::Value(_)
) =>
{
None
}
Const::Ty(_, c) => {
bug!("expected ConstKind::Param or ConstKind::Value here, found {:?}", c)
}
Const::Ty(_, ct) => match ct.kind() {
ty::ConstKind::Param(_) | ty::ConstKind::Error(_) => None,
// Unevaluated consts in MIR bodies don't have associated MIR (e.g. `#[type_const]`).
ty::ConstKind::Unevaluated(_) => None,
// FIXME(mgca): Investigate whether using `None` for `ConstKind::Value` is overly
// strict, and if instead we should be doing some kind of value-based analysis.
ty::ConstKind::Value(_) => None,
_ => bug!(
"expected ConstKind::Param, ConstKind::Value, ConstKind::Unevaluated, or ConstKind::Error here, found {:?}",
ct
),
},
Const::Unevaluated(uv, _) => Some(uv),
Const::Val(..) => None,
};
@ -364,10 +365,8 @@ where
// check performed after the promotion. Verify that with an assertion.
assert!(promoted.is_none() || Q::ALLOW_PROMOTED);
// Don't peak inside trait associated constants, also `#[type_const] const` items
// don't have bodies so there's nothing to look at
if promoted.is_none() && cx.tcx.trait_of_assoc(def).is_none() && !cx.tcx.is_type_const(def)
{
// Don't peak inside trait associated constants.
if promoted.is_none() && cx.tcx.trait_of_assoc(def).is_none() {
let qualifs = cx.tcx.at(constant.span).mir_const_qualif(def);
if !Q::in_qualifs(&qualifs) {

View file

@ -41,8 +41,11 @@
// have to worry about it being moved to a different module in std during stabilization.
// FIXME(#151359): Remove this when `feature(assert_matches)` is stable in stage0.
// (This doesn't necessarily need to be fixed during the beta bump itself.)
#[cfg(bootstrap)]
pub use std::assert_matches::{assert_matches, debug_assert_matches};
use std::fmt;
#[cfg(not(bootstrap))]
pub use std::{assert_matches, debug_assert_matches};
pub use atomic_ref::AtomicRef;
pub use ena::{snapshot_vec, undo_log, unify};

View file

@ -527,6 +527,12 @@ LLVMRustCreateAttrNoValue(LLVMContextRef C, LLVMRustAttributeKind RustAttr) {
*unwrap(C), CaptureInfo(CaptureComponents::Address |
CaptureComponents::ReadProvenance)));
}
#endif
#if LLVM_VERSION_GE(23, 0)
if (RustAttr == LLVMRustAttributeKind::DeadOnReturn) {
return wrap(Attribute::getWithDeadOnReturnInfo(*unwrap(C),
llvm::DeadOnReturnInfo()));
}
#endif
return wrap(Attribute::get(*unwrap(C), fromRust(RustAttr)));
}

View file

@ -147,7 +147,12 @@ impl<'tcx> Value<'tcx> {
_ => return None,
}
Some(tcx.arena.alloc_from_iter(self.to_branch().into_iter().map(|ct| ct.to_leaf().to_u8())))
// We create an iterator that yields `Option<u8>`
let iterator = self.to_branch().into_iter().map(|ct| Some(ct.try_to_leaf()?.to_u8()));
// If there is `None` in the iterator, then the array is not a valid array of u8s and we return `None`
let bytes: Vec<u8> = iterator.collect::<Option<Vec<u8>>>()?;
Some(tcx.arena.alloc_from_iter(bytes))
}
/// Converts to a `ValTreeKind::Leaf` value, `panic`'ing

View file

@ -1911,14 +1911,16 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
return Ok(());
}
},
(ty::ValTreeKind::Branch(_), ty::Array(t, _)) if t == u8_type => {
let bytes = cv.try_to_raw_bytes(self.tcx()).unwrap_or_else(|| {
bug!("expected to convert valtree to raw bytes for type {:?}", t)
});
// If it is a branch with an array, and this array can be printed as raw bytes, then dump its bytes
(ty::ValTreeKind::Branch(_), ty::Array(t, _))
if t == u8_type
&& let Some(bytes) = cv.try_to_raw_bytes(self.tcx()) =>
{
write!(self, "*")?;
self.pretty_print_byte_str(bytes)?;
return Ok(());
}
// Otherwise, print the array separated by commas (or if it's a tuple)
(ty::ValTreeKind::Branch(fields), ty::Array(..) | ty::Tuple(..)) => {
let fields_iter = fields.iter().copied();

View file

@ -1563,11 +1563,22 @@ impl<'v> RootCollector<'_, 'v> {
// If we're collecting items eagerly, then recurse into all constants.
// Otherwise the value is only collected when explicitly mentioned in other items.
if self.strategy == MonoItemCollectionStrategy::Eager {
if !self.tcx.generics_of(id.owner_id).own_requires_monomorphization()
&& let Ok(val) = self.tcx.const_eval_poly(id.owner_id.to_def_id())
{
collect_const_value(self.tcx, val, self.output);
let def_id = id.owner_id.to_def_id();
// Type Consts don't have bodies to evaluate
// nor do they make sense as a static.
if self.tcx.is_type_const(def_id) {
// FIXME(mgca): Is this actually what we want? We may want to
// normalize to a ValTree then convert to a const allocation and
// collect that?
return;
}
if self.tcx.generics_of(id.owner_id).own_requires_monomorphization() {
return;
}
let Ok(val) = self.tcx.const_eval_poly(def_id) else {
return;
};
collect_const_value(self.tcx, val, self.output);
}
}
DefKind::Impl { of_trait: true } => {

View file

@ -1,4 +1,4 @@
use core::assert_matches::assert_matches;
use core::assert_matches;
use std::iter;
use std::ops::Bound::{Excluded, Included, Unbounded};
use std::panic::{AssertUnwindSafe, catch_unwind};

View file

@ -1,7 +1,7 @@
use alloc::ffi::CString;
use alloc::rc::Rc;
use alloc::sync::Arc;
use core::assert_matches::assert_matches;
use core::assert_matches;
use core::ffi::{CStr, FromBytesUntilNulError, c_char};
#[allow(deprecated)]
use core::hash::SipHasher13 as DefaultHasher;

View file

@ -1,6 +1,6 @@
#![allow(invalid_from_utf8)]
use std::assert_matches::assert_matches;
use std::assert_matches;
use std::borrow::Cow;
use std::cmp::Ordering::{Equal, Greater, Less};
use std::str::{from_utf8, from_utf8_unchecked};

View file

@ -1,10 +1,9 @@
use std::assert_matches::assert_matches;
use std::borrow::Cow;
use std::cell::Cell;
use std::collections::TryReserveErrorKind::*;
use std::ops::Bound::*;
use std::ops::{Bound, RangeBounds};
use std::{panic, str};
use std::{assert_matches, panic, str};
pub trait IntoCow<'a, B: ?Sized>
where

View file

@ -3,12 +3,10 @@ use core::num::NonZero;
use core::ptr::NonNull;
use core::{assert_eq, assert_ne};
use std::alloc::System;
use std::assert_matches::assert_matches;
use std::borrow::Cow;
use std::cell::Cell;
use std::collections::TryReserveErrorKind::*;
use std::fmt::Debug;
use std::hint;
use std::iter::InPlaceIterable;
use std::mem::swap;
use std::ops::Bound::*;
@ -16,6 +14,7 @@ use std::panic::{AssertUnwindSafe, catch_unwind};
use std::rc::Rc;
use std::sync::atomic::{AtomicU32, Ordering};
use std::vec::{Drain, IntoIter, PeekMut};
use std::{assert_matches, hint};
use crate::testing::macros::struct_with_counted_drop;

View file

@ -1,6 +1,6 @@
use core::cell::Cell;
use core::num::NonZero;
use std::assert_matches::assert_matches;
use std::assert_matches;
use std::collections::TryReserveErrorKind::*;
use std::collections::VecDeque;
use std::collections::vec_deque::Drain;

View file

@ -54,7 +54,7 @@
)]
use crate::ffi::va_list::{VaArgSafe, VaList};
use crate::marker::{ConstParamTy, Destruct, DiscriminantKind, PointeeSized, Tuple};
use crate::marker::{ConstParamTy, DiscriminantKind, PointeeSized, Tuple};
use crate::{mem, ptr};
mod bounds;
@ -483,11 +483,14 @@ pub const fn unlikely(b: bool) -> bool {
#[rustc_nounwind]
#[miri::intrinsic_fallback_is_spec]
#[inline]
pub const fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T
where
T: [const] Destruct,
{
if b { true_val } else { false_val }
pub const fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T {
if b {
forget(false_val);
true_val
} else {
forget(true_val);
false_val
}
}
/// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:

View file

@ -223,11 +223,7 @@ use prelude::rust_2024::*;
mod macros;
#[unstable(feature = "assert_matches", issue = "82775")]
/// Unstable module containing the unstable `assert_matches` macro.
pub mod assert_matches {
#[unstable(feature = "assert_matches", issue = "82775")]
pub use crate::macros::{assert_matches, debug_assert_matches};
}
pub use crate::macros::{assert_matches, debug_assert_matches};
#[unstable(feature = "derive_from", issue = "144889")]
/// Unstable module containing the unstable `From` derive macro.

View file

@ -124,6 +124,8 @@ macro_rules! assert_ne {
};
}
// FIXME add back debug_assert_matches doc link after bootstrap.
/// Asserts that an expression matches the provided pattern.
///
/// This macro is generally preferable to `assert!(matches!(value, pattern))`, because it can print
@ -135,11 +137,9 @@ macro_rules! assert_ne {
/// otherwise this macro will panic.
///
/// Assertions are always checked in both debug and release builds, and cannot
/// be disabled. See [`debug_assert_matches!`] for assertions that are disabled in
/// be disabled. See `debug_assert_matches!` for assertions that are disabled in
/// release builds by default.
///
/// [`debug_assert_matches!`]: crate::assert_matches::debug_assert_matches
///
/// On panic, this macro will print the value of the expression with its debug representation.
///
/// Like [`assert!`], this macro has a second form, where a custom panic message can be provided.
@ -149,7 +149,7 @@ macro_rules! assert_ne {
/// ```
/// #![feature(assert_matches)]
///
/// use std::assert_matches::assert_matches;
/// use std::assert_matches;
///
/// let a = Some(345);
/// let b = Some(56);
@ -382,7 +382,7 @@ macro_rules! debug_assert_ne {
/// ```
/// #![feature(assert_matches)]
///
/// use std::assert_matches::debug_assert_matches;
/// use std::debug_assert_matches;
///
/// let a = Some(345);
/// let b = Some(56);
@ -404,7 +404,7 @@ macro_rules! debug_assert_ne {
#[rustc_macro_transparency = "semiopaque"]
pub macro debug_assert_matches($($arg:tt)*) {
if $crate::cfg!(debug_assertions) {
$crate::assert_matches::assert_matches!($($arg)*);
$crate::assert_matches!($($arg)*);
}
}

View file

@ -132,6 +132,7 @@ pub mod consts {
pub const LN_10: f16 = 2.30258509299404568401799145468436421_f16;
}
#[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), allow(internal_features))))]
impl f16 {
// FIXME(f16_f128): almost all methods in this `impl` are missing examples and a const
// implementation. Add these once we can run code on all platforms and have f16/f128 in CTFE.
@ -272,7 +273,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let nan = f16::NAN;
/// let f = 7.0_f16;
@ -294,7 +295,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let f = 7.0f16;
/// let inf = f16::INFINITY;
@ -319,7 +320,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let f = 7.0f16;
/// let inf: f16 = f16::INFINITY;
@ -347,7 +348,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let min = f16::MIN_POSITIVE; // 6.1035e-5
/// let max = f16::MAX;
@ -376,7 +377,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let min = f16::MIN_POSITIVE; // 6.1035e-5
/// let max = f16::MAX;
@ -407,7 +408,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// use std::num::FpCategory;
///
@ -443,8 +444,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # // FIXME(f16_f128): LLVM crashes on s390x, llvm/llvm-project#50374
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let f = 7.0_f16;
/// let g = -7.0_f16;
@ -472,8 +472,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # // FIXME(f16_f128): LLVM crashes on s390x, llvm/llvm-project#50374
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let f = 7.0_f16;
/// let g = -7.0_f16;
@ -507,8 +506,7 @@ impl f16 {
///
/// ```rust
/// #![feature(f16)]
/// # // FIXME(f16_f128): ABI issues on MSVC
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// // f16::EPSILON is the difference between 1.0 and the next number up.
/// assert_eq!(1.0f16.next_up(), 1.0 + f16::EPSILON);
@ -562,8 +560,7 @@ impl f16 {
///
/// ```rust
/// #![feature(f16)]
/// # // FIXME(f16_f128): ABI issues on MSVC
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let x = 1.0f16;
/// // Clamp value into range [0, 1).
@ -606,8 +603,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # // FIXME(f16_f128): extendhfsf2, truncsfhf2, __gnu_h2f_ieee, __gnu_f2h_ieee missing for many platforms
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let x = 2.0_f16;
/// let abs_difference = (x.recip() - (1.0 / x)).abs();
@ -633,8 +629,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # // FIXME(f16_f128): extendhfsf2, truncsfhf2, __gnu_h2f_ieee, __gnu_f2h_ieee missing for many platforms
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let angle = std::f16::consts::PI;
///
@ -663,8 +658,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # // FIXME(f16_f128): extendhfsf2, truncsfhf2, __gnu_h2f_ieee, __gnu_f2h_ieee missing for many platforms
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let angle = 180.0f16;
///
@ -697,7 +691,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_has_reliable_f16)] {
///
/// let x = 1.0f16;
/// let y = 2.0f16;
@ -728,7 +722,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_has_reliable_f16)] {
///
/// let x = 1.0f16;
/// let y = 2.0f16;
@ -760,7 +754,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// #![feature(float_minimum_maximum)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_has_reliable_f16)] {
///
/// let x = 1.0f16;
/// let y = 2.0f16;
@ -792,7 +786,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// #![feature(float_minimum_maximum)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_has_reliable_f16)] {
///
/// let x = 1.0f16;
/// let y = 2.0f16;
@ -818,7 +812,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_has_reliable_f16)] {
///
/// assert_eq!(1f16.midpoint(4.0), 2.5);
/// assert_eq!((-5.5f16).midpoint(8.0), 1.25);
@ -848,7 +842,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let value = 4.6_f16;
/// let rounded = unsafe { value.to_int_unchecked::<u16>() };
@ -891,7 +885,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// # // FIXME(f16_f128): enable this once const casting works
/// # // assert_ne!((1f16).to_bits(), 1f16 as u128); // to_bits() is not casting!
@ -939,7 +933,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let v = f16::from_bits(0x4a40);
/// assert_eq!(v, 12.5);
@ -965,8 +959,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # // FIXME(f16_f128): LLVM crashes on s390x, llvm/llvm-project#50374
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let bytes = 12.5f16.to_be_bytes();
/// assert_eq!(bytes, [0x4a, 0x40]);
@ -989,8 +982,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # // FIXME(f16_f128): LLVM crashes on s390x, llvm/llvm-project#50374
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let bytes = 12.5f16.to_le_bytes();
/// assert_eq!(bytes, [0x40, 0x4a]);
@ -1019,8 +1011,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # // FIXME(f16_f128): LLVM crashes on s390x, llvm/llvm-project#50374
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let bytes = 12.5f16.to_ne_bytes();
/// assert_eq!(
@ -1049,7 +1040,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let value = f16::from_be_bytes([0x4a, 0x40]);
/// assert_eq!(value, 12.5);
@ -1071,7 +1062,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let value = f16::from_le_bytes([0x40, 0x4a]);
/// assert_eq!(value, 12.5);
@ -1100,7 +1091,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let value = f16::from_ne_bytes(if cfg!(target_endian = "big") {
/// [0x4a, 0x40]
@ -1150,8 +1141,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # // FIXME(f16_f128): extendhfsf2, truncsfhf2, __gnu_h2f_ieee, __gnu_f2h_ieee missing for many platforms
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// struct GoodBoy {
/// name: &'static str,
@ -1234,7 +1224,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// assert!((-3.0f16).clamp(-2.0, 1.0) == -2.0);
/// assert!((0.0f16).clamp(-2.0, 1.0) == 0.0);
@ -1285,7 +1275,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// #![feature(clamp_magnitude)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
/// assert_eq!(5.0f16.clamp_magnitude(3.0), 3.0);
/// assert_eq!((-5.0f16).clamp_magnitude(3.0), -3.0);
/// assert_eq!(2.0f16.clamp_magnitude(3.0), 2.0);
@ -1309,7 +1299,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16_math)] {
///
/// let x = 3.5_f16;
/// let y = -3.5_f16;
@ -1325,8 +1315,7 @@ impl f16 {
#[rustc_const_unstable(feature = "f16", issue = "116909")]
#[must_use = "method returns a new number and does not mutate the original value"]
pub const fn abs(self) -> Self {
// FIXME(f16_f128): replace with `intrinsics::fabsf16` when available
Self::from_bits(self.to_bits() & !(1 << 15))
intrinsics::fabsf16(self)
}
/// Returns a number that represents the sign of `self`.
@ -1339,7 +1328,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let f = 3.5_f16;
///
@ -1375,7 +1364,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// # #[cfg(target_has_reliable_f16_math)] {
///
/// let f = 3.5_f16;
///
@ -1465,7 +1454,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let f = 3.7_f16;
/// let g = 3.0_f16;
@ -1494,7 +1483,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let f = 3.01_f16;
/// let g = 4.0_f16;
@ -1523,7 +1512,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let f = 3.3_f16;
/// let g = -3.3_f16;
@ -1557,7 +1546,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let f = 3.3_f16;
/// let g = -3.3_f16;
@ -1589,7 +1578,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let f = 3.7_f16;
/// let g = 3.0_f16;
@ -1619,7 +1608,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let x = 3.6_f16;
/// let y = -3.6_f16;
@ -1658,7 +1647,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let m = 10.0_f16;
/// let x = 4.0_f16;
@ -1703,7 +1692,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let a: f16 = 7.0;
/// let b = 4.0;
@ -1747,7 +1736,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let a: f16 = 7.0;
/// let b = 4.0;
@ -1790,7 +1779,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let x = 2.0_f16;
/// let abs_difference = (x.powi(2) - (x * x)).abs();
@ -1823,7 +1812,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let positive = 4.0_f16;
/// let negative = -4.0_f16;
@ -1858,7 +1847,7 @@ impl f16 {
/// ```
/// #![feature(f16)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// # #[cfg(target_has_reliable_f16)] {
///
/// let x = 8.0f16;
///

View file

@ -2103,10 +2103,7 @@ impl<T> Option<&T> {
where
T: Clone,
{
match self {
Some(t) => Some(t.clone()),
None => None,
}
self.map(T::clone)
}
}
@ -2154,10 +2151,7 @@ impl<T> Option<&mut T> {
where
T: Clone,
{
match self {
Some(t) => Some(t.clone()),
None => None,
}
self.as_deref().map(T::clone)
}
}

View file

@ -3,7 +3,7 @@ use realstd::collections::TryReserveErrorKind::*;
use super::Entry::{Occupied, Vacant};
use super::HashMap;
use crate::assert_matches::assert_matches;
use crate::assert_matches;
use crate::cell::RefCell;
use crate::hash::{BuildHasher, BuildHasherDefault, DefaultHasher, RandomState};
use crate::test_helpers::test_rng;

View file

@ -2,7 +2,6 @@ use rand::RngCore;
#[cfg(not(miri))]
use super::Dir;
use crate::assert_matches::assert_matches;
use crate::fs::{self, File, FileTimes, OpenOptions, TryLockError};
#[cfg(not(miri))]
use crate::io;
@ -21,7 +20,7 @@ use crate::path::Path;
use crate::sync::Arc;
use crate::test_helpers::{TempDir, tmpdir};
use crate::time::{Duration, Instant, SystemTime};
use crate::{env, str, thread};
use crate::{assert_matches, env, str, thread};
macro_rules! check {
($e:expr) => {

View file

@ -1,7 +1,6 @@
use super::{Custom, Error, ErrorData, ErrorKind, Repr, SimpleMessage, const_error};
use crate::assert_matches::assert_matches;
use crate::sys::io::{decode_error_kind, error_string};
use crate::{error, fmt};
use crate::{assert_matches, error, fmt};
#[test]
fn test_size() {

View file

@ -711,9 +711,9 @@ pub use core::todo;
// Re-export built-in macros defined through core.
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
pub use core::{
assert, assert_matches, cfg, column, compile_error, concat, const_format_args, env, file,
format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
module_path, option_env, stringify, trace_macros,
assert, cfg, column, compile_error, concat, const_format_args, env, file, format_args,
format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
stringify, trace_macros,
};
// Re-export macros defined in core.
#[stable(feature = "rust1", since = "1.0.0")]
@ -722,6 +722,8 @@ pub use core::{
assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, r#try, unimplemented,
unreachable, write, writeln,
};
#[unstable(feature = "assert_matches", issue = "82775")]
pub use core::{assert_matches, debug_assert_matches};
// Re-export unstable derive macro defined through core.
#[unstable(feature = "derive_from", issue = "144889")]

View file

@ -1,5 +1,5 @@
use super::PidFd as InternalPidFd;
use crate::assert_matches::assert_matches;
use crate::assert_matches;
use crate::os::fd::AsRawFd;
use crate::os::linux::process::{ChildExt, CommandExt as _};
use crate::os::unix::process::{CommandExt as _, ExitStatusExt};

View file

@ -524,7 +524,7 @@ impl Command {
return Ok(None);
}
}
core::assert_matches::debug_assert_matches!(support, SPAWN | NO);
core::debug_assert_matches!(support, SPAWN | NO);
}
}
_ => {

View file

@ -1,4 +1,7 @@
use std::assert_matches::debug_assert_matches;
#[cfg(bootstrap)]
pub use std::assert_matches::debug_assert_matches;
#[cfg(not(bootstrap))]
pub use std::debug_assert_matches;
use std::fmt::{self, Display, Write as _};
use std::sync::LazyLock as Lazy;
use std::{ascii, mem};

View file

@ -1390,10 +1390,6 @@ impl clean::FnDecl {
pub(crate) fn visibility_print_with_space(item: &clean::Item, cx: &Context<'_>) -> impl Display {
fmt::from_fn(move |f| {
if item.is_doc_hidden() {
f.write_str("#[doc(hidden)] ")?;
}
let Some(vis) = item.visibility(cx.tcx()) else {
return Ok(());
};

View file

@ -1075,6 +1075,7 @@ fn assoc_type(
cx: &Context<'_>,
) -> impl fmt::Display {
fmt::from_fn(move |w| {
render_attributes_in_code(w, it, &" ".repeat(indent), cx)?;
write!(
w,
"{indent}{vis}type <a{href} class=\"associatedtype\">{name}</a>{generics}",
@ -2931,6 +2932,21 @@ fn render_attributes_in_code(
prefix: &str,
cx: &Context<'_>,
) -> fmt::Result {
render_attributes_in_code_with_options(w, item, prefix, cx, true, "")
}
pub(super) fn render_attributes_in_code_with_options(
w: &mut impl fmt::Write,
item: &clean::Item,
prefix: &str,
cx: &Context<'_>,
render_doc_hidden: bool,
open_tag: &str,
) -> fmt::Result {
w.write_str(open_tag)?;
if render_doc_hidden && item.is_doc_hidden() {
render_code_attribute(prefix, "#[doc(hidden)]", w)?;
}
for attr in &item.attrs.other_attrs {
let hir::Attribute::Parsed(kind) = attr else { continue };
let attr = match kind {

View file

@ -344,15 +344,38 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
}
for (_, myitem) in &not_stripped_items[&type_] {
let visibility_and_hidden = |item: &clean::Item| match item.visibility(tcx) {
Some(ty::Visibility::Restricted(_)) => {
if item.is_doc_hidden() {
// Don't separate with a space when there are two of them
"<span title=\"Restricted Visibility\">&nbsp;🔒</span><span title=\"Hidden item\">👻</span> "
} else {
"<span title=\"Restricted Visibility\">&nbsp;🔒</span> "
}
}
_ if item.is_doc_hidden() => "<span title=\"Hidden item\">&nbsp;👻</span> ",
_ => "",
};
match myitem.kind {
clean::ExternCrateItem { ref src } => {
use crate::html::format::print_anchor;
let visibility_and_hidden = visibility_and_hidden(myitem);
// Module listings use the hidden marker, so skip doc(hidden) here.
super::render_attributes_in_code_with_options(
w,
myitem,
"",
cx,
false,
"<dt><code>",
)?;
match *src {
Some(src) => {
write!(
w,
"<dt><code>{}extern crate {} as {};",
"{}extern crate {} as {};",
visibility_print_with_space(myitem, cx),
print_anchor(myitem.item_id.expect_def_id(), src, cx),
EscapeBodyTextWithWbr(myitem.name.unwrap().as_str())
@ -361,7 +384,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
None => {
write!(
w,
"<dt><code>{}extern crate {};",
"{}extern crate {};",
visibility_print_with_space(myitem, cx),
print_anchor(
myitem.item_id.expect_def_id(),
@ -371,7 +394,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
)?;
}
}
write!(w, "</code></dt>")?
write!(w, "</code>{visibility_and_hidden}</dt>")?
}
clean::ImportItem(ref import) => {
let (stab_tags, deprecation) = match import.source.did {
@ -386,6 +409,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
}
None => (String::new(), item.is_deprecated(tcx)),
};
let visibility_and_hidden = visibility_and_hidden(myitem);
let id = match import.kind {
clean::ImportKind::Simple(s) => {
format!(" id=\"{}\"", cx.derive_id(format!("reexport.{s}")))
@ -397,13 +421,13 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
"<dt{id}{deprecation_attr}><code>",
deprecation_attr = deprecation_class_attr(deprecation)
)?;
render_attributes_in_code(w, myitem, "", cx)?;
write!(
w,
"{vis}{imp}</code>{stab_tags}\
"{vis}{imp}</code>{visibility_and_hidden}{stab_tags}\
</dt>",
vis = visibility_print_with_space(myitem, cx),
imp = print_import(import, cx),
visibility_and_hidden = visibility_and_hidden,
)?;
}
_ => {
@ -421,20 +445,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
}
_ => "",
};
let visibility_and_hidden = match myitem.visibility(tcx) {
Some(ty::Visibility::Restricted(_)) => {
if myitem.is_doc_hidden() {
// Don't separate with a space when there are two of them
"<span title=\"Restricted Visibility\">&nbsp;🔒</span><span title=\"Hidden item\">👻</span> "
} else {
"<span title=\"Restricted Visibility\">&nbsp;🔒</span> "
}
}
_ if myitem.is_doc_hidden() => {
"<span title=\"Hidden item\">&nbsp;👻</span> "
}
_ => "",
};
let visibility_and_hidden = visibility_and_hidden(myitem);
let docs = MarkdownSummaryLine(&myitem.doc_value(), &myitem.links(cx))
.into_string();
@ -1868,7 +1879,6 @@ fn item_variants(
fn item_macro(cx: &Context<'_>, it: &clean::Item, t: &clean::Macro) -> impl fmt::Display {
fmt::from_fn(|w| {
wrap_item(w, |w| {
// FIXME: Also print `#[doc(hidden)]` for `macro_rules!` if it `is_doc_hidden`.
render_attributes_in_code(w, it, "", cx)?;
if !t.macro_rules {
write!(w, "{}", visibility_print_with_space(it, cx))?;

View file

@ -29,7 +29,10 @@ use rustc_span::{DUMMY_SP, Span, Symbol, sym};
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
use rustc_trait_selection::traits::{Obligation, ObligationCause};
#[cfg(bootstrap)]
use std::assert_matches::debug_assert_matches;
#[cfg(not(bootstrap))]
use std::debug_assert_matches;
use std::collections::hash_map::Entry;
use std::{iter, mem};

View file

@ -0,0 +1,19 @@
//! Check that `select_unpredictable` properly forgets the value it does not select.
#![feature(core_intrinsics)]
use std::cell::Cell;
use std::intrinsics::select_unpredictable;
fn main() {
let (true_val, false_val) = (Cell::new(false), Cell::new(false));
_ = select_unpredictable(true, TraceDrop(&true_val), TraceDrop(&false_val));
assert!(true_val.get());
assert!(!false_val.get());
}
struct TraceDrop<'a>(&'a Cell<bool>);
impl<'a> Drop for TraceDrop<'a> {
fn drop(&mut self) {
self.0.set(true);
}
}

View file

@ -5,7 +5,7 @@
// Test for the absence of `readonly` on the argument when it is mutated via `&raw const`.
// See <https://github.com/rust-lang/rust/issues/111502>.
// CHECK: i8 @foo(ptr{{( dead_on_return)?}} noalias noundef align 1{{( captures\(address\))?}} dereferenceable(128) %x)
// CHECK: i8 @foo(ptr{{( dead_on_return)?}} noalias noundef align 1{{( captures\(address\))?}}{{( dead_on_return)?}} dereferenceable(128) %x)
#[no_mangle]
pub fn foo(x: [u8; 128]) -> u8 {
let ptr = core::ptr::addr_of!(x).cast_mut();
@ -15,7 +15,7 @@ pub fn foo(x: [u8; 128]) -> u8 {
x[0]
}
// CHECK: i1 @second(ptr{{( dead_on_return)?}} noalias noundef align {{[0-9]+}}{{( captures\(address\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b)
// CHECK: i1 @second(ptr{{( dead_on_return)?}} noalias noundef align {{[0-9]+}}{{( captures\(address\))?}}{{( dead_on_return)?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b)
#[no_mangle]
pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool {
let b_bool_ptr = core::ptr::addr_of!(a_ptr_and_b.1.1).cast_mut();
@ -24,7 +24,7 @@ pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool {
}
// If going through a deref (and there are no other mutating accesses), then `readonly` is fine.
// CHECK: i1 @third(ptr{{( dead_on_return)?}} noalias noundef readonly align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b)
// CHECK: i1 @third(ptr{{( dead_on_return)?}} noalias noundef readonly align {{[0-9]+}}{{( captures\(none\))?}}{{( dead_on_return)?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b)
#[no_mangle]
pub unsafe fn third(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool {
let b_bool_ptr = core::ptr::addr_of!((*a_ptr_and_b.0).1).cast_mut();

View file

@ -134,7 +134,7 @@ pub fn mutable_notunpin_borrow(_: &mut NotUnpin) {}
#[no_mangle]
pub fn notunpin_borrow(_: &NotUnpin) {}
// CHECK: @indirect_struct(ptr{{( dead_on_return)?}} noalias noundef readonly align 4{{( captures\(none\))?}} dereferenceable(32) %_1)
// CHECK: @indirect_struct(ptr{{( dead_on_return)?}} noalias noundef readonly align 4{{( captures\(none\))?}}{{( dead_on_return)?}} dereferenceable(32) %_1)
#[no_mangle]
pub fn indirect_struct(_: S) {}

View file

@ -256,7 +256,7 @@ pub struct IntDoubleInt {
c: i32,
}
// CHECK: define void @f_int_double_int_s_arg(ptr{{( dead_on_return)?}} noalias noundef align 8{{( captures\(address\))?}} dereferenceable(24) %a)
// CHECK: define void @f_int_double_int_s_arg(ptr{{( dead_on_return)?}} noalias noundef align 8{{( captures\(address\))?}}{{( dead_on_return)?}} dereferenceable(24) %a)
#[no_mangle]
pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {}

View file

@ -5,25 +5,32 @@
#![crate_name = "foo"]
//@ has 'foo/index.html'
//@ has - '//dt/span[@title="Hidden item"]' '👻'
//@ has - '//*[@id="reexport.hidden_reexport"]/code' '#[doc(hidden)] pub use hidden::inside_hidden as hidden_reexport;'
//@ matches - '//dt[code]' 'pub extern crate .*hidden_core;.*👻'
//@ has - '//dt/code' 'pub extern crate core as hidden_core;'
#[doc(hidden)]
pub extern crate core as hidden_core;
//@ has - '//*[@id="reexport.hidden_reexport"]/span[@title="Hidden item"]' '👻'
//@ has - '//*[@id="reexport.hidden_reexport"]/code' 'pub use hidden::inside_hidden as hidden_reexport;'
#[doc(hidden)]
pub use hidden::inside_hidden as hidden_reexport;
//@ has - '//dt/a[@class="trait"]' 'TraitHidden'
//@ has 'foo/trait.TraitHidden.html'
//@ has - '//code' '#[doc(hidden)] pub trait TraitHidden'
//@ has 'foo/trait.TraitHidden.html' '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[doc(hidden)]'
//@ has 'foo/trait.TraitHidden.html' '//*[@class="rust item-decl"]/code' 'pub trait TraitHidden'
#[doc(hidden)]
pub trait TraitHidden {}
//@ has 'foo/index.html' '//dt/a[@class="trait"]' 'Trait'
pub trait Trait {
//@ has 'foo/trait.Trait.html'
//@ has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' '#[doc(hidden)] const BAR: u32 = 0'
//@ has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]/*[@class="code-attribute"]' '#[doc(hidden)]'
#[doc(hidden)]
const BAR: u32 = 0;
//@ has - '//*[@id="method.foo"]/*[@class="code-header"]/*[@class="code-attribute"]' '#[doc(hidden)]'
//@ has - '//*[@id="method.foo"]/*[@class="code-header"]' 'fn foo()'
#[doc(hidden)]
fn foo() {}
@ -44,15 +51,16 @@ impl Struct {
}
impl Trait for Struct {
//@ has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]' '#[doc(hidden)] const BAR: u32 = 0'
//@ has - '//*[@id="method.foo"]/*[@class="code-header"]' '#[doc(hidden)] fn foo()'
//@ has - '//*[@id="associatedconstant.BAR"]/*[@class="code-header"]/*[@class="code-attribute"]' '#[doc(hidden)]'
//@ has - '//*[@id="method.foo"]/*[@class="code-header"]/*[@class="code-attribute"]' '#[doc(hidden)]'
}
//@ has - '//*[@id="impl-TraitHidden-for-Struct"]/*[@class="code-header"]' 'impl TraitHidden for Struct'
impl TraitHidden for Struct {}
//@ has 'foo/index.html' '//dt/a[@class="enum"]' 'HiddenEnum'
//@ has 'foo/enum.HiddenEnum.html'
//@ has - '//code' '#[doc(hidden)] pub enum HiddenEnum'
//@ has 'foo/enum.HiddenEnum.html' '//*[@class="rust item-decl"]//*[@class="code-attribute"]' '#[doc(hidden)]'
//@ has 'foo/enum.HiddenEnum.html' '//*[@class="rust item-decl"]/code' 'pub enum HiddenEnum'
#[doc(hidden)]
pub enum HiddenEnum {
A,
@ -60,6 +68,7 @@ pub enum HiddenEnum {
//@ has 'foo/index.html' '//dt/a[@class="enum"]' 'Enum'
pub enum Enum {
//@ has 'foo/enum.Enum.html' '//*[@id="variant.A"]/*[@class="code-header"]/*[@class="code-attribute"]' '#[doc(hidden)]'
//@ has 'foo/enum.Enum.html' '//*[@id="variant.A"]/*[@class="code-header"]' 'A'
#[doc(hidden)]
A,

View file

@ -25,7 +25,7 @@ use rustc_public::mir::mono::Instance;
use rustc_public::target::MachineInfo;
use rustc_public::ty::{AdtDef, RigidTy, Ty, TyKind};
use rustc_public::{CrateDef, CrateItem, CrateItems, ItemKind};
use std::assert_matches::assert_matches;
use std::assert_matches;
use std::collections::HashSet;
use std::convert::TryFrom;
use std::io::Write;

View file

@ -20,7 +20,7 @@ extern crate rustc_interface;
extern crate rustc_public;
use std::ascii::Char;
use std::assert_matches::assert_matches;
use std::assert_matches;
use std::cmp::{max, min};
use std::collections::HashMap;
use std::ffi::CStr;

View file

@ -19,7 +19,7 @@ use mir::{TerminatorKind::*, mono::Instance};
use rustc_public::mir::mono::InstanceKind;
use rustc_public::ty::{RigidTy, Ty, TyKind, UintTy};
use rustc_public::*;
use std::assert_matches::assert_matches;
use std::assert_matches;
use std::io::Write;
use std::ops::ControlFlow;

View file

@ -20,7 +20,7 @@ use rustc_public::{
ty::{Abi, ForeignItemKind},
*,
};
use std::assert_matches::assert_matches;
use std::assert_matches;
use std::io::Write;
use std::ops::ControlFlow;

View file

@ -24,7 +24,7 @@ use rustc_public::mir::mono::{Instance, InstanceKind};
use rustc_public::mir::visit::{Location, MirVisitor};
use rustc_public::mir::{LocalDecl, Terminator, TerminatorKind};
use rustc_public::ty::{FnDef, GenericArgs, RigidTy, TyKind};
use std::assert_matches::assert_matches;
use std::assert_matches;
use std::convert::TryFrom;
use std::io::Write;
use std::ops::ControlFlow;

View file

@ -22,7 +22,7 @@ use rustc_public::ItemKind;
use rustc_public::crate_def::CrateDef;
use rustc_public::mir::mono::Instance;
use rustc_public::ty::{RigidTy, TyKind};
use std::assert_matches::assert_matches;
use std::assert_matches;
use std::io::Write;
use std::ops::ControlFlow;

View file

@ -21,7 +21,7 @@ use rustc_public::ItemKind;
use rustc_public::crate_def::CrateDef;
use rustc_public::mir::{ProjectionElem, Rvalue, StatementKind};
use rustc_public::ty::{RigidTy, TyKind, UintTy};
use std::assert_matches::assert_matches;
use std::assert_matches;
use std::io::Write;
use std::ops::ControlFlow;

View file

@ -0,0 +1,11 @@
//@ check-pass
//@compile-flags: -Clink-dead-code=true
// link-dead-code tries to eagerly monomorphize and collect items
// This lead to collector.rs to try and evaluate a type_const
// which will fail since they do not have bodies.
#![expect(incomplete_features)]
#![feature(min_generic_const_args)]
#[type_const]
const TYPE_CONST: usize = 0;
fn main() {}

View file

@ -7,4 +7,6 @@
#[type_const]
pub const TYPE_CONST : usize = 1;
fn main() {}
fn main() {
print!("{}", TYPE_CONST)
}

View file

@ -0,0 +1,13 @@
// This test causes ERROR: mismatched types [E0308]
// and makes rustc to print array from const arguments
#![feature(min_generic_const_args, adt_const_params)]
#![allow(incomplete_features)]
struct TakesArr<const N: [u8; 1]>;
fn foo<const N: u8>() {
let _: TakesArr<{ [N] }> = TakesArr::<{ [1] }>;
//~^ ERROR: mismatched types [E0308]
}
fn main() {}

View file

@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/wrong_type_const_arr_diag.rs:9:32
|
LL | let _: TakesArr<{ [N] }> = TakesArr::<{ [1] }>;
| ----------------- ^^^^^^^^^^^^^^^^^^^ expected `[N]`, found `*b"\x01"`
| |
| expected due to this
|
= note: expected struct `TakesArr<[N]>`
found struct `TakesArr<*b"\x01">`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,21 @@
// This test causes ERROR: mismatched types [E0308]
// and makes rustc to print array from const arguments
#![feature(min_generic_const_args, adt_const_params, trivial_bounds)]
#![allow(incomplete_features)]
trait Trait {
#[type_const]
const ASSOC: u8;
}
struct TakesArr<const N: [u8; 1]>;
fn foo<const N: u8>()
where
u8: Trait
{
let _: TakesArr<{ [<u8 as Trait>::ASSOC] }> = TakesArr::<{ [1] }>;
//~^ ERROR: mismatched types [E0308]
}
fn main() {}

View file

@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/wrong_type_const_arr_diag_trait.rs:17:51
|
LL | let _: TakesArr<{ [<u8 as Trait>::ASSOC] }> = TakesArr::<{ [1] }>;
| ------------------------------------ ^^^^^^^^^^^^^^^^^^^ expected `[<u8 as Trait>::ASSOC]`, found `*b"\x01"`
| |
| expected due to this
|
= note: expected struct `TakesArr<[<u8 as Trait>::ASSOC]>`
found struct `TakesArr<*b"\x01">`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -5,7 +5,7 @@
#![feature(coroutine_trait)]
#![feature(coroutines, stmt_expr_attributes)]
#![feature(never_type)]
use std::assert_matches::assert_matches;
use std::assert_matches;
use std::ops::Coroutine;
use std::ops::CoroutineState;
use std::pin::Pin;

View file

@ -51,7 +51,7 @@ impl ::core::default::Default for Empty {
#[automatically_derived]
impl ::core::hash::Hash for Empty {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {}
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {}
}
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for Empty { }
@ -65,7 +65,7 @@ impl ::core::cmp::Eq for Empty {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {}
fn assert_receiver_is_total_eq(&self) {}
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for Empty {
@ -123,7 +123,7 @@ impl ::core::default::Default for Point {
#[automatically_derived]
impl ::core::hash::Hash for Point {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.x, state);
::core::hash::Hash::hash(&self.y, state)
}
@ -142,7 +142,7 @@ impl ::core::cmp::Eq for Point {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
@ -211,7 +211,7 @@ impl ::core::default::Default for PackedPoint {
#[automatically_derived]
impl ::core::hash::Hash for PackedPoint {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&{ self.x }, state);
::core::hash::Hash::hash(&{ self.y }, state)
}
@ -230,7 +230,7 @@ impl ::core::cmp::Eq for PackedPoint {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
@ -297,7 +297,7 @@ impl ::core::convert::From<u32> for TupleSingleField {
#[automatically_derived]
impl ::core::hash::Hash for TupleSingleField {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}
@ -313,7 +313,7 @@ impl ::core::cmp::Eq for TupleSingleField {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
@ -372,7 +372,7 @@ impl ::core::convert::From<bool> for SingleField {
#[automatically_derived]
impl ::core::hash::Hash for SingleField {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.foo, state)
}
}
@ -388,7 +388,7 @@ impl ::core::cmp::Eq for SingleField {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}
@ -465,7 +465,7 @@ impl ::core::default::Default for Big {
#[automatically_derived]
impl ::core::hash::Hash for Big {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.b1, state);
::core::hash::Hash::hash(&self.b2, state);
::core::hash::Hash::hash(&self.b3, state);
@ -493,7 +493,7 @@ impl ::core::cmp::Eq for Big {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
@ -741,7 +741,7 @@ impl ::core::convert::From<[u32]> for Unsized {
#[automatically_derived]
impl ::core::hash::Hash for Unsized {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}
@ -757,7 +757,7 @@ impl ::core::cmp::Eq for Unsized {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<[u32]>;
}
}
@ -829,7 +829,7 @@ impl<T: ::core::default::Default + Trait, U: ::core::default::Default>
impl<T: ::core::hash::Hash + Trait, U: ::core::hash::Hash> ::core::hash::Hash
for Generic<T, U> where T::A: ::core::hash::Hash {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.t, state);
::core::hash::Hash::hash(&self.ta, state);
::core::hash::Hash::hash(&self.u, state)
@ -852,7 +852,7 @@ impl<T: ::core::cmp::Eq + Trait, U: ::core::cmp::Eq> ::core::cmp::Eq for
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<T>;
let _: ::core::cmp::AssertParamIsEq<T::A>;
let _: ::core::cmp::AssertParamIsEq<U>;
@ -946,7 +946,7 @@ impl<T: ::core::hash::Hash + ::core::marker::Copy + Trait,
PackedGeneric<T, U> where T::A: ::core::hash::Hash + ::core::marker::Copy
{
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&{ self.0 }, state);
::core::hash::Hash::hash(&{ self.1 }, state);
::core::hash::Hash::hash(&{ self.2 }, state)
@ -974,7 +974,7 @@ impl<T: ::core::cmp::Eq + ::core::marker::Copy + Trait, U: ::core::cmp::Eq +
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<T>;
let _: ::core::cmp::AssertParamIsEq<T::A>;
let _: ::core::cmp::AssertParamIsEq<U>;
@ -1043,7 +1043,7 @@ impl ::core::fmt::Debug for Enum0 {
#[automatically_derived]
impl ::core::hash::Hash for Enum0 {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
match *self {}
}
}
@ -1059,7 +1059,7 @@ impl ::core::cmp::Eq for Enum0 {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {}
fn assert_receiver_is_total_eq(&self) {}
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for Enum0 {
@ -1105,7 +1105,7 @@ impl ::core::fmt::Debug for Enum1 {
#[automatically_derived]
impl ::core::hash::Hash for Enum1 {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
match self {
Enum1::Single { x: __self_0 } =>
::core::hash::Hash::hash(__self_0, state),
@ -1129,7 +1129,7 @@ impl ::core::cmp::Eq for Enum1 {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
@ -1181,7 +1181,7 @@ impl ::core::default::Default for Fieldless1 {
#[automatically_derived]
impl ::core::hash::Hash for Fieldless1 {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {}
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {}
}
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for Fieldless1 { }
@ -1195,7 +1195,7 @@ impl ::core::cmp::Eq for Fieldless1 {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {}
fn assert_receiver_is_total_eq(&self) {}
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for Fieldless1 {
@ -1251,7 +1251,7 @@ impl ::core::default::Default for Fieldless {
#[automatically_derived]
impl ::core::hash::Hash for Fieldless {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
@ -1272,7 +1272,7 @@ impl ::core::cmp::Eq for Fieldless {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {}
fn assert_receiver_is_total_eq(&self) {}
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for Fieldless {
@ -1345,7 +1345,7 @@ impl ::core::default::Default for Mixed {
#[automatically_derived]
impl ::core::hash::Hash for Mixed {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
@ -1382,7 +1382,7 @@ impl ::core::cmp::Eq for Mixed {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
let _: ::core::cmp::AssertParamIsEq<Option<u32>>;
let _: ::core::cmp::AssertParamIsEq<Option<i32>>;
@ -1545,7 +1545,7 @@ impl ::core::fmt::Debug for Fielded {
#[automatically_derived]
impl ::core::hash::Hash for Fielded {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
@ -1580,7 +1580,7 @@ impl ::core::cmp::Eq for Fielded {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
let _: ::core::cmp::AssertParamIsEq<bool>;
let _: ::core::cmp::AssertParamIsEq<Option<i32>>;
@ -1666,7 +1666,7 @@ impl<T: ::core::fmt::Debug, U: ::core::fmt::Debug> ::core::fmt::Debug for
impl<T: ::core::hash::Hash, U: ::core::hash::Hash> ::core::hash::Hash for
EnumGeneric<T, U> {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state);
match self {
@ -1702,7 +1702,7 @@ impl<T: ::core::cmp::Eq, U: ::core::cmp::Eq> ::core::cmp::Eq for
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<T>;
let _: ::core::cmp::AssertParamIsEq<U>;
}

View file

@ -6,7 +6,7 @@
#![feature(assert_matches)]
use std::assert_matches::assert_matches;
use std::assert_matches;
fn main() {
assert_matches!(1 + 1, 3, "1 + 1 definitely should be 3");

View file

@ -4,11 +4,11 @@ macro-stats Macro Name Uses Lines Avg Lines B
macro-stats -----------------------------------------------------------------------------------
macro-stats #[derive(Clone)] 8 67 8.4 1_879 234.9
macro-stats #[derive(PartialOrd)] 1 17 17.0 675 675.0
macro-stats #[derive(Hash)] 2 17 8.5 577 288.5
macro-stats #[derive(Hash)] 2 17 8.5 565 282.5
macro-stats q! 1 26 26.0 519 519.0
macro-stats #[derive(Ord)] 1 15 15.0 503 503.0
macro-stats #[derive(Default)] 2 16 8.0 403 201.5
macro-stats #[derive(Eq)] 1 11 11.0 325 325.0
macro-stats #[derive(Eq)] 1 11 11.0 319 319.0
macro-stats #[derive(Debug)] 1 8 8.0 277 277.0
macro-stats #[derive(PartialEq)] 1 9 9.0 267 267.0
macro-stats #[derive(Copy)] 1 2 2.0 61 61.0

View file

@ -5,7 +5,7 @@
#![feature(assert_matches)]
use std::assert_matches::assert_matches;
use std::assert_matches;
fn main() {
assert!(matches!((), ()));