1
Fork 0

Auto merge of #129721 - workingjubilee:rollup-y2o1mnp, r=workingjubilee

Rollup of 14 pull requests

Successful merges:

 - #128192 (rustc_target: Add various aarch64 features)
 - #129170 (Add an ability to convert between `Span` and `visit::Location`)
 - #129343 (Emit specific message for time<=0.3.35)
 - #129378 (Clean up cfg-gating of ProcessPrng extern)
 - #129401 (Partially stabilize `feature(new_uninit)`)
 - #129467 (derive(SmartPointer): assume pointee from the single generic and better error messages)
 - #129494 (format code in tests/ui/threads-sendsync)
 - #129617 (Update books)
 - #129673 (Add fmt::Debug to sync::Weak<T, A>)
 - #129683 (copysign with sign being a NaN can have non-portable results)
 - #129689 (Move `'tcx` lifetime off of impl and onto methods for `CrateMetadataRef`)
 - #129695 (Fix path to run clippy on rustdoc)
 - #129712 (Correct trusty targets to be tier 3)
 - #129715 (Update `compiler_builtins` to `0.1.123`)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-08-29 02:38:32 +00:00
commit 6cf068db56
113 changed files with 805 additions and 474 deletions

View file

@ -21,7 +21,6 @@
#![feature(decl_macro)] #![feature(decl_macro)]
#![feature(dropck_eyepatch)] #![feature(dropck_eyepatch)]
#![feature(maybe_uninit_slice)] #![feature(maybe_uninit_slice)]
#![feature(new_uninit)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(strict_provenance)] #![feature(strict_provenance)]

View file

@ -11,7 +11,6 @@ use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident}; use rustc_span::symbol::{sym, Ident};
use rustc_span::{Span, Symbol}; use rustc_span::{Span, Symbol};
use smallvec::{smallvec, SmallVec};
use thin_vec::{thin_vec, ThinVec}; use thin_vec::{thin_vec, ThinVec};
macro_rules! path { macro_rules! path {
@ -68,43 +67,63 @@ pub(crate) fn expand_deriving_smart_ptr(
}; };
// Convert generic parameters (from the struct) into generic args. // Convert generic parameters (from the struct) into generic args.
let mut pointee_param = None; let self_params: Vec<_> = generics
let mut multiple_pointee_diag: SmallVec<[_; 2]> = smallvec![]; .params
let self_params = generics .iter()
.map(|p| match p.kind {
GenericParamKind::Lifetime => GenericArg::Lifetime(cx.lifetime(p.span(), p.ident)),
GenericParamKind::Type { .. } => GenericArg::Type(cx.ty_ident(p.span(), p.ident)),
GenericParamKind::Const { .. } => GenericArg::Const(cx.const_ident(p.span(), p.ident)),
})
.collect();
let type_params: Vec<_> = generics
.params .params
.iter() .iter()
.enumerate() .enumerate()
.map(|(idx, p)| match p.kind { .filter_map(|(idx, p)| {
GenericParamKind::Lifetime => GenericArg::Lifetime(cx.lifetime(p.span(), p.ident)), if let GenericParamKind::Type { .. } = p.kind {
GenericParamKind::Type { .. } => { Some((idx, p.span(), p.attrs().iter().any(|attr| attr.has_name(sym::pointee))))
if p.attrs().iter().any(|attr| attr.has_name(sym::pointee)) { } else {
if pointee_param.is_some() { None
multiple_pointee_diag.push(cx.dcx().struct_span_err(
p.span(),
"`SmartPointer` can only admit one type as pointee",
));
} else {
pointee_param = Some(idx);
}
}
GenericArg::Type(cx.ty_ident(p.span(), p.ident))
} }
GenericParamKind::Const { .. } => GenericArg::Const(cx.const_ident(p.span(), p.ident)),
}) })
.collect::<Vec<_>>(); .collect();
let Some(pointee_param_idx) = pointee_param else {
let pointee_param_idx = if type_params.is_empty() {
// `#[derive(SmartPointer)]` requires at least one generic type on the target `struct`
cx.dcx().struct_span_err( cx.dcx().struct_span_err(
span, span,
"At least one generic type should be designated as `#[pointee]` in order to derive `SmartPointer` traits", "`SmartPointer` can only be derived on `struct`s that are generic over at least one type",
).emit(); ).emit();
return; return;
}; } else if type_params.len() == 1 {
if !multiple_pointee_diag.is_empty() { // Regardless of the only type param being designed as `#[pointee]` or not, we can just use it as such
for diag in multiple_pointee_diag { type_params[0].0
diag.emit(); } else {
let mut pointees = type_params
.iter()
.filter_map(|&(idx, span, is_pointee)| is_pointee.then_some((idx, span)))
.fuse();
match (pointees.next(), pointees.next()) {
(Some((idx, _span)), None) => idx,
(None, _) => {
cx.dcx().struct_span_err(
span,
"exactly one generic type parameter must be marked as #[pointee] to derive SmartPointer traits",
).emit();
return;
}
(Some((_, one)), Some((_, another))) => {
cx.dcx()
.struct_span_err(
vec![one, another],
"only one type parameter can be marked as `#[pointee]` when deriving SmartPointer traits",
)
.emit();
return;
}
} }
return; };
}
// Create the type of `self`. // Create the type of `self`.
let path = cx.path_all(span, false, vec![name_ident], self_params.clone()); let path = cx.path_all(span, false, vec![name_ident], self_params.clone());

View file

@ -521,13 +521,20 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
let function_features = function_features let function_features = function_features
.iter() .iter()
.flat_map(|feat| { // Convert to LLVMFeatures and filter out unavailable ones
llvm_util::to_llvm_features(cx.tcx.sess, feat).into_iter().map(|f| format!("+{f}")) .flat_map(|feat| llvm_util::to_llvm_features(cx.tcx.sess, feat))
}) // Convert LLVMFeatures & dependencies to +<feats>s
.flat_map(|feat| feat.into_iter().map(|f| format!("+{f}")))
.chain(codegen_fn_attrs.instruction_set.iter().map(|x| match x { .chain(codegen_fn_attrs.instruction_set.iter().map(|x| match x {
InstructionSetAttr::ArmA32 => "-thumb-mode".to_string(), InstructionSetAttr::ArmA32 => "-thumb-mode".to_string(),
InstructionSetAttr::ArmT32 => "+thumb-mode".to_string(), InstructionSetAttr::ArmT32 => "+thumb-mode".to_string(),
})) }))
// HACK: LLVM versions 19+ do not have the FPMR feature and treat it as always enabled
// It only exists as a feature in LLVM 18, cannot be passed down for any other version
.chain(match &*cx.tcx.sess.target.arch {
"aarch64" if llvm_util::get_version().0 == 18 => vec!["+fpmr".to_string()],
_ => vec![],
})
.collect::<Vec<String>>(); .collect::<Vec<String>>();
if cx.tcx.sess.target.is_like_wasm { if cx.tcx.sess.target.is_like_wasm {

View file

@ -209,7 +209,7 @@ impl<'a> IntoIterator for LLVMFeature<'a> {
// Though note that Rust can also be build with an external precompiled version of LLVM // Though note that Rust can also be build with an external precompiled version of LLVM
// which might lead to failures if the oldest tested / supported LLVM version // which might lead to failures if the oldest tested / supported LLVM version
// doesn't yet support the relevant intrinsics // doesn't yet support the relevant intrinsics
pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> { pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFeature<'a>> {
let arch = if sess.target.arch == "x86_64" { let arch = if sess.target.arch == "x86_64" {
"x86" "x86"
} else if sess.target.arch == "arm64ec" { } else if sess.target.arch == "arm64ec" {
@ -218,40 +218,59 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a
&*sess.target.arch &*sess.target.arch
}; };
match (arch, s) { match (arch, s) {
("x86", "sse4.2") => { ("x86", "sse4.2") => Some(LLVMFeature::with_dependency(
LLVMFeature::with_dependency("sse4.2", TargetFeatureFoldStrength::EnableOnly("crc32")) "sse4.2",
} TargetFeatureFoldStrength::EnableOnly("crc32"),
("x86", "pclmulqdq") => LLVMFeature::new("pclmul"), )),
("x86", "rdrand") => LLVMFeature::new("rdrnd"), ("x86", "pclmulqdq") => Some(LLVMFeature::new("pclmul")),
("x86", "bmi1") => LLVMFeature::new("bmi"), ("x86", "rdrand") => Some(LLVMFeature::new("rdrnd")),
("x86", "cmpxchg16b") => LLVMFeature::new("cx16"), ("x86", "bmi1") => Some(LLVMFeature::new("bmi")),
("x86", "lahfsahf") => LLVMFeature::new("sahf"), ("x86", "cmpxchg16b") => Some(LLVMFeature::new("cx16")),
("aarch64", "rcpc2") => LLVMFeature::new("rcpc-immo"), ("x86", "lahfsahf") => Some(LLVMFeature::new("sahf")),
("aarch64", "dpb") => LLVMFeature::new("ccpp"), ("aarch64", "rcpc2") => Some(LLVMFeature::new("rcpc-immo")),
("aarch64", "dpb2") => LLVMFeature::new("ccdp"), ("aarch64", "dpb") => Some(LLVMFeature::new("ccpp")),
("aarch64", "frintts") => LLVMFeature::new("fptoint"), ("aarch64", "dpb2") => Some(LLVMFeature::new("ccdp")),
("aarch64", "fcma") => LLVMFeature::new("complxnum"), ("aarch64", "frintts") => Some(LLVMFeature::new("fptoint")),
("aarch64", "pmuv3") => LLVMFeature::new("perfmon"), ("aarch64", "fcma") => Some(LLVMFeature::new("complxnum")),
("aarch64", "paca") => LLVMFeature::new("pauth"), ("aarch64", "pmuv3") => Some(LLVMFeature::new("perfmon")),
("aarch64", "pacg") => LLVMFeature::new("pauth"), ("aarch64", "paca") => Some(LLVMFeature::new("pauth")),
("aarch64", "pacg") => Some(LLVMFeature::new("pauth")),
("aarch64", "sve-b16b16") => Some(LLVMFeature::new("b16b16")),
("aarch64", "flagm2") => Some(LLVMFeature::new("altnzcv")),
// Rust ties fp and neon together. // Rust ties fp and neon together.
("aarch64", "neon") => { ("aarch64", "neon") => {
LLVMFeature::with_dependency("neon", TargetFeatureFoldStrength::Both("fp-armv8")) Some(LLVMFeature::with_dependency("neon", TargetFeatureFoldStrength::Both("fp-armv8")))
} }
// In LLVM neon implicitly enables fp, but we manually enable // In LLVM neon implicitly enables fp, but we manually enable
// neon when a feature only implicitly enables fp // neon when a feature only implicitly enables fp
("aarch64", "fhm") => LLVMFeature::new("fp16fml"), ("aarch64", "fhm") => Some(LLVMFeature::new("fp16fml")),
("aarch64", "fp16") => LLVMFeature::new("fullfp16"), ("aarch64", "fp16") => Some(LLVMFeature::new("fullfp16")),
// Filter out features that are not supported by the current LLVM version
("aarch64", "faminmax") if get_version().0 < 18 => None,
("aarch64", "fp8") if get_version().0 < 18 => None,
("aarch64", "fp8dot2") if get_version().0 < 18 => None,
("aarch64", "fp8dot4") if get_version().0 < 18 => None,
("aarch64", "fp8fma") if get_version().0 < 18 => None,
("aarch64", "fpmr") if get_version().0 != 18 => None,
("aarch64", "lut") if get_version().0 < 18 => None,
("aarch64", "sme-f8f16") if get_version().0 < 18 => None,
("aarch64", "sme-f8f32") if get_version().0 < 18 => None,
("aarch64", "sme-fa64") if get_version().0 < 18 => None,
("aarch64", "sme-lutv2") if get_version().0 < 18 => None,
("aarch64", "ssve-fp8dot2") if get_version().0 < 18 => None,
("aarch64", "ssve-fp8dot4") if get_version().0 < 18 => None,
("aarch64", "ssve-fp8fma") if get_version().0 < 18 => None,
("aarch64", "v9.5a") if get_version().0 < 18 => None,
// In LLVM 18, `unaligned-scalar-mem` was merged with `unaligned-vector-mem` into a single feature called // In LLVM 18, `unaligned-scalar-mem` was merged with `unaligned-vector-mem` into a single feature called
// `fast-unaligned-access`. In LLVM 19, it was split back out. // `fast-unaligned-access`. In LLVM 19, it was split back out.
("riscv32" | "riscv64", "unaligned-scalar-mem") if get_version().0 == 18 => { ("riscv32" | "riscv64", "unaligned-scalar-mem") if get_version().0 == 18 => {
LLVMFeature::new("fast-unaligned-access") Some(LLVMFeature::new("fast-unaligned-access"))
} }
// For LLVM 18, enable the evex512 target feature if a avx512 target feature is enabled. // For LLVM 18, enable the evex512 target feature if a avx512 target feature is enabled.
("x86", s) if get_version().0 >= 18 && s.starts_with("avx512") => { ("x86", s) if get_version().0 >= 18 && s.starts_with("avx512") => {
LLVMFeature::with_dependency(s, TargetFeatureFoldStrength::EnableOnly("evex512")) Some(LLVMFeature::with_dependency(s, TargetFeatureFoldStrength::EnableOnly("evex512")))
} }
(_, s) => LLVMFeature::new(s), (_, s) => Some(LLVMFeature::new(s)),
} }
} }
@ -291,13 +310,17 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
return true; return true;
} }
// check that all features in a given smallvec are enabled // check that all features in a given smallvec are enabled
for llvm_feature in to_llvm_features(sess, feature) { if let Some(feat) = to_llvm_features(sess, feature) {
let cstr = SmallCStr::new(llvm_feature); for llvm_feature in feat {
if !unsafe { llvm::LLVMRustHasFeature(&target_machine, cstr.as_ptr()) } { let cstr = SmallCStr::new(llvm_feature);
return false; if !unsafe { llvm::LLVMRustHasFeature(&target_machine, cstr.as_ptr()) } {
return false;
}
} }
true
} else {
false
} }
true
}) })
.map(|(feature, _, _)| Symbol::intern(feature)), .map(|(feature, _, _)| Symbol::intern(feature)),
); );
@ -386,9 +409,9 @@ fn print_target_features(out: &mut String, sess: &Session, tm: &llvm::TargetMach
.target .target
.supported_target_features() .supported_target_features()
.iter() .iter()
.map(|(feature, _gate, _implied)| { .filter_map(|(feature, _gate, _implied)| {
// LLVM asserts that these are sorted. LLVM and Rust both use byte comparison for these strings. // LLVM asserts that these are sorted. LLVM and Rust both use byte comparison for these strings.
let llvm_feature = to_llvm_features(sess, *feature).llvm_feature_name; let llvm_feature = to_llvm_features(sess, *feature)?.llvm_feature_name;
let desc = let desc =
match llvm_target_features.binary_search_by_key(&llvm_feature, |(f, _d)| f).ok() { match llvm_target_features.binary_search_by_key(&llvm_feature, |(f, _d)| f).ok() {
Some(index) => { Some(index) => {
@ -398,7 +421,7 @@ fn print_target_features(out: &mut String, sess: &Session, tm: &llvm::TargetMach
None => "", None => "",
}; };
(*feature, desc) Some((*feature, desc))
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
@ -595,7 +618,7 @@ pub(crate) fn global_llvm_features(
if feature_state.is_none() { if feature_state.is_none() {
let rust_feature = let rust_feature =
supported_features.iter().find_map(|&(rust_feature, _, _)| { supported_features.iter().find_map(|&(rust_feature, _, _)| {
let llvm_features = to_llvm_features(sess, rust_feature); let llvm_features = to_llvm_features(sess, rust_feature)?;
if llvm_features.contains(feature) if llvm_features.contains(feature)
&& !llvm_features.contains(rust_feature) && !llvm_features.contains(rust_feature)
{ {
@ -641,7 +664,7 @@ pub(crate) fn global_llvm_features(
// passing requests down to LLVM. This means that all in-language // passing requests down to LLVM. This means that all in-language
// features also work on the command line instead of having two // features also work on the command line instead of having two
// different names when the LLVM name and the Rust name differ. // different names when the LLVM name and the Rust name differ.
let llvm_feature = to_llvm_features(sess, feature); let llvm_feature = to_llvm_features(sess, feature)?;
Some( Some(
std::iter::once(format!( std::iter::once(format!(
@ -691,6 +714,9 @@ fn backend_feature_name<'a>(sess: &Session, s: &'a str) -> Option<&'a str> {
let feature = s let feature = s
.strip_prefix(&['+', '-'][..]) .strip_prefix(&['+', '-'][..])
.unwrap_or_else(|| sess.dcx().emit_fatal(InvalidTargetFeaturePrefix { feature: s })); .unwrap_or_else(|| sess.dcx().emit_fatal(InvalidTargetFeaturePrefix { feature: s }));
if s.is_empty() {
return None;
}
// Rustc-specific feature requests like `+crt-static` or `-crt-static` // Rustc-specific feature requests like `+crt-static` or `-crt-static`
// are not passed down to LLVM. // are not passed down to LLVM.
if RUSTC_SPECIFIC_FEATURES.contains(&feature) { if RUSTC_SPECIFIC_FEATURES.contains(&feature) {

View file

@ -302,6 +302,7 @@ declare_features! (
// FIXME: Document these and merge with the list below. // FIXME: Document these and merge with the list below.
// Unstable `#[target_feature]` directives. // Unstable `#[target_feature]` directives.
(unstable, aarch64_unstable_target_feature, "CURRENT_RUSTC_VERSION", Some(44839)),
(unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)), (unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)),
(unstable, arm_target_feature, "1.27.0", Some(44839)), (unstable, arm_target_feature, "1.27.0", Some(44839)),
(unstable, avx512_target_feature, "1.27.0", Some(44839)), (unstable, avx512_target_feature, "1.27.0", Some(44839)),

View file

@ -1,7 +1,7 @@
// tidy-alphabetical-start // tidy-alphabetical-start
#![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))] #![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))]
#![cfg_attr(feature = "nightly", allow(internal_features))] #![cfg_attr(feature = "nightly", allow(internal_features))]
#![cfg_attr(feature = "nightly", feature(extend_one, new_uninit, step_trait, test))] #![cfg_attr(feature = "nightly", feature(extend_one, step_trait, test))]
#![cfg_attr(feature = "nightly", feature(new_zeroed_alloc))] #![cfg_attr(feature = "nightly", feature(new_zeroed_alloc))]
#![warn(unreachable_pub)] #![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end

View file

@ -962,7 +962,7 @@ impl CrateRoot {
} }
} }
impl<'a, 'tcx> CrateMetadataRef<'a> { impl<'a> CrateMetadataRef<'a> {
fn missing(self, descr: &str, id: DefIndex) -> ! { fn missing(self, descr: &str, id: DefIndex) -> ! {
bug!("missing `{descr}` for {:?}", self.local_def_id(id)) bug!("missing `{descr}` for {:?}", self.local_def_id(id))
} }
@ -1036,7 +1036,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
.decode((self, sess)) .decode((self, sess))
} }
fn load_proc_macro(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> SyntaxExtension { fn load_proc_macro<'tcx>(self, id: DefIndex, tcx: TyCtxt<'tcx>) -> SyntaxExtension {
let (name, kind, helper_attrs) = match *self.raw_proc_macro(id) { let (name, kind, helper_attrs) = match *self.raw_proc_macro(id) {
ProcMacro::CustomDerive { trait_name, attributes, client } => { ProcMacro::CustomDerive { trait_name, attributes, client } => {
let helper_attrs = let helper_attrs =
@ -1070,7 +1070,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
) )
} }
fn get_explicit_item_bounds( fn get_explicit_item_bounds<'tcx>(
self, self,
index: DefIndex, index: DefIndex,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
@ -1084,7 +1084,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
ty::EarlyBinder::bind(&*output) ty::EarlyBinder::bind(&*output)
} }
fn get_explicit_item_super_predicates( fn get_explicit_item_super_predicates<'tcx>(
self, self,
index: DefIndex, index: DefIndex,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
@ -1141,7 +1141,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
) )
} }
fn get_adt_def(self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::AdtDef<'tcx> { fn get_adt_def<'tcx>(self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::AdtDef<'tcx> {
let kind = self.def_kind(item_id); let kind = self.def_kind(item_id);
let did = self.local_def_id(item_id); let did = self.local_def_id(item_id);
@ -1225,12 +1225,12 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
/// Iterates over the stability implications in the given crate (when a `#[unstable]` attribute /// Iterates over the stability implications in the given crate (when a `#[unstable]` attribute
/// has an `implied_by` meta item, then the mapping from the implied feature to the actual /// has an `implied_by` meta item, then the mapping from the implied feature to the actual
/// feature is a stability implication). /// feature is a stability implication).
fn get_stability_implications(self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Symbol)] { fn get_stability_implications<'tcx>(self, tcx: TyCtxt<'tcx>) -> &'tcx [(Symbol, Symbol)] {
tcx.arena.alloc_from_iter(self.root.stability_implications.decode(self)) tcx.arena.alloc_from_iter(self.root.stability_implications.decode(self))
} }
/// Iterates over the lang items in the given crate. /// Iterates over the lang items in the given crate.
fn get_lang_items(self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, LangItem)] { fn get_lang_items<'tcx>(self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, LangItem)] {
tcx.arena.alloc_from_iter( tcx.arena.alloc_from_iter(
self.root self.root
.lang_items .lang_items
@ -1239,7 +1239,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
) )
} }
fn get_stripped_cfg_items(self, cnum: CrateNum, tcx: TyCtxt<'tcx>) -> &'tcx [StrippedCfgItem] { fn get_stripped_cfg_items<'tcx>(
self,
cnum: CrateNum,
tcx: TyCtxt<'tcx>,
) -> &'tcx [StrippedCfgItem] {
let item_names = self let item_names = self
.root .root
.stripped_cfg_items .stripped_cfg_items
@ -1412,7 +1416,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
.decode((self, sess)) .decode((self, sess))
} }
fn get_inherent_implementations_for_type( fn get_inherent_implementations_for_type<'tcx>(
self, self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
id: DefIndex, id: DefIndex,
@ -1439,7 +1443,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
}) })
} }
fn get_incoherent_impls(self, tcx: TyCtxt<'tcx>, simp: SimplifiedType) -> &'tcx [DefId] { fn get_incoherent_impls<'tcx>(self, tcx: TyCtxt<'tcx>, simp: SimplifiedType) -> &'tcx [DefId] {
if let Some(impls) = self.cdata.incoherent_impls.get(&simp) { if let Some(impls) = self.cdata.incoherent_impls.get(&simp) {
tcx.arena.alloc_from_iter(impls.decode(self).map(|idx| self.local_def_id(idx))) tcx.arena.alloc_from_iter(impls.decode(self).map(|idx| self.local_def_id(idx)))
} else { } else {
@ -1447,7 +1451,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
} }
} }
fn get_implementations_of_trait( fn get_implementations_of_trait<'tcx>(
self, self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
trait_def_id: DefId, trait_def_id: DefId,
@ -1491,7 +1495,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
self.root.foreign_modules.decode((self, sess)) self.root.foreign_modules.decode((self, sess))
} }
fn get_dylib_dependency_formats( fn get_dylib_dependency_formats<'tcx>(
self, self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
) -> &'tcx [(CrateNum, LinkagePreference)] { ) -> &'tcx [(CrateNum, LinkagePreference)] {
@ -1503,11 +1507,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
) )
} }
fn get_missing_lang_items(self, tcx: TyCtxt<'tcx>) -> &'tcx [LangItem] { fn get_missing_lang_items<'tcx>(self, tcx: TyCtxt<'tcx>) -> &'tcx [LangItem] {
tcx.arena.alloc_from_iter(self.root.lang_items_missing.decode(self)) tcx.arena.alloc_from_iter(self.root.lang_items_missing.decode(self))
} }
fn exported_symbols( fn exported_symbols<'tcx>(
self, self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] { ) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] {

View file

@ -53,7 +53,6 @@
#![feature(min_specialization)] #![feature(min_specialization)]
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(never_type)] #![feature(never_type)]
#![feature(new_uninit)]
#![feature(ptr_alignment_type)] #![feature(ptr_alignment_type)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]

View file

@ -26,7 +26,6 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(min_specialization)] #![feature(min_specialization)]
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(new_uninit)]
#![feature(read_buf)] #![feature(read_buf)]
#![feature(round_char_boundary)] #![feature(round_char_boundary)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]

View file

@ -356,6 +356,7 @@ symbols! {
_task_context, _task_context,
a32, a32,
aarch64_target_feature, aarch64_target_feature,
aarch64_unstable_target_feature,
aarch64_ver_target_feature, aarch64_ver_target_feature,
abi, abi,
abi_amdgpu_kernel, abi_amdgpu_kernel,
@ -1897,6 +1898,7 @@ symbols! {
three_way_compare, three_way_compare,
thumb2, thumb2,
thumb_mode: "thumb-mode", thumb_mode: "thumb-mode",
time,
tmm_reg, tmm_reg,
to_owned_method, to_owned_method,
to_string, to_string,

View file

@ -7,7 +7,7 @@ pub fn target() -> Target {
llvm_target: "aarch64-unknown-unknown-musl".into(), llvm_target: "aarch64-unknown-unknown-musl".into(),
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("ARM64 Trusty".into()), description: Some("ARM64 Trusty".into()),
tier: Some(2), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(false), std: Some(false),
}, },

View file

@ -8,7 +8,7 @@ pub fn target() -> Target {
llvm_target: "armv7-unknown-unknown-gnueabi".into(), llvm_target: "armv7-unknown-unknown-gnueabi".into(),
metadata: crate::spec::TargetMetadata { metadata: crate::spec::TargetMetadata {
description: Some("Armv7-A Trusty".into()), description: Some("Armv7-A Trusty".into()),
tier: Some(2), tier: Some(3),
host_tools: Some(false), host_tools: Some(false),
std: Some(false), std: Some(false),
}, },

View file

@ -99,6 +99,8 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("bti", Stable, &[]), ("bti", Stable, &[]),
// FEAT_CRC // FEAT_CRC
("crc", Stable, &[]), ("crc", Stable, &[]),
// FEAT_CSSC
("cssc", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_DIT // FEAT_DIT
("dit", Stable, &[]), ("dit", Stable, &[]),
// FEAT_DotProd // FEAT_DotProd
@ -107,21 +109,37 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("dpb", Stable, &[]), ("dpb", Stable, &[]),
// FEAT_DPB2 // FEAT_DPB2
("dpb2", Stable, &["dpb"]), ("dpb2", Stable, &["dpb"]),
// FEAT_ECV
("ecv", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_F32MM // FEAT_F32MM
("f32mm", Stable, &["sve"]), ("f32mm", Stable, &["sve"]),
// FEAT_F64MM // FEAT_F64MM
("f64mm", Stable, &["sve"]), ("f64mm", Stable, &["sve"]),
// FEAT_FAMINMAX
("faminmax", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_FCMA // FEAT_FCMA
("fcma", Stable, &["neon"]), ("fcma", Stable, &["neon"]),
// FEAT_FHM // FEAT_FHM
("fhm", Stable, &["fp16"]), ("fhm", Stable, &["fp16"]),
// FEAT_FLAGM // FEAT_FLAGM
("flagm", Stable, &[]), ("flagm", Stable, &[]),
// FEAT_FLAGM2
("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_FP16 // FEAT_FP16
// Rust ties FP and Neon: https://github.com/rust-lang/rust/pull/91608 // Rust ties FP and Neon: https://github.com/rust-lang/rust/pull/91608
("fp16", Stable, &["neon"]), ("fp16", Stable, &["neon"]),
// FEAT_FP8
("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
// FEAT_FP8DOT2
("fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["fp8dot4"]),
// FEAT_FP8DOT4
("fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["fp8fma"]),
// FEAT_FP8FMA
("fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["fp8"]),
// FEAT_FRINTTS // FEAT_FRINTTS
("frintts", Stable, &[]), ("frintts", Stable, &[]),
// FEAT_HBC
("hbc", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_I8MM // FEAT_I8MM
("i8mm", Stable, &[]), ("i8mm", Stable, &[]),
// FEAT_JSCVT // FEAT_JSCVT
@ -131,6 +149,14 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("lor", Stable, &[]), ("lor", Stable, &[]),
// FEAT_LSE // FEAT_LSE
("lse", Stable, &[]), ("lse", Stable, &[]),
// FEAT_LSE128
("lse128", Unstable(sym::aarch64_unstable_target_feature), &["lse"]),
// FEAT_LSE2
("lse2", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_LUT
("lut", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_MOPS
("mops", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_MTE & FEAT_MTE2 // FEAT_MTE & FEAT_MTE2
("mte", Stable, &[]), ("mte", Stable, &[]),
// FEAT_AdvSimd & FEAT_FP // FEAT_AdvSimd & FEAT_FP
@ -143,14 +169,16 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("pan", Stable, &[]), ("pan", Stable, &[]),
// FEAT_PMUv3 // FEAT_PMUv3
("pmuv3", Stable, &[]), ("pmuv3", Stable, &[]),
// FEAT_RAND // FEAT_RNG
("rand", Stable, &[]), ("rand", Stable, &[]),
// FEAT_RAS & FEAT_RASv1p1 // FEAT_RAS & FEAT_RASv1p1
("ras", Stable, &[]), ("ras", Stable, &[]),
// FEAT_RCPC // FEAT_LRCPC
("rcpc", Stable, &[]), ("rcpc", Stable, &[]),
// FEAT_RCPC2 // FEAT_LRCPC2
("rcpc2", Stable, &["rcpc"]), ("rcpc2", Stable, &["rcpc"]),
// FEAT_LRCPC3
("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
// FEAT_RDM // FEAT_RDM
("rdm", Stable, &["neon"]), ("rdm", Stable, &["neon"]),
// FEAT_SB // FEAT_SB
@ -161,10 +189,36 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("sha3", Stable, &["sha2"]), ("sha3", Stable, &["sha2"]),
// FEAT_SM3 & FEAT_SM4 // FEAT_SM3 & FEAT_SM4
("sm4", Stable, &["neon"]), ("sm4", Stable, &["neon"]),
// FEAT_SME
("sme", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
// FEAT_SME_F16F16
("sme-f16f16", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
// FEAT_SME_F64F64
("sme-f64f64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
// FEAT_SME_F8F16
("sme-f8f16", Unstable(sym::aarch64_unstable_target_feature), &["sme-f8f32"]),
// FEAT_SME_F8F32
("sme-f8f32", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
// FEAT_SME_FA64
("sme-fa64", Unstable(sym::aarch64_unstable_target_feature), &["sme", "sve2"]),
// FEAT_SME_I16I64
("sme-i16i64", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
// FEAT_SME_LUTv2
("sme-lutv2", Unstable(sym::aarch64_unstable_target_feature), &[]),
// FEAT_SME2
("sme2", Unstable(sym::aarch64_unstable_target_feature), &["sme"]),
// FEAT_SME2p1
("sme2p1", Unstable(sym::aarch64_unstable_target_feature), &["sme2"]),
// FEAT_SPE // FEAT_SPE
("spe", Stable, &[]), ("spe", Stable, &[]),
// FEAT_SSBS & FEAT_SSBS2 // FEAT_SSBS & FEAT_SSBS2
("ssbs", Stable, &[]), ("ssbs", Stable, &[]),
// FEAT_SSVE_FP8FDOT2
("ssve-fp8dot2", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8dot4"]),
// FEAT_SSVE_FP8FDOT4
("ssve-fp8dot4", Unstable(sym::aarch64_unstable_target_feature), &["ssve-fp8fma"]),
// FEAT_SSVE_FP8FMA
("ssve-fp8fma", Unstable(sym::aarch64_unstable_target_feature), &["sme2", "fp8"]),
// FEAT_SVE // FEAT_SVE
// It was decided that SVE requires Neon: https://github.com/rust-lang/rust/pull/91608 // It was decided that SVE requires Neon: https://github.com/rust-lang/rust/pull/91608
// //
@ -173,9 +227,11 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// //
// "For backwards compatibility, Neon and VFP are required in the latest architectures." // "For backwards compatibility, Neon and VFP are required in the latest architectures."
("sve", Stable, &["neon"]), ("sve", Stable, &["neon"]),
// FEAT_SVE_B16B16 (SVE or SME Instructions)
("sve-b16b16", Unstable(sym::aarch64_unstable_target_feature), &["bf16"]),
// FEAT_SVE2 // FEAT_SVE2
("sve2", Stable, &["sve"]), ("sve2", Stable, &["sve"]),
// FEAT_SVE2_AES // FEAT_SVE_AES & FEAT_SVE_PMULL128
("sve2-aes", Stable, &["sve2", "aes"]), ("sve2-aes", Stable, &["sve2", "aes"]),
// FEAT_SVE2_BitPerm // FEAT_SVE2_BitPerm
("sve2-bitperm", Stable, &["sve2"]), ("sve2-bitperm", Stable, &["sve2"]),
@ -183,6 +239,8 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("sve2-sha3", Stable, &["sve2", "sha3"]), ("sve2-sha3", Stable, &["sve2", "sha3"]),
// FEAT_SVE2_SM4 // FEAT_SVE2_SM4
("sve2-sm4", Stable, &["sve2", "sm4"]), ("sve2-sm4", Stable, &["sve2", "sm4"]),
// FEAT_SVE2p1
("sve2p1", Unstable(sym::aarch64_unstable_target_feature), &["sve2"]),
// FEAT_TME // FEAT_TME
("tme", Stable, &[]), ("tme", Stable, &[]),
( (
@ -199,9 +257,19 @@ const AARCH64_ALLOWED_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]), ("v8.4a", Unstable(sym::aarch64_ver_target_feature), &["v8.3a", "dotprod", "dit", "flagm"]),
("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]), ("v8.5a", Unstable(sym::aarch64_ver_target_feature), &["v8.4a", "ssbs", "sb", "dpb2", "bti"]),
("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]), ("v8.6a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "bf16", "i8mm"]),
("v8.7a", Unstable(sym::aarch64_ver_target_feature), &[]), ("v8.7a", Unstable(sym::aarch64_ver_target_feature), &["v8.6a", "wfxt"]),
("v8.8a", Unstable(sym::aarch64_ver_target_feature), &["v8.7a", "hbc", "mops"]),
("v8.9a", Unstable(sym::aarch64_ver_target_feature), &["v8.8a", "cssc"]),
("v9.1a", Unstable(sym::aarch64_ver_target_feature), &["v9a", "v8.6a"]),
("v9.2a", Unstable(sym::aarch64_ver_target_feature), &["v9.1a", "v8.7a"]),
("v9.3a", Unstable(sym::aarch64_ver_target_feature), &["v9.2a", "v8.8a"]),
("v9.4a", Unstable(sym::aarch64_ver_target_feature), &["v9.3a", "v8.9a"]),
("v9.5a", Unstable(sym::aarch64_ver_target_feature), &["v9.4a"]),
("v9a", Unstable(sym::aarch64_ver_target_feature), &["v8.5a", "sve2"]),
// FEAT_VHE // FEAT_VHE
("vh", Stable, &[]), ("vh", Stable, &[]),
// FEAT_WFxT
("wfxt", Unstable(sym::aarch64_unstable_target_feature), &[]),
// tidy-alphabetical-end // tidy-alphabetical-end
]; ];

View file

@ -446,6 +446,8 @@ trait_selection_type_annotations_needed = {$source_kind ->
} }
.label = type must be known at this point .label = type must be known at this point
trait_selection_type_annotations_needed_error_time = this is an inference error on crate `time` caused by an API change in Rust 1.80.0; update `time` to version `>=0.3.35` by calling `cargo update`
trait_selection_types_declared_different = these two types are declared with different lifetimes... trait_selection_types_declared_different = these two types are declared with different lifetimes...
trait_selection_unable_to_construct_constant_value = unable to construct a constant value for the unevaluated constant {$unevaluated} trait_selection_unable_to_construct_constant_value = unable to construct a constant value for the unevaluated constant {$unevaluated}

View file

@ -6,7 +6,7 @@ use rustc_errors::codes::*;
use rustc_errors::{Diag, IntoDiagArg}; use rustc_errors::{Diag, IntoDiagArg};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::{CtorOf, DefKind, Namespace, Res}; use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{Body, Closure, Expr, ExprKind, FnRetTy, HirId, LetStmt, LocalSource}; use rustc_hir::{Body, Closure, Expr, ExprKind, FnRetTy, HirId, LetStmt, LocalSource};
use rustc_middle::bug; use rustc_middle::bug;
@ -18,7 +18,7 @@ use rustc_middle::ty::{
TypeFoldable, TypeFolder, TypeSuperFoldable, TypeckResults, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeckResults,
}; };
use rustc_span::symbol::{sym, Ident}; use rustc_span::symbol::{sym, Ident};
use rustc_span::{BytePos, Span, DUMMY_SP}; use rustc_span::{BytePos, FileName, Span, DUMMY_SP};
use crate::error_reporting::TypeErrCtxt; use crate::error_reporting::TypeErrCtxt;
use crate::errors::{ use crate::errors::{
@ -384,6 +384,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
bad_label, bad_label,
was_written: false, was_written: false,
path: Default::default(), path: Default::default(),
time_version: false,
}), }),
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl { TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
span, span,
@ -577,6 +578,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
} }
} }
} }
let time_version =
self.detect_old_time_crate_version(failure_span, &kind, &mut infer_subdiags);
match error_code { match error_code {
TypeAnnotationNeeded::E0282 => self.dcx().create_err(AnnotationRequired { TypeAnnotationNeeded::E0282 => self.dcx().create_err(AnnotationRequired {
span, span,
@ -588,6 +593,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
bad_label: None, bad_label: None,
was_written: path.is_some(), was_written: path.is_some(),
path: path.unwrap_or_default(), path: path.unwrap_or_default(),
time_version,
}), }),
TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl { TypeAnnotationNeeded::E0283 => self.dcx().create_err(AmbiguousImpl {
span, span,
@ -613,6 +619,42 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}), }),
} }
} }
/// Detect the inference regression on crate `time` <= 0.3.35 and emit a more targeted error.
/// <https://github.com/rust-lang/rust/issues/127343>
// FIXME: we should figure out a more generic version of doing this, ideally in cargo itself.
fn detect_old_time_crate_version(
&self,
span: Option<Span>,
kind: &InferSourceKind<'_>,
// We will clear the non-actionable suggestion from the error to reduce noise.
infer_subdiags: &mut Vec<SourceKindSubdiag<'_>>,
) -> bool {
// FIXME(#129461): We are time-boxing this code in the compiler. It'll start failing
// compilation once we promote 1.89 to beta, which will happen in 9 months from now.
#[cfg(not(version("1.89")))]
const fn version_check() {}
#[cfg(version("1.89"))]
const fn version_check() {
panic!("remove this check as presumably the ecosystem has moved from needing it");
}
const { version_check() };
// Only relevant when building the `time` crate.
if self.infcx.tcx.crate_name(LOCAL_CRATE) == sym::time
&& let Some(span) = span
&& let InferSourceKind::LetBinding { pattern_name, .. } = kind
&& let Some(name) = pattern_name
&& name.as_str() == "items"
&& let FileName::Real(file) = self.infcx.tcx.sess.source_map().span_to_filename(span)
{
let path = file.local_path_if_available().to_string_lossy();
if path.contains("format_description") && path.contains("parse") {
infer_subdiags.clear();
return true;
}
}
false
}
} }
#[derive(Debug)] #[derive(Debug)]

View file

@ -205,6 +205,8 @@ pub struct AnnotationRequired<'a> {
#[note(trait_selection_full_type_written)] #[note(trait_selection_full_type_written)]
pub was_written: bool, pub was_written: bool,
pub path: PathBuf, pub path: PathBuf,
#[note(trait_selection_type_annotations_needed_error_time)]
pub time_version: bool,
} }
// Copy of `AnnotationRequired` for E0283 // Copy of `AnnotationRequired` for E0283

View file

@ -19,6 +19,7 @@
#![feature(assert_matches)] #![feature(assert_matches)]
#![feature(associated_type_defaults)] #![feature(associated_type_defaults)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(cfg_version)]
#![feature(control_flow_enum)] #![feature(control_flow_enum)]
#![feature(extract_if)] #![feature(extract_if)]
#![feature(if_let_guard)] #![feature(if_let_guard)]

View file

@ -465,6 +465,22 @@ impl Location {
} }
} }
/// Location of the statement at the given index for a given basic block. Assumes that `stmt_idx`
/// and `bb_idx` are valid for a given body.
pub fn statement_location(body: &Body, bb_idx: &BasicBlockIdx, stmt_idx: usize) -> Location {
let bb = &body.blocks[*bb_idx];
let stmt = &bb.statements[stmt_idx];
Location(stmt.span)
}
/// Location of the terminator for a given basic block. Assumes that `bb_idx` is valid for a given
/// body.
pub fn terminator_location(body: &Body, bb_idx: &BasicBlockIdx) -> Location {
let bb = &body.blocks[*bb_idx];
let terminator = &bb.terminator;
Location(terminator.span)
}
/// Reference to a place used to represent a partial projection. /// Reference to a place used to represent a partial projection.
pub struct PlaceRef<'a> { pub struct PlaceRef<'a> {
pub local: Local, pub local: Local,

View file

@ -58,9 +58,9 @@ dependencies = [
[[package]] [[package]]
name = "compiler_builtins" name = "compiler_builtins"
version = "0.1.121" version = "0.1.123"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce956e6dc07082ec481f0935a51e83b343f8ca51be560452c0ebf830d0bdf5a5" checksum = "b47fcbecb558bdad78c7d3a998523c60a50dd6cd046d5fe74163e309e878fff7"
dependencies = [ dependencies = [
"cc", "cc",
"rustc-std-workspace-core", "rustc-std-workspace-core",

View file

@ -10,7 +10,7 @@ edition = "2021"
[dependencies] [dependencies]
core = { path = "../core" } core = { path = "../core" }
compiler_builtins = { version = "0.1.121", features = ['rustc-dep-of-std'] } compiler_builtins = { version = "0.1.123", features = ['rustc-dep-of-std'] }
[dev-dependencies] [dev-dependencies]
rand = { version = "0.8.5", default-features = false, features = ["alloc"] } rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

View file

@ -262,8 +262,6 @@ impl<T> Box<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
///
/// let mut five = Box::<u32>::new_uninit(); /// let mut five = Box::<u32>::new_uninit();
/// ///
/// let five = unsafe { /// let five = unsafe {
@ -276,7 +274,7 @@ impl<T> Box<T> {
/// assert_eq!(*five, 5) /// assert_eq!(*five, 5)
/// ``` /// ```
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[must_use] #[must_use]
#[inline] #[inline]
pub fn new_uninit() -> Box<mem::MaybeUninit<T>> { pub fn new_uninit() -> Box<mem::MaybeUninit<T>> {
@ -292,7 +290,6 @@ impl<T> Box<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(new_zeroed_alloc)] /// #![feature(new_zeroed_alloc)]
/// ///
/// let zero = Box::<u32>::new_zeroed(); /// let zero = Box::<u32>::new_zeroed();
@ -350,7 +347,7 @@ impl<T> Box<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// let mut five = Box::<u32>::try_new_uninit()?; /// let mut five = Box::<u32>::try_new_uninit()?;
/// ///
@ -380,7 +377,7 @@ impl<T> Box<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// let zero = Box::<u32>::try_new_zeroed()?; /// let zero = Box::<u32>::try_new_zeroed()?;
/// let zero = unsafe { zero.assume_init() }; /// let zero = unsafe { zero.assume_init() };
@ -460,7 +457,7 @@ impl<T, A: Allocator> Box<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// use std::alloc::System; /// use std::alloc::System;
/// ///
@ -498,7 +495,7 @@ impl<T, A: Allocator> Box<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// use std::alloc::System; /// use std::alloc::System;
/// ///
@ -538,7 +535,7 @@ impl<T, A: Allocator> Box<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// use std::alloc::System; /// use std::alloc::System;
/// ///
@ -576,7 +573,7 @@ impl<T, A: Allocator> Box<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// use std::alloc::System; /// use std::alloc::System;
/// ///
@ -654,8 +651,6 @@ impl<T> Box<[T]> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
///
/// let mut values = Box::<[u32]>::new_uninit_slice(3); /// let mut values = Box::<[u32]>::new_uninit_slice(3);
/// ///
/// let values = unsafe { /// let values = unsafe {
@ -670,7 +665,7 @@ impl<T> Box<[T]> {
/// assert_eq!(*values, [1, 2, 3]) /// assert_eq!(*values, [1, 2, 3])
/// ``` /// ```
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[must_use] #[must_use]
pub fn new_uninit_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> { pub fn new_uninit_slice(len: usize) -> Box<[mem::MaybeUninit<T>]> {
unsafe { RawVec::with_capacity(len).into_box(len) } unsafe { RawVec::with_capacity(len).into_box(len) }
@ -686,7 +681,6 @@ impl<T> Box<[T]> {
/// ///
/// ``` /// ```
/// #![feature(new_zeroed_alloc)] /// #![feature(new_zeroed_alloc)]
/// #![feature(new_uninit)]
/// ///
/// let values = Box::<[u32]>::new_zeroed_slice(3); /// let values = Box::<[u32]>::new_zeroed_slice(3);
/// let values = unsafe { values.assume_init() }; /// let values = unsafe { values.assume_init() };
@ -708,7 +702,7 @@ impl<T> Box<[T]> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// let mut values = Box::<[u32]>::try_new_uninit_slice(3)?; /// let mut values = Box::<[u32]>::try_new_uninit_slice(3)?;
/// let values = unsafe { /// let values = unsafe {
@ -746,7 +740,7 @@ impl<T> Box<[T]> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// let values = Box::<[u32]>::try_new_zeroed_slice(3)?; /// let values = Box::<[u32]>::try_new_zeroed_slice(3)?;
/// let values = unsafe { values.assume_init() }; /// let values = unsafe { values.assume_init() };
@ -778,7 +772,7 @@ impl<T, A: Allocator> Box<[T], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// use std::alloc::System; /// use std::alloc::System;
/// ///
@ -812,7 +806,7 @@ impl<T, A: Allocator> Box<[T], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// use std::alloc::System; /// use std::alloc::System;
/// ///
@ -837,7 +831,7 @@ impl<T, A: Allocator> Box<[T], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// use std::alloc::System; /// use std::alloc::System;
/// ///
@ -880,7 +874,7 @@ impl<T, A: Allocator> Box<[T], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// use std::alloc::System; /// use std::alloc::System;
/// ///
@ -927,8 +921,6 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
///
/// let mut five = Box::<u32>::new_uninit(); /// let mut five = Box::<u32>::new_uninit();
/// ///
/// let five: Box<u32> = unsafe { /// let five: Box<u32> = unsafe {
@ -940,7 +932,7 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
/// ///
/// assert_eq!(*five, 5) /// assert_eq!(*five, 5)
/// ``` /// ```
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[inline] #[inline]
pub unsafe fn assume_init(self) -> Box<T, A> { pub unsafe fn assume_init(self) -> Box<T, A> {
let (raw, alloc) = Box::into_raw_with_allocator(self); let (raw, alloc) = Box::into_raw_with_allocator(self);
@ -958,7 +950,6 @@ impl<T, A: Allocator> Box<mem::MaybeUninit<T>, A> {
/// ///
/// ``` /// ```
/// #![feature(box_uninit_write)] /// #![feature(box_uninit_write)]
/// #![feature(new_uninit)]
/// ///
/// let big_box = Box::<[usize; 1024]>::new_uninit(); /// let big_box = Box::<[usize; 1024]>::new_uninit();
/// ///
@ -1001,8 +992,6 @@ impl<T, A: Allocator> Box<[mem::MaybeUninit<T>], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
///
/// let mut values = Box::<[u32]>::new_uninit_slice(3); /// let mut values = Box::<[u32]>::new_uninit_slice(3);
/// ///
/// let values = unsafe { /// let values = unsafe {
@ -1016,7 +1005,7 @@ impl<T, A: Allocator> Box<[mem::MaybeUninit<T>], A> {
/// ///
/// assert_eq!(*values, [1, 2, 3]) /// assert_eq!(*values, [1, 2, 3])
/// ``` /// ```
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[inline] #[inline]
pub unsafe fn assume_init(self) -> Box<[T], A> { pub unsafe fn assume_init(self) -> Box<[T], A> {
let (raw, alloc) = Box::into_raw_with_allocator(self); let (raw, alloc) = Box::into_raw_with_allocator(self);

View file

@ -93,7 +93,6 @@
// tidy-alphabetical-start // tidy-alphabetical-start
#![cfg_attr(not(no_global_oom_handling), feature(const_alloc_error))] #![cfg_attr(not(no_global_oom_handling), feature(const_alloc_error))]
#![cfg_attr(not(no_global_oom_handling), feature(const_btree_len))] #![cfg_attr(not(no_global_oom_handling), feature(const_btree_len))]
#![cfg_attr(test, feature(new_uninit))]
#![feature(alloc_layout_extra)] #![feature(alloc_layout_extra)]
#![feature(allocator_api)] #![feature(allocator_api)]
#![feature(array_chunks)] #![feature(array_chunks)]

View file

@ -503,7 +503,6 @@ impl<T> Rc<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
@ -518,7 +517,7 @@ impl<T> Rc<T> {
/// assert_eq!(*five, 5) /// assert_eq!(*five, 5)
/// ``` /// ```
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[must_use] #[must_use]
pub fn new_uninit() -> Rc<mem::MaybeUninit<T>> { pub fn new_uninit() -> Rc<mem::MaybeUninit<T>> {
unsafe { unsafe {
@ -540,7 +539,6 @@ impl<T> Rc<T> {
/// ///
/// ``` /// ```
/// #![feature(new_zeroed_alloc)] /// #![feature(new_zeroed_alloc)]
/// #![feature(new_uninit)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
/// ///
@ -594,7 +592,7 @@ impl<T> Rc<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
@ -630,7 +628,7 @@ impl<T> Rc<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
/// ///
@ -692,7 +690,6 @@ impl<T, A: Allocator> Rc<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// #![feature(allocator_api)] /// #![feature(allocator_api)]
/// ///
@ -736,7 +733,6 @@ impl<T, A: Allocator> Rc<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(allocator_api)] /// #![feature(allocator_api)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
@ -799,7 +795,7 @@ impl<T, A: Allocator> Rc<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
@ -843,7 +839,7 @@ impl<T, A: Allocator> Rc<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(allocator_api, new_uninit)] /// #![feature(allocator_api)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
/// use std::alloc::System; /// use std::alloc::System;
@ -967,7 +963,6 @@ impl<T> Rc<[T]> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
@ -985,7 +980,7 @@ impl<T> Rc<[T]> {
/// assert_eq!(*values, [1, 2, 3]) /// assert_eq!(*values, [1, 2, 3])
/// ``` /// ```
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[must_use] #[must_use]
pub fn new_uninit_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> { pub fn new_uninit_slice(len: usize) -> Rc<[mem::MaybeUninit<T>]> {
unsafe { Rc::from_ptr(Rc::allocate_for_slice(len)) } unsafe { Rc::from_ptr(Rc::allocate_for_slice(len)) }
@ -1000,7 +995,6 @@ impl<T> Rc<[T]> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(new_zeroed_alloc)] /// #![feature(new_zeroed_alloc)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
@ -1035,7 +1029,6 @@ impl<T, A: Allocator> Rc<[T], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// #![feature(allocator_api)] /// #![feature(allocator_api)]
/// ///
@ -1072,7 +1065,6 @@ impl<T, A: Allocator> Rc<[T], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(allocator_api)] /// #![feature(allocator_api)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
@ -1122,7 +1114,6 @@ impl<T, A: Allocator> Rc<mem::MaybeUninit<T>, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
@ -1136,7 +1127,7 @@ impl<T, A: Allocator> Rc<mem::MaybeUninit<T>, A> {
/// ///
/// assert_eq!(*five, 5) /// assert_eq!(*five, 5)
/// ``` /// ```
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[inline] #[inline]
pub unsafe fn assume_init(self) -> Rc<T, A> { pub unsafe fn assume_init(self) -> Rc<T, A> {
let (ptr, alloc) = Rc::into_inner_with_allocator(self); let (ptr, alloc) = Rc::into_inner_with_allocator(self);
@ -1160,7 +1151,6 @@ impl<T, A: Allocator> Rc<[mem::MaybeUninit<T>], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::rc::Rc; /// use std::rc::Rc;
@ -1177,7 +1167,7 @@ impl<T, A: Allocator> Rc<[mem::MaybeUninit<T>], A> {
/// ///
/// assert_eq!(*values, [1, 2, 3]) /// assert_eq!(*values, [1, 2, 3])
/// ``` /// ```
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[inline] #[inline]
pub unsafe fn assume_init(self) -> Rc<[T], A> { pub unsafe fn assume_init(self) -> Rc<[T], A> {
let (ptr, alloc) = Rc::into_inner_with_allocator(self); let (ptr, alloc) = Rc::into_inner_with_allocator(self);

View file

@ -335,7 +335,7 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Weak<U, A>> f
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Weak<U>> for Weak<T> {} impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Weak<U>> for Weak<T> {}
#[stable(feature = "arc_weak", since = "1.4.0")] #[stable(feature = "arc_weak", since = "1.4.0")]
impl<T: ?Sized> fmt::Debug for Weak<T> { impl<T: ?Sized, A: Allocator> fmt::Debug for Weak<T, A> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "(Weak)") write!(f, "(Weak)")
} }
@ -505,7 +505,6 @@ impl<T> Arc<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
@ -521,7 +520,7 @@ impl<T> Arc<T> {
/// ``` /// ```
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[inline] #[inline]
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[must_use] #[must_use]
pub fn new_uninit() -> Arc<mem::MaybeUninit<T>> { pub fn new_uninit() -> Arc<mem::MaybeUninit<T>> {
unsafe { unsafe {
@ -543,7 +542,6 @@ impl<T> Arc<T> {
/// ///
/// ``` /// ```
/// #![feature(new_zeroed_alloc)] /// #![feature(new_zeroed_alloc)]
/// #![feature(new_uninit)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
/// ///
@ -614,7 +612,7 @@ impl<T> Arc<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit, allocator_api)] /// #![feature(allocator_api)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
@ -650,7 +648,7 @@ impl<T> Arc<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit, allocator_api)] /// #![feature( allocator_api)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
/// ///
@ -711,7 +709,6 @@ impl<T, A: Allocator> Arc<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// #![feature(allocator_api)] /// #![feature(allocator_api)]
/// ///
@ -755,7 +752,6 @@ impl<T, A: Allocator> Arc<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(allocator_api)] /// #![feature(allocator_api)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
@ -845,7 +841,7 @@ impl<T, A: Allocator> Arc<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit, allocator_api)] /// #![feature(allocator_api)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
@ -889,7 +885,7 @@ impl<T, A: Allocator> Arc<T, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit, allocator_api)] /// #![feature(allocator_api)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
/// use std::alloc::System; /// use std::alloc::System;
@ -1101,7 +1097,6 @@ impl<T> Arc<[T]> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
@ -1120,7 +1115,7 @@ impl<T> Arc<[T]> {
/// ``` /// ```
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[inline] #[inline]
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[must_use] #[must_use]
pub fn new_uninit_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> { pub fn new_uninit_slice(len: usize) -> Arc<[mem::MaybeUninit<T>]> {
unsafe { Arc::from_ptr(Arc::allocate_for_slice(len)) } unsafe { Arc::from_ptr(Arc::allocate_for_slice(len)) }
@ -1136,7 +1131,6 @@ impl<T> Arc<[T]> {
/// ///
/// ``` /// ```
/// #![feature(new_zeroed_alloc)] /// #![feature(new_zeroed_alloc)]
/// #![feature(new_uninit)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
/// ///
@ -1172,7 +1166,6 @@ impl<T, A: Allocator> Arc<[T], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// #![feature(allocator_api)] /// #![feature(allocator_api)]
/// ///
@ -1208,7 +1201,6 @@ impl<T, A: Allocator> Arc<[T], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(allocator_api)] /// #![feature(allocator_api)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
@ -1257,7 +1249,6 @@ impl<T, A: Allocator> Arc<mem::MaybeUninit<T>, A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
@ -1271,7 +1262,7 @@ impl<T, A: Allocator> Arc<mem::MaybeUninit<T>, A> {
/// ///
/// assert_eq!(*five, 5) /// assert_eq!(*five, 5)
/// ``` /// ```
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[must_use = "`self` will be dropped if the result is not used"] #[must_use = "`self` will be dropped if the result is not used"]
#[inline] #[inline]
pub unsafe fn assume_init(self) -> Arc<T, A> { pub unsafe fn assume_init(self) -> Arc<T, A> {
@ -1296,7 +1287,6 @@ impl<T, A: Allocator> Arc<[mem::MaybeUninit<T>], A> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(new_uninit)]
/// #![feature(get_mut_unchecked)] /// #![feature(get_mut_unchecked)]
/// ///
/// use std::sync::Arc; /// use std::sync::Arc;
@ -1313,7 +1303,7 @@ impl<T, A: Allocator> Arc<[mem::MaybeUninit<T>], A> {
/// ///
/// assert_eq!(*values, [1, 2, 3]) /// assert_eq!(*values, [1, 2, 3])
/// ``` /// ```
#[unstable(feature = "new_uninit", issue = "63291")] #[stable(feature = "new_uninit", since = "CURRENT_RUSTC_VERSION")]
#[must_use = "`self` will be dropped if the result is not used"] #[must_use = "`self` will be dropped if the result is not used"]
#[inline] #[inline]
pub unsafe fn assume_init(self) -> Arc<[T], A> { pub unsafe fn assume_init(self) -> Arc<[T], A> {

View file

@ -15,7 +15,6 @@
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]
#![feature(linked_list_cursors)] #![feature(linked_list_cursors)]
#![feature(map_try_insert)] #![feature(map_try_insert)]
#![feature(new_uninit)]
#![feature(pattern)] #![feature(pattern)]
#![feature(trusted_len)] #![feature(trusted_len)]
#![feature(try_reserve_kind)] #![feature(try_reserve_kind)]

View file

@ -28,7 +28,6 @@
#![feature(decl_macro)] #![feature(decl_macro)]
#![feature(maybe_uninit_write_slice)] #![feature(maybe_uninit_write_slice)]
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(new_uninit)]
#![feature(panic_can_unwind)] #![feature(panic_can_unwind)]
#![feature(restricted_std)] #![feature(restricted_std)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]

View file

@ -17,7 +17,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true } panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" } panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true } core = { path = "../core", public = true }
compiler_builtins = { version = "0.1.121" } compiler_builtins = { version = "0.1.123" }
profiler_builtins = { path = "../profiler_builtins", optional = true } profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" } unwind = { path = "../unwind" }
hashbrown = { version = "0.14", default-features = false, features = [ hashbrown = { version = "0.14", default-features = false, features = [

View file

@ -250,9 +250,14 @@ impl f128 {
/// ///
/// Equal to `self` if the sign of `self` and `sign` are the same, otherwise equal to `-self`. /// Equal to `self` if the sign of `self` and `sign` are the same, otherwise equal to `-self`.
/// If `self` is a NaN, then a NaN with the same payload as `self` and the sign bit of `sign` is /// If `self` is a NaN, then a NaN with the same payload as `self` and the sign bit of `sign` is
/// returned. Note, however, that conserving the sign bit on NaN across arithmetical operations /// returned.
/// is not generally guaranteed. See [specification of NaN bit ///
/// patterns](primitive@f32#nan-bit-patterns) for more info. /// If `sign` is a NaN, then this operation will still carry over its sign into the result. Note
/// that IEEE 754 doesn't assign any meaning to the sign bit in case of a NaN, and as Rust
/// doesn't guarantee that the bit pattern of NaNs are conserved over arithmetic operations, the
/// result of `copysign` with `sign` being a NaN might produce an unexpected or non-portable
/// result. See the [specification of NaN bit patterns](primitive@f32#nan-bit-patterns) for more
/// info.
/// ///
/// # Examples /// # Examples
/// ///

View file

@ -249,9 +249,14 @@ impl f16 {
/// ///
/// Equal to `self` if the sign of `self` and `sign` are the same, otherwise equal to `-self`. /// Equal to `self` if the sign of `self` and `sign` are the same, otherwise equal to `-self`.
/// If `self` is a NaN, then a NaN with the same payload as `self` and the sign bit of `sign` is /// If `self` is a NaN, then a NaN with the same payload as `self` and the sign bit of `sign` is
/// returned. Note, however, that conserving the sign bit on NaN across arithmetical operations /// returned.
/// is not generally guaranteed. See [specification of NaN bit ///
/// patterns](primitive@f32#nan-bit-patterns) for more info. /// If `sign` is a NaN, then this operation will still carry over its sign into the result. Note
/// that IEEE 754 doesn't assign any meaning to the sign bit in case of a NaN, and as Rust
/// doesn't guarantee that the bit pattern of NaNs are conserved over arithmetic operations, the
/// result of `copysign` with `sign` being a NaN might produce an unexpected or non-portable
/// result. See the [specification of NaN bit patterns](primitive@f32#nan-bit-patterns) for more
/// info.
/// ///
/// # Examples /// # Examples
/// ///

View file

@ -228,9 +228,14 @@ impl f32 {
/// ///
/// Equal to `self` if the sign of `self` and `sign` are the same, otherwise equal to `-self`. /// Equal to `self` if the sign of `self` and `sign` are the same, otherwise equal to `-self`.
/// If `self` is a NaN, then a NaN with the same payload as `self` and the sign bit of `sign` is /// If `self` is a NaN, then a NaN with the same payload as `self` and the sign bit of `sign` is
/// returned. Note, however, that conserving the sign bit on NaN across arithmetical operations /// returned.
/// is not generally guaranteed. See [specification of NaN bit ///
/// patterns](primitive@f32#nan-bit-patterns) for more info. /// If `sign` is a NaN, then this operation will still carry over its sign into the result. Note
/// that IEEE 754 doesn't assign any meaning to the sign bit in case of a NaN, and as Rust
/// doesn't guarantee that the bit pattern of NaNs are conserved over arithmetic operations, the
/// result of `copysign` with `sign` being a NaN might produce an unexpected or non-portable
/// result. See the [specification of NaN bit patterns](primitive@f32#nan-bit-patterns) for more
/// info.
/// ///
/// # Examples /// # Examples
/// ///

View file

@ -228,9 +228,14 @@ impl f64 {
/// ///
/// Equal to `self` if the sign of `self` and `sign` are the same, otherwise equal to `-self`. /// Equal to `self` if the sign of `self` and `sign` are the same, otherwise equal to `-self`.
/// If `self` is a NaN, then a NaN with the same payload as `self` and the sign bit of `sign` is /// If `self` is a NaN, then a NaN with the same payload as `self` and the sign bit of `sign` is
/// returned. Note, however, that conserving the sign bit on NaN across arithmetical operations /// returned.
/// is not generally guaranteed. See [specification of NaN bit ///
/// patterns](primitive@f32#nan-bit-patterns) for more info. /// If `sign` is a NaN, then this operation will still carry over its sign into the result. Note
/// that IEEE 754 doesn't assign any meaning to the sign bit in case of a NaN, and as Rust
/// doesn't guarantee that the bit pattern of NaNs are conserved over arithmetic operations, the
/// result of `copysign` with `sign` being a NaN might produce an unexpected or non-portable
/// result. See the [specification of NaN bit patterns](primitive@f32#nan-bit-patterns) for more
/// info.
/// ///
/// # Examples /// # Examples
/// ///

View file

@ -362,7 +362,6 @@
#![feature(allocator_api)] #![feature(allocator_api)]
#![feature(get_mut_unchecked)] #![feature(get_mut_unchecked)]
#![feature(map_try_insert)] #![feature(map_try_insert)]
#![feature(new_uninit)]
#![feature(new_zeroed_alloc)] #![feature(new_zeroed_alloc)]
#![feature(slice_concat_trait)] #![feature(slice_concat_trait)]
#![feature(thin_box)] #![feature(thin_box)]

View file

@ -109,19 +109,15 @@ if #[cfg(not(target_vendor = "uwp"))] {
} }
// Use raw-dylib to import ProcessPrng as we can't rely on there being an import library. // Use raw-dylib to import ProcessPrng as we can't rely on there being an import library.
cfg_if::cfg_if! { #[cfg(not(target_vendor = "win7"))]
if #[cfg(not(target_vendor = "win7"))] { #[cfg_attr(
#[cfg(target_arch = "x86")] target_arch = "x86",
#[link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated")] link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated")
extern "system" { )]
pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; #[cfg_attr(not(target_arch = "x86"), link(name = "bcryptprimitives", kind = "raw-dylib"))]
} extern "system" {
#[cfg(not(target_arch = "x86"))] pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL;
#[link(name = "bcryptprimitives", kind = "raw-dylib")] }
extern "system" {
pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL;
}
}}
// Functions that aren't available on every version of Windows that we support, // Functions that aren't available on every version of Windows that we support,
// but we still use them and just provide some form of a fallback implementation. // but we still use them and just provide some form of a fallback implementation.

View file

@ -4,6 +4,10 @@
all(target_arch = "arm", any(target_os = "linux", target_os = "android")), all(target_arch = "arm", any(target_os = "linux", target_os = "android")),
feature(stdarch_arm_feature_detection) feature(stdarch_arm_feature_detection)
)] )]
#![cfg_attr(
all(target_arch = "aarch64", any(target_os = "linux", target_os = "android")),
feature(stdarch_aarch64_feature_detection)
)]
#![cfg_attr( #![cfg_attr(
all(target_arch = "powerpc", target_os = "linux"), all(target_arch = "powerpc", target_os = "linux"),
feature(stdarch_powerpc_feature_detection) feature(stdarch_powerpc_feature_detection)
@ -36,21 +40,34 @@ fn aarch64_linux() {
println!("bf16: {}", is_aarch64_feature_detected!("bf16")); println!("bf16: {}", is_aarch64_feature_detected!("bf16"));
println!("bti: {}", is_aarch64_feature_detected!("bti")); println!("bti: {}", is_aarch64_feature_detected!("bti"));
println!("crc: {}", is_aarch64_feature_detected!("crc")); println!("crc: {}", is_aarch64_feature_detected!("crc"));
println!("cssc: {}", is_aarch64_feature_detected!("cssc"));
println!("dit: {}", is_aarch64_feature_detected!("dit")); println!("dit: {}", is_aarch64_feature_detected!("dit"));
println!("dotprod: {}", is_aarch64_feature_detected!("dotprod")); println!("dotprod: {}", is_aarch64_feature_detected!("dotprod"));
println!("dpb2: {}", is_aarch64_feature_detected!("dpb2")); println!("dpb2: {}", is_aarch64_feature_detected!("dpb2"));
println!("dpb: {}", is_aarch64_feature_detected!("dpb")); println!("dpb: {}", is_aarch64_feature_detected!("dpb"));
println!("ecv: {}", is_aarch64_feature_detected!("ecv"));
println!("f32mm: {}", is_aarch64_feature_detected!("f32mm")); println!("f32mm: {}", is_aarch64_feature_detected!("f32mm"));
println!("f64mm: {}", is_aarch64_feature_detected!("f64mm")); println!("f64mm: {}", is_aarch64_feature_detected!("f64mm"));
println!("faminmax: {}", is_aarch64_feature_detected!("faminmax"));
println!("fcma: {}", is_aarch64_feature_detected!("fcma")); println!("fcma: {}", is_aarch64_feature_detected!("fcma"));
println!("fhm: {}", is_aarch64_feature_detected!("fhm")); println!("fhm: {}", is_aarch64_feature_detected!("fhm"));
println!("flagm2: {}", is_aarch64_feature_detected!("flagm2"));
println!("flagm: {}", is_aarch64_feature_detected!("flagm")); println!("flagm: {}", is_aarch64_feature_detected!("flagm"));
println!("fp16: {}", is_aarch64_feature_detected!("fp16")); println!("fp16: {}", is_aarch64_feature_detected!("fp16"));
println!("fp8: {}", is_aarch64_feature_detected!("fp8"));
println!("fp8dot2: {}", is_aarch64_feature_detected!("fp8dot2"));
println!("fp8dot4: {}", is_aarch64_feature_detected!("fp8dot4"));
println!("fp8fma: {}", is_aarch64_feature_detected!("fp8fma"));
println!("fpmr: {}", is_aarch64_feature_detected!("fpmr"));
println!("frintts: {}", is_aarch64_feature_detected!("frintts")); println!("frintts: {}", is_aarch64_feature_detected!("frintts"));
println!("hbc: {}", is_aarch64_feature_detected!("hbc"));
println!("i8mm: {}", is_aarch64_feature_detected!("i8mm")); println!("i8mm: {}", is_aarch64_feature_detected!("i8mm"));
println!("jsconv: {}", is_aarch64_feature_detected!("jsconv")); println!("jsconv: {}", is_aarch64_feature_detected!("jsconv"));
println!("lse128: {}", is_aarch64_feature_detected!("lse128"));
println!("lse2: {}", is_aarch64_feature_detected!("lse2")); println!("lse2: {}", is_aarch64_feature_detected!("lse2"));
println!("lse: {}", is_aarch64_feature_detected!("lse")); println!("lse: {}", is_aarch64_feature_detected!("lse"));
println!("lut: {}", is_aarch64_feature_detected!("lut"));
println!("mops: {}", is_aarch64_feature_detected!("mops"));
println!("mte: {}", is_aarch64_feature_detected!("mte")); println!("mte: {}", is_aarch64_feature_detected!("mte"));
println!("neon: {}", is_aarch64_feature_detected!("neon")); println!("neon: {}", is_aarch64_feature_detected!("neon"));
println!("paca: {}", is_aarch64_feature_detected!("paca")); println!("paca: {}", is_aarch64_feature_detected!("paca"));
@ -58,20 +75,37 @@ fn aarch64_linux() {
println!("pmull: {}", is_aarch64_feature_detected!("pmull")); println!("pmull: {}", is_aarch64_feature_detected!("pmull"));
println!("rand: {}", is_aarch64_feature_detected!("rand")); println!("rand: {}", is_aarch64_feature_detected!("rand"));
println!("rcpc2: {}", is_aarch64_feature_detected!("rcpc2")); println!("rcpc2: {}", is_aarch64_feature_detected!("rcpc2"));
println!("rcpc3: {}", is_aarch64_feature_detected!("rcpc3"));
println!("rcpc: {}", is_aarch64_feature_detected!("rcpc")); println!("rcpc: {}", is_aarch64_feature_detected!("rcpc"));
println!("rdm: {}", is_aarch64_feature_detected!("rdm")); println!("rdm: {}", is_aarch64_feature_detected!("rdm"));
println!("sb: {}", is_aarch64_feature_detected!("sb")); println!("sb: {}", is_aarch64_feature_detected!("sb"));
println!("sha2: {}", is_aarch64_feature_detected!("sha2")); println!("sha2: {}", is_aarch64_feature_detected!("sha2"));
println!("sha3: {}", is_aarch64_feature_detected!("sha3")); println!("sha3: {}", is_aarch64_feature_detected!("sha3"));
println!("sm4: {}", is_aarch64_feature_detected!("sm4")); println!("sm4: {}", is_aarch64_feature_detected!("sm4"));
println!("sme-f16f16: {}", is_aarch64_feature_detected!("sme-f16f16"));
println!("sme-f64f64: {}", is_aarch64_feature_detected!("sme-f64f64"));
println!("sme-f8f16: {}", is_aarch64_feature_detected!("sme-f8f16"));
println!("sme-f8f32: {}", is_aarch64_feature_detected!("sme-f8f32"));
println!("sme-fa64: {}", is_aarch64_feature_detected!("sme-fa64"));
println!("sme-i16i64: {}", is_aarch64_feature_detected!("sme-i16i64"));
println!("sme-lutv2: {}", is_aarch64_feature_detected!("sme-lutv2"));
println!("sme2: {}", is_aarch64_feature_detected!("sme2"));
println!("sme2p1: {}", is_aarch64_feature_detected!("sme2p1"));
println!("sme: {}", is_aarch64_feature_detected!("sme"));
println!("ssbs: {}", is_aarch64_feature_detected!("ssbs")); println!("ssbs: {}", is_aarch64_feature_detected!("ssbs"));
println!("ssve-fp8dot2: {}", is_aarch64_feature_detected!("ssve-fp8dot2"));
println!("ssve-fp8dot4: {}", is_aarch64_feature_detected!("ssve-fp8dot4"));
println!("ssve-fp8fma: {}", is_aarch64_feature_detected!("ssve-fp8fma"));
println!("sve-b16b16: {}", is_aarch64_feature_detected!("sve-b16b16"));
println!("sve2-aes: {}", is_aarch64_feature_detected!("sve2-aes")); println!("sve2-aes: {}", is_aarch64_feature_detected!("sve2-aes"));
println!("sve2-bitperm: {}", is_aarch64_feature_detected!("sve2-bitperm")); println!("sve2-bitperm: {}", is_aarch64_feature_detected!("sve2-bitperm"));
println!("sve2-sha3: {}", is_aarch64_feature_detected!("sve2-sha3")); println!("sve2-sha3: {}", is_aarch64_feature_detected!("sve2-sha3"));
println!("sve2-sm4: {}", is_aarch64_feature_detected!("sve2-sm4")); println!("sve2-sm4: {}", is_aarch64_feature_detected!("sve2-sm4"));
println!("sve2: {}", is_aarch64_feature_detected!("sve2")); println!("sve2: {}", is_aarch64_feature_detected!("sve2"));
println!("sve2p1: {}", is_aarch64_feature_detected!("sve2p1"));
println!("sve: {}", is_aarch64_feature_detected!("sve")); println!("sve: {}", is_aarch64_feature_detected!("sve"));
println!("tme: {}", is_aarch64_feature_detected!("tme")); println!("tme: {}", is_aarch64_feature_detected!("tme"));
println!("wfxt: {}", is_aarch64_feature_detected!("wfxt"));
// tidy-alphabetical-end // tidy-alphabetical-end
} }

View file

@ -313,7 +313,7 @@ lint_any!(
RemoteTestServer, "src/tools/remote-test-server", "remote-test-server"; RemoteTestServer, "src/tools/remote-test-server", "remote-test-server";
Rls, "src/tools/rls", "rls"; Rls, "src/tools/rls", "rls";
RustAnalyzer, "src/tools/rust-analyzer", "rust-analyzer"; RustAnalyzer, "src/tools/rust-analyzer", "rust-analyzer";
Rustdoc, "src/tools/rustdoc", "clippy"; Rustdoc, "src/librustdoc", "clippy";
Rustfmt, "src/tools/rustfmt", "rustfmt"; Rustfmt, "src/tools/rustfmt", "rustfmt";
RustInstaller, "src/tools/rust-installer", "rust-installer"; RustInstaller, "src/tools/rust-installer", "rust-installer";
Tidy, "src/tools/tidy", "tidy"; Tidy, "src/tools/tidy", "tidy";

@ -1 +1 @@
Subproject commit 04bc1396bb857f35b5dda1d773c9571e1f253304 Subproject commit e7d217be2a75ef1753f0988d6ccaba4d7e376259

@ -1 +1 @@
Subproject commit aeeb287d41a0332c210da122bea8e0e91844ab3e Subproject commit eeba2cb9c37ab74118a4fb5e5233f7397e4a91f8

@ -1 +1 @@
Subproject commit 019f3928d8b939ec71b63722dcc2e46330156441 Subproject commit ff5d61d56f11e1986bfa9652c6aff7731576c37d

@ -1 +1 @@
Subproject commit 6ecf95c5f2bfa0e6314dfe282bf775fd1405f7e9 Subproject commit 14649f15d232d509478206ee9ed5105641aa60d0

@ -1 +1 @@
Subproject commit 62cd0df95061ba0ac886333f5cd7f3012f149da1 Subproject commit 0668397076da350c404dadcf07b6cbc433ad3743

@ -1 +1 @@
Subproject commit 8f94061936e492159f4f6c09c0f917a7521893ff Subproject commit 859786c5bc99301bbc22fc631a5c2b341860da08

@ -1 +1 @@
Subproject commit 43d83780db545a1ed6d45773312fc578987e3968 Subproject commit fa928a6d19e1666d8d811dfe3fd35cdad3b4e459

View file

@ -1,7 +1,6 @@
//@compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -Zmiri-disable-stacked-borrows //@compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -Zmiri-disable-stacked-borrows
// Avoid accidental synchronization via address reuse inside `thread::spawn`. // Avoid accidental synchronization via address reuse inside `thread::spawn`.
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0 //@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
#![feature(new_uninit)]
use std::mem::MaybeUninit; use std::mem::MaybeUninit;
use std::ptr::null_mut; use std::ptr::null_mut;

View file

@ -1,7 +1,6 @@
//@compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -Zmiri-disable-stacked-borrows //@compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -Zmiri-disable-stacked-borrows
// Avoid accidental synchronization via address reuse inside `thread::spawn`. // Avoid accidental synchronization via address reuse inside `thread::spawn`.
//@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0 //@compile-flags: -Zmiri-address-reuse-cross-thread-rate=0
#![feature(new_uninit)]
use std::ptr::null_mut; use std::ptr::null_mut;
use std::sync::atomic::{AtomicPtr, Ordering}; use std::sync::atomic::{AtomicPtr, Ordering};

View file

@ -6,7 +6,6 @@
// run multiple times until one try returns true. // run multiple times until one try returns true.
// Spurious failure is possible, if you are really unlucky with // Spurious failure is possible, if you are really unlucky with
// the RNG and always read the latest value from the store buffer. // the RNG and always read the latest value from the store buffer.
#![feature(new_uninit)]
use std::sync::atomic::*; use std::sync::atomic::*;
use std::thread::spawn; use std::thread::spawn;

View file

@ -1,7 +1,6 @@
//@revisions: stack tree //@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows //@[tree]compile-flags: -Zmiri-tree-borrows
//@compile-flags: -Zmiri-strict-provenance //@compile-flags: -Zmiri-strict-provenance
#![feature(new_uninit)]
#![feature(get_mut_unchecked)] #![feature(get_mut_unchecked)]
#![allow(ambiguous_wide_pointer_comparisons)] #![allow(ambiguous_wide_pointer_comparisons)]

View file

@ -1,7 +1,6 @@
//@revisions: stack tree //@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows //@[tree]compile-flags: -Zmiri-tree-borrows
//@compile-flags: -Zmiri-strict-provenance //@compile-flags: -Zmiri-strict-provenance
#![feature(new_uninit)]
#![feature(slice_as_chunks)] #![feature(slice_as_chunks)]
#![feature(slice_partition_dedup)] #![feature(slice_partition_dedup)]
#![feature(layout_for_ptr)] #![feature(layout_for_ptr)]

View file

@ -690,6 +690,7 @@ dependencies = [
"mdbook", "mdbook",
"once_cell", "once_cell",
"pathdiff", "pathdiff",
"pulldown-cmark",
"regex", "regex",
"semver", "semver",
"serde_json", "serde_json",

View file

@ -3,21 +3,21 @@
//@ compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu //@ compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu
//@ needs-llvm-components: aarch64 //@ needs-llvm-components: aarch64
// The "+v8a" feature is matched as optional as it isn't added when we // The "+fpmr" feature is matched as optional as it is only an explicit
// are targeting older LLVM versions. Once the min supported version // feature in LLVM 18. Once the min supported version is LLVM-19 the optional
// is LLVM-14 we can remove the optional regex matching for this feature. // regex matching for this feature can be removed.
//@ [ENABLE_SVE] compile-flags: -C target-feature=+sve -Copt-level=0 //@ [ENABLE_SVE] compile-flags: -C target-feature=+sve -Copt-level=0
// ENABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+sve,?)|(\+neon,?)|(\+fp-armv8,?))*}}" } // ENABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)|(\+fpmr,?)?|(\+sve,?)|(\+neon,?)|(\+fp-armv8,?))*}}" }
//@ [DISABLE_SVE] compile-flags: -C target-feature=-sve -Copt-level=0 //@ [DISABLE_SVE] compile-flags: -C target-feature=-sve -Copt-level=0
// DISABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(-sve,?)|(\+neon,?))*}}" } // DISABLE_SVE: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)|(\+fpmr,?)?|(-sve,?)|(\+neon,?))*}}" }
//@ [DISABLE_NEON] compile-flags: -C target-feature=-neon -Copt-level=0 //@ [DISABLE_NEON] compile-flags: -C target-feature=-neon -Copt-level=0
// DISABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(-fp-armv8,?)|(-neon,?))*}}" } // DISABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)|(\+fpmr,?)?|(-fp-armv8,?)|(-neon,?))*}}" }
//@ [ENABLE_NEON] compile-flags: -C target-feature=+neon -Copt-level=0 //@ [ENABLE_NEON] compile-flags: -C target-feature=+neon -Copt-level=0
// ENABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)?|(\+fp-armv8,?)|(\+neon,?))*}}" } // ENABLE_NEON: attributes #0 = { {{.*}} "target-features"="{{((\+outline-atomics,?)|(\+v8a,?)|(\+fpmr,?)?|(\+fp-armv8,?)|(\+neon,?))*}}" }
#![feature(no_core, lang_items)] #![feature(no_core, lang_items)]
#![no_core] #![no_core]

View file

@ -251,7 +251,7 @@ warning: unexpected `cfg` condition value: `zebra`
LL | cfg!(target_feature = "zebra"); LL | cfg!(target_feature = "zebra");
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 201 more = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, and `avx512vpopcntdq` and 239 more
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
warning: 27 warnings emitted warning: 27 warnings emitted

View file

@ -165,7 +165,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
LL | target_feature = "_UNEXPECTED_VALUE", LL | target_feature = "_UNEXPECTED_VALUE",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `fcma`, `fdivdu`, `fhm`, `flagm`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lsx`, `lvz`, `lzcnt`, `m`, `mclass`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sha512`, `sign-ext`, `simd128`, `sm3`, `sm4`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `sve`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt` = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `cssc`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `ecv`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `faminmax`, `fcma`, `fdivdu`, `fhm`, `flagm`, `flagm2`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fp8`, `fp8dot2`, `fp8dot4`, `fp8fma`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `hbc`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lse128`, `lse2`, `lsx`, `lut`, `lvz`, `lzcnt`, `m`, `mclass`, `mops`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rcpc3`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sha512`, `sign-ext`, `simd128`, `sm3`, `sm4`, `sme`, `sme-f16f16`, `sme-f64f64`, `sme-f8f16`, `sme-f8f32`, `sme-fa64`, `sme-i16i64`, `sme-lutv2`, `sme2`, `sme2p1`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `ssve-fp8dot2`, `ssve-fp8dot4`, `ssve-fp8fma`, `sve`, `sve-b16b16`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `sve2p1`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `v8.8a`, `v8.9a`, `v9.1a`, `v9.2a`, `v9.3a`, `v9.4a`, `v9.5a`, `v9a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `wfxt`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`

View file

@ -20,3 +20,9 @@ where
data: &'a mut T, data: &'a mut T,
x: core::marker::PhantomData<X>, x: core::marker::PhantomData<X>,
} }
#[derive(SmartPointer)]
#[repr(transparent)]
struct MyPointerWithoutPointee<'a, T: ?Sized> {
ptr: &'a T,
}

View file

@ -42,3 +42,18 @@ impl<'a, Y, Z: MyTrait<T> + MyTrait<__S>, T: ?Sized + MyTrait<T> +
MyTrait<__S>> ::core::ops::CoerceUnsized<MyPointer2<'a, Y, Z, __S, X>> for MyTrait<__S>> ::core::ops::CoerceUnsized<MyPointer2<'a, Y, Z, __S, X>> for
MyPointer2<'a, Y, Z, T, X> where Y: MyTrait<T>, Y: MyTrait<__S> { MyPointer2<'a, Y, Z, T, X> where Y: MyTrait<T>, Y: MyTrait<__S> {
} }
#[repr(transparent)]
struct MyPointerWithoutPointee<'a, T: ?Sized> {
ptr: &'a T,
}
#[automatically_derived]
impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized>
::core::ops::DispatchFromDyn<MyPointerWithoutPointee<'a, __S>> for
MyPointerWithoutPointee<'a, T> {
}
#[automatically_derived]
impl<'a, T: ?Sized + ::core::marker::Unsize<__S>, __S: ?Sized>
::core::ops::CoerceUnsized<MyPointerWithoutPointee<'a, __S>> for
MyPointerWithoutPointee<'a, T> {
}

View file

@ -9,13 +9,6 @@ enum NotStruct<'a, T: ?Sized> {
Variant(&'a T), Variant(&'a T),
} }
#[derive(SmartPointer)]
//~^ ERROR: At least one generic type should be designated as `#[pointee]` in order to derive `SmartPointer` traits
#[repr(transparent)]
struct NoPointee<'a, T: ?Sized> {
ptr: &'a T,
}
#[derive(SmartPointer)] #[derive(SmartPointer)]
//~^ ERROR: `SmartPointer` can only be derived on `struct`s with at least one field //~^ ERROR: `SmartPointer` can only be derived on `struct`s with at least one field
#[repr(transparent)] #[repr(transparent)]
@ -30,6 +23,23 @@ struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
//~^ ERROR: lifetime parameter `'a` is never used //~^ ERROR: lifetime parameter `'a` is never used
//~| ERROR: type parameter `T` is never used //~| ERROR: type parameter `T` is never used
#[derive(SmartPointer)]
//~^ ERROR: `SmartPointer` can only be derived on `struct`s that are generic over at least one type
#[repr(transparent)]
struct NoGeneric<'a>(&'a u8);
#[derive(SmartPointer)]
//~^ ERROR: exactly one generic type parameter must be marked as #[pointee] to derive SmartPointer traits
#[repr(transparent)]
struct AmbiguousPointee<'a, T1: ?Sized, T2: ?Sized> {
a: (&'a T1, &'a T2),
}
#[derive(SmartPointer)]
#[repr(transparent)]
struct TooManyPointees<'a, #[pointee] A: ?Sized, #[pointee] B: ?Sized>((&'a A, &'a B));
//~^ ERROR: only one type parameter can be marked as `#[pointee]` when deriving SmartPointer traits
#[derive(SmartPointer)] #[derive(SmartPointer)]
//~^ ERROR: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]` //~^ ERROR: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`
struct NotTransparent<'a, #[pointee] T: ?Sized> { struct NotTransparent<'a, #[pointee] T: ?Sized> {

View file

@ -6,7 +6,7 @@ LL | #[derive(SmartPointer)]
| |
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
error: At least one generic type should be designated as `#[pointee]` in order to derive `SmartPointer` traits error: `SmartPointer` can only be derived on `struct`s with at least one field
--> $DIR/deriving-smart-pointer-neg.rs:12:10 --> $DIR/deriving-smart-pointer-neg.rs:12:10
| |
LL | #[derive(SmartPointer)] LL | #[derive(SmartPointer)]
@ -22,7 +22,7 @@ LL | #[derive(SmartPointer)]
| |
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
error: `SmartPointer` can only be derived on `struct`s with at least one field error: `SmartPointer` can only be derived on `struct`s that are generic over at least one type
--> $DIR/deriving-smart-pointer-neg.rs:26:10 --> $DIR/deriving-smart-pointer-neg.rs:26:10
| |
LL | #[derive(SmartPointer)] LL | #[derive(SmartPointer)]
@ -30,8 +30,22 @@ LL | #[derive(SmartPointer)]
| |
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
error: exactly one generic type parameter must be marked as #[pointee] to derive SmartPointer traits
--> $DIR/deriving-smart-pointer-neg.rs:31:10
|
LL | #[derive(SmartPointer)]
| ^^^^^^^^^^^^
|
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
error: only one type parameter can be marked as `#[pointee]` when deriving SmartPointer traits
--> $DIR/deriving-smart-pointer-neg.rs:40:39
|
LL | struct TooManyPointees<'a, #[pointee] A: ?Sized, #[pointee] B: ?Sized>((&'a A, &'a B));
| ^ ^
error: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]` error: `SmartPointer` can only be derived on `struct`s with `#[repr(transparent)]`
--> $DIR/deriving-smart-pointer-neg.rs:33:10 --> $DIR/deriving-smart-pointer-neg.rs:43:10
| |
LL | #[derive(SmartPointer)] LL | #[derive(SmartPointer)]
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
@ -39,13 +53,13 @@ LL | #[derive(SmartPointer)]
= note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the derive macro `SmartPointer` (in Nightly builds, run with -Z macro-backtrace for more info)
error: `derive(SmartPointer)` requires T to be marked `?Sized` error: `derive(SmartPointer)` requires T to be marked `?Sized`
--> $DIR/deriving-smart-pointer-neg.rs:41:36 --> $DIR/deriving-smart-pointer-neg.rs:51:36
| |
LL | struct NoMaybeSized<'a, #[pointee] T> { LL | struct NoMaybeSized<'a, #[pointee] T> {
| ^ | ^
error[E0392]: lifetime parameter `'a` is never used error[E0392]: lifetime parameter `'a` is never used
--> $DIR/deriving-smart-pointer-neg.rs:22:16 --> $DIR/deriving-smart-pointer-neg.rs:15:16
| |
LL | struct NoField<'a, #[pointee] T: ?Sized> {} LL | struct NoField<'a, #[pointee] T: ?Sized> {}
| ^^ unused lifetime parameter | ^^ unused lifetime parameter
@ -53,7 +67,7 @@ LL | struct NoField<'a, #[pointee] T: ?Sized> {}
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
error[E0392]: type parameter `T` is never used error[E0392]: type parameter `T` is never used
--> $DIR/deriving-smart-pointer-neg.rs:22:31 --> $DIR/deriving-smart-pointer-neg.rs:15:31
| |
LL | struct NoField<'a, #[pointee] T: ?Sized> {} LL | struct NoField<'a, #[pointee] T: ?Sized> {}
| ^ unused type parameter | ^ unused type parameter
@ -61,7 +75,7 @@ LL | struct NoField<'a, #[pointee] T: ?Sized> {}
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
error[E0392]: lifetime parameter `'a` is never used error[E0392]: lifetime parameter `'a` is never used
--> $DIR/deriving-smart-pointer-neg.rs:29:20 --> $DIR/deriving-smart-pointer-neg.rs:22:20
| |
LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>(); LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
| ^^ unused lifetime parameter | ^^ unused lifetime parameter
@ -69,13 +83,13 @@ LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
error[E0392]: type parameter `T` is never used error[E0392]: type parameter `T` is never used
--> $DIR/deriving-smart-pointer-neg.rs:29:35 --> $DIR/deriving-smart-pointer-neg.rs:22:35
| |
LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>(); LL | struct NoFieldUnit<'a, #[pointee] T: ?Sized>();
| ^ unused type parameter | ^ unused type parameter
| |
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
error: aborting due to 10 previous errors error: aborting due to 12 previous errors
For more information about this error, try `rustc --explain E0392`. For more information about this error, try `rustc --explain E0392`.

View file

@ -0,0 +1,8 @@
#![crate_name = "time"]
fn main() {
let items = Box::new(vec![]); //~ ERROR E0282
//~^ NOTE type must be known at this point
//~| NOTE this is an inference error on crate `time` caused by an API change in Rust 1.80.0; update `time` to version `>=0.3.35`
items.into();
}

View file

@ -0,0 +1,11 @@
error[E0282]: type annotations needed for `Box<Vec<_>>`
--> $DIR/detect-old-time-version-format_description-parse.rs:4:9
|
LL | let items = Box::new(vec![]);
| ^^^^^ ---------------- type must be known at this point
|
= note: this is an inference error on crate `time` caused by an API change in Rust 1.80.0; update `time` to version `>=0.3.35` by calling `cargo update`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0282`.

View file

@ -17,6 +17,7 @@
// gate-test-ermsb_target_feature // gate-test-ermsb_target_feature
// gate-test-bpf_target_feature // gate-test-bpf_target_feature
// gate-test-aarch64_ver_target_feature // gate-test-aarch64_ver_target_feature
// gate-test-aarch64_unstable_target_feature
// gate-test-csky_target_feature // gate-test-csky_target_feature
// gate-test-loongarch_target_feature // gate-test-loongarch_target_feature
// gate-test-lahfsahf_target_feature // gate-test-lahfsahf_target_feature

View file

@ -1,5 +1,5 @@
error[E0658]: the target feature `avx512bw` is currently unstable error[E0658]: the target feature `avx512bw` is currently unstable
--> $DIR/gate.rs:26:18 --> $DIR/gate.rs:27:18
| |
LL | #[target_feature(enable = "avx512bw")] LL | #[target_feature(enable = "avx512bw")]
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^

View file

@ -6,8 +6,8 @@
use std::thread; use std::thread;
fn child2(_s: String) { } fn child2(_s: String) {}
pub fn main() { pub fn main() {
let _x = thread::spawn(move|| child2("hi".to_string())); let _x = thread::spawn(move || child2("hi".to_string()));
} }

View file

@ -7,14 +7,15 @@ use std::thread;
struct Pair { struct Pair {
a: isize, a: isize,
b: isize b: isize,
} }
pub fn main() { pub fn main() {
let z: Box<_> = Box::new(Pair { a : 10, b : 12}); let z: Box<_> = Box::new(Pair { a: 10, b: 12 });
thread::spawn(move|| { thread::spawn(move || {
assert_eq!(z.a, 10); assert_eq!(z.a, 10);
assert_eq!(z.b, 12); assert_eq!(z.b, 12);
}).join(); })
.join();
} }

View file

@ -2,12 +2,12 @@
#![allow(unused_must_use)] #![allow(unused_must_use)]
//@ needs-threads //@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender}; use std::sync::mpsc::{channel, Sender};
use std::thread;
pub fn main() { pub fn main() {
let (tx, rx) = channel(); let (tx, rx) = channel();
let t = thread::spawn(move || { child(&tx) }); let t = thread::spawn(move || child(&tx));
let y = rx.recv().unwrap(); let y = rx.recv().unwrap();
println!("received"); println!("received");
println!("{}", y); println!("{}", y);

View file

@ -2,14 +2,15 @@
//@ needs-threads //@ needs-threads
//@ ignore-sgx no processes //@ ignore-sgx no processes
use std::thread;
use std::env;
use std::process::Command; use std::process::Command;
use std::{env, thread};
struct Handle(i32); struct Handle(i32);
impl Drop for Handle { impl Drop for Handle {
fn drop(&mut self) { panic!(); } fn drop(&mut self) {
panic!();
}
} }
thread_local!(static HANDLE: Handle = Handle(0)); thread_local!(static HANDLE: Handle = Handle(0));
@ -19,14 +20,15 @@ fn main() {
if args.len() == 1 { if args.len() == 1 {
let out = Command::new(&args[0]).arg("test").output().unwrap(); let out = Command::new(&args[0]).arg("test").output().unwrap();
let stderr = std::str::from_utf8(&out.stderr).unwrap(); let stderr = std::str::from_utf8(&out.stderr).unwrap();
assert!(stderr.contains("explicit panic"), assert!(stderr.contains("explicit panic"), "bad failure message:\n{}\n", stderr);
"bad failure message:\n{}\n", stderr);
} else { } else {
// TLS dtors are not always run on process exit // TLS dtors are not always run on process exit
thread::spawn(|| { thread::spawn(|| {
HANDLE.with(|h| { HANDLE.with(|h| {
println!("{}", h.0); println!("{}", h.0);
}); });
}).join().unwrap(); })
.join()
.unwrap();
} }
} }

View file

@ -19,5 +19,7 @@ fn main() {
thread::spawn(|| { thread::spawn(|| {
FOO.with(|_| {}); FOO.with(|_| {});
println!("test1"); println!("test1");
}).join().unwrap(); })
.join()
.unwrap();
} }

View file

@ -9,7 +9,10 @@ pub fn main() {
tx.send("hello, world").unwrap(); tx.send("hello, world").unwrap();
thread::spawn(move|| { thread::spawn(move || {
println!("{}", rx.recv().unwrap()); println!("{}", rx.recv().unwrap());
}).join().ok().unwrap(); })
.join()
.ok()
.unwrap();
} }

View file

@ -7,7 +7,7 @@ use std::thread;
pub fn main() { pub fn main() {
let (tx, rx) = channel::<&'static str>(); let (tx, rx) = channel::<&'static str>();
let t = thread::spawn(move|| { let t = thread::spawn(move || {
assert_eq!(rx.recv().unwrap(), "hello, world"); assert_eq!(rx.recv().unwrap(), "hello, world");
}); });

View file

@ -1,12 +1,12 @@
//@ run-pass //@ run-pass
//@ needs-threads //@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Receiver}; use std::sync::mpsc::{channel, Receiver};
use std::thread;
fn periodical(n: isize) -> Receiver<bool> { fn periodical(n: isize) -> Receiver<bool> {
let (chan, port) = channel(); let (chan, port) = channel();
thread::spawn(move|| { thread::spawn(move || {
loop { loop {
for _ in 1..n { for _ in 1..n {
match chan.send(false) { match chan.send(false) {
@ -16,7 +16,7 @@ fn periodical(n: isize) -> Receiver<bool> {
} }
match chan.send(true) { match chan.send(true) {
Ok(()) => {} Ok(()) => {}
Err(..) => break Err(..) => break,
} }
} }
}); });
@ -25,7 +25,7 @@ fn periodical(n: isize) -> Receiver<bool> {
fn integers() -> Receiver<isize> { fn integers() -> Receiver<isize> {
let (chan, port) = channel(); let (chan, port) = channel();
thread::spawn(move|| { thread::spawn(move || {
let mut i = 1; let mut i = 1;
loop { loop {
match chan.send(i) { match chan.send(i) {
@ -47,7 +47,7 @@ fn main() {
(_, true, true) => println!("FizzBuzz"), (_, true, true) => println!("FizzBuzz"),
(_, true, false) => println!("Fizz"), (_, true, false) => println!("Fizz"),
(_, false, true) => println!("Buzz"), (_, false, true) => println!("Buzz"),
(i, false, false) => println!("{}", i) (i, false, false) => println!("{}", i),
} }
} }
} }

View file

@ -3,12 +3,12 @@
#![allow(deprecated)] #![allow(deprecated)]
//@ needs-threads //@ needs-threads
use std::sync::mpsc::{TryRecvError, channel}; use std::sync::mpsc::{channel, TryRecvError};
use std::thread; use std::thread;
pub fn main() { pub fn main() {
let (tx, rx) = channel(); let (tx, rx) = channel();
let t = thread::spawn(move||{ let t = thread::spawn(move || {
thread::sleep_ms(10); thread::sleep_ms(10);
tx.send(()).unwrap(); tx.send(()).unwrap();
}); });
@ -16,7 +16,7 @@ pub fn main() {
match rx.try_recv() { match rx.try_recv() {
Ok(()) => break, Ok(()) => break,
Err(TryRecvError::Empty) => {} Err(TryRecvError::Empty) => {}
Err(TryRecvError::Disconnected) => unreachable!() Err(TryRecvError::Disconnected) => unreachable!(),
} }
} }
t.join(); t.join();

View file

@ -2,18 +2,12 @@
//@ compile-flags:--test //@ compile-flags:--test
//@ needs-threads //@ needs-threads
use std::sync::mpsc::channel; use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::TryRecvError; use std::sync::mpsc::{channel, RecvError, RecvTimeoutError, TryRecvError};
use std::sync::mpsc::RecvError;
use std::sync::mpsc::RecvTimeoutError;
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
/// Simple thread synchronization utility /// Simple thread synchronization utility
struct Barrier { struct Barrier {
// Not using mutex/condvar for precision // Not using mutex/condvar for precision
@ -42,7 +36,6 @@ impl Barrier {
} }
} }
fn shared_close_sender_does_not_lose_messages_iter() { fn shared_close_sender_does_not_lose_messages_iter() {
let (tb, rb) = Barrier::new2(); let (tb, rb) = Barrier::new2();
@ -71,7 +64,6 @@ fn shared_close_sender_does_not_lose_messages() {
}); });
} }
// https://github.com/rust-lang/rust/issues/39364 // https://github.com/rust-lang/rust/issues/39364
fn concurrent_recv_timeout_and_upgrade_iter() { fn concurrent_recv_timeout_and_upgrade_iter() {
// 1 us // 1 us
@ -85,8 +77,8 @@ fn concurrent_recv_timeout_and_upgrade_iter() {
match rx.recv_timeout(sleep) { match rx.recv_timeout(sleep) {
Ok(_) => { Ok(_) => {
break; break;
}, }
Err(_) => {}, Err(_) => {}
} }
} }
}); });
@ -105,7 +97,6 @@ fn concurrent_recv_timeout_and_upgrade() {
}); });
} }
fn concurrent_writes_iter() { fn concurrent_writes_iter() {
const THREADS: usize = 4; const THREADS: usize = 4;
const PER_THR: usize = 100; const PER_THR: usize = 100;

View file

@ -1,12 +1,13 @@
//@ run-pass //@ run-pass
#![allow(unused_imports)] #![allow(unused_imports)]
use std::thread;
use std::sync::Mutex; use std::sync::Mutex;
use std::thread;
fn par_for<I, F>(iter: I, f: F) fn par_for<I, F>(iter: I, f: F)
where I: Iterator, where
I::Item: Send, I: Iterator,
F: Fn(I::Item) + Sync I::Item: Send,
F: Fn(I::Item) + Sync,
{ {
for item in iter { for item in iter {
f(item) f(item)
@ -15,9 +16,7 @@ fn par_for<I, F>(iter: I, f: F)
fn sum(x: &[i32]) { fn sum(x: &[i32]) {
let sum_lengths = Mutex::new(0); let sum_lengths = Mutex::new(0);
par_for(x.windows(4), |x| { par_for(x.windows(4), |x| *sum_lengths.lock().unwrap() += x.len());
*sum_lengths.lock().unwrap() += x.len()
});
assert_eq!(*sum_lengths.lock().unwrap(), (x.len() - 3) * 4); assert_eq!(*sum_lengths.lock().unwrap(), (x.len() - 3) * 4);
} }
@ -26,9 +25,7 @@ fn main() {
let mut elements = [0; 20]; let mut elements = [0; 20];
// iterators over references into this stack frame // iterators over references into this stack frame
par_for(elements.iter_mut().enumerate(), |(i, x)| { par_for(elements.iter_mut().enumerate(), |(i, x)| *x = i as i32);
*x = i as i32
});
sum(&elements) sum(&elements)
} }

View file

@ -6,11 +6,11 @@
//@ pretty-expanded FIXME #23616 //@ pretty-expanded FIXME #23616
//@ needs-threads //@ needs-threads
use std::thread;
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
use std::thread;
struct test { struct test {
f: isize, f: isize,
} }
impl Drop for test { impl Drop for test {
@ -18,15 +18,13 @@ impl Drop for test {
} }
fn test(f: isize) -> test { fn test(f: isize) -> test {
test { test { f: f }
f: f
}
} }
pub fn main() { pub fn main() {
let (tx, rx) = channel(); let (tx, rx) = channel();
let t = thread::spawn(move|| { let t = thread::spawn(move || {
let (tx2, rx2) = channel(); let (tx2, rx2) = channel();
tx.send(tx2).unwrap(); tx.send(tx2).unwrap();

View file

@ -9,11 +9,11 @@ use std::sync::mpsc::{channel, Sender};
// tests that ctrl's type gets inferred properly // tests that ctrl's type gets inferred properly
struct Command<K, V> { struct Command<K, V> {
key: K, key: K,
val: V val: V,
} }
fn cache_server<K:Send+'static,V:Send+'static>(mut tx: Sender<Sender<Command<K, V>>>) { fn cache_server<K: Send + 'static, V: Send + 'static>(mut tx: Sender<Sender<Command<K, V>>>) {
let (tx1, _rx) = channel(); let (tx1, _rx) = channel();
tx.send(tx1); tx.send(tx1);
} }
pub fn main() { } pub fn main() {}

View file

@ -1,9 +1,7 @@
//@ run-pass //@ run-pass
use std::collections::HashMap;
use std::borrow::Cow; use std::borrow::Cow;
use std::borrow::Cow::{Borrowed as B, Owned as O};
use std::borrow::Cow::Borrowed as B; use std::collections::HashMap;
use std::borrow::Cow::Owned as O;
type SendStr = Cow<'static, str>; type SendStr = Cow<'static, str>;

View file

@ -1,8 +1,7 @@
//@ run-pass //@ run-pass
use std::collections::BTreeMap;
use std::borrow::Cow; use std::borrow::Cow;
use std::borrow::Cow::{Borrowed as B, Owned as O};
use std::borrow::Cow::{Owned as O, Borrowed as B}; use std::collections::BTreeMap;
type SendStr = Cow<'static, str>; type SendStr = Cow<'static, str>;
@ -51,8 +50,8 @@ fn main() {
assert_eq!(map.get(&O("def".to_string())), Some(&d)); assert_eq!(map.get(&O("def".to_string())), Some(&d));
assert!(map.remove(&B("foo")).is_some()); assert!(map.remove(&B("foo")).is_some());
assert_eq!(map.into_iter().map(|(k, v)| format!("{}{}", k, v)) assert_eq!(
.collect::<Vec<String>>() map.into_iter().map(|(k, v)| format!("{}{}", k, v)).collect::<Vec<String>>().concat(),
.concat(), "abc50bcd51cde52def53".to_string()
"abc50bcd51cde52def53".to_string()); );
} }

View file

@ -11,15 +11,12 @@
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
struct foo { struct foo {
i: isize, i: isize,
j: char, j: char,
} }
fn foo(i:isize, j: char) -> foo { fn foo(i: isize, j: char) -> foo {
foo { foo { i: i, j: j }
i: i,
j: j
}
} }
pub fn main() { pub fn main() {

View file

@ -1,7 +1,9 @@
//@ run-pass //@ run-pass
fn test<F>(f: F) -> usize
fn test<F>(f: F) -> usize where F: FnOnce(usize) -> usize { where
F: FnOnce(usize) -> usize,
{
return f(22); return f(22);
} }

View file

@ -3,19 +3,24 @@
use std::thread; use std::thread;
pub fn main() { test05(); } pub fn main() {
test05();
}
fn test05_start<F:FnOnce(isize)>(f: F) { fn test05_start<F: FnOnce(isize)>(f: F) {
f(22); f(22);
} }
fn test05() { fn test05() {
let three: Box<_> = Box::new(3); let three: Box<_> = Box::new(3);
let fn_to_send = move|n:isize| { let fn_to_send = move |n: isize| {
println!("{}", *three + n); // will copy x into the closure println!("{}", *three + n); // will copy x into the closure
assert_eq!(*three, 3); assert_eq!(*three, 3);
}; };
thread::spawn(move|| { thread::spawn(move || {
test05_start(fn_to_send); test05_start(fn_to_send);
}).join().ok().unwrap(); })
.join()
.ok()
.unwrap();
} }

View file

@ -10,9 +10,9 @@ fn x(s: String, n: isize) {
} }
pub fn main() { pub fn main() {
let t1 = thread::spawn(|| x("hello from first spawned fn".to_string(), 65) ); let t1 = thread::spawn(|| x("hello from first spawned fn".to_string(), 65));
let t2 = thread::spawn(|| x("hello from second spawned fn".to_string(), 66) ); let t2 = thread::spawn(|| x("hello from second spawned fn".to_string(), 66));
let t3 = thread::spawn(|| x("hello from third spawned fn".to_string(), 67) ); let t3 = thread::spawn(|| x("hello from third spawned fn".to_string(), 67));
let mut i = 30; let mut i = 30;
while i > 0 { while i > 0 {
i = i - 1; i = i - 1;

View file

@ -4,13 +4,13 @@
//@ needs-threads //@ needs-threads
/* /*
Make sure we can spawn tasks that take different types of Make sure we can spawn tasks that take different types of
parameters. This is based on a test case for #520 provided by Rob parameters. This is based on a test case for #520 provided by Rob
Arnold. Arnold.
*/ */
use std::thread;
use std::sync::mpsc::{channel, Sender}; use std::sync::mpsc::{channel, Sender};
use std::thread;
type ctx = Sender<isize>; type ctx = Sender<isize>;
@ -20,6 +20,6 @@ fn iotask(_tx: &ctx, ip: String) {
pub fn main() { pub fn main() {
let (tx, _rx) = channel::<isize>(); let (tx, _rx) = channel::<isize>();
let t = thread::spawn(move|| iotask(&tx, "localhost".to_string()) ); let t = thread::spawn(move || iotask(&tx, "localhost".to_string()));
t.join().ok().unwrap(); t.join().ok().unwrap();
} }

View file

@ -4,7 +4,10 @@
use std::thread; use std::thread;
pub fn main() { pub fn main() {
thread::spawn(move|| child(10)).join().ok().unwrap(); thread::spawn(move || child(10)).join().ok().unwrap();
} }
fn child(i: isize) { println!("{}", i); assert_eq!(i, 10); } fn child(i: isize) {
println!("{}", i);
assert_eq!(i, 10);
}

View file

@ -4,7 +4,7 @@
use std::thread; use std::thread;
pub fn main() { pub fn main() {
let t = thread::spawn(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); let t = thread::spawn(move || child((10, 20, 30, 40, 50, 60, 70, 80, 90)));
t.join().ok().unwrap(); // forget Err value, since it doesn't implement Debug t.join().ok().unwrap(); // forget Err value, since it doesn't implement Debug
} }

View file

@ -6,8 +6,16 @@
use std::net::ToSocketAddrs; use std::net::ToSocketAddrs;
fn is_sync<T>(_: T) where T: Sync {} fn is_sync<T>(_: T)
fn is_send<T>(_: T) where T: Send {} where
T: Sync,
{
}
fn is_send<T>(_: T)
where
T: Send,
{
}
macro_rules! all_sync_send { macro_rules! all_sync_send {
($ctor:expr, $($iter:ident),+) => ({ ($ctor:expr, $($iter:ident),+) => ({

View file

@ -3,18 +3,20 @@
#![allow(warnings)] #![allow(warnings)]
#![feature(drain, collections_bound, btree_range)] #![feature(drain, collections_bound, btree_range)]
use std::collections::BinaryHeap; use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use std::collections::{BTreeMap, BTreeSet};
use std::collections::LinkedList;
use std::collections::VecDeque;
use std::collections::HashMap;
use std::collections::HashSet;
use std::mem; use std::mem;
use std::ops::Bound::Included; use std::ops::Bound::Included;
fn is_sync<T>(_: T) where T: Sync {} fn is_sync<T>(_: T)
fn is_send<T>(_: T) where T: Send {} where
T: Sync,
{
}
fn is_send<T>(_: T)
where
T: Send,
{
}
macro_rules! all_sync_send { macro_rules! all_sync_send {
($ctor:expr, $($iter:ident),+) => ({ ($ctor:expr, $($iter:ident),+) => ({

View file

@ -5,8 +5,16 @@
use std::iter::{empty, once, repeat}; use std::iter::{empty, once, repeat};
fn is_sync<T>(_: T) where T: Sync {} fn is_sync<T>(_: T)
fn is_send<T>(_: T) where T: Send {} where
T: Sync,
{
}
fn is_send<T>(_: T)
where
T: Send,
{
}
macro_rules! all_sync_send { macro_rules! all_sync_send {
($ctor:expr, $iter:ident) => ({ ($ctor:expr, $iter:ident) => ({
@ -43,12 +51,12 @@ macro_rules! all_sync_send_mutable_ref {
} }
macro_rules! is_sync_send { macro_rules! is_sync_send {
($ctor:expr) => ({ ($ctor:expr) => {{
let x = $ctor; let x = $ctor;
is_sync(x); is_sync(x);
let y = $ctor; let y = $ctor;
is_send(y); is_send(y);
}) }};
} }
fn main() { fn main() {
@ -63,24 +71,26 @@ fn main() {
let a = [1]; let a = [1];
let b = [2]; let b = [2];
all_sync_send!(a.iter(), all_sync_send!(
cloned, a.iter(),
cycle, cloned,
chain([2].iter()), cycle,
zip([2].iter()), chain([2].iter()),
map(|_| 1), zip([2].iter()),
filter(|_| true), map(|_| 1),
filter_map(|_| Some(1)), filter(|_| true),
enumerate, filter_map(|_| Some(1)),
peekable, enumerate,
skip_while(|_| true), peekable,
take_while(|_| true), skip_while(|_| true),
skip(1), take_while(|_| true),
take(1), skip(1),
scan(1, |_, _| Some(1)), take(1),
flat_map(|_| b.iter()), scan(1, |_, _| Some(1)),
fuse, flat_map(|_| b.iter()),
inspect(|_| ())); fuse,
inspect(|_| ())
);
is_sync_send!((1..).step_by(2)); is_sync_send!((1..).step_by(2));
is_sync_send!((1..2).step_by(2)); is_sync_send!((1..2).step_by(2));

View file

@ -2,12 +2,14 @@
#![allow(unused_must_use)] #![allow(unused_must_use)]
//@ needs-threads //@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender}; use std::sync::mpsc::{channel, Sender};
use std::thread;
pub fn main() { test05(); } pub fn main() {
test05();
}
fn test05_start(tx : &Sender<isize>) { fn test05_start(tx: &Sender<isize>) {
tx.send(10).unwrap(); tx.send(10).unwrap();
println!("sent 10"); println!("sent 10");
tx.send(20).unwrap(); tx.send(20).unwrap();
@ -18,7 +20,7 @@ fn test05_start(tx : &Sender<isize>) {
fn test05() { fn test05() {
let (tx, rx) = channel(); let (tx, rx) = channel();
let t = thread::spawn(move|| { test05_start(&tx) }); let t = thread::spawn(move || test05_start(&tx));
let mut value: isize = rx.recv().unwrap(); let mut value: isize = rx.recv().unwrap();
println!("{}", value); println!("{}", value);
value = rx.recv().unwrap(); value = rx.recv().unwrap();

View file

@ -4,11 +4,15 @@
use std::thread; use std::thread;
pub fn main() { test00(); } pub fn main() {
test00();
}
fn start() { println!("Started / Finished task."); } fn start() {
println!("Started / Finished task.");
}
fn test00() { fn test00() {
thread::spawn(move|| start() ).join(); thread::spawn(move || start()).join();
println!("Completing."); println!("Completing.");
} }

View file

@ -3,8 +3,8 @@
#![allow(unused_mut)] #![allow(unused_mut)]
//@ needs-threads //@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender}; use std::sync::mpsc::{channel, Sender};
use std::thread;
fn start(tx: &Sender<Sender<String>>) { fn start(tx: &Sender<Sender<String>>) {
let (tx2, rx) = channel(); let (tx2, rx) = channel();
@ -22,7 +22,7 @@ fn start(tx: &Sender<Sender<String>>) {
pub fn main() { pub fn main() {
let (tx, rx) = channel(); let (tx, rx) = channel();
let child = thread::spawn(move|| { start(&tx) }); let child = thread::spawn(move || start(&tx));
let mut c = rx.recv().unwrap(); let mut c = rx.recv().unwrap();
c.send("A".to_string()).unwrap(); c.send("A".to_string()).unwrap();

View file

@ -13,9 +13,7 @@ fn start(tx: &Sender<Sender<isize>>) {
pub fn main() { pub fn main() {
let (tx, rx) = channel(); let (tx, rx) = channel();
let child = thread::spawn(move|| { let child = thread::spawn(move || start(&tx));
start(&tx)
});
let _tx = rx.recv().unwrap(); let _tx = rx.recv().unwrap();
child.join(); child.join();
} }

View file

@ -5,15 +5,17 @@
use std::thread; use std::thread;
pub fn main() { test00(); } pub fn main() {
test00();
}
fn start(_task_number: isize) { println!("Started / Finished task."); } fn start(_task_number: isize) {
println!("Started / Finished task.");
}
fn test00() { fn test00() {
let i: isize = 0; let i: isize = 0;
let mut result = thread::spawn(move|| { let mut result = thread::spawn(move || start(i));
start(i)
});
// Sleep long enough for the thread to finish. // Sleep long enough for the thread to finish.
let mut i = 0_usize; let mut i = 0_usize;

View file

@ -7,12 +7,15 @@ use std::thread;
fn start(tx: &Sender<isize>, start: isize, number_of_messages: isize) { fn start(tx: &Sender<isize>, start: isize, number_of_messages: isize) {
let mut i: isize = 0; let mut i: isize = 0;
while i< number_of_messages { tx.send(start + i).unwrap(); i += 1; } while i < number_of_messages {
tx.send(start + i).unwrap();
i += 1;
}
} }
pub fn main() { pub fn main() {
println!("Check that we don't deadlock."); println!("Check that we don't deadlock.");
let (tx, rx) = channel(); let (tx, rx) = channel();
let _ = thread::spawn(move|| { start(&tx, 0, 10) }).join(); let _ = thread::spawn(move || start(&tx, 0, 10)).join();
println!("Joined task"); println!("Joined task");
} }

View file

@ -13,7 +13,10 @@ pub fn main() {
while (i > 0) { while (i > 0) {
println!("{}", i); println!("{}", i);
let tx = tx.clone(); let tx = tx.clone();
thread::spawn({let i = i; move|| { child(i, &tx) }}); thread::spawn({
let i = i;
move || child(i, &tx)
});
i = i - 1; i = i - 1;
} }

View file

@ -20,9 +20,7 @@ pub fn main() {
// the child's point of view the receiver may die. We should // the child's point of view the receiver may die. We should
// drop messages on the floor in this case, and not crash! // drop messages on the floor in this case, and not crash!
let (tx, rx) = channel(); let (tx, rx) = channel();
let t = thread::spawn(move|| { let t = thread::spawn(move || start(&tx, 10));
start(&tx, 10)
});
rx.recv(); rx.recv();
t.join(); t.join();
} }

View file

@ -3,15 +3,19 @@
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
use std::sync::mpsc::channel;
use std::cmp; use std::cmp;
use std::sync::mpsc::channel;
// Tests of ports and channels on various types // Tests of ports and channels on various types
fn test_rec() { fn test_rec() {
struct R {val0: isize, val1: u8, val2: char} struct R {
val0: isize,
val1: u8,
val2: char,
}
let (tx, rx) = channel(); let (tx, rx) = channel();
let r0: R = R {val0: 0, val1: 1, val2: '2'}; let r0: R = R { val0: 0, val1: 1, val2: '2' };
tx.send(r0).unwrap(); tx.send(r0).unwrap();
let mut r1: R; let mut r1: R;
r1 = rx.recv().unwrap(); r1 = rx.recv().unwrap();
@ -45,34 +49,29 @@ fn test_str() {
enum t { enum t {
tag1, tag1,
tag2(isize), tag2(isize),
tag3(isize, u8, char) tag3(isize, u8, char),
} }
impl cmp::PartialEq for t { impl cmp::PartialEq for t {
fn eq(&self, other: &t) -> bool { fn eq(&self, other: &t) -> bool {
match *self { match *self {
t::tag1 => { t::tag1 => match (*other) {
match (*other) { t::tag1 => true,
t::tag1 => true, _ => false,
_ => false },
} t::tag2(e0a) => match (*other) {
} t::tag2(e0b) => e0a == e0b,
t::tag2(e0a) => { _ => false,
match (*other) { },
t::tag2(e0b) => e0a == e0b, t::tag3(e0a, e1a, e2a) => match (*other) {
_ => false t::tag3(e0b, e1b, e2b) => e0a == e0b && e1a == e1b && e2a == e2b,
} _ => false,
} },
t::tag3(e0a, e1a, e2a) => {
match (*other) {
t::tag3(e0b, e1b, e2b) =>
e0a == e0b && e1a == e1b && e2a == e2b,
_ => false
}
}
} }
} }
fn ne(&self, other: &t) -> bool { !(*self).eq(other) } fn ne(&self, other: &t) -> bool {
!(*self).eq(other)
}
} }
fn test_tag() { fn test_tag() {

View file

@ -9,9 +9,8 @@
use std::thread; use std::thread;
fn f() { fn f() {}
}
pub fn main() { pub fn main() {
thread::spawn(move|| f() ).join(); thread::spawn(move || f()).join();
} }

View file

@ -2,10 +2,13 @@
#![allow(unused_must_use)] #![allow(unused_must_use)]
//@ needs-threads //@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender}; use std::sync::mpsc::{channel, Sender};
use std::thread;
pub fn main() { println!("===== WITHOUT THREADS ====="); test00(); } pub fn main() {
println!("===== WITHOUT THREADS =====");
test00();
}
fn test00_start(ch: &Sender<isize>, message: isize, count: isize) { fn test00_start(ch: &Sender<isize>, message: isize, count: isize) {
println!("Starting test00_start"); println!("Starting test00_start");
@ -34,9 +37,7 @@ fn test00() {
let tx = tx.clone(); let tx = tx.clone();
results.push(thread::spawn({ results.push(thread::spawn({
let i = i; let i = i;
move|| { move || test00_start(&tx, i, number_of_messages)
test00_start(&tx, i, number_of_messages)
}
})); }));
i = i + 1; i = i + 1;
} }
@ -53,7 +54,9 @@ fn test00() {
} }
// Join spawned threads... // Join spawned threads...
for r in results { r.join(); } for r in results {
r.join();
}
println!("Completed: Final number is: "); println!("Completed: Final number is: ");
println!("{}", sum); println!("{}", sum);

View file

@ -3,7 +3,9 @@
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
pub fn main() { test00(); } pub fn main() {
test00();
}
fn test00() { fn test00() {
let mut r: isize = 0; let mut r: isize = 0;

View file

@ -2,7 +2,9 @@
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
pub fn main() { test00(); } pub fn main() {
test00();
}
fn test00() { fn test00() {
let _r: isize = 0; let _r: isize = 0;
@ -10,8 +12,14 @@ fn test00() {
let (tx, rx) = channel(); let (tx, rx) = channel();
let number_of_messages: isize = 1000; let number_of_messages: isize = 1000;
let mut i: isize = 0; let mut i: isize = 0;
while i < number_of_messages { tx.send(i + 0).unwrap(); i += 1; } while i < number_of_messages {
tx.send(i + 0).unwrap();
i += 1;
}
i = 0; i = 0;
while i < number_of_messages { sum += rx.recv().unwrap(); i += 1; } while i < number_of_messages {
sum += rx.recv().unwrap();
i += 1;
}
assert_eq!(sum, number_of_messages * (number_of_messages - 1) / 2); assert_eq!(sum, number_of_messages * (number_of_messages - 1) / 2);
} }

View file

@ -4,7 +4,9 @@
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
pub fn main() { test00(); } pub fn main() {
test00();
}
fn test00() { fn test00() {
let mut r: isize = 0; let mut r: isize = 0;
@ -38,5 +40,4 @@ fn test00() {
assert_eq!(sum, 1998000); assert_eq!(sum, 1998000);
// assert (sum == 4 * ((number_of_messages * // assert (sum == 4 * ((number_of_messages *
// (number_of_messages - 1)) / 2)); // (number_of_messages - 1)) / 2));
} }

View file

@ -6,12 +6,16 @@
use std::sync::mpsc::{channel, Sender}; use std::sync::mpsc::{channel, Sender};
use std::thread; use std::thread;
pub fn main() { test00(); } pub fn main() {
test00();
}
fn test00_start(c: &Sender<isize>, start: isize, fn test00_start(c: &Sender<isize>, start: isize, number_of_messages: isize) {
number_of_messages: isize) {
let mut i: isize = 0; let mut i: isize = 0;
while i < number_of_messages { c.send(start + i).unwrap(); i += 1; } while i < number_of_messages {
c.send(start + i).unwrap();
i += 1;
}
} }
fn test00() { fn test00() {
@ -21,19 +25,19 @@ fn test00() {
let number_of_messages: isize = 10; let number_of_messages: isize = 10;
let tx2 = tx.clone(); let tx2 = tx.clone();
let t1 = thread::spawn(move|| { let t1 = thread::spawn(move || {
test00_start(&tx2, number_of_messages * 0, number_of_messages); test00_start(&tx2, number_of_messages * 0, number_of_messages);
}); });
let tx2 = tx.clone(); let tx2 = tx.clone();
let t2 = thread::spawn(move|| { let t2 = thread::spawn(move || {
test00_start(&tx2, number_of_messages * 1, number_of_messages); test00_start(&tx2, number_of_messages * 1, number_of_messages);
}); });
let tx2 = tx.clone(); let tx2 = tx.clone();
let t3 = thread::spawn(move|| { let t3 = thread::spawn(move || {
test00_start(&tx2, number_of_messages * 2, number_of_messages); test00_start(&tx2, number_of_messages * 2, number_of_messages);
}); });
let tx2 = tx.clone(); let tx2 = tx.clone();
let t4 = thread::spawn(move|| { let t4 = thread::spawn(move || {
test00_start(&tx2, number_of_messages * 3, number_of_messages); test00_start(&tx2, number_of_messages * 3, number_of_messages);
}); });

View file

@ -2,14 +2,19 @@
#![allow(unused_must_use)] #![allow(unused_must_use)]
//@ needs-threads //@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender}; use std::sync::mpsc::{channel, Sender};
use std::thread;
pub fn main() { test00(); } pub fn main() {
test00();
}
fn test00_start(c: &Sender<isize>, number_of_messages: isize) { fn test00_start(c: &Sender<isize>, number_of_messages: isize) {
let mut i: isize = 0; let mut i: isize = 0;
while i < number_of_messages { c.send(i + 0).unwrap(); i += 1; } while i < number_of_messages {
c.send(i + 0).unwrap();
i += 1;
}
} }
fn test00() { fn test00() {
@ -18,7 +23,7 @@ fn test00() {
let (tx, rx) = channel(); let (tx, rx) = channel();
let number_of_messages: isize = 10; let number_of_messages: isize = 10;
let result = thread::spawn(move|| { let result = thread::spawn(move || {
test00_start(&tx, number_of_messages); test00_start(&tx, number_of_messages);
}); });

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