diff options
637 files changed, 4003 insertions, 3840 deletions
diff --git a/Cargo.lock b/Cargo.lock index e93af7926a2..441ca1e6c2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4501,8 +4501,6 @@ dependencies = [ "rustc_abi", "rustc_data_structures", "rustc_hir", - "rustc_infer", - "rustc_macros", "rustc_middle", "rustc_span", "tracing", diff --git a/compiler/rustc_abi/src/callconv.rs b/compiler/rustc_abi/src/callconv.rs index 4529ab8058e..a21e1aee9b0 100644 --- a/compiler/rustc_abi/src/callconv.rs +++ b/compiler/rustc_abi/src/callconv.rs @@ -74,7 +74,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> { Ok(HomogeneousAggregate::Homogeneous(Reg { kind, size: self.size })) } - BackendRepr::Vector { .. } => { + BackendRepr::SimdVector { .. } => { assert!(!self.is_zst()); Ok(HomogeneousAggregate::Homogeneous(Reg { kind: RegKind::Vector, diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index 3f83787ea37..d3ae6a29f10 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -386,13 +386,15 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { BackendRepr::Memory { sized: true } } // Vectors require at least element alignment, else disable the opt - BackendRepr::Vector { element, count: _ } if element.align(dl).abi > align.abi => { + BackendRepr::SimdVector { element, count: _ } + if element.align(dl).abi > align.abi => + { BackendRepr::Memory { sized: true } } // the alignment tests passed and we can use this BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..) - | BackendRepr::Vector { .. } + | BackendRepr::SimdVector { .. } | BackendRepr::Memory { .. } => repr, }, }; @@ -464,7 +466,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { hide_niches(a); hide_niches(b); } - BackendRepr::Vector { element, count: _ } => hide_niches(element), + BackendRepr::SimdVector { element, count: _ } => hide_niches(element), BackendRepr::Memory { sized: _ } => {} } st.largest_niche = None; @@ -1314,7 +1316,9 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { match field.backend_repr { // For plain scalars, or vectors of them, we can't unpack // newtypes for `#[repr(C)]`, as that affects C ABIs. - BackendRepr::Scalar(_) | BackendRepr::Vector { .. } if optimize_abi => { + BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } + if optimize_abi => + { abi = field.backend_repr; } // But scalar pairs are Rust-specific and get diff --git a/compiler/rustc_abi/src/layout/ty.rs b/compiler/rustc_abi/src/layout/ty.rs index 221e990ae86..03f3f043c21 100644 --- a/compiler/rustc_abi/src/layout/ty.rs +++ b/compiler/rustc_abi/src/layout/ty.rs @@ -219,7 +219,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> { C: HasDataLayout, { match self.backend_repr { - BackendRepr::Vector { .. } => self.size == expected_size, + BackendRepr::SimdVector { .. } => self.size == expected_size, BackendRepr::Memory { .. } => { if self.fields.count() == 1 && self.fields.offset(0).bytes() == 0 { self.field(cx, 0).is_single_vector_element(cx, expected_size) diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 81e4e255f37..2197dd68eaf 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1410,7 +1410,7 @@ impl AddressSpace { pub enum BackendRepr { Scalar(Scalar), ScalarPair(Scalar, Scalar), - Vector { + SimdVector { element: Scalar, count: u64, }, @@ -1426,9 +1426,9 @@ impl BackendRepr { #[inline] pub fn is_unsized(&self) -> bool { match *self { - BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) | BackendRepr::Vector { .. } => { - false - } + BackendRepr::Scalar(_) + | BackendRepr::ScalarPair(..) + | BackendRepr::SimdVector { .. } => false, BackendRepr::Memory { sized } => !sized, } } @@ -1467,7 +1467,7 @@ impl BackendRepr { BackendRepr::Scalar(s) => Some(s.align(cx).abi), BackendRepr::ScalarPair(s1, s2) => Some(s1.align(cx).max(s2.align(cx)).abi), // The align of a Vector can vary in surprising ways - BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => None, + BackendRepr::SimdVector { .. } | BackendRepr::Memory { .. } => None, } } @@ -1489,7 +1489,7 @@ impl BackendRepr { Some(size) } // The size of a Vector can vary in surprising ways - BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => None, + BackendRepr::SimdVector { .. } | BackendRepr::Memory { .. } => None, } } @@ -1500,8 +1500,8 @@ impl BackendRepr { BackendRepr::ScalarPair(s1, s2) => { BackendRepr::ScalarPair(s1.to_union(), s2.to_union()) } - BackendRepr::Vector { element, count } => { - BackendRepr::Vector { element: element.to_union(), count } + BackendRepr::SimdVector { element, count } => { + BackendRepr::SimdVector { element: element.to_union(), count } } BackendRepr::Memory { .. } => BackendRepr::Memory { sized: true }, } @@ -1513,8 +1513,8 @@ impl BackendRepr { // We do *not* ignore the sign since it matters for some ABIs (e.g. s390x). (BackendRepr::Scalar(l), BackendRepr::Scalar(r)) => l.primitive() == r.primitive(), ( - BackendRepr::Vector { element: element_l, count: count_l }, - BackendRepr::Vector { element: element_r, count: count_r }, + BackendRepr::SimdVector { element: element_l, count: count_l }, + BackendRepr::SimdVector { element: element_r, count: count_r }, ) => element_l.primitive() == element_r.primitive() && count_l == count_r, (BackendRepr::ScalarPair(l1, l2), BackendRepr::ScalarPair(r1, r2)) => { l1.primitive() == r1.primitive() && l2.primitive() == r2.primitive() @@ -1735,7 +1735,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> { /// Returns `true` if this is an aggregate type (including a ScalarPair!) pub fn is_aggregate(&self) -> bool { match self.backend_repr { - BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => false, + BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => false, BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => true, } } @@ -1877,9 +1877,9 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> { /// non-trivial alignment constraints. You probably want to use `is_1zst` instead. pub fn is_zst(&self) -> bool { match self.backend_repr { - BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) | BackendRepr::Vector { .. } => { - false - } + BackendRepr::Scalar(_) + | BackendRepr::ScalarPair(..) + | BackendRepr::SimdVector { .. } => false, BackendRepr::Memory { sized } => sized && self.size.bytes() == 0, } } diff --git a/compiler/rustc_ast_lowering/messages.ftl b/compiler/rustc_ast_lowering/messages.ftl index 1b91c33742d..906fb213ee7 100644 --- a/compiler/rustc_ast_lowering/messages.ftl +++ b/compiler/rustc_ast_lowering/messages.ftl @@ -37,11 +37,11 @@ ast_lowering_bad_return_type_notation_inputs = .suggestion = remove the input types ast_lowering_bad_return_type_notation_needs_dots = return type notation arguments must be elided with `..` - .suggestion = add `..` + .suggestion = use the correct syntax by adding `..` to the arguments ast_lowering_bad_return_type_notation_output = return type not allowed with return type notation - .suggestion = remove the return type +ast_lowering_bad_return_type_notation_output_suggestion = use the right argument notation and remove the return type ast_lowering_bad_return_type_notation_position = return type notation not allowed in this position yet @@ -88,7 +88,7 @@ ast_lowering_invalid_abi_clobber_abi = invalid ABI for `clobber_abi` .note = the following ABIs are supported on this target: {$supported_abis} -ast_lowering_invalid_abi_suggestion = did you mean +ast_lowering_invalid_abi_suggestion = there's a similarly named valid ABI `{$suggestion}` ast_lowering_invalid_asm_template_modifier_const = asm template modifiers are not allowed for `const` arguments diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs index cfd32fc066f..87af7959a88 100644 --- a/compiler/rustc_ast_lowering/src/asm.rs +++ b/compiler/rustc_ast_lowering/src/asm.rs @@ -195,7 +195,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } InlineAsmOperand::Const { anon_const } => hir::InlineAsmOperand::Const { - anon_const: self.lower_anon_const_to_anon_const(anon_const), + anon_const: self.lower_const_block(anon_const), }, InlineAsmOperand::Sym { sym } => { let static_def_id = self diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index f31e2db051d..ceeb5dffbea 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -46,8 +46,9 @@ pub(crate) struct TupleStructWithDefault { #[derive(Subdiagnostic)] #[suggestion( ast_lowering_invalid_abi_suggestion, - code = "{suggestion}", - applicability = "maybe-incorrect" + code = "\"{suggestion}\"", + applicability = "maybe-incorrect", + style = "verbose" )] pub(crate) struct InvalidAbiSuggestion { #[primary_span] @@ -372,24 +373,39 @@ pub(crate) struct InclusiveRangeWithNoEnd { pub span: Span, } +#[derive(Subdiagnostic)] +#[multipart_suggestion( + ast_lowering_bad_return_type_notation_output_suggestion, + applicability = "machine-applicable", + style = "verbose" +)] +/// Given `T: Tr<m() -> Ret>` or `T: Tr<m(Ty) -> Ret>`, suggest `T: Tr<m(..)>`. +pub(crate) struct RTNSuggestion { + #[suggestion_part(code = "")] + pub output: Span, + #[suggestion_part(code = "(..)")] + pub input: Span, +} + #[derive(Diagnostic)] pub(crate) enum BadReturnTypeNotation { #[diag(ast_lowering_bad_return_type_notation_inputs)] Inputs { #[primary_span] - #[suggestion(code = "()", applicability = "maybe-incorrect")] + #[suggestion(code = "(..)", applicability = "machine-applicable", style = "verbose")] span: Span, }, #[diag(ast_lowering_bad_return_type_notation_output)] Output { #[primary_span] - #[suggestion(code = "", applicability = "maybe-incorrect")] span: Span, + #[subdiagnostic] + suggestion: RTNSuggestion, }, #[diag(ast_lowering_bad_return_type_notation_needs_dots)] NeedsDots { #[primary_span] - #[suggestion(code = "(..)", applicability = "maybe-incorrect")] + #[suggestion(code = "(..)", applicability = "machine-applicable", style = "verbose")] span: Span, }, #[diag(ast_lowering_bad_return_type_notation_position)] diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index efbd1711daa..9c3db7abc1c 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -671,10 +671,13 @@ impl<'hir> LoweringContext<'_, 'hir> { let span = self.lower_span(arm.span); self.lower_attrs(hir_id, &arm.attrs, arm.span); let is_never_pattern = pat.is_never_pattern(); - let body = if let Some(body) = &arm.body + // We need to lower the body even if it's unneeded for never pattern in match, + // ensure that we can get HirId for DefId if need (issue #137708). + let body = arm.body.as_ref().map(|x| self.lower_expr(x)); + let body = if let Some(body) = body && !is_never_pattern { - self.lower_expr(body) + body } else { // Either `body.is_none()` or `is_never_pattern` here. if !is_never_pattern { diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index a4fc4b3e3a1..15802101f71 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1510,7 +1510,7 @@ impl<'hir> LoweringContext<'_, 'hir> { span: abi.span, suggestion: suggested_name.map(|suggested_name| InvalidAbiSuggestion { span: abi.span, - suggestion: format!("\"{suggested_name}\""), + suggestion: suggested_name.to_string(), }), command: "rustc --print=calling-conventions".to_string(), }); diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 1c69937eed0..13edcc10c9e 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -926,19 +926,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { if let Some(first_char) = constraint.ident.as_str().chars().next() && first_char.is_ascii_lowercase() { - let mut err = if !data.inputs.is_empty() { - self.dcx().create_err(errors::BadReturnTypeNotation::Inputs { - span: data.inputs_span, - }) - } else if let FnRetTy::Ty(ty) = &data.output { - self.dcx().create_err(errors::BadReturnTypeNotation::Output { - span: data.inputs_span.shrink_to_hi().to(ty.span), - }) - } else { - self.dcx().create_err(errors::BadReturnTypeNotation::NeedsDots { - span: data.inputs_span, - }) + tracing::info!(?data, ?data.inputs); + let err = match (&data.inputs[..], &data.output) { + ([_, ..], FnRetTy::Default(_)) => { + errors::BadReturnTypeNotation::Inputs { span: data.inputs_span } + } + ([], FnRetTy::Default(_)) => { + errors::BadReturnTypeNotation::NeedsDots { span: data.inputs_span } + } + // The case `T: Trait<method(..) -> Ret>` is handled in the parser. + (_, FnRetTy::Ty(ty)) => { + let span = data.inputs_span.shrink_to_hi().to(ty.span); + errors::BadReturnTypeNotation::Output { + span, + suggestion: errors::RTNSuggestion { + output: span, + input: data.inputs_span, + }, + } + } }; + let mut err = self.dcx().create_err(err); if !self.tcx.features().return_type_notation() && self.tcx.sess.is_nightly_build() { diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index 55d06477313..6b6244b05aa 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -13,7 +13,7 @@ use tracing::{debug, instrument}; use super::errors::{ AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation, - GenericTypeWithParentheses, UseAngleBrackets, + GenericTypeWithParentheses, RTNSuggestion, UseAngleBrackets, }; use super::{ AllowReturnTypeNotation, GenericArgsCtor, GenericArgsMode, ImplTraitContext, ImplTraitPosition, @@ -268,19 +268,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } GenericArgs::Parenthesized(data) => match generic_args_mode { GenericArgsMode::ReturnTypeNotation => { - let mut err = if !data.inputs.is_empty() { - self.dcx().create_err(BadReturnTypeNotation::Inputs { - span: data.inputs_span, - }) - } else if let FnRetTy::Ty(ty) = &data.output { - self.dcx().create_err(BadReturnTypeNotation::Output { - span: data.inputs_span.shrink_to_hi().to(ty.span), - }) - } else { - self.dcx().create_err(BadReturnTypeNotation::NeedsDots { - span: data.inputs_span, - }) + tracing::info!(?data, ?data.inputs); + let err = match (&data.inputs[..], &data.output) { + ([_, ..], FnRetTy::Default(_)) => { + BadReturnTypeNotation::Inputs { span: data.inputs_span } + } + ([], FnRetTy::Default(_)) => { + BadReturnTypeNotation::NeedsDots { span: data.inputs_span } + } + // The case `T: Trait<method(..) -> Ret>` is handled in the parser. + (_, FnRetTy::Ty(ty)) => { + let span = data.inputs_span.shrink_to_hi().to(ty.span); + BadReturnTypeNotation::Output { + span, + suggestion: RTNSuggestion { + output: span, + input: data.inputs_span, + }, + } + } }; + let mut err = self.dcx().create_err(err); if !self.tcx.features().return_type_notation() && self.tcx.sess.is_nightly_build() { diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index bd0d98028ae..6d05696e146 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -38,7 +38,7 @@ use rustc_mir_dataflow::move_paths::MoveData; use rustc_mir_dataflow::points::DenseLocationMap; use rustc_span::def_id::CRATE_DEF_ID; use rustc_span::source_map::Spanned; -use rustc_span::{DUMMY_SP, Span, sym}; +use rustc_span::{Span, sym}; use rustc_trait_selection::traits::query::type_op::custom::scrape_region_constraints; use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput}; use tracing::{debug, instrument, trace}; @@ -51,7 +51,6 @@ use crate::polonius::legacy::{PoloniusFacts, PoloniusLocationTable}; use crate::polonius::{PoloniusContext, PoloniusLivenessContext}; use crate::region_infer::TypeTest; use crate::region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderIndices}; -use crate::renumber::RegionCtxt; use crate::session_diagnostics::{MoveUnsized, SimdIntrinsicArgConst}; use crate::type_check::free_region_relations::{CreateResult, UniversalRegionRelations}; use crate::universal_regions::{DefiningTy, UniversalRegions}; @@ -2121,35 +2120,31 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { // // Note that other checks (such as denying `dyn Send` -> `dyn // Debug`) are in `rustc_hir_typeck`. - if let ty::Dynamic(src_tty, ..) = src_tail.kind() - && let ty::Dynamic(dst_tty, ..) = dst_tail.kind() + if let ty::Dynamic(src_tty, _src_lt, _) = *src_tail.kind() + && let ty::Dynamic(dst_tty, dst_lt, _) = *dst_tail.kind() && src_tty.principal().is_some() && dst_tty.principal().is_some() { // Remove auto traits. // Auto trait checks are handled in `rustc_hir_typeck` as FCW. - let src_obj = tcx.mk_ty_from_kind(ty::Dynamic( + let src_obj = Ty::new_dynamic( + tcx, tcx.mk_poly_existential_predicates( &src_tty.without_auto_traits().collect::<Vec<_>>(), ), - tcx.lifetimes.re_static, + // FIXME: Once we disallow casting `*const dyn Trait + 'short` + // to `*const dyn Trait + 'long`, then this can just be `src_lt`. + dst_lt, ty::Dyn, - )); - let dst_obj = tcx.mk_ty_from_kind(ty::Dynamic( + ); + let dst_obj = Ty::new_dynamic( + tcx, tcx.mk_poly_existential_predicates( &dst_tty.without_auto_traits().collect::<Vec<_>>(), ), - tcx.lifetimes.re_static, + dst_lt, ty::Dyn, - )); - - // Replace trait object lifetimes with fresh vars, to allow - // casts like - // `*mut dyn FnOnce() + 'a` -> `*mut dyn FnOnce() + 'static` - let src_obj = - freshen_single_trait_object_lifetime(self.infcx, src_obj); - let dst_obj = - freshen_single_trait_object_lifetime(self.infcx, dst_obj); + ); debug!(?src_tty, ?dst_tty, ?src_obj, ?dst_obj); @@ -2707,16 +2702,3 @@ impl<'tcx> TypeOp<'tcx> for InstantiateOpaqueType<'tcx> { Ok(output) } } - -fn freshen_single_trait_object_lifetime<'tcx>( - infcx: &BorrowckInferCtxt<'tcx>, - ty: Ty<'tcx>, -) -> Ty<'tcx> { - let &ty::Dynamic(tty, _, dyn_kind @ ty::Dyn) = ty.kind() else { bug!("expected trait object") }; - - let fresh = infcx - .next_region_var(rustc_infer::infer::RegionVariableOrigin::MiscVariable(DUMMY_SP), || { - RegionCtxt::Unknown - }); - infcx.tcx.mk_ty_from_kind(ty::Dynamic(tty, fresh, dyn_kind)) -} diff --git a/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs index b28c4c9539c..06d89bc9ea7 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs @@ -84,7 +84,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> { AbiParam::new(scalar_to_clif_type(tcx, scalar)), attrs )], - BackendRepr::Vector { .. } => { + BackendRepr::SimdVector { .. } => { let vector_ty = crate::intrinsics::clif_vector_type(tcx, self.layout); smallvec![AbiParam::new(vector_ty)] } @@ -135,7 +135,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> { BackendRepr::Scalar(scalar) => { (None, vec![AbiParam::new(scalar_to_clif_type(tcx, scalar))]) } - BackendRepr::Vector { .. } => { + BackendRepr::SimdVector { .. } => { let vector_ty = crate::intrinsics::clif_vector_type(tcx, self.layout); (None, vec![AbiParam::new(vector_ty)]) } diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs index 4d9bed8652c..6735ae024d1 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs @@ -53,7 +53,7 @@ fn report_atomic_type_validation_error<'tcx>( pub(crate) fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> Type { let (element, count) = match layout.backend_repr { - BackendRepr::Vector { element, count } => (element, count), + BackendRepr::SimdVector { element, count } => (element, count), _ => unreachable!(), }; diff --git a/compiler/rustc_codegen_cranelift/src/value_and_place.rs b/compiler/rustc_codegen_cranelift/src/value_and_place.rs index 1b3f86c8405..cc739fefcd0 100644 --- a/compiler/rustc_codegen_cranelift/src/value_and_place.rs +++ b/compiler/rustc_codegen_cranelift/src/value_and_place.rs @@ -173,9 +173,11 @@ impl<'tcx> CValue<'tcx> { CValueInner::ByRef(ptr, None) => { let clif_ty = match layout.backend_repr { BackendRepr::Scalar(scalar) => scalar_to_clif_type(fx.tcx, scalar), - BackendRepr::Vector { element, count } => scalar_to_clif_type(fx.tcx, element) - .by(u32::try_from(count).unwrap()) - .unwrap(), + BackendRepr::SimdVector { element, count } => { + scalar_to_clif_type(fx.tcx, element) + .by(u32::try_from(count).unwrap()) + .unwrap() + } _ => unreachable!("{:?}", layout.ty), }; let mut flags = MemFlags::new(); diff --git a/compiler/rustc_codegen_gcc/src/back/lto.rs b/compiler/rustc_codegen_gcc/src/back/lto.rs index cb4caec8c32..e5221c7da31 100644 --- a/compiler/rustc_codegen_gcc/src/back/lto.rs +++ b/compiler/rustc_codegen_gcc/src/back/lto.rs @@ -632,17 +632,16 @@ pub unsafe fn optimize_thin_module( Arc::new(SyncContext::new(context)) } }; - let module = ModuleCodegen { - module_llvm: GccContext { + let module = ModuleCodegen::new_regular( + thin_module.name().to_string(), + GccContext { context, should_combine_object_files, // TODO(antoyo): use the correct relocation model here. relocation_model: RelocModel::Pic, temp_dir: None, }, - name: thin_module.name().to_string(), - kind: ModuleKind::Regular, - }; + ); /*{ let target = &*module.module_llvm.tm; let llmod = module.module_llvm.llmod(); diff --git a/compiler/rustc_codegen_gcc/src/base.rs b/compiler/rustc_codegen_gcc/src/base.rs index 962f4b161d7..9b495174a3f 100644 --- a/compiler/rustc_codegen_gcc/src/base.rs +++ b/compiler/rustc_codegen_gcc/src/base.rs @@ -4,10 +4,10 @@ use std::sync::Arc; use std::time::Instant; use gccjit::{CType, Context, FunctionType, GlobalKind}; +use rustc_codegen_ssa::ModuleCodegen; use rustc_codegen_ssa::base::maybe_create_entry_wrapper; use rustc_codegen_ssa::mono_item::MonoItemExt; use rustc_codegen_ssa::traits::DebugInfoCodegenMethods; -use rustc_codegen_ssa::{ModuleCodegen, ModuleKind}; use rustc_middle::dep_graph; use rustc_middle::mir::mono::Linkage; #[cfg(feature = "master")] @@ -237,16 +237,15 @@ pub fn compile_codegen_unit( } } - ModuleCodegen { - name: cgu_name.to_string(), - module_llvm: GccContext { + ModuleCodegen::new_regular( + cgu_name.to_string(), + GccContext { context: Arc::new(SyncContext::new(context)), relocation_model: tcx.sess.relocation_model(), should_combine_object_files: false, temp_dir: None, }, - kind: ModuleKind::Regular, - } + ) } (module, cost) diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index f8672c07299..f38622074f1 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -312,7 +312,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc let layout = self.layout_of(tp_ty).layout; let _use_integer_compare = match layout.backend_repr() { Scalar(_) | ScalarPair(_, _) => true, - Vector { .. } => false, + SimdVector { .. } => false, Memory { .. } => { // For rusty ABIs, small aggregates are actually passed // as `RegKind::Integer` (see `FnAbi::adjust_for_abi`), diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index 6455bcec685..9d91aab72ab 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -393,7 +393,7 @@ impl WriteBackendMethods for GccCodegenBackend { unsafe fn optimize( _cgcx: &CodegenContext<Self>, _dcx: DiagCtxtHandle<'_>, - module: &ModuleCodegen<Self::Module>, + module: &mut ModuleCodegen<Self::Module>, config: &ModuleConfig, ) -> Result<(), FatalError> { module.module_llvm.context.set_optimization_level(to_gcc_opt_level(config.opt_level)); diff --git a/compiler/rustc_codegen_gcc/src/type_of.rs b/compiler/rustc_codegen_gcc/src/type_of.rs index bac4fc51300..ae98b3d0b56 100644 --- a/compiler/rustc_codegen_gcc/src/type_of.rs +++ b/compiler/rustc_codegen_gcc/src/type_of.rs @@ -63,7 +63,7 @@ fn uncached_gcc_type<'gcc, 'tcx>( ) -> Type<'gcc> { match layout.backend_repr { BackendRepr::Scalar(_) => bug!("handled elsewhere"), - BackendRepr::Vector { ref element, count } => { + BackendRepr::SimdVector { ref element, count } => { let element = layout.scalar_gcc_type_at(cx, element, Size::ZERO); let element = // NOTE: gcc doesn't allow pointer types in vectors. @@ -178,7 +178,7 @@ pub trait LayoutGccExt<'tcx> { impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { fn is_gcc_immediate(&self) -> bool { match self.backend_repr { - BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true, + BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => true, BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false, } } @@ -186,9 +186,9 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { fn is_gcc_scalar_pair(&self) -> bool { match self.backend_repr { BackendRepr::ScalarPair(..) => true, - BackendRepr::Scalar(_) | BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => { - false - } + BackendRepr::Scalar(_) + | BackendRepr::SimdVector { .. } + | BackendRepr::Memory { .. } => false, } } diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index be5673eddf9..e8a69743157 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -939,9 +939,10 @@ fn llvm_fixup_input<'ll, 'tcx>( } bx.insert_element(bx.const_undef(vec_ty), value, bx.const_i32(0)) } - (AArch64(AArch64InlineAsmRegClass::vreg_low16), BackendRepr::Vector { element, count }) - if layout.size.bytes() == 8 => - { + ( + AArch64(AArch64InlineAsmRegClass::vreg_low16), + BackendRepr::SimdVector { element, count }, + ) if layout.size.bytes() == 8 => { let elem_ty = llvm_asm_scalar_type(bx.cx, element); let vec_ty = bx.cx.type_vector(elem_ty, count); let indices: Vec<_> = (0..count * 2).map(|x| bx.const_i32(x as i32)).collect(); @@ -954,7 +955,7 @@ fn llvm_fixup_input<'ll, 'tcx>( } ( X86(X86InlineAsmRegClass::xmm_reg | X86InlineAsmRegClass::zmm_reg), - BackendRepr::Vector { .. }, + BackendRepr::SimdVector { .. }, ) if layout.size.bytes() == 64 => bx.bitcast(value, bx.cx.type_vector(bx.cx.type_f64(), 8)), ( X86( @@ -989,7 +990,7 @@ fn llvm_fixup_input<'ll, 'tcx>( | X86InlineAsmRegClass::ymm_reg | X86InlineAsmRegClass::zmm_reg, ), - BackendRepr::Vector { element, count: count @ (8 | 16) }, + BackendRepr::SimdVector { element, count: count @ (8 | 16) }, ) if element.primitive() == Primitive::Float(Float::F16) => { bx.bitcast(value, bx.type_vector(bx.type_i16(), count)) } @@ -1026,7 +1027,7 @@ fn llvm_fixup_input<'ll, 'tcx>( | ArmInlineAsmRegClass::qreg_low4 | ArmInlineAsmRegClass::qreg_low8, ), - BackendRepr::Vector { element, count: count @ (4 | 8) }, + BackendRepr::SimdVector { element, count: count @ (4 | 8) }, ) if element.primitive() == Primitive::Float(Float::F16) => { bx.bitcast(value, bx.type_vector(bx.type_i16(), count)) } @@ -1099,9 +1100,10 @@ fn llvm_fixup_output<'ll, 'tcx>( } value } - (AArch64(AArch64InlineAsmRegClass::vreg_low16), BackendRepr::Vector { element, count }) - if layout.size.bytes() == 8 => - { + ( + AArch64(AArch64InlineAsmRegClass::vreg_low16), + BackendRepr::SimdVector { element, count }, + ) if layout.size.bytes() == 8 => { let elem_ty = llvm_asm_scalar_type(bx.cx, element); let vec_ty = bx.cx.type_vector(elem_ty, count * 2); let indices: Vec<_> = (0..count).map(|x| bx.const_i32(x as i32)).collect(); @@ -1114,7 +1116,7 @@ fn llvm_fixup_output<'ll, 'tcx>( } ( X86(X86InlineAsmRegClass::xmm_reg | X86InlineAsmRegClass::zmm_reg), - BackendRepr::Vector { .. }, + BackendRepr::SimdVector { .. }, ) if layout.size.bytes() == 64 => bx.bitcast(value, layout.llvm_type(bx.cx)), ( X86( @@ -1145,7 +1147,7 @@ fn llvm_fixup_output<'ll, 'tcx>( | X86InlineAsmRegClass::ymm_reg | X86InlineAsmRegClass::zmm_reg, ), - BackendRepr::Vector { element, count: count @ (8 | 16) }, + BackendRepr::SimdVector { element, count: count @ (8 | 16) }, ) if element.primitive() == Primitive::Float(Float::F16) => { bx.bitcast(value, bx.type_vector(bx.type_f16(), count)) } @@ -1182,7 +1184,7 @@ fn llvm_fixup_output<'ll, 'tcx>( | ArmInlineAsmRegClass::qreg_low4 | ArmInlineAsmRegClass::qreg_low8, ), - BackendRepr::Vector { element, count: count @ (4 | 8) }, + BackendRepr::SimdVector { element, count: count @ (4 | 8) }, ) if element.primitive() == Primitive::Float(Float::F16) => { bx.bitcast(value, bx.type_vector(bx.type_f16(), count)) } @@ -1243,9 +1245,10 @@ fn llvm_fixup_output_type<'ll, 'tcx>( let count = 16 / layout.size.bytes(); cx.type_vector(elem_ty, count) } - (AArch64(AArch64InlineAsmRegClass::vreg_low16), BackendRepr::Vector { element, count }) - if layout.size.bytes() == 8 => - { + ( + AArch64(AArch64InlineAsmRegClass::vreg_low16), + BackendRepr::SimdVector { element, count }, + ) if layout.size.bytes() == 8 => { let elem_ty = llvm_asm_scalar_type(cx, element); cx.type_vector(elem_ty, count * 2) } @@ -1256,7 +1259,7 @@ fn llvm_fixup_output_type<'ll, 'tcx>( } ( X86(X86InlineAsmRegClass::xmm_reg | X86InlineAsmRegClass::zmm_reg), - BackendRepr::Vector { .. }, + BackendRepr::SimdVector { .. }, ) if layout.size.bytes() == 64 => cx.type_vector(cx.type_f64(), 8), ( X86( @@ -1284,7 +1287,7 @@ fn llvm_fixup_output_type<'ll, 'tcx>( | X86InlineAsmRegClass::ymm_reg | X86InlineAsmRegClass::zmm_reg, ), - BackendRepr::Vector { element, count: count @ (8 | 16) }, + BackendRepr::SimdVector { element, count: count @ (8 | 16) }, ) if element.primitive() == Primitive::Float(Float::F16) => { cx.type_vector(cx.type_i16(), count) } @@ -1321,7 +1324,7 @@ fn llvm_fixup_output_type<'ll, 'tcx>( | ArmInlineAsmRegClass::qreg_low4 | ArmInlineAsmRegClass::qreg_low8, ), - BackendRepr::Vector { element, count: count @ (4 | 8) }, + BackendRepr::SimdVector { element, count: count @ (4 | 8) }, ) if element.primitive() == Primitive::Float(Float::F16) => { cx.type_vector(cx.type_i16(), count) } diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index 93553f3f364..0a161442933 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -132,14 +132,33 @@ fn get_llvm_object_symbols( if err.is_null() { return Ok(true); } else { - return Err(unsafe { *Box::from_raw(err as *mut io::Error) }); + let error = unsafe { *Box::from_raw(err as *mut io::Error) }; + // These are the magic constants for LLVM bitcode files: + // https://github.com/llvm/llvm-project/blob/7eadc1960d199676f04add402bb0aa6f65b7b234/llvm/lib/BinaryFormat/Magic.cpp#L90-L97 + if buf.starts_with(&[0xDE, 0xCE, 0x17, 0x0B]) || buf.starts_with(&[b'B', b'C', 0xC0, 0xDE]) + { + // For LLVM bitcode, failure to read the symbols is not fatal. The bitcode may have been + // produced by a newer LLVM version that the one linked to rustc. This is fine provided + // that the linker does use said newer LLVM version. We skip writing the symbols for the + // bitcode to the symbol table of the archive. Traditional linkers don't like this, but + // newer linkers like lld, mold and wild ignore the symbol table anyway, so if they link + // against a new enough LLVM it will work out in the end. + // LLVM's archive writer also has this same behavior of only warning about invalid + // bitcode since https://github.com/llvm/llvm-project/pull/96848 + + // We don't have access to the DiagCtxt here to produce a nice warning in the correct format. + eprintln!("warning: Failed to read symbol table from LLVM bitcode: {}", error); + return Ok(true); + } else { + return Err(error); + } } unsafe extern "C" fn callback(state: *mut c_void, symbol_name: *const c_char) -> *mut c_void { let f = unsafe { &mut *(state as *mut &mut dyn FnMut(&[u8]) -> io::Result<()>) }; match f(unsafe { CStr::from_ptr(symbol_name) }.to_bytes()) { Ok(()) => std::ptr::null_mut(), - Err(err) => Box::into_raw(Box::new(err)) as *mut c_void, + Err(err) => Box::into_raw(Box::new(err) as Box<io::Error>) as *mut c_void, } } @@ -148,7 +167,7 @@ fn get_llvm_object_symbols( Box::into_raw(Box::new(io::Error::new( io::ErrorKind::Other, format!("LLVM error: {}", error.to_string_lossy()), - ))) as *mut c_void + )) as Box<io::Error>) as *mut c_void } } diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 05a2cd1c5a3..668795191a2 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -2,6 +2,7 @@ use std::collections::BTreeMap; use std::ffi::{CStr, CString}; use std::fs::File; use std::path::Path; +use std::ptr::NonNull; use std::sync::Arc; use std::{io, iter, slice}; @@ -305,11 +306,8 @@ fn fat_lto( assert!(!serialized_modules.is_empty(), "must have at least one serialized module"); let (buffer, name) = serialized_modules.remove(0); info!("no in-memory regular modules to choose from, parsing {:?}", name); - ModuleCodegen { - module_llvm: ModuleLlvm::parse(cgcx, &name, buffer.data(), dcx)?, - name: name.into_string().unwrap(), - kind: ModuleKind::Regular, - } + let llvm_module = ModuleLlvm::parse(cgcx, &name, buffer.data(), dcx)?; + ModuleCodegen::new_regular(name.into_string().unwrap(), llvm_module) } }; { @@ -655,14 +653,14 @@ pub(crate) fn run_pass_manager( } unsafe { - write::llvm_optimize(cgcx, dcx, module, config, opt_level, opt_stage, stage)?; + write::llvm_optimize(cgcx, dcx, module, None, config, opt_level, opt_stage, stage)?; } if cfg!(llvm_enzyme) && enable_ad { let opt_stage = llvm::OptStage::FatLTO; let stage = write::AutodiffStage::PostAD; unsafe { - write::llvm_optimize(cgcx, dcx, module, config, opt_level, opt_stage, stage)?; + write::llvm_optimize(cgcx, dcx, module, None, config, opt_level, opt_stage, stage)?; } // This is the final IR, so people should be able to inspect the optimized autodiff output. @@ -729,6 +727,11 @@ impl ThinBuffer { ThinBuffer(buffer) } } + + pub unsafe fn from_raw_ptr(ptr: *mut llvm::ThinLTOBuffer) -> ThinBuffer { + let mut ptr = NonNull::new(ptr).unwrap(); + ThinBuffer(unsafe { ptr.as_mut() }) + } } impl ThinBufferMethods for ThinBuffer { @@ -772,11 +775,11 @@ pub(crate) unsafe fn optimize_thin_module( // crates but for locally codegened modules we may be able to reuse // that LLVM Context and Module. let module_llvm = ModuleLlvm::parse(cgcx, module_name, thin_module.data(), dcx)?; - let mut module = ModuleCodegen { - module_llvm, - name: thin_module.name().to_string(), - kind: ModuleKind::Regular, - }; + let mut module = ModuleCodegen::new_regular(thin_module.name(), module_llvm); + // Given that the newly created module lacks a thinlto buffer for embedding, we need to re-add it here. + if cgcx.config(ModuleKind::Regular).embed_bitcode() { + module.thin_lto_buffer = Some(thin_module.data().to_vec()); + } { let target = &*module.module_llvm.tm; let llmod = module.module_llvm.llmod(); diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 29d6121844f..bead4c82a81 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -1,6 +1,7 @@ use std::ffi::{CStr, CString}; use std::io::{self, Write}; use std::path::{Path, PathBuf}; +use std::ptr::null_mut; use std::sync::Arc; use std::{fs, slice, str}; @@ -15,7 +16,7 @@ use rustc_codegen_ssa::back::write::{ TargetMachineFactoryFn, }; use rustc_codegen_ssa::traits::*; -use rustc_codegen_ssa::{CompiledModule, ModuleCodegen}; +use rustc_codegen_ssa::{CompiledModule, ModuleCodegen, ModuleKind}; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::small_c_str::SmallCStr; use rustc_errors::{DiagCtxtHandle, FatalError, Level}; @@ -551,6 +552,7 @@ pub(crate) unsafe fn llvm_optimize( cgcx: &CodegenContext<LlvmCodegenBackend>, dcx: DiagCtxtHandle<'_>, module: &ModuleCodegen<ModuleLlvm>, + thin_lto_buffer: Option<&mut *mut llvm::ThinLTOBuffer>, config: &ModuleConfig, opt_level: config::OptLevel, opt_stage: llvm::OptStage, @@ -584,7 +586,17 @@ pub(crate) unsafe fn llvm_optimize( vectorize_loop = config.vectorize_loop; } trace!(?unroll_loops, ?vectorize_slp, ?vectorize_loop, ?run_enzyme); - let using_thin_buffers = opt_stage == llvm::OptStage::PreLinkThinLTO || config.bitcode_needed(); + if thin_lto_buffer.is_some() { + assert!( + matches!( + opt_stage, + llvm::OptStage::PreLinkNoLTO + | llvm::OptStage::PreLinkFatLTO + | llvm::OptStage::PreLinkThinLTO + ), + "the bitcode for LTO can only be obtained at the pre-link stage" + ); + } let pgo_gen_path = get_pgo_gen_path(config); let pgo_use_path = get_pgo_use_path(config); let pgo_sample_use_path = get_pgo_sample_use_path(config); @@ -644,7 +656,9 @@ pub(crate) unsafe fn llvm_optimize( config.no_prepopulate_passes, config.verify_llvm_ir, config.lint_llvm_ir, - using_thin_buffers, + thin_lto_buffer, + config.emit_thin_lto, + config.emit_thin_lto_summary, config.merge_functions, unroll_loops, vectorize_slp, @@ -675,7 +689,7 @@ pub(crate) unsafe fn llvm_optimize( pub(crate) unsafe fn optimize( cgcx: &CodegenContext<LlvmCodegenBackend>, dcx: DiagCtxtHandle<'_>, - module: &ModuleCodegen<ModuleLlvm>, + module: &mut ModuleCodegen<ModuleLlvm>, config: &ModuleConfig, ) -> Result<(), FatalError> { let _timer = cgcx.prof.generic_activity_with_arg("LLVM_module_optimize", &*module.name); @@ -705,9 +719,53 @@ pub(crate) unsafe fn optimize( // Otherwise we pretend AD is already done and run the normal opt pipeline (=PostAD). let consider_ad = cfg!(llvm_enzyme) && config.autodiff.contains(&config::AutoDiff::Enable); let autodiff_stage = if consider_ad { AutodiffStage::PreAD } else { AutodiffStage::PostAD }; - return unsafe { - llvm_optimize(cgcx, dcx, module, config, opt_level, opt_stage, autodiff_stage) + // The embedded bitcode is used to run LTO/ThinLTO. + // The bitcode obtained during the `codegen` phase is no longer suitable for performing LTO. + // It may have undergone LTO due to ThinLocal, so we need to obtain the embedded bitcode at + // this point. + let mut thin_lto_buffer = if (module.kind == ModuleKind::Regular + && config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full)) + || config.emit_thin_lto_summary + { + Some(null_mut()) + } else { + None }; + unsafe { + llvm_optimize( + cgcx, + dcx, + module, + thin_lto_buffer.as_mut(), + config, + opt_level, + opt_stage, + autodiff_stage, + ) + }?; + if let Some(thin_lto_buffer) = thin_lto_buffer { + let thin_lto_buffer = unsafe { ThinBuffer::from_raw_ptr(thin_lto_buffer) }; + module.thin_lto_buffer = Some(thin_lto_buffer.data().to_vec()); + let bc_summary_out = + cgcx.output_filenames.temp_path(OutputType::ThinLinkBitcode, module_name); + if config.emit_thin_lto_summary + && let Some(thin_link_bitcode_filename) = bc_summary_out.file_name() + { + let summary_data = thin_lto_buffer.thin_link_data(); + cgcx.prof.artifact_size( + "llvm_bitcode_summary", + thin_link_bitcode_filename.to_string_lossy(), + summary_data.len() as u64, + ); + let _timer = cgcx.prof.generic_activity_with_arg( + "LLVM_module_codegen_emit_bitcode_summary", + &*module.name, + ); + if let Err(err) = fs::write(&bc_summary_out, summary_data) { + dcx.emit_err(WriteBytecode { path: &bc_summary_out, err }); + } + } + } } Ok(()) } @@ -760,59 +818,41 @@ pub(crate) unsafe fn codegen( // otherwise requested. let bc_out = cgcx.output_filenames.temp_path(OutputType::Bitcode, module_name); - let bc_summary_out = - cgcx.output_filenames.temp_path(OutputType::ThinLinkBitcode, module_name); let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, module_name); if config.bitcode_needed() { - let _timer = cgcx - .prof - .generic_activity_with_arg("LLVM_module_codegen_make_bitcode", &*module.name); - let thin = ThinBuffer::new(llmod, config.emit_thin_lto, config.emit_thin_lto_summary); - let data = thin.data(); - - if let Some(bitcode_filename) = bc_out.file_name() { - cgcx.prof.artifact_size( - "llvm_bitcode", - bitcode_filename.to_string_lossy(), - data.len() as u64, - ); - } - - if config.emit_thin_lto_summary - && let Some(thin_link_bitcode_filename) = bc_summary_out.file_name() - { - let summary_data = thin.thin_link_data(); - cgcx.prof.artifact_size( - "llvm_bitcode_summary", - thin_link_bitcode_filename.to_string_lossy(), - summary_data.len() as u64, - ); - - let _timer = cgcx.prof.generic_activity_with_arg( - "LLVM_module_codegen_emit_bitcode_summary", - &*module.name, - ); - if let Err(err) = fs::write(&bc_summary_out, summary_data) { - dcx.emit_err(WriteBytecode { path: &bc_summary_out, err }); - } - } - if config.emit_bc || config.emit_obj == EmitObj::Bitcode { + let thin = { + let _timer = cgcx.prof.generic_activity_with_arg( + "LLVM_module_codegen_make_bitcode", + &*module.name, + ); + ThinBuffer::new(llmod, config.emit_thin_lto, false) + }; + let data = thin.data(); let _timer = cgcx .prof .generic_activity_with_arg("LLVM_module_codegen_emit_bitcode", &*module.name); + if let Some(bitcode_filename) = bc_out.file_name() { + cgcx.prof.artifact_size( + "llvm_bitcode", + bitcode_filename.to_string_lossy(), + data.len() as u64, + ); + } if let Err(err) = fs::write(&bc_out, data) { dcx.emit_err(WriteBytecode { path: &bc_out, err }); } } - if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) { + if config.embed_bitcode() && module.kind == ModuleKind::Regular { let _timer = cgcx .prof .generic_activity_with_arg("LLVM_module_codegen_embed_bitcode", &*module.name); + let thin_bc = + module.thin_lto_buffer.as_deref().expect("cannot find embedded bitcode"); unsafe { - embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); + embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, &thin_bc); } } } diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index d35c7945bae..6bd27914dbd 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -13,10 +13,10 @@ use std::time::Instant; +use rustc_codegen_ssa::ModuleCodegen; use rustc_codegen_ssa::base::maybe_create_entry_wrapper; use rustc_codegen_ssa::mono_item::MonoItemExt; use rustc_codegen_ssa::traits::*; -use rustc_codegen_ssa::{ModuleCodegen, ModuleKind}; use rustc_data_structures::small_c_str::SmallCStr; use rustc_middle::dep_graph; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; @@ -133,11 +133,7 @@ pub(crate) fn compile_codegen_unit( } } - ModuleCodegen { - name: cgu_name.to_string(), - module_llvm: llvm_module, - kind: ModuleKind::Regular, - } + ModuleCodegen::new_regular(cgu_name.to_string(), llvm_module) } (module, cost) diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 1169b9c067d..0272667e223 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -470,7 +470,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { let layout = self.layout_of(tp_ty).layout; let use_integer_compare = match layout.backend_repr() { Scalar(_) | ScalarPair(_, _) => true, - Vector { .. } => false, + SimdVector { .. } => false, Memory { .. } => { // For rusty ABIs, small aggregates are actually passed // as `RegKind::Integer` (see `FnAbi::adjust_for_abi`), diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index e9e1b644f18..c88372db491 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -194,7 +194,7 @@ impl WriteBackendMethods for LlvmCodegenBackend { unsafe fn optimize( cgcx: &CodegenContext<Self>, dcx: DiagCtxtHandle<'_>, - module: &ModuleCodegen<Self::Module>, + module: &mut ModuleCodegen<Self::Module>, config: &ModuleConfig, ) -> Result<(), FatalError> { unsafe { back::write::optimize(cgcx, dcx, module, config) } diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index da91e6edbcf..2dc14e4613d 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2425,7 +2425,9 @@ unsafe extern "C" { NoPrepopulatePasses: bool, VerifyIR: bool, LintIR: bool, - UseThinLTOBuffers: bool, + ThinLTOBuffer: Option<&mut *mut ThinLTOBuffer>, + EmitThinLTO: bool, + EmitThinLTOSummary: bool, MergeFunctions: bool, UnrollLoops: bool, SLPVectorize: bool, diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index ba01fbff385..4e7096da502 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -19,7 +19,7 @@ fn uncached_llvm_type<'a, 'tcx>( ) -> &'a Type { match layout.backend_repr { BackendRepr::Scalar(_) => bug!("handled elsewhere"), - BackendRepr::Vector { element, count } => { + BackendRepr::SimdVector { element, count } => { let element = layout.scalar_llvm_type_at(cx, element); return cx.type_vector(element, count); } @@ -171,7 +171,7 @@ pub(crate) trait LayoutLlvmExt<'tcx> { impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { fn is_llvm_immediate(&self) -> bool { match self.backend_repr { - BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true, + BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => true, BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false, } } @@ -179,9 +179,9 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { fn is_llvm_scalar_pair(&self) -> bool { match self.backend_repr { BackendRepr::ScalarPair(..) => true, - BackendRepr::Scalar(_) | BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => { - false - } + BackendRepr::Scalar(_) + | BackendRepr::SimdVector { .. } + | BackendRepr::Memory { .. } => false, } } diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index b090730ac6b..5054ae561c0 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1726,8 +1726,12 @@ fn exec_linker( args.push_str( &Escape { arg: arg.to_str().unwrap(), - // LLD also uses MSVC-like parsing for @-files by default when running on windows hosts - is_like_msvc: sess.target.is_like_msvc || (cfg!(windows) && flavor.uses_lld()), + // Windows-style escaping for @-files is used by + // - all linkers targeting MSVC-like targets, including LLD + // - all LLD flavors running on Windows hosts + // С/С++ compilers use Posix-style escaping (except clang-cl, which we do not use). + is_like_msvc: sess.target.is_like_msvc + || (cfg!(windows) && flavor.uses_lld() && !flavor.uses_cc()), } .to_string(), ); diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 236507ac0cd..3aacbcde1a7 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -373,7 +373,11 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static Architecture::Avr => { // Resolve the ISA revision and set // the appropriate EF_AVR_ARCH flag. - ef_avr_arch(&sess.target.options.cpu) + if let Some(ref cpu) = sess.opts.cg.target_cpu { + ef_avr_arch(cpu) + } else { + bug!("AVR CPU not explicitly specified") + } } Architecture::Csky => { let e_flags = match sess.target.options.abi.as_ref() { diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index f008bd12ed8..c8bb229998e 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -278,6 +278,10 @@ impl ModuleConfig { || self.emit_obj == EmitObj::Bitcode || self.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) } + + pub fn embed_bitcode(&self) -> bool { + self.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) + } } /// Configuration passed to the function returned by the `target_machine_factory`. @@ -877,14 +881,14 @@ pub(crate) fn compute_per_cgu_lto_type( fn execute_optimize_work_item<B: ExtraBackendMethods>( cgcx: &CodegenContext<B>, - module: ModuleCodegen<B::Module>, + mut module: ModuleCodegen<B::Module>, module_config: &ModuleConfig, ) -> Result<WorkItemResult<B>, FatalError> { let dcx = cgcx.create_dcx(); let dcx = dcx.handle(); unsafe { - B::optimize(cgcx, dcx, &module, module_config)?; + B::optimize(cgcx, dcx, &mut module, module_config)?; } // After we've done the initial round of optimizations we need to diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 73a97d32c2d..63f2f8fa3d1 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -687,7 +687,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>( submit_codegened_module_to_llvm( &backend, &ongoing_codegen.coordinator.sender, - ModuleCodegen { name: llmod_id, module_llvm, kind: ModuleKind::Allocator }, + ModuleCodegen::new_allocator(llmod_id, module_llvm), cost, ); } diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index 9d2ac219d59..4e758bfdec3 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -75,9 +75,29 @@ pub struct ModuleCodegen<M> { pub name: String, pub module_llvm: M, pub kind: ModuleKind, + /// Saving the ThinLTO buffer for embedding in the object file. + pub thin_lto_buffer: Option<Vec<u8>>, } impl<M> ModuleCodegen<M> { + pub fn new_regular(name: impl Into<String>, module: M) -> Self { + Self { + name: name.into(), + module_llvm: module, + kind: ModuleKind::Regular, + thin_lto_buffer: None, + } + } + + pub fn new_allocator(name: impl Into<String>, module: M) -> Self { + Self { + name: name.into(), + module_llvm: module, + kind: ModuleKind::Allocator, + thin_lto_buffer: None, + } + } + pub fn into_compiled_module( self, emit_obj: bool, diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs index 0593fb420c3..96d1ab018f6 100644 --- a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs +++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs @@ -349,7 +349,7 @@ fn wasm_type<'tcx>( PassMode::Direct(_) => { let direct_type = match arg_abi.layout.backend_repr { BackendRepr::Scalar(scalar) => wasm_primitive(scalar.primitive(), ptr_type), - BackendRepr::Vector { .. } => "v128", + BackendRepr::SimdVector { .. } => "v128", BackendRepr::Memory { .. } => { // FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed let _ = WasmCAbi::Legacy; diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs index 461cf1b8acd..4b33bdeadba 100644 --- a/compiler/rustc_codegen_ssa/src/mir/operand.rs +++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs @@ -359,7 +359,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { let offset = self.layout.fields.offset(i); if !bx.is_backend_ref(self.layout) && bx.is_backend_ref(field) { - if let BackendRepr::Vector { count, .. } = self.layout.backend_repr + if let BackendRepr::SimdVector { count, .. } = self.layout.backend_repr && let BackendRepr::Memory { sized: true } = field.backend_repr && count.is_power_of_two() { @@ -404,7 +404,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { } }; OperandValue::Immediate(match field.backend_repr { - BackendRepr::Vector { .. } => imm, + BackendRepr::SimdVector { .. } => imm, BackendRepr::Scalar(out_scalar) => { let Some(in_scalar) = in_scalar else { span_bug!( @@ -666,7 +666,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // However, some SIMD types do not actually use the vector ABI // (in particular, packed SIMD types do not). Ensure we exclude those. let layout = bx.layout_of(constant_ty); - if let BackendRepr::Vector { .. } = layout.backend_repr { + if let BackendRepr::SimdVector { .. } = layout.backend_repr { let (llval, ty) = self.immediate_const_vector(bx, constant); return OperandRef { val: OperandValue::Immediate(llval), diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index d24e48b37a4..67555d40332 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -1190,7 +1190,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { assert!(!self.cx.is_backend_scalar_pair(layout)); OperandValueKind::Immediate(match layout.backend_repr { abi::BackendRepr::Scalar(s) => s, - abi::BackendRepr::Vector { element, .. } => element, + abi::BackendRepr::SimdVector { element, .. } => element, x => span_bug!(self.mir.span, "Couldn't translate {x:?} as backend immediate"), }) } else if self.cx.is_backend_scalar_pair(layout) { diff --git a/compiler/rustc_codegen_ssa/src/traits/write.rs b/compiler/rustc_codegen_ssa/src/traits/write.rs index 97fe614aa10..c77efdd1728 100644 --- a/compiler/rustc_codegen_ssa/src/traits/write.rs +++ b/compiler/rustc_codegen_ssa/src/traits/write.rs @@ -40,7 +40,7 @@ pub trait WriteBackendMethods: 'static + Sized + Clone { unsafe fn optimize( cgcx: &CodegenContext<Self>, dcx: DiagCtxtHandle<'_>, - module: &ModuleCodegen<Self::Module>, + module: &mut ModuleCodegen<Self::Module>, config: &ModuleConfig, ) -> Result<(), FatalError>; fn optimize_fat( diff --git a/compiler/rustc_const_eval/messages.ftl b/compiler/rustc_const_eval/messages.ftl index eecc6690f51..ccf9b240d40 100644 --- a/compiler/rustc_const_eval/messages.ftl +++ b/compiler/rustc_const_eval/messages.ftl @@ -109,6 +109,8 @@ const_eval_frame_note_inner = inside {$where_ -> *[other] {""} } +const_eval_frame_note_last = the failure occurred here + const_eval_in_bounds_test = out-of-bounds pointer use const_eval_incompatible_calling_conventions = calling a function with calling convention {$callee_conv} using calling convention {$caller_conv} @@ -300,8 +302,7 @@ const_eval_overflow_arith = const_eval_overflow_shift = overflowing shift by {$shift_amount} in `{$intrinsic}` -const_eval_panic = - the evaluated program panicked at '{$msg}', {$file}:{$line}:{$col} +const_eval_panic = evaluation panicked: {$msg} const_eval_panic_non_str = argument to `panic!()` in a const context must have type `&str` diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index 3e32336d8fc..ffb32fa41eb 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -48,11 +48,8 @@ impl MachineStopType for ConstEvalErrKind { | ModifiedGlobal | WriteThroughImmutablePointer => {} AssertFailure(kind) => kind.add_args(adder), - Panic { msg, line, col, file } => { + Panic { msg, .. } => { adder("msg".into(), msg.into_diag_arg(&mut None)); - adder("file".into(), file.into_diag_arg(&mut None)); - adder("line".into(), line.into_diag_arg(&mut None)); - adder("col".into(), col.into_diag_arg(&mut None)); } } } @@ -72,7 +69,7 @@ pub fn get_span_and_frames<'tcx>( let mut stacktrace = Frame::generate_stacktrace_from_stack(stack); // Filter out `requires_caller_location` frames. stacktrace.retain(|frame| !frame.instance.def.requires_caller_location(*tcx)); - let span = stacktrace.first().map(|f| f.span).unwrap_or(tcx.span); + let span = stacktrace.last().map(|f| f.span).unwrap_or(tcx.span); let mut frames = Vec::new(); @@ -115,6 +112,20 @@ pub fn get_span_and_frames<'tcx>( } } + // In `rustc`, we present const-eval errors from the outer-most place first to the inner-most. + // So we reverse the frames here. The first frame will be the same as the span from the current + // `TyCtxtAt<'_>`, so we remove it as it would be redundant. + frames.reverse(); + if frames.len() > 0 { + frames.remove(0); + } + if let Some(last) = frames.last_mut() + // If the span is not going to be printed, we don't want the span label for `is_last`. + && tcx.sess.source_map().span_to_snippet(last.span.source_callsite()).is_ok() + { + last.has_label = true; + } + (span, frames) } diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index ef756e58c5e..b020eeccf71 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -6,6 +6,7 @@ use rustc_abi::WrappingRange; use rustc_errors::codes::*; use rustc_errors::{ Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, Level, + MultiSpan, SubdiagMessageOp, Subdiagnostic, }; use rustc_hir::ConstContext; use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; @@ -17,6 +18,7 @@ use rustc_middle::mir::interpret::{ use rustc_middle::ty::{self, Mutability, Ty}; use rustc_span::{Span, Symbol}; +use crate::fluent_generated as fluent; use crate::interpret::InternKind; #[derive(Diagnostic)] @@ -278,14 +280,31 @@ pub(crate) struct NonConstImplNote { pub span: Span, } -#[derive(Subdiagnostic, Clone)] -#[note(const_eval_frame_note)] +#[derive(Clone)] pub struct FrameNote { - #[primary_span] pub span: Span, pub times: i32, pub where_: &'static str, pub instance: String, + pub has_label: bool, +} + +impl Subdiagnostic for FrameNote { + fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>( + self, + diag: &mut Diag<'_, G>, + f: &F, + ) { + diag.arg("times", self.times); + diag.arg("where_", self.where_); + diag.arg("instance", self.instance); + let mut span: MultiSpan = self.span.into(); + if self.has_label && !self.span.is_dummy() { + span.push_span_label(self.span, fluent::const_eval_frame_note_last); + } + let msg = f(diag, fluent::const_eval_frame_note.into()); + diag.span_note(span, msg); + } } #[derive(Subdiagnostic)] diff --git a/compiler/rustc_const_eval/src/interpret/stack.rs b/compiler/rustc_const_eval/src/interpret/stack.rs index 7d0e0492792..d7b03776bc4 100644 --- a/compiler/rustc_const_eval/src/interpret/stack.rs +++ b/compiler/rustc_const_eval/src/interpret/stack.rs @@ -231,13 +231,19 @@ impl<'tcx> FrameInfo<'tcx> { pub fn as_note(&self, tcx: TyCtxt<'tcx>) -> errors::FrameNote { let span = self.span; if tcx.def_key(self.instance.def_id()).disambiguated_data.data == DefPathData::Closure { - errors::FrameNote { where_: "closure", span, instance: String::new(), times: 0 } + errors::FrameNote { + where_: "closure", + span, + instance: String::new(), + times: 0, + has_label: false, + } } else { let instance = format!("{}", self.instance); // Note: this triggers a `must_produce_diag` state, which means that if we ever get // here we must emit a diagnostic. We should never display a `FrameInfo` unless we // actually want to emit a warning or error to the user. - errors::FrameNote { where_: "instance", span, instance, times: 0 } + errors::FrameNote { where_: "instance", span, instance, times: 0, has_label: false } } } } diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 40dec0cb39e..eb3f552cd27 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -1296,7 +1296,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt, self.visit_scalar(b, b_layout)?; } } - BackendRepr::Vector { .. } => { + BackendRepr::SimdVector { .. } => { // No checks here, we assume layout computation gets this right. // (This is harder to check since Miri does not represent these as `Immediate`. We // also cannot use field projections since this might be a newtype around a vector.) diff --git a/compiler/rustc_const_eval/src/util/check_validity_requirement.rs b/compiler/rustc_const_eval/src/util/check_validity_requirement.rs index 6426bca2332..d7e97f32bae 100644 --- a/compiler/rustc_const_eval/src/util/check_validity_requirement.rs +++ b/compiler/rustc_const_eval/src/util/check_validity_requirement.rs @@ -117,7 +117,7 @@ fn check_validity_requirement_lax<'tcx>( BackendRepr::ScalarPair(s1, s2) => { scalar_allows_raw_init(s1) && scalar_allows_raw_init(s2) } - BackendRepr::Vector { element: s, count } => count == 0 || scalar_allows_raw_init(s), + BackendRepr::SimdVector { element: s, count } => count == 0 || scalar_allows_raw_init(s), BackendRepr::Memory { .. } => true, // Fields are checked below. }; if !valid { diff --git a/compiler/rustc_error_codes/src/error_codes/E0133.md b/compiler/rustc_error_codes/src/error_codes/E0133.md index 8ca3f03ce15..854cca3d10f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0133.md +++ b/compiler/rustc_error_codes/src/error_codes/E0133.md @@ -45,6 +45,7 @@ unsafe fn g() { ``` Linting against this is controlled via the `unsafe_op_in_unsafe_fn` lint, which -is `allow` by default but will be upgraded to `warn` in a future edition. +is `warn` by default in the 2024 edition and `allow` by default in earlier +editions. [unsafe-section]: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 66c26a541f1..0acd3b0f800 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -508,6 +508,8 @@ declare_features! ( (incomplete, generic_const_exprs, "1.56.0", Some(76560)), /// Allows generic parameters and where-clauses on free & associated const items. (incomplete, generic_const_items, "1.73.0", Some(113521)), + /// Allows the type of const generics to depend on generic parameters + (incomplete, generic_const_parameter_types, "CURRENT_RUSTC_VERSION", Some(137626)), /// Allows any generic constants being used as pattern type range ends (incomplete, generic_pattern_types, "1.86.0", Some(136574)), /// Allows registering static items globally, possibly across crates, to iterate over at runtime. diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index cde22e81c03..399f1f4b237 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3512,7 +3512,7 @@ pub enum InlineAsmOperand<'hir> { out_expr: Option<&'hir Expr<'hir>>, }, Const { - anon_const: &'hir AnonConst, + anon_const: ConstBlock, }, SymFn { expr: &'hir Expr<'hir>, diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index d5fa7ec366b..e349e23f7dc 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -1447,7 +1447,7 @@ pub fn walk_inline_asm<'v, V: Visitor<'v>>( visit_opt!(visitor, visit_expr, out_expr); } InlineAsmOperand::Const { anon_const, .. } => { - try_visit!(visitor.visit_anon_const(anon_const)); + try_visit!(visitor.visit_inline_const(anon_const)); } InlineAsmOperand::SymFn { expr, .. } => { try_visit!(visitor.visit_expr(expr)); diff --git a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs index 51194740450..590ade516ec 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs @@ -1,5 +1,3 @@ -use std::assert_matches::debug_assert_matches; - use rustc_abi::FieldIdx; use rustc_ast::InlineAsmTemplatePiece; use rustc_data_structures::fx::FxIndexSet; @@ -21,6 +19,7 @@ pub struct InlineAsmCtxt<'a, 'tcx: 'a> { typing_env: ty::TypingEnv<'tcx>, target_features: &'tcx FxIndexSet<Symbol>, expr_ty: Box<dyn Fn(&hir::Expr<'tcx>) -> Ty<'tcx> + 'a>, + node_ty: Box<dyn Fn(hir::HirId) -> Ty<'tcx> + 'a>, } enum NonAsmTypeReason<'tcx> { @@ -35,13 +34,15 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { tcx: TyCtxt<'tcx>, def_id: LocalDefId, typing_env: ty::TypingEnv<'tcx>, - get_operand_ty: impl Fn(&hir::Expr<'tcx>) -> Ty<'tcx> + 'a, + expr_ty: impl Fn(&hir::Expr<'tcx>) -> Ty<'tcx> + 'a, + node_ty: impl Fn(hir::HirId) -> Ty<'tcx> + 'a, ) -> Self { InlineAsmCtxt { tcx, typing_env, target_features: tcx.asm_target_features(def_id), - expr_ty: Box::new(get_operand_ty), + expr_ty: Box::new(expr_ty), + node_ty: Box::new(node_ty), } } @@ -49,6 +50,10 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { (self.expr_ty)(expr) } + fn node_ty(&self, hir_id: hir::HirId) -> Ty<'tcx> { + (self.node_ty)(hir_id) + } + // FIXME(compiler-errors): This could use `<$ty as Pointee>::Metadata == ()` fn is_thin_ptr_ty(&self, ty: Ty<'tcx>) -> bool { // Type still may have region variables, but `Sized` does not depend @@ -487,12 +492,23 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { ); } } - // Typeck has checked that Const operands are integers. hir::InlineAsmOperand::Const { anon_const } => { - debug_assert_matches!( - self.tcx.type_of(anon_const.def_id).instantiate_identity().kind(), - ty::Error(_) | ty::Int(_) | ty::Uint(_) - ); + let ty = self.node_ty(anon_const.hir_id); + match ty.kind() { + ty::Error(_) => {} + _ if ty.is_integral() => {} + _ => { + self.tcx + .dcx() + .struct_span_err(op_sp, "invalid type for `const` operand") + .with_span_label( + self.tcx.def_span(anon_const.def_id), + format!("is {} `{}`", ty.kind().article(), ty), + ) + .with_help("`const` operands must be of an integer type") + .emit(); + } + } } // Typeck has checked that SymFn refers to a function. hir::InlineAsmOperand::SymFn { expr } => { diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index e6ea6eddcaa..d72cf00293f 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -966,7 +966,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(), let ty = tcx.type_of(param.def_id).instantiate_identity(); if tcx.features().unsized_const_params() { - enter_wf_checking_ctxt(tcx, hir_ty.span, param.def_id, |wfcx| { + enter_wf_checking_ctxt(tcx, hir_ty.span, tcx.local_parent(param.def_id), |wfcx| { wfcx.register_bound( ObligationCause::new( hir_ty.span, @@ -980,7 +980,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(), Ok(()) }) } else if tcx.features().adt_const_params() { - enter_wf_checking_ctxt(tcx, hir_ty.span, param.def_id, |wfcx| { + enter_wf_checking_ctxt(tcx, hir_ty.span, tcx.local_parent(param.def_id), |wfcx| { wfcx.register_bound( ObligationCause::new( hir_ty.span, diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 08d63f4349e..027aa5554a4 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -1822,6 +1822,9 @@ fn const_param_default<'tcx>( ), }; let icx = ItemCtxt::new(tcx, def_id); - let ct = icx.lowerer().lower_const_arg(default_ct, FeedConstTy::Param(def_id.to_def_id())); + let identity_args = ty::GenericArgs::identity_for_item(tcx, def_id); + let ct = icx + .lowerer() + .lower_const_arg(default_ct, FeedConstTy::Param(def_id.to_def_id(), identity_args)); ty::EarlyBinder::bind(ct) } diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 2cdd9a3a934..af1338e50d0 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -186,17 +186,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { { Some(parent_did) } - // Exclude `GlobalAsm` here which cannot have generics. - Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. }) - if asm.operands.iter().any(|(op, _op_sp)| match op { - hir::InlineAsmOperand::Const { anon_const } => { - anon_const.hir_id == hir_id - } - _ => false, - }) => - { - Some(parent_did) - } Node::TyPat(_) => Some(parent_did), _ => None, } diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 44e172a7b70..2022127a15b 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -223,10 +223,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen } hir::GenericParamKind::Const { .. } => { let param_def_id = param.def_id.to_def_id(); - let ct_ty = tcx - .type_of(param_def_id) - .no_bound_vars() - .expect("const parameters cannot be generic"); + let ct_ty = tcx.type_of(param_def_id).instantiate_identity(); let ct = icx.lowerer().lower_const_param(param_def_id, param.hir_id); predicates .insert((ty::ClauseKind::ConstArgHasType(ct, ct_ty).upcast(tcx), param.span)); diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index d564dc9699a..6936544838c 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -8,7 +8,7 @@ use rustc_middle::query::plumbing::CyclePlaceholder; use rustc_middle::ty::fold::fold_regions; use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::util::IntTypeExt; -use rustc_middle::ty::{self, Article, IsSuggestable, Ty, TyCtxt, TypeVisitableExt}; +use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::{bug, span_bug}; use rustc_span::{DUMMY_SP, Ident, Span}; @@ -35,13 +35,6 @@ fn anon_const_type_of<'tcx>(icx: &ItemCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx let parent_node_id = tcx.parent_hir_id(hir_id); let parent_node = tcx.hir_node(parent_node_id); - let find_const = |&(op, op_sp)| match op { - hir::InlineAsmOperand::Const { anon_const } if anon_const.hir_id == hir_id => { - Some((anon_const, op_sp)) - } - _ => None, - }; - match parent_node { // Anon consts "inside" the type system. Node::ConstArg(&ConstArg { @@ -50,31 +43,6 @@ fn anon_const_type_of<'tcx>(icx: &ItemCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx .. }) if anon_hir_id == hir_id => const_arg_anon_type_of(icx, arg_hir_id, span), - // Anon consts outside the type system. - Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. }) - | Node::Item(&Item { kind: ItemKind::GlobalAsm { asm, .. }, .. }) - if let Some((anon_const, op_sp)) = asm.operands.iter().find_map(find_const) => - { - let ty = tcx.typeck(def_id).node_type(hir_id); - - match ty.kind() { - ty::Error(_) => ty, - ty::Int(_) | ty::Uint(_) => ty, - _ => { - let guar = tcx - .dcx() - .struct_span_err(op_sp, "invalid type for `const` operand") - .with_span_label( - tcx.def_span(anon_const.def_id), - format!("is {} `{}`", ty.kind().article(), ty), - ) - .with_help("`const` operands must be of an integer type") - .emit(); - - Ty::new_error(tcx, guar) - } - } - } Node::Variant(Variant { disr_expr: Some(e), .. }) if e.hir_id == hir_id => { tcx.adt_def(tcx.hir_get_parent_item(hir_id)).repr().discr_type().to_ty(tcx) } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs index 8d58a3bfbd3..fa58f12c553 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs @@ -273,7 +273,7 @@ pub fn lower_generic_args<'tcx: 'a, 'a>( // We lower to an infer even when the feature gate is not enabled // as it is useful for diagnostics to be able to see a `ConstKind::Infer` - args.push(ctx.provided_kind(param, arg)); + args.push(ctx.provided_kind(&args, param, arg)); args_iter.next(); params.next(); } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 750770178ee..a0f848f07c4 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -232,12 +232,15 @@ impl AssocItemQSelf { /// Use this enum with `<dyn HirTyLowerer>::lower_const_arg` to instruct it with the /// desired behavior. #[derive(Debug, Clone, Copy)] -pub enum FeedConstTy { +pub enum FeedConstTy<'a, 'tcx> { /// Feed the type. /// /// The `DefId` belongs to the const param that we are supplying /// this (anon) const arg to. - Param(DefId), + /// + /// The list of generic args is used to instantiate the parameters + /// used by the type of the const param specified by `DefId`. + Param(DefId, &'a [ty::GenericArg<'tcx>]), /// Don't feed the type. No, } @@ -298,6 +301,7 @@ pub trait GenericArgsLowerer<'a, 'tcx> { fn provided_kind( &mut self, + preceding_args: &[ty::GenericArg<'tcx>], param: &ty::GenericParamDef, arg: &GenericArg<'tcx>, ) -> ty::GenericArg<'tcx>; @@ -481,6 +485,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { fn provided_kind( &mut self, + preceding_args: &[ty::GenericArg<'tcx>], param: &ty::GenericParamDef, arg: &GenericArg<'tcx>, ) -> ty::GenericArg<'tcx> { @@ -526,7 +531,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { (GenericParamDefKind::Const { .. }, GenericArg::Const(ct)) => self .lowerer // Ambig portions of `ConstArg` are handled in the match arm below - .lower_const_arg(ct.as_unambig_ct(), FeedConstTy::Param(param.def_id)) + .lower_const_arg( + ct.as_unambig_ct(), + FeedConstTy::Param(param.def_id, preceding_args), + ) .into(), (&GenericParamDefKind::Const { .. }, GenericArg::Infer(inf)) => { self.lowerer.ct_infer(Some(param), inf.span).into() @@ -582,8 +590,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let ty = tcx .at(self.span) .type_of(param.def_id) - .no_bound_vars() - .expect("const parameter types cannot be generic"); + .instantiate(tcx, preceding_args); if let Err(guar) = ty.error_reported() { return ty::Const::new_error(tcx, guar).into(); } @@ -2107,14 +2114,50 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { pub fn lower_const_arg( &self, const_arg: &hir::ConstArg<'tcx>, - feed: FeedConstTy, + feed: FeedConstTy<'_, 'tcx>, ) -> Const<'tcx> { let tcx = self.tcx(); - if let FeedConstTy::Param(param_def_id) = feed + if let FeedConstTy::Param(param_def_id, args) = feed && let hir::ConstArgKind::Anon(anon) = &const_arg.kind { - tcx.feed_anon_const_type(anon.def_id, tcx.type_of(param_def_id)); + let anon_const_type = tcx.type_of(param_def_id).instantiate(tcx, args); + + // We must error if the instantiated type has any inference variables as we will + // use this type to feed the `type_of` and query results must not contain inference + // variables otherwise we will ICE. + // + // We also error if the type contains any regions as effectively any region will wind + // up as a region variable in mir borrowck. It would also be somewhat concerning if + // hir typeck was using equality but mir borrowck wound up using subtyping as that could + // result in a non-infer in hir typeck but a region variable in borrowck. + // + // FIXME(generic_const_parameter_types): Ideally we remove these errors one day when + // we have the ability to intermix typeck of anon const const args with the parent + // bodies typeck. + if tcx.features().generic_const_parameter_types() + && (anon_const_type.has_free_regions() || anon_const_type.has_erased_regions()) + { + let e = tcx.dcx().span_err( + const_arg.span(), + "anonymous constants with lifetimes in their type are not yet supported", + ); + tcx.feed_anon_const_type(anon.def_id, ty::EarlyBinder::bind(Ty::new_error(tcx, e))); + return ty::Const::new_error(tcx, e); + } + if anon_const_type.has_non_region_infer() { + let e = tcx.dcx().span_err( + const_arg.span(), + "anonymous constants with inferred types are not yet supported", + ); + tcx.feed_anon_const_type(anon.def_id, ty::EarlyBinder::bind(Ty::new_error(tcx, e))); + return ty::Const::new_error(tcx, e); + } + + tcx.feed_anon_const_type( + anon.def_id, + ty::EarlyBinder::bind(tcx.type_of(param_def_id).instantiate(tcx, args)), + ); } let hir_id = const_arg.hir_id; @@ -2230,10 +2273,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let expr = &tcx.hir_body(anon.body).value; debug!(?expr); - let ty = tcx - .type_of(anon.def_id) - .no_bound_vars() - .expect("const parameter types cannot be generic"); + // FIXME(generic_const_parameter_types): We should use the proper generic args + // here. It's only used as a hint for literals so doesn't matter too much to use the right + // generic arguments, just weaker type inference. + let ty = tcx.type_of(anon.def_id).instantiate_identity(); match self.try_lower_anon_const_lit(ty, expr) { Some(v) => v, diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index bdfbd540e40..cf18bab950a 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -260,7 +260,7 @@ pub fn lower_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> { pub fn lower_const_arg_for_rustdoc<'tcx>( tcx: TyCtxt<'tcx>, hir_ct: &hir::ConstArg<'tcx>, - feed: FeedConstTy, + feed: FeedConstTy<'_, 'tcx>, ) -> Const<'tcx> { let env_def_id = tcx.hir_get_parent_item(hir_ct.hir_id); collect::ItemCtxt::new(tcx, env_def_id.def_id).lowerer().lower_const_arg(hir_ct, feed) diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index b3377b48769..e06398cf3c4 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1413,7 +1413,8 @@ impl<'a> State<'a> { hir::InlineAsmOperand::Const { ref anon_const } => { s.word("const"); s.space(); - s.print_anon_const(anon_const); + // Not using `print_inline_const` to avoid additional `const { ... }` + s.ann.nested(s, Nested::Body(anon_const.body)) } hir::InlineAsmOperand::SymFn { ref expr } => { s.word("sym_fn"); diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 462983be88d..ea4ec345ad0 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -895,20 +895,22 @@ impl<'a, 'tcx> CastCheck<'tcx> { // e.g. we want to allow `dyn T -> (dyn T,)`, etc. // // We also need to skip auto traits to emit an FCW and not an error. - let src_obj = tcx.mk_ty_from_kind(ty::Dynamic( + let src_obj = Ty::new_dynamic( + tcx, tcx.mk_poly_existential_predicates( &src_tty.without_auto_traits().collect::<Vec<_>>(), ), tcx.lifetimes.re_erased, ty::Dyn, - )); - let dst_obj = tcx.mk_ty_from_kind(ty::Dynamic( + ); + let dst_obj = Ty::new_dynamic( + tcx, tcx.mk_poly_existential_predicates( &dst_tty.without_auto_traits().collect::<Vec<_>>(), ), tcx.lifetimes.re_erased, ty::Dyn, - )); + ); // `dyn Src = dyn Dst`, this checks for matching traits/generics/projections // This is `fcx.demand_eqtype`, but inlined to give a better error. diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 43dfec0f408..dec1779d92c 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -1853,12 +1853,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return Ty::new_error(tcx, guar); } + // We defer checking whether the element type is `Copy` as it is possible to have + // an inference variable as a repeat count and it seems unlikely that `Copy` would + // have inference side effects required for type checking to succeed. + if tcx.features().generic_arg_infer() { + self.deferred_repeat_expr_checks.borrow_mut().push((element, element_ty, count)); // If the length is 0, we don't create any elements, so we don't copy any. // If the length is 1, we don't copy that one element, we move it. Only check // for `Copy` if the length is larger, or unevaluated. - // FIXME(min_const_generic_exprs): We could perhaps defer this check so that - // we don't require `<?0t as Tr>::CONST` doesn't unnecessarily require `Copy`. - if count.try_to_target_usize(tcx).is_none_or(|x| x > 1) { + } else if count.try_to_target_usize(self.tcx).is_none_or(|x| x > 1) { self.enforce_repeat_element_needs_copy_bound(element, element_ty); } @@ -1868,7 +1871,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } /// Requires that `element_ty` is `Copy` (unless it's a const expression itself). - fn enforce_repeat_element_needs_copy_bound( + pub(super) fn enforce_repeat_element_needs_copy_bound( &self, element: &hir::Expr<'_>, element_ty: Ty<'tcx>, @@ -3771,13 +3774,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.check_expr_asm_operand(out_expr, false); } } + hir::InlineAsmOperand::Const { ref anon_const } => { + self.check_expr_const_block(anon_const, Expectation::NoExpectation); + } hir::InlineAsmOperand::SymFn { expr } => { self.check_expr(expr); } - // `AnonConst`s have their own body and is type-checked separately. - // As they don't flow into the type system we don't need them to - // be well-formed. - hir::InlineAsmOperand::Const { .. } => {} hir::InlineAsmOperand::SymStatic { .. } => {} hir::InlineAsmOperand::Label { block } => { let previous_diverges = self.diverges.get(); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 2d7d80e39bc..054e3bcb67c 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -85,25 +85,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }) } - /// Resolves type and const variables in `ty` if possible. Unlike the infcx + /// Resolves type and const variables in `t` if possible. Unlike the infcx /// version (resolve_vars_if_possible), this version will /// also select obligations if it seems useful, in an effort /// to get more type information. // FIXME(-Znext-solver): A lot of the calls to this method should // probably be `try_structurally_resolve_type` or `structurally_resolve_type` instead. #[instrument(skip(self), level = "debug", ret)] - pub(crate) fn resolve_vars_with_obligations(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> { + pub(crate) fn resolve_vars_with_obligations<T: TypeFoldable<TyCtxt<'tcx>>>( + &self, + mut t: T, + ) -> T { // No Infer()? Nothing needs doing. - if !ty.has_non_region_infer() { + if !t.has_non_region_infer() { debug!("no inference var, nothing needs doing"); - return ty; + return t; } - // If `ty` is a type variable, see whether we already know what it is. - ty = self.resolve_vars_if_possible(ty); - if !ty.has_non_region_infer() { - debug!(?ty); - return ty; + // If `t` is a type variable, see whether we already know what it is. + t = self.resolve_vars_if_possible(t); + if !t.has_non_region_infer() { + debug!(?t); + return t; } // If not, try resolving pending obligations as much as @@ -111,7 +114,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // indirect dependencies that don't seem worth tracking // precisely. self.select_obligations_where_possible(|_| {}); - self.resolve_vars_if_possible(ty) + self.resolve_vars_if_possible(t) } pub(crate) fn record_deferred_call_resolution( @@ -519,7 +522,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(crate) fn lower_const_arg( &self, const_arg: &'tcx hir::ConstArg<'tcx>, - feed: FeedConstTy, + feed: FeedConstTy<'_, 'tcx>, ) -> ty::Const<'tcx> { let ct = self.lowerer().lower_const_arg(const_arg, feed); self.register_wf_obligation( @@ -1135,7 +1138,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .last() .is_some_and(|GenericPathSegment(def_id, _)| tcx.generics_of(*def_id).has_self); - let (res, self_ctor_args) = if let Res::SelfCtor(impl_def_id) = res { + let (res, implicit_args) = if let Res::Def(DefKind::ConstParam, def) = res { + // types of const parameters are somewhat special as they are part of + // the same environment as the const parameter itself. this means that + // unlike most paths `type-of(N)` can return a type naming parameters + // introduced by the containing item, rather than provided through `N`. + // + // for example given `<T, const M: usize, const N: [T; M]>` and some + // `let a = N;` expression. The path to `N` would wind up with no args + // (as it has no args), but instantiating the early binder on `typeof(N)` + // requires providing generic arguments for `[T, M, N]`. + (res, Some(ty::GenericArgs::identity_for_item(tcx, tcx.parent(def)))) + } else if let Res::SelfCtor(impl_def_id) = res { let ty = LoweredTy::from_raw( self, span, @@ -1261,6 +1275,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn provided_kind( &mut self, + preceding_args: &[ty::GenericArg<'tcx>], param: &ty::GenericParamDef, arg: &GenericArg<'tcx>, ) -> ty::GenericArg<'tcx> { @@ -1280,7 +1295,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (GenericParamDefKind::Const { .. }, GenericArg::Const(ct)) => self .fcx // Ambiguous parts of `ConstArg` are handled in the match arms below - .lower_const_arg(ct.as_unambig_ct(), FeedConstTy::Param(param.def_id)) + .lower_const_arg( + ct.as_unambig_ct(), + FeedConstTy::Param(param.def_id, preceding_args), + ) .into(), (&GenericParamDefKind::Const { .. }, GenericArg::Infer(inf)) => { self.fcx.ct_infer(Some(param), inf.span).into() @@ -1320,7 +1338,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - let args_raw = self_ctor_args.unwrap_or_else(|| { + let args_raw = implicit_args.unwrap_or_else(|| { lower_generic_args( self, def_id, @@ -1454,7 +1472,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { sp: Span, ct: ty::Const<'tcx>, ) -> ty::Const<'tcx> { - // FIXME(min_const_generic_exprs): We could process obligations here if `ct` is a var. + let ct = self.resolve_vars_with_obligations(ct); if self.next_trait_solver() && let ty::ConstKind::Unevaluated(..) = ct.kind() @@ -1510,6 +1528,32 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } + pub(crate) fn structurally_resolve_const( + &self, + sp: Span, + ct: ty::Const<'tcx>, + ) -> ty::Const<'tcx> { + let ct = self.try_structurally_resolve_const(sp, ct); + + if !ct.is_ct_infer() { + ct + } else { + let e = self.tainted_by_errors().unwrap_or_else(|| { + self.err_ctxt() + .emit_inference_failure_err( + self.body_id, + sp, + ct.into(), + TypeAnnotationNeeded::E0282, + true, + ) + .emit() + }); + // FIXME: Infer `?ct = {const error}`? + ty::Const::new_error(self.tcx, e) + } + } + pub(crate) fn with_breakable_ctxt<F: FnOnce() -> R, R>( &self, id: HirId, diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 63c1c060827..e60a4bb47b5 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -110,8 +110,40 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.tcx.erase_regions(ty) } }; - InlineAsmCtxt::new(self.tcx, enclosing_id, self.typing_env(self.param_env), expr_ty) - .check_asm(asm); + let node_ty = |hir_id: HirId| self.typeck_results.borrow().node_type(hir_id); + InlineAsmCtxt::new( + self.tcx, + enclosing_id, + self.typing_env(self.param_env), + expr_ty, + node_ty, + ) + .check_asm(asm); + } + } + + pub(in super::super) fn check_repeat_exprs(&self) { + let mut deferred_repeat_expr_checks = self.deferred_repeat_expr_checks.borrow_mut(); + debug!("FnCtxt::check_repeat_exprs: {} deferred checks", deferred_repeat_expr_checks.len()); + for (element, element_ty, count) in deferred_repeat_expr_checks.drain(..) { + // We want to emit an error if the const is not structurally resolveable as otherwise + // we can find up conservatively proving `Copy` which may infer the repeat expr count + // to something that never required `Copy` in the first place. + let count = + self.structurally_resolve_const(element.span, self.normalize(element.span, count)); + + // Avoid run on "`NotCopy: Copy` is not implemented" errors when the repeat expr count + // is erroneous/unknown. The user might wind up specifying a repeat count of 0/1. + if count.references_error() { + continue; + } + + // If the length is 0, we don't create any elements, so we don't copy any. + // If the length is 1, we don't copy that one element, we move it. Only check + // for `Copy` if the length is larger. + if count.try_to_target_usize(self.tcx).is_none_or(|x| x > 1) { + self.enforce_repeat_element_needs_copy_bound(element, element_ty); + } } } diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index 0130ad775d9..8b9c2b4a6ca 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -199,6 +199,15 @@ fn typeck_with_inspect<'tcx>( fcx.write_ty(id, expected_type); }; + // Whether to check repeat exprs before/after inference fallback is somewhat arbitrary of a decision + // as neither option is strictly more permissive than the other. However, we opt to check repeat exprs + // first as errors from not having inferred array lengths yet seem less confusing than errors from inference + // fallback arbitrarily inferring something incompatible with `Copy` inference side effects. + // + // This should also be forwards compatible with moving repeat expr checks to a custom goal kind or using + // marker traits in the future. + fcx.check_repeat_exprs(); + fcx.type_inference_fallback(); // Even though coercion casts provide type hints, we check casts after fallback for diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 3b107fbf173..0483164ca03 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -426,6 +426,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { fn provided_kind( &mut self, + preceding_args: &[ty::GenericArg<'tcx>], param: &ty::GenericParamDef, arg: &GenericArg<'tcx>, ) -> ty::GenericArg<'tcx> { @@ -446,7 +447,10 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { (GenericParamDefKind::Const { .. }, GenericArg::Const(ct)) => self .cfcx // We handle the ambig portions of `ConstArg` in the match arms below - .lower_const_arg(ct.as_unambig_ct(), FeedConstTy::Param(param.def_id)) + .lower_const_arg( + ct.as_unambig_ct(), + FeedConstTy::Param(param.def_id, preceding_args), + ) .into(), (GenericParamDefKind::Const { .. }, GenericArg::Infer(inf)) => { self.cfcx.ct_infer(Some(param), inf.span).into() diff --git a/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs b/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs index 903be7e732a..381606a9fb0 100644 --- a/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs +++ b/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs @@ -62,6 +62,9 @@ pub(crate) struct TypeckRootCtxt<'tcx> { pub(super) deferred_coroutine_interiors: RefCell<Vec<(LocalDefId, hir::BodyId, Ty<'tcx>)>>, + pub(super) deferred_repeat_expr_checks: + RefCell<Vec<(&'tcx hir::Expr<'tcx>, Ty<'tcx>, ty::Const<'tcx>)>>, + /// Whenever we introduce an adjustment from `!` into a type variable, /// we record that type variable here. This is later used to inform /// fallback. See the `fallback` module for details. @@ -96,6 +99,7 @@ impl<'tcx> TypeckRootCtxt<'tcx> { deferred_transmute_checks: RefCell::new(Vec::new()), deferred_asm_checks: RefCell::new(Vec::new()), deferred_coroutine_interiors: RefCell::new(Vec::new()), + deferred_repeat_expr_checks: RefCell::new(Vec::new()), diverging_type_vars: RefCell::new(Default::default()), infer_var_info: RefCell::new(Default::default()), } diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index 9857f4434ff..d7d7d6a20ac 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -248,13 +248,6 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { } } } - - fn visit_const_block(&mut self, span: Span, anon_const: &hir::ConstBlock) { - self.visit_node_id(span, anon_const.hir_id); - - let body = self.tcx().hir_body(anon_const.body); - self.visit_body(body); - } } /////////////////////////////////////////////////////////////////////////// @@ -284,9 +277,6 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> { hir::ExprKind::Field(..) | hir::ExprKind::OffsetOf(..) => { self.visit_field_id(e.hir_id); } - hir::ExprKind::ConstBlock(ref anon_const) => { - self.visit_const_block(e.span, anon_const); - } _ => {} } @@ -297,6 +287,14 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> { self.fix_index_builtin_expr(e); } + fn visit_inline_const(&mut self, anon_const: &hir::ConstBlock) { + let span = self.tcx().def_span(anon_const.def_id); + self.visit_node_id(span, anon_const.hir_id); + + let body = self.tcx().hir_body(anon_const.body); + self.visit_body(body); + } + fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) { match &p.kind { hir::GenericParamKind::Lifetime { .. } => { @@ -340,9 +338,6 @@ impl<'cx, 'tcx> Visitor<'tcx> for WritebackCx<'cx, 'tcx> { fn visit_pat_expr(&mut self, expr: &'tcx hir::PatExpr<'tcx>) { self.visit_node_id(expr.span, expr.hir_id); - if let hir::PatExprKind::ConstBlock(c) = &expr.kind { - self.visit_const_block(expr.span, c); - } intravisit::walk_pat_expr(self, expr); } diff --git a/compiler/rustc_infer/src/infer/relate/higher_ranked.rs b/compiler/rustc_infer/src/infer/relate/higher_ranked.rs index 0998f3c4790..a12d83db91f 100644 --- a/compiler/rustc_infer/src/infer/relate/higher_ranked.rs +++ b/compiler/rustc_infer/src/infer/relate/higher_ranked.rs @@ -2,6 +2,7 @@ //! the end of the file for details. use rustc_middle::ty::fold::FnMutDelegate; +use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use tracing::{debug, instrument}; @@ -26,8 +27,9 @@ impl<'tcx> InferCtxt<'tcx> { where T: TypeFoldable<TyCtxt<'tcx>>, { - if let Some(inner) = binder.clone().no_bound_vars() { - return inner; + // Inlined `no_bound_vars`. + if !binder.as_ref().skip_binder().has_escaping_bound_vars() { + return binder.skip_binder(); } let next_universe = self.create_next_universe(); diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 9ce4abdb432..6e607baebb5 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -7,6 +7,7 @@ #include "llvm/Analysis/Lint.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Bitcode/BitcodeWriter.h" +#include "llvm/Bitcode/BitcodeWriterPass.h" #include "llvm/CodeGen/CommandFlags.h" #include "llvm/IR/AssemblyAnnotationWriter.h" #include "llvm/IR/AutoUpgrade.h" @@ -37,6 +38,7 @@ #include "llvm/Transforms/Instrumentation/InstrProfiling.h" #include "llvm/Transforms/Instrumentation/MemorySanitizer.h" #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" +#include "llvm/Transforms/Scalar/AnnotationRemarks.h" #include "llvm/Transforms/Utils/CanonicalizeAliases.h" #include "llvm/Transforms/Utils/FunctionImportUtils.h" #include "llvm/Transforms/Utils/NameAnonGlobals.h" @@ -195,6 +197,19 @@ extern "C" void LLVMRustTimeTraceProfilerFinish(const char *FileName) { GEN_SUBTARGETS #undef SUBTARGET +// This struct and various functions are sort of a hack right now, but the +// problem is that we've got in-memory LLVM modules after we generate and +// optimize all codegen-units for one compilation in rustc. To be compatible +// with the LTO support above we need to serialize the modules plus their +// ThinLTO summary into memory. +// +// This structure is basically an owned version of a serialize module, with +// a ThinLTO summary attached. +struct LLVMRustThinLTOBuffer { + std::string data; + std::string thin_link_data; +}; + extern "C" bool LLVMRustHasFeature(LLVMTargetMachineRef TM, const char *Feature) { TargetMachine *Target = unwrap(TM); @@ -704,7 +719,8 @@ extern "C" LLVMRustResult LLVMRustOptimize( LLVMModuleRef ModuleRef, LLVMTargetMachineRef TMRef, LLVMRustPassBuilderOptLevel OptLevelRust, LLVMRustOptStage OptStage, bool IsLinkerPluginLTO, bool NoPrepopulatePasses, bool VerifyIR, - bool LintIR, bool UseThinLTOBuffers, bool MergeFunctions, bool UnrollLoops, + bool LintIR, LLVMRustThinLTOBuffer **ThinLTOBufferRef, bool EmitThinLTO, + bool EmitThinLTOSummary, bool MergeFunctions, bool UnrollLoops, bool SLPVectorize, bool LoopVectorize, bool DisableSimplifyLibCalls, bool EmitLifetimeMarkers, bool RunEnzyme, LLVMRustSanitizerOptions *SanitizerOptions, const char *PGOGenPath, @@ -952,7 +968,10 @@ extern "C" LLVMRustResult LLVMRustOptimize( } ModulePassManager MPM; - bool NeedThinLTOBufferPasses = UseThinLTOBuffers; + bool NeedThinLTOBufferPasses = EmitThinLTO; + auto ThinLTOBuffer = std::make_unique<LLVMRustThinLTOBuffer>(); + raw_string_ostream ThinLTODataOS(ThinLTOBuffer->data); + raw_string_ostream ThinLinkDataOS(ThinLTOBuffer->thin_link_data); if (!NoPrepopulatePasses) { // The pre-link pipelines don't support O0 and require using // buildO0DefaultPipeline() instead. At the same time, the LTO pipelines do @@ -976,7 +995,25 @@ extern "C" LLVMRustResult LLVMRustOptimize( switch (OptStage) { case LLVMRustOptStage::PreLinkNoLTO: - MPM = PB.buildPerModuleDefaultPipeline(OptLevel); + if (ThinLTOBufferRef) { + // This is similar to LLVM's `buildFatLTODefaultPipeline`, where the + // bitcode for embedding is obtained after performing + // `ThinLTOPreLinkDefaultPipeline`. + MPM.addPass(PB.buildThinLTOPreLinkDefaultPipeline(OptLevel)); + if (EmitThinLTO) { + MPM.addPass(ThinLTOBitcodeWriterPass( + ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr)); + } else { + MPM.addPass(BitcodeWriterPass(ThinLTODataOS)); + } + *ThinLTOBufferRef = ThinLTOBuffer.release(); + MPM.addPass(PB.buildModuleOptimizationPipeline( + OptLevel, ThinOrFullLTOPhase::None)); + MPM.addPass( + createModuleToFunctionPassAdaptor(AnnotationRemarksPass())); + } else { + MPM = PB.buildPerModuleDefaultPipeline(OptLevel); + } break; case LLVMRustOptStage::PreLinkThinLTO: MPM = PB.buildThinLTOPreLinkDefaultPipeline(OptLevel); @@ -1022,6 +1059,16 @@ extern "C" LLVMRustResult LLVMRustOptimize( MPM.addPass(CanonicalizeAliasesPass()); MPM.addPass(NameAnonGlobalPass()); } + // For `-Copt-level=0`, ThinLTO, or LTO. + if (ThinLTOBufferRef && *ThinLTOBufferRef == nullptr) { + if (EmitThinLTO) { + MPM.addPass(ThinLTOBitcodeWriterPass( + ThinLTODataOS, EmitThinLTOSummary ? &ThinLinkDataOS : nullptr)); + } else { + MPM.addPass(BitcodeWriterPass(ThinLTODataOS)); + } + *ThinLTOBufferRef = ThinLTOBuffer.release(); + } // now load "-enzyme" pass: #ifdef ENZYME @@ -1500,19 +1547,6 @@ extern "C" bool LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, return true; } -// This struct and various functions are sort of a hack right now, but the -// problem is that we've got in-memory LLVM modules after we generate and -// optimize all codegen-units for one compilation in rustc. To be compatible -// with the LTO support above we need to serialize the modules plus their -// ThinLTO summary into memory. -// -// This structure is basically an owned version of a serialize module, with -// a ThinLTO summary attached. -struct LLVMRustThinLTOBuffer { - std::string data; - std::string thin_link_data; -}; - extern "C" LLVMRustThinLTOBuffer * LLVMRustThinLTOBufferCreate(LLVMModuleRef M, bool is_thin, bool emit_summary) { auto Ret = std::make_unique<LLVMRustThinLTOBuffer>(); diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs index 41958949836..fe42a224d9f 100644 --- a/compiler/rustc_middle/src/ty/codec.rs +++ b/compiler/rustc_middle/src/ty/codec.rs @@ -224,7 +224,7 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for Ty<'tcx> { }) } else { let tcx = decoder.interner(); - tcx.mk_ty_from_kind(rustc_type_ir::TyKind::decode(decoder)) + tcx.mk_ty_from_kind(ty::TyKind::decode(decoder)) } } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 38a3f722ca2..d0aa2b8cbda 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -324,11 +324,11 @@ impl<'tcx> Interner for TyCtxt<'tcx> { self.features() } - fn bound_coroutine_hidden_types( + fn coroutine_hidden_types( self, def_id: DefId, - ) -> impl IntoIterator<Item = ty::EarlyBinder<'tcx, ty::Binder<'tcx, Ty<'tcx>>>> { - self.bound_coroutine_hidden_types(def_id) + ) -> ty::EarlyBinder<'tcx, ty::Binder<'tcx, &'tcx ty::List<Ty<'tcx>>>> { + self.coroutine_hidden_types(def_id) } fn fn_sig(self, def_id: DefId) -> ty::EarlyBinder<'tcx, ty::PolyFnSig<'tcx>> { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index d926d6cc02a..527509af05f 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -992,12 +992,6 @@ impl<'tcx> ParamEnv<'tcx> { ParamEnv { caller_bounds } } - /// Returns this same environment but with no caller bounds. - #[inline] - pub fn without_caller_bounds(self) -> Self { - Self::new(ListWithCachedTypeInfo::empty()) - } - /// Creates a pair of param-env and value for use in queries. pub fn and<T: TypeVisitable<TyCtxt<'tcx>>>(self, value: T) -> ParamEnvAnd<'tcx, T> { ParamEnvAnd { param_env: self, value } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index d5617adf26b..ce563c59251 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -342,6 +342,7 @@ impl ParamConst { ParamConst::new(def.index, def.name) } + #[instrument(level = "debug")] pub fn find_ty_from_env<'tcx>(self, env: ParamEnv<'tcx>) -> Ty<'tcx> { let mut candidates = env.caller_bounds().iter().filter_map(|clause| { // `ConstArgHasType` are never desugared to be higher ranked. @@ -461,7 +462,7 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn new_param(tcx: TyCtxt<'tcx>, index: u32, name: Symbol) -> Ty<'tcx> { - tcx.mk_ty_from_kind(Param(ParamTy { index, name })) + Ty::new(tcx, Param(ParamTy { index, name })) } #[inline] diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 4d917963cd6..237aa66f486 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -740,51 +740,37 @@ impl<'tcx> TyCtxt<'tcx> { } /// Return the set of types that should be taken into account when checking - /// trait bounds on a coroutine's internal state. - // FIXME(compiler-errors): We should remove this when the old solver goes away; - // and all other usages of this function should go through `bound_coroutine_hidden_types` - // instead. - pub fn coroutine_hidden_types( - self, - def_id: DefId, - ) -> impl Iterator<Item = ty::EarlyBinder<'tcx, Ty<'tcx>>> { - let coroutine_layout = self.mir_coroutine_witnesses(def_id); - coroutine_layout - .as_ref() - .map_or_else(|| [].iter(), |l| l.field_tys.iter()) - .filter(|decl| !decl.ignore_for_traits) - .map(|decl| ty::EarlyBinder::bind(decl.ty)) - } - - /// Return the set of types that should be taken into account when checking /// trait bounds on a coroutine's internal state. This properly replaces /// `ReErased` with new existential bound lifetimes. - pub fn bound_coroutine_hidden_types( + pub fn coroutine_hidden_types( self, def_id: DefId, - ) -> impl Iterator<Item = ty::EarlyBinder<'tcx, ty::Binder<'tcx, Ty<'tcx>>>> { + ) -> ty::EarlyBinder<'tcx, ty::Binder<'tcx, &'tcx ty::List<Ty<'tcx>>>> { let coroutine_layout = self.mir_coroutine_witnesses(def_id); - coroutine_layout - .as_ref() - .map_or_else(|| [].iter(), |l| l.field_tys.iter()) - .filter(|decl| !decl.ignore_for_traits) - .map(move |decl| { - let mut vars = vec![]; - let ty = fold_regions(self, decl.ty, |re, debruijn| { - assert_eq!(re, self.lifetimes.re_erased); - let var = ty::BoundVar::from_usize(vars.len()); - vars.push(ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon)); - ty::Region::new_bound( - self, - debruijn, - ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon }, - ) - }); - ty::EarlyBinder::bind(ty::Binder::bind_with_vars( - ty, - self.mk_bound_variable_kinds(&vars), - )) - }) + let mut vars = vec![]; + let bound_tys = self.mk_type_list_from_iter( + coroutine_layout + .as_ref() + .map_or_else(|| [].iter(), |l| l.field_tys.iter()) + .filter(|decl| !decl.ignore_for_traits) + .map(|decl| { + let ty = fold_regions(self, decl.ty, |re, debruijn| { + assert_eq!(re, self.lifetimes.re_erased); + let var = ty::BoundVar::from_usize(vars.len()); + vars.push(ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon)); + ty::Region::new_bound( + self, + debruijn, + ty::BoundRegion { var, kind: ty::BoundRegionKind::Anon }, + ) + }); + ty + }), + ); + ty::EarlyBinder::bind(ty::Binder::bind_with_vars( + bound_tys, + self.mk_bound_variable_kinds(&vars), + )) } /// Expands the given impl trait type, stopping if the type is recursive. diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 88877d05ffa..7139516702e 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -730,12 +730,20 @@ impl<'tcx> ThirBuildCx<'tcx> { } } hir::InlineAsmOperand::Const { ref anon_const } => { - let value = - mir::Const::from_unevaluated(tcx, anon_const.def_id.to_def_id()) - .instantiate_identity(); - let span = tcx.def_span(anon_const.def_id); - - InlineAsmOperand::Const { value, span } + let ty = self.typeck_results.node_type(anon_const.hir_id); + let did = anon_const.def_id.to_def_id(); + let typeck_root_def_id = tcx.typeck_root_def_id(did); + let parent_args = tcx.erase_regions(GenericArgs::identity_for_item( + tcx, + typeck_root_def_id, + )); + let args = + InlineConstArgs::new(tcx, InlineConstArgsParts { parent_args, ty }) + .args; + + let uneval = mir::UnevaluatedConst::new(did, args); + let value = mir::Const::Unevaluated(uneval, ty); + InlineAsmOperand::Const { value, span: tcx.def_span(did) } } hir::InlineAsmOperand::SymFn { expr } => { InlineAsmOperand::SymFn { value: self.mirror_expr(expr) } diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 29521d42720..981dedd5b5c 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -1567,7 +1567,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { BackendRepr::ScalarPair(a, b) => { !a.is_always_valid(&self.ecx) || !b.is_always_valid(&self.ecx) } - BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => false, + BackendRepr::SimdVector { .. } | BackendRepr::Memory { .. } => false, } } diff --git a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs index 4c8dd933317..9f26da7d5c6 100644 --- a/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs +++ b/compiler/rustc_monomorphize/src/mono_checks/abi_check.rs @@ -18,7 +18,7 @@ fn uses_vector_registers(mode: &PassMode, repr: &BackendRepr) -> bool { cast.prefix.iter().any(|r| r.is_some_and(|x| x.kind == RegKind::Vector)) || cast.rest.unit.kind == RegKind::Vector } - PassMode::Direct(..) | PassMode::Pair(..) => matches!(repr, BackendRepr::Vector { .. }), + PassMode::Direct(..) | PassMode::Pair(..) => matches!(repr, BackendRepr::SimdVector { .. }), } } diff --git a/compiler/rustc_next_trait_solver/src/delegate.rs b/compiler/rustc_next_trait_solver/src/delegate.rs index a64941cce3a..850d86d91e8 100644 --- a/compiler/rustc_next_trait_solver/src/delegate.rs +++ b/compiler/rustc_next_trait_solver/src/delegate.rs @@ -102,7 +102,6 @@ pub trait SolverDelegate: Deref<Target = Self::Infcx> + Sized { fn is_transmutable( &self, - param_env: <Self::Interner as Interner>::ParamEnv, dst: <Self::Interner as Interner>::Ty, src: <Self::Interner as Interner>::Ty, assume: <Self::Interner as Interner>::Const, diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs index dc0f4c4483e..93804b14125 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs @@ -18,7 +18,7 @@ use crate::solve::{AdtDestructorKind, EvalCtxt, Goal, NoSolution}; pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<D, I>( ecx: &EvalCtxt<'_, D>, ty: I::Ty, -) -> Result<Vec<ty::Binder<I, I::Ty>>, NoSolution> +) -> Result<ty::Binder<I, Vec<I::Ty>>, NoSolution> where D: SolverDelegate<Interner = I>, I: Interner, @@ -33,10 +33,10 @@ where | ty::FnPtr(..) | ty::Error(_) | ty::Never - | ty::Char => Ok(vec![]), + | ty::Char => Ok(ty::Binder::dummy(vec![])), // Treat `str` like it's defined as `struct str([u8]);` - ty::Str => Ok(vec![ty::Binder::dummy(Ty::new_slice(cx, Ty::new_u8(cx)))]), + ty::Str => Ok(ty::Binder::dummy(vec![Ty::new_slice(cx, Ty::new_u8(cx))])), ty::Dynamic(..) | ty::Param(..) @@ -49,53 +49,49 @@ where } ty::RawPtr(element_ty, _) | ty::Ref(_, element_ty, _) => { - Ok(vec![ty::Binder::dummy(element_ty)]) + Ok(ty::Binder::dummy(vec![element_ty])) } ty::Pat(element_ty, _) | ty::Array(element_ty, _) | ty::Slice(element_ty) => { - Ok(vec![ty::Binder::dummy(element_ty)]) + Ok(ty::Binder::dummy(vec![element_ty])) } ty::Tuple(tys) => { // (T1, ..., Tn) -- meets any bound that all of T1...Tn meet - Ok(tys.iter().map(ty::Binder::dummy).collect()) + Ok(ty::Binder::dummy(tys.to_vec())) } - ty::Closure(_, args) => Ok(vec![ty::Binder::dummy(args.as_closure().tupled_upvars_ty())]), + ty::Closure(_, args) => Ok(ty::Binder::dummy(vec![args.as_closure().tupled_upvars_ty()])), ty::CoroutineClosure(_, args) => { - Ok(vec![ty::Binder::dummy(args.as_coroutine_closure().tupled_upvars_ty())]) + Ok(ty::Binder::dummy(vec![args.as_coroutine_closure().tupled_upvars_ty()])) } ty::Coroutine(_, args) => { let coroutine_args = args.as_coroutine(); - Ok(vec![ - ty::Binder::dummy(coroutine_args.tupled_upvars_ty()), - ty::Binder::dummy(coroutine_args.witness()), - ]) + Ok(ty::Binder::dummy(vec![coroutine_args.tupled_upvars_ty(), coroutine_args.witness()])) } ty::CoroutineWitness(def_id, args) => Ok(ecx .cx() - .bound_coroutine_hidden_types(def_id) - .into_iter() - .map(|bty| bty.instantiate(cx, args)) - .collect()), + .coroutine_hidden_types(def_id) + .instantiate(cx, args) + .map_bound(|tys| tys.to_vec())), - ty::UnsafeBinder(bound_ty) => Ok(vec![bound_ty.into()]), + ty::UnsafeBinder(bound_ty) => Ok(bound_ty.map_bound(|ty| vec![ty])), // For `PhantomData<T>`, we pass `T`. - ty::Adt(def, args) if def.is_phantom_data() => Ok(vec![ty::Binder::dummy(args.type_at(0))]), + ty::Adt(def, args) if def.is_phantom_data() => Ok(ty::Binder::dummy(vec![args.type_at(0)])), ty::Adt(def, args) => { - Ok(def.all_field_tys(cx).iter_instantiated(cx, args).map(ty::Binder::dummy).collect()) + Ok(ty::Binder::dummy(def.all_field_tys(cx).iter_instantiated(cx, args).collect())) } ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => { // We can resolve the `impl Trait` to its concrete type, // which enforces a DAG between the functions requiring // the auto trait bounds in question. - Ok(vec![ty::Binder::dummy(cx.type_of(def_id).instantiate(cx, args))]) + Ok(ty::Binder::dummy(vec![cx.type_of(def_id).instantiate(cx, args)])) } } } @@ -104,7 +100,7 @@ where pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<D, I>( ecx: &EvalCtxt<'_, D>, ty: I::Ty, -) -> Result<Vec<ty::Binder<I, I::Ty>>, NoSolution> +) -> Result<ty::Binder<I, Vec<I::Ty>>, NoSolution> where D: SolverDelegate<Interner = I>, I: Interner, @@ -130,7 +126,7 @@ where | ty::CoroutineClosure(..) | ty::Never | ty::Dynamic(_, _, ty::DynStar) - | ty::Error(_) => Ok(vec![]), + | ty::Error(_) => Ok(ty::Binder::dummy(vec![])), ty::Str | ty::Slice(_) @@ -145,11 +141,11 @@ where panic!("unexpected type `{ty:?}`") } - ty::UnsafeBinder(bound_ty) => Ok(vec![bound_ty.into()]), + ty::UnsafeBinder(bound_ty) => Ok(bound_ty.map_bound(|ty| vec![ty])), // impl Sized for () // impl Sized for (T1, T2, .., Tn) where Tn: Sized if n >= 1 - ty::Tuple(tys) => Ok(tys.last().map_or_else(Vec::new, |ty| vec![ty::Binder::dummy(ty)])), + ty::Tuple(tys) => Ok(ty::Binder::dummy(tys.last().map_or_else(Vec::new, |ty| vec![ty]))), // impl Sized for Adt<Args...> where sized_constraint(Adt)<Args...>: Sized // `sized_constraint(Adt)` is the deepest struct trail that can be determined @@ -162,9 +158,9 @@ where // if the ADT is sized for all possible args. ty::Adt(def, args) => { if let Some(sized_crit) = def.sized_constraint(ecx.cx()) { - Ok(vec![ty::Binder::dummy(sized_crit.instantiate(ecx.cx(), args))]) + Ok(ty::Binder::dummy(vec![sized_crit.instantiate(ecx.cx(), args)])) } else { - Ok(vec![]) + Ok(ty::Binder::dummy(vec![])) } } } @@ -174,14 +170,14 @@ where pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<D, I>( ecx: &EvalCtxt<'_, D>, ty: I::Ty, -) -> Result<Vec<ty::Binder<I, I::Ty>>, NoSolution> +) -> Result<ty::Binder<I, Vec<I::Ty>>, NoSolution> where D: SolverDelegate<Interner = I>, I: Interner, { match ty.kind() { // impl Copy/Clone for FnDef, FnPtr - ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) => Ok(vec![]), + ty::FnDef(..) | ty::FnPtr(..) | ty::Error(_) => Ok(ty::Binder::dummy(vec![])), // Implementations are provided in core ty::Uint(_) @@ -197,7 +193,7 @@ where // Cannot implement in core, as we can't be generic over patterns yet, // so we'd have to list all patterns and type combinations. - ty::Pat(ty, ..) => Ok(vec![ty::Binder::dummy(ty)]), + ty::Pat(ty, ..) => Ok(ty::Binder::dummy(vec![ty])), ty::Dynamic(..) | ty::Str @@ -215,14 +211,14 @@ where } // impl Copy/Clone for (T1, T2, .., Tn) where T1: Copy/Clone, T2: Copy/Clone, .. Tn: Copy/Clone - ty::Tuple(tys) => Ok(tys.iter().map(ty::Binder::dummy).collect()), + ty::Tuple(tys) => Ok(ty::Binder::dummy(tys.to_vec())), // impl Copy/Clone for Closure where Self::TupledUpvars: Copy/Clone - ty::Closure(_, args) => Ok(vec![ty::Binder::dummy(args.as_closure().tupled_upvars_ty())]), + ty::Closure(_, args) => Ok(ty::Binder::dummy(vec![args.as_closure().tupled_upvars_ty()])), // impl Copy/Clone for CoroutineClosure where Self::TupledUpvars: Copy/Clone ty::CoroutineClosure(_, args) => { - Ok(vec![ty::Binder::dummy(args.as_coroutine_closure().tupled_upvars_ty())]) + Ok(ty::Binder::dummy(vec![args.as_coroutine_closure().tupled_upvars_ty()])) } // only when `coroutine_clone` is enabled and the coroutine is movable @@ -232,10 +228,7 @@ where Movability::Movable => { if ecx.cx().features().coroutine_clone() { let coroutine = args.as_coroutine(); - Ok(vec![ - ty::Binder::dummy(coroutine.tupled_upvars_ty()), - ty::Binder::dummy(coroutine.witness()), - ]) + Ok(ty::Binder::dummy(vec![coroutine.tupled_upvars_ty(), coroutine.witness()])) } else { Err(NoSolution) } @@ -247,10 +240,9 @@ where // impl Copy/Clone for CoroutineWitness where T: Copy/Clone forall T in coroutine_hidden_types ty::CoroutineWitness(def_id, args) => Ok(ecx .cx() - .bound_coroutine_hidden_types(def_id) - .into_iter() - .map(|bty| bty.instantiate(ecx.cx(), args)) - .collect()), + .coroutine_hidden_types(def_id) + .instantiate(ecx.cx(), args) + .map_bound(|tys| tys.to_vec())), } } diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index cee52c05efb..b0bbec48947 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs @@ -967,7 +967,7 @@ where /// `enter_forall`, but takes `&mut self` and passes it back through the /// callback since it can't be aliased during the call. - pub(super) fn enter_forall<T: TypeFoldable<I> + Copy, U>( + pub(super) fn enter_forall<T: TypeFoldable<I>, U>( &mut self, value: ty::Binder<I, T>, f: impl FnOnce(&mut Self, T) -> U, @@ -1091,12 +1091,11 @@ where pub(super) fn is_transmutable( &mut self, - param_env: I::ParamEnv, dst: I::Ty, src: I::Ty, assume: I::Const, ) -> Result<Certainty, NoSolution> { - self.delegate.is_transmutable(param_env, dst, src, assume) + self.delegate.is_transmutable(dst, src, assume) } } diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index 1665dbb3018..1b18142c242 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -617,7 +617,6 @@ where )?; let certainty = ecx.is_transmutable( - goal.param_env, goal.predicate.trait_ref.args.type_at(0), goal.predicate.trait_ref.args.type_at(1), assume, @@ -1239,17 +1238,15 @@ where constituent_tys: impl Fn( &EvalCtxt<'_, D>, I::Ty, - ) -> Result<Vec<ty::Binder<I, I::Ty>>, NoSolution>, + ) -> Result<ty::Binder<I, Vec<I::Ty>>, NoSolution>, ) -> Result<Candidate<I>, NoSolution> { self.probe_trait_candidate(source).enter(|ecx| { - let goals = constituent_tys(ecx, goal.predicate.self_ty())? - .into_iter() - .map(|ty| { - ecx.enter_forall(ty, |ecx, ty| { - goal.with(ecx.cx(), goal.predicate.with_self_ty(ecx.cx(), ty)) - }) - }) - .collect::<Vec<_>>(); + let goals = + ecx.enter_forall(constituent_tys(ecx, goal.predicate.self_ty())?, |ecx, tys| { + tys.into_iter() + .map(|ty| goal.with(ecx.cx(), goal.predicate.with_self_ty(ecx.cx(), ty))) + .collect::<Vec<_>>() + }); ecx.add_goals(GoalSource::ImplWhereBound, goals); ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) }) diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index fc7a3323fc1..8d2fd595942 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -2922,8 +2922,9 @@ pub(crate) struct AddBoxNew { #[diag(parse_bad_return_type_notation_output)] pub(crate) struct BadReturnTypeNotationOutput { #[primary_span] - #[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")] pub span: Span, + #[suggestion(code = "", applicability = "maybe-incorrect", style = "verbose")] + pub suggestion: Span, } #[derive(Diagnostic)] diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 1280a1cd312..8091dfa2a4a 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -382,11 +382,14 @@ impl<'a> Parser<'a> { self.psess.gated_spans.gate(sym::return_type_notation, span); + let prev_lo = self.prev_token.span.shrink_to_hi(); if self.eat_noexpect(&token::RArrow) { let lo = self.prev_token.span; let ty = self.parse_ty()?; + let span = lo.to(ty.span); + let suggestion = prev_lo.to(ty.span); self.dcx() - .emit_err(errors::BadReturnTypeNotationOutput { span: lo.to(ty.span) }); + .emit_err(errors::BadReturnTypeNotationOutput { span, suggestion }); } P(ast::GenericArgs::ParenthesizedElided(span)) diff --git a/compiler/rustc_resolve/messages.ftl b/compiler/rustc_resolve/messages.ftl index b13de2875bc..9f062b3935f 100644 --- a/compiler/rustc_resolve/messages.ftl +++ b/compiler/rustc_resolve/messages.ftl @@ -125,9 +125,6 @@ resolve_const_param_in_enum_discriminant = resolve_const_param_in_non_trivial_anon_const = const parameters may only be used as standalone arguments, i.e. `{$name}` -resolve_const_param_in_ty_of_const_param = - const parameters may not be used in the type of const parameters - resolve_constructor_private_if_any_field_private = a constructor is private if any of the fields is private @@ -250,9 +247,6 @@ resolve_lifetime_param_in_enum_discriminant = resolve_lifetime_param_in_non_trivial_anon_const = lifetime parameters may not be used in const expressions -resolve_lifetime_param_in_ty_of_const_param = - lifetime parameters may not be used in the type of const parameters - resolve_lowercase_self = attempt to use a non-constant value in a constant .suggestion = try using `Self` @@ -437,9 +431,6 @@ resolve_type_param_in_enum_discriminant = resolve_type_param_in_non_trivial_anon_const = type parameters may not be used in const expressions -resolve_type_param_in_ty_of_const_param = - type parameters may not be used in the type of const parameters - resolve_undeclared_label = use of undeclared label `{$name}` .label = undeclared label `{$name}` diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 75972a71c8e..9d78c71b76a 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -459,4 +459,43 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> { visit::walk_attribute(self, attr); self.in_attr = orig_in_attr; } + + fn visit_inline_asm(&mut self, asm: &'a InlineAsm) { + let InlineAsm { + asm_macro: _, + template: _, + template_strs: _, + operands, + clobber_abis: _, + options: _, + line_spans: _, + } = asm; + for (op, _span) in operands { + match op { + InlineAsmOperand::In { expr, reg: _ } + | InlineAsmOperand::Out { expr: Some(expr), reg: _, late: _ } + | InlineAsmOperand::InOut { expr, reg: _, late: _ } => { + self.visit_expr(expr); + } + InlineAsmOperand::Out { expr: None, reg: _, late: _ } => {} + InlineAsmOperand::SplitInOut { in_expr, out_expr, reg: _, late: _ } => { + self.visit_expr(in_expr); + if let Some(expr) = out_expr { + self.visit_expr(expr); + } + } + InlineAsmOperand::Const { anon_const } => { + let def = self.create_def( + anon_const.id, + kw::Empty, + DefKind::InlineConst, + anon_const.value.span, + ); + self.with_parent(def, |this| visit::walk_anon_const(this, anon_const)); + } + InlineAsmOperand::Sym { sym } => self.visit_inline_asm_sym(sym), + InlineAsmOperand::Label { block } => self.visit_block(block), + } + } + } } diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 20af56e7ee4..e3405c89b79 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -890,9 +890,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ResolutionError::ForwardDeclaredGenericParam => { self.dcx().create_err(errs::ForwardDeclaredGenericParam { span }) } - ResolutionError::ParamInTyOfConstParam { name, param_kind: is_type } => self - .dcx() - .create_err(errs::ParamInTyOfConstParam { span, name, param_kind: is_type }), + ResolutionError::ParamInTyOfConstParam { name } => { + self.dcx().create_err(errs::ParamInTyOfConstParam { span, name }) + } ResolutionError::ParamInNonTrivialAnonConst { name, param_kind: is_type } => { self.dcx().create_err(errs::ParamInNonTrivialAnonConst { span, diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index 7eb795034b0..b5d3e5ea776 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -347,19 +347,6 @@ pub(crate) struct ParamInTyOfConstParam { #[label] pub(crate) span: Span, pub(crate) name: Symbol, - #[subdiagnostic] - pub(crate) param_kind: Option<ParamKindInTyOfConstParam>, -} - -#[derive(Debug)] -#[derive(Subdiagnostic)] -pub(crate) enum ParamKindInTyOfConstParam { - #[note(resolve_type_param_in_ty_of_const_param)] - Type, - #[note(resolve_const_param_in_ty_of_const_param)] - Const, - #[note(resolve_lifetime_param_in_ty_of_const_param)] - Lifetime, } #[derive(Diagnostic)] diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index 499b9bca4d2..d9776be4dd0 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -1131,6 +1131,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { return Res::Err; } + if let RibKind::ConstParamTy = all_ribs[rib_index].kind { + if let Some(span) = finalize { + self.report_error( + span, + ResolutionError::ParamInTyOfConstParam { name: rib_ident.name }, + ); + } + assert_eq!(res, Res::Err); + return Res::Err; + } + match res { Res::Local(_) => { use ResolutionError::*; @@ -1209,10 +1220,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { if let Some(span) = finalize { self.report_error( span, - ParamInTyOfConstParam { - name: rib_ident.name, - param_kind: None, - }, + ParamInTyOfConstParam { name: rib_ident.name }, ); } return Res::Err; @@ -1239,6 +1247,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | RibKind::MacroDefinition(..) | RibKind::InlineAsmSym | RibKind::AssocItem + | RibKind::ConstParamTy | RibKind::ForwardGenericParamBan => { // Nothing to do. Continue. continue; @@ -1292,18 +1301,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { RibKind::Item(has_generic_params, def_kind) => { (has_generic_params, def_kind) } - RibKind::ConstParamTy => { - if let Some(span) = finalize { - self.report_error( - span, - ResolutionError::ParamInTyOfConstParam { - name: rib_ident.name, - param_kind: Some(errors::ParamKindInTyOfConstParam::Type), - }, - ); - } - return Res::Err; - } }; if let Some(span) = finalize { @@ -1328,6 +1325,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | RibKind::MacroDefinition(..) | RibKind::InlineAsmSym | RibKind::AssocItem + | RibKind::ConstParamTy | RibKind::ForwardGenericParamBan => continue, RibKind::ConstantItem(trivial, _) => { @@ -1361,18 +1359,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { RibKind::Item(has_generic_params, def_kind) => { (has_generic_params, def_kind) } - RibKind::ConstParamTy => { - if let Some(span) = finalize { - self.report_error( - span, - ResolutionError::ParamInTyOfConstParam { - name: rib_ident.name, - param_kind: Some(errors::ParamKindInTyOfConstParam::Const), - }, - ); - } - return Res::Err; - } }; // This was an attempt to use a const parameter outside its scope. diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 32ef781631b..f119ed55e7d 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -227,9 +227,11 @@ impl RibKind<'_> { | RibKind::ConstantItem(..) | RibKind::Module(_) | RibKind::MacroDefinition(_) - | RibKind::ConstParamTy | RibKind::InlineAsmSym => false, - RibKind::AssocItem | RibKind::Item(..) | RibKind::ForwardGenericParamBan => true, + RibKind::ConstParamTy + | RibKind::AssocItem + | RibKind::Item(..) + | RibKind::ForwardGenericParamBan => true, } } @@ -1570,6 +1572,17 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { forward_ty_ban_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), Res::Err); } + let mut forward_ty_ban_rib_const_param_ty = Rib { + bindings: forward_ty_ban_rib.bindings.clone(), + patterns_with_skipped_bindings: FxHashMap::default(), + kind: RibKind::ConstParamTy, + }; + let mut forward_const_ban_rib_const_param_ty = Rib { + bindings: forward_const_ban_rib.bindings.clone(), + patterns_with_skipped_bindings: FxHashMap::default(), + kind: RibKind::ConstParamTy, + }; + self.with_lifetime_rib(LifetimeRibKind::AnonymousReportError, |this| { for param in params { match param.kind { @@ -1592,21 +1605,27 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } // Allow all following defaults to refer to this type parameter. - forward_ty_ban_rib - .bindings - .remove(&Ident::with_dummy_span(param.ident.name)); + let i = &Ident::with_dummy_span(param.ident.name); + forward_ty_ban_rib.bindings.remove(i); + if this.r.tcx.features().generic_const_parameter_types() { + forward_ty_ban_rib_const_param_ty.bindings.remove(i); + } } GenericParamKind::Const { ref ty, kw_span: _, ref default } => { // Const parameters can't have param bounds. assert!(param.bounds.is_empty()); - this.ribs[TypeNS].push(Rib::new(RibKind::ConstParamTy)); - this.ribs[ValueNS].push(Rib::new(RibKind::ConstParamTy)); - this.with_lifetime_rib(LifetimeRibKind::ConstParamTy, |this| { + this.ribs[TypeNS].push(forward_ty_ban_rib_const_param_ty); + this.ribs[ValueNS].push(forward_const_ban_rib_const_param_ty); + if this.r.tcx.features().generic_const_parameter_types() { this.visit_ty(ty) - }); - this.ribs[TypeNS].pop().unwrap(); - this.ribs[ValueNS].pop().unwrap(); + } else { + this.with_lifetime_rib(LifetimeRibKind::ConstParamTy, |this| { + this.visit_ty(ty) + }); + } + forward_const_ban_rib_const_param_ty = this.ribs[ValueNS].pop().unwrap(); + forward_ty_ban_rib_const_param_ty = this.ribs[TypeNS].pop().unwrap(); if let Some(expr) = default { this.ribs[TypeNS].push(forward_ty_ban_rib); @@ -1620,9 +1639,11 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } // Allow all following defaults to refer to this const parameter. - forward_const_ban_rib - .bindings - .remove(&Ident::with_dummy_span(param.ident.name)); + let i = &Ident::with_dummy_span(param.ident.name); + forward_const_ban_rib.bindings.remove(i); + if this.r.tcx.features().generic_const_parameter_types() { + forward_const_ban_rib_const_param_ty.bindings.remove(i); + } } } } diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index fa9c42e3593..0e14e7671b1 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -3052,7 +3052,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { .create_err(errors::ParamInTyOfConstParam { span: lifetime_ref.ident.span, name: lifetime_ref.ident.name, - param_kind: Some(errors::ParamKindInTyOfConstParam::Lifetime), }) .emit(); } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index ea48d0cad74..4c5d4041022 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -30,9 +30,7 @@ use std::sync::Arc; use diagnostics::{ImportSuggestion, LabelSuggestion, Suggestion}; use effective_visibilities::EffectiveVisibilitiesVisitor; -use errors::{ - ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst, ParamKindInTyOfConstParam, -}; +use errors::{ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst}; use imports::{Import, ImportData, ImportKind, NameResolution}; use late::{HasGenericParams, PathSource, PatternSource, UnnecessaryQualification}; use macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef}; @@ -276,8 +274,10 @@ enum ResolutionError<'ra> { }, /// Error E0128: generic parameters with a default cannot use forward-declared identifiers. ForwardDeclaredGenericParam, + // FIXME(generic_const_parameter_types): This should give custom output specifying it's only + // problematic to use *forward declared* parameters when the feature is enabled. /// ERROR E0770: the type of const parameters must not depend on other generic parameters. - ParamInTyOfConstParam { name: Symbol, param_kind: Option<ParamKindInTyOfConstParam> }, + ParamInTyOfConstParam { name: Symbol }, /// generic parameters must not be used inside const evaluations. /// /// This error is only emitted when using `min_const_generics`. diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index ba7ccd6a02d..7586c5766b5 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -539,7 +539,10 @@ impl FromStr for SplitDwarfKind { #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, HashStable_Generic)] #[derive(Encodable, Decodable)] pub enum OutputType { + /// This is the optimized bitcode, which could be either pre-LTO or non-LTO bitcode, + /// depending on the specific request type. Bitcode, + /// This is the summary or index data part of the ThinLTO bitcode. ThinLinkBitcode, Assembly, LlvmAssembly, diff --git a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs index a627e0e69b6..62cbab9b723 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs @@ -206,7 +206,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::BackendRepr { rustc_abi::BackendRepr::ScalarPair(first, second) => { ValueAbi::ScalarPair(first.stable(tables), second.stable(tables)) } - rustc_abi::BackendRepr::Vector { element, count } => { + rustc_abi::BackendRepr::SimdVector { element, count } => { ValueAbi::Vector { element: element.stable(tables), count } } rustc_abi::BackendRepr::Memory { sized } => ValueAbi::Aggregate { sized }, diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 501c9039f2d..2a709b07255 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1037,6 +1037,7 @@ symbols! { generic_associated_types_extended, generic_const_exprs, generic_const_items, + generic_const_parameter_types, generic_param_attrs, generic_pattern_types, get_context, diff --git a/compiler/rustc_target/src/callconv/loongarch.rs b/compiler/rustc_target/src/callconv/loongarch.rs index 3fa67c624a7..209d7483e61 100644 --- a/compiler/rustc_target/src/callconv/loongarch.rs +++ b/compiler/rustc_target/src/callconv/loongarch.rs @@ -25,7 +25,7 @@ struct CannotUseFpConv; fn is_loongarch_aggregate<Ty>(arg: &ArgAbi<'_, Ty>) -> bool { match arg.layout.backend_repr { - BackendRepr::Vector { .. } => true, + BackendRepr::SimdVector { .. } => true, _ => arg.layout.is_aggregate(), } } @@ -80,7 +80,7 @@ where } } }, - BackendRepr::Vector { .. } => return Err(CannotUseFpConv), + BackendRepr::SimdVector { .. } => return Err(CannotUseFpConv), BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => match arg_layout.fields { FieldsShape::Primitive => { unreachable!("aggregates can't have `FieldsShape::Primitive`") diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index 1c044fe98b3..198d08864be 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -357,7 +357,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> { scalar_attrs(&layout, a, Size::ZERO), scalar_attrs(&layout, b, a.size(cx).align_to(b.align(cx).abi)), ), - BackendRepr::Vector { .. } => PassMode::Direct(ArgAttributes::new()), + BackendRepr::SimdVector { .. } => PassMode::Direct(ArgAttributes::new()), BackendRepr::Memory { .. } => Self::indirect_pass_mode(&layout), }; ArgAbi { layout, mode } @@ -759,7 +759,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { if arg_idx.is_none() && arg.layout.size > Primitive::Pointer(AddressSpace::DATA).size(cx) * 2 - && !matches!(arg.layout.backend_repr, BackendRepr::Vector { .. }) + && !matches!(arg.layout.backend_repr, BackendRepr::SimdVector { .. }) { // Return values larger than 2 registers using a return area // pointer. LLVM and Cranelift disagree about how to return @@ -826,7 +826,7 @@ impl<'a, Ty> FnAbi<'a, Ty> { } } - BackendRepr::Vector { .. } => { + BackendRepr::SimdVector { .. } => { // This is a fun case! The gist of what this is doing is // that we want callers and callees to always agree on the // ABI of how they pass SIMD arguments. If we were to *not* diff --git a/compiler/rustc_target/src/callconv/riscv.rs b/compiler/rustc_target/src/callconv/riscv.rs index 785175229b0..7368e225efa 100644 --- a/compiler/rustc_target/src/callconv/riscv.rs +++ b/compiler/rustc_target/src/callconv/riscv.rs @@ -31,7 +31,7 @@ struct CannotUseFpConv; fn is_riscv_aggregate<Ty>(arg: &ArgAbi<'_, Ty>) -> bool { match arg.layout.backend_repr { - BackendRepr::Vector { .. } => true, + BackendRepr::SimdVector { .. } => true, _ => arg.layout.is_aggregate(), } } @@ -86,7 +86,7 @@ where } } }, - BackendRepr::Vector { .. } => return Err(CannotUseFpConv), + BackendRepr::SimdVector { .. } => return Err(CannotUseFpConv), BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => match arg_layout.fields { FieldsShape::Primitive => { unreachable!("aggregates can't have `FieldsShape::Primitive`") diff --git a/compiler/rustc_target/src/callconv/s390x.rs b/compiler/rustc_target/src/callconv/s390x.rs index 4f69e32b2e3..1ba792c5acc 100644 --- a/compiler/rustc_target/src/callconv/s390x.rs +++ b/compiler/rustc_target/src/callconv/s390x.rs @@ -8,7 +8,7 @@ use crate::spec::HasTargetSpec; fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) { let size = ret.layout.size; - if size.bits() <= 128 && matches!(ret.layout.backend_repr, BackendRepr::Vector { .. }) { + if size.bits() <= 128 && matches!(ret.layout.backend_repr, BackendRepr::SimdVector { .. }) { return; } if !ret.layout.is_aggregate() && size.bits() <= 64 { @@ -40,7 +40,7 @@ where let size = arg.layout.size; if size.bits() <= 128 { - if let BackendRepr::Vector { .. } = arg.layout.backend_repr { + if let BackendRepr::SimdVector { .. } = arg.layout.backend_repr { // pass non-wrapped vector types using `PassMode::Direct` return; } diff --git a/compiler/rustc_target/src/callconv/x86.rs b/compiler/rustc_target/src/callconv/x86.rs index 7e5aab0201b..73aff85a0ad 100644 --- a/compiler/rustc_target/src/callconv/x86.rs +++ b/compiler/rustc_target/src/callconv/x86.rs @@ -109,7 +109,7 @@ where { match layout.backend_repr { BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) => false, - BackendRepr::Vector { .. } => true, + BackendRepr::SimdVector { .. } => true, BackendRepr::Memory { .. } => { for i in 0..layout.fields.count() { if contains_vector(cx, layout.field(cx, i)) { diff --git a/compiler/rustc_target/src/callconv/x86_64.rs b/compiler/rustc_target/src/callconv/x86_64.rs index ab306e20239..300b19f62e7 100644 --- a/compiler/rustc_target/src/callconv/x86_64.rs +++ b/compiler/rustc_target/src/callconv/x86_64.rs @@ -56,7 +56,7 @@ where Primitive::Float(_) => Class::Sse, }, - BackendRepr::Vector { .. } => Class::Sse, + BackendRepr::SimdVector { .. } => Class::Sse, BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => { for i in 0..layout.fields.count() { diff --git a/compiler/rustc_target/src/callconv/x86_win64.rs b/compiler/rustc_target/src/callconv/x86_win64.rs index 4d99a9f9ba0..8f8597ea662 100644 --- a/compiler/rustc_target/src/callconv/x86_win64.rs +++ b/compiler/rustc_target/src/callconv/x86_win64.rs @@ -18,7 +18,7 @@ pub(crate) fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<' _ => a.make_indirect(), } } - BackendRepr::Vector { .. } => { + BackendRepr::SimdVector { .. } => { // FIXME(eddyb) there should be a size cap here // (probably what clang calls "illegal vectors"). } diff --git a/compiler/rustc_target/src/callconv/xtensa.rs b/compiler/rustc_target/src/callconv/xtensa.rs index 6c030cb3bf7..b687f0e20c6 100644 --- a/compiler/rustc_target/src/callconv/xtensa.rs +++ b/compiler/rustc_target/src/callconv/xtensa.rs @@ -116,7 +116,7 @@ where fn is_xtensa_aggregate<'a, Ty>(arg: &ArgAbi<'a, Ty>) -> bool { match arg.layout.backend_repr { - BackendRepr::Vector { .. } => true, + BackendRepr::SimdVector { .. } => true, _ => arg.layout.is_aggregate(), } } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 596f794568c..d270b4cf96b 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -1189,9 +1189,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let span = obligation.cause.span; let mut diag = match ty.kind() { - _ if ty.has_param() => { - span_bug!(span, "const param tys cannot mention other generic parameters"); - } ty::Float(_) => { struct_span_code_err!( self.dcx(), @@ -2419,6 +2416,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { &mut vec![], &mut Default::default(), ); + self.suggest_swapping_lhs_and_rhs( + err, + obligation.predicate, + obligation.param_env, + obligation.cause.code(), + ); self.suggest_unsized_bound_if_applicable(err, obligation); if let Some(span) = err.span.primary_span() && let Some(mut diag) = @@ -2530,9 +2533,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { return GetSafeTransmuteErrorAndReason::Silent; }; - let Some(assume) = - rustc_transmute::Assume::from_const(self.infcx.tcx, obligation.param_env, assume) - else { + let Some(assume) = rustc_transmute::Assume::from_const(self.infcx.tcx, assume) else { self.dcx().span_delayed_bug( span, "Unable to construct rustc_transmute::Assume where it was previously possible", @@ -2544,11 +2545,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let src = trait_pred.trait_ref.args.type_at(1); let err_msg = format!("`{src}` cannot be safely transmuted into `{dst}`"); - match rustc_transmute::TransmuteTypeEnv::new(self.infcx).is_transmutable( - obligation.cause, - src_and_dst, - assume, - ) { + match rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx) + .is_transmutable(src_and_dst, assume) + { Answer::No(reason) => { let safe_transmute_explanation = match reason { rustc_transmute::Reason::SrcIsNotYetSupported => { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 0ff00e752a2..b85c18c5312 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -4914,6 +4914,53 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); true } + pub(crate) fn suggest_swapping_lhs_and_rhs<T>( + &self, + err: &mut Diag<'_>, + predicate: T, + param_env: ty::ParamEnv<'tcx>, + cause_code: &ObligationCauseCode<'tcx>, + ) where + T: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>, + { + let tcx = self.tcx; + let predicate = predicate.upcast(tcx); + match *cause_code { + ObligationCauseCode::BinOp { + lhs_hir_id, + rhs_hir_id: Some(rhs_hir_id), + rhs_span: Some(rhs_span), + .. + } if let Some(typeck_results) = &self.typeck_results + && let hir::Node::Expr(lhs) = tcx.hir_node(lhs_hir_id) + && let hir::Node::Expr(rhs) = tcx.hir_node(rhs_hir_id) + && let Some(lhs_ty) = typeck_results.expr_ty_opt(lhs) + && let Some(rhs_ty) = typeck_results.expr_ty_opt(rhs) => + { + if let Some(pred) = predicate.as_trait_clause() + && tcx.is_lang_item(pred.def_id(), LangItem::PartialEq) + && self + .infcx + .type_implements_trait(pred.def_id(), [rhs_ty, lhs_ty], param_env) + .must_apply_modulo_regions() + { + let lhs_span = tcx.hir().span(lhs_hir_id); + let sm = tcx.sess.source_map(); + if let Ok(rhs_snippet) = sm.span_to_snippet(rhs_span) + && let Ok(lhs_snippet) = sm.span_to_snippet(lhs_span) + { + err.note(format!("`{rhs_ty}` implements `PartialEq<{lhs_ty}>`")); + err.multipart_suggestion( + "consider swapping the equality", + vec![(lhs_span, rhs_snippet), (rhs_span, lhs_snippet)], + Applicability::MaybeIncorrect, + ); + } + } + } + _ => {} + } + } } /// Add a hint to add a missing borrow or remove an unnecessary one. diff --git a/compiler/rustc_trait_selection/src/solve/delegate.rs b/compiler/rustc_trait_selection/src/solve/delegate.rs index 58d8a3a6254..e69bad095e3 100644 --- a/compiler/rustc_trait_selection/src/solve/delegate.rs +++ b/compiler/rustc_trait_selection/src/solve/delegate.rs @@ -7,7 +7,6 @@ use rustc_infer::infer::canonical::{ Canonical, CanonicalExt as _, CanonicalQueryInput, CanonicalVarInfo, CanonicalVarValues, }; use rustc_infer::infer::{InferCtxt, RegionVariableOrigin, TyCtxtInferExt}; -use rustc_infer::traits::ObligationCause; use rustc_infer::traits::solve::Goal; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt as _}; @@ -222,7 +221,6 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate< // register candidates. We probably need to register >1 since we may have an OR of ANDs. fn is_transmutable( &self, - param_env: ty::ParamEnv<'tcx>, dst: Ty<'tcx>, src: Ty<'tcx>, assume: ty::Const<'tcx>, @@ -231,16 +229,14 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate< // which will ICE for region vars. let (dst, src) = self.tcx.erase_regions((dst, src)); - let Some(assume) = rustc_transmute::Assume::from_const(self.tcx, param_env, assume) else { + let Some(assume) = rustc_transmute::Assume::from_const(self.tcx, assume) else { return Err(NoSolution); }; // FIXME(transmutability): This really should be returning nested goals for `Answer::If*` - match rustc_transmute::TransmuteTypeEnv::new(&self.0).is_transmutable( - ObligationCause::dummy(), - rustc_transmute::Types { src, dst }, - assume, - ) { + match rustc_transmute::TransmuteTypeEnv::new(self.0.tcx) + .is_transmutable(rustc_transmute::Types { src, dst }, assume) + { rustc_transmute::Answer::Yes => Ok(Certainty::Yes), rustc_transmute::Answer::No(_) | rustc_transmute::Answer::If(_) => Err(NoSolution), } diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index 2ef9d5421ba..6bf76eaee5c 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -31,20 +31,19 @@ impl<'a, 'tcx> At<'a, 'tcx> { /// normalized. If you don't care about regions, you should prefer /// `normalize_erasing_regions`, which is more efficient. /// - /// If the normalization succeeds and is unambiguous, returns back - /// the normalized value along with various outlives relations (in - /// the form of obligations that must be discharged). + /// If the normalization succeeds, returns back the normalized + /// value along with various outlives relations (in the form of + /// obligations that must be discharged). /// - /// N.B., this will *eventually* be the main means of - /// normalizing, but for now should be used only when we actually - /// know that normalization will succeed, since error reporting - /// and other details are still "under development". - /// - /// This normalization should *only* be used when the projection does not - /// have possible ambiguity or may not be well-formed. + /// This normalization should *only* be used when the projection is well-formed and + /// does not have possible ambiguity (contains inference variables). /// /// After codegen, when lifetimes do not matter, it is preferable to instead /// use [`TyCtxt::normalize_erasing_regions`], which wraps this procedure. + /// + /// N.B. Once the new solver is stabilized this method of normalization will + /// likely be removed as trait solver operations are already cached by the query + /// system making this redundant. fn query_normalize<T>(self, value: T) -> Result<Normalized<'tcx, T>, NoSolution> where T: TypeFoldable<TyCtxt<'tcx>>, @@ -210,8 +209,6 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'a, 'tcx> { // See note in `rustc_trait_selection::traits::project` about why we // wait to fold the args. - - // Wrap this in a closure so we don't accidentally return from the outer function let res = match kind { ty::Opaque => { // Only normalize `impl Trait` outside of type inference, usually in codegen. diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 32cbb97e314..a58317dd56d 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -414,9 +414,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { if self.tcx().features().generic_const_exprs() { assume = crate::traits::evaluate_const(self.infcx, assume, obligation.param_env) } - let Some(assume) = - rustc_transmute::Assume::from_const(self.infcx.tcx, obligation.param_env, assume) - else { + let Some(assume) = rustc_transmute::Assume::from_const(self.infcx.tcx, assume) else { return Err(Unimplemented); }; @@ -424,12 +422,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let src = predicate.trait_ref.args.type_at(1); debug!(?src, ?dst); - let mut transmute_env = rustc_transmute::TransmuteTypeEnv::new(self.infcx); - let maybe_transmutable = transmute_env.is_transmutable( - obligation.cause.clone(), - rustc_transmute::Types { dst, src }, - assume, - ); + let mut transmute_env = rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx); + let maybe_transmutable = + transmute_env.is_transmutable(rustc_transmute::Types { dst, src }, assume); let fully_flattened = match maybe_transmutable { Answer::No(_) => Err(Unimplemented)?, diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index a4ee1cbb853..77dbb43465e 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -9,7 +9,7 @@ use std::ops::ControlFlow; use std::{cmp, iter}; use hir::def::DefKind; -use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::{Diag, EmissionGuarantee}; use rustc_hir as hir; @@ -25,7 +25,6 @@ use rustc_middle::dep_graph::{DepNodeIndex, dep_kinds}; pub use rustc_middle::traits::select::*; use rustc_middle::ty::abstract_const::NotConstEvaluatable; use rustc_middle::ty::error::TypeErrorToStringExt; -use rustc_middle::ty::fold::fold_regions; use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths}; use rustc_middle::ty::{ self, GenericArgsRef, PolyProjectionPredicate, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, @@ -1008,7 +1007,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // depend on its particular value in order to work, so we can clear // out the param env and get better caching. debug!("in global"); - obligation.param_env = obligation.param_env.without_caller_bounds(); + obligation.param_env = ty::ParamEnv::empty(); } let stack = self.push_stack(previous_stack, &obligation); @@ -2205,8 +2204,8 @@ impl<'tcx> SelectionContext<'_, 'tcx> { } ty::CoroutineWitness(def_id, args) => { - let hidden_types = bind_coroutine_hidden_types_above( - self.infcx, + let hidden_types = rebind_coroutine_witness_types( + self.infcx.tcx, def_id, args, obligation.predicate.bound_vars(), @@ -2354,7 +2353,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { } ty::CoroutineWitness(def_id, args) => { - bind_coroutine_hidden_types_above(self.infcx, def_id, args, t.bound_vars()) + rebind_coroutine_witness_types(self.infcx.tcx, def_id, args, t.bound_vars()) } // For `PhantomData<T>`, we pass `T`. @@ -2849,6 +2848,23 @@ impl<'tcx> SelectionContext<'_, 'tcx> { } } +fn rebind_coroutine_witness_types<'tcx>( + tcx: TyCtxt<'tcx>, + def_id: DefId, + args: ty::GenericArgsRef<'tcx>, + bound_vars: &'tcx ty::List<ty::BoundVariableKind>, +) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> { + let bound_coroutine_types = tcx.coroutine_hidden_types(def_id).skip_binder(); + let shifted_coroutine_types = + tcx.shift_bound_var_indices(bound_vars.len(), bound_coroutine_types.skip_binder()); + ty::Binder::bind_with_vars( + ty::EarlyBinder::bind(shifted_coroutine_types.to_vec()).instantiate(tcx, args), + tcx.mk_bound_variable_kinds_from_iter( + bound_vars.iter().chain(bound_coroutine_types.bound_vars()), + ), + ) +} + impl<'o, 'tcx> TraitObligationStack<'o, 'tcx> { fn list(&'o self) -> TraitObligationStackList<'o, 'tcx> { TraitObligationStackList::with(self) @@ -3157,56 +3173,3 @@ pub(crate) enum ProjectionMatchesProjection { Ambiguous, No, } - -/// Replace all regions inside the coroutine interior with late bound regions. -/// Note that each region slot in the types gets a new fresh late bound region, which means that -/// none of the regions inside relate to any other, even if typeck had previously found constraints -/// that would cause them to be related. -#[instrument(level = "trace", skip(infcx), ret)] -fn bind_coroutine_hidden_types_above<'tcx>( - infcx: &InferCtxt<'tcx>, - def_id: DefId, - args: ty::GenericArgsRef<'tcx>, - bound_vars: &ty::List<ty::BoundVariableKind>, -) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> { - let tcx = infcx.tcx; - let mut seen_tys = FxHashSet::default(); - - let considering_regions = infcx.considering_regions; - - let num_bound_variables = bound_vars.len() as u32; - let mut counter = num_bound_variables; - - let hidden_types: Vec<_> = tcx - .coroutine_hidden_types(def_id) - // Deduplicate tys to avoid repeated work. - .filter(|bty| seen_tys.insert(*bty)) - .map(|mut bty| { - // Only remap erased regions if we use them. - if considering_regions { - bty = bty.map_bound(|ty| { - fold_regions(tcx, ty, |r, current_depth| match r.kind() { - ty::ReErased => { - let br = ty::BoundRegion { - var: ty::BoundVar::from_u32(counter), - kind: ty::BoundRegionKind::Anon, - }; - counter += 1; - ty::Region::new_bound(tcx, current_depth, br) - } - r => bug!("unexpected region: {r:?}"), - }) - }) - } - - bty.instantiate(tcx, args) - }) - .collect(); - let bound_vars = tcx.mk_bound_variable_kinds_from_iter( - bound_vars.iter().chain( - (num_bound_variables..counter) - .map(|_| ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon)), - ), - ); - ty::Binder::bind_with_vars(hidden_types, bound_vars) -} diff --git a/compiler/rustc_transmute/Cargo.toml b/compiler/rustc_transmute/Cargo.toml index e9daf6b0c38..f0c783b3002 100644 --- a/compiler/rustc_transmute/Cargo.toml +++ b/compiler/rustc_transmute/Cargo.toml @@ -8,8 +8,6 @@ edition = "2024" rustc_abi = { path = "../rustc_abi", optional = true } rustc_data_structures = { path = "../rustc_data_structures" } rustc_hir = { path = "../rustc_hir", optional = true } -rustc_infer = { path = "../rustc_infer", optional = true } -rustc_macros = { path = "../rustc_macros", optional = true } rustc_middle = { path = "../rustc_middle", optional = true } rustc_span = { path = "../rustc_span", optional = true } tracing = "0.1" @@ -19,8 +17,6 @@ tracing = "0.1" rustc = [ "dep:rustc_abi", "dep:rustc_hir", - "dep:rustc_infer", - "dep:rustc_macros", "dep:rustc_middle", "dep:rustc_span", ] diff --git a/compiler/rustc_transmute/src/layout/dfa.rs b/compiler/rustc_transmute/src/layout/dfa.rs index a70dc034e63..a29baade42f 100644 --- a/compiler/rustc_transmute/src/layout/dfa.rs +++ b/compiler/rustc_transmute/src/layout/dfa.rs @@ -38,7 +38,7 @@ impl<R> Transitions<R> where R: Ref, { - #[allow(dead_code)] + #[cfg(test)] fn insert(&mut self, transition: Transition<R>, state: State) { match transition { Transition::Byte(b) => { @@ -86,15 +86,6 @@ impl<R> Dfa<R> where R: Ref, { - #[allow(dead_code)] - pub(crate) fn unit() -> Self { - let transitions: Map<State, Transitions<R>> = Map::default(); - let start = State::new(); - let accepting = start; - - Self { transitions, start, accepting } - } - #[cfg(test)] pub(crate) fn bool() -> Self { let mut transitions: Map<State, Transitions<R>> = Map::default(); diff --git a/compiler/rustc_transmute/src/layout/nfa.rs b/compiler/rustc_transmute/src/layout/nfa.rs index 3b49c59fa68..9c21fd94f03 100644 --- a/compiler/rustc_transmute/src/layout/nfa.rs +++ b/compiler/rustc_transmute/src/layout/nfa.rs @@ -159,11 +159,6 @@ where } Self { transitions, start, accepting } } - - #[allow(dead_code)] - pub(crate) fn edges_from(&self, start: State) -> Option<&Map<Transition<R>, Set<State>>> { - self.transitions.get(&start) - } } impl State { diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs index b00585d2922..a21be5dda4e 100644 --- a/compiler/rustc_transmute/src/layout/tree.rs +++ b/compiler/rustc_transmute/src/layout/tree.rs @@ -237,7 +237,7 @@ pub(crate) mod rustc { ty::Tuple(members) => Self::from_tuple((ty, layout), members, cx), - ty::Array(inner_ty, len) => { + ty::Array(inner_ty, _len) => { let FieldsShape::Array { stride, count } = &layout.fields else { return Err(Err::NotYetSupported); }; @@ -282,7 +282,6 @@ pub(crate) mod rustc { FieldsShape::Primitive => { assert_eq!(members.len(), 1); let inner_ty = members[0]; - let inner_layout = layout_of(cx, inner_ty)?; Self::from_ty(inner_ty, cx) } FieldsShape::Arbitrary { offsets, .. } => { @@ -345,7 +344,7 @@ pub(crate) mod rustc { // the enum delegates its layout to the variant at `index`. layout_of_variant(*index, None) } - Variants::Multiple { tag, tag_encoding, tag_field, .. } => { + Variants::Multiple { tag: _, tag_encoding, tag_field, .. } => { // `Variants::Multiple` denotes an enum with multiple // variants. The layout of such an enum is the disjunction // of the layouts of its tagged variants. @@ -356,7 +355,7 @@ pub(crate) mod rustc { let variants = def.discriminants(cx.tcx()).try_fold( Self::uninhabited(), - |variants, (idx, ref discriminant)| { + |variants, (idx, _discriminant)| { let variant = layout_of_variant(idx, Some(tag_encoding.clone()))?; Result::<Self, Err>::Ok(variants.or(variant)) }, @@ -414,7 +413,7 @@ pub(crate) mod rustc { // Append the fields, in memory order, to the layout. let inverse_memory_index = memory_index.invert_bijective_mapping(); - for (memory_idx, &field_idx) in inverse_memory_index.iter_enumerated() { + for &field_idx in inverse_memory_index.iter() { // Add interfield padding. let padding_needed = offsets[field_idx] - size; let padding = Self::padding(padding_needed.bytes_usize()); @@ -468,15 +467,14 @@ pub(crate) mod rustc { // This constructor does not support non-`FieldsShape::Union` // layouts. Fields of this shape are all placed at offset 0. - let FieldsShape::Union(fields) = layout.fields() else { + let FieldsShape::Union(_fields) = layout.fields() else { return Err(Err::NotYetSupported); }; let fields = &def.non_enum_variant().fields; let fields = fields.iter_enumerated().try_fold( Self::uninhabited(), - |fields, (idx, field_def)| { - let field_def = Def::Field(field_def); + |fields, (idx, _field_def)| { let field_ty = ty_field(cx, (ty, layout), idx); let field_layout = layout_of(cx, field_ty)?; let field = Self::from_ty(field_ty, cx)?; diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index f9537f708ef..81a11f7cfb2 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -1,6 +1,4 @@ // tidy-alphabetical-start -#![allow(unused_variables)] -#![feature(alloc_layout_extra)] #![feature(never_type)] #![warn(unreachable_pub)] // tidy-alphabetical-end @@ -81,15 +79,12 @@ pub enum Reason<T> { #[cfg(feature = "rustc")] mod rustc { use rustc_hir::lang_items::LangItem; - use rustc_infer::infer::InferCtxt; - use rustc_macros::TypeVisitable; - use rustc_middle::traits::ObligationCause; - use rustc_middle::ty::{Const, ParamEnv, Ty, TyCtxt}; + use rustc_middle::ty::{Const, Ty, TyCtxt}; use super::*; /// The source and destination types of a transmutation. - #[derive(TypeVisitable, Debug, Clone, Copy)] + #[derive(Debug, Clone, Copy)] pub struct Types<'tcx> { /// The source type. pub src: Ty<'tcx>, @@ -97,27 +92,22 @@ mod rustc { pub dst: Ty<'tcx>, } - pub struct TransmuteTypeEnv<'cx, 'tcx> { - infcx: &'cx InferCtxt<'tcx>, + pub struct TransmuteTypeEnv<'tcx> { + tcx: TyCtxt<'tcx>, } - impl<'cx, 'tcx> TransmuteTypeEnv<'cx, 'tcx> { - pub fn new(infcx: &'cx InferCtxt<'tcx>) -> Self { - Self { infcx } + impl<'tcx> TransmuteTypeEnv<'tcx> { + pub fn new(tcx: TyCtxt<'tcx>) -> Self { + Self { tcx } } - #[allow(unused)] pub fn is_transmutable( &mut self, - cause: ObligationCause<'tcx>, types: Types<'tcx>, assume: crate::Assume, ) -> crate::Answer<crate::layout::rustc::Ref<'tcx>> { crate::maybe_transmutable::MaybeTransmutableQuery::new( - types.src, - types.dst, - assume, - self.infcx.tcx, + types.src, types.dst, assume, self.tcx, ) .answer() } @@ -125,11 +115,7 @@ mod rustc { impl Assume { /// Constructs an `Assume` from a given const-`Assume`. - pub fn from_const<'tcx>( - tcx: TyCtxt<'tcx>, - param_env: ParamEnv<'tcx>, - ct: Const<'tcx>, - ) -> Option<Self> { + pub fn from_const<'tcx>(tcx: TyCtxt<'tcx>, ct: Const<'tcx>) -> Option<Self> { use rustc_middle::ty::ScalarInt; use rustc_span::sym; diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs index 023c8fad781..63fabc9c83d 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs @@ -79,12 +79,12 @@ where pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> { let Self { src, dst, assume, context } = self; - // Unconditionally all `Def` nodes from `src`, without pruning away the + // Unconditionally remove all `Def` nodes from `src`, without pruning away the // branches they appear in. This is valid to do for value-to-value // transmutations, but not for `&mut T` to `&mut U`; we will need to be // more sophisticated to handle transmutations between mutable // references. - let src = src.prune(&|def| false); + let src = src.prune(&|_def| false); if src.is_inhabited() && !dst.is_inhabited() { return Answer::No(Reason::DstUninhabited); @@ -96,7 +96,7 @@ where let dst = if assume.safety { // ...if safety is assumed, don't check if they carry safety // invariants; retain all paths. - dst.prune(&|def| false) + dst.prune(&|_def| false) } else { // ...otherwise, prune away all paths with safety invariants from // the `Dst` layout. diff --git a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs index 84af20c773e..4d81382eba0 100644 --- a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs +++ b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs @@ -92,7 +92,6 @@ mod bool { #[test] fn should_permit_validity_expansion_and_reject_contraction() { - let un = layout::Tree::<Def, !>::uninhabited(); let b0 = layout::Tree::<Def, !>::from_bits(0); let b1 = layout::Tree::<Def, !>::from_bits(1); let b2 = layout::Tree::<Def, !>::from_bits(2); diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 74ab65b4f58..e317768ff60 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -460,7 +460,7 @@ fn fn_abi_sanity_check<'tcx>( // `layout.backend_repr` and ignore everything else. We should just reject //`Aggregate` entirely here, but some targets need to be fixed first. match arg.layout.backend_repr { - BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => {} + BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => {} BackendRepr::ScalarPair(..) => { panic!("`PassMode::Direct` used for ScalarPair type {}", arg.layout.ty) } diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 2ab6b8e17c4..1a82d171307 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -553,7 +553,7 @@ fn layout_of_uncached<'tcx>( ) } else { ( - BackendRepr::Vector { element: e_abi, count: e_len }, + BackendRepr::SimdVector { element: e_abi, count: e_len }, dl.llvmlike_vector_align(size), ) }; diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index c695e2887fd..7423a156a21 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -234,7 +234,7 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou "`ScalarPair` second field with bad ABI in {inner:#?}", ); } - BackendRepr::Vector { element, count } => { + BackendRepr::SimdVector { element, count } => { let align = layout.align.abi; let size = layout.size; let element_align = element.align(cx).abi; diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 8ed45b4e541..8610c30ab70 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -37,8 +37,6 @@ fn sized_constraint_for_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<' | Never | Dynamic(_, _, ty::DynStar) => None, - UnsafeBinder(_) => todo!(), - // these are never sized Str | Slice(..) | Dynamic(_, _, ty::Dyn) | Foreign(..) => Some(ty), @@ -52,9 +50,14 @@ fn sized_constraint_for_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<' sized_constraint_for_ty(tcx, ty) }), - // these can be sized or unsized + // these can be sized or unsized. Param(..) | Alias(..) | Error(_) => Some(ty), + // We cannot instantiate the binder, so just return the *original* type back, + // but only if the inner type has a sized constraint. Thus we skip the binder, + // but don't actually use the result from `sized_constraint_for_ty`. + UnsafeBinder(inner_ty) => sized_constraint_for_ty(tcx, inner_ty.skip_binder()).map(|_| ty), + Placeholder(..) | Bound(..) | Infer(..) => { bug!("unexpected type `{ty:?}` in sized_constraint_for_ty") } diff --git a/compiler/rustc_type_ir/src/infer_ctxt.rs b/compiler/rustc_type_ir/src/infer_ctxt.rs index c9b636132f8..d5edc9610a4 100644 --- a/compiler/rustc_type_ir/src/infer_ctxt.rs +++ b/compiler/rustc_type_ir/src/infer_ctxt.rs @@ -151,7 +151,7 @@ pub trait InferCtxtLike: Sized { value: ty::Binder<Self::Interner, T>, ) -> T; - fn enter_forall<T: TypeFoldable<Self::Interner> + Copy, U>( + fn enter_forall<T: TypeFoldable<Self::Interner>, U>( &self, value: ty::Binder<Self::Interner, T>, f: impl FnOnce(T) -> U, diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs index 291ac42525e..e765cb66d00 100644 --- a/compiler/rustc_type_ir/src/interner.rs +++ b/compiler/rustc_type_ir/src/interner.rs @@ -189,10 +189,10 @@ pub trait Interner: type Features: Features<Self>; fn features(self) -> Self::Features; - fn bound_coroutine_hidden_types( + fn coroutine_hidden_types( self, def_id: Self::DefId, - ) -> impl IntoIterator<Item = ty::EarlyBinder<Self, ty::Binder<Self, Self::Ty>>>; + ) -> ty::EarlyBinder<Self, ty::Binder<Self, Self::Tys>>; fn fn_sig( self, diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index 594236cf1d9..c8ced78c4d7 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1369,7 +1369,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_lt"] fn lt(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Less)) + self.partial_cmp(other).is_some_and(Ordering::is_lt) } /// Tests less than or equal to (for `self` and `other`) and is used by the @@ -1387,7 +1387,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_le"] fn le(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Less | Equal)) + self.partial_cmp(other).is_some_and(Ordering::is_le) } /// Tests greater than (for `self` and `other`) and is used by the `>` @@ -1405,7 +1405,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_gt"] fn gt(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Greater)) + self.partial_cmp(other).is_some_and(Ordering::is_gt) } /// Tests greater than or equal to (for `self` and `other`) and is used by @@ -1423,7 +1423,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_ge"] fn ge(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Greater | Equal)) + self.partial_cmp(other).is_some_and(Ordering::is_ge) } } diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs index 3bde183fefb..935dd2e5673 100644 --- a/library/core/src/intrinsics/simd.rs +++ b/library/core/src/intrinsics/simd.rs @@ -11,7 +11,7 @@ /// `idx` must be in-bounds of the vector. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T; +pub const unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T; /// Extracts an element from a vector. /// @@ -22,32 +22,32 @@ pub unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T; /// `idx` must be in-bounds of the vector. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U; +pub const unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U; /// Adds two simd vectors elementwise. /// -/// `T` must be a vector of integer or floating point primitive types. +/// `T` must be a vector of integers or floats. #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn simd_add<T>(_x: T, _y: T) -> T; /// Subtracts `rhs` from `lhs` elementwise. /// -/// `T` must be a vector of integer or floating point primitive types. +/// `T` must be a vector of integers or floats. #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn simd_sub<T>(_lhs: T, _rhs: T) -> T; /// Multiplies two simd vectors elementwise. /// -/// `T` must be a vector of integer or floating point primitive types. +/// `T` must be a vector of integers or floats. #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn simd_mul<T>(_x: T, _y: T) -> T; /// Divides `lhs` by `rhs` elementwise. /// -/// `T` must be a vector of integer or floating point primitive types. +/// `T` must be a vector of integers or floats. /// /// # Safety /// For integers, `rhs` must not contain any zero elements. @@ -58,7 +58,7 @@ pub unsafe fn simd_div<T>(_lhs: T, _rhs: T) -> T; /// Returns remainder of two vectors elementwise. /// -/// `T` must be a vector of integer or floating point primitive types. +/// `T` must be a vector of integers or floats. /// /// # Safety /// For integers, `rhs` must not contain any zero elements. @@ -71,7 +71,7 @@ pub unsafe fn simd_rem<T>(_lhs: T, _rhs: T) -> T; /// /// Shifts `lhs` left by `rhs`, shifting in sign bits for signed types. /// -/// `T` must be a vector of integer primitive types. +/// `T` must be a vector of integers. /// /// # Safety /// @@ -82,7 +82,7 @@ pub unsafe fn simd_shl<T>(_lhs: T, _rhs: T) -> T; /// Shifts vector right elementwise, with UB on overflow. /// -/// `T` must be a vector of integer primitive types. +/// `T` must be a vector of integers. /// /// Shifts `lhs` right by `rhs`, shifting in sign bits for signed types. /// @@ -95,29 +95,28 @@ pub unsafe fn simd_shr<T>(_lhs: T, _rhs: T) -> T; /// "Ands" vectors elementwise. /// -/// `T` must be a vector of integer primitive types. +/// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn simd_and<T>(_x: T, _y: T) -> T; /// "Ors" vectors elementwise. /// -/// `T` must be a vector of integer primitive types. +/// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn simd_or<T>(_x: T, _y: T) -> T; /// "Exclusive ors" vectors elementwise. /// -/// `T` must be a vector of integer primitive types. +/// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn simd_xor<T>(_x: T, _y: T) -> T; /// Numerically casts a vector, elementwise. /// -/// `T` and `U` must be vectors of integer or floating point primitive types, and must have the -/// same length. +/// `T` and `U` must be vectors of integers or floats, and must have the same length. /// /// When casting floats to integers, the result is truncated. Out-of-bounds result lead to UB. /// When casting integers to floats, the result is rounded. @@ -138,8 +137,7 @@ pub unsafe fn simd_cast<T, U>(_x: T) -> U; /// Numerically casts a vector, elementwise. /// -/// `T` and `U` be a vectors of integer or floating point primitive types, and must have the -/// same length. +/// `T` and `U` be a vectors of integers or floats, and must have the same length. /// /// Like `simd_cast`, but saturates float-to-integer conversions (NaN becomes 0). /// This matches regular `as` and is always safe. @@ -153,7 +151,7 @@ pub unsafe fn simd_as<T, U>(_x: T) -> U; /// Negates a vector elementwise. /// -/// `T` must be a vector of integer or floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// Rust panics for `-<int>::Min` due to overflow, but it is not UB with this intrinsic. #[rustc_intrinsic] @@ -187,7 +185,7 @@ pub unsafe fn simd_fmax<T>(_x: T, _y: T) -> T; /// Tests elementwise equality of two vectors. /// -/// `T` must be a vector of floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// @@ -198,7 +196,7 @@ pub unsafe fn simd_eq<T, U>(_x: T, _y: T) -> U; /// Tests elementwise inequality equality of two vectors. /// -/// `T` must be a vector of floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// @@ -209,7 +207,7 @@ pub unsafe fn simd_ne<T, U>(_x: T, _y: T) -> U; /// Tests if `x` is less than `y`, elementwise. /// -/// `T` must be a vector of floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// @@ -220,7 +218,7 @@ pub unsafe fn simd_lt<T, U>(_x: T, _y: T) -> U; /// Tests if `x` is less than or equal to `y`, elementwise. /// -/// `T` must be a vector of floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// @@ -231,7 +229,7 @@ pub unsafe fn simd_le<T, U>(_x: T, _y: T) -> U; /// Tests if `x` is greater than `y`, elementwise. /// -/// `T` must be a vector of floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// @@ -242,7 +240,7 @@ pub unsafe fn simd_gt<T, U>(_x: T, _y: T) -> U; /// Tests if `x` is greater than or equal to `y`, elementwise. /// -/// `T` must be a vector of floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// @@ -273,7 +271,7 @@ pub unsafe fn simd_shuffle<T, U, V>(_x: T, _y: T, _idx: U) -> V; /// /// `U` must be a vector of pointers to the element type of `T`, with the same length as `T`. /// -/// `V` must be a vector of integers with the same length as `T` (but any element size). +/// `V` must be a vector of signed integers with the same length as `T` (but any element size). /// /// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, read the pointer. /// Otherwise if the corresponding value in `mask` is `0`, return the corresponding value from @@ -294,7 +292,7 @@ pub unsafe fn simd_gather<T, U, V>(_val: T, _ptr: U, _mask: V) -> T; /// /// `U` must be a vector of pointers to the element type of `T`, with the same length as `T`. /// -/// `V` must be a vector of integers with the same length as `T` (but any element size). +/// `V` must be a vector of signed integers with the same length as `T` (but any element size). /// /// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, write the /// corresponding value in `val` to the pointer. @@ -318,7 +316,7 @@ pub unsafe fn simd_scatter<T, U, V>(_val: T, _ptr: U, _mask: V); /// /// `U` must be a pointer to the element type of `T` /// -/// `V` must be a vector of integers with the same length as `T` (but any element size). +/// `V` must be a vector of signed integers with the same length as `T` (but any element size). /// /// For each element, if the corresponding value in `mask` is `!0`, read the corresponding /// pointer offset from `ptr`. @@ -341,7 +339,7 @@ pub unsafe fn simd_masked_load<V, U, T>(_mask: V, _ptr: U, _val: T) -> T; /// /// `U` must be a pointer to the element type of `T` /// -/// `V` must be a vector of integers with the same length as `T` (but any element size). +/// `V` must be a vector of signed integers with the same length as `T` (but any element size). /// /// For each element, if the corresponding value in `mask` is `!0`, write the corresponding /// value in `val` to the pointer offset from `ptr`. @@ -375,7 +373,7 @@ pub unsafe fn simd_saturating_sub<T>(_lhs: T, _rhs: T) -> T; /// Adds elements within a vector from left to right. /// -/// `T` must be a vector of integer or floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be the element type of `T`. /// @@ -387,7 +385,7 @@ pub unsafe fn simd_reduce_add_ordered<T, U>(_x: T, _y: U) -> U; /// Adds elements within a vector in arbitrary order. May also be re-associated with /// unordered additions on the inputs/outputs. /// -/// `T` must be a vector of integer or floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be the element type of `T`. #[rustc_intrinsic] @@ -396,7 +394,7 @@ pub unsafe fn simd_reduce_add_unordered<T, U>(_x: T) -> U; /// Multiplies elements within a vector from left to right. /// -/// `T` must be a vector of integer or floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be the element type of `T`. /// @@ -408,7 +406,7 @@ pub unsafe fn simd_reduce_mul_ordered<T, U>(_x: T, _y: U) -> U; /// Multiplies elements within a vector in arbitrary order. May also be re-associated with /// unordered additions on the inputs/outputs. /// -/// `T` must be a vector of integer or floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be the element type of `T`. #[rustc_intrinsic] @@ -437,7 +435,7 @@ pub unsafe fn simd_reduce_any<T>(_x: T) -> bool; /// Returns the maximum element of a vector. /// -/// `T` must be a vector of integer or floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be the element type of `T`. /// @@ -448,7 +446,7 @@ pub unsafe fn simd_reduce_max<T, U>(_x: T) -> U; /// Returns the minimum element of a vector. /// -/// `T` must be a vector of integer or floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be the element type of `T`. /// @@ -459,7 +457,7 @@ pub unsafe fn simd_reduce_min<T, U>(_x: T) -> U; /// Logical "ands" all elements together. /// -/// `T` must be a vector of integer or floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be the element type of `T`. #[rustc_intrinsic] @@ -468,7 +466,7 @@ pub unsafe fn simd_reduce_and<T, U>(_x: T) -> U; /// Logical "ors" all elements together. /// -/// `T` must be a vector of integer or floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be the element type of `T`. #[rustc_intrinsic] @@ -477,7 +475,7 @@ pub unsafe fn simd_reduce_or<T, U>(_x: T) -> U; /// Logical "exclusive ors" all elements together. /// -/// `T` must be a vector of integer or floating-point primitive types. +/// `T` must be a vector of integers or floats. /// /// `U` must be the element type of `T`. #[rustc_intrinsic] @@ -523,9 +521,9 @@ pub unsafe fn simd_bitmask<T, U>(_x: T) -> U; /// Selects elements from a mask. /// -/// `M` must be an integer vector. +/// `T` must be a vector. /// -/// `T` must be a vector with the same number of elements as `M`. +/// `M` must be a signed integer vector with the same length as `T` (but any element size). /// /// For each element, if the corresponding value in `mask` is `!0`, select the element from /// `if_true`. If the corresponding value in `mask` is `0`, select the element from diff --git a/library/coretests/tests/num/int_log.rs b/library/coretests/tests/num/int_log.rs index 9c630a61dd5..e8d35fc21ce 100644 --- a/library/coretests/tests/num/int_log.rs +++ b/library/coretests/tests/num/int_log.rs @@ -1,5 +1,13 @@ //! Tests for the `Integer::{ilog,log2,log10}` methods. +/// Rounds the argument down to the next integer, except that we account for potential imprecision +/// in the input, so if `f` is very close to an integer, it will round to that. +fn round_down_imprecise(f: f32) -> u32 { + // Rounds up for values less than 16*EPSILON below an integer, + // and rounds down for everything else. + (f + 16.0 * f32::EPSILON) as u32 +} + #[test] fn checked_ilog() { assert_eq!(999u32.checked_ilog(10), Some(2)); @@ -25,11 +33,19 @@ fn checked_ilog() { } #[cfg(not(miri))] // Miri is too slow for i in 1..=i16::MAX { - assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32), "checking {i}"); + assert_eq!( + i.checked_ilog(13), + Some(round_down_imprecise((i as f32).log(13.0))), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=u16::MAX { - assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32), "checking {i}"); + assert_eq!( + i.checked_ilog(13), + Some(round_down_imprecise((i as f32).log(13.0))), + "checking {i}" + ); } } @@ -46,25 +62,34 @@ fn checked_ilog2() { assert_eq!(0i8.checked_ilog2(), None); assert_eq!(0i16.checked_ilog2(), None); - assert_eq!(8192u16.checked_ilog2(), Some((8192f32).log2() as u32)); - assert_eq!(32768u16.checked_ilog2(), Some((32768f32).log2() as u32)); - assert_eq!(8192i16.checked_ilog2(), Some((8192f32).log2() as u32)); + assert_eq!(8192u16.checked_ilog2(), Some(round_down_imprecise((8192f32).log2()))); + assert_eq!(32768u16.checked_ilog2(), Some(round_down_imprecise((32768f32).log2()))); + assert_eq!(8192i16.checked_ilog2(), Some(round_down_imprecise((8192f32).log2()))); for i in 1..=u8::MAX { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=u16::MAX { - // Guard against Android's imprecise f32::ilog2 implementation. - if i != 8192 && i != 32768 { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); - } + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } for i in i8::MIN..=0 { assert_eq!(i.checked_ilog2(), None, "checking {i}"); } for i in 1..=i8::MAX { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in i16::MIN..=0 { @@ -72,10 +97,11 @@ fn checked_ilog2() { } #[cfg(not(miri))] // Miri is too slow for i in 1..=i16::MAX { - // Guard against Android's imprecise f32::ilog2 implementation. - if i != 8192 { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); - } + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } } @@ -92,15 +118,27 @@ fn checked_ilog10() { } #[cfg(not(miri))] // Miri is too slow for i in 1..=i16::MAX { - assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog10(), + Some(round_down_imprecise((i as f32).log10())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=u16::MAX { - assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog10(), + Some(round_down_imprecise((i as f32).log10())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=100_000u32 { - assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog10(), + Some(round_down_imprecise((i as f32).log10())), + "checking {i}" + ); } } diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 30bc0e3b088..5aa048c4cbc 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -83,7 +83,7 @@ impl Error { pub(crate) const UNKNOWN_THREAD_COUNT: Self = const_error!( ErrorKind::NotFound, - "The number of hardware threads is not known for the target platform", + "the number of hardware threads is not known for the target platform", ); pub(crate) const UNSUPPORTED_PLATFORM: Self = diff --git a/library/std/src/os/windows/io/socket.rs b/library/std/src/os/windows/io/socket.rs index 2bc6ce222ae..1c228914de9 100644 --- a/library/std/src/os/windows/io/socket.rs +++ b/library/std/src/os/windows/io/socket.rs @@ -90,7 +90,7 @@ impl OwnedSocket { #[cfg(target_vendor = "uwp")] pub(crate) fn set_no_inherit(&self) -> io::Result<()> { - Err(io::const_error!(io::ErrorKind::Unsupported, "Unavailable on UWP")) + Err(io::const_error!(io::ErrorKind::Unsupported, "unavailable on UWP")) } } diff --git a/library/std/src/sys/net/connection/xous/tcplistener.rs b/library/std/src/sys/net/connection/xous/tcplistener.rs index 851d2eb8178..7f13ca55920 100644 --- a/library/std/src/sys/net/connection/xous/tcplistener.rs +++ b/library/std/src/sys/net/connection/xous/tcplistener.rs @@ -11,7 +11,7 @@ macro_rules! unimpl { () => { return Err(io::const_error!( io::ErrorKind::Unsupported, - "This function is not yet implemented", + "this function is not yet implemented", )); }; } @@ -71,7 +71,7 @@ impl TcpListener { 0, 4096, ) else { - return Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response")); }; // The first four bytes should be zero upon success, and will be nonzero @@ -80,15 +80,15 @@ impl TcpListener { if response[0] != 0 || valid == 0 { let errcode = response[1]; if errcode == NetError::SocketInUse as u8 { - return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use")); + return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use")); } else if errcode == NetError::Invalid as u8 { - return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "Invalid address")); + return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "invalid address")); } else if errcode == NetError::LibraryError as u8 { - return Err(io::const_error!(io::ErrorKind::Other, "Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } else { return Err(io::const_error!( io::ErrorKind::Other, - "Unable to connect or internal error", + "unable to connect or internal error", )); } } @@ -131,7 +131,7 @@ impl TcpListener { } else if receive_request.raw[1] == NetError::WouldBlock as u8 { return Err(io::const_error!(io::ErrorKind::WouldBlock, "accept would block")); } else if receive_request.raw[1] == NetError::LibraryError as u8 { - return Err(io::const_error!(io::ErrorKind::Other, "Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } else { return Err(io::const_error!(io::ErrorKind::Other, "library error")); } @@ -169,7 +169,7 @@ impl TcpListener { Ok((TcpStream::from_listener(stream_fd, self.local.port(), port, addr), addr)) } } else { - Err(io::const_error!(io::ErrorKind::InvalidInput, "Unable to accept")) + Err(io::const_error!(io::ErrorKind::InvalidInput, "unable to accept")) } } @@ -186,7 +186,7 @@ impl TcpListener { services::net_server(), services::NetBlockingScalar::StdSetTtlTcp(self.fd.load(Ordering::Relaxed), ttl).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|_| ()) } @@ -195,7 +195,7 @@ impl TcpListener { services::net_server(), services::NetBlockingScalar::StdGetTtlTcp(self.fd.load(Ordering::Relaxed)).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|res| res[0] as _)?) } diff --git a/library/std/src/sys/net/connection/xous/tcpstream.rs b/library/std/src/sys/net/connection/xous/tcpstream.rs index 7f7bbfb7fed..283b1fe9a33 100644 --- a/library/std/src/sys/net/connection/xous/tcpstream.rs +++ b/library/std/src/sys/net/connection/xous/tcpstream.rs @@ -12,7 +12,7 @@ macro_rules! unimpl { () => { return Err(io::const_error!( io::ErrorKind::Unsupported, - "This function is not yet implemented", + "this function is not yet implemented", )); }; } @@ -96,7 +96,7 @@ impl TcpStream { 0, 4096, ) else { - return Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response")); }; // The first four bytes should be zero upon success, and will be nonzero @@ -106,13 +106,13 @@ impl TcpStream { // errcode is a u8 but stuck in a u16 where the upper byte is invalid. Mask & decode accordingly. let errcode = response[0]; if errcode == NetError::SocketInUse as u8 { - return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use")); + return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use")); } else if errcode == NetError::Unaddressable as u8 { - return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "Invalid address")); + return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "invalid address")); } else { return Err(io::const_error!( io::ErrorKind::InvalidInput, - "Unable to connect or internal error", + "unable to connect or internal error", )); } } @@ -198,7 +198,7 @@ impl TcpStream { ) else { return Err(io::const_error!( io::ErrorKind::InvalidInput, - "Library failure: wrong message type or messaging error", + "library failure: wrong message type or messaging error", )); }; @@ -212,11 +212,11 @@ impl TcpStream { if result[0] != 0 { if result[1] == 8 { // timed out - return Err(io::const_error!(io::ErrorKind::TimedOut, "Timeout")); + return Err(io::const_error!(io::ErrorKind::TimedOut, "timeout")); } if result[1] == 9 { // would block - return Err(io::const_error!(io::ErrorKind::WouldBlock, "Would block")); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "would block")); } } Err(io::const_error!(io::ErrorKind::Other, "recv_slice failure")) @@ -258,20 +258,20 @@ impl TcpStream { self.write_timeout.load(Ordering::Relaxed) as usize, buf_len, ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error")))?; + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "internal error")))?; if send_request.raw[0] != 0 { if send_request.raw[4] == 8 { // timed out return Err(io::const_error!( io::ErrorKind::BrokenPipe, - "Timeout or connection closed", + "timeout or connection closed", )); } else if send_request.raw[4] == 9 { // would block - return Err(io::const_error!(io::ErrorKind::WouldBlock, "Would block")); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "would block")); } else { - return Err(io::const_error!(io::ErrorKind::InvalidInput, "Error when sending")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "error when sending")); } } Ok(u32::from_le_bytes([ @@ -304,7 +304,7 @@ impl TcpStream { 0, 0, ) else { - return Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "internal error")); }; let mut i = get_addr.raw.iter(); match *i.next().unwrap() { @@ -324,7 +324,7 @@ impl TcpStream { } Ok(SocketAddr::V6(SocketAddrV6::new(new_addr.into(), self.local_port, 0, 0))) } - _ => Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error")), + _ => Err(io::const_error!(io::ErrorKind::InvalidInput, "tnternal error")), } } @@ -333,7 +333,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdTcpStreamShutdown(self.fd, how).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|_| ()) } @@ -355,7 +355,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdSetNodelay(self.fd, enabled).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|_| ()) } @@ -364,7 +364,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdGetNodelay(self.fd).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|res| res[0] != 0)?) } @@ -376,7 +376,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdSetTtlTcp(self.fd, ttl).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|_| ()) } @@ -385,7 +385,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdGetTtlTcp(self.fd).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|res| res[0] as _)?) } diff --git a/library/std/src/sys/net/connection/xous/udp.rs b/library/std/src/sys/net/connection/xous/udp.rs index ab5bd357b61..f35970bc321 100644 --- a/library/std/src/sys/net/connection/xous/udp.rs +++ b/library/std/src/sys/net/connection/xous/udp.rs @@ -13,7 +13,7 @@ macro_rules! unimpl { () => { return Err(io::const_error!( io::ErrorKind::Unsupported, - "This function is not yet implemented", + "this function is not yet implemented", )); }; } @@ -72,18 +72,18 @@ impl UdpSocket { if response[0] != 0 || valid == 0 { let errcode = response[1]; if errcode == NetError::SocketInUse as u8 { - return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use")); + return Err(io::const_error!(io::ErrorKind::ResourceBusy, "socket in use")); } else if errcode == NetError::Invalid as u8 { return Err(io::const_error!( io::ErrorKind::InvalidInput, - "Port can't be 0 or invalid address", + "port can't be 0 or invalid address", )); } else if errcode == NetError::LibraryError as u8 { - return Err(io::const_error!(io::ErrorKind::Other, "Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } else { return Err(io::const_error!( io::ErrorKind::Other, - "Unable to connect or internal error", + "unable to connect or internal error", )); } } @@ -98,13 +98,13 @@ impl UdpSocket { nonblocking: Cell::new(false), }); } - Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response")) + Err(io::const_error!(io::ErrorKind::InvalidInput, "invalid response")) } pub fn peer_addr(&self) -> io::Result<SocketAddr> { match self.remote.get() { Some(dest) => Ok(dest), - None => Err(io::const_error!(io::ErrorKind::NotConnected, "No peer specified")), + None => Err(io::const_error!(io::ErrorKind::NotConnected, "no peer specified")), } } @@ -145,7 +145,7 @@ impl UdpSocket { } else if receive_request.raw[1] == NetError::WouldBlock as u8 { return Err(io::const_error!(io::ErrorKind::WouldBlock, "recv would block")); } else if receive_request.raw[1] == NetError::LibraryError as u8 { - return Err(io::const_error!(io::ErrorKind::Other, "Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } else { return Err(io::const_error!(io::ErrorKind::Other, "library error")); } @@ -178,7 +178,7 @@ impl UdpSocket { Ok((rxlen as usize, addr)) } } else { - Err(io::const_error!(io::ErrorKind::InvalidInput, "Unable to recv")) + Err(io::const_error!(io::ErrorKind::InvalidInput, "unable to recv")) } } @@ -281,19 +281,19 @@ impl UdpSocket { if errcode == NetError::SocketInUse as u8 { return Err(io::const_error!( io::ErrorKind::ResourceBusy, - "Socket in use", + "socket in use", )); } else if errcode == NetError::Invalid as u8 { return Err(io::const_error!( io::ErrorKind::InvalidInput, - "Socket not valid", + "socket not valid", )); } else if errcode == NetError::LibraryError as u8 { - return Err(io::const_error!(io::ErrorKind::Other, "Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } else { return Err(io::const_error!( io::ErrorKind::Other, - "Unable to connect", + "unable to connect", )); } } else { @@ -303,13 +303,13 @@ impl UdpSocket { } Err(crate::os::xous::ffi::Error::ServerQueueFull) => { if now.elapsed() >= write_timeout { - return Err(io::const_error!(io::ErrorKind::WouldBlock, "Write timed out")); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "write timed out")); } else { // question: do we want to do something a bit more gentle than immediately retrying? crate::thread::yield_now(); } } - _ => return Err(io::const_error!(io::ErrorKind::Other, "Library error")), + _ => return Err(io::const_error!(io::ErrorKind::Other, "library error")), } } } @@ -363,7 +363,7 @@ impl UdpSocket { services::net_server(), services::NetBlockingScalar::StdSetTtlUdp(self.fd, ttl).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|_| ()) } @@ -372,7 +372,7 @@ impl UdpSocket { services::net_server(), services::NetBlockingScalar::StdGetTtlUdp(self.fd).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "unexpected return value"))) .map(|res| res[0] as _)?) } diff --git a/library/std/src/sys/pal/hermit/thread.rs b/library/std/src/sys/pal/hermit/thread.rs index 4a7afddbec1..bb68a824fc3 100644 --- a/library/std/src/sys/pal/hermit/thread.rs +++ b/library/std/src/sys/pal/hermit/thread.rs @@ -41,7 +41,7 @@ impl Thread { unsafe { drop(Box::from_raw(p)); } - Err(io::const_error!(io::ErrorKind::Uncategorized, "Unable to create thread!")) + Err(io::const_error!(io::ErrorKind::Uncategorized, "unable to create thread!")) } else { Ok(Thread { tid }) }; diff --git a/library/std/src/sys/pal/uefi/helpers.rs b/library/std/src/sys/pal/uefi/helpers.rs index ec2da4e4ee7..cb6aacd0063 100644 --- a/library/std/src/sys/pal/uefi/helpers.rs +++ b/library/std/src/sys/pal/uefi/helpers.rs @@ -158,7 +158,7 @@ pub(crate) unsafe fn close_event(evt: NonNull<crate::ffi::c_void>) -> io::Result /// Note: Some protocols need to be manually freed. It is the caller's responsibility to do so. pub(crate) fn image_handle_protocol<T>(protocol_guid: Guid) -> io::Result<NonNull<T>> { let system_handle = uefi::env::try_image_handle() - .ok_or(io::const_error!(io::ErrorKind::NotFound, "Protocol not found in Image handle"))?; + .ok_or(io::const_error!(io::ErrorKind::NotFound, "protocol not found in Image handle"))?; open_protocol(system_handle, protocol_guid) } @@ -178,7 +178,7 @@ pub(crate) fn device_path_to_text(path: NonNull<device_path::Protocol>) -> io::R }; let path = os_string_from_raw(path_ptr) - .ok_or(io::const_error!(io::ErrorKind::InvalidData, "Invalid path"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidData, "invalid path"))?; if let Some(boot_services) = crate::os::uefi::env::boot_services() { let boot_services: NonNull<r_efi::efi::BootServices> = boot_services.cast(); @@ -213,7 +213,7 @@ pub(crate) fn device_path_to_text(path: NonNull<device_path::Protocol>) -> io::R } } - Err(io::const_error!(io::ErrorKind::NotFound, "No device path to text protocol found")) + Err(io::const_error!(io::ErrorKind::NotFound, "no device path to text protocol found")) } /// Gets RuntimeServices. @@ -245,7 +245,7 @@ impl OwnedDevicePath { NonNull::new(path) .map(OwnedDevicePath) - .ok_or_else(|| const_error!(io::ErrorKind::InvalidFilename, "Invalid Device Path")) + .ok_or_else(|| const_error!(io::ErrorKind::InvalidFilename, "invalid Device Path")) } static LAST_VALID_HANDLE: AtomicPtr<crate::ffi::c_void> = @@ -490,7 +490,7 @@ pub(crate) fn get_device_path_from_map(map: &Path) -> io::Result<BorrowedDeviceP let shell = open_shell().ok_or(io::const_error!(io::ErrorKind::NotFound, "UEFI Shell not found"))?; let mut path = os_string_to_raw(map.as_os_str()) - .ok_or(io::const_error!(io::ErrorKind::InvalidFilename, "Invalid UEFI shell mapping"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidFilename, "invalid UEFI shell mapping"))?; // The Device Path Protocol pointer returned by UEFI shell is owned by the shell and is not // freed throughout it's lifetime. So it has a 'static lifetime. diff --git a/library/std/src/sys/pal/uefi/os.rs b/library/std/src/sys/pal/uefi/os.rs index e305b8610c9..d26d61890c1 100644 --- a/library/std/src/sys/pal/uefi/os.rs +++ b/library/std/src/sys/pal/uefi/os.rs @@ -70,7 +70,7 @@ pub fn getcwd() -> io::Result<PathBuf> { let path_ptr = unsafe { ((*shell.as_ptr()).get_cur_dir)(crate::ptr::null_mut()) }; helpers::os_string_from_raw(path_ptr) .map(PathBuf::from) - .ok_or(io::const_error!(io::ErrorKind::InvalidData, "Invalid path")) + .ok_or(io::const_error!(io::ErrorKind::InvalidData, "invalid path")) } None => { let mut t = current_exe()?; @@ -86,7 +86,7 @@ pub fn chdir(p: &path::Path) -> io::Result<()> { let shell = helpers::open_shell().ok_or(unsupported_err())?; let mut p = helpers::os_string_to_raw(p.as_os_str()) - .ok_or(io::const_error!(io::ErrorKind::InvalidData, "Invalid path"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidData, "invalid path"))?; let r = unsafe { ((*shell.as_ptr()).set_cur_dir)(crate::ptr::null_mut(), p.as_mut_ptr()) }; if r.is_error() { Err(io::Error::from_raw_os_error(r.as_usize())) } else { Ok(()) } @@ -229,15 +229,15 @@ mod uefi_env { pub(crate) fn set(key: &OsStr, val: &OsStr) -> io::Result<()> { let mut key_ptr = helpers::os_string_to_raw(key) - .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "Invalid Key"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "invalid key"))?; let mut val_ptr = helpers::os_string_to_raw(val) - .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "Invalid Value"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "invalid value"))?; unsafe { set_raw(key_ptr.as_mut_ptr(), val_ptr.as_mut_ptr()) } } pub(crate) fn unset(key: &OsStr) -> io::Result<()> { let mut key_ptr = helpers::os_string_to_raw(key) - .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "Invalid Key"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "invalid key"))?; unsafe { set_raw(key_ptr.as_mut_ptr(), crate::ptr::null_mut()) } } @@ -267,7 +267,7 @@ mod uefi_env { }); // SAFETY: val.add(start) is always NULL terminated let val = unsafe { get_raw(shell, val.add(start)) } - .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "Invalid Value"))?; + .ok_or(io::const_error!(io::ErrorKind::InvalidInput, "invalid value"))?; vars.push((key, val)); start = i + 1; diff --git a/library/std/src/sys/pal/uefi/process.rs b/library/std/src/sys/pal/uefi/process.rs index c73a6350357..a47c8dbcaaa 100644 --- a/library/std/src/sys/pal/uefi/process.rs +++ b/library/std/src/sys/pal/uefi/process.rs @@ -613,7 +613,7 @@ mod uefi_command_internal { OsString::from_wide(&self._buffer) .into_string() .map(Into::into) - .map_err(|_| const_error!(io::ErrorKind::Other, "utf8 conversion failed")) + .map_err(|_| const_error!(io::ErrorKind::Other, "UTF-8 conversion failed")) } extern "efiapi" fn reset( diff --git a/library/std/src/sys/pal/uefi/stdio.rs b/library/std/src/sys/pal/uefi/stdio.rs index d049d19bc83..257e321dd03 100644 --- a/library/std/src/sys/pal/uefi/stdio.rs +++ b/library/std/src/sys/pal/uefi/stdio.rs @@ -71,7 +71,7 @@ impl io::Read for Stdin { }; if ch.len() > 1 { - return Err(io::const_error!(io::ErrorKind::InvalidData, "invalid utf-16 sequence")); + return Err(io::const_error!(io::ErrorKind::InvalidData, "invalid UTF-16 sequence")); } match ch.pop().unwrap() { diff --git a/library/std/src/sys/pal/unix/os.rs b/library/std/src/sys/pal/unix/os.rs index 78404b4afa7..3a238d160cb 100644 --- a/library/std/src/sys/pal/unix/os.rs +++ b/library/std/src/sys/pal/unix/os.rs @@ -475,7 +475,7 @@ pub fn current_exe() -> io::Result<PathBuf> { ); if result != libc::B_OK { use crate::io::ErrorKind; - Err(io::const_error!(ErrorKind::Uncategorized, "Error getting executable path")) + Err(io::const_error!(ErrorKind::Uncategorized, "error getting executable path")) } else { // find_path adds the null terminator. let name = CStr::from_ptr(name.as_ptr()).to_bytes(); @@ -492,7 +492,7 @@ pub fn current_exe() -> io::Result<PathBuf> { #[cfg(target_os = "l4re")] pub fn current_exe() -> io::Result<PathBuf> { use crate::io::ErrorKind; - Err(io::const_error!(ErrorKind::Unsupported, "Not yet implemented!")) + Err(io::const_error!(ErrorKind::Unsupported, "not yet implemented!")) } #[cfg(target_os = "vxworks")] diff --git a/library/std/src/sys/pal/unix/process/process_fuchsia.rs b/library/std/src/sys/pal/unix/process/process_fuchsia.rs index b7a35718757..4ddc96356b9 100644 --- a/library/std/src/sys/pal/unix/process/process_fuchsia.rs +++ b/library/std/src/sys/pal/unix/process/process_fuchsia.rs @@ -187,7 +187,7 @@ impl Process { if actual != 1 { return Err(io::const_error!( io::ErrorKind::InvalidData, - "Failed to get exit status of process", + "failed to get exit status of process", )); } Ok(ExitStatus(proc_info.return_code)) @@ -224,7 +224,7 @@ impl Process { if actual != 1 { return Err(io::const_error!( io::ErrorKind::InvalidData, - "Failed to get exit status of process", + "failed to get exit status of process", )); } Ok(Some(ExitStatus(proc_info.return_code))) diff --git a/library/std/src/sys/pal/unix/process/process_unix.rs b/library/std/src/sys/pal/unix/process/process_unix.rs index aa7406dd548..1f3abd4cc12 100644 --- a/library/std/src/sys/pal/unix/process/process_unix.rs +++ b/library/std/src/sys/pal/unix/process/process_unix.rs @@ -1228,7 +1228,7 @@ mod linux_child_ext { .as_ref() // SAFETY: The os type is a transparent wrapper, therefore we can transmute references .map(|fd| unsafe { mem::transmute::<&imp::PidFd, &os::PidFd>(fd) }) - .ok_or_else(|| io::const_error!(ErrorKind::Uncategorized, "No pidfd was created.")) + .ok_or_else(|| io::const_error!(ErrorKind::Uncategorized, "no pidfd was created.")) } fn into_pidfd(mut self) -> Result<os::PidFd, Self> { diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 4c5757b890a..3dedc8d1257 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -480,7 +480,7 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> { unsafe { use libc::_syspage_ptr; if _syspage_ptr.is_null() { - Err(io::const_error!(io::ErrorKind::NotFound, "No syspage available")) + Err(io::const_error!(io::ErrorKind::NotFound, "no syspage available")) } else { let cpus = (*_syspage_ptr).num_cpu; NonZero::new(cpus as usize) @@ -520,7 +520,7 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> { } } else { // FIXME: implement on Redox, l4re - Err(io::const_error!(io::ErrorKind::Unsupported, "Getting the number of hardware threads is not supported on the target platform")) + Err(io::const_error!(io::ErrorKind::Unsupported, "getting the number of hardware threads is not supported on the target platform")) } } } diff --git a/library/std/src/sys/pal/unix/time.rs b/library/std/src/sys/pal/unix/time.rs index e224980e95f..0271626380c 100644 --- a/library/std/src/sys/pal/unix/time.rs +++ b/library/std/src/sys/pal/unix/time.rs @@ -92,7 +92,7 @@ impl Timespec { if tv_nsec >= 0 && tv_nsec < NSEC_PER_SEC as i64 { Ok(unsafe { Self::new_unchecked(tv_sec, tv_nsec) }) } else { - Err(io::const_error!(io::ErrorKind::InvalidData, "Invalid timestamp")) + Err(io::const_error!(io::ErrorKind::InvalidData, "invalid timestamp")) } } diff --git a/library/std/src/sys/pal/windows/fs.rs b/library/std/src/sys/pal/windows/fs.rs index dce5a429cb0..623a7d89ba5 100644 --- a/library/std/src/sys/pal/windows/fs.rs +++ b/library/std/src/sys/pal/windows/fs.rs @@ -724,7 +724,7 @@ impl File { { return Err(io::const_error!( io::ErrorKind::InvalidInput, - "Cannot set file timestamp to 0", + "cannot set file timestamp to 0", )); } let is_max = |t: c::FILETIME| t.dwLowDateTime == u32::MAX && t.dwHighDateTime == u32::MAX; @@ -734,7 +734,7 @@ impl File { { return Err(io::const_error!( io::ErrorKind::InvalidInput, - "Cannot set file timestamp to 0xFFFF_FFFF_FFFF_FFFF", + "cannot set file timestamp to 0xFFFF_FFFF_FFFF_FFFF", )); } cvt(unsafe { diff --git a/library/std/src/sys/pal/windows/process.rs b/library/std/src/sys/pal/windows/process.rs index a41dfbfe601..6eff471f386 100644 --- a/library/std/src/sys/pal/windows/process.rs +++ b/library/std/src/sys/pal/windows/process.rs @@ -260,9 +260,10 @@ impl Command { needs_stdin: bool, proc_thread_attribute_list: Option<&ProcThreadAttributeList<'_>>, ) -> io::Result<(Process, StdioPipes)> { + let env_saw_path = self.env.have_changed_path(); let maybe_env = self.env.capture_if_changed(); - let child_paths = if let Some(env) = maybe_env.as_ref() { + let child_paths = if env_saw_path && let Some(env) = maybe_env.as_ref() { env.get(&EnvKey::new("PATH")).map(|s| s.as_os_str()) } else { None diff --git a/library/test/src/formatters/junit.rs b/library/test/src/formatters/junit.rs index 36158b0258a..84153a9d05b 100644 --- a/library/test/src/formatters/junit.rs +++ b/library/test/src/formatters/junit.rs @@ -39,15 +39,15 @@ fn str_to_cdata(s: &str) -> String { impl<T: Write> OutputFormatter for JunitFormatter<T> { fn write_discovery_start(&mut self) -> io::Result<()> { - Err(io::const_error!(io::ErrorKind::NotFound, "Not yet implemented!")) + Err(io::const_error!(io::ErrorKind::NotFound, "not yet implemented!")) } fn write_test_discovered(&mut self, _desc: &TestDesc, _test_type: &str) -> io::Result<()> { - Err(io::const_error!(io::ErrorKind::NotFound, "Not yet implemented!")) + Err(io::const_error!(io::ErrorKind::NotFound, "not yet implemented!")) } fn write_discovery_finish(&mut self, _state: &ConsoleTestDiscoveryState) -> io::Result<()> { - Err(io::const_error!(io::ErrorKind::NotFound, "Not yet implemented!")) + Err(io::const_error!(io::ErrorKind::NotFound, "not yet implemented!")) } fn write_run_start( diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index aee56fe78e2..8e913f68184 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -987,9 +987,7 @@ macro_rules! tool_doc { cargo.rustdocflag("-Arustdoc::private-intra-doc-links"); cargo.rustdocflag("--enable-index-page"); cargo.rustdocflag("--show-type-layout"); - // FIXME: `--generate-link-to-definition` tries to resolve cfged out code - // see https://github.com/rust-lang/rust/pull/122066#issuecomment-1983049222 - // cargo.rustdocflag("--generate-link-to-definition"); + cargo.rustdocflag("--generate-link-to-definition"); let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target).join("doc"); $(for krate in $crates { diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 709711d9d34..c9fa2e9ba96 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -269,7 +269,13 @@ impl Step for Cargotest { .args(builder.config.test_args()) .env("RUSTC", builder.rustc(compiler)) .env("RUSTDOC", builder.rustdoc(compiler)); - add_rustdoc_cargo_linker_args(&mut cmd, builder, compiler.host, LldThreads::No); + add_rustdoc_cargo_linker_args( + &mut cmd, + builder, + compiler.host, + LldThreads::No, + compiler.stage, + ); cmd.delay_failure().run(builder); } } @@ -847,7 +853,7 @@ impl Step for RustdocTheme { .env("CFG_RELEASE_CHANNEL", &builder.config.channel) .env("RUSTDOC_REAL", builder.rustdoc(self.compiler)) .env("RUSTC_BOOTSTRAP", "1"); - cmd.args(linker_args(builder, self.compiler.host, LldThreads::No)); + cmd.args(linker_args(builder, self.compiler.host, LldThreads::No, self.compiler.stage)); cmd.delay_failure().run(builder); } @@ -1023,7 +1029,13 @@ impl Step for RustdocGUI { cmd.env("RUSTDOC", builder.rustdoc(self.compiler)) .env("RUSTC", builder.rustc(self.compiler)); - add_rustdoc_cargo_linker_args(&mut cmd, builder, self.compiler.host, LldThreads::No); + add_rustdoc_cargo_linker_args( + &mut cmd, + builder, + self.compiler.host, + LldThreads::No, + self.compiler.stage, + ); for path in &builder.paths { if let Some(p) = helpers::is_valid_test_suite_arg(path, "tests/rustdoc-gui", builder) { @@ -1887,7 +1899,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the let mut hostflags = flags.clone(); hostflags.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display())); - hostflags.extend(linker_flags(builder, compiler.host, LldThreads::No)); + hostflags.extend(linker_flags(builder, compiler.host, LldThreads::No, compiler.stage)); let mut targetflags = flags; targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display())); diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 0aab9f04fea..d1d52d82eaa 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -260,7 +260,7 @@ impl Cargo { } } - for arg in linker_args(builder, compiler.host, LldThreads::Yes) { + for arg in linker_args(builder, compiler.host, LldThreads::Yes, 0) { self.hostflags.arg(&arg); } @@ -270,10 +270,10 @@ impl Cargo { } // We want to set -Clinker using Cargo, therefore we only call `linker_flags` and not // `linker_args` here. - for flag in linker_flags(builder, target, LldThreads::Yes) { + for flag in linker_flags(builder, target, LldThreads::Yes, compiler.stage) { self.rustflags.arg(&flag); } - for arg in linker_args(builder, target, LldThreads::Yes) { + for arg in linker_args(builder, target, LldThreads::Yes, compiler.stage) { self.rustdocflags.arg(&arg); } diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 9c04f097bee..c8e2856bdc8 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -1462,7 +1462,7 @@ impl<'a> Builder<'a> { cmd.arg("-Dwarnings"); } cmd.arg("-Znormalize-docs"); - cmd.args(linker_args(self, compiler.host, LldThreads::Yes)); + cmd.args(linker_args(self, compiler.host, LldThreads::Yes, compiler.stage)); cmd } diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 3fee397da09..7ad308cd067 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -430,8 +430,9 @@ pub fn linker_args( builder: &Builder<'_>, target: TargetSelection, lld_threads: LldThreads, + stage: u32, ) -> Vec<String> { - let mut args = linker_flags(builder, target, lld_threads); + let mut args = linker_flags(builder, target, lld_threads, stage); if let Some(linker) = builder.linker(target) { args.push(format!("-Clinker={}", linker.display())); @@ -446,12 +447,18 @@ pub fn linker_flags( builder: &Builder<'_>, target: TargetSelection, lld_threads: LldThreads, + stage: u32, ) -> Vec<String> { let mut args = vec![]; if !builder.is_lld_direct_linker(target) && builder.config.lld_mode.is_used() { match builder.config.lld_mode { LldMode::External => { - args.push("-Clinker-flavor=gnu-lld-cc".to_string()); + // cfg(bootstrap) - remove after updating bootstrap compiler (#137498) + if stage == 0 && target.is_windows() { + args.push("-Clink-arg=-fuse-ld=lld".to_string()); + } else { + args.push("-Clinker-flavor=gnu-lld-cc".to_string()); + } // FIXME(kobzol): remove this flag once MCP510 gets stabilized args.push("-Zunstable-options".to_string()); } @@ -479,8 +486,9 @@ pub fn add_rustdoc_cargo_linker_args( builder: &Builder<'_>, target: TargetSelection, lld_threads: LldThreads, + stage: u32, ) { - let args = linker_args(builder, target, lld_threads); + let args = linker_args(builder, target, lld_threads, stage); let mut flags = cmd .get_envs() .find_map(|(k, v)| if k == OsStr::new("RUSTDOCFLAGS") { v } else { None }) diff --git a/src/ci/run.sh b/src/ci/run.sh index 536754f12bc..b874f71832d 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -279,5 +279,5 @@ if [ "$RUN_CHECK_WITH_PARALLEL_QUERIES" != "" ]; then fi echo "::group::sccache stats" -sccache --show-adv-stats || true +sccache --show-stats || true echo "::endgroup::" diff --git a/src/doc/rustdoc/src/write-documentation/re-exports.md b/src/doc/rustdoc/src/write-documentation/re-exports.md index 34688545c74..ee60916351a 100644 --- a/src/doc/rustdoc/src/write-documentation/re-exports.md +++ b/src/doc/rustdoc/src/write-documentation/re-exports.md @@ -85,7 +85,22 @@ pub struct Hidden; pub use self::Hidden as InlinedHidden; ``` -The same applies on re-exports themselves: if you have multiple re-exports and some of them have +However, if you still want the re-export itself to be visible, you can add the `#[doc(inline)]` +attribute on it: + +```rust,ignore (inline) +// This struct won't be visible. +#[doc(hidden)] +pub struct Hidden; + +#[doc(inline)] +pub use self::Hidden as InlinedHidden; +``` + +In this case, you will have `pub use self::Hidden as InlinedHidden;` in the generated documentation +but no link to the `Hidden` item. + +So back to `#[doc(hidden)]`: if you have multiple re-exports and some of them have `#[doc(hidden)]`, then these ones (and only these) won't appear in the documentation: ```rust,ignore (inline) diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs index 4792bc525a5..9935074877b 100644 --- a/src/librustdoc/doctest/make.rs +++ b/src/librustdoc/doctest/make.rs @@ -208,7 +208,7 @@ impl DocTestBuilder { let (main_pre, main_post) = if returns_result { ( format!( - "fn main() {{ {inner_attr}fn {inner_fn_name}() -> Result<(), impl core::fmt::Debug> {{\n", + "fn main() {{ {inner_attr}fn {inner_fn_name}() -> core::result::Result<(), impl core::fmt::Debug> {{\n", ), format!("\n}} {inner_fn_name}().unwrap() }}"), ) diff --git a/src/librustdoc/doctest/tests.rs b/src/librustdoc/doctest/tests.rs index fa6cca3681b..e2b964bf5af 100644 --- a/src/librustdoc/doctest/tests.rs +++ b/src/librustdoc/doctest/tests.rs @@ -316,7 +316,7 @@ let mut input = String::new(); io::stdin().read_line(&mut input)?; Ok::<(), io:Error>(())"; let expected = "#![allow(unused)] -fn main() { fn _inner() -> Result<(), impl core::fmt::Debug> { +fn main() { fn _inner() -> core::result::Result<(), impl core::fmt::Debug> { use std::io; let mut input = String::new(); io::stdin().read_line(&mut input)?; diff --git a/src/tools/miri/tests/fail/erroneous_const.stderr b/src/tools/miri/tests/fail/erroneous_const.stderr index 3528620cb6a..2906ac6b20a 100644 --- a/src/tools/miri/tests/fail/erroneous_const.stderr +++ b/src/tools/miri/tests/fail/erroneous_const.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `PrintName::<i32>::VOID` failed --> tests/fail/erroneous_const.rs:LL:CC | LL | const VOID: ! = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', tests/fail/erroneous_const.rs:LL:CC + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index e2ab336d2e4..a4e49e0aa10 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs @@ -192,7 +192,7 @@ fn layout_of_simd_ty( Ok(Arc::new(Layout { variants: Variants::Single { index: struct_variant_idx() }, fields, - backend_repr: BackendRepr::Vector { element: e_abi, count: e_len }, + backend_repr: BackendRepr::SimdVector { element: e_abi, count: e_len }, largest_niche: e_ly.largest_niche, uninhabited: false, size, diff --git a/src/tools/rustfmt/src/types.rs b/src/tools/rustfmt/src/types.rs index 0009490e86f..7b44b47c719 100644 --- a/src/tools/rustfmt/src/types.rs +++ b/src/tools/rustfmt/src/types.rs @@ -1019,7 +1019,11 @@ impl Rewrite for ast::Ty { } ast::TyKind::UnsafeBinder(ref binder) => { let mut result = String::new(); - if let Some(ref lifetime_str) = + if binder.generic_params.is_empty() { + // We always want to write `unsafe<>` since `unsafe<> Ty` + // and `Ty` are distinct types. + result.push_str("unsafe<> ") + } else if let Some(ref lifetime_str) = rewrite_bound_params(context, shape, &binder.generic_params) { result.push_str("unsafe<"); diff --git a/src/tools/rustfmt/tests/source/unsafe-binders.rs b/src/tools/rustfmt/tests/source/unsafe-binders.rs index ccf7c8bb9af..2f43af54d20 100644 --- a/src/tools/rustfmt/tests/source/unsafe-binders.rs +++ b/src/tools/rustfmt/tests/source/unsafe-binders.rs @@ -9,3 +9,6 @@ struct Foo { struct Bar(unsafe<'a> &'a ()); impl Trait for unsafe<'a> &'a () {} + +fn empty() +-> unsafe<> () {} diff --git a/src/tools/rustfmt/tests/target/unsafe-binders.rs b/src/tools/rustfmt/tests/target/unsafe-binders.rs index 9d308f4a894..d52dc559519 100644 --- a/src/tools/rustfmt/tests/target/unsafe-binders.rs +++ b/src/tools/rustfmt/tests/target/unsafe-binders.rs @@ -7,3 +7,5 @@ struct Foo { struct Bar(unsafe<'a> &'a ()); impl Trait for unsafe<'a> &'a () {} + +fn empty() -> unsafe<> () {} diff --git a/tests/assembly/aarch64-pointer-auth.rs b/tests/assembly/aarch64-pointer-auth.rs index 344e9e74bc2..8c006982679 100644 --- a/tests/assembly/aarch64-pointer-auth.rs +++ b/tests/assembly/aarch64-pointer-auth.rs @@ -1,5 +1,6 @@ // Test that PAC instructions are emitted when branch-protection is specified. +//@ add-core-stubs //@ revisions: PACRET PAUTHLR_NOP PAUTHLR //@ assembly-output: emit-asm //@ needs-llvm-components: aarch64 @@ -14,8 +15,8 @@ #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; // PACRET: hint #25 // PACRET: hint #29 diff --git a/tests/assembly/cmse.rs b/tests/assembly/cmse.rs index e0ada8dc2f1..2984df92225 100644 --- a/tests/assembly/cmse.rs +++ b/tests/assembly/cmse.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: hard soft //@ assembly-output: emit-asm //@ [hard] compile-flags: --target thumbv8m.main-none-eabihf --crate-type lib -Copt-level=1 @@ -7,10 +8,9 @@ #![crate_type = "lib"] #![feature(abi_c_cmse_nonsecure_call, cmse_nonsecure_entry, no_core, lang_items)] #![no_core] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} + +extern crate minicore; +use minicore::*; // CHECK-LABEL: __acle_se_entry_point: // CHECK-NEXT: entry_point: diff --git a/tests/assembly/dwarf4.rs b/tests/assembly/dwarf4.rs index 22be8e5603f..6013adf3386 100644 --- a/tests/assembly/dwarf4.rs +++ b/tests/assembly/dwarf4.rs @@ -1,5 +1,6 @@ // Makes sure that `-Z dwarf-version=4` causes `rustc` to emit DWARF version 4. //@ assembly-output: emit-asm +//@ add-core-stubs //@ compile-flags: -g --target x86_64-unknown-linux-gnu -Z dwarf-version=4 -Copt-level=0 //@ needs-llvm-components: x86 @@ -7,10 +8,8 @@ #![crate_type = "rlib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; pub fn wibble() {} diff --git a/tests/assembly/dwarf5.rs b/tests/assembly/dwarf5.rs index 35f2716e9fa..9cd596e7834 100644 --- a/tests/assembly/dwarf5.rs +++ b/tests/assembly/dwarf5.rs @@ -1,4 +1,5 @@ // Makes sure that `-Z dwarf-version=5` causes `rustc` to emit DWARF version 5. +//@ add-core-stubs //@ assembly-output: emit-asm //@ compile-flags: -g --target x86_64-unknown-linux-gnu -Z dwarf-version=5 -Copt-level=0 //@ needs-llvm-components: x86 @@ -7,10 +8,8 @@ #![crate_type = "rlib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; pub fn wibble() {} diff --git a/tests/assembly/pic-relocation-model.rs b/tests/assembly/pic-relocation-model.rs index 73db94791ec..d35cd968389 100644 --- a/tests/assembly/pic-relocation-model.rs +++ b/tests/assembly/pic-relocation-model.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x64 //@ assembly-output: emit-asm //@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pic @@ -7,10 +8,8 @@ #![no_core] #![crate_type = "rlib"] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // CHECK-LABEL: call_other_fn: // CHECK: {{(jmpq|callq)}} *other_fn@GOTPCREL(%rip) diff --git a/tests/assembly/pie-relocation-model.rs b/tests/assembly/pie-relocation-model.rs index e632b4dd582..5c74b34eb31 100644 --- a/tests/assembly/pie-relocation-model.rs +++ b/tests/assembly/pie-relocation-model.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x64 //@ assembly-output: emit-asm //@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pie @@ -7,10 +8,8 @@ #![no_core] #![crate_type = "rlib"] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // CHECK-LABEL: call_other_fn: // With PIE local functions are called "directly". diff --git a/tests/assembly/powerpc64-struct-abi.rs b/tests/assembly/powerpc64-struct-abi.rs index 0332eb94d8a..eb27afc4f23 100644 --- a/tests/assembly/powerpc64-struct-abi.rs +++ b/tests/assembly/powerpc64-struct-abi.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: elfv1-be elfv2-be elfv2-le aix //@ assembly-output: emit-asm //@ compile-flags: -Copt-level=3 @@ -20,21 +21,9 @@ #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; -#[lang = "copy"] -trait Copy {} - -#[lang = "freeze"] -trait Freeze {} - -#[lang = "unpin"] -trait Unpin {} - -impl Copy for u8 {} -impl Copy for u16 {} -impl Copy for u32 {} impl Copy for FiveU32s {} impl Copy for FiveU16s {} impl Copy for ThreeU8s {} diff --git a/tests/assembly/riscv-soft-abi-with-float-features.rs b/tests/assembly/riscv-soft-abi-with-float-features.rs index 8ccfa72a7b6..72cbd3841c1 100644 --- a/tests/assembly/riscv-soft-abi-with-float-features.rs +++ b/tests/assembly/riscv-soft-abi-with-float-features.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ assembly-output: emit-asm //@ compile-flags: --target riscv64imac-unknown-none-elf -Ctarget-feature=+f,+d //@ needs-llvm-components: riscv @@ -9,15 +10,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} - -#[lang = "copy"] -trait Copy {} - -impl Copy for f16 {} -impl Copy for f32 {} -impl Copy for f64 {} +extern crate minicore; +use minicore::*; // This test checks that the floats are all returned in `a0` as required by the `lp64` ABI. diff --git a/tests/assembly/s390x-backchain-toggle.rs b/tests/assembly/s390x-backchain-toggle.rs index 7ef0292d911..83c7b82d0d4 100644 --- a/tests/assembly/s390x-backchain-toggle.rs +++ b/tests/assembly/s390x-backchain-toggle.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: enable-backchain disable-backchain //@ assembly-output: emit-asm //@ compile-flags: -Copt-level=3 --crate-type=lib --target=s390x-unknown-linux-gnu @@ -8,8 +9,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; extern "C" { fn extern_func(); diff --git a/tests/assembly/simd-bitmask.rs b/tests/assembly/simd-bitmask.rs index 4a829c4dd98..a632791153b 100644 --- a/tests/assembly/simd-bitmask.rs +++ b/tests/assembly/simd-bitmask.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x86 x86-avx2 x86-avx512 aarch64 //@ [x86] compile-flags: --target=x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel //@ [x86] needs-llvm-components: x86 @@ -16,12 +17,8 @@ #![no_core] #![allow(non_camel_case_types)] -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(simd)] pub struct m8x16([i8; 16]); diff --git a/tests/assembly/simd-intrinsic-gather.rs b/tests/assembly/simd-intrinsic-gather.rs index 3152de35f29..8c17a58046d 100644 --- a/tests/assembly/simd-intrinsic-gather.rs +++ b/tests/assembly/simd-intrinsic-gather.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x86-avx512 //@ [x86-avx512] compile-flags: --target=x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel //@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq @@ -9,12 +10,8 @@ #![no_core] #![allow(non_camel_case_types)] -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(simd)] pub struct f64x4([f64; 4]); diff --git a/tests/assembly/simd-intrinsic-mask-load.rs b/tests/assembly/simd-intrinsic-mask-load.rs index efe3e3752fa..a0d0514c014 100644 --- a/tests/assembly/simd-intrinsic-mask-load.rs +++ b/tests/assembly/simd-intrinsic-mask-load.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x86-avx2 x86-avx512 //@ [x86-avx2] compile-flags: --target=x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel //@ [x86-avx2] compile-flags: -C target-feature=+avx2 @@ -12,13 +13,8 @@ #![no_core] #![allow(non_camel_case_types)] -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy {} -impl<T: ?Sized> Copy for *const T {} +extern crate minicore; +use minicore::*; #[repr(simd)] pub struct i8x16([i8; 16]); diff --git a/tests/assembly/simd-intrinsic-mask-reduce.rs b/tests/assembly/simd-intrinsic-mask-reduce.rs index 4d4adda6c24..959c4ddefdb 100644 --- a/tests/assembly/simd-intrinsic-mask-reduce.rs +++ b/tests/assembly/simd-intrinsic-mask-reduce.rs @@ -1,4 +1,5 @@ // verify that simd mask reductions do not introduce additional bit shift operations +//@ add-core-stubs //@ revisions: x86 aarch64 //@ [x86] compile-flags: --target=x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel // Set the base cpu explicitly, in case the default has been changed. @@ -13,12 +14,8 @@ #![no_core] #![allow(non_camel_case_types)] -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(simd)] pub struct mask8x16([i8; 16]); diff --git a/tests/assembly/simd-intrinsic-mask-store.rs b/tests/assembly/simd-intrinsic-mask-store.rs index f5d924f24a7..4be9194943c 100644 --- a/tests/assembly/simd-intrinsic-mask-store.rs +++ b/tests/assembly/simd-intrinsic-mask-store.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x86-avx2 x86-avx512 //@ [x86-avx2] compile-flags: --target=x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel //@ [x86-avx2] compile-flags: -C target-feature=+avx2 @@ -12,13 +13,8 @@ #![no_core] #![allow(non_camel_case_types)] -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy {} -impl<T: ?Sized> Copy for *mut T {} +extern crate minicore; +use minicore::*; #[repr(simd)] pub struct i8x16([i8; 16]); diff --git a/tests/assembly/simd-intrinsic-scatter.rs b/tests/assembly/simd-intrinsic-scatter.rs index 5f52ababd19..715de04af4d 100644 --- a/tests/assembly/simd-intrinsic-scatter.rs +++ b/tests/assembly/simd-intrinsic-scatter.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x86-avx512 //@ [x86-avx512] compile-flags: --target=x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel //@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq @@ -9,12 +10,8 @@ #![no_core] #![allow(non_camel_case_types)] -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(simd)] pub struct f64x4([f64; 4]); diff --git a/tests/assembly/simd-intrinsic-select.rs b/tests/assembly/simd-intrinsic-select.rs index 74784a77213..7f1e42662bf 100644 --- a/tests/assembly/simd-intrinsic-select.rs +++ b/tests/assembly/simd-intrinsic-select.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x86-avx2 x86-avx512 aarch64 //@ [x86-avx2] compile-flags: --target=x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel //@ [x86-avx2] compile-flags: -C target-feature=+avx2 @@ -14,12 +15,8 @@ #![no_core] #![allow(non_camel_case_types)] -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(simd)] pub struct i8x16([i8; 16]); diff --git a/tests/assembly/sparc-struct-abi.rs b/tests/assembly/sparc-struct-abi.rs index 3a254f17964..b1594428811 100644 --- a/tests/assembly/sparc-struct-abi.rs +++ b/tests/assembly/sparc-struct-abi.rs @@ -2,6 +2,7 @@ // - float structure members are passes in floating point registers // (#86163) +//@ add-core-stubs //@ assembly-output: emit-asm //@ needs-llvm-components: sparc //@ compile-flags: --target=sparcv9-sun-solaris -Copt-level=3 @@ -9,11 +10,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} -impl Copy for f32 {} +extern crate minicore; +use minicore::*; #[repr(C)] pub struct Franta { diff --git a/tests/assembly/stack-probes.rs b/tests/assembly/stack-probes.rs index e0931157ce1..de245431f47 100644 --- a/tests/assembly/stack-probes.rs +++ b/tests/assembly/stack-probes.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x86_64 i686 aarch64 //@ assembly-output: emit-asm //@[x86_64] compile-flags: --target x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel @@ -11,12 +12,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -impl Copy for u8 {} +extern crate minicore; +use minicore::*; // Check that inline-asm stack probes are generated correctly. // To avoid making this test fragile to slight asm changes, diff --git a/tests/assembly/stack-protector/stack-protector-target-support.rs b/tests/assembly/stack-protector/stack-protector-target-support.rs index 74a609dcdcc..e9ba0f9ba89 100644 --- a/tests/assembly/stack-protector/stack-protector-target-support.rs +++ b/tests/assembly/stack-protector/stack-protector-target-support.rs @@ -1,6 +1,7 @@ // Test that stack smash protection code is emitted for all tier1 and tier2 // targets, with the exception of nvptx64-nvidia-cuda // +//@ add-core-stubs //@ revisions: r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 r16 r17 r18 r19 r20 r21 r22 r23 //@ revisions: r24 r25 r26 r27 r28 r29 r30 r31 r32 r33 r35 r36 r37 r38 r39 r40 r41 r42 r43 r44 //@ revisions: r45 r46 r47 r48 r49 r50 r51 r52 r53 r54 r55 r56 r57 r58 r59 r60 r61 r62 r63 r64 r65 @@ -183,10 +184,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[no_mangle] pub fn foo() { diff --git a/tests/assembly/static-relocation-model.rs b/tests/assembly/static-relocation-model.rs index eafdfd485ba..53fa18852b6 100644 --- a/tests/assembly/static-relocation-model.rs +++ b/tests/assembly/static-relocation-model.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x64 A64 ppc64le //@ assembly-output: emit-asm //@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=static @@ -11,20 +12,8 @@ #![no_core] #![crate_type = "rlib"] -#[lang = "sized"] -trait Sized {} - -#[lang = "copy"] -trait Copy {} - -#[lang = "sync"] -trait Sync {} - -#[lang = "drop_in_place"] -fn drop_in_place<T>(_: *mut T) {} - -impl Copy for u8 {} -impl Sync for u8 {} +extern crate minicore; +use minicore::*; #[no_mangle] pub static PIERIS: u8 = 42; diff --git a/tests/assembly/target-feature-multiple.rs b/tests/assembly/target-feature-multiple.rs index 83c38568647..bc432d21931 100644 --- a/tests/assembly/target-feature-multiple.rs +++ b/tests/assembly/target-feature-multiple.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ assembly-output: emit-asm //@ needs-llvm-components: x86 //@ revisions: TWOFLAGS SINGLEFLAG @@ -19,11 +20,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -impl Copy for u32 {} +extern crate minicore; +use minicore::*; // Use of these requires target features to be enabled extern "unadjusted" { diff --git a/tests/assembly/targets/targets-amdgpu.rs b/tests/assembly/targets/targets-amdgpu.rs index 501eed2e247..1d10b8fc315 100644 --- a/tests/assembly/targets/targets-amdgpu.rs +++ b/tests/assembly/targets/targets-amdgpu.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ assembly-output: emit-asm // ignore-tidy-linelength //@ revisions: amdgcn_amd_amdhsa @@ -11,8 +12,8 @@ #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; pub fn test() -> u8 { 42 diff --git a/tests/assembly/targets/targets-elf.rs b/tests/assembly/targets/targets-elf.rs index 3e73d2c6eb7..dc564c60f80 100644 --- a/tests/assembly/targets/targets-elf.rs +++ b/tests/assembly/targets/targets-elf.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ assembly-output: emit-asm // ignore-tidy-linelength //@ revisions: aarch64_be_unknown_linux_gnu @@ -709,8 +710,8 @@ #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; // Force linkage to ensure code is actually generated #[no_mangle] diff --git a/tests/assembly/targets/targets-macho.rs b/tests/assembly/targets/targets-macho.rs index 25e9059afeb..92bde1c6971 100644 --- a/tests/assembly/targets/targets-macho.rs +++ b/tests/assembly/targets/targets-macho.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ assembly-output: emit-asm // ignore-tidy-linelength //@ revisions: aarch64_apple_darwin @@ -80,8 +81,8 @@ #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; // Force linkage to ensure code is actually generated #[no_mangle] diff --git a/tests/assembly/targets/targets-nvptx.rs b/tests/assembly/targets/targets-nvptx.rs index 9048191affa..49c12aebaaa 100644 --- a/tests/assembly/targets/targets-nvptx.rs +++ b/tests/assembly/targets/targets-nvptx.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ assembly-output: emit-asm // ignore-tidy-linelength //@ revisions: nvptx64_nvidia_cuda @@ -11,8 +12,8 @@ #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; pub fn test() -> u8 { 42 diff --git a/tests/assembly/targets/targets-pe.rs b/tests/assembly/targets/targets-pe.rs index b74d0181c4d..f895b79ba50 100644 --- a/tests/assembly/targets/targets-pe.rs +++ b/tests/assembly/targets/targets-pe.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ assembly-output: emit-asm // ignore-tidy-linelength //@ revisions: aarch64_pc_windows_msvc @@ -95,8 +96,8 @@ #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; pub fn test() -> u8 { 42 diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index 0aa8b6b8f89..03aa8476508 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -25,7 +25,8 @@ naked_functions, f16, f128, - asm_experimental_arch + asm_experimental_arch, + unboxed_closures )] #![allow(unused, improper_ctypes_definitions, internal_features)] #![no_std] @@ -61,7 +62,7 @@ pub auto trait Unpin {} impl_marker_trait!( Copy => [ - bool, char, + char, bool, isize, i8, i16, i32, i64, i128, usize, u8, u16, u32, u64, u128, f16, f32, f64, f128, @@ -102,6 +103,9 @@ pub struct UnsafeCell<T: ?Sized> { } impl<T: ?Sized> !Freeze for UnsafeCell<T> {} +#[lang = "tuple_trait"] +pub trait Tuple {} + #[rustc_builtin_macro] pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) { /* compiler built-in */ @@ -129,3 +133,61 @@ macro_rules! stringify { /* compiler built-in */ }; } + +#[lang = "add"] +pub trait Add<Rhs = Self> { + type Output; + + fn add(self, _: Rhs) -> Self::Output; +} + +impl Add<isize> for isize { + type Output = isize; + + fn add(self, other: isize) -> isize { + 7 // avoid needing to add all of the overflow handling and panic language items + } +} + +#[lang = "sync"] +trait Sync {} +impl Sync for u8 {} + +#[lang = "drop_in_place"] +fn drop_in_place<T>(_: *mut T) {} + +#[lang = "fn_once"] +pub trait FnOnce<Args: Tuple> { + #[lang = "fn_once_output"] + type Output; + + extern "rust-call" fn call_once(self, args: Args) -> Self::Output; +} + +#[lang = "fn_mut"] +pub trait FnMut<Args: Tuple>: FnOnce<Args> { + extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; +} + +#[lang = "fn"] +pub trait Fn<Args: Tuple>: FnMut<Args> { + extern "rust-call" fn call(&self, args: Args) -> Self::Output; +} + +#[lang = "dispatch_from_dyn"] +trait DispatchFromDyn<T> {} + +impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {} + +#[lang = "unsize"] +trait Unsize<T: ?Sized> {} + +#[lang = "coerce_unsized"] +pub trait CoerceUnsized<T: ?Sized> {} + +impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} + +#[lang = "drop"] +trait Drop { + fn drop(&mut self); +} diff --git a/tests/codegen/aarch64-softfloat.rs b/tests/codegen/aarch64-softfloat.rs index 85380a6c472..4f5366e047f 100644 --- a/tests/codegen/aarch64-softfloat.rs +++ b/tests/codegen/aarch64-softfloat.rs @@ -1,15 +1,12 @@ +//@ add-core-stubs //@ compile-flags: --target aarch64-unknown-none-softfloat -Zmerge-functions=disabled //@ needs-llvm-components: aarch64 #![crate_type = "lib"] #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -impl Copy for f32 {} -impl Copy for f64 {} +extern crate minicore; +use minicore::*; // CHECK: i64 @pass_f64_C(i64 {{[^,]*}}) #[no_mangle] diff --git a/tests/codegen/aarch64-struct-align-128.rs b/tests/codegen/aarch64-struct-align-128.rs index 3fed19d96b1..ba1d19680f4 100644 --- a/tests/codegen/aarch64-struct-align-128.rs +++ b/tests/codegen/aarch64-struct-align-128.rs @@ -1,5 +1,6 @@ // Test that structs aligned to 128 bits are passed with the correct ABI on aarch64. +//@ add-core-stubs //@ revisions: linux darwin win //@[linux] compile-flags: --target aarch64-unknown-linux-gnu //@[darwin] compile-flags: --target aarch64-apple-darwin @@ -12,12 +13,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // Passed as `[i64 x 2]`, since it's an aggregate with size <= 128 bits, align < 128 bits. #[repr(C)] diff --git a/tests/codegen/abi-efiapi.rs b/tests/codegen/abi-efiapi.rs index 986d042268a..1736f0daf0f 100644 --- a/tests/codegen/abi-efiapi.rs +++ b/tests/codegen/abi-efiapi.rs @@ -1,5 +1,6 @@ // Checks if the correct annotation for the efiapi ABI is passed to llvm. +//@ add-core-stubs //@ revisions:x86_64 i686 aarch64 arm riscv //@[x86_64] compile-flags: --target x86_64-unknown-uefi //@[x86_64] needs-llvm-components: aarch64 arm riscv @@ -17,12 +18,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; //x86_64: define win64cc void @has_efiapi //i686: define void @has_efiapi diff --git a/tests/codegen/abi-repr-ext.rs b/tests/codegen/abi-repr-ext.rs index b06d225ed70..1da28a94d9d 100644 --- a/tests/codegen/abi-repr-ext.rs +++ b/tests/codegen/abi-repr-ext.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: -Copt-level=3 //@ revisions:x86_64 i686 aarch64-apple aarch64-windows aarch64-linux arm riscv @@ -24,12 +25,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(i8)] pub enum Type { diff --git a/tests/codegen/abi-sysv64.rs b/tests/codegen/abi-sysv64.rs index ec555ee5f1d..7ade17f2bae 100644 --- a/tests/codegen/abi-sysv64.rs +++ b/tests/codegen/abi-sysv64.rs @@ -2,6 +2,7 @@ // llvm. Also checks that the abi-sysv64 feature gate allows usage // of the sysv64 abi. // +//@ add-core-stubs //@ needs-llvm-components: x86 //@ compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu -Copt-level=0 @@ -9,11 +10,8 @@ #![no_core] #![feature(abi_x86_interrupt, no_core, lang_items)] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -impl Copy for i64 {} +extern crate minicore; +use minicore::*; // CHECK: define x86_64_sysvcc i64 @has_sysv64_abi #[no_mangle] diff --git a/tests/codegen/abi-win64-zst.rs b/tests/codegen/abi-win64-zst.rs index 825a5c1b09c..e46f9666d42 100644 --- a/tests/codegen/abi-win64-zst.rs +++ b/tests/codegen/abi-win64-zst.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: -Z merge-functions=disabled //@ add-core-stubs diff --git a/tests/codegen/abi-x86-interrupt.rs b/tests/codegen/abi-x86-interrupt.rs index b8f3ebb99dd..255ccba2c11 100644 --- a/tests/codegen/abi-x86-interrupt.rs +++ b/tests/codegen/abi-x86-interrupt.rs @@ -2,6 +2,7 @@ // llvm. Also checks that the abi_x86_interrupt feature gate allows usage // of the x86-interrupt abi. +//@ add-core-stubs //@ needs-llvm-components: x86 //@ compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu -Copt-level=0 @@ -9,11 +10,8 @@ #![no_core] #![feature(abi_x86_interrupt, no_core, lang_items)] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -impl Copy for i64 {} +extern crate minicore; +use minicore::*; // CHECK: define x86_intrcc i64 @has_x86_interrupt_abi #[no_mangle] diff --git a/tests/codegen/avr/avr-func-addrspace.rs b/tests/codegen/avr/avr-func-addrspace.rs index 2ec7c86b5f4..2ae2f40d7b3 100644 --- a/tests/codegen/avr/avr-func-addrspace.rs +++ b/tests/codegen/avr/avr-func-addrspace.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: -Copt-level=3 --target=avr-none -C target-cpu=atmega328p --crate-type=rlib -C panic=abort //@ needs-llvm-components: avr @@ -13,45 +14,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} -impl<T: ?Sized> Copy for *const T {} -#[lang = "legacy_receiver"] -pub trait LegacyReceiver {} -#[lang = "tuple_trait"] -pub trait Tuple {} - -pub struct Result<T, E> { - _a: T, - _b: E, -} - -impl Copy for usize {} -impl Copy for &usize {} - -#[lang = "drop_in_place"] -pub unsafe fn drop_in_place<T: ?Sized>(_: *mut T) {} - -#[lang = "fn_once"] -pub trait FnOnce<Args: Tuple> { - #[lang = "fn_once_output"] - type Output; - - extern "rust-call" fn call_once(self, args: Args) -> Self::Output; -} - -#[lang = "fn_mut"] -pub trait FnMut<Args: Tuple>: FnOnce<Args> { - extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; -} - -#[lang = "fn"] -pub trait Fn<Args: Tuple>: FnOnce<Args> { - /// Performs the call operation. - extern "rust-call" fn call(&self, args: Args) -> Self::Output; -} +extern crate minicore; +use minicore::*; extern "rust-intrinsic" { pub fn transmute<Src, Dst>(src: Src) -> Dst; diff --git a/tests/codegen/branch-protection-old-llvm.rs b/tests/codegen/branch-protection-old-llvm.rs index 1846f35479d..14b34ac5018 100644 --- a/tests/codegen/branch-protection-old-llvm.rs +++ b/tests/codegen/branch-protection-old-llvm.rs @@ -1,5 +1,6 @@ // Test that the correct module flags are emitted with different branch protection flags. +//@ add-core-stubs //@ revisions: BTI PACRET LEAF BKEY NONE //@ needs-llvm-components: aarch64 //@ [BTI] compile-flags: -Z branch-protection=bti @@ -13,8 +14,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; // A basic test function. pub fn test() {} diff --git a/tests/codegen/branch-protection.rs b/tests/codegen/branch-protection.rs index 945bad05625..ae14eae9ae0 100644 --- a/tests/codegen/branch-protection.rs +++ b/tests/codegen/branch-protection.rs @@ -1,5 +1,6 @@ // Test that the correct module flags are emitted with different branch protection flags. +//@ add-core-stubs //@ revisions: BTI PACRET LEAF BKEY PAUTHLR PAUTHLR_BKEY PAUTHLR_LEAF PAUTHLR_BTI NONE //@ needs-llvm-components: aarch64 //@ [BTI] compile-flags: -Z branch-protection=bti @@ -17,8 +18,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; // A basic test function. // CHECK: @test(){{.*}} [[ATTR:#[0-9]+]] { diff --git a/tests/codegen/cast-target-abi.rs b/tests/codegen/cast-target-abi.rs index a0801eb9826..186198bc631 100644 --- a/tests/codegen/cast-target-abi.rs +++ b/tests/codegen/cast-target-abi.rs @@ -1,4 +1,5 @@ // ignore-tidy-linelength +//@ add-core-stubs //@ revisions:aarch64 loongarch64 powerpc64 sparc64 x86_64 //@ min-llvm-version: 19 //@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes -Zlint-llvm-ir -Cllvm-args=-lint-abort-on-error @@ -21,12 +22,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // This struct will be passed as a single `i64` or `i32`. // This may be (if `i64)) larger than the Rust layout, which is just `{ i16, i16 }`. diff --git a/tests/codegen/cf-protection.rs b/tests/codegen/cf-protection.rs index 244d1eb2544..f1349a5dcb9 100644 --- a/tests/codegen/cf-protection.rs +++ b/tests/codegen/cf-protection.rs @@ -1,5 +1,6 @@ // Test that the correct module flags are emitted with different control-flow protection flags. +//@ add-core-stubs //@ revisions: undefined none branch return full //@ needs-llvm-components: x86 //@ [undefined] compile-flags: @@ -13,8 +14,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; // A basic test function. pub fn test() {} diff --git a/tests/codegen/cffi/ffi-out-of-bounds-loads.rs b/tests/codegen/cffi/ffi-out-of-bounds-loads.rs index ae8d8383f5b..404f6237849 100644 --- a/tests/codegen/cffi/ffi-out-of-bounds-loads.rs +++ b/tests/codegen/cffi/ffi-out-of-bounds-loads.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: linux apple //@ min-llvm-version: 19 //@ compile-flags: -Copt-level=0 -Cno-prepopulate-passes -Zlint-llvm-ir -Cllvm-args=-lint-abort-on-error @@ -14,12 +15,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(C)] struct S { diff --git a/tests/codegen/comparison-operators-2-struct.rs b/tests/codegen/comparison-operators-2-struct.rs new file mode 100644 index 00000000000..e179066ebfd --- /dev/null +++ b/tests/codegen/comparison-operators-2-struct.rs @@ -0,0 +1,61 @@ +//@ compile-flags: -C opt-level=1 +//@ min-llvm-version: 20 + +// The `derive(PartialOrd)` for a 2-field type doesn't override `lt`/`le`/`gt`/`ge`. +// This double-checks that the `Option<Ordering>` intermediate values used +// in the operators for such a type all optimize away. + +#![crate_type = "lib"] + +use std::cmp::Ordering; + +#[derive(PartialOrd, PartialEq)] +pub struct Foo(i32, u32); + +// CHECK-LABEL: @check_lt( +// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:.+]]) +#[no_mangle] +pub fn check_lt(a: Foo, b: Foo) -> bool { + // CHECK-DAG: %[[EQ:.+]] = icmp eq i32 %[[A0]], %[[B0]] + // CHECK-DAG: %[[R0:.+]] = icmp slt i32 %[[A0]], %[[B0]] + // CHECK-DAG: %[[R1:.+]] = icmp ult i32 %[[A1]], %[[B1]] + // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[R1]], i1 %[[R0]] + // CHECK-NEXT: ret i1 %[[R]] + a < b +} + +// CHECK-LABEL: @check_le( +// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:.+]]) +#[no_mangle] +pub fn check_le(a: Foo, b: Foo) -> bool { + // CHECK-DAG: %[[EQ:.+]] = icmp eq i32 %[[A0]], %[[B0]] + // CHECK-DAG: %[[R0:.+]] = icmp sle i32 %[[A0]], %[[B0]] + // CHECK-DAG: %[[R1:.+]] = icmp ule i32 %[[A1]], %[[B1]] + // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[R1]], i1 %[[R0]] + // CHECK-NEXT: ret i1 %[[R]] + a <= b +} + +// CHECK-LABEL: @check_gt( +// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:.+]]) +#[no_mangle] +pub fn check_gt(a: Foo, b: Foo) -> bool { + // CHECK-DAG: %[[EQ:.+]] = icmp eq i32 %[[A0]], %[[B0]] + // CHECK-DAG: %[[R0:.+]] = icmp sgt i32 %[[A0]], %[[B0]] + // CHECK-DAG: %[[R1:.+]] = icmp ugt i32 %[[A1]], %[[B1]] + // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[R1]], i1 %[[R0]] + // CHECK-NEXT: ret i1 %[[R]] + a > b +} + +// CHECK-LABEL: @check_ge( +// CHECK-SAME: i32{{.+}}%[[A0:.+]], i32{{.+}}%[[A1:.+]], i32{{.+}}%[[B0:.+]], i32{{.+}}%[[B1:.+]]) +#[no_mangle] +pub fn check_ge(a: Foo, b: Foo) -> bool { + // CHECK-DAG: %[[EQ:.+]] = icmp eq i32 %[[A0]], %[[B0]] + // CHECK-DAG: %[[R0:.+]] = icmp sge i32 %[[A0]], %[[B0]] + // CHECK-DAG: %[[R1:.+]] = icmp uge i32 %[[A1]], %[[B1]] + // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[R1]], i1 %[[R0]] + // CHECK-NEXT: ret i1 %[[R]] + a >= b +} diff --git a/tests/codegen/comparison-operators-2-tuple.rs b/tests/codegen/comparison-operators-2-tuple.rs index 8e2915e84eb..91a99f9b91f 100644 --- a/tests/codegen/comparison-operators-2-tuple.rs +++ b/tests/codegen/comparison-operators-2-tuple.rs @@ -1,5 +1,6 @@ //@ compile-flags: -C opt-level=1 -Z merge-functions=disabled //@ only-x86_64 +//@ min-llvm-version: 20 #![crate_type = "lib"] @@ -65,12 +66,7 @@ pub fn check_ge_direct(a: TwoTuple, b: TwoTuple) -> bool { } // -// These ones are harder, since there are more intermediate values to remove. -// -// `<` seems to be getting lucky right now, so test that doesn't regress. -// -// The others, however, aren't managing to optimize away the extra `select`s yet. -// See <https://github.com/rust-lang/rust/issues/106107> for more about this. +// These used to not optimize as well, but thanks to LLVM 20 they work now 🎉 // // CHECK-LABEL: @check_lt_via_cmp @@ -89,11 +85,11 @@ pub fn check_lt_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) #[no_mangle] pub fn check_le_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { - // FIXME-CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // FIXME-CHECK-DAG: %[[CMP0:.+]] = icmp sle i16 %[[A0]], %[[B0]] - // FIXME-CHECK-DAG: %[[CMP1:.+]] = icmp ule i16 %[[A1]], %[[B1]] - // FIXME-CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] - // FIXME-CHECK: ret i1 %[[R]] + // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp sle i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP1:.+]] = icmp ule i16 %[[A1]], %[[B1]] + // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] + // CHECK: ret i1 %[[R]] Ord::cmp(&a, &b).is_le() } @@ -101,11 +97,11 @@ pub fn check_le_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) #[no_mangle] pub fn check_gt_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { - // FIXME-CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // FIXME-CHECK-DAG: %[[CMP0:.+]] = icmp sgt i16 %[[A0]], %[[B0]] - // FIXME-CHECK-DAG: %[[CMP1:.+]] = icmp ugt i16 %[[A1]], %[[B1]] - // FIXME-CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] - // FIXME-CHECK: ret i1 %[[R]] + // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp sgt i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP1:.+]] = icmp ugt i16 %[[A1]], %[[B1]] + // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] + // CHECK: ret i1 %[[R]] Ord::cmp(&a, &b).is_gt() } @@ -113,10 +109,10 @@ pub fn check_gt_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-SAME: (i16 noundef %[[A0:.+]], i16 noundef %[[A1:.+]], i16 noundef %[[B0:.+]], i16 noundef %[[B1:.+]]) #[no_mangle] pub fn check_ge_via_cmp(a: TwoTuple, b: TwoTuple) -> bool { - // FIXME-CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // FIXME-CHECK-DAG: %[[CMP0:.+]] = icmp sge i16 %[[A0]], %[[B0]] - // FIXME-CHECK-DAG: %[[CMP1:.+]] = icmp uge i16 %[[A1]], %[[B1]] - // FIXME-CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] - // FIXME-CHECK: ret i1 %[[R]] + // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp sge i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP1:.+]] = icmp uge i16 %[[A1]], %[[B1]] + // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] + // CHECK: ret i1 %[[R]] Ord::cmp(&a, &b).is_ge() } diff --git a/tests/codegen/default-requires-uwtable.rs b/tests/codegen/default-requires-uwtable.rs index 3cb35cea022..54a6e171db6 100644 --- a/tests/codegen/default-requires-uwtable.rs +++ b/tests/codegen/default-requires-uwtable.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: WINDOWS_ ANDROID_ //@ compile-flags: -C panic=abort -Copt-level=0 //@ [WINDOWS_] compile-flags: --target=x86_64-pc-windows-msvc @@ -9,8 +10,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; // CHECK: attributes #{{.*}} uwtable pub fn foo() {} diff --git a/tests/codegen/fastcall-inreg.rs b/tests/codegen/fastcall-inreg.rs index 00b390bf1bf..066943d6e7e 100644 --- a/tests/codegen/fastcall-inreg.rs +++ b/tests/codegen/fastcall-inreg.rs @@ -2,6 +2,7 @@ // as "inreg" like the C/C++ compilers for the platforms. // x86 only. +//@ add-core-stubs //@ compile-flags: --target i686-unknown-linux-gnu -Cno-prepopulate-passes -Copt-level=3 //@ needs-llvm-components: x86 @@ -9,10 +10,8 @@ #![no_core] #![feature(no_core, lang_items)] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; pub mod tests { // CHECK: @f1(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 noundef %_3) diff --git a/tests/codegen/fixed-x18.rs b/tests/codegen/fixed-x18.rs index 4997a39a726..a5767cfa456 100644 --- a/tests/codegen/fixed-x18.rs +++ b/tests/codegen/fixed-x18.rs @@ -1,6 +1,7 @@ // Test that the `reserve-x18` target feature is (not) emitted when // the `-Zfixed-x18` flag is (not) set. +//@ add-core-stubs //@ revisions: unset set //@ needs-llvm-components: aarch64 //@ compile-flags: --target aarch64-unknown-none @@ -10,8 +11,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; #[no_mangle] pub fn foo() { diff --git a/tests/codegen/frame-pointer.rs b/tests/codegen/frame-pointer.rs index da81c2e9cd9..1f7c9a59c98 100644 --- a/tests/codegen/frame-pointer.rs +++ b/tests/codegen/frame-pointer.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: --crate-type=rlib -Copt-level=0 //@ revisions: aarch64-apple aarch64-linux force x64-apple x64-linux //@ [aarch64-apple] needs-llvm-components: aarch64 @@ -13,11 +14,9 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -impl Copy for u32 {} + +extern crate minicore; +use minicore::*; // CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] { #[no_mangle] diff --git a/tests/codegen/function-return.rs b/tests/codegen/function-return.rs index 2b9de4e1478..4127f516038 100644 --- a/tests/codegen/function-return.rs +++ b/tests/codegen/function-return.rs @@ -1,6 +1,7 @@ // Test that the `fn_ret_thunk_extern` function attribute is (not) emitted when // the `-Zfunction-return={keep,thunk-extern}` flag is (not) set. +//@ add-core-stubs //@ revisions: unset keep thunk-extern keep-thunk-extern thunk-extern-keep //@ needs-llvm-components: x86 //@ compile-flags: --target x86_64-unknown-linux-gnu @@ -13,8 +14,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; #[no_mangle] pub fn foo() { diff --git a/tests/codegen/gpu-kernel-abi.rs b/tests/codegen/gpu-kernel-abi.rs index fba17936494..8ac376d9338 100644 --- a/tests/codegen/gpu-kernel-abi.rs +++ b/tests/codegen/gpu-kernel-abi.rs @@ -1,17 +1,14 @@ // Checks that the gpu-kernel calling convention correctly translates to LLVM calling conventions. +//@ add-core-stubs //@ revisions: nvptx //@ [nvptx] compile-flags: --crate-type=rlib --target=nvptx64-nvidia-cuda //@ [nvptx] needs-llvm-components: nvptx #![feature(no_core, lang_items, abi_gpu_kernel)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // nvptx: define ptx_kernel void @fun(i32 #[no_mangle] diff --git a/tests/codegen/intrinsics/nontemporal.rs b/tests/codegen/intrinsics/nontemporal.rs index af8892d30e7..1d4fae83c29 100644 --- a/tests/codegen/intrinsics/nontemporal.rs +++ b/tests/codegen/intrinsics/nontemporal.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: -Copt-level=3 //@revisions: with_nontemporal without_nontemporal //@[with_nontemporal] compile-flags: --target aarch64-unknown-linux-gnu @@ -14,13 +15,8 @@ #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} - -impl Copy for u32 {} -impl<T> Copy for *mut T {} +extern crate minicore; +use minicore::*; extern "rust-intrinsic" { pub fn nontemporal_store<T>(ptr: *mut T, val: T); diff --git a/tests/codegen/issues/issue-114312.rs b/tests/codegen/issues/issue-114312.rs index e9418249089..61355dd5873 100644 --- a/tests/codegen/issues/issue-114312.rs +++ b/tests/codegen/issues/issue-114312.rs @@ -15,7 +15,6 @@ pub enum Expr { #[no_mangle] pub extern "C" fn issue_114312(expr: Expr) { // CHECK-LABEL: @issue_114312( - // CHECK-NOT: readonly // CHECK-SAME: byval // CHECK-NEXT: start: // CHECK-NEXT: ret void diff --git a/tests/codegen/issues/issue-84268.rs b/tests/codegen/issues/issue-84268.rs index 8a8ea9d1ccf..1dc55a909ad 100644 --- a/tests/codegen/issues/issue-84268.rs +++ b/tests/codegen/issues/issue-84268.rs @@ -1,10 +1,7 @@ //@ compile-flags: -Copt-level=3 --crate-type=rlib -#![feature(intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -extern "rust-intrinsic" { - fn simd_fabs<T>(x: T) -> T; - fn simd_eq<T, U>(x: T, y: T) -> U; -} +use std::intrinsics::simd::{simd_eq, simd_fabs}; #[repr(simd)] pub struct V([f32; 4]); diff --git a/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs b/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs index b11bd657c18..93c8d60930b 100644 --- a/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs +++ b/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target loongarch64-unknown-linux-gnu //@ needs-llvm-components: loongarch @@ -6,12 +7,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // CHECK: define void @f_fpr_tracking(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, i8 noundef zeroext %i) #[no_mangle] diff --git a/tests/codegen/macos/i686-macosx-deployment-target.rs b/tests/codegen/macos/i686-macosx-deployment-target.rs index 1f44bdfc648..cfa91e61cb0 100644 --- a/tests/codegen/macos/i686-macosx-deployment-target.rs +++ b/tests/codegen/macos/i686-macosx-deployment-target.rs @@ -1,19 +1,15 @@ -// // Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. // See issue #60235. +//@ add-core-stubs //@ compile-flags: -Copt-level=3 --target=i686-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ rustc-env:MACOSX_DEPLOYMENT_TARGET=10.14 #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(C)] pub struct Bool { diff --git a/tests/codegen/macos/i686-no-macosx-deployment-target.rs b/tests/codegen/macos/i686-no-macosx-deployment-target.rs index a09773e0b9e..25ec5f6acbb 100644 --- a/tests/codegen/macos/i686-no-macosx-deployment-target.rs +++ b/tests/codegen/macos/i686-no-macosx-deployment-target.rs @@ -1,19 +1,15 @@ -// // Checks that we leave the target alone MACOSX_DEPLOYMENT_TARGET is unset. // See issue #60235. +//@ add-core-stubs //@ compile-flags: -Copt-level=3 --target=i686-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ unset-rustc-env:MACOSX_DEPLOYMENT_TARGET #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(C)] pub struct Bool { diff --git a/tests/codegen/macos/x86_64-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-macosx-deployment-target.rs index bd8c027a9fb..8ea95ba0575 100644 --- a/tests/codegen/macos/x86_64-macosx-deployment-target.rs +++ b/tests/codegen/macos/x86_64-macosx-deployment-target.rs @@ -1,19 +1,15 @@ -// // Checks that we correctly modify the target when MACOSX_DEPLOYMENT_TARGET is set. // See issue #60235. +//@ add-core-stubs //@ compile-flags: -Copt-level=3 --target=x86_64-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ rustc-env:MACOSX_DEPLOYMENT_TARGET=10.14 #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(C)] pub struct Bool { diff --git a/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs index ff4a8fc46f9..474094957ae 100644 --- a/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs +++ b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs @@ -1,19 +1,15 @@ -// // Checks that we leave the target alone when MACOSX_DEPLOYMENT_TARGET is unset. // See issue #60235. +//@ add-core-stubs //@ compile-flags: -Copt-level=3 --target=x86_64-apple-darwin --crate-type=rlib //@ needs-llvm-components: x86 //@ unset-rustc-env:MACOSX_DEPLOYMENT_TARGET #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(C)] pub struct Bool { diff --git a/tests/codegen/naked-fn/instruction-set.rs b/tests/codegen/naked-fn/instruction-set.rs index 5b790b2034c..a7b4c22a59b 100644 --- a/tests/codegen/naked-fn/instruction-set.rs +++ b/tests/codegen/naked-fn/instruction-set.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: arm-mode thumb-mode //@ [arm-mode] compile-flags: --target armv5te-none-eabi //@ [thumb-mode] compile-flags: --target thumbv5te-none-eabi @@ -8,15 +9,8 @@ #![feature(no_core, lang_items, rustc_attrs, naked_functions)] #![no_core] -#[rustc_builtin_macro] -macro_rules! naked_asm { - () => {}; -} - -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // arm-mode: .arm // thumb-mode: .thumb diff --git a/tests/codegen/naked-fn/naked-functions.rs b/tests/codegen/naked-fn/naked-functions.rs index f505d27d48c..6483e27c97a 100644 --- a/tests/codegen/naked-fn/naked-functions.rs +++ b/tests/codegen/naked-fn/naked-functions.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: linux win macos thumb // //@[linux] compile-flags: --target x86_64-unknown-linux-gnu @@ -13,15 +14,8 @@ #![feature(no_core, lang_items, rustc_attrs, naked_functions)] #![no_core] -#[rustc_builtin_macro] -macro_rules! naked_asm { - () => {}; -} - -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // linux,win: .intel_syntax // diff --git a/tests/codegen/no-jump-tables.rs b/tests/codegen/no-jump-tables.rs index 654da2cec11..e49de7e9dc1 100644 --- a/tests/codegen/no-jump-tables.rs +++ b/tests/codegen/no-jump-tables.rs @@ -1,6 +1,7 @@ // Test that the `no-jump-tables` function attribute are (not) emitted when // the `-Zno-jump-tables` flag is (not) set. +//@ add-core-stubs //@ revisions: unset set //@ needs-llvm-components: x86 //@ compile-flags: --target x86_64-unknown-linux-gnu @@ -10,8 +11,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; #[no_mangle] pub fn foo() { diff --git a/tests/codegen/overaligned-constant.rs b/tests/codegen/overaligned-constant.rs index e5540aca387..0f5977880f2 100644 --- a/tests/codegen/overaligned-constant.rs +++ b/tests/codegen/overaligned-constant.rs @@ -9,14 +9,14 @@ struct S(i32); struct SmallStruct(f32, Option<S>, &'static [f32]); -// CHECK: @0 = private unnamed_addr constant +// CHECK: [[const:@.*]] = private unnamed_addr constant // CHECK-SAME: , align 8 #[no_mangle] pub fn overaligned_constant() { // CHECK-LABEL: @overaligned_constant // CHECK: [[full:%_.*]] = alloca [32 x i8], align 8 - // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[full]], ptr align 8 @0, i64 32, i1 false) + // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[full]], ptr align 8 [[const]], i64 32, i1 false) let mut s = S(1); s.0 = 3; diff --git a/tests/codegen/powerpc64le-struct-align-128.rs b/tests/codegen/powerpc64le-struct-align-128.rs index 3981cd12129..c1c1ac26485 100644 --- a/tests/codegen/powerpc64le-struct-align-128.rs +++ b/tests/codegen/powerpc64le-struct-align-128.rs @@ -1,6 +1,7 @@ // Test that structs aligned to 128 bits are passed with the correct ABI on powerpc64le. // This is similar to aarch64-struct-align-128.rs, but for ppc. +//@ add-core-stubs //@ compile-flags: --target powerpc64le-unknown-linux-gnu //@ needs-llvm-components: powerpc @@ -8,12 +9,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(C)] pub struct Align8 { diff --git a/tests/codegen/regparm-inreg.rs b/tests/codegen/regparm-inreg.rs index 82e15731128..8dae3a83e4e 100644 --- a/tests/codegen/regparm-inreg.rs +++ b/tests/codegen/regparm-inreg.rs @@ -2,6 +2,7 @@ // marks function arguments as "inreg" like the C/C++ compilers for the platforms. // x86 only. +//@ add-core-stubs //@ compile-flags: --target i686-unknown-linux-gnu -Cno-prepopulate-passes -Copt-level=3 //@ needs-llvm-components: x86 @@ -14,10 +15,9 @@ #![crate_type = "lib"] #![no_core] #![feature(no_core, lang_items, repr_simd)] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} + +extern crate minicore; +use minicore::*; pub mod tests { // regparm doesn't work for "fastcall" calling conv (only 2 inregs) diff --git a/tests/codegen/repr/transparent-byval-struct-ptr.rs b/tests/codegen/repr/transparent-byval-struct-ptr.rs index f9cfeb90390..0918884144f 100644 --- a/tests/codegen/repr/transparent-byval-struct-ptr.rs +++ b/tests/codegen/repr/transparent-byval-struct-ptr.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: i686-linux i686-freebsd x64-linux x64-apple //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes @@ -21,14 +22,9 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; -impl Copy for [u32; 16] {} impl Copy for BigS {} impl Copy for BigU {} diff --git a/tests/codegen/repr/transparent-imm-array.rs b/tests/codegen/repr/transparent-imm-array.rs index f790d093cf4..6dad0447784 100644 --- a/tests/codegen/repr/transparent-imm-array.rs +++ b/tests/codegen/repr/transparent-imm-array.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: arm-linux arm-android armv7-linux armv7-android mips thumb sparc //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes @@ -27,14 +28,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} - -impl Copy for [u32; 16] {} +extern crate minicore; +use minicore::*; impl Copy for BigS {} impl Copy for BigU {} diff --git a/tests/codegen/repr/transparent-mips64.rs b/tests/codegen/repr/transparent-mips64.rs index 7282654b856..98901350154 100644 --- a/tests/codegen/repr/transparent-mips64.rs +++ b/tests/codegen/repr/transparent-mips64.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: mips64 mips64el //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes @@ -13,14 +14,9 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; -impl Copy for [u32; 16] {} impl Copy for BigS {} impl Copy for BigU {} diff --git a/tests/codegen/repr/transparent-opaque-ptr.rs b/tests/codegen/repr/transparent-opaque-ptr.rs index 798b7e01bba..7911370c478 100644 --- a/tests/codegen/repr/transparent-opaque-ptr.rs +++ b/tests/codegen/repr/transparent-opaque-ptr.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: aarch64-linux aarch64-darwin wasm32-wasip1 //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes @@ -19,14 +20,9 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; -impl Copy for [u32; 16] {} impl Copy for BigS {} impl Copy for BigU {} diff --git a/tests/codegen/repr/transparent-sparc64.rs b/tests/codegen/repr/transparent-sparc64.rs index 05c090bd672..62bfc8a5fce 100644 --- a/tests/codegen/repr/transparent-sparc64.rs +++ b/tests/codegen/repr/transparent-sparc64.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target sparc64-unknown-linux-gnu //@ needs-llvm-components: sparc @@ -8,14 +9,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} - -impl Copy for [u32; 16] {} +extern crate minicore; +use minicore::*; impl Copy for BigS {} impl Copy for BigU {} diff --git a/tests/codegen/repr/transparent-sysv64.rs b/tests/codegen/repr/transparent-sysv64.rs index 99c855db962..3efc3f7c391 100644 --- a/tests/codegen/repr/transparent-sysv64.rs +++ b/tests/codegen/repr/transparent-sysv64.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: linux apple win //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes @@ -13,12 +14,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(C)] pub struct Rgb8 { diff --git a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs index 46f747ad407..df99f6969fc 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: --target riscv64gc-unknown-linux-gnu -Copt-level=3 -C no-prepopulate-passes -C panic=abort //@ needs-llvm-components: riscv @@ -6,19 +7,8 @@ #![feature(no_core, lang_items)] #![allow(improper_ctypes)] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -impl Copy for bool {} -impl Copy for i8 {} -impl Copy for u8 {} -impl Copy for i32 {} -impl Copy for i64 {} -impl Copy for u64 {} -impl Copy for f32 {} -impl Copy for f64 {} -impl<T> Copy for *mut T {} +extern crate minicore; +use minicore::*; // CHECK: define void @f_void() #[no_mangle] diff --git a/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs index bef8fe0c044..d768ab9381a 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64d-abi.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target riscv64gc-unknown-linux-gnu //@ needs-llvm-components: riscv @@ -6,12 +7,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // CHECK: define void @f_fpr_tracking(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, i8 noundef zeroext %i) #[no_mangle] diff --git a/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs b/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs index 214370f424c..361f0322690 100644 --- a/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs +++ b/tests/codegen/riscv-abi/riscv64-lp64f-lp64d-abi.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes --target riscv64gc-unknown-linux-gnu //@ needs-llvm-components: riscv @@ -6,12 +7,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // CHECK: define void @f_fpr_tracking(float %0, float %1, float %2, float %3, float %4, float %5, float %6, float %7, i8 noundef zeroext %i) #[no_mangle] diff --git a/tests/codegen/riscv-target-abi.rs b/tests/codegen/riscv-target-abi.rs index 88da4ece7ba..d41fcb4dd84 100644 --- a/tests/codegen/riscv-target-abi.rs +++ b/tests/codegen/riscv-target-abi.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions:riscv64gc riscv32gc riscv32imac //@[riscv64gc] compile-flags: --target=riscv64gc-unknown-linux-gnu @@ -16,5 +17,5 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; diff --git a/tests/codegen/sanitizer/aarch64-shadow-call-stack-with-fixed-x18.rs b/tests/codegen/sanitizer/aarch64-shadow-call-stack-with-fixed-x18.rs index e2e14ab14a8..e1d7dc2d631 100644 --- a/tests/codegen/sanitizer/aarch64-shadow-call-stack-with-fixed-x18.rs +++ b/tests/codegen/sanitizer/aarch64-shadow-call-stack-with-fixed-x18.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: aarch64 android //@[aarch64] compile-flags: --target aarch64-unknown-none -Zfixed-x18 -Zsanitizer=shadow-call-stack //@[aarch64] needs-llvm-components: aarch64 @@ -9,8 +10,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; // CHECK: ; Function Attrs:{{.*}}shadowcallstack #[no_mangle] diff --git a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs index 56ee875286a..774c9ab53f1 100644 --- a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs +++ b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs @@ -1,5 +1,6 @@ // Verifies that `-Zsanitizer=kernel-address` emits sanitizer instrumentation. +//@ add-core-stubs //@ compile-flags: -Zsanitizer=kernel-address -Copt-level=0 //@ revisions: aarch64 riscv64imac riscv64gc x86_64 //@[aarch64] compile-flags: --target aarch64-unknown-none @@ -15,13 +16,8 @@ #![feature(no_core, no_sanitize, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} - -#[lang = "copy"] -trait Copy {} - -impl Copy for u8 {} +extern crate minicore; +use minicore::*; // CHECK-LABEL: ; kasan_emits_instrumentation::unsanitized // CHECK-NEXT: ; Function Attrs: diff --git a/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs b/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs index d48e4016a16..0be1ff19774 100644 --- a/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs +++ b/tests/codegen/sanitizer/kcfi/add-cfi-normalize-integers-flag.rs @@ -1,5 +1,6 @@ // Verifies that "cfi-normalize-integers" module flag is added. // +//@ add-core-stubs //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 @@ -11,10 +12,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; pub fn foo() {} diff --git a/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs b/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs index 013de74f8d6..eabe0409c9a 100644 --- a/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs +++ b/tests/codegen/sanitizer/kcfi/add-kcfi-flag.rs @@ -1,5 +1,6 @@ // Verifies that "kcfi" module flag is added. // +//@ add-core-stubs //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 @@ -11,10 +12,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; pub fn foo() {} diff --git a/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs b/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs index b4924719f4c..2f18c9d84b9 100644 --- a/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs +++ b/tests/codegen/sanitizer/kcfi/add-kcfi-offset-flag.rs @@ -1,5 +1,6 @@ // Verifies that "kcfi-offset" module flag is added. // +//@ add-core-stubs //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 @@ -11,10 +12,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; pub fn foo() {} diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs index ba2e397f6da..6b40918dd3a 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-attr-no-sanitize.rs @@ -1,5 +1,6 @@ // Verifies that KCFI operand bundles are omitted. // +//@ add-core-stubs //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 @@ -11,12 +12,8 @@ #![feature(no_core, no_sanitize, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -impl Copy for i32 {} +extern crate minicore; +use minicore::*; #[no_sanitize(kcfi)] pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs index 4e95bdf4d7c..942b50deb02 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs @@ -1,5 +1,6 @@ // Verifies that generalized KCFI type metadata for functions are emitted. // +//@ add-core-stubs //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 @@ -11,12 +12,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -impl Copy for i32 {} +extern crate minicore; +use minicore::*; pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs index 31b43b50988..c89d9bdd121 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs @@ -1,5 +1,6 @@ // Verifies that normalized and generalized KCFI type metadata for functions are emitted. // +//@ add-core-stubs //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 @@ -11,12 +12,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -impl Copy for i32 {} +extern crate minicore; +use minicore::*; pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs index 4755f6062aa..220cae1a4fa 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs @@ -1,5 +1,6 @@ // Verifies that normalized KCFI type metadata for functions are emitted. // +//@ add-core-stubs //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 @@ -11,12 +12,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -impl Copy for i32 {} +extern crate minicore; +use minicore::*; pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs index be9760bd9af..bb9a0005903 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle-itanium-cxx-abi.rs @@ -1,5 +1,6 @@ // Verifies that KCFI type metadata for functions are emitted. // +//@ add-core-stubs //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 @@ -11,12 +12,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -impl Copy for i32 {} +extern crate minicore; +use minicore::*; pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo diff --git a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs index c9c94cdb329..8b844b99142 100644 --- a/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs +++ b/tests/codegen/sanitizer/kcfi/emit-kcfi-operand-bundle.rs @@ -1,5 +1,6 @@ // Verifies that KCFI operand bundles are emitted. // +//@ add-core-stubs //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 @@ -11,12 +12,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -impl Copy for i32 {} +extern crate minicore; +use minicore::*; pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { // CHECK-LABEL: define{{.*}}foo{{.*}}!{{<unknown kind #36>|kcfi_type}} !{{[0-9]+}} diff --git a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs index 5ab55a46726..15c107bea15 100644 --- a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs @@ -1,5 +1,6 @@ // Verifies that type metadata identifiers for trait objects are emitted correctly. // +//@ add-core-stubs //@ revisions: aarch64 x86_64 //@ [aarch64] compile-flags: --target aarch64-unknown-none //@ [aarch64] needs-llvm-components: aarch64 @@ -11,29 +12,8 @@ #![feature(arbitrary_self_types, no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -impl<T: ?Sized> Copy for &T {} -#[lang = "legacy_receiver"] -trait LegacyReceiver {} -#[lang = "dispatch_from_dyn"] -trait DispatchFromDyn<T> {} -impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {} -#[lang = "unsize"] -trait Unsize<T: ?Sized> {} -#[lang = "coerce_unsized"] -pub trait CoerceUnsized<T: ?Sized> {} -impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "drop_in_place"] -fn drop_in_place_fn<T>() {} -#[lang = "drop"] -trait Drop { - fn drop(&mut self); -} +extern crate minicore; +use minicore::*; pub trait Trait1 { fn foo(&self); diff --git a/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs b/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs index 5833b832ba4..945e46218d0 100644 --- a/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs +++ b/tests/codegen/sanitizer/riscv64-shadow-call-stack.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: --target riscv64imac-unknown-none-elf -Zsanitizer=shadow-call-stack //@ needs-llvm-components: riscv @@ -6,8 +7,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; // CHECK: ; Function Attrs:{{.*}}shadowcallstack // CHECK: define dso_local void @foo() unnamed_addr #0 diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-abs.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-abs.rs index 4a5a6391c05..485ba92272d 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-abs.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-abs.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_fabs; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_fabs<T>(x: T) -> T; -} - // CHECK-LABEL: @fabs_32x2 #[no_mangle] pub unsafe fn fabs_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-ceil.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-ceil.rs index 89e54f579ff..e8bda7c29c4 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-ceil.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-ceil.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_ceil; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_ceil<T>(x: T) -> T; -} - // CHECK-LABEL: @ceil_32x2 #[no_mangle] pub unsafe fn ceil_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-cos.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-cos.rs index b40fd5365de..8dc967bc3ad 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-cos.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-cos.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_fcos; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_fcos<T>(x: T) -> T; -} - // CHECK-LABEL: @fcos_32x2 #[no_mangle] pub unsafe fn fcos_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp.rs index fef003dde5b..00caca2f294 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_fexp; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_fexp<T>(x: T) -> T; -} - // CHECK-LABEL: @exp_32x2 #[no_mangle] pub unsafe fn exp_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp2.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp2.rs index 779c0fc403a..eda4053189c 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp2.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-exp2.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_fexp2; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_fexp2<T>(x: T) -> T; -} - // CHECK-LABEL: @exp2_32x2 #[no_mangle] pub unsafe fn exp2_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-floor.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-floor.rs index b2bd27a5b75..ad69d4cdd88 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-floor.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-floor.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_floor; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_floor<T>(x: T) -> T; -} - // CHECK-LABEL: @floor_32x2 #[no_mangle] pub unsafe fn floor_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-fma.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-fma.rs index 37f4782626a..cbeefdc31c0 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-fma.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-fma.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_fma; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_fma<T>(x: T, b: T, c: T) -> T; -} - // CHECK-LABEL: @fma_32x2 #[no_mangle] pub unsafe fn fma_32x2(a: f32x2, b: f32x2, c: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-fsqrt.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-fsqrt.rs index 336adf6db73..618daa4b44d 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-fsqrt.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-fsqrt.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_fsqrt; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_fsqrt<T>(x: T) -> T; -} - // CHECK-LABEL: @fsqrt_32x2 #[no_mangle] pub unsafe fn fsqrt_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log.rs index 8e97abc3a66..98a481e4004 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_flog; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_flog<T>(x: T) -> T; -} - // CHECK-LABEL: @log_32x2 #[no_mangle] pub unsafe fn log_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log10.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log10.rs index 1d4d4dc24e9..9108cd963f0 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log10.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log10.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_flog10; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_flog10<T>(x: T) -> T; -} - // CHECK-LABEL: @log10_32x2 #[no_mangle] pub unsafe fn log10_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log2.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log2.rs index 28f2f151617..2b20850dbd9 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-log2.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-log2.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_flog2; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_flog2<T>(x: T) -> T; -} - // CHECK-LABEL: @log2_32x2 #[no_mangle] pub unsafe fn log2_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-minmax.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-minmax.rs index 50c51bebe37..ce07b212e84 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-minmax.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-minmax.rs @@ -1,19 +1,15 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::{simd_fmax, simd_fmin}; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x4(pub [f32; 4]); -extern "rust-intrinsic" { - fn simd_fmin<T>(x: T, y: T) -> T; - fn simd_fmax<T>(x: T, y: T) -> T; -} - // CHECK-LABEL: @fmin #[no_mangle] pub unsafe fn fmin(a: f32x4, b: f32x4) -> f32x4 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-float-sin.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-float-sin.rs index 4173809e3a9..7de26b415bb 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-float-sin.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-float-sin.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_fsin; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x2(pub [f32; 2]); @@ -21,10 +22,6 @@ pub struct f32x8(pub [f32; 8]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x16(pub [f32; 16]); -extern "rust-intrinsic" { - fn simd_fsin<T>(x: T) -> T; -} - // CHECK-LABEL: @fsin_32x2 #[no_mangle] pub unsafe fn fsin_32x2(a: f32x2) -> f32x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs index a5afa27876a..ecf5eb24ee5 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs @@ -1,71 +1,71 @@ //@ compile-flags: -C no-prepopulate-passes -// #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] #![deny(unused)] -// signed integer types +use std::intrinsics::simd::{simd_saturating_add, simd_saturating_sub}; -#[repr(simd)] #[derive(Copy, Clone)] pub struct i8x2([i8; 2]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i8x4([i8; 4]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i8x8([i8; 8]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i8x16([i8; 16]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i8x32([i8; 32]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i8x64([i8; 64]); +#[rustfmt::skip] +mod types { + // signed integer types -#[repr(simd)] #[derive(Copy, Clone)] pub struct i16x2([i16; 2]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i16x4([i16; 4]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i16x8([i16; 8]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i16x16([i16; 16]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i16x32([i16; 32]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x2([i8; 2]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x4([i8; 4]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x8([i8; 8]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x16([i8; 16]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x32([i8; 32]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x64([i8; 64]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i32x2([i32; 2]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i32x4([i32; 4]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i32x8([i32; 8]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i32x16([i32; 16]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i16x2([i16; 2]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i16x4([i16; 4]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i16x8([i16; 8]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i16x16([i16; 16]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i16x32([i16; 32]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i64x2([i64; 2]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i64x4([i64; 4]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i64x8([i64; 8]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i32x2([i32; 2]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i32x4([i32; 4]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i32x8([i32; 8]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i32x16([i32; 16]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i128x2([i128; 2]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct i128x4([i128; 4]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i64x2([i64; 2]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i64x4([i64; 4]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i64x8([i64; 8]); -// unsigned integer types + #[repr(simd)] #[derive(Copy, Clone)] pub struct i128x2([i128; 2]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct i128x4([i128; 4]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u8x2([u8; 2]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u8x4([u8; 4]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u8x8([u8; 8]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u8x16([u8; 16]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u8x32([u8; 32]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u8x64([u8; 64]); + // unsigned integer types -#[repr(simd)] #[derive(Copy, Clone)] pub struct u16x2([u16; 2]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u16x4([u16; 4]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u16x8([u16; 8]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u16x16([u16; 16]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u16x32([u16; 32]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x2([u8; 2]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x4([u8; 4]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x8([u8; 8]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x16([u8; 16]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x32([u8; 32]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x64([u8; 64]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u32x2([u32; 2]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u32x4([u32; 4]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u32x8([u32; 8]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u32x16([u32; 16]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u16x2([u16; 2]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u16x4([u16; 4]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u16x8([u16; 8]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u16x16([u16; 16]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u16x32([u16; 32]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u64x2([u64; 2]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u64x4([u64; 4]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u64x8([u64; 8]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u32x2([u32; 2]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u32x4([u32; 4]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u32x8([u32; 8]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u32x16([u32; 16]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u128x2([u128; 2]); -#[repr(simd)] #[derive(Copy, Clone)] pub struct u128x4([u128; 4]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u64x2([u64; 2]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u64x4([u64; 4]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u64x8([u64; 8]); -extern "rust-intrinsic" { - fn simd_saturating_add<T>(x: T, y: T) -> T; - fn simd_saturating_sub<T>(x: T, y: T) -> T; + #[repr(simd)] #[derive(Copy, Clone)] pub struct u128x2([u128; 2]); + #[repr(simd)] #[derive(Copy, Clone)] pub struct u128x4([u128; 4]); } +use types::*; + // NOTE(eddyb) `%{{x|0}}` is used because on some targets (e.g. WASM) // SIMD vectors are passed directly, resulting in `%x` being a vector, // while on others they're passed indirectly, resulting in `%x` being @@ -213,8 +213,6 @@ pub unsafe fn sadd_i128x4(x: i128x4, y: i128x4) -> i128x4 { simd_saturating_add(x, y) } - - // CHECK-LABEL: @uadd_u8x2 #[no_mangle] pub unsafe fn uadd_u8x2(x: u8x2, y: u8x2) -> u8x2 { @@ -355,10 +353,6 @@ pub unsafe fn uadd_u128x4(x: u128x4, y: u128x4) -> u128x4 { simd_saturating_add(x, y) } - - - - // CHECK-LABEL: @ssub_i8x2 #[no_mangle] pub unsafe fn ssub_i8x2(x: i8x2, y: i8x2) -> i8x2 { @@ -499,8 +493,6 @@ pub unsafe fn ssub_i128x4(x: i128x4, y: i128x4) -> i128x4 { simd_saturating_sub(x, y) } - - // CHECK-LABEL: @usub_u8x2 #[no_mangle] pub unsafe fn usub_u8x2(x: u8x2, y: u8x2) -> u8x2 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-bitmask.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-bitmask.rs index e9112f1f321..a2c40aa91b5 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-bitmask.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-bitmask.rs @@ -2,10 +2,11 @@ // #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_bitmask; + #[repr(simd)] #[derive(Copy, Clone)] pub struct u32x2([u32; 2]); @@ -18,10 +19,6 @@ pub struct i32x2([i32; 2]); #[derive(Copy, Clone)] pub struct i8x16([i8; 16]); -extern "rust-intrinsic" { - fn simd_bitmask<T, U>(x: T) -> U; -} - // NOTE(eddyb) `%{{x|1}}` is used because on some targets (e.g. WASM) // SIMD vectors are passed directly, resulting in `%x` being a vector, // while on others they're passed indirectly, resulting in `%x` being diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs index 7f99f695bf4..9bb46a3546b 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-gather.rs @@ -3,10 +3,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_gather; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec2<T>(pub [T; 2]); @@ -15,14 +16,13 @@ pub struct Vec2<T>(pub [T; 2]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec4<T>(pub [T; 4]); -extern "rust-intrinsic" { - fn simd_gather<T, P, M>(value: T, pointers: P, mask: M) -> T; -} - // CHECK-LABEL: @gather_f32x2 #[no_mangle] -pub unsafe fn gather_f32x2(pointers: Vec2<*const f32>, mask: Vec2<i32>, - values: Vec2<f32>) -> Vec2<f32> { +pub unsafe fn gather_f32x2( + pointers: Vec2<*const f32>, + mask: Vec2<i32>, + values: Vec2<f32>, +) -> Vec2<f32> { // CHECK: [[A:%[0-9]+]] = lshr <2 x i32> {{.*}}, {{<i32 31, i32 31>|splat \(i32 31\)}} // CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1> // CHECK: call <2 x float> @llvm.masked.gather.v2f32.v2p0(<2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> [[B]], <2 x float> {{.*}}) @@ -31,8 +31,11 @@ pub unsafe fn gather_f32x2(pointers: Vec2<*const f32>, mask: Vec2<i32>, // CHECK-LABEL: @gather_pf32x2 #[no_mangle] -pub unsafe fn gather_pf32x2(pointers: Vec2<*const *const f32>, mask: Vec2<i32>, - values: Vec2<*const f32>) -> Vec2<*const f32> { +pub unsafe fn gather_pf32x2( + pointers: Vec2<*const *const f32>, + mask: Vec2<i32>, + values: Vec2<*const f32>, +) -> Vec2<*const f32> { // CHECK: [[A:%[0-9]+]] = lshr <2 x i32> {{.*}}, {{<i32 31, i32 31>|splat \(i32 31\)}} // CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1> // CHECK: call <2 x ptr> @llvm.masked.gather.v2p0.v2p0(<2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> [[B]], <2 x ptr> {{.*}}) diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs index 7f46630e920..fcc4cb5d630 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-load.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_masked_load; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec2<T>(pub [T; 2]); @@ -13,14 +14,9 @@ pub struct Vec2<T>(pub [T; 2]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec4<T>(pub [T; 4]); -extern "rust-intrinsic" { - fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; -} - // CHECK-LABEL: @load_f32x2 #[no_mangle] -pub unsafe fn load_f32x2(mask: Vec2<i32>, pointer: *const f32, - values: Vec2<f32>) -> Vec2<f32> { +pub unsafe fn load_f32x2(mask: Vec2<i32>, pointer: *const f32, values: Vec2<f32>) -> Vec2<f32> { // CHECK: [[A:%[0-9]+]] = lshr <2 x i32> {{.*}}, {{<i32 31, i32 31>|splat \(i32 31\)}} // CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1> // CHECK: call <2 x float> @llvm.masked.load.v2f32.p0(ptr {{.*}}, i32 4, <2 x i1> [[B]], <2 x float> {{.*}}) @@ -29,8 +25,11 @@ pub unsafe fn load_f32x2(mask: Vec2<i32>, pointer: *const f32, // CHECK-LABEL: @load_pf32x4 #[no_mangle] -pub unsafe fn load_pf32x4(mask: Vec4<i32>, pointer: *const *const f32, - values: Vec4<*const f32>) -> Vec4<*const f32> { +pub unsafe fn load_pf32x4( + mask: Vec4<i32>, + pointer: *const *const f32, + values: Vec4<*const f32>, +) -> Vec4<*const f32> { // CHECK: [[A:%[0-9]+]] = lshr <4 x i32> {{.*}}, {{<i32 31, i32 31, i32 31, i32 31>|splat \(i32 31\)}} // CHECK: [[B:%[0-9]+]] = trunc <4 x i32> [[A]] to <4 x i1> // CHECK: call <4 x ptr> @llvm.masked.load.v4p0.p0(ptr {{.*}}, i32 {{.*}}, <4 x i1> [[B]], <4 x ptr> {{.*}}) diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs index 0d43234f1e2..04f4a0c6382 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-masked-store.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_masked_store; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec2<T>(pub [T; 2]); @@ -13,10 +14,6 @@ pub struct Vec2<T>(pub [T; 2]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec4<T>(pub [T; 4]); -extern "rust-intrinsic" { - fn simd_masked_store<M, P, T>(mask: M, pointer: P, values: T) -> (); -} - // CHECK-LABEL: @store_f32x2 #[no_mangle] pub unsafe fn store_f32x2(mask: Vec2<i32>, pointer: *mut f32, values: Vec2<f32>) { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs index ef7827bd96f..9506f8f6d3a 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-scatter.rs @@ -3,10 +3,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_scatter; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec2<T>(pub [T; 2]); @@ -15,25 +16,22 @@ pub struct Vec2<T>(pub [T; 2]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct Vec4<T>(pub [T; 4]); -extern "rust-intrinsic" { - fn simd_scatter<T, P, M>(value: T, pointers: P, mask: M); -} - // CHECK-LABEL: @scatter_f32x2 #[no_mangle] -pub unsafe fn scatter_f32x2(pointers: Vec2<*mut f32>, mask: Vec2<i32>, - values: Vec2<f32>) { +pub unsafe fn scatter_f32x2(pointers: Vec2<*mut f32>, mask: Vec2<i32>, values: Vec2<f32>) { // CHECK: [[A:%[0-9]+]] = lshr <2 x i32> {{.*}}, {{<i32 31, i32 31>|splat \(i32 31\)}} // CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1> // CHECK: call void @llvm.masked.scatter.v2f32.v2p0(<2 x float> {{.*}}, <2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> [[B]] simd_scatter(values, pointers, mask) } - // CHECK-LABEL: @scatter_pf32x2 #[no_mangle] -pub unsafe fn scatter_pf32x2(pointers: Vec2<*mut *const f32>, mask: Vec2<i32>, - values: Vec2<*const f32>) { +pub unsafe fn scatter_pf32x2( + pointers: Vec2<*mut *const f32>, + mask: Vec2<i32>, + values: Vec2<*const f32>, +) { // CHECK: [[A:%[0-9]+]] = lshr <2 x i32> {{.*}}, {{<i32 31, i32 31>|splat \(i32 31\)}} // CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1> // CHECK: call void @llvm.masked.scatter.v2p0.v2p0(<2 x ptr> {{.*}}, <2 x ptr> {{.*}}, i32 {{.*}}, <2 x i1> [[B]] diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-select.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-select.rs index 33ed2b437f9..71279d9f0ea 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-generic-select.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-generic-select.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] - -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::{simd_select, simd_select_bitmask}; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] pub struct f32x4(pub [f32; 4]); @@ -21,11 +22,6 @@ pub struct b8x4(pub [i8; 4]); #[derive(Copy, Clone, PartialEq, Debug)] pub struct i32x4([i32; 4]); -extern "rust-intrinsic" { - fn simd_select<T, U>(x: T, a: U, b: U) -> U; - fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U; -} - // CHECK-LABEL: @select_m8 #[no_mangle] pub unsafe fn select_m8(m: b8x4, a: f32x4, b: f32x4) -> f32x4 { diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-mask-reduce.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-mask-reduce.rs index 92067db9b15..269fe41225e 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-mask-reduce.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-mask-reduce.rs @@ -1,10 +1,11 @@ //@ compile-flags: -C no-prepopulate-passes -// #![crate_type = "lib"] -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::{simd_reduce_all, simd_reduce_any}; + #[repr(simd)] #[derive(Copy, Clone)] pub struct mask32x2([i32; 2]); @@ -13,11 +14,6 @@ pub struct mask32x2([i32; 2]); #[derive(Copy, Clone)] pub struct mask8x16([i8; 16]); -extern "rust-intrinsic" { - fn simd_reduce_all<T>(x: T) -> bool; - fn simd_reduce_any<T>(x: T) -> bool; -} - // NOTE(eddyb) `%{{x|1}}` is used because on some targets (e.g. WASM) // SIMD vectors are passed directly, resulting in `%x` being a vector, // while on others they're passed indirectly, resulting in `%x` being diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs index 0d21d510557..d3853361de9 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs @@ -12,7 +12,7 @@ #![crate_type = "lib"] #![allow(non_camel_case_types)] -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] diff --git a/tests/codegen/simd/simd_arith_offset.rs b/tests/codegen/simd/simd_arith_offset.rs index e14fce1d418..b8af6fce332 100644 --- a/tests/codegen/simd/simd_arith_offset.rs +++ b/tests/codegen/simd/simd_arith_offset.rs @@ -3,11 +3,9 @@ // #![crate_type = "lib"] -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] -extern "rust-intrinsic" { - pub(crate) fn simd_arith_offset<T, U>(ptrs: T, offsets: U) -> T; -} +use std::intrinsics::simd::simd_arith_offset; /// A vector of *const T. #[derive(Debug, Copy, Clone)] diff --git a/tests/codegen/some-abis-do-extend-params-to-32-bits.rs b/tests/codegen/some-abis-do-extend-params-to-32-bits.rs index 10970cacdcf..6ca6697588f 100644 --- a/tests/codegen/some-abis-do-extend-params-to-32-bits.rs +++ b/tests/codegen/some-abis-do-extend-params-to-32-bits.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: -Cno-prepopulate-passes -Copt-level=0 //@ revisions:x86_64 i686 aarch64-apple aarch64-windows aarch64-linux arm riscv @@ -24,12 +25,8 @@ #![no_std] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; // The patterns in this file are written in the style of a table to make the // uniformities and distinctions more apparent. diff --git a/tests/codegen/sparc-struct-abi.rs b/tests/codegen/sparc-struct-abi.rs index 0a8720c4fca..32d2c5bb0ef 100644 --- a/tests/codegen/sparc-struct-abi.rs +++ b/tests/codegen/sparc-struct-abi.rs @@ -1,17 +1,14 @@ // Checks that we correctly codegen extern "C" functions returning structs. // See issues #52638 and #86163. +//@ add-core-stubs //@ compile-flags: -Copt-level=3 --target=sparc64-unknown-linux-gnu --crate-type=rlib //@ needs-llvm-components: sparc #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "freeze"] -trait Freeze {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[repr(C)] pub struct Bool { diff --git a/tests/codegen/stack-probes-inline.rs b/tests/codegen/stack-probes-inline.rs index c5073b9cc22..746272b0994 100644 --- a/tests/codegen/stack-probes-inline.rs +++ b/tests/codegen/stack-probes-inline.rs @@ -1,6 +1,7 @@ // Check the "probe-stack" attribute for targets with `StackProbeType::Inline`, // or `StackProbeType::InlineOrCall` when running on newer LLVM. +//@ add-core-stubs //@ compile-flags: -C no-prepopulate-passes //@ revisions: aarch64 powerpc powerpc64 powerpc64le s390x i686 x86_64 //@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu @@ -22,8 +23,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; #[no_mangle] pub fn foo() { diff --git a/tests/codegen/target-feature-overrides.rs b/tests/codegen/target-feature-overrides.rs index f38a1ae72de..0fc1e0136b3 100644 --- a/tests/codegen/target-feature-overrides.rs +++ b/tests/codegen/target-feature-overrides.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: COMPAT INCOMPAT //@ needs-llvm-components: x86 //@ compile-flags: --target=x86_64-unknown-linux-gnu -Copt-level=3 @@ -9,10 +10,8 @@ #![crate_type = "lib"] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; extern "C" { fn peach() -> u32; diff --git a/tests/codegen/tied-features-strength.rs b/tests/codegen/tied-features-strength.rs index 1b2b63c3d1a..8b1f3b14fc3 100644 --- a/tests/codegen/tied-features-strength.rs +++ b/tests/codegen/tied-features-strength.rs @@ -1,4 +1,5 @@ // ignore-tidy-linelength +//@ add-core-stubs //@ revisions: ENABLE_SVE DISABLE_SVE DISABLE_NEON ENABLE_NEON //@ compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu //@ needs-llvm-components: aarch64 @@ -22,7 +23,7 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; pub fn test() {} diff --git a/tests/codegen/uninhabited-transparent-return-abi.rs b/tests/codegen/uninhabited-transparent-return-abi.rs index 6e8b1683163..face1577c3f 100644 --- a/tests/codegen/uninhabited-transparent-return-abi.rs +++ b/tests/codegen/uninhabited-transparent-return-abi.rs @@ -24,7 +24,7 @@ extern "Rust" { pub fn test_uninhabited_ret_by_ref() { // CHECK: %_1 = alloca [24 x i8], align {{8|4}} // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %_1) - // CHECK-NEXT: call void @opaque(ptr noalias nocapture noundef nonnull sret([24 x i8]) align {{8|4}} dereferenceable(24) %_1) #2 + // CHECK-NEXT: call void @opaque({{.*}} sret([24 x i8]) {{.*}} %_1) #2 // CHECK-NEXT: unreachable unsafe { opaque(); @@ -36,7 +36,7 @@ pub fn test_uninhabited_ret_by_ref() { pub fn test_uninhabited_ret_by_ref_with_arg(rsi: u32) { // CHECK: %_2 = alloca [24 x i8], align {{8|4}} // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %_2) - // CHECK-NEXT: call void @opaque_with_arg(ptr noalias nocapture noundef nonnull sret([24 x i8]) align {{8|4}} dereferenceable(24) %_2, i32 noundef %rsi) #2 + // CHECK-NEXT: call void @opaque_with_arg({{.*}} sret([24 x i8]) {{.*}} %_2, i32 noundef %rsi) #2 // CHECK-NEXT: unreachable unsafe { opaque_with_arg(rsi); diff --git a/tests/codegen/uninit-consts.rs b/tests/codegen/uninit-consts.rs index 649927b87b4..a58008e171e 100644 --- a/tests/codegen/uninit-consts.rs +++ b/tests/codegen/uninit-consts.rs @@ -11,15 +11,15 @@ pub struct PartiallyUninit { y: MaybeUninit<[u8; 10]>, } -// CHECK: [[FULLY_UNINIT:@[0-9]+]] = private unnamed_addr constant <{ [10 x i8] }> undef +// CHECK: [[FULLY_UNINIT:@.*]] = private unnamed_addr constant <{ [10 x i8] }> undef -// CHECK: [[PARTIALLY_UNINIT:@[0-9]+]] = private unnamed_addr constant <{ [4 x i8], [12 x i8] }> <{ [4 x i8] c"{{\\EF\\BE\\AD\\DE|\\DE\\AD\\BE\\EF}}", [12 x i8] undef }>, align 4 +// CHECK: [[PARTIALLY_UNINIT:@.*]] = private unnamed_addr constant <{ [4 x i8], [12 x i8] }> <{ [4 x i8] c"{{\\EF\\BE\\AD\\DE|\\DE\\AD\\BE\\EF}}", [12 x i8] undef }>, align 4 // This shouldn't contain undef, since it contains more chunks // than the default value of uninit_const_chunk_threshold. -// CHECK: [[UNINIT_PADDING_HUGE:@[0-9]+]] = private unnamed_addr constant <{ [32768 x i8] }> <{ [32768 x i8] c"{{.+}}" }>, align 4 +// CHECK: [[UNINIT_PADDING_HUGE:@.*]] = private unnamed_addr constant <{ [32768 x i8] }> <{ [32768 x i8] c"{{.+}}" }>, align 4 -// CHECK: [[FULLY_UNINIT_HUGE:@[0-9]+]] = private unnamed_addr constant <{ [16384 x i8] }> undef +// CHECK: [[FULLY_UNINIT_HUGE:@.*]] = private unnamed_addr constant <{ [16384 x i8] }> undef // CHECK-LABEL: @fully_uninit #[no_mangle] diff --git a/tests/crashes/117877.rs b/tests/crashes/117877.rs deleted file mode 100644 index b1effc0cbcb..00000000000 --- a/tests/crashes/117877.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ known-bug: #117877 -//@ edition:2021 -//@ needs-rustc-debug-assertions -//@ only-x86_64 -#![feature(asm_const)] - -use std::arch::asm; - -async unsafe fn foo<'a>() { - asm!("/* {0} */", const N); -} - -fn main() {} diff --git a/tests/incremental/issue-61530.rs b/tests/incremental/issue-61530.rs index 71ac39d0e03..673556a9d02 100644 --- a/tests/incremental/issue-61530.rs +++ b/tests/incremental/issue-61530.rs @@ -1,14 +1,12 @@ -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] //@ revisions:rpass1 rpass2 +use std::intrinsics::simd::simd_shuffle; + #[repr(simd)] struct I32x2([i32; 2]); -extern "rust-intrinsic" { - fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; -} - #[repr(simd)] struct SimdShuffleIdx<const LEN: usize>([u32; LEN]); diff --git a/tests/mir-opt/issues/issue_75439.rs b/tests/mir-opt/issues/issue_75439.rs index ea763dd1b10..d7883f0dc71 100644 --- a/tests/mir-opt/issues/issue_75439.rs +++ b/tests/mir-opt/issues/issue_75439.rs @@ -1,10 +1,14 @@ -// skip-filecheck // EMIT_MIR issue_75439.foo.MatchBranchSimplification.diff //@ ignore-endian-big use std::mem::transmute; pub fn foo(bytes: [u8; 16]) -> Option<[u8; 4]> { + // CHECK-LABEL: fn foo( + // CHECK: bb2: { + // CHECK-NEXT: 0: [[bb:bb[0-9]+]], + // CHECK-SAME: {{[0-9]+}}: [[bb]], + // big endian `u32`s let dwords: [u32; 4] = unsafe { transmute(bytes) }; const FF: u32 = 0x0000_ffff_u32.to_be(); diff --git a/tests/run-make/pgo-embed-bc-lto/interesting.rs b/tests/run-make/pgo-embed-bc-lto/interesting.rs new file mode 100644 index 00000000000..13105c17e12 --- /dev/null +++ b/tests/run-make/pgo-embed-bc-lto/interesting.rs @@ -0,0 +1,16 @@ +#![crate_name = "interesting"] +#![crate_type = "rlib"] + +extern crate opaque; + +#[no_mangle] +#[inline(never)] +pub fn function_called_once() { + opaque::foo(); +} + +// CHECK-LABEL: @function_called_once +// CHECK-SAME: !prof [[function_called_once_id:![0-9]+]] { +// CHECK: "CG Profile" +// CHECK-NOT: "CG Profile" +// CHECK-DAG: [[function_called_once_id]] = !{!"function_entry_count", i64 1} diff --git a/tests/run-make/pgo-embed-bc-lto/main.rs b/tests/run-make/pgo-embed-bc-lto/main.rs new file mode 100644 index 00000000000..ce8747bef3c --- /dev/null +++ b/tests/run-make/pgo-embed-bc-lto/main.rs @@ -0,0 +1,5 @@ +extern crate interesting; + +fn main() { + interesting::function_called_once(); +} diff --git a/tests/run-make/pgo-embed-bc-lto/opaque.rs b/tests/run-make/pgo-embed-bc-lto/opaque.rs new file mode 100644 index 00000000000..b4467dc7796 --- /dev/null +++ b/tests/run-make/pgo-embed-bc-lto/opaque.rs @@ -0,0 +1,5 @@ +#![crate_name = "opaque"] +#![crate_type = "rlib"] + +#[inline(never)] +pub fn foo() {} diff --git a/tests/run-make/pgo-embed-bc-lto/rmake.rs b/tests/run-make/pgo-embed-bc-lto/rmake.rs new file mode 100644 index 00000000000..b7eba0c68e3 --- /dev/null +++ b/tests/run-make/pgo-embed-bc-lto/rmake.rs @@ -0,0 +1,67 @@ +// This test case verifies that we successfully complete an LTO build with PGO +// using the embedded bitcode. +// It also ensures that the generated IR correctly includes the call results. + +//@ needs-profiler-runtime +//@ ignore-cross-compile + +use std::path::Path; + +use run_make_support::{ + has_extension, has_prefix, llvm_filecheck, llvm_profdata, rfs, run, rustc, shallow_find_files, +}; + +fn run_test(cg_units: usize) { + let path_prof_data_dir = Path::new("prof_data_dir"); + if path_prof_data_dir.exists() { + rfs::remove_dir_all(path_prof_data_dir); + } + rfs::create_dir_all(&path_prof_data_dir); + let path_merged_profdata = path_prof_data_dir.join("merged.profdata"); + rustc().input("opaque.rs").codegen_units(1).run(); + rustc() + .input("interesting.rs") + .profile_generate(&path_prof_data_dir) + .opt() + .crate_type("lib,cdylib") + .codegen_units(cg_units) + .run(); + rustc() + .input("main.rs") + .arg("-Clto=thin") + .opt() + .codegen_units(cg_units) + .profile_generate(&path_prof_data_dir) + .opt() + .run(); + run("main"); + llvm_profdata().merge().output(&path_merged_profdata).input(path_prof_data_dir).run(); + rustc() + .input("interesting.rs") + .profile_use(&path_merged_profdata) + .opt() + .crate_type("lib,cdylib") + .codegen_units(cg_units) + .emit("link") + .run(); + rustc() + .input("main.rs") + .arg("-Clto=thin") + .opt() + .codegen_units(cg_units) + .profile_use(&path_merged_profdata) + .emit("llvm-ir,link") + .opt() + .run(); + let files = shallow_find_files(".", |path| { + has_prefix(path, "main.interesting.interesting") && has_extension(path, "ll") + }); + assert_eq!(files.len(), 1); + let llvm_ir = &files[0]; + llvm_filecheck().patterns("interesting.rs").stdin_buf(rfs::read(llvm_ir)).run(); +} + +fn main() { + run_test(1); + run_test(16); +} diff --git a/tests/run-make/rustdoc-scrape-examples-macros/src/lib.rs b/tests/run-make/rustdoc-scrape-examples-macros/src/lib.rs index 26ab1390a49..3ec2cf66fa3 100644 --- a/tests/run-make/rustdoc-scrape-examples-macros/src/lib.rs +++ b/tests/run-make/rustdoc-scrape-examples-macros/src/lib.rs @@ -1,8 +1,8 @@ // Scraped example should only include line numbers for items b and c in ex.rs -// @!has foobar/fn.f.html '//*[@class="src-line-numbers"]' '14' -// @has foobar/fn.f.html '//*[@class="src-line-numbers"]' '15' -// @has foobar/fn.f.html '//*[@class="src-line-numbers"]' '21' -// @!has foobar/fn.f.html '//*[@class="src-line-numbers"]' '22' +//@ !has foobar/fn.f.html '//span[@data-nosnippet]' '14' +//@ has foobar/fn.f.html '//span[@data-nosnippet]' '15' +//@ has foobar/fn.f.html '//span[@data-nosnippet]' '21' +//@ !has foobar/fn.f.html '//span[@data-nosnippet]' '22' pub fn f() {} diff --git a/tests/run-make/rustdoc-scrape-examples-multiple/src/lib.rs b/tests/run-make/rustdoc-scrape-examples-multiple/src/lib.rs index bdfeda92d79..25600915f5f 100644 --- a/tests/run-make/rustdoc-scrape-examples-multiple/src/lib.rs +++ b/tests/run-make/rustdoc-scrape-examples-multiple/src/lib.rs @@ -1,6 +1,5 @@ -// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]//*[@class="prev"]' '' -// @has foobar/fn.ok.html '//*[@class="more-scraped-examples"]' '' -// @has src/ex/ex.rs.html -// @has foobar/fn.ok.html '//a[@href="../src/ex/ex.rs.html#2"]' '' +//@ has foobar/fn.ok.html '//*[@class="more-scraped-examples"]' '' +//@ has src/ex/ex.rs.html +//@ has foobar/fn.ok.html '//a[@href="../src/ex/ex.rs.html#2"]' '' pub fn ok() {} diff --git a/tests/run-make/rustdoc-scrape-examples-ordering/src/lib.rs b/tests/run-make/rustdoc-scrape-examples-ordering/src/lib.rs index c53c987a7cb..c957263c048 100644 --- a/tests/run-make/rustdoc-scrape-examples-ordering/src/lib.rs +++ b/tests/run-make/rustdoc-scrape-examples-ordering/src/lib.rs @@ -1,6 +1,6 @@ -// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' 'ex2' -// @has foobar/fn.ok.html '//*[@class="more-scraped-examples"]' 'ex1' -// @has foobar/fn.ok.html '//*[@class="highlight focus"]' 'ok' -// @has foobar/fn.ok.html '//*[@class="highlight"]' 'ok' +//@ has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' 'ex2' +//@ has foobar/fn.ok.html '//*[@class="more-scraped-examples"]' 'ex1' +//@ has foobar/fn.ok.html '//*[@class="highlight focus"]' 'ok' +//@ has foobar/fn.ok.html '//*[@class="highlight"]' 'ok' pub fn ok(_x: i32) {} diff --git a/tests/run-make/rustdoc-scrape-examples-remap/src/lib.rs b/tests/run-make/rustdoc-scrape-examples-remap/src/lib.rs index f525a4270dd..e1dc4f91506 100644 --- a/tests/run-make/rustdoc-scrape-examples-remap/src/lib.rs +++ b/tests/run-make/rustdoc-scrape-examples-remap/src/lib.rs @@ -1,5 +1,5 @@ -// @has foobar/b/fn.foo.html '//*[@class="scraped-example expanded"]' 'ex.rs' -// @has foobar/c/fn.foo.html '//*[@class="scraped-example expanded"]' 'ex.rs' +//@ has foobar/b/fn.foo.html '//*[@class="scraped-example expanded"]' 'ex.rs' +//@ has foobar/c/fn.foo.html '//*[@class="scraped-example expanded"]' 'ex.rs' #[path = "a.rs"] pub mod b; diff --git a/tests/run-make/rustdoc-scrape-examples-test/src/lib.rs b/tests/run-make/rustdoc-scrape-examples-test/src/lib.rs index 22be1ad4101..93d56b7e972 100644 --- a/tests/run-make/rustdoc-scrape-examples-test/src/lib.rs +++ b/tests/run-make/rustdoc-scrape-examples-test/src/lib.rs @@ -1,3 +1,3 @@ -// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' '' +//@ has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' '' pub fn ok() {} diff --git a/tests/run-make/rustdoc-scrape-examples-whitespace/src/lib.rs b/tests/run-make/rustdoc-scrape-examples-whitespace/src/lib.rs index 28c34716c2f..8fc3a5e41d2 100644 --- a/tests/run-make/rustdoc-scrape-examples-whitespace/src/lib.rs +++ b/tests/run-make/rustdoc-scrape-examples-whitespace/src/lib.rs @@ -1,3 +1,3 @@ -// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]//code' ' ' +//@ has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]//code' ' ' pub fn ok() {} diff --git a/tests/run-make/rustdoc-themes/foo.rs b/tests/run-make/rustdoc-themes/foo.rs index 8b1e75b0ae1..555429b07df 100644 --- a/tests/run-make/rustdoc-themes/foo.rs +++ b/tests/run-make/rustdoc-themes/foo.rs @@ -1,4 +1,4 @@ -// @has test.css -// @has foo/struct.Foo.html -// @has - '//*[@name="rustdoc-vars"]/@data-themes' 'test' +//@ has test.css +//@ has foo/struct.Foo.html +//@ has - '//*[@name="rustdoc-vars"]/@data-themes' 'test' pub struct Foo; diff --git a/tests/run-make/rustdoc-with-out-dir-option/src/lib.rs b/tests/run-make/rustdoc-with-out-dir-option/src/lib.rs index 044bb6acb19..98753560d3a 100644 --- a/tests/run-make/rustdoc-with-out-dir-option/src/lib.rs +++ b/tests/run-make/rustdoc-with-out-dir-option/src/lib.rs @@ -1,2 +1,2 @@ -// @has foobar/fn.ok.html +//@ has foobar/fn.ok.html pub fn ok() {} diff --git a/tests/run-make/rustdoc-with-output-option/src/lib.rs b/tests/run-make/rustdoc-with-output-option/src/lib.rs index 044bb6acb19..98753560d3a 100644 --- a/tests/run-make/rustdoc-with-output-option/src/lib.rs +++ b/tests/run-make/rustdoc-with-output-option/src/lib.rs @@ -1,2 +1,2 @@ -// @has foobar/fn.ok.html +//@ has foobar/fn.ok.html pub fn ok() {} diff --git a/tests/run-make/rustdoc-with-short-out-dir-option/src/lib.rs b/tests/run-make/rustdoc-with-short-out-dir-option/src/lib.rs index 044bb6acb19..98753560d3a 100644 --- a/tests/run-make/rustdoc-with-short-out-dir-option/src/lib.rs +++ b/tests/run-make/rustdoc-with-short-out-dir-option/src/lib.rs @@ -1,2 +1,2 @@ -// @has foobar/fn.ok.html +//@ has foobar/fn.ok.html pub fn ok() {} diff --git a/tests/run-make/staticlib-broken-bitcode/rmake.rs b/tests/run-make/staticlib-broken-bitcode/rmake.rs new file mode 100644 index 00000000000..17d17c1f0f5 --- /dev/null +++ b/tests/run-make/staticlib-broken-bitcode/rmake.rs @@ -0,0 +1,23 @@ +// Regression test for https://github.com/rust-lang/rust/issues/128955#issuecomment-2657811196 +// which checks that rustc can read an archive containing LLVM bitcode with a +// newer version from the one rustc links against. +use run_make_support::{llvm_ar, path, rfs, rustc, static_lib_name}; + +fn main() { + rfs::create_dir("archive"); + + let mut bitcode = b"BC\xC0\xDE".to_vec(); + bitcode.extend(std::iter::repeat(b'a').take(50)); + rfs::write("archive/invalid_bitcode.o", &bitcode); + + llvm_ar() + .arg("rcuS") // like obj_to_ar() except skips creating a symbol table + .output_input( + path("archive").join(static_lib_name("thin_archive")), + "archive/invalid_bitcode.o", + ) + .run(); + + // Build an rlib which includes the members of this thin archive + rustc().input("rust_lib.rs").library_search_path("archive").run(); +} diff --git a/tests/run-make/staticlib-broken-bitcode/rust_lib.rs b/tests/run-make/staticlib-broken-bitcode/rust_lib.rs new file mode 100644 index 00000000000..c76b0f25433 --- /dev/null +++ b/tests/run-make/staticlib-broken-bitcode/rust_lib.rs @@ -0,0 +1,6 @@ +#![crate_type = "rlib"] + +#[link(name = "thin_archive", kind = "static")] +extern "C" { + pub fn simple_fn(); +} diff --git a/tests/rustdoc-ui/unused-extern-crate.rs b/tests/rustdoc-ui/unused-extern-crate.rs deleted file mode 100644 index 240dd1f00e2..00000000000 --- a/tests/rustdoc-ui/unused-extern-crate.rs +++ /dev/null @@ -1,3 +0,0 @@ -//@ check-pass -//@ aux-crate:panic_item=panic-item.rs -// @has unused_extern_crate/index.html diff --git a/tests/rustdoc-ui/auxiliary/panic-item.rs b/tests/rustdoc/auxiliary/panic-item.rs index ccf784f7284..ccf784f7284 100644 --- a/tests/rustdoc-ui/auxiliary/panic-item.rs +++ b/tests/rustdoc/auxiliary/panic-item.rs diff --git a/tests/rustdoc/unused-extern-crate.rs b/tests/rustdoc/unused-extern-crate.rs new file mode 100644 index 00000000000..cdc00fd313a --- /dev/null +++ b/tests/rustdoc/unused-extern-crate.rs @@ -0,0 +1,2 @@ +//@ aux-crate:panic_item=panic-item.rs +//@ has unused_extern_crate/index.html diff --git a/tests/ui/abi/arm-unadjusted-intrinsic.rs b/tests/ui/abi/arm-unadjusted-intrinsic.rs index 533cd40b30a..dcf0d9f39f6 100644 --- a/tests/ui/abi/arm-unadjusted-intrinsic.rs +++ b/tests/ui/abi/arm-unadjusted-intrinsic.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ build-pass //@ revisions: arm //@[arm] compile-flags: --target arm-unknown-linux-gnueabi @@ -14,19 +15,8 @@ #![crate_type = "lib"] #![allow(non_camel_case_types)] -/// To work cross-target this test must be no_core. -/// This little prelude supplies what we need. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -pub trait Copy: Sized {} -impl Copy for i8 {} -impl<T: ?Sized> Copy for *const T {} -impl<T: ?Sized> Copy for *mut T {} - -// I hate no_core tests! -impl<T: Copy, const N: usize> Copy for [T; N] {} +extern crate minicore; +use minicore::*; // Regression test for https://github.com/rust-lang/rust/issues/118124. diff --git a/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr b/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr index e1f43347985..c71797b500d 100644 --- a/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr +++ b/tests/ui/abi/riscv-discoverability-guidance.riscv32.stderr @@ -1,24 +1,27 @@ error[E0703]: invalid ABI: found `riscv-interrupt` - --> $DIR/riscv-discoverability-guidance.rs:17:8 + --> $DIR/riscv-discoverability-guidance.rs:15:8 | LL | extern "riscv-interrupt" fn isr() {} - | ^^^^^^^^^^^^^^^^^ - | | - | invalid ABI - | help: did you mean: `"riscv-interrupt-m"` + | ^^^^^^^^^^^^^^^^^ invalid ABI | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions +help: there's a similarly named valid ABI `riscv-interrupt-m` + | +LL | extern "riscv-interrupt-m" fn isr() {} + | ++ error[E0703]: invalid ABI: found `riscv-interrupt-u` - --> $DIR/riscv-discoverability-guidance.rs:22:8 + --> $DIR/riscv-discoverability-guidance.rs:20:8 | LL | extern "riscv-interrupt-u" fn isr_U() {} - | ^^^^^^^^^^^^^^^^^^^ - | | - | invalid ABI - | help: did you mean: `"riscv-interrupt-m"` + | ^^^^^^^^^^^^^^^^^^^ invalid ABI | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions +help: there's a similarly named valid ABI `riscv-interrupt-m` + | +LL - extern "riscv-interrupt-u" fn isr_U() {} +LL + extern "riscv-interrupt-m" fn isr_U() {} + | error: aborting due to 2 previous errors diff --git a/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr b/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr index e1f43347985..c71797b500d 100644 --- a/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr +++ b/tests/ui/abi/riscv-discoverability-guidance.riscv64.stderr @@ -1,24 +1,27 @@ error[E0703]: invalid ABI: found `riscv-interrupt` - --> $DIR/riscv-discoverability-guidance.rs:17:8 + --> $DIR/riscv-discoverability-guidance.rs:15:8 | LL | extern "riscv-interrupt" fn isr() {} - | ^^^^^^^^^^^^^^^^^ - | | - | invalid ABI - | help: did you mean: `"riscv-interrupt-m"` + | ^^^^^^^^^^^^^^^^^ invalid ABI | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions +help: there's a similarly named valid ABI `riscv-interrupt-m` + | +LL | extern "riscv-interrupt-m" fn isr() {} + | ++ error[E0703]: invalid ABI: found `riscv-interrupt-u` - --> $DIR/riscv-discoverability-guidance.rs:22:8 + --> $DIR/riscv-discoverability-guidance.rs:20:8 | LL | extern "riscv-interrupt-u" fn isr_U() {} - | ^^^^^^^^^^^^^^^^^^^ - | | - | invalid ABI - | help: did you mean: `"riscv-interrupt-m"` + | ^^^^^^^^^^^^^^^^^^^ invalid ABI | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions +help: there's a similarly named valid ABI `riscv-interrupt-m` + | +LL - extern "riscv-interrupt-u" fn isr_U() {} +LL + extern "riscv-interrupt-m" fn isr_U() {} + | error: aborting due to 2 previous errors diff --git a/tests/ui/abi/riscv-discoverability-guidance.rs b/tests/ui/abi/riscv-discoverability-guidance.rs index dec5059b0a7..41cce35aefa 100644 --- a/tests/ui/abi/riscv-discoverability-guidance.rs +++ b/tests/ui/abi/riscv-discoverability-guidance.rs @@ -1,4 +1,5 @@ // ignore-tidy-linelength +//@ add-core-stubs //@ revisions: riscv32 riscv64 // //@ [riscv32] needs-llvm-components: riscv @@ -6,13 +7,10 @@ //@ [riscv64] needs-llvm-components: riscv //@ [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf -C target-feature=-unaligned-scalar-mem --crate-type=rlib #![no_core] -#![feature( - no_core, - lang_items, - abi_riscv_interrupt -)] -#[lang = "sized"] -trait Sized {} +#![feature(no_core, lang_items, abi_riscv_interrupt)] + +extern crate minicore; +use minicore::*; extern "riscv-interrupt" fn isr() {} //~^ ERROR invalid ABI diff --git a/tests/ui/abi/sparcv8plus-llvm19.rs b/tests/ui/abi/sparcv8plus-llvm19.rs index a884e5ca06f..3d6d8568b6e 100644 --- a/tests/ui/abi/sparcv8plus-llvm19.rs +++ b/tests/ui/abi/sparcv8plus-llvm19.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: sparc sparcv8plus sparc_cpu_v9 sparc_feature_v8plus sparc_cpu_v9_feature_v8plus //@[sparc] compile-flags: --target sparc-unknown-none-elf //@[sparc] needs-llvm-components: sparc @@ -15,10 +16,8 @@ #![feature(no_core, rustc_attrs, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[rustc_builtin_macro] macro_rules! compile_error { diff --git a/tests/ui/abi/sparcv8plus-llvm19.sparc.stderr b/tests/ui/abi/sparcv8plus-llvm19.sparc.stderr index 7eedf26135f..d3462ae87d3 100644 --- a/tests/ui/abi/sparcv8plus-llvm19.sparc.stderr +++ b/tests/ui/abi/sparcv8plus-llvm19.sparc.stderr @@ -1,5 +1,5 @@ error: -v8plus,-v9 - --> $DIR/sparcv8plus-llvm19.rs:29:1 + --> $DIR/sparcv8plus-llvm19.rs:28:1 | LL | compile_error!("-v8plus,-v9"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/sparcv8plus-llvm19.sparc_cpu_v9.stderr b/tests/ui/abi/sparcv8plus-llvm19.sparc_cpu_v9.stderr index ac61df35678..9891aec94b8 100644 --- a/tests/ui/abi/sparcv8plus-llvm19.sparc_cpu_v9.stderr +++ b/tests/ui/abi/sparcv8plus-llvm19.sparc_cpu_v9.stderr @@ -1,5 +1,5 @@ error: +v8plus,+v9 - --> $DIR/sparcv8plus-llvm19.rs:34:1 + --> $DIR/sparcv8plus-llvm19.rs:33:1 | LL | compile_error!("+v8plus,+v9"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/sparcv8plus-llvm19.sparc_cpu_v9_feature_v8plus.stderr b/tests/ui/abi/sparcv8plus-llvm19.sparc_cpu_v9_feature_v8plus.stderr index ac61df35678..9891aec94b8 100644 --- a/tests/ui/abi/sparcv8plus-llvm19.sparc_cpu_v9_feature_v8plus.stderr +++ b/tests/ui/abi/sparcv8plus-llvm19.sparc_cpu_v9_feature_v8plus.stderr @@ -1,5 +1,5 @@ error: +v8plus,+v9 - --> $DIR/sparcv8plus-llvm19.rs:34:1 + --> $DIR/sparcv8plus-llvm19.rs:33:1 | LL | compile_error!("+v8plus,+v9"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/sparcv8plus-llvm19.sparc_feature_v8plus.stderr b/tests/ui/abi/sparcv8plus-llvm19.sparc_feature_v8plus.stderr index 1bf7a3ad76a..dbcdb8ed121 100644 --- a/tests/ui/abi/sparcv8plus-llvm19.sparc_feature_v8plus.stderr +++ b/tests/ui/abi/sparcv8plus-llvm19.sparc_feature_v8plus.stderr @@ -1,5 +1,5 @@ error: +v8plus,-v9 (FIXME) - --> $DIR/sparcv8plus-llvm19.rs:39:1 + --> $DIR/sparcv8plus-llvm19.rs:38:1 | LL | compile_error!("+v8plus,-v9 (FIXME)"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/sparcv8plus-llvm19.sparcv8plus.stderr b/tests/ui/abi/sparcv8plus-llvm19.sparcv8plus.stderr index ac61df35678..9891aec94b8 100644 --- a/tests/ui/abi/sparcv8plus-llvm19.sparcv8plus.stderr +++ b/tests/ui/abi/sparcv8plus-llvm19.sparcv8plus.stderr @@ -1,5 +1,5 @@ error: +v8plus,+v9 - --> $DIR/sparcv8plus-llvm19.rs:34:1 + --> $DIR/sparcv8plus-llvm19.rs:33:1 | LL | compile_error!("+v8plus,+v9"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/sparcv8plus.rs b/tests/ui/abi/sparcv8plus.rs index a78ae0cd328..6c17f721838 100644 --- a/tests/ui/abi/sparcv8plus.rs +++ b/tests/ui/abi/sparcv8plus.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: sparc sparcv8plus sparc_cpu_v9 sparc_feature_v8plus sparc_cpu_v9_feature_v8plus //@[sparc] compile-flags: --target sparc-unknown-none-elf //@[sparc] needs-llvm-components: sparc @@ -15,10 +16,8 @@ #![feature(no_core, rustc_attrs, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; #[rustc_builtin_macro] macro_rules! compile_error { diff --git a/tests/ui/abi/sparcv8plus.sparc.stderr b/tests/ui/abi/sparcv8plus.sparc.stderr index 6d14ff53ab9..e2aa89a9273 100644 --- a/tests/ui/abi/sparcv8plus.sparc.stderr +++ b/tests/ui/abi/sparcv8plus.sparc.stderr @@ -1,5 +1,5 @@ error: -v8plus,-v9 - --> $DIR/sparcv8plus.rs:29:1 + --> $DIR/sparcv8plus.rs:28:1 | LL | compile_error!("-v8plus,-v9"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/sparcv8plus.sparc_cpu_v9.stderr b/tests/ui/abi/sparcv8plus.sparc_cpu_v9.stderr index 00fd7ef4ea8..2c5699f2dec 100644 --- a/tests/ui/abi/sparcv8plus.sparc_cpu_v9.stderr +++ b/tests/ui/abi/sparcv8plus.sparc_cpu_v9.stderr @@ -1,5 +1,5 @@ error: -v8plus,+v9 - --> $DIR/sparcv8plus.rs:42:1 + --> $DIR/sparcv8plus.rs:41:1 | LL | compile_error!("-v8plus,+v9"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/sparcv8plus.sparc_cpu_v9_feature_v8plus.stderr b/tests/ui/abi/sparcv8plus.sparc_cpu_v9_feature_v8plus.stderr index a3c74e67f8f..4b96e4421f9 100644 --- a/tests/ui/abi/sparcv8plus.sparc_cpu_v9_feature_v8plus.stderr +++ b/tests/ui/abi/sparcv8plus.sparc_cpu_v9_feature_v8plus.stderr @@ -1,5 +1,5 @@ error: +v8plus,+v9 - --> $DIR/sparcv8plus.rs:33:1 + --> $DIR/sparcv8plus.rs:32:1 | LL | compile_error!("+v8plus,+v9"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/sparcv8plus.sparc_feature_v8plus.stderr b/tests/ui/abi/sparcv8plus.sparc_feature_v8plus.stderr index 84f560d158c..dfdec88961b 100644 --- a/tests/ui/abi/sparcv8plus.sparc_feature_v8plus.stderr +++ b/tests/ui/abi/sparcv8plus.sparc_feature_v8plus.stderr @@ -1,5 +1,5 @@ error: +v8plus,-v9 (FIXME) - --> $DIR/sparcv8plus.rs:38:1 + --> $DIR/sparcv8plus.rs:37:1 | LL | compile_error!("+v8plus,-v9 (FIXME)"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/sparcv8plus.sparcv8plus.stderr b/tests/ui/abi/sparcv8plus.sparcv8plus.stderr index a3c74e67f8f..4b96e4421f9 100644 --- a/tests/ui/abi/sparcv8plus.sparcv8plus.stderr +++ b/tests/ui/abi/sparcv8plus.sparcv8plus.stderr @@ -1,5 +1,5 @@ error: +v8plus,+v9 - --> $DIR/sparcv8plus.rs:33:1 + --> $DIR/sparcv8plus.rs:32:1 | LL | compile_error!("+v8plus,+v9"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/unsupported.aarch64.stderr b/tests/ui/abi/unsupported.aarch64.stderr index 2eb6ab08232..01f071f1f31 100644 --- a/tests/ui/abi/unsupported.aarch64.stderr +++ b/tests/ui/abi/unsupported.aarch64.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:36:15 + --> $DIR/unsupported.rs:35:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:41:1 + --> $DIR/unsupported.rs:40:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:52:17 + --> $DIR/unsupported.rs:51:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 + --> $DIR/unsupported.rs:64:1 | LL | extern "aapcs" {} | ^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:74:18 + --> $DIR/unsupported.rs:73:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:79:1 + --> $DIR/unsupported.rs:78:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:84:15 + --> $DIR/unsupported.rs:83:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:89:1 + --> $DIR/unsupported.rs:88:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:97:17 + --> $DIR/unsupported.rs:96:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:108:1 + --> $DIR/unsupported.rs:107:1 | LL | extern "riscv-interrupt-m" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:119:15 + --> $DIR/unsupported.rs:118:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:130:1 + --> $DIR/unsupported.rs:129:1 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:142:20 + --> $DIR/unsupported.rs:141:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +99,13 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:155:1 + --> $DIR/unsupported.rs:154:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:168:19 + --> $DIR/unsupported.rs:167:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -114,13 +114,13 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:181:1 + --> $DIR/unsupported.rs:180:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:188:21 + --> $DIR/unsupported.rs:187:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:196:22 + --> $DIR/unsupported.rs:195:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,67 +138,67 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:201:1 + --> $DIR/unsupported.rs:200:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:34:1 + --> $DIR/unsupported.rs:33:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 + --> $DIR/unsupported.rs:42:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:46:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:72:1 + --> $DIR/unsupported.rs:71:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:82:1 + --> $DIR/unsupported.rs:81:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:92:1 + --> $DIR/unsupported.rs:91:1 | LL | extern "riscv-interrupt-m" fn riscv() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:114:1 + --> $DIR/unsupported.rs:113:1 | LL | extern "x86-interrupt" fn x86() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:136:1 + --> $DIR/unsupported.rs:135:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:162:1 + --> $DIR/unsupported.rs:161:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:194:1 + --> $DIR/unsupported.rs:193:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/unsupported.arm.stderr b/tests/ui/abi/unsupported.arm.stderr index ee878379cc6..dfb4b573349 100644 --- a/tests/ui/abi/unsupported.arm.stderr +++ b/tests/ui/abi/unsupported.arm.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:36:15 + --> $DIR/unsupported.rs:35:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:41:1 + --> $DIR/unsupported.rs:40:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:74:18 + --> $DIR/unsupported.rs:73:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:79:1 + --> $DIR/unsupported.rs:78:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:84:15 + --> $DIR/unsupported.rs:83:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:89:1 + --> $DIR/unsupported.rs:88:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:97:17 + --> $DIR/unsupported.rs:96:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:108:1 + --> $DIR/unsupported.rs:107:1 | LL | extern "riscv-interrupt-m" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:119:15 + --> $DIR/unsupported.rs:118:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:130:1 + --> $DIR/unsupported.rs:129:1 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:142:20 + --> $DIR/unsupported.rs:141:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:155:1 + --> $DIR/unsupported.rs:154:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:168:19 + --> $DIR/unsupported.rs:167:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +99,13 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:181:1 + --> $DIR/unsupported.rs:180:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:188:21 + --> $DIR/unsupported.rs:187:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +114,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:196:22 + --> $DIR/unsupported.rs:195:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,61 +123,61 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:201:1 + --> $DIR/unsupported.rs:200:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:34:1 + --> $DIR/unsupported.rs:33:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 + --> $DIR/unsupported.rs:42:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:72:1 + --> $DIR/unsupported.rs:71:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:82:1 + --> $DIR/unsupported.rs:81:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:92:1 + --> $DIR/unsupported.rs:91:1 | LL | extern "riscv-interrupt-m" fn riscv() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:114:1 + --> $DIR/unsupported.rs:113:1 | LL | extern "x86-interrupt" fn x86() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:136:1 + --> $DIR/unsupported.rs:135:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:162:1 + --> $DIR/unsupported.rs:161:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:194:1 + --> $DIR/unsupported.rs:193:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/unsupported.i686.stderr b/tests/ui/abi/unsupported.i686.stderr index 02b2cdd356f..d7b76a4730b 100644 --- a/tests/ui/abi/unsupported.i686.stderr +++ b/tests/ui/abi/unsupported.i686.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:36:15 + --> $DIR/unsupported.rs:35:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:41:1 + --> $DIR/unsupported.rs:40:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:52:17 + --> $DIR/unsupported.rs:51:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 + --> $DIR/unsupported.rs:64:1 | LL | extern "aapcs" {} | ^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:74:18 + --> $DIR/unsupported.rs:73:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:79:1 + --> $DIR/unsupported.rs:78:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:84:15 + --> $DIR/unsupported.rs:83:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:89:1 + --> $DIR/unsupported.rs:88:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:97:17 + --> $DIR/unsupported.rs:96:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:108:1 + --> $DIR/unsupported.rs:107:1 | LL | extern "riscv-interrupt-m" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:188:21 + --> $DIR/unsupported.rs:187:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:196:22 + --> $DIR/unsupported.rs:195:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,49 +93,49 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:201:1 + --> $DIR/unsupported.rs:200:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:34:1 + --> $DIR/unsupported.rs:33:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 + --> $DIR/unsupported.rs:42:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:46:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:72:1 + --> $DIR/unsupported.rs:71:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:82:1 + --> $DIR/unsupported.rs:81:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:92:1 + --> $DIR/unsupported.rs:91:1 | LL | extern "riscv-interrupt-m" fn riscv() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:194:1 + --> $DIR/unsupported.rs:193:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/unsupported.riscv32.stderr b/tests/ui/abi/unsupported.riscv32.stderr index abf403da8bd..eef2ead4f0f 100644 --- a/tests/ui/abi/unsupported.riscv32.stderr +++ b/tests/ui/abi/unsupported.riscv32.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:36:15 + --> $DIR/unsupported.rs:35:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:41:1 + --> $DIR/unsupported.rs:40:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:52:17 + --> $DIR/unsupported.rs:51:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 + --> $DIR/unsupported.rs:64:1 | LL | extern "aapcs" {} | ^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:74:18 + --> $DIR/unsupported.rs:73:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:79:1 + --> $DIR/unsupported.rs:78:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:84:15 + --> $DIR/unsupported.rs:83:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:89:1 + --> $DIR/unsupported.rs:88:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:119:15 + --> $DIR/unsupported.rs:118:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:130:1 + --> $DIR/unsupported.rs:129:1 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:142:20 + --> $DIR/unsupported.rs:141:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:155:1 + --> $DIR/unsupported.rs:154:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:168:19 + --> $DIR/unsupported.rs:167:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +99,13 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:181:1 + --> $DIR/unsupported.rs:180:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:188:21 + --> $DIR/unsupported.rs:187:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +114,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:196:22 + --> $DIR/unsupported.rs:195:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,61 +123,61 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:201:1 + --> $DIR/unsupported.rs:200:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:34:1 + --> $DIR/unsupported.rs:33:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 + --> $DIR/unsupported.rs:42:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:46:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:72:1 + --> $DIR/unsupported.rs:71:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:82:1 + --> $DIR/unsupported.rs:81:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:114:1 + --> $DIR/unsupported.rs:113:1 | LL | extern "x86-interrupt" fn x86() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:136:1 + --> $DIR/unsupported.rs:135:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:162:1 + --> $DIR/unsupported.rs:161:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:194:1 + --> $DIR/unsupported.rs:193:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/unsupported.riscv64.stderr b/tests/ui/abi/unsupported.riscv64.stderr index abf403da8bd..eef2ead4f0f 100644 --- a/tests/ui/abi/unsupported.riscv64.stderr +++ b/tests/ui/abi/unsupported.riscv64.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:36:15 + --> $DIR/unsupported.rs:35:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:41:1 + --> $DIR/unsupported.rs:40:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:52:17 + --> $DIR/unsupported.rs:51:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 + --> $DIR/unsupported.rs:64:1 | LL | extern "aapcs" {} | ^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:74:18 + --> $DIR/unsupported.rs:73:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:79:1 + --> $DIR/unsupported.rs:78:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:84:15 + --> $DIR/unsupported.rs:83:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:89:1 + --> $DIR/unsupported.rs:88:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:119:15 + --> $DIR/unsupported.rs:118:15 | LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:130:1 + --> $DIR/unsupported.rs:129:1 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:142:20 + --> $DIR/unsupported.rs:141:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:155:1 + --> $DIR/unsupported.rs:154:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:168:19 + --> $DIR/unsupported.rs:167:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +99,13 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:181:1 + --> $DIR/unsupported.rs:180:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:188:21 + --> $DIR/unsupported.rs:187:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +114,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:196:22 + --> $DIR/unsupported.rs:195:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,61 +123,61 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:201:1 + --> $DIR/unsupported.rs:200:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:34:1 + --> $DIR/unsupported.rs:33:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 + --> $DIR/unsupported.rs:42:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:46:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:72:1 + --> $DIR/unsupported.rs:71:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:82:1 + --> $DIR/unsupported.rs:81:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:114:1 + --> $DIR/unsupported.rs:113:1 | LL | extern "x86-interrupt" fn x86() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:136:1 + --> $DIR/unsupported.rs:135:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:162:1 + --> $DIR/unsupported.rs:161:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:194:1 + --> $DIR/unsupported.rs:193:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/abi/unsupported.rs b/tests/ui/abi/unsupported.rs index 7d4142f0dee..84646502f6f 100644 --- a/tests/ui/abi/unsupported.rs +++ b/tests/ui/abi/unsupported.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x64 i686 aarch64 arm riscv32 riscv64 // //@ [x64] needs-llvm-components: x86 @@ -25,11 +26,9 @@ abi_c_cmse_nonsecure_call, cmse_nonsecure_entry )] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; extern "ptx-kernel" fn ptx() {} //~^ ERROR is not a supported ABI diff --git a/tests/ui/abi/unsupported.x64.stderr b/tests/ui/abi/unsupported.x64.stderr index 824a33c948a..80613d83e58 100644 --- a/tests/ui/abi/unsupported.x64.stderr +++ b/tests/ui/abi/unsupported.x64.stderr @@ -1,5 +1,5 @@ warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:36:15 + --> $DIR/unsupported.rs:35:15 | LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,13 +9,13 @@ LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:41:1 + --> $DIR/unsupported.rs:40:1 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:52:17 + --> $DIR/unsupported.rs:51:17 | LL | fn aapcs_ptr(f: extern "aapcs" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -24,13 +24,13 @@ LL | fn aapcs_ptr(f: extern "aapcs" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 + --> $DIR/unsupported.rs:64:1 | LL | extern "aapcs" {} | ^^^^^^^^^^^^^^^^^ warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:74:18 + --> $DIR/unsupported.rs:73:18 | LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,13 +39,13 @@ LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:79:1 + --> $DIR/unsupported.rs:78:1 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:84:15 + --> $DIR/unsupported.rs:83:15 | LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,13 +54,13 @@ LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:89:1 + --> $DIR/unsupported.rs:88:1 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:97:17 + --> $DIR/unsupported.rs:96:17 | LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -69,13 +69,13 @@ LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:108:1 + --> $DIR/unsupported.rs:107:1 | LL | extern "riscv-interrupt-m" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:142:20 + --> $DIR/unsupported.rs:141:20 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -84,13 +84,13 @@ LL | fn thiscall_ptr(f: extern "thiscall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:155:1 + --> $DIR/unsupported.rs:154:1 | LL | extern "thiscall" {} | ^^^^^^^^^^^^^^^^^^^^ warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:168:19 + --> $DIR/unsupported.rs:167:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +99,13 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:181:1 + --> $DIR/unsupported.rs:180:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:188:21 + --> $DIR/unsupported.rs:187:21 | LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +114,7 @@ LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:196:22 + --> $DIR/unsupported.rs:195:22 | LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,61 +123,61 @@ LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:201:1 + --> $DIR/unsupported.rs:200:1 | LL | extern "C-cmse-nonsecure-entry" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:34:1 + --> $DIR/unsupported.rs:33:1 | LL | extern "ptx-kernel" fn ptx() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 + --> $DIR/unsupported.rs:42:1 | LL | extern "gpu-kernel" fn gpu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:46:1 + --> $DIR/unsupported.rs:45:1 | LL | extern "aapcs" fn aapcs() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:72:1 + --> $DIR/unsupported.rs:71:1 | LL | extern "msp430-interrupt" fn msp430() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:82:1 + --> $DIR/unsupported.rs:81:1 | LL | extern "avr-interrupt" fn avr() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:92:1 + --> $DIR/unsupported.rs:91:1 | LL | extern "riscv-interrupt-m" fn riscv() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:136:1 + --> $DIR/unsupported.rs:135:1 | LL | extern "thiscall" fn thiscall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:162:1 + --> $DIR/unsupported.rs:161:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:194:1 + --> $DIR/unsupported.rs:193:1 | LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/asm/const-resolve-error.rs b/tests/ui/asm/const-resolve-error.rs new file mode 100644 index 00000000000..19c8af0d542 --- /dev/null +++ b/tests/ui/asm/const-resolve-error.rs @@ -0,0 +1,10 @@ +//@ edition:2021 +//@ needs-asm-support + +use std::arch::asm; + +async unsafe fn foo<'a>() { + asm!("/* {0} */", const N); //~ ERROR E0425 +} + +fn main() {} diff --git a/tests/ui/asm/const-resolve-error.stderr b/tests/ui/asm/const-resolve-error.stderr new file mode 100644 index 00000000000..f02a7f0a6b1 --- /dev/null +++ b/tests/ui/asm/const-resolve-error.stderr @@ -0,0 +1,14 @@ +error[E0425]: cannot find value `N` in this scope + --> $DIR/const-resolve-error.rs:7:29 + | +LL | asm!("/* {0} */", const N); + | ^ not found in this scope + | +help: you might be missing a const parameter + | +LL | async unsafe fn foo<'a, const N: /* Type */>() { + | +++++++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/asm/fail-const-eval-issue-121099.rs b/tests/ui/asm/fail-const-eval-issue-121099.rs index 36d00b1e5d2..c91bbfd1b73 100644 --- a/tests/ui/asm/fail-const-eval-issue-121099.rs +++ b/tests/ui/asm/fail-const-eval-issue-121099.rs @@ -5,6 +5,6 @@ use std::arch::global_asm; fn main() {} -global_asm!("/* {} */", const 1 << 500); //~ ERROR evaluation of constant value failed [E0080] +global_asm!("/* {} */", const 1 << 500); //~ ERROR E0080 -global_asm!("/* {} */", const 1 / 0); //~ ERROR evaluation of constant value failed [E0080] +global_asm!("/* {} */", const 1 / 0); //~ ERROR E0080 diff --git a/tests/ui/asm/fail-const-eval-issue-121099.stderr b/tests/ui/asm/fail-const-eval-issue-121099.stderr index 5d86c3a5f7b..eb662dadffb 100644 --- a/tests/ui/asm/fail-const-eval-issue-121099.stderr +++ b/tests/ui/asm/fail-const-eval-issue-121099.stderr @@ -1,10 +1,10 @@ -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation of `{global_asm#0}::{constant#0}` failed --> $DIR/fail-const-eval-issue-121099.rs:8:31 | LL | global_asm!("/* {} */", const 1 << 500); | ^^^^^^^^ attempt to shift left by `500_i32`, which would overflow -error[E0080]: evaluation of constant value failed +error[E0080]: evaluation of `{global_asm#1}::{constant#0}` failed --> $DIR/fail-const-eval-issue-121099.rs:10:31 | LL | global_asm!("/* {} */", const 1 / 0); diff --git a/tests/ui/asm/invalid-const-operand.stderr b/tests/ui/asm/invalid-const-operand.stderr index 13bb10e84a5..1cedabeef28 100644 --- a/tests/ui/asm/invalid-const-operand.stderr +++ b/tests/ui/asm/invalid-const-operand.stderr @@ -80,7 +80,7 @@ error: invalid type for `const` operand LL | asm!("{}", const &0); | ^^^^^^-- | | - | is a `&i32` + | is a `&{integer}` | = help: `const` operands must be of an integer type diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs index f00aaec1a8c..90fd2c2b4f3 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs @@ -21,6 +21,9 @@ fn foo_path<T: Trait>() where T::method(i32): Send {} fn bar_path<T: Trait>() where T::method() -> (): Send {} //~^ ERROR return type not allowed with return type notation +fn bay_path<T: Trait>() where T::method(..) -> (): Send {} +//~^ ERROR return type not allowed with return type notation + fn baz_path<T: Trait>() where T::method(): Send {} //~^ ERROR return type notation arguments must be elided with `..` diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr index c6b9f3eff90..bd02b7d6534 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr @@ -1,17 +1,29 @@ +error: return type not allowed with return type notation + --> $DIR/bad-inputs-and-output.rs:24:45 + | +LL | fn bay_path<T: Trait>() where T::method(..) -> (): Send {} + | ^^^^^ + | +help: remove the return type + | +LL - fn bay_path<T: Trait>() where T::method(..) -> (): Send {} +LL + fn bay_path<T: Trait>() where T::method(..): Send {} + | + error[E0575]: expected associated type, found associated function `Trait::method` - --> $DIR/bad-inputs-and-output.rs:27:36 + --> $DIR/bad-inputs-and-output.rs:30:36 | LL | fn foo_qualified<T: Trait>() where <T as Trait>::method(i32): Send {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a associated type error[E0575]: expected associated type, found associated function `Trait::method` - --> $DIR/bad-inputs-and-output.rs:30:36 + --> $DIR/bad-inputs-and-output.rs:33:36 | LL | fn bar_qualified<T: Trait>() where <T as Trait>::method() -> (): Send {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a associated type error[E0575]: expected associated type, found associated function `Trait::method` - --> $DIR/bad-inputs-and-output.rs:33:36 + --> $DIR/bad-inputs-and-output.rs:36:36 | LL | fn baz_qualified<T: Trait>() where <T as Trait>::method(): Send {} | ^^^^^^^^^^^^^^^^^^^^^^ not a associated type @@ -20,38 +32,72 @@ error: argument types not allowed with return type notation --> $DIR/bad-inputs-and-output.rs:9:23 | LL | fn foo<T: Trait<method(i32): Send>>() {} - | ^^^^^ help: remove the input types: `()` + | ^^^^^ + | +help: remove the input types + | +LL - fn foo<T: Trait<method(i32): Send>>() {} +LL + fn foo<T: Trait<method(..): Send>>() {} + | error: return type not allowed with return type notation --> $DIR/bad-inputs-and-output.rs:12:25 | LL | fn bar<T: Trait<method() -> (): Send>>() {} - | ^^^^^^ help: remove the return type + | ^^^^^^ + | +help: use the right argument notation and remove the return type + | +LL - fn bar<T: Trait<method() -> (): Send>>() {} +LL + fn bar<T: Trait<method(..): Send>>() {} + | error: return type notation arguments must be elided with `..` --> $DIR/bad-inputs-and-output.rs:15:23 | LL | fn baz<T: Trait<method(): Send>>() {} - | ^^ help: add `..`: `(..)` + | ^^ + | +help: use the correct syntax by adding `..` to the arguments + | +LL | fn baz<T: Trait<method(..): Send>>() {} + | ++ error: argument types not allowed with return type notation --> $DIR/bad-inputs-and-output.rs:18:40 | LL | fn foo_path<T: Trait>() where T::method(i32): Send {} - | ^^^^^ help: remove the input types: `()` + | ^^^^^ + | +help: remove the input types + | +LL - fn foo_path<T: Trait>() where T::method(i32): Send {} +LL + fn foo_path<T: Trait>() where T::method(..): Send {} + | error: return type not allowed with return type notation --> $DIR/bad-inputs-and-output.rs:21:42 | LL | fn bar_path<T: Trait>() where T::method() -> (): Send {} - | ^^^^^^ help: remove the return type + | ^^^^^^ + | +help: use the right argument notation and remove the return type + | +LL - fn bar_path<T: Trait>() where T::method() -> (): Send {} +LL + fn bar_path<T: Trait>() where T::method(..): Send {} + | error: return type notation arguments must be elided with `..` - --> $DIR/bad-inputs-and-output.rs:24:40 + --> $DIR/bad-inputs-and-output.rs:27:40 | LL | fn baz_path<T: Trait>() where T::method(): Send {} - | ^^ help: add `..`: `(..)` + | ^^ + | +help: use the correct syntax by adding `..` to the arguments + | +LL | fn baz_path<T: Trait>() where T::method(..): Send {} + | ++ -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0575`. diff --git a/tests/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.rs b/tests/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.rs index 707bcac78bf..22786043693 100644 --- a/tests/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.rs +++ b/tests/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs // Test that we do not ICE when the self type is `ty::err`, but rather // just propagate the error. @@ -6,17 +7,8 @@ #![feature(no_core)] #![no_core] -#[lang="sized"] -pub trait Sized { - // Empty. -} - -#[lang = "add"] -trait Add<RHS=Self> { - type Output; - - fn add(self, _: RHS) -> Self::Output; -} +extern crate minicore; +use minicore::*; fn ice<A>(a: A) { let r = loop {}; diff --git a/tests/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.stderr b/tests/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.stderr index ebe56c8cd68..0bbb601a6d2 100644 --- a/tests/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.stderr +++ b/tests/ui/associated-types/associated-types-ICE-when-projecting-out-of-err.stderr @@ -1,14 +1,8 @@ error[E0277]: the trait bound `(): Add<A>` is not satisfied - --> $DIR/associated-types-ICE-when-projecting-out-of-err.rs:23:11 + --> $DIR/associated-types-ICE-when-projecting-out-of-err.rs:15:11 | LL | r = r + a; | ^ the trait `Add<A>` is not implemented for `()` - | -help: this trait has no implementations, consider adding one - --> $DIR/associated-types-ICE-when-projecting-out-of-err.rs:15:1 - | -LL | trait Add<RHS=Self> { - | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/issue-81899.rs b/tests/ui/borrowck/issue-81899.rs index 1f1af5c7e05..380c03751f5 100644 --- a/tests/ui/borrowck/issue-81899.rs +++ b/tests/ui/borrowck/issue-81899.rs @@ -1,15 +1,14 @@ // Regression test for #81899. // The `panic!()` below is important to trigger the fixed ICE. -const _CONST: &[u8] = &f(&[], |_| {}); +const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed //~^ constant const fn f<F>(_: &[u8], _: F) -> &[u8] where F: FnMut(&u8), { - panic!() //~ ERROR evaluation of constant value failed - //~^ panic + panic!() //~ inside `f } fn main() {} diff --git a/tests/ui/borrowck/issue-81899.stderr b/tests/ui/borrowck/issue-81899.stderr index 1da573ea97c..2e6e7511ec9 100644 --- a/tests/ui/borrowck/issue-81899.stderr +++ b/tests/ui/borrowck/issue-81899.stderr @@ -1,19 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/issue-81899.rs:11:5 + --> $DIR/issue-81899.rs:4:24 | -LL | panic!() - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-81899.rs:11:5 +LL | const _CONST: &[u8] = &f(&[], |_| {}); + | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic | note: inside `f::<{closure@$DIR/issue-81899.rs:4:31: 4:34}>` --> $DIR/issue-81899.rs:11:5 | LL | panic!() - | ^^^^^^^^ -note: inside `_CONST` - --> $DIR/issue-81899.rs:4:24 - | -LL | const _CONST: &[u8] = &f(&[], |_| {}); - | ^^^^^^^^^^^^^^ + | ^^^^^^^^ the failure occurred here = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered diff --git a/tests/ui/borrowck/issue-88434-minimal-example.rs b/tests/ui/borrowck/issue-88434-minimal-example.rs index b75abcb731e..ebaa9a92273 100644 --- a/tests/ui/borrowck/issue-88434-minimal-example.rs +++ b/tests/ui/borrowck/issue-88434-minimal-example.rs @@ -1,14 +1,13 @@ // Regression test related to issue 88434 -const _CONST: &() = &f(&|_| {}); +const _CONST: &() = &f(&|_| {}); //~ ERROR evaluation of constant value failed //~^ constant const fn f<F>(_: &F) where F: FnMut(&u8), { - panic!() //~ ERROR evaluation of constant value failed - //~^ panic + panic!() //~ inside `f } fn main() { } diff --git a/tests/ui/borrowck/issue-88434-minimal-example.stderr b/tests/ui/borrowck/issue-88434-minimal-example.stderr index b32331ce448..c8ac13a3473 100644 --- a/tests/ui/borrowck/issue-88434-minimal-example.stderr +++ b/tests/ui/borrowck/issue-88434-minimal-example.stderr @@ -1,19 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/issue-88434-minimal-example.rs:10:5 + --> $DIR/issue-88434-minimal-example.rs:3:22 | -LL | panic!() - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-88434-minimal-example.rs:10:5 +LL | const _CONST: &() = &f(&|_| {}); + | ^^^^^^^^^^ evaluation panicked: explicit panic | note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28}>` --> $DIR/issue-88434-minimal-example.rs:10:5 | LL | panic!() - | ^^^^^^^^ -note: inside `_CONST` - --> $DIR/issue-88434-minimal-example.rs:3:22 - | -LL | const _CONST: &() = &f(&|_| {}); - | ^^^^^^^^^^ + | ^^^^^^^^ the failure occurred here = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered diff --git a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs index f9134e669dc..8d042630424 100644 --- a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs +++ b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.rs @@ -1,14 +1,13 @@ // Regression test for issue 88434 -const _CONST: &[u8] = &f(&[], |_| {}); +const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed //~^ constant const fn f<F>(_: &[u8], _: F) -> &[u8] where F: FnMut(&u8), { - panic!() //~ ERROR evaluation of constant value failed - //~^ panic + panic!() //~ inside `f } fn main() { } diff --git a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr index e3c881dd465..0041759609c 100644 --- a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr +++ b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr @@ -1,19 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 + --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24 | -LL | panic!() - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-88434-removal-index-should-be-less.rs:10:5 +LL | const _CONST: &[u8] = &f(&[], |_| {}); + | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic | note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>` --> $DIR/issue-88434-removal-index-should-be-less.rs:10:5 | LL | panic!() - | ^^^^^^^^ -note: inside `_CONST` - --> $DIR/issue-88434-removal-index-should-be-less.rs:3:24 - | -LL | const _CONST: &[u8] = &f(&[], |_| {}); - | ^^^^^^^^^^^^^^ + | ^^^^^^^^ the failure occurred here = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered diff --git a/tests/ui/borrowck/issue-92157.rs b/tests/ui/borrowck/issue-92157.rs index a2b685cdf6e..72f216e301d 100644 --- a/tests/ui/borrowck/issue-92157.rs +++ b/tests/ui/borrowck/issue-92157.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs #![feature(no_core)] #![feature(lang_items)] @@ -13,28 +14,7 @@ fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize { 40+2 } -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} - -#[lang = "drop_in_place"] -#[allow(unconditional_recursion)] -pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { - drop_in_place(to_drop) -} - -#[lang = "add"] -trait Add<RHS> { - type Output; - fn add(self, other: RHS) -> Self::Output; -} - -impl Add<isize> for isize { - type Output = isize; - fn add(self, other: isize) -> isize { - self + other - } -} +extern crate minicore; +use minicore::*; fn main() {} diff --git a/tests/ui/borrowck/issue-92157.stderr b/tests/ui/borrowck/issue-92157.stderr index 0ffedccd690..248d700ab4b 100644 --- a/tests/ui/borrowck/issue-92157.stderr +++ b/tests/ui/borrowck/issue-92157.stderr @@ -1,5 +1,5 @@ error[E0308]: lang item `start` function has wrong type - --> $DIR/issue-92157.rs:11:1 + --> $DIR/issue-92157.rs:12:1 | LL | fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters diff --git a/tests/ui/c-variadic/variadic-ffi-1.rs b/tests/ui/c-variadic/variadic-ffi-1.rs index e41ab269211..9dcd55d13e3 100644 --- a/tests/ui/c-variadic/variadic-ffi-1.rs +++ b/tests/ui/c-variadic/variadic-ffi-1.rs @@ -1,9 +1,11 @@ +//@ add-core-stubs //@ needs-llvm-components: x86 //@ compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib #![no_core] #![feature(no_core, lang_items)] -#[lang="sized"] -trait Sized { } + +extern crate minicore; +use minicore::*; extern "stdcall" { fn printf(_: *const u8, ...); diff --git a/tests/ui/c-variadic/variadic-ffi-1.stderr b/tests/ui/c-variadic/variadic-ffi-1.stderr index 39dfb2548a3..f99abed0a62 100644 --- a/tests/ui/c-variadic/variadic-ffi-1.stderr +++ b/tests/ui/c-variadic/variadic-ffi-1.stderr @@ -1,17 +1,17 @@ error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi` - --> $DIR/variadic-ffi-1.rs:9:5 + --> $DIR/variadic-ffi-1.rs:11:5 | LL | fn printf(_: *const u8, ...); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error[E0060]: this function takes at least 2 arguments but 0 arguments were supplied - --> $DIR/variadic-ffi-1.rs:22:9 + --> $DIR/variadic-ffi-1.rs:24:9 | LL | foo(); | ^^^-- two arguments of type `isize` and `u8` are missing | note: function defined here - --> $DIR/variadic-ffi-1.rs:15:8 + --> $DIR/variadic-ffi-1.rs:17:8 | LL | fn foo(f: isize, x: u8, ...); | ^^^ - - @@ -21,13 +21,13 @@ LL | foo(/* isize */, /* u8 */); | +++++++++++++++++++++ error[E0060]: this function takes at least 2 arguments but 1 argument was supplied - --> $DIR/variadic-ffi-1.rs:23:9 + --> $DIR/variadic-ffi-1.rs:25:9 | LL | foo(1); | ^^^--- argument #2 of type `u8` is missing | note: function defined here - --> $DIR/variadic-ffi-1.rs:15:8 + --> $DIR/variadic-ffi-1.rs:17:8 | LL | fn foo(f: isize, x: u8, ...); | ^^^ - @@ -37,7 +37,7 @@ LL | foo(1, /* u8 */); | ++++++++++ error[E0308]: mismatched types - --> $DIR/variadic-ffi-1.rs:25:56 + --> $DIR/variadic-ffi-1.rs:27:56 | LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo; | ------------------------------------- ^^^ expected non-variadic fn, found variadic function @@ -48,7 +48,7 @@ LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo; found fn item `unsafe extern "C" fn(_, _, ...) {foo}` error[E0308]: mismatched types - --> $DIR/variadic-ffi-1.rs:26:54 + --> $DIR/variadic-ffi-1.rs:28:54 | LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar; | ----------------------------------- ^^^ expected variadic fn, found non-variadic function @@ -59,7 +59,7 @@ LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar; found fn item `extern "C" fn(_, _) {bar}` error[E0617]: can't pass `f32` to variadic function - --> $DIR/variadic-ffi-1.rs:28:19 + --> $DIR/variadic-ffi-1.rs:30:19 | LL | foo(1, 2, 3f32); | ^^^^ @@ -70,7 +70,7 @@ LL | foo(1, 2, 3f32 as c_double); | +++++++++++ error[E0617]: can't pass `bool` to variadic function - --> $DIR/variadic-ffi-1.rs:29:19 + --> $DIR/variadic-ffi-1.rs:31:19 | LL | foo(1, 2, true); | ^^^^ @@ -81,7 +81,7 @@ LL | foo(1, 2, true as c_int); | ++++++++ error[E0617]: can't pass `i8` to variadic function - --> $DIR/variadic-ffi-1.rs:30:19 + --> $DIR/variadic-ffi-1.rs:32:19 | LL | foo(1, 2, 1i8); | ^^^ @@ -92,7 +92,7 @@ LL | foo(1, 2, 1i8 as c_int); | ++++++++ error[E0617]: can't pass `u8` to variadic function - --> $DIR/variadic-ffi-1.rs:31:19 + --> $DIR/variadic-ffi-1.rs:33:19 | LL | foo(1, 2, 1u8); | ^^^ @@ -103,7 +103,7 @@ LL | foo(1, 2, 1u8 as c_uint); | +++++++++ error[E0617]: can't pass `i16` to variadic function - --> $DIR/variadic-ffi-1.rs:32:19 + --> $DIR/variadic-ffi-1.rs:34:19 | LL | foo(1, 2, 1i16); | ^^^^ @@ -114,7 +114,7 @@ LL | foo(1, 2, 1i16 as c_int); | ++++++++ error[E0617]: can't pass `u16` to variadic function - --> $DIR/variadic-ffi-1.rs:33:19 + --> $DIR/variadic-ffi-1.rs:35:19 | LL | foo(1, 2, 1u16); | ^^^^ diff --git a/tests/ui/check-cfg/my-awesome-platform.json b/tests/ui/check-cfg/my-awesome-platform.json index 5e9ab8f1a2d..03b08b727bd 100644 --- a/tests/ui/check-cfg/my-awesome-platform.json +++ b/tests/ui/check-cfg/my-awesome-platform.json @@ -1,6 +1,6 @@ { "llvm-target": "x86_64-unknown-none-gnu", - "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", "arch": "x86_64", "target-endian": "little", "target-pointer-width": "64", diff --git a/tests/ui/check-cfg/values-target-json.rs b/tests/ui/check-cfg/values-target-json.rs index b52decdf6c0..d473f39c3d6 100644 --- a/tests/ui/check-cfg/values-target-json.rs +++ b/tests/ui/check-cfg/values-target-json.rs @@ -1,5 +1,6 @@ // This test checks that we don't lint values defined by a custom target (target json) // +//@ add-core-stubs //@ check-pass //@ no-auto-check-cfg //@ needs-llvm-components: x86 @@ -8,8 +9,8 @@ #![feature(lang_items, no_core, auto_traits)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; #[cfg(target_os = "linux")] fn target_os_linux() {} diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/callback-as-argument.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/callback-as-argument.rs index 37c8319d98d..b25a81b858b 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/callback-as-argument.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/callback-as-argument.rs @@ -1,13 +1,12 @@ +//@ add-core-stubs //@ build-pass //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm #![feature(abi_c_cmse_nonsecure_call, cmse_nonsecure_entry, no_core, lang_items, intrinsics)] #![no_core] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} -impl Copy for u32 {} + +extern crate minicore; +use minicore::*; #[no_mangle] pub extern "C-cmse-nonsecure-entry" fn test( diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs index 31782b05105..18041b08061 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs @@ -1,12 +1,11 @@ +//@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm #![feature(abi_c_cmse_nonsecure_call, no_core, lang_items)] #![no_core] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} -impl Copy for u32 {} + +extern crate minicore; +use minicore::*; #[repr(C)] struct Wrapper<T>(T); diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr index 0560f0eec1c..ab7c9cee4f0 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr @@ -1,11 +1,11 @@ error: function pointer types may not have generic parameters - --> $DIR/generics.rs:15:42 + --> $DIR/generics.rs:14:42 | LL | f1: extern "C-cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, | ^^^^^^^^^ error[E0412]: cannot find type `U` in this scope - --> $DIR/generics.rs:15:52 + --> $DIR/generics.rs:14:52 | LL | struct Test<T: Copy> { | - similarly named type parameter `T` defined here @@ -23,7 +23,7 @@ LL | struct Test<T: Copy, U> { | +++ error[E0562]: `impl Trait` is not allowed in `fn` pointer parameters - --> $DIR/generics.rs:18:43 + --> $DIR/generics.rs:17:43 | LL | f2: extern "C-cmse-nonsecure-call" fn(impl Copy, u32, u32, u32) -> u64, | ^^^^^^^^^ @@ -31,19 +31,19 @@ LL | f2: extern "C-cmse-nonsecure-call" fn(impl Copy, u32, u32, u32) -> u64, = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0798]: function pointers with the `"C-cmse-nonsecure-call"` ABI cannot contain generics in their type - --> $DIR/generics.rs:20:9 + --> $DIR/generics.rs:19:9 | LL | f3: extern "C-cmse-nonsecure-call" fn(T, u32, u32, u32) -> u64, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0798]: function pointers with the `"C-cmse-nonsecure-call"` ABI cannot contain generics in their type - --> $DIR/generics.rs:21:9 + --> $DIR/generics.rs:20:9 | LL | f4: extern "C-cmse-nonsecure-call" fn(Wrapper<T>, u32, u32, u32) -> u64, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/generics.rs:27:73 + --> $DIR/generics.rs:26:73 | LL | type WithTraitObject = extern "C-cmse-nonsecure-call" fn(&dyn Trait) -> &dyn Trait; | ^^^^^^^^^^ this type doesn't fit in the available registers @@ -52,7 +52,7 @@ LL | type WithTraitObject = extern "C-cmse-nonsecure-call" fn(&dyn Trait) -> &dy = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/generics.rs:31:62 + --> $DIR/generics.rs:30:62 | LL | extern "C-cmse-nonsecure-call" fn(&'static dyn Trait) -> &'static dyn Trait; | ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers @@ -61,7 +61,7 @@ LL | extern "C-cmse-nonsecure-call" fn(&'static dyn Trait) -> &'static dyn T = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/generics.rs:38:62 + --> $DIR/generics.rs:37:62 | LL | extern "C-cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTransparent; | ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers @@ -70,7 +70,7 @@ LL | extern "C-cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTranspa = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi` - --> $DIR/generics.rs:41:20 + --> $DIR/generics.rs:40:20 | LL | type WithVarArgs = extern "C-cmse-nonsecure-call" fn(u32, ...); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.rs index 083a563bd7b..8328f9b6dd5 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.rs @@ -1,12 +1,11 @@ +//@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm #![feature(abi_c_cmse_nonsecure_call, no_core, lang_items)] #![no_core] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} -impl Copy for u32 {} + +extern crate minicore; +use minicore::*; #[repr(C, align(16))] #[allow(unused)] diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.stderr index a5f5e1c3151..10a5e856107 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.stderr @@ -1,5 +1,5 @@ error[E0798]: arguments for `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/params-via-stack.rs:17:63 + --> $DIR/params-via-stack.rs:16:63 | LL | f1: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, x: u32, y: u32), | ^^^^^^^^^^^^^^ these arguments don't fit in the available registers @@ -7,7 +7,7 @@ LL | f1: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, x: u32, y: u3 = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers error[E0798]: arguments for `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/params-via-stack.rs:18:63 + --> $DIR/params-via-stack.rs:17:63 | LL | f2: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u16, u16), | ^^^ this argument doesn't fit in the available registers @@ -15,7 +15,7 @@ LL | f2: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u16, u16), = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers error[E0798]: arguments for `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/params-via-stack.rs:19:53 + --> $DIR/params-via-stack.rs:18:53 | LL | f3: extern "C-cmse-nonsecure-call" fn(u32, u64, u32), | ^^^ this argument doesn't fit in the available registers @@ -23,7 +23,7 @@ LL | f3: extern "C-cmse-nonsecure-call" fn(u32, u64, u32), = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers error[E0798]: arguments for `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/params-via-stack.rs:20:58 + --> $DIR/params-via-stack.rs:19:58 | LL | f4: extern "C-cmse-nonsecure-call" fn(AlignRelevant, u32), | ^^^ this argument doesn't fit in the available registers @@ -31,7 +31,7 @@ LL | f4: extern "C-cmse-nonsecure-call" fn(AlignRelevant, u32), = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers error[E0798]: arguments for `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/params-via-stack.rs:21:43 + --> $DIR/params-via-stack.rs:20:43 | LL | f5: extern "C-cmse-nonsecure-call" fn([u32; 5]), | ^^^^^^^^ this argument doesn't fit in the available registers diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs index b052aabb499..890ec4b00f6 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm //@ add-core-stubs diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr index 89f7f159d6e..d2077352900 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr @@ -1,5 +1,5 @@ error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:35:50 + --> $DIR/return-via-stack.rs:36:50 | LL | u128: extern "C-cmse-nonsecure-call" fn() -> u128, | ^^^^ this type doesn't fit in the available registers @@ -8,7 +8,7 @@ LL | u128: extern "C-cmse-nonsecure-call" fn() -> u128, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:36:50 + --> $DIR/return-via-stack.rs:37:50 | LL | i128: extern "C-cmse-nonsecure-call" fn() -> i128, | ^^^^ this type doesn't fit in the available registers @@ -17,7 +17,7 @@ LL | i128: extern "C-cmse-nonsecure-call" fn() -> i128, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:25:48 + --> $DIR/return-via-stack.rs:26:48 | LL | f1: extern "C-cmse-nonsecure-call" fn() -> ReprCU64, | ^^^^^^^^ this type doesn't fit in the available registers @@ -26,7 +26,7 @@ LL | f1: extern "C-cmse-nonsecure-call" fn() -> ReprCU64, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:26:48 + --> $DIR/return-via-stack.rs:27:48 | LL | f2: extern "C-cmse-nonsecure-call" fn() -> ReprCBytes, | ^^^^^^^^^^ this type doesn't fit in the available registers @@ -35,7 +35,7 @@ LL | f2: extern "C-cmse-nonsecure-call" fn() -> ReprCBytes, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:27:48 + --> $DIR/return-via-stack.rs:28:48 | LL | f3: extern "C-cmse-nonsecure-call" fn() -> U64Compound, | ^^^^^^^^^^^ this type doesn't fit in the available registers @@ -44,7 +44,7 @@ LL | f3: extern "C-cmse-nonsecure-call" fn() -> U64Compound, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:28:48 + --> $DIR/return-via-stack.rs:29:48 | LL | f4: extern "C-cmse-nonsecure-call" fn() -> ReprCAlign16, | ^^^^^^^^^^^^ this type doesn't fit in the available registers @@ -53,7 +53,7 @@ LL | f4: extern "C-cmse-nonsecure-call" fn() -> ReprCAlign16, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:29:48 + --> $DIR/return-via-stack.rs:30:48 | LL | f5: extern "C-cmse-nonsecure-call" fn() -> [u8; 5], | ^^^^^^^ this type doesn't fit in the available registers @@ -62,7 +62,7 @@ LL | f5: extern "C-cmse-nonsecure-call" fn() -> [u8; 5], = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:51:48 + --> $DIR/return-via-stack.rs:52:48 | LL | f1: extern "C-cmse-nonsecure-call" fn() -> ReprRustUnionU64, | ^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers @@ -71,7 +71,7 @@ LL | f1: extern "C-cmse-nonsecure-call" fn() -> ReprRustUnionU64, = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:52:48 + --> $DIR/return-via-stack.rs:53:48 | LL | f2: extern "C-cmse-nonsecure-call" fn() -> ReprCUnionU64, | ^^^^^^^^^^^^^ this type doesn't fit in the available registers diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/via-registers.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/via-registers.rs index 9fda55c2a48..7dfe6cf9672 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/via-registers.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/via-registers.rs @@ -1,13 +1,12 @@ +//@ add-core-stubs //@ build-pass //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm #![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)] #![no_core] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} -impl Copy for u32 {} + +extern crate minicore; +use minicore::*; #[repr(transparent)] pub struct ReprTransparentStruct<T> { diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs index 3265cf4146d..5a2d2db19c5 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs @@ -1,8 +1,10 @@ +//@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm #![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)] #![no_core] -#[lang="sized"] -trait Sized { } + +extern crate minicore; +use minicore::*; pub extern "C-cmse-nonsecure-call" fn test() {} //~ ERROR [E0781] diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr index 8d1b10eaeb5..f49fab043a4 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr @@ -1,5 +1,5 @@ error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers - --> $DIR/wrong-abi-location-1.rs:8:1 + --> $DIR/wrong-abi-location-1.rs:10:1 | LL | pub extern "C-cmse-nonsecure-call" fn test() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs index b47471c6ad7..e93b153949a 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs @@ -1,9 +1,11 @@ +//@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm #![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)] #![no_core] -#[lang="sized"] -trait Sized { } + +extern crate minicore; +use minicore::*; extern "C-cmse-nonsecure-call" { //~ ERROR [E0781] fn test(); diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr index 917098e21d8..bae8d20d81c 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr @@ -1,5 +1,5 @@ error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers - --> $DIR/wrong-abi-location-2.rs:8:1 + --> $DIR/wrong-abi-location-2.rs:10:1 | LL | / extern "C-cmse-nonsecure-call" { LL | | fn test(); diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs index a264bba6f3c..19b6179dde7 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs @@ -1,12 +1,11 @@ +//@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm #![feature(cmse_nonsecure_entry, c_variadic, no_core, lang_items)] #![no_core] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} -impl Copy for u32 {} + +extern crate minicore; +use minicore::*; #[repr(C)] struct Wrapper<T>(T); diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr index 9e67f881f75..c314671dc29 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr @@ -1,11 +1,11 @@ error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg - --> $DIR/generics.rs:74:55 + --> $DIR/generics.rs:73:55 | LL | extern "C-cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { | ^^^^^^ error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type - --> $DIR/generics.rs:31:1 + --> $DIR/generics.rs:30:1 | LL | / extern "C-cmse-nonsecure-entry" fn introduced_generic<U: Copy>( LL | | @@ -17,19 +17,19 @@ LL | | ) -> u64 { | |________^ error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type - --> $DIR/generics.rs:41:1 + --> $DIR/generics.rs:40:1 | LL | extern "C-cmse-nonsecure-entry" fn impl_trait(_: impl Copy, _: u32, _: u32, _: u32) -> u64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type - --> $DIR/generics.rs:15:5 + --> $DIR/generics.rs:14:5 | LL | extern "C-cmse-nonsecure-entry" fn ambient_generic(_: T, _: u32, _: u32, _: u32) -> u64 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type - --> $DIR/generics.rs:20:5 + --> $DIR/generics.rs:19:5 | LL | / extern "C-cmse-nonsecure-entry" fn ambient_generic_nested( LL | | @@ -41,7 +41,7 @@ LL | | ) -> u64 { | |____________^ error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/generics.rs:52:67 + --> $DIR/generics.rs:51:67 | LL | extern "C-cmse-nonsecure-entry" fn trait_object(x: &dyn Trait) -> &dyn Trait { | ^^^^^^^^^^ this type doesn't fit in the available registers @@ -50,7 +50,7 @@ LL | extern "C-cmse-nonsecure-entry" fn trait_object(x: &dyn Trait) -> &dyn Trai = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/generics.rs:59:6 + --> $DIR/generics.rs:58:6 | LL | ) -> &'static dyn Trait { | ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers @@ -59,7 +59,7 @@ LL | ) -> &'static dyn Trait { = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/generics.rs:69:6 + --> $DIR/generics.rs:68:6 | LL | ) -> WrapperTransparent { | ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers @@ -68,7 +68,7 @@ LL | ) -> WrapperTransparent { = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error: requires `va_list` lang_item - --> $DIR/generics.rs:74:55 + --> $DIR/generics.rs:73:55 | LL | extern "C-cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { | ^^^^^^ diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs index 572d792d5a5..4c53f9422da 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs @@ -1,12 +1,11 @@ +//@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm #![feature(cmse_nonsecure_entry, no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -impl Copy for u32 {} + +extern crate minicore; +use minicore::*; #[repr(C, align(16))] #[allow(unused)] diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr index b77e64c6bfb..24e9ddf32fe 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr @@ -1,5 +1,5 @@ error[E0798]: arguments for `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:16:78 + --> $DIR/params-via-stack.rs:15:78 | LL | pub extern "C-cmse-nonsecure-entry" fn f1(_: u32, _: u32, _: u32, _: u32, _: u32, _: u32) {} | ^^^^^^^^^^^ these arguments don't fit in the available registers @@ -7,7 +7,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn f1(_: u32, _: u32, _: u32, _: u32, _ = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers error[E0798]: arguments for `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:18:78 + --> $DIR/params-via-stack.rs:17:78 | LL | pub extern "C-cmse-nonsecure-entry" fn f2(_: u32, _: u32, _: u32, _: u16, _: u16) {} | ^^^ this argument doesn't fit in the available registers @@ -15,7 +15,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn f2(_: u32, _: u32, _: u32, _: u16, _ = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers error[E0798]: arguments for `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:20:62 + --> $DIR/params-via-stack.rs:19:62 | LL | pub extern "C-cmse-nonsecure-entry" fn f3(_: u32, _: u64, _: u32) {} | ^^^ this argument doesn't fit in the available registers @@ -23,7 +23,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn f3(_: u32, _: u64, _: u32) {} = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers error[E0798]: arguments for `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:22:64 + --> $DIR/params-via-stack.rs:21:64 | LL | pub extern "C-cmse-nonsecure-entry" fn f4(_: AlignRelevant, _: u32) {} | ^^^ this argument doesn't fit in the available registers @@ -31,7 +31,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn f4(_: AlignRelevant, _: u32) {} = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers error[E0798]: arguments for `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:26:46 + --> $DIR/params-via-stack.rs:25:46 | LL | pub extern "C-cmse-nonsecure-entry" fn f5(_: [u32; 5]) {} | ^^^^^^^^ this argument doesn't fit in the available registers diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.rs index 23d55526e57..735eab10fa1 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm //@ add-core-stubs diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.stderr index d37d9b5e8ff..9c885d95318 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.stderr @@ -1,5 +1,5 @@ error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:24:48 + --> $DIR/return-via-stack.rs:25:48 | LL | pub extern "C-cmse-nonsecure-entry" fn f1() -> ReprCU64 { | ^^^^^^^^ this type doesn't fit in the available registers @@ -8,7 +8,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn f1() -> ReprCU64 { = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:29:48 + --> $DIR/return-via-stack.rs:30:48 | LL | pub extern "C-cmse-nonsecure-entry" fn f2() -> ReprCBytes { | ^^^^^^^^^^ this type doesn't fit in the available registers @@ -17,7 +17,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn f2() -> ReprCBytes { = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:34:48 + --> $DIR/return-via-stack.rs:35:48 | LL | pub extern "C-cmse-nonsecure-entry" fn f3() -> U64Compound { | ^^^^^^^^^^^ this type doesn't fit in the available registers @@ -26,7 +26,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn f3() -> U64Compound { = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:39:48 + --> $DIR/return-via-stack.rs:40:48 | LL | pub extern "C-cmse-nonsecure-entry" fn f4() -> ReprCAlign16 { | ^^^^^^^^^^^^ this type doesn't fit in the available registers @@ -35,7 +35,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn f4() -> ReprCAlign16 { = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:46:48 + --> $DIR/return-via-stack.rs:47:48 | LL | pub extern "C-cmse-nonsecure-entry" fn f5() -> [u8; 5] { | ^^^^^^^ this type doesn't fit in the available registers @@ -44,7 +44,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn f5() -> [u8; 5] { = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:52:50 + --> $DIR/return-via-stack.rs:53:50 | LL | pub extern "C-cmse-nonsecure-entry" fn u128() -> u128 { | ^^^^ this type doesn't fit in the available registers @@ -53,7 +53,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn u128() -> u128 { = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:58:50 + --> $DIR/return-via-stack.rs:59:50 | LL | pub extern "C-cmse-nonsecure-entry" fn i128() -> i128 { | ^^^^ this type doesn't fit in the available registers @@ -62,7 +62,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn i128() -> i128 { = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:75:56 + --> $DIR/return-via-stack.rs:76:56 | LL | pub extern "C-cmse-nonsecure-entry" fn union_rust() -> ReprRustUnionU64 { | ^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers @@ -71,7 +71,7 @@ LL | pub extern "C-cmse-nonsecure-entry" fn union_rust() -> ReprRustUnionU64 { = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:80:53 + --> $DIR/return-via-stack.rs:81:53 | LL | pub extern "C-cmse-nonsecure-entry" fn union_c() -> ReprCUnionU64 { | ^^^^^^^^^^^^^ this type doesn't fit in the available registers diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.aarch64.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.aarch64.stderr index 26409279fbe..6a90dc8d635 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.aarch64.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.aarch64.stderr @@ -1,5 +1,5 @@ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/trustzone-only.rs:20:1 + --> $DIR/trustzone-only.rs:17:1 | LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs index a4ea7a1757d..6d84dab2166 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: x86 aarch64 thumb7 // //@[x86] compile-flags: --target x86_64-unknown-linux-gnu @@ -9,12 +10,8 @@ #![feature(no_core, lang_items, rustc_attrs, cmse_nonsecure_entry)] #![no_core] -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -impl Copy for u32 {} +extern crate minicore; +use minicore::*; #[no_mangle] pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.thumb7.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.thumb7.stderr index 26409279fbe..6a90dc8d635 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.thumb7.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.thumb7.stderr @@ -1,5 +1,5 @@ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/trustzone-only.rs:20:1 + --> $DIR/trustzone-only.rs:17:1 | LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.x86.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.x86.stderr index 26409279fbe..6a90dc8d635 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.x86.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.x86.stderr @@ -1,5 +1,5 @@ error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/trustzone-only.rs:20:1 + --> $DIR/trustzone-only.rs:17:1 | LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs index 8978b35d356..912fc8b85eb 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs @@ -1,15 +1,13 @@ +//@ add-core-stubs //@ build-pass //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm #![feature(cmse_nonsecure_entry, no_core, lang_items)] #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -trait Copy {} -impl Copy for u32 {} -impl Copy for u8 {} + +extern crate minicore; +use minicore::*; #[repr(transparent)] pub struct ReprTransparentStruct<T> { diff --git a/tests/ui/coherence/const-errs-dont-conflict-103369.rs b/tests/ui/coherence/const-errs-dont-conflict-103369.rs index c7d46a8000d..14937e0f02e 100644 --- a/tests/ui/coherence/const-errs-dont-conflict-103369.rs +++ b/tests/ui/coherence/const-errs-dont-conflict-103369.rs @@ -2,13 +2,12 @@ pub trait ConstGenericTrait<const N: u32> {} -impl ConstGenericTrait<{my_fn(1)}> for () {} +impl ConstGenericTrait<{my_fn(1)}> for () {} //~ ERROR E0080 -impl ConstGenericTrait<{my_fn(2)}> for () {} +impl ConstGenericTrait<{my_fn(2)}> for () {} //~ ERROR E0080 const fn my_fn(v: u32) -> u32 { - panic!("Some error occurred"); //~ ERROR E0080 - //~| ERROR E0080 + panic!("Some error occurred"); } fn main() {} diff --git a/tests/ui/coherence/const-errs-dont-conflict-103369.stderr b/tests/ui/coherence/const-errs-dont-conflict-103369.stderr index 22066d6b6bd..4acaaf22ae8 100644 --- a/tests/ui/coherence/const-errs-dont-conflict-103369.stderr +++ b/tests/ui/coherence/const-errs-dont-conflict-103369.stderr @@ -1,37 +1,27 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const-errs-dont-conflict-103369.rs:10:5 + --> $DIR/const-errs-dont-conflict-103369.rs:5:25 | -LL | panic!("Some error occurred"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'Some error occurred', $DIR/const-errs-dont-conflict-103369.rs:10:5 +LL | impl ConstGenericTrait<{my_fn(1)}> for () {} + | ^^^^^^^^ evaluation panicked: Some error occurred | note: inside `my_fn` --> $DIR/const-errs-dont-conflict-103369.rs:10:5 | LL | panic!("Some error occurred"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `<() as ConstGenericTrait<{my_fn(1)}>>::{constant#0}` - --> $DIR/const-errs-dont-conflict-103369.rs:5:25 - | -LL | impl ConstGenericTrait<{my_fn(1)}> for () {} - | ^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed - --> $DIR/const-errs-dont-conflict-103369.rs:10:5 + --> $DIR/const-errs-dont-conflict-103369.rs:7:25 | -LL | panic!("Some error occurred"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'Some error occurred', $DIR/const-errs-dont-conflict-103369.rs:10:5 +LL | impl ConstGenericTrait<{my_fn(2)}> for () {} + | ^^^^^^^^ evaluation panicked: Some error occurred | note: inside `my_fn` --> $DIR/const-errs-dont-conflict-103369.rs:10:5 | LL | panic!("Some error occurred"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `<() as ConstGenericTrait<{my_fn(2)}>>::{constant#0}` - --> $DIR/const-errs-dont-conflict-103369.rs:7:25 - | -LL | impl ConstGenericTrait<{my_fn(2)}> for () {} - | ^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr b/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr index 539d840f0a8..f639e276f46 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.full.stderr @@ -3,16 +3,12 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); | ^ the type must not depend on the parameter `N` - | - = note: const parameters may not be used in the type of const parameters error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/const-param-type-depends-on-const-param.rs:15:40 | LL | pub struct SelfDependent<const N: [u8; N]>; | ^ the type must not depend on the parameter `N` - | - = note: const parameters may not be used in the type of const parameters error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr index 18b89963267..44fcf9a13b1 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr @@ -3,16 +3,12 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); | ^ the type must not depend on the parameter `N` - | - = note: const parameters may not be used in the type of const parameters error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/const-param-type-depends-on-const-param.rs:15:40 | LL | pub struct SelfDependent<const N: [u8; N]>; | ^ the type must not depend on the parameter `N` - | - = note: const parameters may not be used in the type of const parameters error: `[u8; N]` is forbidden as the type of a const generic parameter --> $DIR/const-param-type-depends-on-const-param.rs:11:47 diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr index 55bced29aff..3075597895b 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param-ungated.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | struct B<T, const N: T>(PhantomData<[T; N]>); | ^ the type must not depend on the parameter `T` - | - = note: type parameters may not be used in the type of const parameters error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr index 49cf4281323..e8257ace692 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.full.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub struct Dependent<T, const X: T>([(); X]); | ^ the type must not depend on the parameter `T` - | - = note: type parameters may not be used in the type of const parameters error[E0392]: type parameter `T` is never used --> $DIR/const-param-type-depends-on-type-param.rs:11:22 diff --git a/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr index 49cf4281323..e8257ace692 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-type-param.min.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub struct Dependent<T, const X: T>([(); X]); | ^ the type must not depend on the parameter `T` - | - = note: type parameters may not be used in the type of const parameters error[E0392]: type parameter `T` is never used --> $DIR/const-param-type-depends-on-type-param.rs:11:22 diff --git a/tests/ui/const-generics/generic_const_parameter_types/bad_inference.rs b/tests/ui/const-generics/generic_const_parameter_types/bad_inference.rs new file mode 100644 index 00000000000..de2e687e870 --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/bad_inference.rs @@ -0,0 +1,23 @@ +#![feature( + adt_const_params, + unsized_const_params, + generic_const_parameter_types, + generic_arg_infer +)] +#![allow(incomplete_features)] + +use std::marker::ConstParamTy_; + +fn foo<T: ConstParamTy_, const N: usize, const M: [T; N]>() -> [T; N] { + loop {} +} + +fn main() { + // Requires inferring `T`/`N` from `12_u8` and `2` respectively. + let a = foo::<_, _, { [12_u8; 2] }>(); + //~^ ERROR: anonymous constants with inferred types are not yet supported + + // Requires inferring `T`/`N`/`12_?i`/`_` from `[u8; 2]` + let b: [u8; 2] = foo::<_, _, { [12; _] }>(); + //~^ ERROR: anonymous constants with inferred types are not yet supported +} diff --git a/tests/ui/const-generics/generic_const_parameter_types/bad_inference.stderr b/tests/ui/const-generics/generic_const_parameter_types/bad_inference.stderr new file mode 100644 index 00000000000..1ac67fe622b --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/bad_inference.stderr @@ -0,0 +1,14 @@ +error: anonymous constants with inferred types are not yet supported + --> $DIR/bad_inference.rs:17:25 + | +LL | let a = foo::<_, _, { [12_u8; 2] }>(); + | ^^^^^^^^^^^^^^ + +error: anonymous constants with inferred types are not yet supported + --> $DIR/bad_inference.rs:21:34 + | +LL | let b: [u8; 2] = foo::<_, _, { [12; _] }>(); + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/const-generics/generic_const_parameter_types/evaluate_const_parameter_in_mir.rs b/tests/ui/const-generics/generic_const_parameter_types/evaluate_const_parameter_in_mir.rs new file mode 100644 index 00000000000..910deb6632d --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/evaluate_const_parameter_in_mir.rs @@ -0,0 +1,19 @@ +//@ check-pass + +#![feature( + adt_const_params, + unsized_const_params, + generic_const_parameter_types, + generic_arg_infer +)] +#![allow(incomplete_features)] + +use std::marker::ConstParamTy_; + +fn foo<T: ConstParamTy_, const N: usize, const M: [T; N]>() -> [T; N] { + M +} + +fn main() { + let a: [u8; 2] = foo::<u8, 2, { [12; _] }>(); +} diff --git a/tests/ui/const-generics/generic_const_parameter_types/forward_declared_type.rs b/tests/ui/const-generics/generic_const_parameter_types/forward_declared_type.rs new file mode 100644 index 00000000000..91c1c80e07c --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/forward_declared_type.rs @@ -0,0 +1,11 @@ +#![feature(adt_const_params, generic_const_parameter_types)] +#![expect(incomplete_features)] + +use std::marker::PhantomData; + +struct UsesConst<const N: [u8; M], const M: usize>; +//~^ ERROR: the type of const parameters must not depend on other generic parameters +struct UsesType<const N: [T; 2], T>(PhantomData<T>); +//~^ ERROR: the type of const parameters must not depend on other generic parameters + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_parameter_types/forward_declared_type.stderr b/tests/ui/const-generics/generic_const_parameter_types/forward_declared_type.stderr new file mode 100644 index 00000000000..b0dbdff8413 --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/forward_declared_type.stderr @@ -0,0 +1,15 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/forward_declared_type.rs:6:32 + | +LL | struct UsesConst<const N: [u8; M], const M: usize>; + | ^ the type must not depend on the parameter `M` + +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/forward_declared_type.rs:8:27 + | +LL | struct UsesType<const N: [T; 2], T>(PhantomData<T>); + | ^ the type must not depend on the parameter `T` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/generic_const_parameter_types/inferred_from_arg.rs b/tests/ui/const-generics/generic_const_parameter_types/inferred_from_arg.rs new file mode 100644 index 00000000000..d655fc174ee --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/inferred_from_arg.rs @@ -0,0 +1,13 @@ +//@ check-pass + +#![feature(adt_const_params, generic_arg_infer, generic_const_parameter_types)] +#![expect(incomplete_features)] + +struct Bar<const N: usize, const M: [u8; N]>; + +fn foo<const N: usize, const M: [u8; N]>(_: Bar<N, M>) {} + +fn main() { + foo(Bar::<2, { [1; 2] }>); + foo::<_, _>(Bar::<2, { [1; 2] }>); +} diff --git a/tests/ui/const-generics/generic_const_parameter_types/lifetime_dependent_const_param.rs b/tests/ui/const-generics/generic_const_parameter_types/lifetime_dependent_const_param.rs new file mode 100644 index 00000000000..6b81ca743aa --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/lifetime_dependent_const_param.rs @@ -0,0 +1,20 @@ +#![feature(generic_const_parameter_types, adt_const_params, unsized_const_params)] +#![expect(incomplete_features)] + +fn foo<'a, const N: &'a u32>() {} + +fn bar() { + foo::<'static, { &1_u32 }>(); + //~^ ERROR: anonymous constants with lifetimes in their type are not yet supported + foo::<'_, { &1_u32 }>(); + //~^ ERROR: anonymous constants with lifetimes in their type are not yet supported +} + +fn borrowck<'a, const N: &'static u32, const M: &'a u32>() { + foo::<'a, M>(); + foo::<'static, M>(); + //~^ ERROR: lifetime may not live long enough + foo::<'static, N>(); +} + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_parameter_types/lifetime_dependent_const_param.stderr b/tests/ui/const-generics/generic_const_parameter_types/lifetime_dependent_const_param.stderr new file mode 100644 index 00000000000..be5f27bcbc0 --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/lifetime_dependent_const_param.stderr @@ -0,0 +1,23 @@ +error: anonymous constants with lifetimes in their type are not yet supported + --> $DIR/lifetime_dependent_const_param.rs:7:20 + | +LL | foo::<'static, { &1_u32 }>(); + | ^^^^^^^^^^ + +error: anonymous constants with lifetimes in their type are not yet supported + --> $DIR/lifetime_dependent_const_param.rs:9:15 + | +LL | foo::<'_, { &1_u32 }>(); + | ^^^^^^^^^^ + +error: lifetime may not live long enough + --> $DIR/lifetime_dependent_const_param.rs:15:5 + | +LL | fn borrowck<'a, const N: &'static u32, const M: &'a u32>() { + | -- lifetime `'a` defined here +LL | foo::<'a, M>(); +LL | foo::<'static, M>(); + | ^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/const-generics/generic_const_parameter_types/mismatched_args_with_value.rs b/tests/ui/const-generics/generic_const_parameter_types/mismatched_args_with_value.rs new file mode 100644 index 00000000000..df8a057b335 --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/mismatched_args_with_value.rs @@ -0,0 +1,15 @@ +#![feature(adt_const_params, unsized_const_params, generic_const_parameter_types)] +#![allow(incomplete_features)] + +use std::marker::ConstParamTy_; + +fn foo<const N: usize, const M: [u8; N]>() {} +fn bar<T: ConstParamTy_, const M: [T; 2]>() {} + +fn main() { + foo::<3, { [1; 2] }>(); + //~^ ERROR: mismatched type + + bar::<u8, { [2_u16; 2] }>(); + //~^ ERROR: mismatched type +} diff --git a/tests/ui/const-generics/generic_const_parameter_types/mismatched_args_with_value.stderr b/tests/ui/const-generics/generic_const_parameter_types/mismatched_args_with_value.stderr new file mode 100644 index 00000000000..2411d31b980 --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/mismatched_args_with_value.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/mismatched_args_with_value.rs:10:16 + | +LL | foo::<3, { [1; 2] }>(); + | ^^^^^^ expected an array with a size of 3, found one with a size of 2 + +error[E0308]: mismatched types + --> $DIR/mismatched_args_with_value.rs:13:18 + | +LL | bar::<u8, { [2_u16; 2] }>(); + | ^^^^^ expected `u8`, found `u16` + | +help: change the type of the numeric literal from `u16` to `u8` + | +LL - bar::<u8, { [2_u16; 2] }>(); +LL + bar::<u8, { [2_u8; 2] }>(); + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/generic_const_parameter_types/no_const_param_ty_bound.rs b/tests/ui/const-generics/generic_const_parameter_types/no_const_param_ty_bound.rs new file mode 100644 index 00000000000..1a5ab46cda1 --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/no_const_param_ty_bound.rs @@ -0,0 +1,9 @@ +#![feature(adt_const_params, unsized_const_params, generic_const_parameter_types)] +#![expect(incomplete_features)] + +use std::marker::{ConstParamTy_, PhantomData}; + +struct UsesType<T, const N: usize, const M: [T; N]>(PhantomData<T>); +//~^ ERROR: `[T; N]` can't be used as a const parameter type + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_parameter_types/no_const_param_ty_bound.stderr b/tests/ui/const-generics/generic_const_parameter_types/no_const_param_ty_bound.stderr new file mode 100644 index 00000000000..4ea323f4a5c --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/no_const_param_ty_bound.stderr @@ -0,0 +1,11 @@ +error[E0741]: `[T; N]` can't be used as a const parameter type + --> $DIR/no_const_param_ty_bound.rs:6:45 + | +LL | struct UsesType<T, const N: usize, const M: [T; N]>(PhantomData<T>); + | ^^^^^^ + | + = note: `T` must implement `UnsizedConstParamTy`, but it does not + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0741`. diff --git a/tests/ui/const-generics/generic_const_parameter_types/unrelated_inferred_arg.rs b/tests/ui/const-generics/generic_const_parameter_types/unrelated_inferred_arg.rs new file mode 100644 index 00000000000..b389e12884e --- /dev/null +++ b/tests/ui/const-generics/generic_const_parameter_types/unrelated_inferred_arg.rs @@ -0,0 +1,21 @@ +//@ check-pass + +#![feature( + adt_const_params, + unsized_const_params, + generic_const_parameter_types, + generic_arg_infer +)] +#![allow(incomplete_features)] + +use std::marker::ConstParamTy_; + +fn foo<U, T: ConstParamTy_, const N: usize, const M: [T; N]>(_: U) -> [T; N] { + loop {} +} + +fn main() { + // Check that `_` doesnt cause a "Type of const argument is uninferred" error + // as it is not actually used by the type of `M`. + let a = foo::<_, u8, 2, { [12; _] }>(true); +} diff --git a/tests/ui/const-generics/issues/issue-100313.rs b/tests/ui/const-generics/issues/issue-100313.rs index 553165f90b8..7ce2a3b908c 100644 --- a/tests/ui/const-generics/issues/issue-100313.rs +++ b/tests/ui/const-generics/issues/issue-100313.rs @@ -6,15 +6,14 @@ struct T<const B: &'static bool>; impl<const B: &'static bool> T<B> { const fn set_false(&self) { unsafe { - *(B as *const bool as *mut bool) = false; - //~^ ERROR evaluation of constant value failed [E0080] + *(B as *const bool as *mut bool) = false; //~ inside `T } } } const _: () = { let x = T::<{ &true }>; - x.set_false(); + x.set_false(); //~ ERROR evaluation of constant value failed [E0080] }; fn main() {} diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr index 6e419078e5e..03a658a83af 100644 --- a/tests/ui/const-generics/issues/issue-100313.stderr +++ b/tests/ui/const-generics/issues/issue-100313.stderr @@ -1,19 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/issue-100313.rs:9:13 + --> $DIR/issue-100313.rs:16:5 | -LL | *(B as *const bool as *mut bool) = false; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ writing to ALLOC0 which is read-only +LL | x.set_false(); + | ^^^^^^^^^^^^^ writing to ALLOC0 which is read-only | note: inside `T::<&true>::set_false` --> $DIR/issue-100313.rs:9:13 | LL | *(B as *const bool as *mut bool) = false; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `_` - --> $DIR/issue-100313.rs:17:5 - | -LL | x.set_false(); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-56445-1.full.stderr b/tests/ui/const-generics/issues/issue-56445-1.full.stderr index 86eb57355bd..392a125de67 100644 --- a/tests/ui/const-generics/issues/issue-56445-1.full.stderr +++ b/tests/ui/const-generics/issues/issue-56445-1.full.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); | ^^ the type must not depend on the parameter `'a` - | - = note: lifetime parameters may not be used in the type of const parameters error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-56445-1.min.stderr b/tests/ui/const-generics/issues/issue-56445-1.min.stderr index 86eb57355bd..392a125de67 100644 --- a/tests/ui/const-generics/issues/issue-56445-1.min.stderr +++ b/tests/ui/const-generics/issues/issue-56445-1.min.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); | ^^ the type must not depend on the parameter `'a` - | - = note: lifetime parameters may not be used in the type of const parameters error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-62878.full.stderr b/tests/ui/const-generics/issues/issue-62878.full.stderr index 615bfeb65a5..5e6b3ad9f4c 100644 --- a/tests/ui/const-generics/issues/issue-62878.full.stderr +++ b/tests/ui/const-generics/issues/issue-62878.full.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn foo<const N: usize, const A: [u8; N]>() {} | ^ the type must not depend on the parameter `N` - | - = note: const parameters may not be used in the type of const parameters error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-62878.min.stderr b/tests/ui/const-generics/issues/issue-62878.min.stderr index 1bb111b188d..d3d4fa43871 100644 --- a/tests/ui/const-generics/issues/issue-62878.min.stderr +++ b/tests/ui/const-generics/issues/issue-62878.min.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn foo<const N: usize, const A: [u8; N]>() {} | ^ the type must not depend on the parameter `N` - | - = note: const parameters may not be used in the type of const parameters error: `[u8; N]` is forbidden as the type of a const generic parameter --> $DIR/issue-62878.rs:5:33 diff --git a/tests/ui/const-generics/issues/issue-71169.full.stderr b/tests/ui/const-generics/issues/issue-71169.full.stderr index 9553be6fc07..f600ecdab74 100644 --- a/tests/ui/const-generics/issues/issue-71169.full.stderr +++ b/tests/ui/const-generics/issues/issue-71169.full.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {} | ^^^ the type must not depend on the parameter `LEN` - | - = note: const parameters may not be used in the type of const parameters error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-71169.min.stderr b/tests/ui/const-generics/issues/issue-71169.min.stderr index 2ecbc337951..c04a710eee9 100644 --- a/tests/ui/const-generics/issues/issue-71169.min.stderr +++ b/tests/ui/const-generics/issues/issue-71169.min.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {} | ^^^ the type must not depend on the parameter `LEN` - | - = note: const parameters may not be used in the type of const parameters error: `[u8; LEN]` is forbidden as the type of a const generic parameter --> $DIR/issue-71169.rs:5:38 diff --git a/tests/ui/const-generics/issues/issue-71381.full.stderr b/tests/ui/const-generics/issues/issue-71381.full.stderr index b6460e0017f..01bbe55415d 100644 --- a/tests/ui/const-generics/issues/issue-71381.full.stderr +++ b/tests/ui/const-generics/issues/issue-71381.full.stderr @@ -3,16 +3,12 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { | ^^^^ the type must not depend on the parameter `Args` - | - = note: type parameters may not be used in the type of const parameters error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/issue-71381.rs:23:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` - | - = note: type parameters may not be used in the type of const parameters error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-71381.min.stderr b/tests/ui/const-generics/issues/issue-71381.min.stderr index 38d2cbe6368..2b0a671bc3f 100644 --- a/tests/ui/const-generics/issues/issue-71381.min.stderr +++ b/tests/ui/const-generics/issues/issue-71381.min.stderr @@ -3,16 +3,12 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { | ^^^^ the type must not depend on the parameter `Args` - | - = note: type parameters may not be used in the type of const parameters error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/issue-71381.rs:23:40 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^ the type must not depend on the parameter `Args` - | - = note: type parameters may not be used in the type of const parameters error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71381.rs:14:61 diff --git a/tests/ui/const-generics/issues/issue-71611.full.stderr b/tests/ui/const-generics/issues/issue-71611.full.stderr index 6f6a9fc21a6..e115630b64e 100644 --- a/tests/ui/const-generics/issues/issue-71611.full.stderr +++ b/tests/ui/const-generics/issues/issue-71611.full.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn func<A, const F: fn(inner: A)>(outer: A) { | ^ the type must not depend on the parameter `A` - | - = note: type parameters may not be used in the type of const parameters error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/issues/issue-71611.min.stderr b/tests/ui/const-generics/issues/issue-71611.min.stderr index 7252bfd1d6a..b2e2e5cb445 100644 --- a/tests/ui/const-generics/issues/issue-71611.min.stderr +++ b/tests/ui/const-generics/issues/issue-71611.min.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn func<A, const F: fn(inner: A)>(outer: A) { | ^ the type must not depend on the parameter `A` - | - = note: type parameters may not be used in the type of const parameters error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71611.rs:5:21 diff --git a/tests/ui/const-generics/issues/issue-88997.stderr b/tests/ui/const-generics/issues/issue-88997.stderr index b49d52dd0ba..505ba0da232 100644 --- a/tests/ui/const-generics/issues/issue-88997.stderr +++ b/tests/ui/const-generics/issues/issue-88997.stderr @@ -3,16 +3,12 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | struct Range<T: PartialOrd, const MIN: T, const MAX: T>(T) | ^ the type must not depend on the parameter `T` - | - = note: type parameters may not be used in the type of const parameters error[E0770]: the type of const parameters must not depend on other generic parameters --> $DIR/issue-88997.rs:8:54 | LL | struct Range<T: PartialOrd, const MIN: T, const MAX: T>(T) | ^ the type must not depend on the parameter `T` - | - = note: type parameters may not be used in the type of const parameters error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-90364.stderr b/tests/ui/const-generics/issues/issue-90364.stderr index 6c00a654cde..384ce5da3e2 100644 --- a/tests/ui/const-generics/issues/issue-90364.stderr +++ b/tests/ui/const-generics/issues/issue-90364.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | pub struct Foo<T, const H: T>(T) | ^ the type must not depend on the parameter `T` - | - = note: type parameters may not be used in the type of const parameters error: aborting due to 1 previous error diff --git a/tests/ui/const-ptr/forbidden_slices.rs b/tests/ui/const-ptr/forbidden_slices.rs index 59ea92c5ab3..001cfd66ad1 100644 --- a/tests/ui/const-ptr/forbidden_slices.rs +++ b/tests/ui/const-ptr/forbidden_slices.rs @@ -48,9 +48,11 @@ pub static S8: &[u64] = unsafe { pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; //~^ ERROR it is undefined behavior to use this value pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore +//~^ ERROR could not evaluate static initializer pub static R2: &[u32] = unsafe { let ptr = &D0 as *const u32; from_ptr_range(ptr..ptr.add(2)) // errors inside libcore + //~^ ERROR could not evaluate static initializer }; pub static R4: &[u8] = unsafe { //~^ ERROR: it is undefined behavior to use this value @@ -74,13 +76,16 @@ pub static R7: &[u16] = unsafe { }; pub static R8: &[u64] = unsafe { let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::<u64>(); - from_ptr_range(ptr..ptr.add(1)) //~ inside `R8` + from_ptr_range(ptr..ptr.add(1)) + //~^ ERROR could not evaluate static initializer }; // This is sneaky: &D0 and &D0 point to different objects // (even if at runtime they have the same address) pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; +//~^ ERROR could not evaluate static initializer pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; +//~^ ERROR could not evaluate static initializer const D0: u32 = 0x11111111; // Constant chosen for endianness-independent behavior. const D1: MaybeUninit<&u32> = MaybeUninit::uninit(); diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index df588fcc5e1..a4e9c972ceb 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -100,36 +100,28 @@ LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) } } error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/forbidden_slices.rs:50:33 | - = note: the evaluated program panicked at 'assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize', $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize | -note: inside `std::ptr::const_ptr::<impl *const ()>::offset_from_unsigned` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `from_ptr_range::<'_, ()>` --> $SRC_DIR/core/src/slice/raw.rs:LL:COL -note: inside `R1` - --> $DIR/forbidden_slices.rs:50:33 - | -LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `std::ptr::const_ptr::<impl *const ()>::offset_from_unsigned` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/forbidden_slices.rs:54:25 | - = note: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC10 which is only 4 bytes from the end of the allocation +LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore + | ^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC10 which is only 4 bytes from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u32>::add` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `R2` - --> $DIR/forbidden_slices.rs:53:25 - | -LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore - | ^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:55:1 + --> $DIR/forbidden_slices.rs:57:1 | LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer @@ -140,7 +132,7 @@ LL | pub static R4: &[u8] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:60:1 + --> $DIR/forbidden_slices.rs:62:1 | LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer @@ -153,7 +145,7 @@ LL | pub static R5: &[u8] = unsafe { = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:65:1 + --> $DIR/forbidden_slices.rs:67:1 | LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean @@ -164,7 +156,7 @@ LL | pub static R6: &[bool] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/forbidden_slices.rs:70:1 + --> $DIR/forbidden_slices.rs:72:1 | LL | pub static R7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1) @@ -175,47 +167,35 @@ LL | pub static R7: &[u16] = unsafe { } error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/forbidden_slices.rs:79:25 | - = note: out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation +LL | from_ptr_range(ptr..ptr.add(1)) + | ^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 8 bytes of memory, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u64>::add` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `R8` - --> $DIR/forbidden_slices.rs:77:25 - | -LL | from_ptr_range(ptr..ptr.add(1)) - | ^^^^^^^^^^ error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/forbidden_slices.rs:85:34 | - = note: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation +LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation | -note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `from_ptr_range::<'_, u32>` --> $SRC_DIR/core/src/slice/raw.rs:LL:COL -note: inside `R9` - --> $DIR/forbidden_slices.rs:82:34 - | -LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/forbidden_slices.rs:87:35 | - = note: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation +LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation | -note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `from_ptr_range::<'_, u32>` --> $SRC_DIR/core/src/slice/raw.rs:LL:COL -note: inside `R10` - --> $DIR/forbidden_slices.rs:83:35 - | -LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL error: aborting due to 18 previous errors diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index 7f354963eb1..899e151c9b8 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -1,45 +1,33 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $DIR/out_of_bounds_read.rs:10:33 | - = note: memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes +LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; + | ^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | note: inside `std::ptr::read::<u32>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `_READ` - --> $DIR/out_of_bounds_read.rs:10:33 - | -LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $DIR/out_of_bounds_read.rs:11:39 | - = note: memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes +LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; + | ^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | -note: inside `std::ptr::read::<u32>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::const_ptr::<impl *const u32>::read` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `_CONST_READ` - --> $DIR/out_of_bounds_read.rs:11:39 - | -LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; - | ^^^^^^^^^^^^^^^^^^^ +note: inside `std::ptr::read::<u32>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $DIR/out_of_bounds_read.rs:12:37 | - = note: memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes +LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: expected a pointer to 4 bytes of memory, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes | -note: inside `std::ptr::read::<u32>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::mut_ptr::<impl *mut u32>::read` --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL -note: inside `_MUT_READ` - --> $DIR/out_of_bounds_read.rs:12:37 - | -LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `std::ptr::read::<u32>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 3 previous errors diff --git a/tests/ui/consts/assert-type-intrinsics.stderr b/tests/ui/consts/assert-type-intrinsics.stderr index 66c4f0f9cd6..92c0610a248 100644 --- a/tests/ui/consts/assert-type-intrinsics.stderr +++ b/tests/ui/consts/assert-type-intrinsics.stderr @@ -2,19 +2,19 @@ error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:11:9 | LL | MaybeUninit::<!>::uninit().assume_init(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'aborted execution: attempted to instantiate uninhabited type `!`', $DIR/assert-type-intrinsics.rs:11:36 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to instantiate uninhabited type `!` error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:15:9 | LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'aborted execution: attempted to leave type `&i32` uninitialized, which is invalid', $DIR/assert-type-intrinsics.rs:15:9 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:19:9 | LL | intrinsics::assert_zero_valid::<&'static i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'aborted execution: attempted to zero-initialize type `&i32`, which is invalid', $DIR/assert-type-intrinsics.rs:19:9 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs b/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs index 87f8b52a650..7db8c6e81ab 100644 --- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs +++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs @@ -7,12 +7,18 @@ const X: fn(usize) -> usize = double; const fn bar(x: fn(usize) -> usize, y: usize) -> usize { x(y) - //~^ ERROR evaluation of constant value failed - //~| ERROR evaluation of constant value failed + //~^ NOTE inside `bar` + //~| NOTE the failure occurred here + //~| NOTE inside `bar` + //~| NOTE the failure occurred here } const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday +//~^ ERROR evaluation of constant value failed +//~| NOTE calling non-const function `double` const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday +//~^ ERROR evaluation of constant value failed +//~| NOTE calling non-const function `double` fn main() { assert_eq!(Y, 4); diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr index 0734f479f98..a4d2e26c3af 100644 --- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -1,36 +1,26 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const_fn_ptr_fail2.rs:9:5 + --> $DIR/const_fn_ptr_fail2.rs:16:18 | -LL | x(y) - | ^^^^ calling non-const function `double` +LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday + | ^^^^^^^^^ calling non-const function `double` | note: inside `bar` --> $DIR/const_fn_ptr_fail2.rs:9:5 | LL | x(y) - | ^^^^ -note: inside `Y` - --> $DIR/const_fn_ptr_fail2.rs:14:18 - | -LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday - | ^^^^^^^^^ + | ^^^^ the failure occurred here error[E0080]: evaluation of constant value failed - --> $DIR/const_fn_ptr_fail2.rs:9:5 + --> $DIR/const_fn_ptr_fail2.rs:19:18 | -LL | x(y) - | ^^^^ calling non-const function `double` +LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday + | ^^^^^^^^^^^^^^ calling non-const function `double` | note: inside `bar` --> $DIR/const_fn_ptr_fail2.rs:9:5 | LL | x(y) - | ^^^^ -note: inside `Z` - --> $DIR/const_fn_ptr_fail2.rs:15:18 - | -LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday - | ^^^^^^^^^^^^^^ + | ^^^^ the failure occurred here warning: skipping const checks | diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr index 5f4af25611f..64e227c4f45 100644 --- a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic-normalize-tabs-115498.rs:3:17 | LL | struct Bug([u8; panic!{"\t"}]); - | ^^^^^^^^^^^^ the evaluated program panicked at ' ', $DIR/const_panic-normalize-tabs-115498.rs:3:17 + | ^^^^^^^^^^^^ evaluation panicked: | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-eval/const_panic.stderr b/tests/ui/consts/const-eval/const_panic.stderr index 0f7be46072d..0816b04faca 100644 --- a/tests/ui/consts/const-eval/const_panic.stderr +++ b/tests/ui/consts/const-eval/const_panic.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:6:15 | LL | const Z: () = std::panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:6:15 + | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: cheese | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `std::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -10,7 +10,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:9:16 | LL | const Z2: () = std::panic!(); - | ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:9:16 + | ^^^^^^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `std::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -18,7 +18,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:12:15 | LL | const Y: () = std::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15 + | ^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code | = note: this error originates in the macro `$crate::panic::unreachable_2015` which comes from the expansion of the macro `std::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -26,7 +26,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:15:15 | LL | const X: () = std::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:15:15 + | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented | = note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -34,7 +34,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:18:15 | LL | const W: () = std::panic!(MSG); - | ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:18:15 + | ^^^^^^^^^^^^^^^^ evaluation panicked: hello | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `std::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -42,7 +42,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:21:16 | LL | const W2: () = std::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:21:16 + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `std::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -50,7 +50,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:24:20 | LL | const Z_CORE: () = core::panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic.rs:24:20 + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: cheese | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `core::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -58,7 +58,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:27:21 | LL | const Z2_CORE: () = core::panic!(); - | ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:27:21 + | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `core::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -66,7 +66,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:30:20 | LL | const Y_CORE: () = core::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:30:20 + | ^^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code | = note: this error originates in the macro `$crate::panic::unreachable_2015` which comes from the expansion of the macro `core::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -74,7 +74,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:33:20 | LL | const X_CORE: () = core::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:33:20 + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented | = note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -82,7 +82,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:36:20 | LL | const W_CORE: () = core::panic!(MSG); - | ^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:36:20 + | ^^^^^^^^^^^^^^^^^ evaluation panicked: hello | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `core::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -90,7 +90,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic.rs:39:21 | LL | const W2_CORE: () = core::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic.rs:39:21 + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `core::panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-eval/const_panic_2021.stderr b/tests/ui/consts/const-eval/const_panic_2021.stderr index 192fa3a12c2..4faa2a1e4cf 100644 --- a/tests/ui/consts/const-eval/const_panic_2021.stderr +++ b/tests/ui/consts/const-eval/const_panic_2021.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:6:15 | LL | const A: () = std::panic!("blåhaj"); - | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'blåhaj', $DIR/const_panic_2021.rs:6:15 + | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: blåhaj | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `std::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -10,7 +10,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:9:15 | LL | const B: () = std::panic!(); - | ^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:9:15 + | ^^^^^^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `std::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -18,7 +18,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:12:15 | LL | const C: () = std::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:12:15 + | ^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code | = note: this error originates in the macro `$crate::panic::unreachable_2021` which comes from the expansion of the macro `std::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -26,7 +26,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:15:15 | LL | const D: () = std::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:15:15 + | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented | = note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -34,7 +34,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:18:15 | LL | const E: () = std::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic_2021.rs:18:15 + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `std::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -42,7 +42,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:21:20 | LL | const A_CORE: () = core::panic!("shark"); - | ^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'shark', $DIR/const_panic_2021.rs:21:20 + | ^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: shark | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `core::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -50,7 +50,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:24:20 | LL | const B_CORE: () = core::panic!(); - | ^^^^^^^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/const_panic_2021.rs:24:20 + | ^^^^^^^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `core::panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -58,7 +58,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:27:20 | LL | const C_CORE: () = core::unreachable!(); - | ^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_2021.rs:27:20 + | ^^^^^^^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code | = note: this error originates in the macro `$crate::panic::unreachable_2021` which comes from the expansion of the macro `core::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -66,7 +66,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:30:20 | LL | const D_CORE: () = core::unimplemented!(); - | ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_2021.rs:30:20 + | ^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: not implemented | = note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -74,7 +74,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_2021.rs:33:20 | LL | const E_CORE: () = core::panic!("{}", MSG); - | ^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello', $DIR/const_panic_2021.rs:33:20 + | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: hello | = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `core::panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr index df19ed4a898..11e70c48499 100644 --- a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr +++ b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_libcore_bin.rs:8:15 | LL | const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:8:15 + | ^^^^^^^^^^^^^^^^ evaluation panicked: cheese | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -10,7 +10,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_libcore_bin.rs:11:15 | LL | const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^ the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:11:15 + | ^^^^^^^^^^^^^^ evaluation panicked: internal error: entered unreachable code | = note: this error originates in the macro `$crate::panic::unreachable_2015` which comes from the expansion of the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -18,7 +18,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_panic_libcore_bin.rs:14:15 | LL | const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^^^ the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:14:15 + | ^^^^^^^^^^^^^^^^ evaluation panicked: not implemented | = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-eval/const_panic_track_caller.rs b/tests/ui/consts/const-eval/const_panic_track_caller.rs index 9cf7a3ba7dc..799a59d16ca 100644 --- a/tests/ui/consts/const-eval/const_panic_track_caller.rs +++ b/tests/ui/consts/const-eval/const_panic_track_caller.rs @@ -12,11 +12,10 @@ const fn b() -> u32 { } const fn c() -> u32 { - b() - //~^ ERROR evaluation of constant value failed - //~| NOTE the evaluated program panicked - //~| NOTE inside + b() //~ NOTE inside `c` + //~^ NOTE the failure occurred here } const X: u32 = c(); -//~^ NOTE inside +//~^ ERROR evaluation of constant value failed +//~| NOTE hey diff --git a/tests/ui/consts/const-eval/const_panic_track_caller.stderr b/tests/ui/consts/const-eval/const_panic_track_caller.stderr index a7df82705b8..8736a8c9409 100644 --- a/tests/ui/consts/const-eval/const_panic_track_caller.stderr +++ b/tests/ui/consts/const-eval/const_panic_track_caller.stderr @@ -1,19 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/const_panic_track_caller.rs:15:5 + --> $DIR/const_panic_track_caller.rs:19:16 | -LL | b() - | ^^^ the evaluated program panicked at 'hey', $DIR/const_panic_track_caller.rs:15:5 +LL | const X: u32 = c(); + | ^^^ evaluation panicked: hey | note: inside `c` --> $DIR/const_panic_track_caller.rs:15:5 | LL | b() - | ^^^ -note: inside `X` - --> $DIR/const_panic_track_caller.rs:21:16 - | -LL | const X: u32 = c(); - | ^^^ + | ^^^ the failure occurred here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs index 9cf9360dcbd..c1a544031c2 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs @@ -2,11 +2,10 @@ #![feature(const_heap)] use std::intrinsics; -const FOO: i32 = foo(); +const FOO: i32 = foo(); //~ error: evaluation of constant value failed const fn foo() -> i32 { unsafe { - let _ = intrinsics::const_allocate(4, 3) as *mut i32; - //~^ error: evaluation of constant value failed + let _ = intrinsics::const_allocate(4, 3) as *mut i32; //~ inside `foo` } 1 } diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index 2fd7222da52..e1cb7a83996 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -1,19 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/alloc_intrinsic_errors.rs:8:17 + --> $DIR/alloc_intrinsic_errors.rs:5:18 | -LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2 +LL | const FOO: i32 = foo(); + | ^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2 | note: inside `foo` --> $DIR/alloc_intrinsic_errors.rs:8:17 | LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `FOO` - --> $DIR/alloc_intrinsic_errors.rs:5:18 - | -LL | const FOO: i32 = foo(); - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr index eef39255927..efdbbe5698f 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/panic-assoc-never-type.rs:9:21 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:9:21 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-eval/panic-never-type.stderr b/tests/ui/consts/const-eval/panic-never-type.stderr index d3ba3eefb1a..30a320f8db2 100644 --- a/tests/ui/consts/const-eval/panic-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-never-type.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/panic-never-type.rs:4:17 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-never-type.rs:4:17 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/const-eval/parse_ints.rs b/tests/ui/consts/const-eval/parse_ints.rs index cb9a3eb4312..309b7ee5d27 100644 --- a/tests/ui/consts/const-eval/parse_ints.rs +++ b/tests/ui/consts/const-eval/parse_ints.rs @@ -2,7 +2,7 @@ const _OK: () = match i32::from_str_radix("-1234", 10) { Ok(x) => assert!(x == -1234), Err(_) => panic!(), }; -const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; -const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; +const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; //~ ERROR evaluation of constant value failed +const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; //~ ERROR evaluation of constant value failed fn main () {} diff --git a/tests/ui/consts/const-eval/parse_ints.stderr b/tests/ui/consts/const-eval/parse_ints.stderr index 189d3c3958b..7a855bb9e5c 100644 --- a/tests/ui/consts/const-eval/parse_ints.stderr +++ b/tests/ui/consts/const-eval/parse_ints.stderr @@ -1,33 +1,25 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/num/mod.rs:LL:COL + --> $DIR/parse_ints.rs:5:24 | - = note: the evaluated program panicked at 'from_ascii_radix: radix must lie in the range `[2, 36]`', $SRC_DIR/core/src/num/mod.rs:LL:COL +LL | const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` | -note: inside `core::num::<impl u64>::from_ascii_radix` - --> $SRC_DIR/core/src/num/mod.rs:LL:COL note: inside `core::num::<impl u64>::from_str_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL -note: inside `_TOO_LOW` - --> $DIR/parse_ints.rs:5:24 - | -LL | const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `core::num::<impl u64>::from_ascii_radix` + --> $SRC_DIR/core/src/num/mod.rs:LL:COL = note: this error originates in the macro `from_str_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/num/mod.rs:LL:COL + --> $DIR/parse_ints.rs:6:25 | - = note: the evaluated program panicked at 'from_ascii_radix: radix must lie in the range `[2, 36]`', $SRC_DIR/core/src/num/mod.rs:LL:COL +LL | const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: from_ascii_radix: radix must lie in the range `[2, 36]` | -note: inside `core::num::<impl u64>::from_ascii_radix` - --> $SRC_DIR/core/src/num/mod.rs:LL:COL note: inside `core::num::<impl u64>::from_str_radix` --> $SRC_DIR/core/src/num/mod.rs:LL:COL -note: inside `_TOO_HIGH` - --> $DIR/parse_ints.rs:6:25 - | -LL | const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `core::num::<impl u64>::from_ascii_radix` + --> $SRC_DIR/core/src/num/mod.rs:LL:COL = note: this error originates in the macro `from_str_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs index 5724293f145..478e93a910e 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.rs +++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs @@ -17,7 +17,10 @@ const MISALIGNED_COPY: () = unsafe { let y = x.as_ptr().cast::<u32>(); let mut z = 123; y.copy_to_nonoverlapping(&mut z, 1); - //~^NOTE + //~^ ERROR evaluation of constant value failed + //~| NOTE inside `std::ptr::const_ptr + //~| NOTE inside `copy_nonoverlapping::<u32>` + //~| NOTE accessing memory with alignment 1, but alignment 4 is required // The actual error points into the implementation of `copy_to_nonoverlapping`. }; diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr index c3360c8b3e2..4fff293b2ee 100644 --- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr +++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr @@ -11,28 +11,24 @@ LL | *ptr = 0; | ^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL + --> $DIR/raw-pointer-ub.rs:19:5 | - = note: accessing memory with alignment 1, but alignment 4 is required +LL | y.copy_to_nonoverlapping(&mut z, 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment 1, but alignment 4 is required | -note: inside `copy_nonoverlapping::<u32>` - --> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL note: inside `std::ptr::const_ptr::<impl *const u32>::copy_to_nonoverlapping` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `MISALIGNED_COPY` - --> $DIR/raw-pointer-ub.rs:19:5 - | -LL | y.copy_to_nonoverlapping(&mut z, 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `copy_nonoverlapping::<u32>` + --> $SRC_DIR/core/src/intrinsics/mod.rs:LL:COL error[E0080]: evaluation of constant value failed - --> $DIR/raw-pointer-ub.rs:31:16 + --> $DIR/raw-pointer-ub.rs:34:16 | LL | let _val = (*ptr).0; | ^^^^^^^^ accessing memory based on pointer with alignment 4, but alignment 16 is required error[E0080]: evaluation of constant value failed - --> $DIR/raw-pointer-ub.rs:38:16 + --> $DIR/raw-pointer-ub.rs:41:16 | LL | let _val = *ptr; | ^^^^ memory access failed: expected a pointer to 8 bytes of memory, but got ALLOC0 which is only 4 bytes from the end of the allocation diff --git a/tests/ui/consts/const-eval/simd/insert_extract.rs b/tests/ui/consts/const-eval/simd/insert_extract.rs index e5873ea26e8..fc97f9ec141 100644 --- a/tests/ui/consts/const-eval/simd/insert_extract.rs +++ b/tests/ui/consts/const-eval/simd/insert_extract.rs @@ -1,28 +1,19 @@ //@ run-pass #![feature(repr_simd)] -#![feature(intrinsics, rustc_attrs)] +#![feature(intrinsics, core_intrinsics, rustc_attrs)] #![feature(staged_api)] #![stable(feature = "foo", since = "1.3.37")] #![allow(non_camel_case_types)] -// repr(simd) now only supports array types -#[repr(simd)] struct i8x1([i8; 1]); -#[repr(simd)] struct u16x2([u16; 2]); -#[repr(simd)] struct f32x4([f32; 4]); - -#[stable(feature = "foo", since = "1.3.37")] -#[rustc_const_stable(feature = "foo", since = "1.3.37")] -#[rustc_intrinsic] -const unsafe fn simd_insert<T, U>(_x: T, _idx: u32, _val: U) -> T { - unimplemented!() -} +use std::intrinsics::simd::{simd_extract, simd_insert}; -#[stable(feature = "foo", since = "1.3.37")] -#[rustc_const_stable(feature = "foo", since = "1.3.37")] -#[rustc_intrinsic] -const unsafe fn simd_extract<T, U>(_x: T, _idx: u32) -> U { - unimplemented!() -} +// repr(simd) now only supports array types +#[repr(simd)] +struct i8x1([i8; 1]); +#[repr(simd)] +struct u16x2([u16; 2]); +#[repr(simd)] +struct f32x4([f32; 4]); fn main() { { diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.rs b/tests/ui/consts/const-eval/transmute-size-mismatch.rs index 2410baea28c..8a7fd8257b0 100644 --- a/tests/ui/consts/const-eval/transmute-size-mismatch.rs +++ b/tests/ui/consts/const-eval/transmute-size-mismatch.rs @@ -10,15 +10,19 @@ const unsafe fn mir_transmute<T, U>(x: T) -> U { mir!{ { RET = CastTransmute(x); - //~^ ERROR evaluation of constant value failed - //~| ERROR evaluation of constant value failed + //~^ NOTE inside `mir_transmute + //~| NOTE inside `mir_transmute + //~| NOTE the failure occurred here + //~| NOTE the failure occurred here Return() } } } -const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; +const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; //~ ERROR evaluation of constant value failed +//~^ NOTE transmuting from 4-byte type to 2-byte type: `i32` -> `u16` -const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; +const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; //~ ERROR evaluation of constant value failed +//~^ NOTE transmuting from 2-byte type to 4-byte type: `i16` -> `u32` fn main() {} diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr index e051491d343..888df16ec4e 100644 --- a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr +++ b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr @@ -1,36 +1,26 @@ error[E0080]: evaluation of constant value failed - --> $DIR/transmute-size-mismatch.rs:12:13 + --> $DIR/transmute-size-mismatch.rs:22:35 | -LL | RET = CastTransmute(x); - | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 4-byte type to 2-byte type: `i32` -> `u16` +LL | const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; + | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 4-byte type to 2-byte type: `i32` -> `u16` | note: inside `mir_transmute::<i32, u16>` --> $DIR/transmute-size-mismatch.rs:12:13 | LL | RET = CastTransmute(x); - | ^^^^^^^^^^^^^^^^^^^^^^ -note: inside `FROM_BIGGER` - --> $DIR/transmute-size-mismatch.rs:20:35 - | -LL | const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here error[E0080]: evaluation of constant value failed - --> $DIR/transmute-size-mismatch.rs:12:13 + --> $DIR/transmute-size-mismatch.rs:25:36 | -LL | RET = CastTransmute(x); - | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 2-byte type to 4-byte type: `i16` -> `u32` +LL | const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; + | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 2-byte type to 4-byte type: `i16` -> `u32` | note: inside `mir_transmute::<i16, u32>` --> $DIR/transmute-size-mismatch.rs:12:13 | LL | RET = CastTransmute(x); - | ^^^^^^^^^^^^^^^^^^^^^^ -note: inside `FROM_SMALLER` - --> $DIR/transmute-size-mismatch.rs:22:36 - | -LL | const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-eval/ub-enum.rs b/tests/ui/consts/const-eval/ub-enum.rs index 11cd87023d1..5be444e667a 100644 --- a/tests/ui/consts/const-eval/ub-enum.rs +++ b/tests/ui/consts/const-eval/ub-enum.rs @@ -101,7 +101,7 @@ const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem: const TEST_ICE_89765: () = { // This is a regression test for https://github.com/rust-lang/rust/issues/89765. unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; - //~^ inside `TEST_ICE_89765` + //~^ ERROR evaluation of constant value failed }; fn main() { diff --git a/tests/ui/consts/const-eval/ub-enum.stderr b/tests/ui/consts/const-eval/ub-enum.stderr index a0712f64c7b..cfb7eaf537a 100644 --- a/tests/ui/consts/const-eval/ub-enum.stderr +++ b/tests/ui/consts/const-eval/ub-enum.stderr @@ -117,17 +117,13 @@ LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + --> $DIR/ub-enum.rs:103:14 | - = note: read discriminant of an uninhabited enum variant +LL | unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ read discriminant of an uninhabited enum variant | note: inside `discriminant::<Never>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL -note: inside `TEST_ICE_89765` - --> $DIR/ub-enum.rs:103:14 - | -LL | unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/consts/const-eval/ub-invalid-values.rs b/tests/ui/consts/const-eval/ub-invalid-values.rs index 1724a88dd3d..c0b68d7619a 100644 --- a/tests/ui/consts/const-eval/ub-invalid-values.rs +++ b/tests/ui/consts/const-eval/ub-invalid-values.rs @@ -1,11 +1,12 @@ const fn bool_cast(ptr: *const bool) { unsafe { - let _val = *ptr as u32; //~ERROR: evaluation of constant value failed - //~^ interpreting an invalid 8-bit value as a bool + let _val = *ptr as u32; //~ NOTE inside `bool_cast` + //~^ NOTE the failure occurred here }} const _: () = { let v = 3_u8; - bool_cast(&v as *const u8 as *const bool); + bool_cast(&v as *const u8 as *const bool); //~ ERROR: evaluation of constant value failed + //~^ NOTE interpreting an invalid 8-bit value as a bool }; fn main() {} diff --git a/tests/ui/consts/const-eval/ub-invalid-values.stderr b/tests/ui/consts/const-eval/ub-invalid-values.stderr index edf72f731e5..76952c1f1a3 100644 --- a/tests/ui/consts/const-eval/ub-invalid-values.stderr +++ b/tests/ui/consts/const-eval/ub-invalid-values.stderr @@ -1,19 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ub-invalid-values.rs:2:16 + --> $DIR/ub-invalid-values.rs:8:5 | -LL | let _val = *ptr as u32; - | ^^^^^^^^^^^ interpreting an invalid 8-bit value as a bool: 0x03 +LL | bool_cast(&v as *const u8 as *const bool); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ interpreting an invalid 8-bit value as a bool: 0x03 | note: inside `bool_cast` --> $DIR/ub-invalid-values.rs:2:16 | LL | let _val = *ptr as u32; - | ^^^^^^^^^^^ -note: inside `_` - --> $DIR/ub-invalid-values.rs:8:5 - | -LL | bool_cast(&v as *const u8 as *const bool); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ the failure occurred here error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.rs b/tests/ui/consts/const-eval/ub-ref-ptr.rs index 78d6fb5b65b..50e510a3d54 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.rs +++ b/tests/ui/consts/const-eval/ub-ref-ptr.rs @@ -63,7 +63,7 @@ const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; const UNALIGNED_READ: () = unsafe { let x = &[0u8; 4]; let ptr = x.as_ptr().cast::<u32>(); - ptr.read(); //~ inside `UNALIGNED_READ` + ptr.read(); //~ ERROR evaluation of constant value failed }; diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 3bbf2977392..72a523282e6 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -149,19 +149,15 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; } error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $DIR/ub-ref-ptr.rs:66:5 | - = note: accessing memory based on pointer with alignment 1, but alignment 4 is required +LL | ptr.read(); + | ^^^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required | -note: inside `std::ptr::read::<u32>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::const_ptr::<impl *const u32>::read` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `UNALIGNED_READ` - --> $DIR/ub-ref-ptr.rs:66:5 - | -LL | ptr.read(); - | ^^^^^^^^^^ +note: inside `std::ptr::read::<u32>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL error: aborting due to 15 previous errors diff --git a/tests/ui/consts/const-eval/unwind-abort.rs b/tests/ui/consts/const-eval/unwind-abort.rs index 8d5ed876e43..fee53f8528d 100644 --- a/tests/ui/consts/const-eval/unwind-abort.rs +++ b/tests/ui/consts/const-eval/unwind-abort.rs @@ -1,8 +1,8 @@ const extern "C" fn foo() { - panic!() //~ ERROR evaluation of constant value failed + panic!() //~ inside `foo` } -const _: () = foo(); +const _: () = foo(); //~ ERROR evaluation of constant value failed // Ensure that the CTFE engine handles calls to `extern "C"` aborting gracefully fn main() { diff --git a/tests/ui/consts/const-eval/unwind-abort.stderr b/tests/ui/consts/const-eval/unwind-abort.stderr index 340f1dbe841..96c0dd7c5e9 100644 --- a/tests/ui/consts/const-eval/unwind-abort.stderr +++ b/tests/ui/consts/const-eval/unwind-abort.stderr @@ -1,19 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/unwind-abort.rs:2:5 + --> $DIR/unwind-abort.rs:5:15 | -LL | panic!() - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:2:5 +LL | const _: () = foo(); + | ^^^^^ evaluation panicked: explicit panic | note: inside `foo` --> $DIR/unwind-abort.rs:2:5 | LL | panic!() - | ^^^^^^^^ -note: inside `_` - --> $DIR/unwind-abort.rs:5:15 - | -LL | const _: () = foo(); - | ^^^^^ + | ^^^^^^^^ the failure occurred here = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs index 261dea6182d..c4df93b6239 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -1,6 +1,5 @@ const fn foo() -> ! { - unsafe { std::mem::transmute(()) } - //~^ ERROR evaluation of constant value failed + unsafe { std::mem::transmute(()) } //~ inside `foo` } // Type defined in a submodule, so that it is not "visibly" @@ -14,6 +13,7 @@ pub mod empty { } const FOO: [empty::Empty; 3] = [foo(); 3]; +//~^ ERROR evaluation of constant value failed const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; //~^ ERROR evaluation of constant value failed diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr index d9f1780f7b9..29311fdb25a 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr @@ -1,19 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/validate_uninhabited_zsts.rs:2:14 + --> $DIR/validate_uninhabited_zsts.rs:15:33 | -LL | unsafe { std::mem::transmute(()) } - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of the never type `!` +LL | const FOO: [empty::Empty; 3] = [foo(); 3]; + | ^^^^^ constructing invalid value: encountered a value of the never type `!` | note: inside `foo` --> $DIR/validate_uninhabited_zsts.rs:2:14 | LL | unsafe { std::mem::transmute(()) } - | ^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `FOO` - --> $DIR/validate_uninhabited_zsts.rs:16:33 - | -LL | const FOO: [empty::Empty; 3] = [foo(); 3]; - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:18:42 diff --git a/tests/ui/consts/const-fn-in-vec.rs b/tests/ui/consts/const-fn-in-vec.rs index 0483800efef..d1430bc8e00 100644 --- a/tests/ui/consts/const-fn-in-vec.rs +++ b/tests/ui/consts/const-fn-in-vec.rs @@ -1,11 +1,16 @@ static _MAYBE_STRINGS: [Option<String>; 5] = [None; 5]; //~^ ERROR the trait bound `String: Copy` is not satisfied -fn main() { - // should hint to create an inline `const` block - // or to create a new `const` item +// should hint to create an inline `const` block +// or to create a new `const` item +fn foo() { let _strings: [String; 5] = [String::new(); 5]; //~^ ERROR the trait bound `String: Copy` is not satisfied +} + +fn bar() { let _maybe_strings: [Option<String>; 5] = [None; 5]; //~^ ERROR the trait bound `String: Copy` is not satisfied } + +fn main() {} diff --git a/tests/ui/consts/const-fn-in-vec.stderr b/tests/ui/consts/const-fn-in-vec.stderr index b31e180fea2..5be26d7c121 100644 --- a/tests/ui/consts/const-fn-in-vec.stderr +++ b/tests/ui/consts/const-fn-in-vec.stderr @@ -22,7 +22,7 @@ LL | let _strings: [String; 5] = [String::new(); 5]; = note: the `Copy` trait is required because this value will be copied for each element of the array error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/const-fn-in-vec.rs:9:48 + --> $DIR/const-fn-in-vec.rs:12:48 | LL | let _maybe_strings: [Option<String>; 5] = [None; 5]; | ^^^^ diff --git a/tests/ui/consts/const-ptr-is-null.rs b/tests/ui/consts/const-ptr-is-null.rs index 0abd9afa422..319f6b1a62b 100644 --- a/tests/ui/consts/const-ptr-is-null.rs +++ b/tests/ui/consts/const-ptr-is-null.rs @@ -19,7 +19,7 @@ const MAYBE_NULL: () = { assert!(!ptr.wrapping_byte_sub(1).is_null()); // ... but once we shift outside the allocation, with an offset divisible by 4, // we might become null. - assert!(!ptr.wrapping_sub(512).is_null()); //~inside `MAYBE_NULL` + assert!(!ptr.wrapping_sub(512).is_null()); //~ ERROR evaluation of constant value failed }; fn main() {} diff --git a/tests/ui/consts/const-ptr-is-null.stderr b/tests/ui/consts/const-ptr-is-null.stderr index 5ef79790d93..ff2db14a2f5 100644 --- a/tests/ui/consts/const-ptr-is-null.stderr +++ b/tests/ui/consts/const-ptr-is-null.stderr @@ -1,18 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/const-ptr-is-null.rs:22:14 | - = note: the evaluated program panicked at 'null-ness of this pointer cannot be determined in const context', $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL +LL | assert!(!ptr.wrapping_sub(512).is_null()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: null-ness of this pointer cannot be determined in const context | -note: inside `std::ptr::const_ptr::<impl *const T>::is_null::compiletime` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL note: inside `std::ptr::const_ptr::<impl *const i32>::is_null` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `MAYBE_NULL` - --> $DIR/const-ptr-is-null.rs:22:14 - | -LL | assert!(!ptr.wrapping_sub(512).is_null()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `const_eval_select` (in Nightly builds, run with -Z macro-backtrace for more info) +note: inside `std::ptr::const_ptr::<impl *const T>::is_null::compiletime` + --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + = note: this error originates in the macro `$crate::intrinsics::const_eval_select` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-unwrap.rs b/tests/ui/consts/const-unwrap.rs index ea0a15af1be..d48078a0834 100644 --- a/tests/ui/consts/const-unwrap.rs +++ b/tests/ui/consts/const-unwrap.rs @@ -5,7 +5,7 @@ const FOO: i32 = Some(42i32).unwrap(); const BAR: i32 = Option::<i32>::None.unwrap(); //~^ ERROR: evaluation of constant value failed -//~| NOTE: the evaluated program panicked +//~| NOTE: called `Option::unwrap()` on a `None` value const BAZ: i32 = Option::<i32>::None.expect("absolutely not!"); //~^ ERROR: evaluation of constant value failed diff --git a/tests/ui/consts/const-unwrap.stderr b/tests/ui/consts/const-unwrap.stderr index aa5dd9a5c36..832c95992c8 100644 --- a/tests/ui/consts/const-unwrap.stderr +++ b/tests/ui/consts/const-unwrap.stderr @@ -2,13 +2,13 @@ error[E0080]: evaluation of constant value failed --> $DIR/const-unwrap.rs:6:18 | LL | const BAR: i32 = Option::<i32>::None.unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'called `Option::unwrap()` on a `None` value', $DIR/const-unwrap.rs:6:38 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: called `Option::unwrap()` on a `None` value error[E0080]: evaluation of constant value failed --> $DIR/const-unwrap.rs:10:18 | LL | const BAZ: i32 = Option::<i32>::None.expect("absolutely not!"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'absolutely not!', $DIR/const-unwrap.rs:10:38 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: absolutely not! error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const_unsafe_unreachable_ub.rs b/tests/ui/consts/const_unsafe_unreachable_ub.rs index 705e208b56d..a3f7fd46a75 100644 --- a/tests/ui/consts/const_unsafe_unreachable_ub.rs +++ b/tests/ui/consts/const_unsafe_unreachable_ub.rs @@ -1,13 +1,14 @@ -//@ error-pattern: evaluation of constant value failed - const unsafe fn foo(x: bool) -> bool { match x { true => true, - false => std::hint::unreachable_unchecked(), + false => std::hint::unreachable_unchecked(), //~ NOTE inside `foo` } } const BAR: bool = unsafe { foo(false) }; +//~^ ERROR evaluation of constant value failed +//~| NOTE entering unreachable code +//~| NOTE inside `unreachable_unchecked` fn main() { assert_eq!(BAR, true); diff --git a/tests/ui/consts/const_unsafe_unreachable_ub.stderr b/tests/ui/consts/const_unsafe_unreachable_ub.stderr index 6394563e2bb..079ed77b219 100644 --- a/tests/ui/consts/const_unsafe_unreachable_ub.stderr +++ b/tests/ui/consts/const_unsafe_unreachable_ub.stderr @@ -1,20 +1,16 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/hint.rs:LL:COL + --> $DIR/const_unsafe_unreachable_ub.rs:8:28 | - = note: entering unreachable code +LL | const BAR: bool = unsafe { foo(false) }; + | ^^^^^^^^^^ entering unreachable code | -note: inside `unreachable_unchecked` - --> $SRC_DIR/core/src/hint.rs:LL:COL note: inside `foo` - --> $DIR/const_unsafe_unreachable_ub.rs:6:18 + --> $DIR/const_unsafe_unreachable_ub.rs:4:18 | LL | false => std::hint::unreachable_unchecked(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `BAR` - --> $DIR/const_unsafe_unreachable_ub.rs:10:28 - | -LL | const BAR: bool = unsafe { foo(false) }; - | ^^^^^^^^^^ +note: inside `unreachable_unchecked` + --> $SRC_DIR/core/src/hint.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/consts/control-flow/assert.stderr b/tests/ui/consts/control-flow/assert.stderr index 2f863daf760..fc378f57fa4 100644 --- a/tests/ui/consts/control-flow/assert.stderr +++ b/tests/ui/consts/control-flow/assert.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/assert.rs:5:15 | LL | const _: () = assert!(false); - | ^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:5:15 + | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/issue-32829.stderr b/tests/ui/consts/issue-32829.stderr index 8eee87af8e1..0cbc73cfaa3 100644 --- a/tests/ui/consts/issue-32829.stderr +++ b/tests/ui/consts/issue-32829.stderr @@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/issue-32829.rs:1:22 | LL | static S : u64 = { { panic!("foo"); 0 } }; - | ^^^^^^^^^^^^^ the evaluated program panicked at 'foo', $DIR/issue-32829.rs:1:22 + | ^^^^^^^^^^^^^ evaluation panicked: foo | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/issue-66693-panic-in-array-len.stderr b/tests/ui/consts/issue-66693-panic-in-array-len.stderr index 1585ea317d9..9cf5ad126f3 100644 --- a/tests/ui/consts/issue-66693-panic-in-array-len.stderr +++ b/tests/ui/consts/issue-66693-panic-in-array-len.stderr @@ -10,7 +10,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-66693-panic-in-array-len.rs:10:21 | LL | let _ = [false; panic!()]; - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-66693-panic-in-array-len.rs:10:21 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/issue-66693.stderr b/tests/ui/consts/issue-66693.stderr index a435ace4773..46f30a8cbab 100644 --- a/tests/ui/consts/issue-66693.stderr +++ b/tests/ui/consts/issue-66693.stderr @@ -18,7 +18,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-66693.rs:16:15 | LL | const _: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-66693.rs:16:15 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -26,7 +26,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/issue-66693.rs:18:19 | LL | static _BAR: () = panic!("panic in static"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'panic in static', $DIR/issue-66693.rs:18:19 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: panic in static | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/issue-76064.stderr b/tests/ui/consts/issue-76064.stderr index fabebdb1a77..55059220388 100644 --- a/tests/ui/consts/issue-76064.stderr +++ b/tests/ui/consts/issue-76064.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-76064.rs:1:17 | LL | struct Bug([u8; panic!("panic")]); - | ^^^^^^^^^^^^^^^ the evaluated program panicked at 'panic', $DIR/issue-76064.rs:1:17 + | ^^^^^^^^^^^^^^^ evaluation panicked: panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/issue-miri-1910.rs b/tests/ui/consts/issue-miri-1910.rs index 107d9742b92..d194dd3c78b 100644 --- a/tests/ui/consts/issue-miri-1910.rs +++ b/tests/ui/consts/issue-miri-1910.rs @@ -5,6 +5,7 @@ const C: () = unsafe { let foo = Some(&42 as *const i32); let one_and_a_half_pointers = std::mem::size_of::<*const i32>()/2*3; (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); + //~^ ERROR evaluation of constant value failed }; fn main() { diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index 32beed5dba0..59cbccc13a7 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -1,17 +1,13 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $DIR/issue-miri-1910.rs:7:5 | - = note: unable to turn pointer into integer +LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer | -note: inside `std::ptr::read::<u8>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::const_ptr::<impl *const u8>::read` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `C` - --> $DIR/issue-miri-1910.rs:7:5 - | -LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `std::ptr::read::<u8>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/miri_unleashed/abi-mismatch.rs b/tests/ui/consts/miri_unleashed/abi-mismatch.rs index da5b1dd5802..ea640ae78d5 100644 --- a/tests/ui/consts/miri_unleashed/abi-mismatch.rs +++ b/tests/ui/consts/miri_unleashed/abi-mismatch.rs @@ -4,13 +4,12 @@ const extern "C" fn c_fn() {} const fn call_rust_fn(my_fn: extern "Rust" fn()) { - my_fn(); - //~^ ERROR could not evaluate static initializer - //~| NOTE calling a function with calling convention C using calling convention Rust - //~| NOTE inside `call_rust_fn` + my_fn(); //~ NOTE inside `call_rust_fn` + //~^ NOTE the failure occurred here } static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); -//~^ NOTE inside `VAL` +//~^ ERROR could not evaluate static initializer +//~| NOTE calling a function with calling convention C using calling convention Rust fn main() {} diff --git a/tests/ui/consts/miri_unleashed/abi-mismatch.stderr b/tests/ui/consts/miri_unleashed/abi-mismatch.stderr index 639795efae7..88623b134b0 100644 --- a/tests/ui/consts/miri_unleashed/abi-mismatch.stderr +++ b/tests/ui/consts/miri_unleashed/abi-mismatch.stderr @@ -1,19 +1,14 @@ error[E0080]: could not evaluate static initializer - --> $DIR/abi-mismatch.rs:7:5 + --> $DIR/abi-mismatch.rs:11:18 | -LL | my_fn(); - | ^^^^^^^ calling a function with calling convention C using calling convention Rust +LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention C using calling convention Rust | note: inside `call_rust_fn` --> $DIR/abi-mismatch.rs:7:5 | LL | my_fn(); - | ^^^^^^^ -note: inside `VAL` - --> $DIR/abi-mismatch.rs:13:18 - | -LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ the failure occurred here warning: skipping const checks | diff --git a/tests/ui/consts/miri_unleashed/assoc_const.rs b/tests/ui/consts/miri_unleashed/assoc_const.rs index db37197f190..96b47ff4e5e 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.rs +++ b/tests/ui/consts/miri_unleashed/assoc_const.rs @@ -9,7 +9,7 @@ trait Foo<T> { } trait Bar<T, U: Foo<T>> { - const F: u32 = (U::X, 42).1; + const F: u32 = (U::X, 42).1; //~ ERROR } impl Foo<u32> for () { @@ -26,5 +26,5 @@ fn main() { // this is fine, but would have been forbidden by the static checks on `F` let x = <() as Bar<u32, ()>>::F; // this test only causes errors due to the line below, so post-monomorphization - let y = <String as Bar<Vec<u32>, String>>::F; //~ constant + let y = <String as Bar<Vec<u32>, String>>::F; } diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index 3303a784265..f259765f6e5 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,17 +1,13 @@ -error[E0080]: evaluation of `<String as Bar<Vec<u32>, String>>::F` failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +error[E0080]: evaluation of `std::ptr::drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))` failed + --> $DIR/assoc_const.rs:12:31 | - = note: calling non-const function `<Vec<u32> as Drop>::drop` +LL | const F: u32 = (U::X, 42).1; + | ^ calling non-const function `<Vec<u32> as Drop>::drop` | -note: inside `std::ptr::drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::drop_in_place::<(Vec<u32>, u32)> - shim(Some((Vec<u32>, u32)))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `<String as Bar<Vec<u32>, String>>::F` - --> $DIR/assoc_const.rs:12:31 - | -LL | const F: u32 = (U::X, 42).1; - | ^ +note: inside `std::ptr::drop_in_place::<Vec<u32>> - shim(Some(Vec<u32>))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: erroneous constant encountered --> $DIR/assoc_const.rs:29:13 diff --git a/tests/ui/consts/miri_unleashed/drop.stderr b/tests/ui/consts/miri_unleashed/drop.stderr index 5c415b5bac1..40a29d5a819 100644 --- a/tests/ui/consts/miri_unleashed/drop.stderr +++ b/tests/ui/consts/miri_unleashed/drop.stderr @@ -1,15 +1,11 @@ error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $DIR/drop.rs:17:1 | - = note: calling non-const function `<Vec<i32> as Drop>::drop` +LL | }; + | ^ calling non-const function `<Vec<i32> as Drop>::drop` | note: inside `std::ptr::drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `TEST_BAD` - --> $DIR/drop.rs:17:1 - | -LL | }; - | ^ warning: skipping const checks | diff --git a/tests/ui/consts/missing_span_in_backtrace.rs b/tests/ui/consts/missing_span_in_backtrace.rs index 703cc7fbf89..c8c7453daa1 100644 --- a/tests/ui/consts/missing_span_in_backtrace.rs +++ b/tests/ui/consts/missing_span_in_backtrace.rs @@ -13,7 +13,7 @@ const X: () = { // Swap them, bytewise. unsafe { - ptr::swap_nonoverlapping( + ptr::swap_nonoverlapping( //~ ERROR evaluation of constant value failed &mut ptr1 as *mut _ as *mut MaybeUninit<u8>, &mut ptr2 as *mut _ as *mut MaybeUninit<u8>, mem::size_of::<&i32>(), diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index 05ae7305dbc..2f3a65302bd 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -1,17 +1,4 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | - = note: unable to copy parts of a pointer from memory at ALLOC0 - | -note: inside `std::ptr::read::<MaybeUninit<MaybeUninit<u8>>>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `std::ptr::swap_nonoverlapping_simple_untyped::<MaybeUninit<u8>>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `swap_nonoverlapping::compiletime::<MaybeUninit<u8>>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `swap_nonoverlapping::<MaybeUninit<u8>>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `X` --> $DIR/missing_span_in_backtrace.rs:16:9 | 16 | / ptr::swap_nonoverlapping( @@ -19,7 +6,16 @@ note: inside `X` 18 | | &mut ptr2 as *mut _ as *mut MaybeUninit<u8>, 19 | | mem::size_of::<&i32>(), 20 | | ); - | |_________^ + | |_________^ unable to copy parts of a pointer from memory at ALLOC0 + | +note: inside `swap_nonoverlapping::<MaybeUninit<u8>>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `swap_nonoverlapping::compiletime::<MaybeUninit<u8>>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `std::ptr::swap_nonoverlapping_simple_untyped::<MaybeUninit<u8>>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `std::ptr::read::<MaybeUninit<MaybeUninit<u8>>>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: this error originates in the macro `$crate::intrinsics::const_eval_select` which comes from the expansion of the macro `const_eval_select` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/offset_from_ub.rs b/tests/ui/consts/offset_from_ub.rs index 39384bf0c8b..53d9c7a39da 100644 --- a/tests/ui/consts/offset_from_ub.rs +++ b/tests/ui/consts/offset_from_ub.rs @@ -21,7 +21,7 @@ pub const DIFFERENT_ALLOC: usize = { }; pub const NOT_PTR: usize = { - unsafe { (42 as *const u8).offset_from(&5u8) as usize } + unsafe { (42 as *const u8).offset_from(&5u8) as usize } //~ ERROR evaluation of constant value failed }; pub const NOT_MULTIPLE_OF_SIZE: isize = { @@ -107,13 +107,13 @@ pub const OFFSET_VERY_FAR1: isize = { let ptr1 = ptr::null::<u8>(); let ptr2 = ptr1.wrapping_offset(isize::MAX); unsafe { ptr2.offset_from(ptr1) } - //~^ inside + //~^ ERROR evaluation of constant value failed }; pub const OFFSET_VERY_FAR2: isize = { let ptr1 = ptr::null::<u8>(); let ptr2 = ptr1.wrapping_offset(isize::MAX); unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } - //~^ inside + //~^ ERROR evaluation of constant value failed }; // If the pointers are the same, OOB/null/UAF is fine. diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index 8cfbdd13190..08e42c9f30b 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -5,17 +5,13 @@ LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_from_ub.rs:24:14 | - = note: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation +LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `NOT_PTR` - --> $DIR/offset_from_ub.rs:24:14 - | -LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:31:14 @@ -78,30 +74,22 @@ LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called when first pointer is too far ahead of second error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_from_ub.rs:109:14 | - = note: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation +LL | unsafe { ptr2.offset_from(ptr1) } + | ^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `OFFSET_VERY_FAR1` - --> $DIR/offset_from_ub.rs:109:14 - | -LL | unsafe { ptr2.offset_from(ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_from_ub.rs:115:14 | - = note: `ptr_offset_from` called when first pointer is too far before second +LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called when first pointer is too far before second | note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `OFFSET_VERY_FAR2` - --> $DIR/offset_from_ub.rs:115:14 - | -LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 14 previous errors diff --git a/tests/ui/consts/offset_ub.rs b/tests/ui/consts/offset_ub.rs index dda6dd388f2..8c52586c485 100644 --- a/tests/ui/consts/offset_ub.rs +++ b/tests/ui/consts/offset_ub.rs @@ -5,21 +5,21 @@ use std::ptr; //@ normalize-stderr: "\d+ bytes" -> "$$BYTES bytes" -pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; //~NOTE -pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; //~NOTE -pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; //~NOTE +pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; //~ ERROR +pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; //~ ERROR +pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; //~ ERROR -pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; //~NOTE -pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; //~NOTE -pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; //~NOTE -pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; //~NOTE -pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; //~NOTE +pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; //~ ERROR +pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; //~ ERROR +pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; //~ ERROR +pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; //~ ERROR +pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; //~ ERROR -pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; //~NOTE -pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) }; //~NOTE +pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; //~ ERROR +pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) }; //~ ERROR // Make sure that we don't panic when computing abs(offset*size_of::<T>()) -pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; //~NOTE +pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; //~ ERROR // Offset-by-zero is allowed. pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::<u8>().offset(0) }; diff --git a/tests/ui/consts/offset_ub.stderr b/tests/ui/consts/offset_ub.stderr index 779cb9654f4..a247ad25465 100644 --- a/tests/ui/consts/offset_ub.stderr +++ b/tests/ui/consts/offset_ub.stderr @@ -1,145 +1,101 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:8:46 | - = note: out-of-bounds pointer arithmetic: expected a pointer to the end of 1 byte of memory, but got ALLOC0 which is at the beginning of the allocation +LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of 1 byte of memory, but got ALLOC0 which is at the beginning of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `BEFORE_START` - --> $DIR/offset_ub.rs:8:46 - | -LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:9:43 | - = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC1 which is only 1 byte from the end of the allocation +LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC1 which is only 1 byte from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `AFTER_END` - --> $DIR/offset_ub.rs:9:43 - | -LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:10:45 | - = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC2 which is only $BYTES bytes from the end of the allocation +LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got ALLOC2 which is only $BYTES bytes from the end of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `AFTER_ARRAY` - --> $DIR/offset_ub.rs:10:45 - | -LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:12:43 | - = note: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` +LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` | note: inside `std::ptr::const_ptr::<impl *const u16>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `OVERFLOW` - --> $DIR/offset_ub.rs:12:43 - | -LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:13:44 | - = note: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` +LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize` | note: inside `std::ptr::const_ptr::<impl *const u16>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `UNDERFLOW` - --> $DIR/offset_ub.rs:13:44 - | -LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:14:56 | - = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) +LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `OVERFLOW_ADDRESS_SPACE` - --> $DIR/offset_ub.rs:14:56 - | -LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:15:57 | - = note: out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) +LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `UNDERFLOW_ADDRESS_SPACE` - --> $DIR/offset_ub.rs:15:57 - | -LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:16:49 | - = note: out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got ALLOC3-0x2 which points to before the beginning of the allocation +LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got ALLOC3-0x2 which points to before the beginning of the allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `NEGATIVE_OFFSET` - --> $DIR/offset_ub.rs:16:49 - | -LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:18:50 | - = note: out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes +LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 1 byte of memory, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `ZERO_SIZED_ALLOC` - --> $DIR/offset_ub.rs:18:50 - | -LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:19:42 | - = note: out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) +LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to $BYTES bytes of memory, but got 0x1[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset` --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL -note: inside `DANGLING` - --> $DIR/offset_ub.rs:19:42 - | -LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + --> $DIR/offset_ub.rs:22:47 | - = note: out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) +LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to the end of $BYTES bytes of memory, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance) | note: inside `std::ptr::const_ptr::<impl *const u8>::offset` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `UNDERFLOW_ABS` - --> $DIR/offset_ub.rs:22:47 - | -LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 11 previous errors diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.rs b/tests/ui/consts/qualif-indirect-mutation-fail.rs index 0f59a86b7cc..4abb231c29f 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.rs +++ b/tests/ui/consts/qualif-indirect-mutation-fail.rs @@ -15,7 +15,7 @@ pub const A1: () = { let b = &mut y; std::mem::swap(a, b); std::mem::forget(y); -}; +}; //~ ERROR evaluation of constant value failed // Mutable borrow of a type with drop impl. pub const A2: () = { @@ -26,7 +26,7 @@ pub const A2: () = { std::mem::swap(a, b); std::mem::forget(y); let _z = x; //~ ERROR destructor of -}; +}; //~ ERROR evaluation of constant value failed // Shared borrow of a type that might be !Freeze and Drop. pub const fn g1<T>() { diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr index e76d7d3b670..d3bb01af754 100644 --- a/tests/ui/consts/qualif-indirect-mutation-fail.stderr +++ b/tests/ui/consts/qualif-indirect-mutation-fail.stderr @@ -8,21 +8,17 @@ LL | }; | - value is dropped here error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $DIR/qualif-indirect-mutation-fail.rs:18:1 | - = note: calling non-const function `<Vec<u8> as Drop>::drop` +LL | }; + | ^ calling non-const function `<Vec<u8> as Drop>::drop` | -note: inside `std::ptr::drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))` +note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))` +note: inside `std::ptr::drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `A1` - --> $DIR/qualif-indirect-mutation-fail.rs:18:1 - | -LL | }; - | ^ error[E0493]: destructor of `Option<String>` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:28:9 @@ -33,21 +29,17 @@ LL | }; | - value is dropped here error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + --> $DIR/qualif-indirect-mutation-fail.rs:29:1 | - = note: calling non-const function `<Vec<u8> as Drop>::drop` +LL | }; + | ^ calling non-const function `<Vec<u8> as Drop>::drop` | -note: inside `std::ptr::drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))` +note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `std::ptr::drop_in_place::<String> - shim(Some(String))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `std::ptr::drop_in_place::<Option<String>> - shim(Some(Option<String>))` +note: inside `std::ptr::drop_in_place::<Vec<u8>> - shim(Some(Vec<u8>))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `A2` - --> $DIR/qualif-indirect-mutation-fail.rs:29:1 - | -LL | }; - | ^ error[E0493]: destructor of `(u32, Option<String>)` cannot be evaluated at compile-time --> $DIR/qualif-indirect-mutation-fail.rs:6:9 diff --git a/tests/ui/consts/recursive.rs b/tests/ui/consts/recursive.rs index 5d736e31bcb..b5703d11310 100644 --- a/tests/ui/consts/recursive.rs +++ b/tests/ui/consts/recursive.rs @@ -2,9 +2,8 @@ const fn f<T>(x: T) { //~ WARN function cannot return without recursing f(x); - //~^ ERROR evaluation of constant value failed } -const X: () = f(1); +const X: () = f(1); //~ ERROR evaluation of constant value failed fn main() {} diff --git a/tests/ui/consts/recursive.stderr b/tests/ui/consts/recursive.stderr index 0046005c74f..fd38b078b94 100644 --- a/tests/ui/consts/recursive.stderr +++ b/tests/ui/consts/recursive.stderr @@ -10,26 +10,21 @@ LL | f(x); = note: `#[warn(unconditional_recursion)]` on by default error[E0080]: evaluation of constant value failed - --> $DIR/recursive.rs:4:5 + --> $DIR/recursive.rs:7:15 | -LL | f(x); - | ^^^^ reached the configured maximum number of stack frames +LL | const X: () = f(1); + | ^^^^ reached the configured maximum number of stack frames | -note: inside `f::<i32>` +note: [... 126 additional calls inside `f::<i32>` ...] --> $DIR/recursive.rs:4:5 | LL | f(x); | ^^^^ -note: [... 126 additional calls inside `f::<i32>` ...] +note: inside `f::<i32>` --> $DIR/recursive.rs:4:5 | LL | f(x); - | ^^^^ -note: inside `X` - --> $DIR/recursive.rs:8:15 - | -LL | const X: () = f(1); - | ^^^^ + | ^^^^ the failure occurred here error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr index c3b641a899a..08d0b338728 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-called-fn.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-called-fn.rs:10:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr index c3b641a899a..08d0b338728 100644 --- a/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-called-fn.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-called-fn.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-called-fn.rs:10:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr index 75c3575a110..41fe2cf84e4 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-closure.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-closure.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr index 75c3575a110..41fe2cf84e4 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-closure.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-closure.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-closure.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr index 73790f7517d..b62b25bd3aa 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-drop.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-drop.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr index 73790f7517d..b62b25bd3aa 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-drop.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-drop.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-drop.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr index 706c0d55b62..c8a7cf983c4 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr index 706c0d55b62..c8a7cf983c4 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-assoc-type.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fn-behind-assoc-type.rs:10:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr index 581edd2b7b8..1e68d66cf5e 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-fn-behind-generic.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fn-behind-generic.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr index 581edd2b7b8..1e68d66cf5e 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-generic.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-fn-behind-generic.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fn-behind-generic.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr index 07e46b8a816..a9cc56fba45 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `m::Fail::<i32>::C` failed --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr index 07e46b8a816..a9cc56fba45 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn-behind-opaque-type.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `m::Fail::<i32>::C` failed --> $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fn-behind-opaque-type.rs:11:23 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr index 52462076ff9..ec549561a17 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-fn.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fn.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr index 52462076ff9..ec549561a17 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fn.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-fn.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fn.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr index dea2a342383..dfaf69d52b2 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Late::<i32>::FAIL` failed --> $DIR/collect-in-dead-fnptr-in-const.rs:9:22 | LL | const FAIL: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fnptr-in-const.rs:9:22 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr index dea2a342383..dfaf69d52b2 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr-in-const.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Late::<i32>::FAIL` failed --> $DIR/collect-in-dead-fnptr-in-const.rs:9:22 | LL | const FAIL: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fnptr-in-const.rs:9:22 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr index 51c68782687..7cbd423cdc0 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-fnptr.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fnptr.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr index 51c68782687..7cbd423cdc0 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-fnptr.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-fnptr.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-fnptr.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr index 2ab1f80e2d3..58e9d7a2c9a 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-move.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-move.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr index 2ab1f80e2d3..58e9d7a2c9a 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-move.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-move.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-move.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr index b4e18706489..6c78ca79fd6 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-vtable.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-vtable.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr index b4e18706489..6c78ca79fd6 100644 --- a/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-dead-vtable.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-dead-vtable.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-dead-vtable.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr index a50c49d5362..fd231e1101d 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-promoted-const.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-promoted-const.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr index cf0aa8ef7a7..0f3f77769ad 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<T>::C` failed --> $DIR/collect-in-promoted-const.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-promoted-const.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -16,7 +16,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/collect-in-promoted-const.rs:9:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-promoted-const.rs:9:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr index 0e3bbbcc2ec..d2145089028 100644 --- a/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-const-called-fn.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/interpret-in-const-called-fn.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/interpret-in-const-called-fn.rs:8:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr b/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr index 0e3bbbcc2ec..d2145089028 100644 --- a/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-const-called-fn.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/interpret-in-const-called-fn.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/interpret-in-const-called-fn.rs:8:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr index 6ab991b6471..2bd0b92d4c2 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr @@ -1,20 +1,16 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/hint.rs:LL:COL + --> $DIR/interpret-in-promoted.rs:13:28 | - = note: entering unreachable code +LL | let _x: &'static () = &ub(); + | ^^^^ entering unreachable code | -note: inside `unreachable_unchecked` - --> $SRC_DIR/core/src/hint.rs:LL:COL note: inside `ub` --> $DIR/interpret-in-promoted.rs:7:5 | LL | std::hint::unreachable_unchecked(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `FOO` - --> $DIR/interpret-in-promoted.rs:13:28 - | -LL | let _x: &'static () = &ub(); - | ^^^^ +note: inside `unreachable_unchecked` + --> $SRC_DIR/core/src/hint.rs:LL:COL note: erroneous constant encountered --> $DIR/interpret-in-promoted.rs:13:27 diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr index 6ab991b6471..2bd0b92d4c2 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr @@ -1,20 +1,16 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/hint.rs:LL:COL + --> $DIR/interpret-in-promoted.rs:13:28 | - = note: entering unreachable code +LL | let _x: &'static () = &ub(); + | ^^^^ entering unreachable code | -note: inside `unreachable_unchecked` - --> $SRC_DIR/core/src/hint.rs:LL:COL note: inside `ub` --> $DIR/interpret-in-promoted.rs:7:5 | LL | std::hint::unreachable_unchecked(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: inside `FOO` - --> $DIR/interpret-in-promoted.rs:13:28 - | -LL | let _x: &'static () = &ub(); - | ^^^^ +note: inside `unreachable_unchecked` + --> $SRC_DIR/core/src/hint.rs:LL:COL note: erroneous constant encountered --> $DIR/interpret-in-promoted.rs:13:27 diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.rs b/tests/ui/consts/required-consts/interpret-in-promoted.rs index 48caece6ff5..2c7b3375054 100644 --- a/tests/ui/consts/required-consts/interpret-in-promoted.rs +++ b/tests/ui/consts/required-consts/interpret-in-promoted.rs @@ -4,13 +4,13 @@ //! Make sure we evaluate const fn calls even if they get promoted and their result ignored. const unsafe fn ub() { - std::hint::unreachable_unchecked(); + std::hint::unreachable_unchecked(); //~ inside `ub` } pub const FOO: () = unsafe { // Make sure that this gets promoted and then fails to evaluate, and we deal with that // correctly. - let _x: &'static () = &ub(); //~ erroneous constant + let _x: &'static () = &ub(); //~ ERROR evaluation of constant value failed }; fn main() {} diff --git a/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr index 5e8da609e76..f999bf370b8 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.noopt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/interpret-in-static.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/interpret-in-static.rs:8:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/required-consts/interpret-in-static.opt.stderr b/tests/ui/consts/required-consts/interpret-in-static.opt.stderr index 5e8da609e76..f999bf370b8 100644 --- a/tests/ui/consts/required-consts/interpret-in-static.opt.stderr +++ b/tests/ui/consts/required-consts/interpret-in-static.opt.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `Fail::<i32>::C` failed --> $DIR/interpret-in-static.rs:8:19 | LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/interpret-in-static.rs:8:19 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/consts/uninhabited-const-issue-61744.rs b/tests/ui/consts/uninhabited-const-issue-61744.rs index 19ee842c36b..743aaf58ef5 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.rs +++ b/tests/ui/consts/uninhabited-const-issue-61744.rs @@ -1,7 +1,7 @@ //@ build-fail pub const unsafe fn fake_type<T>() -> T { - hint_unreachable() //~ ERROR evaluation of `<i32 as Const>::CONSTANT` failed + hint_unreachable() //~ inside } pub const unsafe fn hint_unreachable() -> ! { @@ -9,7 +9,7 @@ pub const unsafe fn hint_unreachable() -> ! { } trait Const { - const CONSTANT: i32 = unsafe { fake_type() }; //~ inside + const CONSTANT: i32 = unsafe { fake_type() }; //~ ERROR evaluation of `fake_type::<!>` failed } impl<T> Const for T {} diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index 7575ad730b3..dd175b92593 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -1,10 +1,10 @@ -error[E0080]: evaluation of `<i32 as Const>::CONSTANT` failed - --> $DIR/uninhabited-const-issue-61744.rs:4:5 +error[E0080]: evaluation of `fake_type::<!>` failed + --> $DIR/uninhabited-const-issue-61744.rs:12:36 | -LL | hint_unreachable() - | ^^^^^^^^^^^^^^^^^^ reached the configured maximum number of stack frames +LL | const CONSTANT: i32 = unsafe { fake_type() }; + | ^^^^^^^^^^^ reached the configured maximum number of stack frames | -note: inside `fake_type::<!>` +note: inside `fake_type::<i32>` --> $DIR/uninhabited-const-issue-61744.rs:4:5 | LL | hint_unreachable() @@ -634,16 +634,11 @@ note: inside `hint_unreachable` | LL | fake_type() | ^^^^^^^^^^^ -note: inside `fake_type::<i32>` +note: inside `fake_type::<!>` --> $DIR/uninhabited-const-issue-61744.rs:4:5 | LL | hint_unreachable() - | ^^^^^^^^^^^^^^^^^^ -note: inside `<i32 as Const>::CONSTANT` - --> $DIR/uninhabited-const-issue-61744.rs:12:36 - | -LL | const CONSTANT: i32 = unsafe { fake_type() }; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ the failure occurred here error: aborting due to 1 previous error diff --git a/tests/ui/deriving/deriving-with-helper.rs b/tests/ui/deriving/deriving-with-helper.rs index c71d553c892..df98bb6beb9 100644 --- a/tests/ui/deriving/deriving-with-helper.rs +++ b/tests/ui/deriving/deriving-with-helper.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ check-pass //@ compile-flags: --crate-type=lib @@ -8,6 +9,9 @@ #![no_core] +extern crate minicore; +use minicore::*; + #[rustc_builtin_macro] macro derive() {} @@ -26,9 +30,6 @@ mod default { } } -#[lang = "sized"] -trait Sized {} - #[derive(Default)] enum S { #[default] // OK diff --git a/tests/ui/error-codes/E0511.rs b/tests/ui/error-codes/E0511.rs index 81656c71088..c7e59c5c6c9 100644 --- a/tests/ui/error-codes/E0511.rs +++ b/tests/ui/error-codes/E0511.rs @@ -1,11 +1,11 @@ //@ build-fail -#![feature(intrinsics)] +#![feature(core_intrinsics)] -extern "rust-intrinsic" { - fn simd_add<T>(a: T, b: T) -> T; -} +use std::intrinsics::simd::simd_add; fn main() { - unsafe { simd_add(0, 1); } //~ ERROR E0511 + unsafe { + simd_add(0, 1) //~ ERROR E0511 + }; } diff --git a/tests/ui/error-codes/E0511.stderr b/tests/ui/error-codes/E0511.stderr index 59eb19d2ee5..45f5b8d238d 100644 --- a/tests/ui/error-codes/E0511.stderr +++ b/tests/ui/error-codes/E0511.stderr @@ -1,8 +1,8 @@ error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/E0511.rs:10:14 + --> $DIR/E0511.rs:9:9 | -LL | unsafe { simd_add(0, 1); } - | ^^^^^^^^^^^^^^ +LL | simd_add(0, 1) + | ^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0771.stderr b/tests/ui/error-codes/E0771.stderr index 5e829e6f6d2..dfeaa347941 100644 --- a/tests/ui/error-codes/E0771.stderr +++ b/tests/ui/error-codes/E0771.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | fn function_with_str<'a, const STRING: &'a str>() {} | ^^ the type must not depend on the parameter `'a` - | - = note: lifetime parameters may not be used in the type of const parameters warning: the feature `unsized_const_params` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/E0771.rs:1:30 diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr index 46769cdea8a..8fb51f5b637 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr @@ -1,29 +1,24 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ctfe-id-unlimited.rs:17:42 + --> $DIR/ctfe-id-unlimited.rs:28:20 | -LL | #[cfg(r#return)] _ => return inner(acc + 1, n - 1), - | ^^^^^^^^^^^^^^^^^^^^^ reached the configured maximum number of stack frames +LL | const ID_ED: u32 = rec_id(ORIGINAL); + | ^^^^^^^^^^^^^^^^ reached the configured maximum number of stack frames | -note: inside `inner` - --> $DIR/ctfe-id-unlimited.rs:17:42 +note: inside `rec_id` + --> $DIR/ctfe-id-unlimited.rs:21:5 | -LL | #[cfg(r#return)] _ => return inner(acc + 1, n - 1), - | ^^^^^^^^^^^^^^^^^^^^^ +LL | inner(0, n) + | ^^^^^^^^^^^ note: [... 125 additional calls inside `inner` ...] --> $DIR/ctfe-id-unlimited.rs:17:42 | LL | #[cfg(r#return)] _ => return inner(acc + 1, n - 1), | ^^^^^^^^^^^^^^^^^^^^^ -note: inside `rec_id` - --> $DIR/ctfe-id-unlimited.rs:22:5 - | -LL | inner(0, n) - | ^^^^^^^^^^^ -note: inside `ID_ED` - --> $DIR/ctfe-id-unlimited.rs:29:20 +note: inside `inner` + --> $DIR/ctfe-id-unlimited.rs:17:42 | -LL | const ID_ED: u32 = rec_id(ORIGINAL); - | ^^^^^^^^^^^^^^^^ +LL | #[cfg(r#return)] _ => return inner(acc + 1, n - 1), + | ^^^^^^^^^^^^^^^^^^^^^ the failure occurred here error: aborting due to 1 previous error diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs index 2a04d4893e6..9e89f4066bb 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs @@ -15,7 +15,6 @@ const fn rec_id(n: u32) -> u32 { 0 => acc, #[cfg(r#become)] _ => become inner(acc + 1, n - 1), #[cfg(r#return)] _ => return inner(acc + 1, n - 1), - //[return]~^ error: evaluation of constant value failed } } @@ -26,7 +25,7 @@ const fn rec_id(n: u32) -> u32 { const ORIGINAL: u32 = 12345; // Original number, but with identity function applied // (this is the same, but requires execution of the recursion) -const ID_ED: u32 = rec_id(ORIGINAL); +const ID_ED: u32 = rec_id(ORIGINAL); //[return]~ error: evaluation of constant value failed // Assert to make absolutely sure the computation actually happens const ASSERT: () = assert!(ORIGINAL == ID_ED); diff --git a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs index fba4a2692af..e7038a01d2d 100644 --- a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs +++ b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs @@ -6,14 +6,11 @@ pub const fn f() { } const fn g() { - panic!() - //~^ error: evaluation of constant value failed - //~| note: in this expansion of panic! - //~| note: inside `g` - //~| note: in this expansion of panic! + panic!() //~ NOTE inside `g` + //~^ NOTE in this expansion of panic! } -const _: () = f(); -//~^ note: inside `_` +const _: () = f(); //~ ERROR evaluation of constant value failed +//~^ NOTE explicit panic fn main() {} diff --git a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr index 8c070512105..ef71722a0ab 100644 --- a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr @@ -1,19 +1,14 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ctfe-tail-call-panic.rs:9:5 + --> $DIR/ctfe-tail-call-panic.rs:13:15 | -LL | panic!() - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/ctfe-tail-call-panic.rs:9:5 +LL | const _: () = f(); + | ^^^ evaluation panicked: explicit panic | note: inside `g` --> $DIR/ctfe-tail-call-panic.rs:9:5 | LL | panic!() - | ^^^^^^^^ -note: inside `_` - --> $DIR/ctfe-tail-call-panic.rs:16:15 - | -LL | const _: () = f(); - | ^^^ + | ^^^^^^^^ the failure occurred here = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs index ce3d3fc645d..6901a2ab9f1 100644 --- a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs +++ b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs @@ -1,9 +1,11 @@ +//@ add-core-stubs //@ needs-llvm-components: avr //@ compile-flags: --target=avr-none -C target-cpu=atmega328p --crate-type=rlib #![no_core] #![feature(no_core, lang_items)] -#[lang="sized"] -trait Sized { } + +extern crate minicore; +use minicore::*; // Test that the AVR interrupt ABI cannot be used when avr_interrupt // feature gate is not used. diff --git a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr index d9f3c3adc7f..768209eec63 100644 --- a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr +++ b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr @@ -1,5 +1,5 @@ error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:11:8 + --> $DIR/feature-gate-abi-avr-interrupt.rs:13:8 | LL | extern "avr-non-blocking-interrupt" fn fu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | extern "avr-non-blocking-interrupt" fn fu() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:13:8 + --> $DIR/feature-gate-abi-avr-interrupt.rs:15:8 | LL | extern "avr-interrupt" fn f() {} | ^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | extern "avr-interrupt" fn f() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:17:12 + --> $DIR/feature-gate-abi-avr-interrupt.rs:19:12 | LL | extern "avr-interrupt" fn m(); | ^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | extern "avr-interrupt" fn m(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:19:12 + --> $DIR/feature-gate-abi-avr-interrupt.rs:21:12 | LL | extern "avr-non-blocking-interrupt" fn mu(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | extern "avr-non-blocking-interrupt" fn mu(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:22:12 + --> $DIR/feature-gate-abi-avr-interrupt.rs:24:12 | LL | extern "avr-interrupt" fn dm() {} | ^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | extern "avr-interrupt" fn dm() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:24:12 + --> $DIR/feature-gate-abi-avr-interrupt.rs:26:12 | LL | extern "avr-non-blocking-interrupt" fn dmu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | extern "avr-non-blocking-interrupt" fn dmu() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:30:12 + --> $DIR/feature-gate-abi-avr-interrupt.rs:32:12 | LL | extern "avr-interrupt" fn m() {} | ^^^^^^^^^^^^^^^ @@ -69,7 +69,7 @@ LL | extern "avr-interrupt" fn m() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:32:12 + --> $DIR/feature-gate-abi-avr-interrupt.rs:34:12 | LL | extern "avr-non-blocking-interrupt" fn mu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -79,7 +79,7 @@ LL | extern "avr-non-blocking-interrupt" fn mu() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:37:12 + --> $DIR/feature-gate-abi-avr-interrupt.rs:39:12 | LL | extern "avr-interrupt" fn im() {} | ^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ LL | extern "avr-interrupt" fn im() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:39:12 + --> $DIR/feature-gate-abi-avr-interrupt.rs:41:12 | LL | extern "avr-non-blocking-interrupt" fn imu() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -99,7 +99,7 @@ LL | extern "avr-non-blocking-interrupt" fn imu() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:43:18 + --> $DIR/feature-gate-abi-avr-interrupt.rs:45:18 | LL | type TA = extern "avr-interrupt" fn(); | ^^^^^^^^^^^^^^^ @@ -109,7 +109,7 @@ LL | type TA = extern "avr-interrupt" fn(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:45:19 + --> $DIR/feature-gate-abi-avr-interrupt.rs:47:19 | LL | type TAU = extern "avr-non-blocking-interrupt" fn(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -119,7 +119,7 @@ LL | type TAU = extern "avr-non-blocking-interrupt" fn(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:48:8 + --> $DIR/feature-gate-abi-avr-interrupt.rs:50:8 | LL | extern "avr-interrupt" {} | ^^^^^^^^^^^^^^^ @@ -129,7 +129,7 @@ LL | extern "avr-interrupt" {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "avr-non-blocking-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-avr-interrupt.rs:50:8 + --> $DIR/feature-gate-abi-avr-interrupt.rs:52:8 | LL | extern "avr-non-blocking-interrupt" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs index bb69a638cee..60bf69f597c 100644 --- a/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs +++ b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.rs @@ -1,9 +1,11 @@ +//@ add-core-stubs //@ needs-llvm-components: msp430 //@ compile-flags: --target=msp430-none-elf --crate-type=rlib #![no_core] #![feature(no_core, lang_items)] -#[lang="sized"] -trait Sized { } + +extern crate minicore; +use minicore::*; extern "msp430-interrupt" fn f() {} //~^ ERROR "msp430-interrupt" ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr index 21ddbf7a86d..4a995b4efa6 100644 --- a/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr +++ b/tests/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr @@ -1,5 +1,5 @@ error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-msp430-interrupt.rs:8:8 + --> $DIR/feature-gate-abi-msp430-interrupt.rs:10:8 | LL | extern "msp430-interrupt" fn f() {} | ^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | extern "msp430-interrupt" fn f() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-msp430-interrupt.rs:12:12 + --> $DIR/feature-gate-abi-msp430-interrupt.rs:14:12 | LL | extern "msp430-interrupt" fn m(); | ^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | extern "msp430-interrupt" fn m(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-msp430-interrupt.rs:15:12 + --> $DIR/feature-gate-abi-msp430-interrupt.rs:17:12 | LL | extern "msp430-interrupt" fn dm() {} | ^^^^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | extern "msp430-interrupt" fn dm() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-msp430-interrupt.rs:21:12 + --> $DIR/feature-gate-abi-msp430-interrupt.rs:23:12 | LL | extern "msp430-interrupt" fn m() {} | ^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | extern "msp430-interrupt" fn m() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-msp430-interrupt.rs:26:12 + --> $DIR/feature-gate-abi-msp430-interrupt.rs:28:12 | LL | extern "msp430-interrupt" fn im() {} | ^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | extern "msp430-interrupt" fn im() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-msp430-interrupt.rs:30:18 + --> $DIR/feature-gate-abi-msp430-interrupt.rs:32:18 | LL | type TA = extern "msp430-interrupt" fn(); | ^^^^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | type TA = extern "msp430-interrupt" fn(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "msp430-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-msp430-interrupt.rs:33:8 + --> $DIR/feature-gate-abi-msp430-interrupt.rs:35:8 | LL | extern "msp430-interrupt" {} | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs index 6f4989fbd9f..006d01c5589 100644 --- a/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs +++ b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.rs @@ -1,9 +1,11 @@ +//@ add-core-stubs //@ needs-llvm-components: riscv //@ compile-flags: --target=riscv32imc-unknown-none-elf --crate-type=rlib #![no_core] #![feature(no_core, lang_items)] -#[lang = "sized"] -trait Sized {} + +extern crate minicore; +use minicore::*; // Test that the riscv interrupt ABIs cannot be used when riscv_interrupt // feature gate is not used. diff --git a/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr index 3c9e99aa1b9..af956c35da6 100644 --- a/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr +++ b/tests/ui/feature-gates/feature-gate-abi-riscv-interrupt.stderr @@ -1,5 +1,5 @@ error[E0658]: the extern "riscv-interrupt-m" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-riscv-interrupt.rs:11:8 + --> $DIR/feature-gate-abi-riscv-interrupt.rs:13:8 | LL | extern "riscv-interrupt-m" fn f() {} | ^^^^^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | extern "riscv-interrupt-m" fn f() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "riscv-interrupt-s" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-riscv-interrupt.rs:13:8 + --> $DIR/feature-gate-abi-riscv-interrupt.rs:15:8 | LL | extern "riscv-interrupt-s" fn f_s() {} | ^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | extern "riscv-interrupt-s" fn f_s() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "riscv-interrupt-m" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-riscv-interrupt.rs:17:12 + --> $DIR/feature-gate-abi-riscv-interrupt.rs:19:12 | LL | extern "riscv-interrupt-m" fn m(); | ^^^^^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | extern "riscv-interrupt-m" fn m(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "riscv-interrupt-m" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-riscv-interrupt.rs:23:12 + --> $DIR/feature-gate-abi-riscv-interrupt.rs:25:12 | LL | extern "riscv-interrupt-m" fn m() {} | ^^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | extern "riscv-interrupt-m" fn m() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "riscv-interrupt-m" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-riscv-interrupt.rs:28:12 + --> $DIR/feature-gate-abi-riscv-interrupt.rs:30:12 | LL | extern "riscv-interrupt-m" fn im() {} | ^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | extern "riscv-interrupt-m" fn im() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "riscv-interrupt-m" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-riscv-interrupt.rs:32:18 + --> $DIR/feature-gate-abi-riscv-interrupt.rs:34:18 | LL | type TA = extern "riscv-interrupt-m" fn(); | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs index 93c59364f10..c4fdb5f427c 100644 --- a/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs +++ b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.rs @@ -1,9 +1,11 @@ +//@ add-core-stubs //@ needs-llvm-components: x86 //@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib #![no_core] #![feature(no_core, lang_items)] -#[lang="sized"] -trait Sized { } + +extern crate minicore; +use minicore::*; extern "x86-interrupt" fn f7() {} //~ ERROR "x86-interrupt" ABI is experimental trait Tr { diff --git a/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr index 231cf207c86..67211d402c6 100644 --- a/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr +++ b/tests/ui/feature-gates/feature-gate-abi-x86-interrupt.stderr @@ -1,5 +1,5 @@ error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-x86-interrupt.rs:8:8 + --> $DIR/feature-gate-abi-x86-interrupt.rs:10:8 | LL | extern "x86-interrupt" fn f7() {} | ^^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | extern "x86-interrupt" fn f7() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-x86-interrupt.rs:10:12 + --> $DIR/feature-gate-abi-x86-interrupt.rs:12:12 | LL | extern "x86-interrupt" fn m7(); | ^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | extern "x86-interrupt" fn m7(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-x86-interrupt.rs:11:12 + --> $DIR/feature-gate-abi-x86-interrupt.rs:13:12 | LL | extern "x86-interrupt" fn dm7() {} | ^^^^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | extern "x86-interrupt" fn dm7() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-x86-interrupt.rs:18:12 + --> $DIR/feature-gate-abi-x86-interrupt.rs:20:12 | LL | extern "x86-interrupt" fn m7() {} | ^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | extern "x86-interrupt" fn m7() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-x86-interrupt.rs:23:12 + --> $DIR/feature-gate-abi-x86-interrupt.rs:25:12 | LL | extern "x86-interrupt" fn im7() {} | ^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | extern "x86-interrupt" fn im7() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-x86-interrupt.rs:26:18 + --> $DIR/feature-gate-abi-x86-interrupt.rs:28:18 | LL | type A7 = extern "x86-interrupt" fn(); | ^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | type A7 = extern "x86-interrupt" fn(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "x86-interrupt" ABI is experimental and subject to change - --> $DIR/feature-gate-abi-x86-interrupt.rs:28:8 + --> $DIR/feature-gate-abi-x86-interrupt.rs:30:8 | LL | extern "x86-interrupt" {} | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-abi.rs b/tests/ui/feature-gates/feature-gate-abi.rs index 7ab05889c20..2af623734ee 100644 --- a/tests/ui/feature-gates/feature-gate-abi.rs +++ b/tests/ui/feature-gates/feature-gate-abi.rs @@ -1,14 +1,12 @@ // gate-test-intrinsics +//@ add-core-stubs //@ compile-flags: --crate-type=rlib #![feature(no_core, lang_items)] #![no_core] -#[lang="sized"] -trait Sized { } - -#[lang="tuple_trait"] -trait Tuple { } +extern crate minicore; +use minicore::*; // Functions extern "rust-intrinsic" fn f1() {} //~ ERROR extern "rust-intrinsic" ABI is an implementation detail diff --git a/tests/ui/feature-gates/feature-gate-abi.stderr b/tests/ui/feature-gates/feature-gate-abi.stderr index 70ec64e5135..a974c0099cb 100644 --- a/tests/ui/feature-gates/feature-gate-abi.stderr +++ b/tests/ui/feature-gates/feature-gate-abi.stderr @@ -1,5 +1,5 @@ error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:14:8 + --> $DIR/feature-gate-abi.rs:12:8 | LL | extern "rust-intrinsic" fn f1() {} | ^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | extern "rust-intrinsic" fn f1() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:16:8 + --> $DIR/feature-gate-abi.rs:14:8 | LL | extern "rust-intrinsic" fn f2() {} | ^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | extern "rust-intrinsic" fn f2() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-call" ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:18:8 + --> $DIR/feature-gate-abi.rs:16:8 | LL | extern "rust-call" fn f4(_: ()) {} | ^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | extern "rust-call" fn f4(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:22:12 + --> $DIR/feature-gate-abi.rs:20:12 | LL | extern "rust-intrinsic" fn m1(); | ^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | extern "rust-intrinsic" fn m1(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:24:12 + --> $DIR/feature-gate-abi.rs:22:12 | LL | extern "rust-intrinsic" fn m2(); | ^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | extern "rust-intrinsic" fn m2(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-call" ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:26:12 + --> $DIR/feature-gate-abi.rs:24:12 | LL | extern "rust-call" fn m4(_: ()); | ^^^^^^^^^^^ @@ -55,7 +55,7 @@ LL | extern "rust-call" fn m4(_: ()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-call" ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:28:12 + --> $DIR/feature-gate-abi.rs:26:12 | LL | extern "rust-call" fn dm4(_: ()) {} | ^^^^^^^^^^^ @@ -65,7 +65,7 @@ LL | extern "rust-call" fn dm4(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:35:12 + --> $DIR/feature-gate-abi.rs:33:12 | LL | extern "rust-intrinsic" fn m1() {} | ^^^^^^^^^^^^^^^^ @@ -74,7 +74,7 @@ LL | extern "rust-intrinsic" fn m1() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:37:12 + --> $DIR/feature-gate-abi.rs:35:12 | LL | extern "rust-intrinsic" fn m2() {} | ^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ LL | extern "rust-intrinsic" fn m2() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-call" ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:39:12 + --> $DIR/feature-gate-abi.rs:37:12 | LL | extern "rust-call" fn m4(_: ()) {} | ^^^^^^^^^^^ @@ -93,7 +93,7 @@ LL | extern "rust-call" fn m4(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:44:12 + --> $DIR/feature-gate-abi.rs:42:12 | LL | extern "rust-intrinsic" fn im1() {} | ^^^^^^^^^^^^^^^^ @@ -102,7 +102,7 @@ LL | extern "rust-intrinsic" fn im1() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:46:12 + --> $DIR/feature-gate-abi.rs:44:12 | LL | extern "rust-intrinsic" fn im2() {} | ^^^^^^^^^^^^^^^^ @@ -111,7 +111,7 @@ LL | extern "rust-intrinsic" fn im2() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-call" ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:48:12 + --> $DIR/feature-gate-abi.rs:46:12 | LL | extern "rust-call" fn im4(_: ()) {} | ^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | extern "rust-call" fn im4(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:52:18 + --> $DIR/feature-gate-abi.rs:50:18 | LL | type A1 = extern "rust-intrinsic" fn(); | ^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL | type A1 = extern "rust-intrinsic" fn(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:53:18 + --> $DIR/feature-gate-abi.rs:51:18 | LL | type A2 = extern "rust-intrinsic" fn(); | ^^^^^^^^^^^^^^^^ @@ -139,7 +139,7 @@ LL | type A2 = extern "rust-intrinsic" fn(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-call" ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:54:18 + --> $DIR/feature-gate-abi.rs:52:18 | LL | type A4 = extern "rust-call" fn(_: ()); | ^^^^^^^^^^^ @@ -149,7 +149,7 @@ LL | type A4 = extern "rust-call" fn(_: ()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:57:8 + --> $DIR/feature-gate-abi.rs:55:8 | LL | extern "rust-intrinsic" {} | ^^^^^^^^^^^^^^^^ @@ -158,7 +158,7 @@ LL | extern "rust-intrinsic" {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-intrinsic" ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi.rs:58:8 + --> $DIR/feature-gate-abi.rs:56:8 | LL | extern "rust-intrinsic" {} | ^^^^^^^^^^^^^^^^ @@ -167,7 +167,7 @@ LL | extern "rust-intrinsic" {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "rust-call" ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:59:8 + --> $DIR/feature-gate-abi.rs:57:8 | LL | extern "rust-call" {} | ^^^^^^^^^^^ @@ -177,49 +177,49 @@ LL | extern "rust-call" {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:22:32 + --> $DIR/feature-gate-abi.rs:20:32 | LL | extern "rust-intrinsic" fn m1(); | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:24:32 + --> $DIR/feature-gate-abi.rs:22:32 | LL | extern "rust-intrinsic" fn m2(); | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:14:33 + --> $DIR/feature-gate-abi.rs:12:33 | LL | extern "rust-intrinsic" fn f1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:16:33 + --> $DIR/feature-gate-abi.rs:14:33 | LL | extern "rust-intrinsic" fn f2() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:35:37 + --> $DIR/feature-gate-abi.rs:33:37 | LL | extern "rust-intrinsic" fn m1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:37:37 + --> $DIR/feature-gate-abi.rs:35:37 | LL | extern "rust-intrinsic" fn m2() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:44:38 + --> $DIR/feature-gate-abi.rs:42:38 | LL | extern "rust-intrinsic" fn im1() {} | ^^ error: intrinsic must be in `extern "rust-intrinsic" { ... }` block - --> $DIR/feature-gate-abi.rs:46:38 + --> $DIR/feature-gate-abi.rs:44:38 | LL | extern "rust-intrinsic" fn im2() {} | ^^ diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs index fb04906dafe..d9027b417b4 100644 --- a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs @@ -1,13 +1,11 @@ +//@ add-core-stubs //@ compile-flags: --crate-type=rlib #![feature(no_core, lang_items)] #![no_core] -#[lang="sized"] -trait Sized { } - -#[lang="tuple_trait"] -trait Tuple { } +extern crate minicore; +use minicore::*; // Functions extern "gpu-kernel" fn f1(_: ()) {} //~ ERROR "gpu-kernel" ABI is experimental and subject to change diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.stderr b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.stderr index b05c16e3d9e..d8dbd94696e 100644 --- a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.stderr +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.stderr @@ -1,5 +1,5 @@ error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:13:8 + --> $DIR/feature-gate-abi_gpu_kernel.rs:11:8 | LL | extern "gpu-kernel" fn f1(_: ()) {} | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | extern "gpu-kernel" fn f1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:18:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:16:12 | LL | extern "gpu-kernel" fn m1(_: ()); | ^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | extern "gpu-kernel" fn m1(_: ()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:20:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:18:12 | LL | extern "gpu-kernel" fn dm1(_: ()) {} | ^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | extern "gpu-kernel" fn dm1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:28:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:26:12 | LL | extern "gpu-kernel" fn m1(_: ()) {} | ^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | extern "gpu-kernel" fn m1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:34:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:32:12 | LL | extern "gpu-kernel" fn im1(_: ()) {} | ^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | extern "gpu-kernel" fn im1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:39:18 + --> $DIR/feature-gate-abi_gpu_kernel.rs:37:18 | LL | type A1 = extern "gpu-kernel" fn(_: ()); | ^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | type A1 = extern "gpu-kernel" fn(_: ()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:44:8 + --> $DIR/feature-gate-abi_gpu_kernel.rs:42:8 | LL | extern "gpu-kernel" {} | ^^^^^^^^^^^^ @@ -69,7 +69,7 @@ LL | extern "gpu-kernel" {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date warning: the calling convention "gpu-kernel" is not supported on this target - --> $DIR/feature-gate-abi_gpu_kernel.rs:39:11 + --> $DIR/feature-gate-abi_gpu_kernel.rs:37:11 | LL | type A1 = extern "gpu-kernel" fn(_: ()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -79,31 +79,31 @@ LL | type A1 = extern "gpu-kernel" fn(_: ()); = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:44:1 + --> $DIR/feature-gate-abi_gpu_kernel.rs:42:1 | LL | extern "gpu-kernel" {} | ^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:13:1 + --> $DIR/feature-gate-abi_gpu_kernel.rs:11:1 | LL | extern "gpu-kernel" fn f1(_: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:20:5 + --> $DIR/feature-gate-abi_gpu_kernel.rs:18:5 | LL | extern "gpu-kernel" fn dm1(_: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:28:5 + --> $DIR/feature-gate-abi_gpu_kernel.rs:26:5 | LL | extern "gpu-kernel" fn m1(_: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:34:5 + --> $DIR/feature-gate-abi_gpu_kernel.rs:32:5 | LL | extern "gpu-kernel" fn im1(_: ()) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-abi_ptx.rs b/tests/ui/feature-gates/feature-gate-abi_ptx.rs index e742492303a..3cc2b786192 100644 --- a/tests/ui/feature-gates/feature-gate-abi_ptx.rs +++ b/tests/ui/feature-gates/feature-gate-abi_ptx.rs @@ -1,9 +1,11 @@ +//@ add-core-stubs //@ needs-llvm-components: nvptx //@ compile-flags: --target=nvptx64-nvidia-cuda --crate-type=rlib #![no_core] #![feature(no_core, lang_items)] -#[lang="sized"] -trait Sized { } + +extern crate minicore; +use minicore::*; extern "ptx-kernel" fn fu() {} //~ ERROR extern "ptx-kernel" ABI is experimental diff --git a/tests/ui/feature-gates/feature-gate-abi_ptx.stderr b/tests/ui/feature-gates/feature-gate-abi_ptx.stderr index d128075919b..cbe9fd8d834 100644 --- a/tests/ui/feature-gates/feature-gate-abi_ptx.stderr +++ b/tests/ui/feature-gates/feature-gate-abi_ptx.stderr @@ -1,5 +1,5 @@ error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_ptx.rs:8:8 + --> $DIR/feature-gate-abi_ptx.rs:10:8 | LL | extern "ptx-kernel" fn fu() {} | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | extern "ptx-kernel" fn fu() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_ptx.rs:11:12 + --> $DIR/feature-gate-abi_ptx.rs:13:12 | LL | extern "ptx-kernel" fn mu(); | ^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | extern "ptx-kernel" fn mu(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_ptx.rs:12:12 + --> $DIR/feature-gate-abi_ptx.rs:14:12 | LL | extern "ptx-kernel" fn dmu() {} | ^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | extern "ptx-kernel" fn dmu() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_ptx.rs:17:12 + --> $DIR/feature-gate-abi_ptx.rs:19:12 | LL | extern "ptx-kernel" fn mu() {} | ^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | extern "ptx-kernel" fn mu() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_ptx.rs:21:12 + --> $DIR/feature-gate-abi_ptx.rs:23:12 | LL | extern "ptx-kernel" fn imu() {} | ^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | extern "ptx-kernel" fn imu() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_ptx.rs:24:19 + --> $DIR/feature-gate-abi_ptx.rs:26:19 | LL | type TAU = extern "ptx-kernel" fn(); | ^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | type TAU = extern "ptx-kernel" fn(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_ptx.rs:26:8 + --> $DIR/feature-gate-abi_ptx.rs:28:8 | LL | extern "ptx-kernel" {} | ^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-asm_experimental_arch.rs b/tests/ui/feature-gates/feature-gate-asm_experimental_arch.rs index a52fbbe4075..a3b41e07195 100644 --- a/tests/ui/feature-gates/feature-gate-asm_experimental_arch.rs +++ b/tests/ui/feature-gates/feature-gate-asm_experimental_arch.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: --target mips-unknown-linux-gnu //@ needs-llvm-components: mips @@ -5,15 +6,8 @@ #![crate_type = "rlib"] #![no_core] -#[rustc_builtin_macro] -macro_rules! asm { - () => {}; -} - -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; unsafe fn main() { asm!(""); diff --git a/tests/ui/feature-gates/feature-gate-asm_experimental_arch.stderr b/tests/ui/feature-gates/feature-gate-asm_experimental_arch.stderr index d930429779c..e59a10c11c3 100644 --- a/tests/ui/feature-gates/feature-gate-asm_experimental_arch.stderr +++ b/tests/ui/feature-gates/feature-gate-asm_experimental_arch.stderr @@ -1,5 +1,5 @@ error[E0658]: inline assembly is not stable yet on this architecture - --> $DIR/feature-gate-asm_experimental_arch.rs:19:5 + --> $DIR/feature-gate-asm_experimental_arch.rs:13:5 | LL | asm!(""); | ^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-asm_experimental_reg.rs b/tests/ui/feature-gates/feature-gate-asm_experimental_reg.rs index 7aec7455b2e..6c53c2213a5 100644 --- a/tests/ui/feature-gates/feature-gate-asm_experimental_reg.rs +++ b/tests/ui/feature-gates/feature-gate-asm_experimental_reg.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ needs-asm-support //@ compile-flags: --target s390x-unknown-linux-gnu //@ needs-llvm-components: systemz @@ -6,15 +7,8 @@ #![crate_type = "rlib"] #![no_core] -#[rustc_builtin_macro] -macro_rules! asm { - () => {}; -} - -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} +extern crate minicore; +use minicore::*; unsafe fn main() { asm!("", in("v0") 0); diff --git a/tests/ui/feature-gates/feature-gate-asm_experimental_reg.stderr b/tests/ui/feature-gates/feature-gate-asm_experimental_reg.stderr index 0791ce4543c..6f2ea0ddaec 100644 --- a/tests/ui/feature-gates/feature-gate-asm_experimental_reg.stderr +++ b/tests/ui/feature-gates/feature-gate-asm_experimental_reg.stderr @@ -1,5 +1,5 @@ error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/feature-gate-asm_experimental_reg.rs:20:14 + --> $DIR/feature-gate-asm_experimental_reg.rs:14:14 | LL | asm!("", in("v0") 0); | ^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | asm!("", in("v0") 0); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `i32` cannot be used with this register class in stable - --> $DIR/feature-gate-asm_experimental_reg.rs:20:23 + --> $DIR/feature-gate-asm_experimental_reg.rs:14:23 | LL | asm!("", in("v0") 0); | ^ diff --git a/tests/ui/feature-gates/feature-gate-generic-const-parameter-types.normal.stderr b/tests/ui/feature-gates/feature-gate-generic-const-parameter-types.normal.stderr new file mode 100644 index 00000000000..1377f845d16 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-generic-const-parameter-types.normal.stderr @@ -0,0 +1,21 @@ +error[E0770]: the type of const parameters must not depend on other generic parameters + --> $DIR/feature-gate-generic-const-parameter-types.rs:7:50 + | +LL | struct MyADT<const LEN: usize, const ARRAY: [u8; LEN]>; + | ^^^ the type must not depend on the parameter `LEN` + +error: `[u8; LEN]` is forbidden as the type of a const generic parameter + --> $DIR/feature-gate-generic-const-parameter-types.rs:7:45 + | +LL | struct MyADT<const LEN: usize, const ARRAY: [u8; LEN]>; + | ^^^^^^^^^ + | + = note: the only supported types are integers, `bool`, and `char` +help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types + | +LL + #![feature(adt_const_params)] + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/feature-gates/feature-gate-generic-const-parameter-types.rs b/tests/ui/feature-gates/feature-gate-generic-const-parameter-types.rs new file mode 100644 index 00000000000..cc374ea3eb2 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-generic-const-parameter-types.rs @@ -0,0 +1,11 @@ +//@ [feature] check-pass +//@ revisions: normal feature + +#![cfg_attr(feature, feature(adt_const_params, generic_const_parameter_types))] +#![cfg_attr(feature, expect(incomplete_features))] + +struct MyADT<const LEN: usize, const ARRAY: [u8; LEN]>; +//[normal]~^ ERROR: the type of const parameters must not depend on other generic parameters +//[normal]~| ERROR: `[u8; LEN]` is forbidden as the type of a const generic parameter + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-vectorcall.rs b/tests/ui/feature-gates/feature-gate-vectorcall.rs index aafa6a2ed62..b29fd08473a 100644 --- a/tests/ui/feature-gates/feature-gate-vectorcall.rs +++ b/tests/ui/feature-gates/feature-gate-vectorcall.rs @@ -1,10 +1,12 @@ // gate-test-abi_vectorcall +//@ add-core-stubs //@ needs-llvm-components: x86 //@ compile-flags: --target=i686-pc-windows-msvc --crate-type=rlib #![no_core] #![feature(no_core, lang_items)] -#[lang="sized"] -trait Sized { } + +extern crate minicore; +use minicore::*; // Test that the "vectorcall" ABI is feature-gated, and cannot be used when // the `vectorcall` feature gate is not used. diff --git a/tests/ui/feature-gates/feature-gate-vectorcall.stderr b/tests/ui/feature-gates/feature-gate-vectorcall.stderr index 8f3f47a3d48..81dd10f5fe5 100644 --- a/tests/ui/feature-gates/feature-gate-vectorcall.stderr +++ b/tests/ui/feature-gates/feature-gate-vectorcall.stderr @@ -1,5 +1,5 @@ error[E0658]: the extern "vectorcall" ABI is experimental and subject to change - --> $DIR/feature-gate-vectorcall.rs:12:8 + --> $DIR/feature-gate-vectorcall.rs:14:8 | LL | extern "vectorcall" fn f() {} | ^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | extern "vectorcall" fn f() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "vectorcall" ABI is experimental and subject to change - --> $DIR/feature-gate-vectorcall.rs:15:12 + --> $DIR/feature-gate-vectorcall.rs:17:12 | LL | extern "vectorcall" fn m(); | ^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | extern "vectorcall" fn m(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "vectorcall" ABI is experimental and subject to change - --> $DIR/feature-gate-vectorcall.rs:17:12 + --> $DIR/feature-gate-vectorcall.rs:19:12 | LL | extern "vectorcall" fn dm() {} | ^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | extern "vectorcall" fn dm() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "vectorcall" ABI is experimental and subject to change - --> $DIR/feature-gate-vectorcall.rs:22:12 + --> $DIR/feature-gate-vectorcall.rs:24:12 | LL | extern "vectorcall" fn m() {} | ^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | extern "vectorcall" fn m() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "vectorcall" ABI is experimental and subject to change - --> $DIR/feature-gate-vectorcall.rs:26:12 + --> $DIR/feature-gate-vectorcall.rs:28:12 | LL | extern "vectorcall" fn im() {} | ^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | extern "vectorcall" fn im() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "vectorcall" ABI is experimental and subject to change - --> $DIR/feature-gate-vectorcall.rs:29:18 + --> $DIR/feature-gate-vectorcall.rs:31:18 | LL | type TA = extern "vectorcall" fn(); | ^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | type TA = extern "vectorcall" fn(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "vectorcall" ABI is experimental and subject to change - --> $DIR/feature-gate-vectorcall.rs:31:8 + --> $DIR/feature-gate-vectorcall.rs:33:8 | LL | extern "vectorcall" {} | ^^^^^^^^^^^^ diff --git a/tests/ui/force-inlining/asm.rs b/tests/ui/force-inlining/asm.rs index 85014ffa515..2b5f87c59d3 100644 --- a/tests/ui/force-inlining/asm.rs +++ b/tests/ui/force-inlining/asm.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ build-fail //@ compile-flags: --crate-type=lib --target thumbv4t-none-eabi //@ needs-llvm-components: arm @@ -9,17 +10,8 @@ #![feature(no_core, lang_items)] #![no_core] -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy {} -#[lang = "freeze"] -pub unsafe trait Freeze {} - -#[lang = "start"] -fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8, _sigpipe: u8) -> isize { - 0 -} +extern crate minicore; +use minicore::*; #[rustc_builtin_macro] #[macro_export] diff --git a/tests/ui/force-inlining/asm.stderr b/tests/ui/force-inlining/asm.stderr index ef04688965b..1744c0215bb 100644 --- a/tests/ui/force-inlining/asm.stderr +++ b/tests/ui/force-inlining/asm.stderr @@ -1,5 +1,5 @@ error: `instruction_set_a32` could not be inlined into `t32` but is required to be inlined - --> $DIR/asm.rs:53:5 + --> $DIR/asm.rs:45:5 | LL | instruction_set_a32(); | ^^^^^^^^^^^^^^^^^^^^^ ...`instruction_set_a32` called here @@ -7,7 +7,7 @@ LL | instruction_set_a32(); = note: could not be inlined due to: incompatible instruction set error: `inline_always_and_using_inline_asm` could not be inlined into `t32` but is required to be inlined - --> $DIR/asm.rs:57:5 + --> $DIR/asm.rs:49:5 | LL | inline_always_and_using_inline_asm(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...`inline_always_and_using_inline_asm` called here @@ -15,7 +15,7 @@ LL | inline_always_and_using_inline_asm(); = note: could not be inlined due to: cannot move inline-asm across instruction sets error: `instruction_set_a32` could not be inlined into `default` but is required to be inlined - --> $DIR/asm.rs:62:5 + --> $DIR/asm.rs:54:5 | LL | instruction_set_a32(); | ^^^^^^^^^^^^^^^^^^^^^ ...`instruction_set_a32` called here @@ -23,7 +23,7 @@ LL | instruction_set_a32(); = note: could not be inlined due to: incompatible instruction set error: `instruction_set_t32` could not be inlined into `default` but is required to be inlined - --> $DIR/asm.rs:64:5 + --> $DIR/asm.rs:56:5 | LL | instruction_set_t32(); | ^^^^^^^^^^^^^^^^^^^^^ ...`instruction_set_t32` called here diff --git a/tests/ui/generic-const-items/def-site-eval.fail.stderr b/tests/ui/generic-const-items/def-site-eval.fail.stderr index 22a5f291697..1ba4455c7be 100644 --- a/tests/ui/generic-const-items/def-site-eval.fail.stderr +++ b/tests/ui/generic-const-items/def-site-eval.fail.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `_::<'_>` failed --> $DIR/def-site-eval.rs:14:20 | LL | const _<'_a>: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/def-site-eval.rs:14:20 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr b/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr index 654004571db..2b28e29421c 100644 --- a/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr +++ b/tests/ui/generic-const-items/wfcheck_err_leak_issue_118179.stderr @@ -3,8 +3,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | struct G<T, const N: Vec<T>>(T); | ^ the type must not depend on the parameter `T` - | - = note: type parameters may not be used in the type of const parameters error: aborting due to 1 previous error diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.rs b/tests/ui/generics/post_monomorphization_error_backtrace.rs index 2c18f2b233a..f5f36ef03ae 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.rs +++ b/tests/ui/generics/post_monomorphization_error_backtrace.rs @@ -6,10 +6,10 @@ fn assert_zst<T>() { const V: () = assert!(std::mem::size_of::<T>() == 0); //~^ ERROR: evaluation of `assert_zst::F::<u32>::V` failed [E0080] //~| NOTE: in this expansion of assert! - //~| NOTE: the evaluated program panicked + //~| NOTE: assertion failed //~| ERROR: evaluation of `assert_zst::F::<i32>::V` failed [E0080] //~| NOTE: in this expansion of assert! - //~| NOTE: the evaluated program panicked + //~| NOTE: assertion failed } F::<T>::V; //~^NOTE: erroneous constant diff --git a/tests/ui/generics/post_monomorphization_error_backtrace.stderr b/tests/ui/generics/post_monomorphization_error_backtrace.stderr index 8a57979bca7..1366d5491f4 100644 --- a/tests/ui/generics/post_monomorphization_error_backtrace.stderr +++ b/tests/ui/generics/post_monomorphization_error_backtrace.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `assert_zst::F::<u32>::V` failed --> $DIR/post_monomorphization_error_backtrace.rs:6:23 | LL | const V: () = assert!(std::mem::size_of::<T>() == 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: std::mem::size_of::<T>() == 0', $DIR/post_monomorphization_error_backtrace.rs:6:23 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -22,7 +22,7 @@ error[E0080]: evaluation of `assert_zst::F::<i32>::V` failed --> $DIR/post_monomorphization_error_backtrace.rs:6:23 | LL | const V: () = assert!(std::mem::size_of::<T>() == 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: std::mem::size_of::<T>() == 0', $DIR/post_monomorphization_error_backtrace.rs:6:23 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/infinite/infinite-recursion-const-fn.rs b/tests/ui/infinite/infinite-recursion-const-fn.rs index 4209153116d..7b7f6fafab5 100644 --- a/tests/ui/infinite/infinite-recursion-const-fn.rs +++ b/tests/ui/infinite/infinite-recursion-const-fn.rs @@ -1,11 +1,11 @@ //https://github.com/rust-lang/rust/issues/31364 const fn a() -> usize { - b() //~ ERROR evaluation of constant value failed [E0080] + b() } const fn b() -> usize { a() } -const ARR: [i32; a()] = [5; 6]; +const ARR: [i32; a()] = [5; 6]; //~ ERROR evaluation of constant value failed [E0080] fn main() {} diff --git a/tests/ui/infinite/infinite-recursion-const-fn.stderr b/tests/ui/infinite/infinite-recursion-const-fn.stderr index fd5a3c3c546..524abdf4d7a 100644 --- a/tests/ui/infinite/infinite-recursion-const-fn.stderr +++ b/tests/ui/infinite/infinite-recursion-const-fn.stderr @@ -1,8 +1,8 @@ error[E0080]: evaluation of constant value failed - --> $DIR/infinite-recursion-const-fn.rs:4:5 + --> $DIR/infinite-recursion-const-fn.rs:9:18 | -LL | b() - | ^^^ reached the configured maximum number of stack frames +LL | const ARR: [i32; a()] = [5; 6]; + | ^^^ reached the configured maximum number of stack frames | note: inside `a` --> $DIR/infinite-recursion-const-fn.rs:4:5 @@ -638,12 +638,7 @@ note: inside `a` --> $DIR/infinite-recursion-const-fn.rs:4:5 | LL | b() - | ^^^ -note: inside `ARR::{constant#0}` - --> $DIR/infinite-recursion-const-fn.rs:9:18 - | -LL | const ARR: [i32; a()] = [5; 6]; - | ^^^ + | ^^^ the failure occurred here error: aborting due to 1 previous error diff --git a/tests/ui/inline-const/collect-scopes-in-pat.rs b/tests/ui/inline-const/collect-scopes-in-pat.rs index 024fde53741..16baf920f58 100644 --- a/tests/ui/inline-const/collect-scopes-in-pat.rs +++ b/tests/ui/inline-const/collect-scopes-in-pat.rs @@ -1,4 +1,4 @@ -// @compile-flags: -Zlint-mir +//@ compile-flags: -Zlint-mir //@ check-pass #![feature(inline_const_pat)] diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index dcd6b62bbfc..e67c0b28e02 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `foo::<i32>::{constant#0}` failed --> $DIR/const-expr-generic-err.rs:4:13 | LL | const { assert!(std::mem::size_of::<T>() == 0); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: std::mem::size_of::<T>() == 0', $DIR/const-expr-generic-err.rs:4:13 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: std::mem::size_of::<T>() == 0 | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/inline-const/required-const.stderr b/tests/ui/inline-const/required-const.stderr index 6ca4c250223..a6c630b5477 100644 --- a/tests/ui/inline-const/required-const.stderr +++ b/tests/ui/inline-const/required-const.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `foo::<i32>::{constant#0}` failed --> $DIR/required-const.rs:6:17 | LL | const { panic!() } - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/required-const.rs:6:17 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/intrinsics/bad-intrinsic-monomorphization.rs b/tests/ui/intrinsics/bad-intrinsic-monomorphization.rs index 254ac24f0b9..d68cbf26ef1 100644 --- a/tests/ui/intrinsics/bad-intrinsic-monomorphization.rs +++ b/tests/ui/intrinsics/bad-intrinsic-monomorphization.rs @@ -7,10 +7,6 @@ // Bad monomorphizations could previously cause LLVM asserts even though the // error was caught in the compiler. -extern "rust-intrinsic" { - fn simd_add<T>(x: T, y: T) -> T; -} - use std::intrinsics; #[derive(Copy, Clone)] @@ -27,6 +23,6 @@ pub unsafe fn test_fadd_fast(a: Foo, b: Foo) -> Foo { } pub unsafe fn test_simd_add(a: Foo, b: Foo) -> Foo { - simd_add(a, b) + intrinsics::simd::simd_add(a, b) //~^ ERROR `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo` } diff --git a/tests/ui/intrinsics/bad-intrinsic-monomorphization.stderr b/tests/ui/intrinsics/bad-intrinsic-monomorphization.stderr index c070f018181..f49d95e9cfc 100644 --- a/tests/ui/intrinsics/bad-intrinsic-monomorphization.stderr +++ b/tests/ui/intrinsics/bad-intrinsic-monomorphization.stderr @@ -1,20 +1,20 @@ error[E0511]: invalid monomorphization of `cttz` intrinsic: expected basic integer type, found `Foo` - --> $DIR/bad-intrinsic-monomorphization.rs:20:5 + --> $DIR/bad-intrinsic-monomorphization.rs:16:5 | LL | intrinsics::cttz(v) | ^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `fadd_fast` intrinsic: expected basic float type, found `Foo` - --> $DIR/bad-intrinsic-monomorphization.rs:25:5 + --> $DIR/bad-intrinsic-monomorphization.rs:21:5 | LL | intrinsics::fadd_fast(a, b) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo` - --> $DIR/bad-intrinsic-monomorphization.rs:30:5 + --> $DIR/bad-intrinsic-monomorphization.rs:26:5 | -LL | simd_add(a, b) - | ^^^^^^^^^^^^^^ +LL | intrinsics::simd::simd_add(a, b) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/issues/issue-76191.stderr b/tests/ui/issues/issue-76191.stderr index a397d082142..de08fc4ed0d 100644 --- a/tests/ui/issues/issue-76191.stderr +++ b/tests/ui/issues/issue-76191.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-76191.rs:8:37 | LL | const RANGE2: RangeInclusive<i32> = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-76191.rs:8:37 + | ^^^^^^^^ evaluation panicked: explicit panic | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/layout/hexagon-enum.rs b/tests/ui/layout/hexagon-enum.rs index 5fa12e479e7..02833eb41fa 100644 --- a/tests/ui/layout/hexagon-enum.rs +++ b/tests/ui/layout/hexagon-enum.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: --target hexagon-unknown-linux-musl //@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED" //@ needs-llvm-components: hexagon @@ -9,8 +10,8 @@ #![crate_type = "lib"] #![no_core] -#[lang="sized"] -trait Sized {} +extern crate minicore; +use minicore::*; #[rustc_layout(debug)] #[repr(C)] diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index 90c06ba1f83..b802b400b18 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -71,7 +71,7 @@ error: layout_of(A) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, } - --> $DIR/hexagon-enum.rs:17:1 + --> $DIR/hexagon-enum.rs:18:1 | LL | enum A { Apple } | ^^^^^^ @@ -149,7 +149,7 @@ error: layout_of(B) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, } - --> $DIR/hexagon-enum.rs:21:1 + --> $DIR/hexagon-enum.rs:22:1 | LL | enum B { Banana = 255, } | ^^^^^^ @@ -227,7 +227,7 @@ error: layout_of(C) = Layout { unadjusted_abi_align: Align(2 bytes), randomization_seed: $SEED, } - --> $DIR/hexagon-enum.rs:25:1 + --> $DIR/hexagon-enum.rs:26:1 | LL | enum C { Chaenomeles = 256, } | ^^^^^^ @@ -305,7 +305,7 @@ error: layout_of(P) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, } - --> $DIR/hexagon-enum.rs:29:1 + --> $DIR/hexagon-enum.rs:30:1 | LL | enum P { Peach = 0x1000_0000isize, } | ^^^^^^ @@ -383,7 +383,7 @@ error: layout_of(T) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, } - --> $DIR/hexagon-enum.rs:35:1 + --> $DIR/hexagon-enum.rs:36:1 | LL | enum T { Tangerine = TANGERINE as isize } | ^^^^^^ diff --git a/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs b/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs index 5df97338710..c6d5f2bfa0e 100644 --- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs +++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.rs @@ -12,6 +12,6 @@ struct P2 { //~^ ERROR: the size for values of type `[bool]` cannot be known at compilation time } -static CHECK: () = assert!(align_of::<P2>() == 1); +static CHECK: () = assert!(align_of::<P2>() == 1); //~ ERROR could not evaluate static initializer fn main() {} diff --git a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr index f54e97e2a5c..3a4735e4832 100644 --- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr +++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr @@ -19,17 +19,13 @@ LL | struct MySlice<T>(T); | this could be changed to `T: ?Sized`... error[E0080]: could not evaluate static initializer - --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + --> $DIR/invalid-unsized-in-always-sized-tail.rs:15:28 | - = note: the type `MySlice<[bool]>` has an unknown layout +LL | static CHECK: () = assert!(align_of::<P2>() == 1); + | ^^^^^^^^^^^^^^^^ the type `MySlice<[bool]>` has an unknown layout | note: inside `align_of::<P2>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL -note: inside `CHECK` - --> $DIR/invalid-unsized-in-always-sized-tail.rs:15:28 - | -LL | static CHECK: () = assert!(align_of::<P2>() == 1); - | ^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/layout/thumb-enum.rs b/tests/ui/layout/thumb-enum.rs index 2381d9d0292..1c4fab812f9 100644 --- a/tests/ui/layout/thumb-enum.rs +++ b/tests/ui/layout/thumb-enum.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabihf //@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED" //@ needs-llvm-components: arm @@ -9,8 +10,8 @@ #![crate_type = "lib"] #![no_core] -#[lang="sized"] -trait Sized {} +extern crate minicore; +use minicore::*; #[rustc_layout(debug)] #[repr(C)] diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index 0c343318564..07153fee027 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -71,7 +71,7 @@ error: layout_of(A) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, } - --> $DIR/thumb-enum.rs:17:1 + --> $DIR/thumb-enum.rs:18:1 | LL | enum A { Apple } | ^^^^^^ @@ -149,7 +149,7 @@ error: layout_of(B) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, } - --> $DIR/thumb-enum.rs:21:1 + --> $DIR/thumb-enum.rs:22:1 | LL | enum B { Banana = 255, } | ^^^^^^ @@ -227,7 +227,7 @@ error: layout_of(C) = Layout { unadjusted_abi_align: Align(2 bytes), randomization_seed: $SEED, } - --> $DIR/thumb-enum.rs:25:1 + --> $DIR/thumb-enum.rs:26:1 | LL | enum C { Chaenomeles = 256, } | ^^^^^^ @@ -305,7 +305,7 @@ error: layout_of(P) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, } - --> $DIR/thumb-enum.rs:29:1 + --> $DIR/thumb-enum.rs:30:1 | LL | enum P { Peach = 0x1000_0000isize, } | ^^^^^^ @@ -383,7 +383,7 @@ error: layout_of(T) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, } - --> $DIR/thumb-enum.rs:35:1 + --> $DIR/thumb-enum.rs:36:1 | LL | enum T { Tangerine = TANGERINE as isize } | ^^^^^^ diff --git a/tests/ui/layout/too-big-with-padding.rs b/tests/ui/layout/too-big-with-padding.rs index 8423ad2e1d6..0f03bd10fb6 100644 --- a/tests/ui/layout/too-big-with-padding.rs +++ b/tests/ui/layout/too-big-with-padding.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ build-fail //@ compile-flags: --target i686-unknown-linux-gnu --crate-type lib //@ needs-llvm-components: x86 @@ -6,13 +7,11 @@ #![no_std] #![no_core] +extern crate minicore; +use minicore::*; + // 0x7fffffff is fine, but after rounding up it becomes too big #[repr(C, align(2))] pub struct Example([u8; 0x7fffffff]); pub fn lib(_x: Example) {} //~ERROR: too big for the target architecture - -#[lang = "sized"] -pub trait Sized {} -#[lang = "copy"] -pub trait Copy: Sized {} diff --git a/tests/ui/layout/too-big-with-padding.stderr b/tests/ui/layout/too-big-with-padding.stderr index fc3b4db049a..761ac7514ee 100644 --- a/tests/ui/layout/too-big-with-padding.stderr +++ b/tests/ui/layout/too-big-with-padding.stderr @@ -1,5 +1,5 @@ error: values of the type `Example` are too big for the target architecture - --> $DIR/too-big-with-padding.rs:13:1 + --> $DIR/too-big-with-padding.rs:17:1 | LL | pub fn lib(_x: Example) {} | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/layout/unknown-when-no-type-parameter.stderr b/tests/ui/layout/unknown-when-no-type-parameter.stderr index d0456e2b329..9e414d224bb 100644 --- a/tests/ui/layout/unknown-when-no-type-parameter.stderr +++ b/tests/ui/layout/unknown-when-no-type-parameter.stderr @@ -1,15 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + --> $DIR/unknown-when-no-type-parameter.rs:11:10 | - = note: the type `<() as Project>::Assoc` has an unknown layout +LL | [(); size_of::<<() as Project>::Assoc>()]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `<() as Project>::Assoc` has an unknown layout | note: inside `std::mem::size_of::<<() as Project>::Assoc>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL -note: inside `foo::{constant#0}` - --> $DIR/unknown-when-no-type-parameter.rs:11:10 - | -LL | [(); size_of::<<() as Project>::Assoc>()]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index b7effdc8d61..7373ca8cf84 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -9,8 +9,6 @@ error[E0770]: the type of const parameters must not depend on other generic para | LL | struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; | ^^ the type must not depend on the parameter `'a` - | - = note: lifetime parameters may not be used in the type of const parameters error[E0214]: parenthesized type parameters may only be used with a `Fn` trait --> $DIR/unusual-rib-combinations.rs:11:15 diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr index d2b5150c556..d705b3daf79 100644 --- a/tests/ui/limits/issue-55878.stderr +++ b/tests/ui/limits/issue-55878.stderr @@ -1,15 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/mem/mod.rs:LL:COL + --> $DIR/issue-55878.rs:5:26 | - = note: values of the type `[u8; usize::MAX]` are too big for the target architecture +LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; usize::MAX]` are too big for the target architecture | note: inside `std::mem::size_of::<[u8; usize::MAX]>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL -note: inside `main` - --> $DIR/issue-55878.rs:5:26 - | -LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/mir/checks_without_panic_impl.rs b/tests/ui/mir/checks_without_panic_impl.rs index 0dba5784daa..11ab50a5f9a 100644 --- a/tests/ui/mir/checks_without_panic_impl.rs +++ b/tests/ui/mir/checks_without_panic_impl.rs @@ -2,6 +2,7 @@ // does not prevent crates without a panic_impl from compiling. // See rust-lang/rust#109996 +//@ add-core-stubs //@ build-pass //@ compile-flags: -Cdebug-assertions=yes @@ -11,7 +12,7 @@ #![feature(no_core)] #![no_core] -#[lang = "sized"] -trait Foo {} +extern crate minicore; +use minicore::*; pub unsafe fn foo(x: *const i32) -> &'static i32 { unsafe { &*x } } diff --git a/tests/ui/never_type/unused_trait_in_never_pattern_body.rs b/tests/ui/never_type/unused_trait_in_never_pattern_body.rs new file mode 100644 index 00000000000..8179c94b72b --- /dev/null +++ b/tests/ui/never_type/unused_trait_in_never_pattern_body.rs @@ -0,0 +1,12 @@ +fn a() { + match 0 { + ! => || { //~ ERROR `!` patterns are experimental + //~^ ERROR a never pattern is always unreachable + //~^^ ERROR mismatched types + use std::ops::Add; + 0.add(1) + }, + } +} + +fn main() {} diff --git a/tests/ui/never_type/unused_trait_in_never_pattern_body.stderr b/tests/ui/never_type/unused_trait_in_never_pattern_body.stderr new file mode 100644 index 00000000000..18ca9f12b7e --- /dev/null +++ b/tests/ui/never_type/unused_trait_in_never_pattern_body.stderr @@ -0,0 +1,36 @@ +error[E0658]: `!` patterns are experimental + --> $DIR/unused_trait_in_never_pattern_body.rs:3:9 + | +LL | ! => || { + | ^ + | + = note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information + = help: add `#![feature(never_patterns)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: a never pattern is always unreachable + --> $DIR/unused_trait_in_never_pattern_body.rs:3:14 + | +LL | ! => || { + | ______________^ +LL | | +LL | | +LL | | use std::ops::Add; +LL | | 0.add(1) +LL | | }, + | | ^ + | | | + | |_________this will never be executed + | help: remove this expression + +error: mismatched types + --> $DIR/unused_trait_in_never_pattern_body.rs:3:9 + | +LL | ! => || { + | ^ a never pattern must be used on an uninhabited type + | + = note: the matched value is of type `i32` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/process/win-command-child-path.rs b/tests/ui/process/win-command-child-path.rs new file mode 100644 index 00000000000..7ec2679749f --- /dev/null +++ b/tests/ui/process/win-command-child-path.rs @@ -0,0 +1,72 @@ +//@ run-pass +//@ only-windows +//@ needs-subprocess +//@ no-prefer-dynamic + +// Test Windows std::process::Command search path semantics when setting PATH on the child process. +// NOTE: The exact semantics here are (possibly) subject to change. + +use std::process::Command; +use std::{env, fs, path}; + +fn main() { + if env::args().skip(1).any(|s| s == "--child") { + child(); + } else if env::args().skip(1).any(|s| s == "--parent") { + parent(); + } else { + setup(); + } +} + +// Set up the directories so that there are three app dirs: +// app: Where the parent app is run from +// parent: In the parent's PATH env var +// child: In the child's PATH env var +fn setup() { + let exe = env::current_exe().unwrap(); + + fs::create_dir_all("app").unwrap(); + fs::copy(&exe, "app/myapp.exe").unwrap(); + fs::create_dir_all("parent").unwrap(); + fs::copy(&exe, "parent/myapp.exe").unwrap(); + fs::create_dir_all("child").unwrap(); + fs::copy(&exe, "child/myapp.exe").unwrap(); + + let parent_path = path::absolute("parent").unwrap(); + let status = + Command::new("./app/myapp.exe").env("PATH", parent_path).arg("--parent").status().unwrap(); + // print the status in case of abnormal exit + dbg!(status); + assert!(status.success()); +} + +// The child simply prints the name of its parent directory. +fn child() { + let exe = env::current_exe().unwrap(); + let parent = exe.parent().unwrap().file_name().unwrap(); + println!("{}", parent.display()); +} + +fn parent() { + let exe = env::current_exe().unwrap(); + let name = exe.file_name().unwrap(); + + // By default, the application dir will be search first for the exe + let output = Command::new(&name).arg("--child").output().unwrap(); + assert_eq!(output.stdout, b"app\n"); + + // Setting an environment variable should not change the above. + let output = Command::new(&name).arg("--child").env("a", "b").output().unwrap(); + assert_eq!(output.stdout, b"app\n"); + + // Setting a child path means that path will be searched first. + let child_path = path::absolute("child").unwrap(); + let output = Command::new(&name).arg("--child").env("PATH", child_path).output().unwrap(); + assert_eq!(output.stdout, b"child\n"); + + // Setting a child path that does not contain the exe (currently) means + // we fallback to searching the app dir. + let output = Command::new(&name).arg("--child").env("PATH", "").output().unwrap(); + assert_eq!(output.stdout, b"app\n"); +} diff --git a/tests/ui/repeat-expr/copy-check-deferred-after-fallback.rs b/tests/ui/repeat-expr/copy-check-deferred-after-fallback.rs new file mode 100644 index 00000000000..d9ad93541ec --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-deferred-after-fallback.rs @@ -0,0 +1,37 @@ +#![feature(generic_arg_infer)] + +// Test that would start passing if we defer repeat expr copy checks to end of +// typechecking and they're checked after integer fallback occurs. We accomplish +// this by contriving a situation where integer fallback allows progress to be +// made on a trait goal that infers the length of a repeat expr. + +use std::marker::PhantomData; + +struct NotCopy; + +trait Trait<const N: usize> {} + +impl Trait<2> for u32 {} +impl Trait<1> for i32 {} + +fn make_goal<T: Trait<N>, const N: usize>(_: &T, _: [NotCopy; N]) {} + +fn main() { + let a = 1; + let b = [NotCopy; _]; + //~^ ERROR: type annotations needed + + // a is of type `?y` + // b is of type `[NotCopy; ?x]` + // there is a goal ?y: Trait<?x>` with two candidates: + // - `i32: Trait<1>`, ?y=i32 ?x=1 which doesnt require `NotCopy: Copy` + // - `u32: Trait<2>` ?y=u32 ?x=2 which requires `NotCopy: Copy` + make_goal(&a, b); + + // final repeat expr checks: + // + // `NotCopy; ?x` + // - succeeds if fallback happens before repeat exprs as `i32: Trait<?x>` infers `?x=1` + // - fails if repeat expr checks happen first as `?x` is unconstrained so cannot be + // structurally resolved +} diff --git a/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr b/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr new file mode 100644 index 00000000000..2a0cb3fb7a3 --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-deferred-after-fallback.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed for `[NotCopy; _]` + --> $DIR/copy-check-deferred-after-fallback.rs:21:9 + | +LL | let b = [NotCopy; _]; + | ^ ------- type must be known at this point + | +help: consider giving `b` an explicit type, where the value of const parameter `N` is specified + | +LL | let b: [_; N] = [NotCopy; _]; + | ++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/repeat-expr/copy-check-deferred-before-fallback.rs b/tests/ui/repeat-expr/copy-check-deferred-before-fallback.rs new file mode 100644 index 00000000000..4654d7483a6 --- /dev/null +++ b/tests/ui/repeat-expr/copy-check-deferred-before-fallback.rs @@ -0,0 +1,59 @@ +//@ check-pass + +#![feature(generic_arg_infer)] + +// Test that if we defer repeat expr copy checks to end of typechecking they're +// checked before integer fallback occurs. We accomplish this by contriving a +// situation where we have a goal that can be proven either via another repeat expr +// check or by integer fallback. In the integer fallback case an array length would +// be inferred to `2` requiring `NotCopy: Copy`, and in the repeat expr case it would +// be inferred to `1`. + +use std::marker::PhantomData; + +struct NotCopy; + +struct Foo<T>(PhantomData<T>); + +impl Clone for Foo<u32> { + fn clone(&self) -> Self { + Foo(PhantomData) + } +} + +impl Copy for Foo<u32> {} + +fn tie<T>(_: &T, _: [Foo<T>; 2]) {} + +trait Trait<const N: usize> {} + +impl Trait<2> for i32 {} +impl Trait<1> for u32 {} + +fn make_goal<T: Trait<N>, const N: usize>(_: &T, _: [NotCopy; N]) {} + +fn main() { + let a = 1; + let b: [Foo<_>; 2] = [Foo(PhantomData); _]; + tie(&a, b); + let c = [NotCopy; _]; + + // a is of type `?y` + // b is of type `[Foo<?y>; 2]` + // c is of type `[NotCopy; ?x]` + // there is a goal ?y: Trait<?x>` with two candidates: + // - `i32: Trait<2>`, ?y=i32 ?x=2 which requires `NotCopy: Copy` when expr checks happen + // - `u32: Trait<1>` ?y=u32 ?x=1 which doesnt require `NotCopy: Copy` + make_goal(&a, c); + + // final repeat expr checks: + // + // `Foo<?y>; 2` + // - Foo<?y>: Copy + // - requires ?y=u32 + // + // `NotCopy; ?x` + // - fails if fallback happens before repeat exprs as `i32: Trait<?x>` infers `?x=2` + // - succeeds if repeat expr checks happen first as `?y=u32` means `u32: Trait<?x>` + // infers `?x=1` +} diff --git a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.gai.stderr b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.gai.stderr new file mode 100644 index 00000000000..de38476c82b --- /dev/null +++ b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.gai.stderr @@ -0,0 +1,17 @@ +error[E0282]: type annotations needed for `[Foo<_>; 2]` + --> $DIR/copy-inference-side-effects-are-lazy.rs:22:9 + | +LL | let x = [Foo(PhantomData); 2]; + | ^ +LL | +LL | _ = extract(x).max(2); + | ---------- type must be known at this point + | +help: consider giving `x` an explicit type, where the type for type parameter `T` is specified + | +LL | let x: [Foo<T>; 2] = [Foo(PhantomData); 2]; + | +++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.rs b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.rs new file mode 100644 index 00000000000..0b0672d9c2b --- /dev/null +++ b/tests/ui/repeat-expr/copy-inference-side-effects-are-lazy.rs @@ -0,0 +1,25 @@ +//@revisions: current gai +//@[current] check-pass + +#![cfg_attr(gai, feature(generic_arg_infer))] + +use std::marker::PhantomData; + +struct Foo<T>(PhantomData<T>); + +impl Clone for Foo<u8> { + fn clone(&self) -> Self { + Foo(PhantomData) + } +} +impl Copy for Foo<u8> {} + +fn extract<T, const N: usize>(_: [Foo<T>; N]) -> T { + loop {} +} + +fn main() { + let x = [Foo(PhantomData); 2]; + //[gai]~^ ERROR: type annotations needed + _ = extract(x).max(2); +} diff --git a/tests/ui/repeat-expr/infer.rs b/tests/ui/repeat-expr/copy-inference-side-effects.rs index eb47b5f462f..eb47b5f462f 100644 --- a/tests/ui/repeat-expr/infer.rs +++ b/tests/ui/repeat-expr/copy-inference-side-effects.rs diff --git a/tests/ui/repeat-expr/dont-require-copy-on-infer.rs b/tests/ui/repeat-expr/dont-require-copy-on-infer.rs new file mode 100644 index 00000000000..e81bf1595be --- /dev/null +++ b/tests/ui/repeat-expr/dont-require-copy-on-infer.rs @@ -0,0 +1,6 @@ +//@ check-pass +#![feature(generic_arg_infer)] + +fn main() { + let a: [_; 1] = [String::new(); _]; +} diff --git a/tests/ui/repeat-expr/no-conservative-copy-impl-requirement.rs b/tests/ui/repeat-expr/no-conservative-copy-impl-requirement.rs new file mode 100644 index 00000000000..eb70df62996 --- /dev/null +++ b/tests/ui/repeat-expr/no-conservative-copy-impl-requirement.rs @@ -0,0 +1,20 @@ +#![feature(generic_arg_infer)] + +struct Foo<const N: usize>; + +impl Clone for Foo<1> { + fn clone(&self) -> Self { + Foo + } +} +impl Copy for Foo<1> {} + +fn unify<const N: usize>(_: &[Foo<N>; N]) { + loop {} +} + +fn main() { + let x = &[Foo::<_>; _]; + //~^ ERROR: type annotations needed for `&[Foo<_>; _]` + _ = unify(x); +} diff --git a/tests/ui/repeat-expr/no-conservative-copy-impl-requirement.stderr b/tests/ui/repeat-expr/no-conservative-copy-impl-requirement.stderr new file mode 100644 index 00000000000..04f8ff33fda --- /dev/null +++ b/tests/ui/repeat-expr/no-conservative-copy-impl-requirement.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed for `&[Foo<_>; _]` + --> $DIR/no-conservative-copy-impl-requirement.rs:17:9 + | +LL | let x = &[Foo::<_>; _]; + | ^ -------- type must be known at this point + | +help: consider giving `x` an explicit type, where the value of const parameter `N` is specified + | +LL | let x: &[Foo<N>; N] = &[Foo::<_>; _]; + | ++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/repr/16-bit-repr-c-enum.rs b/tests/ui/repr/16-bit-repr-c-enum.rs index 8c2d2fafce0..d4d5a086dcc 100644 --- a/tests/ui/repr/16-bit-repr-c-enum.rs +++ b/tests/ui/repr/16-bit-repr-c-enum.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ build-pass //@ revisions: avr msp430 // @@ -11,6 +12,9 @@ #![stable(feature = "intrinsics_for_test", since = "3.3.3")] #![allow(dead_code)] +extern crate minicore; +use minicore::*; + // Test that the repr(C) attribute doesn't break compilation // Previous bad assumption was that 32-bit enum default width is fine on msp430, avr // But the width of the C int on these platforms is 16 bits, and C enums <= C int range @@ -26,11 +30,6 @@ enum Foo { #[rustc_intrinsic] const fn size_of<T>() -> usize; -#[lang="sized"] -trait Sized {} -#[lang="copy"] -trait Copy {} - const EXPECTED: usize = 2; const ACTUAL: usize = size_of::<Foo>(); // Validate that the size is indeed 16 bits, to match this C static_assert: diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index 204db30786e..42fcaee2d4a 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -81,7 +81,7 @@ error: layout_of(Univariant) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:39:1 + --> $DIR/repr-c-dead-variants.rs:43:1 | LL | enum Univariant { | ^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ error: layout_of(TwoVariants) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:46:1 + --> $DIR/repr-c-dead-variants.rs:50:1 | LL | enum TwoVariants { | ^^^^^^^^^^^^^^^^ @@ -327,7 +327,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:58:1 + --> $DIR/repr-c-dead-variants.rs:62:1 | LL | enum DeadBranchHasOtherField { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index 1fab00bf50c..bb2c6e70dc7 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -81,7 +81,7 @@ error: layout_of(Univariant) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:39:1 + --> $DIR/repr-c-dead-variants.rs:43:1 | LL | enum Univariant { | ^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ error: layout_of(TwoVariants) = Layout { unadjusted_abi_align: Align(1 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:46:1 + --> $DIR/repr-c-dead-variants.rs:50:1 | LL | enum TwoVariants { | ^^^^^^^^^^^^^^^^ @@ -327,7 +327,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:58:1 + --> $DIR/repr-c-dead-variants.rs:62:1 | LL | enum DeadBranchHasOtherField { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index 204db30786e..42fcaee2d4a 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -81,7 +81,7 @@ error: layout_of(Univariant) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:39:1 + --> $DIR/repr-c-dead-variants.rs:43:1 | LL | enum Univariant { | ^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ error: layout_of(TwoVariants) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:46:1 + --> $DIR/repr-c-dead-variants.rs:50:1 | LL | enum TwoVariants { | ^^^^^^^^^^^^^^^^ @@ -327,7 +327,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:58:1 + --> $DIR/repr-c-dead-variants.rs:62:1 | LL | enum DeadBranchHasOtherField { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/repr/repr-c-dead-variants.rs b/tests/ui/repr/repr-c-dead-variants.rs index 99f20982a99..7f274308562 100644 --- a/tests/ui/repr/repr-c-dead-variants.rs +++ b/tests/ui/repr/repr-c-dead-variants.rs @@ -4,8 +4,12 @@ #![no_std] #![no_core] +extern crate minicore; +use minicore::*; + // See also: repr-c-int-dead-variants.rs +//@ add-core-stubs //@ normalize-stderr: "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN" //@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED" @@ -59,6 +63,3 @@ enum DeadBranchHasOtherField { //~ ERROR layout_of Variant1(Void, Align8U64), Variant2(u8), } - -#[lang = "sized"] -trait Sized {} diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index 204db30786e..42fcaee2d4a 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -81,7 +81,7 @@ error: layout_of(Univariant) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:39:1 + --> $DIR/repr-c-dead-variants.rs:43:1 | LL | enum Univariant { | ^^^^^^^^^^^^^^^ @@ -219,7 +219,7 @@ error: layout_of(TwoVariants) = Layout { unadjusted_abi_align: Align(4 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:46:1 + --> $DIR/repr-c-dead-variants.rs:50:1 | LL | enum TwoVariants { | ^^^^^^^^^^^^^^^^ @@ -327,7 +327,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { unadjusted_abi_align: Align(8 bytes), randomization_seed: $SEED, } - --> $DIR/repr-c-dead-variants.rs:58:1 + --> $DIR/repr-c-dead-variants.rs:62:1 | LL | enum DeadBranchHasOtherField { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/repr/repr_align_greater_usize.msp430.stderr b/tests/ui/repr/repr_align_greater_usize.msp430.stderr index 7c85249c009..db25cb1b5f2 100644 --- a/tests/ui/repr/repr_align_greater_usize.msp430.stderr +++ b/tests/ui/repr/repr_align_greater_usize.msp430.stderr @@ -1,5 +1,5 @@ error[E0589]: alignment must not be greater than `isize::MAX` bytes - --> $DIR/repr_align_greater_usize.rs:21:8 + --> $DIR/repr_align_greater_usize.rs:22:8 | LL | #[repr(align(32768))] | ^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[repr(align(32768))] = note: `isize::MAX` is 32767 for the current target error[E0589]: alignment must not be greater than `isize::MAX` bytes - --> $DIR/repr_align_greater_usize.rs:24:8 + --> $DIR/repr_align_greater_usize.rs:25:8 | LL | #[repr(align(65536))] | ^^^^^^^^^^^^ diff --git a/tests/ui/repr/repr_align_greater_usize.rs b/tests/ui/repr/repr_align_greater_usize.rs index b47320b6d9b..7499e242d59 100644 --- a/tests/ui/repr/repr_align_greater_usize.rs +++ b/tests/ui/repr/repr_align_greater_usize.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: msp430 aarch32 //@[msp430] needs-llvm-components: msp430 //@[msp430] compile-flags: --target=msp430-none-elf @@ -12,8 +13,8 @@ #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; #[repr(align(16384))] struct Kitten; diff --git a/tests/ui/sanitizer/cfg-kasan.rs b/tests/ui/sanitizer/cfg-kasan.rs index 491eaf3acc1..ba0abf60570 100644 --- a/tests/ui/sanitizer/cfg-kasan.rs +++ b/tests/ui/sanitizer/cfg-kasan.rs @@ -1,6 +1,7 @@ // Verifies that when compiling with -Zsanitizer=kernel-address, // the `#[cfg(sanitize = "address")]` attribute is configured. +//@ add-core-stubs //@ check-pass //@ compile-flags: -Zsanitizer=kernel-address //@ revisions: aarch64 riscv64imac riscv64gc x86_64 @@ -17,8 +18,8 @@ #![feature(cfg_sanitize, no_core, lang_items)] #![no_core] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; const _: fn() -> () = main; diff --git a/tests/ui/sanitizer/cfg.rs b/tests/ui/sanitizer/cfg.rs index 7b8f285e41a..a43813c0446 100644 --- a/tests/ui/sanitizer/cfg.rs +++ b/tests/ui/sanitizer/cfg.rs @@ -1,6 +1,7 @@ // Verifies that when compiling with -Zsanitizer=option, // the `#[cfg(sanitize = "option")]` attribute is configured. +//@ add-core-stubs //@ check-pass //@ revisions: address cfi kcfi leak memory thread //@compile-flags: -Ctarget-feature=-crt-static @@ -23,10 +24,8 @@ #![crate_type="lib"] #![no_core] -#[lang="sized"] -trait Sized { } -#[lang="copy"] -trait Copy { } +extern crate minicore; +use minicore::*; #[cfg(all(sanitize = "address", address))] fn main() {} diff --git a/tests/ui/simd/array-trait.rs b/tests/ui/simd/array-trait.rs index 32cbf01428c..26218856771 100644 --- a/tests/ui/simd/array-trait.rs +++ b/tests/ui/simd/array-trait.rs @@ -1,11 +1,11 @@ // Figuring out the size of a vector type that depends on traits doesn't ICE #![allow(dead_code)] - - -#![feature(repr_simd, intrinsics, generic_const_exprs)] +#![feature(repr_simd, core_intrinsics, generic_const_exprs)] #![allow(non_camel_case_types, incomplete_features)] +use std::intrinsics::simd::{simd_extract, simd_insert}; + pub trait Simd { type Lane: Clone + Copy; const SIZE: usize; @@ -24,13 +24,6 @@ pub struct T<S: Simd>([S::Lane; S::SIZE]); //~| ERROR SIMD vector element type should be a primitive scalar //~| ERROR unconstrained generic constant -#[rustc_intrinsic] -unsafe fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; - -#[rustc_intrinsic] -unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E; - - pub fn main() { let mut t = T::<i32x4>([0; 4]); unsafe { diff --git a/tests/ui/simd/array-type.rs b/tests/ui/simd/array-type.rs index d1de7004416..468e0b2f9b5 100644 --- a/tests/ui/simd/array-type.rs +++ b/tests/ui/simd/array-type.rs @@ -1,8 +1,8 @@ //@ run-pass #![allow(dead_code)] +#![feature(repr_simd, core_intrinsics)] - -#![feature(repr_simd, intrinsics)] +use std::intrinsics::simd::{simd_extract, simd_insert}; #[repr(simd)] #[derive(Copy, Clone)] @@ -12,13 +12,6 @@ struct S([i32; 4]); #[derive(Copy, Clone)] struct T<const N: usize>([i32; N]); -#[rustc_intrinsic] -unsafe fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; - -#[rustc_intrinsic] -unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E; - - pub fn main() { let mut s = S([0; 4]); diff --git a/tests/ui/simd/const-err-trumps-simd-err.stderr b/tests/ui/simd/const-err-trumps-simd-err.stderr index 11cbcad227f..e88c277885e 100644 --- a/tests/ui/simd/const-err-trumps-simd-err.stderr +++ b/tests/ui/simd/const-err-trumps-simd-err.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of `get_elem::<4>::{constant#0}` failed --> $DIR/const-err-trumps-simd-err.rs:16:13 | LL | const { assert!(LANE < 4); } // the error should be here... - | ^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: LANE < 4', $DIR/const-err-trumps-simd-err.rs:16:13 + | ^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: LANE < 4 | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/simd/generics.rs b/tests/ui/simd/generics.rs index 453ed86c14a..1ae08fef7cd 100644 --- a/tests/ui/simd/generics.rs +++ b/tests/ui/simd/generics.rs @@ -1,7 +1,8 @@ //@ run-pass #![allow(non_camel_case_types)] -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] +use std::intrinsics::simd::simd_add; use std::ops; #[repr(simd)] @@ -20,11 +21,7 @@ struct B<T>([T; 4]); #[derive(Copy, Clone)] struct C<T, const N: usize>([T; N]); - -#[rustc_intrinsic] -unsafe fn simd_add<T>(x: T, y: T) -> T; - -fn add<T: ops::Add<Output=T>>(lhs: T, rhs: T) -> T { +fn add<T: ops::Add<Output = T>>(lhs: T, rhs: T) -> T { lhs + rhs } @@ -60,7 +57,6 @@ impl ops::Add for C<f32, 4> { } } - pub fn main() { let x = [1.0f32, 2.0f32, 3.0f32, 4.0f32]; let y = [2.0f32, 4.0f32, 6.0f32, 8.0f32]; diff --git a/tests/ui/simd/intrinsic/float-math-pass.rs b/tests/ui/simd/intrinsic/float-math-pass.rs index 91059f353fd..4c28568a739 100644 --- a/tests/ui/simd/intrinsic/float-math-pass.rs +++ b/tests/ui/simd/intrinsic/float-math-pass.rs @@ -8,58 +8,14 @@ // Test that the simd floating-point math intrinsics produce correct results. -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, intrinsics, core_intrinsics)] #![allow(non_camel_case_types)] #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct f32x4(pub [f32; 4]); -#[rustc_intrinsic] -unsafe fn simd_fsqrt<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_fabs<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_fsin<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_fcos<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_fexp<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_fexp2<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_fma<T>(x: T, y: T, z: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_relaxed_fma<T>(x: T, y: T, z: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_flog<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_flog10<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_flog2<T>(x: T) -> T; - -// rounding functions -#[rustc_intrinsic] -unsafe fn simd_ceil<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_floor<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_round<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_trunc<T>(x: T) -> T; +use std::intrinsics::simd::*; macro_rules! assert_approx_eq_f32 { ($a:expr, $b:expr) => {{ diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs index 0fcff8584c8..fdf06b7882e 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs @@ -1,7 +1,10 @@ //@ build-fail -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] + +use std::intrinsics::simd::*; + #[repr(simd)] #[derive(Copy, Clone)] pub struct i32x4(pub [i32; 4]); @@ -14,55 +17,6 @@ pub struct u32x4(pub [u32; 4]); #[derive(Copy, Clone)] pub struct f32x4(pub [f32; 4]); -#[rustc_intrinsic] -unsafe fn simd_add<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_sub<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_mul<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_div<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_rem<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_shl<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_shr<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_and<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_or<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_xor<T>(x: T, y: T) -> T; - - -#[rustc_intrinsic] -unsafe fn simd_neg<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_bswap<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_bitreverse<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_ctlz<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_ctpop<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_cttz<T>(x: T) -> T; - fn main() { let x = i32x4([0, 0, 0, 0]); let y = u32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr index e67de2fe903..76db6d5328f 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr @@ -1,143 +1,143 @@ error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:110:9 + --> $DIR/generic-arithmetic-2.rs:64:9 | LL | simd_add(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:112:9 + --> $DIR/generic-arithmetic-2.rs:66:9 | LL | simd_sub(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:114:9 + --> $DIR/generic-arithmetic-2.rs:68:9 | LL | simd_mul(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:116:9 + --> $DIR/generic-arithmetic-2.rs:70:9 | LL | simd_div(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:118:9 + --> $DIR/generic-arithmetic-2.rs:72:9 | LL | simd_shl(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:120:9 + --> $DIR/generic-arithmetic-2.rs:74:9 | LL | simd_shr(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:122:9 + --> $DIR/generic-arithmetic-2.rs:76:9 | LL | simd_and(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:124:9 + --> $DIR/generic-arithmetic-2.rs:78:9 | LL | simd_or(0, 0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:126:9 + --> $DIR/generic-arithmetic-2.rs:80:9 | LL | simd_xor(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:129:9 + --> $DIR/generic-arithmetic-2.rs:83:9 | LL | simd_neg(0); | ^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:131:9 + --> $DIR/generic-arithmetic-2.rs:85:9 | LL | simd_bswap(0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:133:9 + --> $DIR/generic-arithmetic-2.rs:87:9 | LL | simd_bitreverse(0); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:135:9 + --> $DIR/generic-arithmetic-2.rs:89:9 | LL | simd_ctlz(0); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:137:9 + --> $DIR/generic-arithmetic-2.rs:91:9 | LL | simd_cttz(0); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:140:9 + --> $DIR/generic-arithmetic-2.rs:94:9 | LL | simd_shl(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:142:9 + --> $DIR/generic-arithmetic-2.rs:96:9 | LL | simd_shr(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:144:9 + --> $DIR/generic-arithmetic-2.rs:98:9 | LL | simd_and(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:146:9 + --> $DIR/generic-arithmetic-2.rs:100:9 | LL | simd_or(z, z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:148:9 + --> $DIR/generic-arithmetic-2.rs:102:9 | LL | simd_xor(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:150:9 + --> $DIR/generic-arithmetic-2.rs:104:9 | LL | simd_bswap(z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:152:9 + --> $DIR/generic-arithmetic-2.rs:106:9 | LL | simd_bitreverse(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:154:9 + --> $DIR/generic-arithmetic-2.rs:108:9 | LL | simd_ctlz(z); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctpop` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:156:9 + --> $DIR/generic-arithmetic-2.rs:110:9 | LL | simd_ctpop(z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:158:9 + --> $DIR/generic-arithmetic-2.rs:112:9 | LL | simd_cttz(z); | ^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index 29d82255d4e..3f0325d690b 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -1,6 +1,6 @@ //@ run-pass #![allow(non_camel_case_types)] -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] @@ -22,53 +22,7 @@ macro_rules! all_eq { }}; } -#[rustc_intrinsic] -unsafe fn simd_add<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_sub<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_mul<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_div<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_rem<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_shl<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_shr<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_and<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_or<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_xor<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_neg<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_bswap<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_bitreverse<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_ctlz<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_ctpop<T>(x: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_cttz<T>(x: T) -> T; +use std::intrinsics::simd::*; fn main() { let x1 = i32x4([1, 2, 3, 4]); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs index 85464402d6a..ca170f2d850 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs @@ -1,7 +1,10 @@ //@ build-fail //@ ignore-emscripten -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] + +use std::intrinsics::simd::{simd_saturating_add, simd_saturating_sub}; + #[repr(simd)] #[derive(Copy, Clone)] pub struct i32x4(pub [i32; 4]); @@ -14,13 +17,6 @@ pub struct x4<T>(pub [T; 4]); #[derive(Copy, Clone)] pub struct f32x4(pub [f32; 4]); -#[rustc_intrinsic] -unsafe fn simd_saturating_add<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_saturating_sub<T>(x: T, y: T) -> T; - - fn main() { let x = i32x4([0, 0, 0, 0]); let y = x4([0_usize, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr index cf275db7e43..f7874582340 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr @@ -1,11 +1,11 @@ error[E0511]: invalid monomorphization of `simd_saturating_add` intrinsic: expected element type `f32` of vector type `f32x4` to be a signed or unsigned integer type - --> $DIR/generic-arithmetic-saturating-2.rs:35:9 + --> $DIR/generic-arithmetic-saturating-2.rs:31:9 | LL | simd_saturating_add(z, z); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_saturating_sub` intrinsic: expected element type `f32` of vector type `f32x4` to be a signed or unsigned integer type - --> $DIR/generic-arithmetic-saturating-2.rs:37:9 + --> $DIR/generic-arithmetic-saturating-2.rs:33:9 | LL | simd_saturating_sub(z, z); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs index 5fe65257d15..4d12a312331 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs @@ -2,7 +2,9 @@ //@ ignore-emscripten #![allow(non_camel_case_types)] -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] + +use std::intrinsics::simd::{simd_saturating_add, simd_saturating_sub}; #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] @@ -12,13 +14,6 @@ struct u32x4(pub [u32; 4]); #[derive(Copy, Clone)] struct I32<const N: usize>([i32; N]); -#[rustc_intrinsic] -unsafe fn simd_saturating_add<T>(x: T, y: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_saturating_sub<T>(x: T, y: T) -> T; - - fn main() { // unsigned { diff --git a/tests/ui/simd/intrinsic/generic-as.rs b/tests/ui/simd/intrinsic/generic-as.rs index 124ca56bc88..da53211cbc7 100644 --- a/tests/ui/simd/intrinsic/generic-as.rs +++ b/tests/ui/simd/intrinsic/generic-as.rs @@ -1,10 +1,8 @@ //@ run-pass -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] - -#[rustc_intrinsic] -unsafe fn simd_as<T, U>(x: T) -> U; +use std::intrinsics::simd::simd_as; #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/intrinsic/generic-bitmask-pass.rs b/tests/ui/simd/intrinsic/generic-bitmask-pass.rs index 08526991fbe..cb3221e21d5 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask-pass.rs +++ b/tests/ui/simd/intrinsic/generic-bitmask-pass.rs @@ -1,13 +1,12 @@ //@ run-pass #![allow(non_camel_case_types)] - //@ ignore-emscripten //@ ignore-endian-big behavior of simd_bitmask is endian-specific // Test that the simd_bitmask intrinsic produces correct results. +#![feature(repr_simd, core_intrinsics)] -#![feature(repr_simd, intrinsics)] -#[allow(non_camel_case_types)] +use std::intrinsics::simd::simd_bitmask; #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] @@ -21,9 +20,6 @@ struct u8x4(pub [u8; 4]); #[derive(Copy, Clone, PartialEq, Debug)] struct Tx4<T>(pub [T; 4]); -#[rustc_intrinsic] -unsafe fn simd_bitmask<T, U>(x: T) -> U; - fn main() { let z = u32x4([0, 0, 0, 0]); let ez = 0_u8; @@ -56,6 +52,5 @@ fn main() { let r: u8 = simd_bitmask(msize); assert_eq!(r, e); - } } diff --git a/tests/ui/simd/intrinsic/generic-bitmask.rs b/tests/ui/simd/intrinsic/generic-bitmask.rs index 49589d22bbf..9f5e806337e 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask.rs +++ b/tests/ui/simd/intrinsic/generic-bitmask.rs @@ -3,9 +3,11 @@ // Test that the simd_bitmask intrinsic produces ok-ish error // messages when misused. -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_bitmask; + #[repr(simd)] #[derive(Copy, Clone)] pub struct u32x2([u32; 2]); @@ -30,9 +32,6 @@ struct u8x32([u8; 32]); #[derive(Copy, Clone)] struct u8x64([u8; 64]); -#[rustc_intrinsic] -unsafe fn simd_bitmask<T, U>(x: T) -> U; - fn main() { let m2 = u32x2([0; 2]); let m4 = u32x4([0; 4]); @@ -63,6 +62,5 @@ fn main() { let _: u128 = simd_bitmask(m64); //~^ ERROR invalid monomorphization of `simd_bitmask` intrinsic - - } + } } diff --git a/tests/ui/simd/intrinsic/generic-bitmask.stderr b/tests/ui/simd/intrinsic/generic-bitmask.stderr index c217bb2d8f1..3c4878f39cc 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask.stderr +++ b/tests/ui/simd/intrinsic/generic-bitmask.stderr @@ -1,29 +1,29 @@ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u16`, expected `u8` or `[u8; 1]` - --> $DIR/generic-bitmask.rs:52:22 + --> $DIR/generic-bitmask.rs:51:22 | LL | let _: u16 = simd_bitmask(m2); | ^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u16`, expected `u8` or `[u8; 1]` - --> $DIR/generic-bitmask.rs:55:22 + --> $DIR/generic-bitmask.rs:54:22 | LL | let _: u16 = simd_bitmask(m8); | ^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u32`, expected `u16` or `[u8; 2]` - --> $DIR/generic-bitmask.rs:58:22 + --> $DIR/generic-bitmask.rs:57:22 | LL | let _: u32 = simd_bitmask(m16); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u64`, expected `u32` or `[u8; 4]` - --> $DIR/generic-bitmask.rs:61:22 + --> $DIR/generic-bitmask.rs:60:22 | LL | let _: u64 = simd_bitmask(m32); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u128`, expected `u64` or `[u8; 8]` - --> $DIR/generic-bitmask.rs:64:23 + --> $DIR/generic-bitmask.rs:63:23 | LL | let _: u128 = simd_bitmask(m64); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-bswap-byte.rs b/tests/ui/simd/intrinsic/generic-bswap-byte.rs index 4521573636c..903a07656a7 100644 --- a/tests/ui/simd/intrinsic/generic-bswap-byte.rs +++ b/tests/ui/simd/intrinsic/generic-bswap-byte.rs @@ -1,7 +1,9 @@ //@ run-pass -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_bswap; + #[repr(simd)] #[derive(Copy, Clone)] struct i8x4([i8; 4]); @@ -10,9 +12,6 @@ struct i8x4([i8; 4]); #[derive(Copy, Clone)] struct u8x4([u8; 4]); -#[rustc_intrinsic] -unsafe fn simd_bswap<T>(x: T) -> T; - fn main() { unsafe { assert_eq!(simd_bswap(i8x4([0, 1, 2, 3])).0, [0, 1, 2, 3]); diff --git a/tests/ui/simd/intrinsic/generic-cast-pass.rs b/tests/ui/simd/intrinsic/generic-cast-pass.rs index aab7347d1de..7a4663bcad2 100644 --- a/tests/ui/simd/intrinsic/generic-cast-pass.rs +++ b/tests/ui/simd/intrinsic/generic-cast-pass.rs @@ -1,9 +1,8 @@ //@ run-pass -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] -#[rustc_intrinsic] -unsafe fn simd_cast<T, U>(x: T) -> U; +use std::intrinsics::simd::simd_cast; use std::cmp::{max, min}; diff --git a/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs b/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs index 9f28898654f..ea34e9ffeb8 100644 --- a/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs +++ b/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs @@ -1,8 +1,7 @@ //@ run-pass -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] -#[rustc_intrinsic] -unsafe fn simd_cast<T, U>(x: T) -> U; +use std::intrinsics::simd::simd_cast; #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/intrinsic/generic-cast.rs b/tests/ui/simd/intrinsic/generic-cast.rs index 7f398804eb4..4b13a93f323 100644 --- a/tests/ui/simd/intrinsic/generic-cast.rs +++ b/tests/ui/simd/intrinsic/generic-cast.rs @@ -1,6 +1,8 @@ //@ build-fail -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] + +use std::intrinsics::simd::simd_cast; #[repr(simd)] #[derive(Copy, Clone)] @@ -20,10 +22,6 @@ struct f32x4([f32; 4]); #[allow(non_camel_case_types)] struct f32x8([f32; 8]); - -#[rustc_intrinsic] -unsafe fn simd_cast<T, U>(x: T) -> U; - fn main() { let x = i32x4([0, 0, 0, 0]); @@ -35,6 +33,6 @@ fn main() { simd_cast::<i32x4, i32>(x); //~^ ERROR expected SIMD return type, found non-SIMD `i32` simd_cast::<_, i32x8>(x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8 + //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8 } } diff --git a/tests/ui/simd/intrinsic/generic-cast.stderr b/tests/ui/simd/intrinsic/generic-cast.stderr index 1b6ac03f8c9..192aa13216b 100644 --- a/tests/ui/simd/intrinsic/generic-cast.stderr +++ b/tests/ui/simd/intrinsic/generic-cast.stderr @@ -1,23 +1,23 @@ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-cast.rs:31:9 + --> $DIR/generic-cast.rs:29:9 | LL | simd_cast::<i32, i32>(0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-cast.rs:33:9 + --> $DIR/generic-cast.rs:31:9 | LL | simd_cast::<i32, i32x4>(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-cast.rs:35:9 + --> $DIR/generic-cast.rs:33:9 | LL | simd_cast::<i32x4, i32>(x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8 - --> $DIR/generic-cast.rs:37:9 + --> $DIR/generic-cast.rs:35:9 | LL | simd_cast::<_, i32x8>(x); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-comparison-pass.rs b/tests/ui/simd/intrinsic/generic-comparison-pass.rs index d0ec2503602..2ee164cdfd8 100644 --- a/tests/ui/simd/intrinsic/generic-comparison-pass.rs +++ b/tests/ui/simd/intrinsic/generic-comparison-pass.rs @@ -1,8 +1,10 @@ //@ run-pass -#![feature(repr_simd, intrinsics, concat_idents)] +#![feature(repr_simd, core_intrinsics, concat_idents)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::{simd_eq, simd_ge, simd_gt, simd_le, simd_lt, simd_ne}; + #[repr(simd)] #[derive(Copy, Clone)] struct i32x4([i32; 4]); @@ -13,24 +15,6 @@ struct u32x4(pub [u32; 4]); #[derive(Copy, Clone)] struct f32x4(pub [f32; 4]); -#[rustc_intrinsic] -unsafe fn simd_eq<T, U>(x: T, y: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_ne<T, U>(x: T, y: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_lt<T, U>(x: T, y: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_le<T, U>(x: T, y: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_gt<T, U>(x: T, y: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_ge<T, U>(x: T, y: T) -> U; - macro_rules! cmp { ($method: ident($lhs: expr, $rhs: expr)) => {{ let lhs = $lhs; diff --git a/tests/ui/simd/intrinsic/generic-comparison.rs b/tests/ui/simd/intrinsic/generic-comparison.rs index e5adb49f6a3..ebd1f629be4 100644 --- a/tests/ui/simd/intrinsic/generic-comparison.rs +++ b/tests/ui/simd/intrinsic/generic-comparison.rs @@ -1,6 +1,6 @@ //@ build-fail -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #[repr(simd)] #[derive(Copy, Clone)] @@ -11,24 +11,7 @@ struct i32x4([i32; 4]); #[allow(non_camel_case_types)] struct i16x8([i16; 8]); - -#[rustc_intrinsic] -unsafe fn simd_eq<T, U>(x: T, y: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_ne<T, U>(x: T, y: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_lt<T, U>(x: T, y: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_le<T, U>(x: T, y: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_gt<T, U>(x: T, y: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_ge<T, U>(x: T, y: T) -> U; +use std::intrinsics::simd::{simd_eq, simd_ge, simd_gt, simd_le, simd_lt, simd_ne}; fn main() { let x = i32x4([0, 0, 0, 0]); @@ -61,16 +44,16 @@ fn main() { //~^ ERROR expected SIMD return type, found non-SIMD `i32` simd_eq::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 simd_ne::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 simd_lt::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 simd_le::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 simd_gt::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 simd_ge::<_, i16x8>(x, x); -//~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 + //~^ ERROR return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 } } diff --git a/tests/ui/simd/intrinsic/generic-comparison.stderr b/tests/ui/simd/intrinsic/generic-comparison.stderr index cc66d2ce40a..a6e91bf6a36 100644 --- a/tests/ui/simd/intrinsic/generic-comparison.stderr +++ b/tests/ui/simd/intrinsic/generic-comparison.stderr @@ -1,107 +1,107 @@ error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:37:9 + --> $DIR/generic-comparison.rs:20:9 | LL | simd_eq::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:39:9 + --> $DIR/generic-comparison.rs:22:9 | LL | simd_ne::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:41:9 + --> $DIR/generic-comparison.rs:24:9 | LL | simd_lt::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:43:9 + --> $DIR/generic-comparison.rs:26:9 | LL | simd_le::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:45:9 + --> $DIR/generic-comparison.rs:28:9 | LL | simd_gt::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:47:9 + --> $DIR/generic-comparison.rs:30:9 | LL | simd_ge::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:50:9 + --> $DIR/generic-comparison.rs:33:9 | LL | simd_eq::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:52:9 + --> $DIR/generic-comparison.rs:35:9 | LL | simd_ne::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:54:9 + --> $DIR/generic-comparison.rs:37:9 | LL | simd_lt::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:56:9 + --> $DIR/generic-comparison.rs:39:9 | LL | simd_le::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:58:9 + --> $DIR/generic-comparison.rs:41:9 | LL | simd_gt::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:60:9 + --> $DIR/generic-comparison.rs:43:9 | LL | simd_ge::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:63:9 + --> $DIR/generic-comparison.rs:46:9 | LL | simd_eq::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:65:9 + --> $DIR/generic-comparison.rs:48:9 | LL | simd_ne::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:67:9 + --> $DIR/generic-comparison.rs:50:9 | LL | simd_lt::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:69:9 + --> $DIR/generic-comparison.rs:52:9 | LL | simd_le::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:71:9 + --> $DIR/generic-comparison.rs:54:9 | LL | simd_gt::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:73:9 + --> $DIR/generic-comparison.rs:56:9 | LL | simd_ge::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-elements-pass.rs b/tests/ui/simd/intrinsic/generic-elements-pass.rs index b8d872c5cb7..4dc2e4d5a80 100644 --- a/tests/ui/simd/intrinsic/generic-elements-pass.rs +++ b/tests/ui/simd/intrinsic/generic-elements-pass.rs @@ -1,6 +1,8 @@ //@ run-pass -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] + +use std::intrinsics::simd::{simd_extract, simd_insert, simd_shuffle}; #[repr(simd)] #[derive(Copy, Clone, Debug, PartialEq)] @@ -15,15 +17,6 @@ struct i32x4([i32; 4]); #[allow(non_camel_case_types)] struct i32x8([i32; 8]); -#[rustc_intrinsic] -unsafe fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; - -#[rustc_intrinsic] -unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E; - -#[rustc_intrinsic] -unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; - #[repr(simd)] struct SimdShuffleIdx<const LEN: usize>([u32; LEN]); diff --git a/tests/ui/simd/intrinsic/generic-elements.rs b/tests/ui/simd/intrinsic/generic-elements.rs index 54cf35df8c7..905299a9289 100644 --- a/tests/ui/simd/intrinsic/generic-elements.rs +++ b/tests/ui/simd/intrinsic/generic-elements.rs @@ -1,8 +1,20 @@ //@ build-fail -#![feature(repr_simd, intrinsics, rustc_attrs, adt_const_params, unsized_const_params)] +#![feature( + repr_simd, + intrinsics, + core_intrinsics, + rustc_attrs, + adt_const_params, + unsized_const_params +)] #![allow(incomplete_features)] +use std::intrinsics::simd::{simd_extract, simd_insert, simd_shuffle}; + +#[rustc_intrinsic] +unsafe fn simd_shuffle_const_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U; + #[repr(simd)] #[derive(Copy, Clone)] #[allow(non_camel_case_types)] @@ -29,21 +41,6 @@ struct f32x4([f32; 4]); #[allow(non_camel_case_types)] struct f32x8([f32; 8]); - -#[rustc_intrinsic] -unsafe fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; - -#[rustc_intrinsic] -unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E; - - -#[rustc_intrinsic] -unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; - -#[rustc_intrinsic] -unsafe fn simd_shuffle_const_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U; - - #[repr(simd)] struct SimdShuffleIdx<const LEN: usize>([u32; LEN]); diff --git a/tests/ui/simd/intrinsic/generic-elements.stderr b/tests/ui/simd/intrinsic/generic-elements.stderr index 1b3e8d59213..3779aa86cee 100644 --- a/tests/ui/simd/intrinsic/generic-elements.stderr +++ b/tests/ui/simd/intrinsic/generic-elements.stderr @@ -1,125 +1,125 @@ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:54:9 + --> $DIR/generic-elements.rs:51:9 | LL | simd_insert(0, 0, 0); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected inserted type `i32` (element of input `i32x4`), found `f64` - --> $DIR/generic-elements.rs:56:9 + --> $DIR/generic-elements.rs:53:9 | LL | simd_insert(x, 0, 1.0); | ^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_extract` intrinsic: expected return type `i32` (element of input `i32x4`), found `f32` - --> $DIR/generic-elements.rs:58:9 + --> $DIR/generic-elements.rs:55:9 | LL | simd_extract::<_, f32>(x, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:62:9 + --> $DIR/generic-elements.rs:59:9 | LL | simd_shuffle::<i32, _, i32>(0, 0, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:65:9 + --> $DIR/generic-elements.rs:62:9 | LL | simd_shuffle::<i32, _, i32>(0, 0, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:68:9 + --> $DIR/generic-elements.rs:65:9 | LL | simd_shuffle::<i32, _, i32>(0, 0, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - --> $DIR/generic-elements.rs:71:9 + --> $DIR/generic-elements.rs:68:9 | LL | simd_shuffle::<_, _, f32x2>(x, x, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - --> $DIR/generic-elements.rs:73:9 + --> $DIR/generic-elements.rs:70:9 | LL | simd_shuffle::<_, _, f32x4>(x, x, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - --> $DIR/generic-elements.rs:75:9 + --> $DIR/generic-elements.rs:72:9 | LL | simd_shuffle::<_, _, f32x8>(x, x, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 2, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:78:9 + --> $DIR/generic-elements.rs:75:9 | LL | simd_shuffle::<_, _, i32x8>(x, x, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 4, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:80:9 + --> $DIR/generic-elements.rs:77:9 | LL | simd_shuffle::<_, _, i32x8>(x, x, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 8, found `i32x2` with length 2 - --> $DIR/generic-elements.rs:82:9 + --> $DIR/generic-elements.rs:79:9 | LL | simd_shuffle::<_, _, i32x2>(x, x, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:86:9 + --> $DIR/generic-elements.rs:83:9 | LL | simd_shuffle_const_generic::<i32, i32, I2>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:89:9 + --> $DIR/generic-elements.rs:86:9 | LL | simd_shuffle_const_generic::<i32, i32, I4>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:92:9 + --> $DIR/generic-elements.rs:89:9 | LL | simd_shuffle_const_generic::<i32, i32, I8>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - --> $DIR/generic-elements.rs:95:9 + --> $DIR/generic-elements.rs:92:9 | LL | simd_shuffle_const_generic::<_, f32x2, I2>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - --> $DIR/generic-elements.rs:97:9 + --> $DIR/generic-elements.rs:94:9 | LL | simd_shuffle_const_generic::<_, f32x4, I4>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - --> $DIR/generic-elements.rs:99:9 + --> $DIR/generic-elements.rs:96:9 | LL | simd_shuffle_const_generic::<_, f32x8, I8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return type of length 2, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:102:9 + --> $DIR/generic-elements.rs:99:9 | LL | simd_shuffle_const_generic::<_, i32x8, I2>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return type of length 4, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:104:9 + --> $DIR/generic-elements.rs:101:9 | LL | simd_shuffle_const_generic::<_, i32x8, I4>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return type of length 8, found `i32x2` with length 2 - --> $DIR/generic-elements.rs:106:9 + --> $DIR/generic-elements.rs:103:9 | LL | simd_shuffle_const_generic::<_, i32x2, I8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-gather-pass.rs b/tests/ui/simd/intrinsic/generic-gather-pass.rs index 0b2cf47e989..b98d4d6575b 100644 --- a/tests/ui/simd/intrinsic/generic-gather-pass.rs +++ b/tests/ui/simd/intrinsic/generic-gather-pass.rs @@ -3,19 +3,15 @@ // Test that the simd_{gather,scatter} intrinsics produce the correct results. -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::{simd_gather, simd_scatter}; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct x4<T>(pub [T; 4]); -#[rustc_intrinsic] -unsafe fn simd_gather<T, U, V>(x: T, y: U, z: V) -> T; - -#[rustc_intrinsic] -unsafe fn simd_scatter<T, U, V>(x: T, y: U, z: V) -> (); - fn main() { let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; @@ -26,12 +22,8 @@ fn main() { // reading from *const unsafe { let pointer = x.as_ptr(); - let pointers = x4([ - pointer.offset(0), - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ]); + let pointers = + x4([pointer.offset(0), pointer.offset(2), pointer.offset(4), pointer.offset(6)]); let r_strided = simd_gather(default, pointers, mask); @@ -41,12 +33,8 @@ fn main() { // reading from *mut unsafe { let pointer = x.as_mut_ptr(); - let pointers = x4([ - pointer.offset(0), - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ]); + let pointers = + x4([pointer.offset(0), pointer.offset(2), pointer.offset(4), pointer.offset(6)]); let r_strided = simd_gather(default, pointers, mask); @@ -56,12 +44,8 @@ fn main() { // writing to *mut unsafe { let pointer = x.as_mut_ptr(); - let pointers = x4([ - pointer.offset(0), - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ]); + let pointers = + x4([pointer.offset(0), pointer.offset(2), pointer.offset(4), pointer.offset(6)]); let values = x4([42_f32, 43_f32, 44_f32, 45_f32]); simd_scatter(values, pointers, mask); @@ -78,7 +62,7 @@ fn main() { &x[4] as *const f32, &x[5] as *const f32, &x[6] as *const f32, - &x[7] as *const f32 + &x[7] as *const f32, ]; let default = x4([y[0], y[0], y[0], y[0]]); @@ -87,12 +71,8 @@ fn main() { // reading from *const unsafe { let pointer = y.as_ptr(); - let pointers = x4([ - pointer.offset(0), - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ]); + let pointers = + x4([pointer.offset(0), pointer.offset(2), pointer.offset(4), pointer.offset(6)]); let r_strided = simd_gather(default, pointers, mask); @@ -102,12 +82,8 @@ fn main() { // reading from *mut unsafe { let pointer = y.as_mut_ptr(); - let pointers = x4([ - pointer.offset(0), - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ]); + let pointers = + x4([pointer.offset(0), pointer.offset(2), pointer.offset(4), pointer.offset(6)]); let r_strided = simd_gather(default, pointers, mask); @@ -117,12 +93,8 @@ fn main() { // writing to *mut unsafe { let pointer = y.as_mut_ptr(); - let pointers = x4([ - pointer.offset(0), - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ]); + let pointers = + x4([pointer.offset(0), pointer.offset(2), pointer.offset(4), pointer.offset(6)]); let values = x4([y[7], y[6], y[5], y[1]]); simd_scatter(values, pointers, mask); @@ -135,7 +107,7 @@ fn main() { &x[4] as *const f32, &x[5] as *const f32, &x[1] as *const f32, - &x[7] as *const f32 + &x[7] as *const f32, ]; assert_eq!(y, s); } diff --git a/tests/ui/simd/intrinsic/generic-reduction-pass.rs b/tests/ui/simd/intrinsic/generic-reduction-pass.rs index 8408d0f203b..2d5d75447b6 100644 --- a/tests/ui/simd/intrinsic/generic-reduction-pass.rs +++ b/tests/ui/simd/intrinsic/generic-reduction-pass.rs @@ -1,12 +1,11 @@ //@ run-pass #![allow(non_camel_case_types)] - //@ ignore-emscripten // Test that the simd_reduce_{op} intrinsics produce the correct results. +#![feature(repr_simd, core_intrinsics)] -#![feature(repr_simd, intrinsics)] -#[allow(non_camel_case_types)] +use std::intrinsics::simd::*; #[repr(simd)] #[derive(Copy, Clone)] @@ -24,39 +23,6 @@ struct f32x4(pub [f32; 4]); #[derive(Copy, Clone)] struct b8x4(pub [i8; 4]); -#[rustc_intrinsic] -unsafe fn simd_reduce_add_unordered<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_mul_unordered<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_add_ordered<T, U>(x: T, acc: U) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_mul_ordered<T, U>(x: T, acc: U) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_min<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_max<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_and<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_or<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_xor<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_all<T>(x: T) -> bool; - -#[rustc_intrinsic] -unsafe fn simd_reduce_any<T>(x: T) -> bool; - fn main() { unsafe { let x = i32x4([1, -2, 3, 4]); diff --git a/tests/ui/simd/intrinsic/generic-reduction.rs b/tests/ui/simd/intrinsic/generic-reduction.rs index ead13250643..49a33ac35e7 100644 --- a/tests/ui/simd/intrinsic/generic-reduction.rs +++ b/tests/ui/simd/intrinsic/generic-reduction.rs @@ -4,9 +4,11 @@ // Test that the simd_reduce_{op} intrinsics produce ok-ish error // messages when misused. -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::*; + #[repr(simd)] #[derive(Copy, Clone)] pub struct f32x4(pub [f32; 4]); @@ -15,27 +17,6 @@ pub struct f32x4(pub [f32; 4]); #[derive(Copy, Clone)] pub struct u32x4(pub [u32; 4]); -#[rustc_intrinsic] -unsafe fn simd_reduce_add_ordered<T, U>(x: T, y: U) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_and<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_or<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_xor<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_reduce_all<T>(x: T) -> bool; - -#[rustc_intrinsic] -unsafe fn simd_reduce_any<T>(x: T) -> bool; - fn main() { let x = u32x4([0, 0, 0, 0]); let z = f32x4([0.0, 0.0, 0.0, 0.0]); diff --git a/tests/ui/simd/intrinsic/generic-reduction.stderr b/tests/ui/simd/intrinsic/generic-reduction.stderr index 302b9ae1d77..eaa7b8d48eb 100644 --- a/tests/ui/simd/intrinsic/generic-reduction.stderr +++ b/tests/ui/simd/intrinsic/generic-reduction.stderr @@ -1,59 +1,59 @@ error[E0511]: invalid monomorphization of `simd_reduce_add_ordered` intrinsic: expected return type `f32` (element of input `f32x4`), found `i32` - --> $DIR/generic-reduction.rs:44:9 + --> $DIR/generic-reduction.rs:25:9 | LL | simd_reduce_add_ordered(z, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_mul_ordered` intrinsic: expected return type `f32` (element of input `f32x4`), found `i32` - --> $DIR/generic-reduction.rs:46:9 + --> $DIR/generic-reduction.rs:27:9 | LL | simd_reduce_mul_ordered(z, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` - --> $DIR/generic-reduction.rs:49:22 + --> $DIR/generic-reduction.rs:30:22 | LL | let _: f32 = simd_reduce_and(x); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` - --> $DIR/generic-reduction.rs:51:22 + --> $DIR/generic-reduction.rs:32:22 | LL | let _: f32 = simd_reduce_or(x); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` - --> $DIR/generic-reduction.rs:53:22 + --> $DIR/generic-reduction.rs:34:22 | LL | let _: f32 = simd_reduce_xor(x); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: unsupported simd_reduce_and from `f32x4` with element `f32` to `f32` - --> $DIR/generic-reduction.rs:56:22 + --> $DIR/generic-reduction.rs:37:22 | LL | let _: f32 = simd_reduce_and(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: unsupported simd_reduce_or from `f32x4` with element `f32` to `f32` - --> $DIR/generic-reduction.rs:58:22 + --> $DIR/generic-reduction.rs:39:22 | LL | let _: f32 = simd_reduce_or(z); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: unsupported simd_reduce_xor from `f32x4` with element `f32` to `f32` - --> $DIR/generic-reduction.rs:60:22 + --> $DIR/generic-reduction.rs:41:22 | LL | let _: f32 = simd_reduce_xor(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_all` intrinsic: unsupported simd_reduce_all from `f32x4` with element `f32` to `bool` - --> $DIR/generic-reduction.rs:63:23 + --> $DIR/generic-reduction.rs:44:23 | LL | let _: bool = simd_reduce_all(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_any` intrinsic: unsupported simd_reduce_any from `f32x4` with element `f32` to `bool` - --> $DIR/generic-reduction.rs:65:23 + --> $DIR/generic-reduction.rs:46:23 | LL | let _: bool = simd_reduce_any(z); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-select-pass.rs b/tests/ui/simd/intrinsic/generic-select-pass.rs index 6b1b6cb79db..0e5f7c4902f 100644 --- a/tests/ui/simd/intrinsic/generic-select-pass.rs +++ b/tests/ui/simd/intrinsic/generic-select-pass.rs @@ -1,13 +1,12 @@ //@ run-pass #![allow(non_camel_case_types)] - //@ ignore-emscripten //@ ignore-endian-big behavior of simd_select_bitmask is endian-specific // Test that the simd_select intrinsics produces correct results. +#![feature(repr_simd, core_intrinsics)] -#![feature(repr_simd, intrinsics)] -#[allow(non_camel_case_types)] +use std::intrinsics::simd::{simd_select, simd_select_bitmask}; #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] @@ -29,13 +28,6 @@ struct f32x4(pub [f32; 4]); #[derive(Copy, Clone, PartialEq, Debug)] struct b8x4(pub [i8; 4]); -#[rustc_intrinsic] -unsafe fn simd_select<T, U>(x: T, a: U, b: U) -> U; - -#[rustc_intrinsic] -unsafe fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U; - - fn main() { let m0 = b8x4([!0, !0, !0, !0]); let m1 = b8x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-select.rs b/tests/ui/simd/intrinsic/generic-select.rs index 340fe3f3592..917ad3ca604 100644 --- a/tests/ui/simd/intrinsic/generic-select.rs +++ b/tests/ui/simd/intrinsic/generic-select.rs @@ -3,9 +3,11 @@ // Test that the simd_select intrinsic produces ok-ish error // messages when misused. -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::{simd_select, simd_select_bitmask}; + #[repr(simd)] #[derive(Copy, Clone)] pub struct f32x4(pub [f32; 4]); @@ -22,14 +24,6 @@ struct b8x4(pub [i8; 4]); #[derive(Copy, Clone, PartialEq)] struct b8x8(pub [i8; 8]); - -#[rustc_intrinsic] -unsafe fn simd_select<T, U>(x: T, a: U, b: U) -> U; - -#[rustc_intrinsic] -unsafe fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U; - - fn main() { let m4 = b8x4([0, 0, 0, 0]); let m8 = b8x8([0, 0, 0, 0, 0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-select.stderr b/tests/ui/simd/intrinsic/generic-select.stderr index a97fc91f951..c46584d117c 100644 --- a/tests/ui/simd/intrinsic/generic-select.stderr +++ b/tests/ui/simd/intrinsic/generic-select.stderr @@ -1,47 +1,47 @@ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mismatched lengths: mask length `8` != other vector length `4` - --> $DIR/generic-select.rs:42:9 + --> $DIR/generic-select.rs:36:9 | LL | simd_select(m8, x, x); | ^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `u32`, expected `i_` - --> $DIR/generic-select.rs:45:9 + --> $DIR/generic-select.rs:39:9 | LL | simd_select(x, x, x); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `f32`, expected `i_` - --> $DIR/generic-select.rs:48:9 + --> $DIR/generic-select.rs:42:9 | LL | simd_select(z, z, z); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select` intrinsic: expected SIMD argument type, found non-SIMD `u32` - --> $DIR/generic-select.rs:51:9 + --> $DIR/generic-select.rs:45:9 | LL | simd_select(m4, 0u32, 1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: invalid bitmask `u16`, expected `u8` or `[u8; 1]` - --> $DIR/generic-select.rs:54:9 + --> $DIR/generic-select.rs:48:9 | LL | simd_select_bitmask(0u16, x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: expected SIMD argument type, found non-SIMD `u32` - --> $DIR/generic-select.rs:57:9 + --> $DIR/generic-select.rs:51:9 | LL | simd_select_bitmask(0u8, 1u32, 2u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: invalid bitmask `f32`, expected `u8` or `[u8; 1]` - --> $DIR/generic-select.rs:60:9 + --> $DIR/generic-select.rs:54:9 | LL | simd_select_bitmask(0.0f32, x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: invalid bitmask `&str`, expected `u8` or `[u8; 1]` - --> $DIR/generic-select.rs:63:9 + --> $DIR/generic-select.rs:57:9 | LL | simd_select_bitmask("x", x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-shuffle.rs b/tests/ui/simd/intrinsic/generic-shuffle.rs index 1223b8ebe19..7cfd764f5d5 100644 --- a/tests/ui/simd/intrinsic/generic-shuffle.rs +++ b/tests/ui/simd/intrinsic/generic-shuffle.rs @@ -3,16 +3,14 @@ // Test that the simd_shuffle intrinsic produces ok-ish error // messages when misused. -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] + +use std::intrinsics::simd::simd_shuffle; #[repr(simd)] #[derive(Copy, Clone)] pub struct Simd<T, const N: usize>([T; N]); -#[rustc_intrinsic] -unsafe fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; - - fn main() { const I: Simd<u32, 2> = Simd([0; 2]); const I2: Simd<f32, 2> = Simd([0.; 2]); diff --git a/tests/ui/simd/intrinsic/generic-shuffle.stderr b/tests/ui/simd/intrinsic/generic-shuffle.stderr index 7e6d51a5f65..e8cd528b702 100644 --- a/tests/ui/simd/intrinsic/generic-shuffle.stderr +++ b/tests/ui/simd/intrinsic/generic-shuffle.stderr @@ -1,23 +1,23 @@ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: simd_shuffle index must be a SIMD vector of `u32`, got `[u32; 2]` - --> $DIR/generic-shuffle.rs:24:31 + --> $DIR/generic-shuffle.rs:22:31 | LL | let _: Simd<u32, 2> = simd_shuffle(v, v, const { [0u32; 2] }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 2, found `Simd<u32, 4>` with length 4 - --> $DIR/generic-shuffle.rs:27:31 + --> $DIR/generic-shuffle.rs:25:31 | LL | let _: Simd<u32, 4> = simd_shuffle(v, v, I); | ^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `u32` (element of input `Simd<u32, 4>`), found `Simd<f32, 2>` with element type `f32` - --> $DIR/generic-shuffle.rs:30:31 + --> $DIR/generic-shuffle.rs:28:31 | LL | let _: Simd<f32, 2> = simd_shuffle(v, v, I); | ^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: simd_shuffle index must be a SIMD vector of `u32`, got `Simd<f32, 2>` - --> $DIR/generic-shuffle.rs:33:31 + --> $DIR/generic-shuffle.rs:31:31 | LL | let _: Simd<u32, 2> = simd_shuffle(v, v, I2); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs b/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs index b324ac40749..49a26ff5734 100644 --- a/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs +++ b/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs @@ -3,10 +3,9 @@ // //@ run-pass //@ compile-flags: -Zmir-opt-level=4 -#![feature(intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -#[rustc_intrinsic] -unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; +use std::intrinsics::simd::simd_shuffle; #[repr(simd)] #[derive(Debug, PartialEq)] diff --git a/tests/ui/simd/intrinsic/inlining-issue67557.rs b/tests/ui/simd/intrinsic/inlining-issue67557.rs index 319bb15c015..13e7266b2a5 100644 --- a/tests/ui/simd/intrinsic/inlining-issue67557.rs +++ b/tests/ui/simd/intrinsic/inlining-issue67557.rs @@ -3,10 +3,9 @@ // //@ run-pass //@ compile-flags: -Zmir-opt-level=4 -#![feature(intrinsics, repr_simd)] +#![feature(core_intrinsics, repr_simd)] -#[rustc_intrinsic] -unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; +use std::intrinsics::simd::simd_shuffle; #[repr(simd)] #[derive(Debug, PartialEq)] @@ -36,7 +35,6 @@ fn assert_10_13(x: Simd2) { assert_eq!(x, Simd2([10, 13])); } - #[inline(always)] unsafe fn inline_me() -> Simd2 { const IDX: SimdShuffleIdx<2> = SimdShuffleIdx([0, 3]); diff --git a/tests/ui/simd/intrinsic/issue-85855.rs b/tests/ui/simd/intrinsic/issue-85855.rs index daeea793d1b..cbaa8f046be 100644 --- a/tests/ui/simd/intrinsic/issue-85855.rs +++ b/tests/ui/simd/intrinsic/issue-85855.rs @@ -3,8 +3,7 @@ // that no ICE occurs in these cases. #![feature(intrinsics)] -#![crate_type="lib"] - +#![crate_type = "lib"] #[rustc_intrinsic] unsafe fn simd_saturating_add<'a, T: 'a>(x: T, y: T); diff --git a/tests/ui/simd/intrinsic/issue-85855.stderr b/tests/ui/simd/intrinsic/issue-85855.stderr index b91a606ba68..af61c6fcdc1 100644 --- a/tests/ui/simd/intrinsic/issue-85855.stderr +++ b/tests/ui/simd/intrinsic/issue-85855.stderr @@ -1,17 +1,17 @@ error[E0094]: intrinsic has wrong number of lifetime parameters: found 1, expected 0 - --> $DIR/issue-85855.rs:10:30 + --> $DIR/issue-85855.rs:9:30 | LL | unsafe fn simd_saturating_add<'a, T: 'a>(x: T, y: T); | ^^^^^^^^^^^ expected 0 lifetime parameters error[E0094]: intrinsic has wrong number of type parameters: found 2, expected 1 - --> $DIR/issue-85855.rs:17:19 + --> $DIR/issue-85855.rs:16:19 | LL | unsafe fn simd_sub<T, U>(x: T, y: U); | ^^^^^^ expected 1 type parameter error[E0094]: intrinsic has wrong number of const parameters: found 1, expected 0 - --> $DIR/issue-85855.rs:21:19 + --> $DIR/issue-85855.rs:20:19 | LL | unsafe fn simd_mul<T, const N: usize>(x: T, y: T); | ^^^^^^^^^^^^^^^^^^^ expected 0 const parameters diff --git a/tests/ui/simd/intrinsic/ptr-cast.rs b/tests/ui/simd/intrinsic/ptr-cast.rs index 559b8ba1b5c..3a73c0273e1 100644 --- a/tests/ui/simd/intrinsic/ptr-cast.rs +++ b/tests/ui/simd/intrinsic/ptr-cast.rs @@ -1,16 +1,8 @@ //@ run-pass -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] - -#[rustc_intrinsic] -unsafe fn simd_cast_ptr<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_expose_provenance<T, U>(x: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_with_exposed_provenance<T, U>(x: T) -> U; +use std::intrinsics::simd::{simd_cast_ptr, simd_expose_provenance, simd_with_exposed_provenance}; #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/issue-105439.rs b/tests/ui/simd/issue-105439.rs index 108bb282df2..0a44f36fb2e 100644 --- a/tests/ui/simd/issue-105439.rs +++ b/tests/ui/simd/issue-105439.rs @@ -1,17 +1,13 @@ //@ run-pass //@ compile-flags: -O -Zverify-llvm-ir -#![feature(repr_simd)] -#![feature(intrinsics)] +#![feature(repr_simd, core_intrinsics)] #[allow(non_camel_case_types)] #[derive(Clone, Copy)] #[repr(simd)] struct i32x4([i32; 4]); -#[rustc_intrinsic] -pub(crate) unsafe fn simd_add<T>(x: T, y: T) -> T; - #[inline(always)] fn to_array(a: i32x4) -> [i32; 4] { a.0 @@ -19,6 +15,6 @@ fn to_array(a: i32x4) -> [i32; 4] { fn main() { let a = i32x4([1, 2, 3, 4]); - let b = unsafe { simd_add(a, a) }; + let b = unsafe { std::intrinsics::simd::simd_add(a, a) }; assert_eq!(to_array(b), [2, 4, 6, 8]); } diff --git a/tests/ui/simd/issue-39720.rs b/tests/ui/simd/issue-39720.rs index c3c4750d6de..db441e55167 100644 --- a/tests/ui/simd/issue-39720.rs +++ b/tests/ui/simd/issue-39720.rs @@ -1,6 +1,6 @@ //@ run-pass -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #[repr(simd)] #[derive(Copy, Clone, Debug)] @@ -10,11 +10,8 @@ pub struct Char3(pub [i8; 3]); #[derive(Copy, Clone, Debug)] pub struct Short3(pub [i16; 3]); -#[rustc_intrinsic] -unsafe fn simd_cast<T, U>(x: T) -> U; - fn main() { - let cast: Short3 = unsafe { simd_cast(Char3([10, -3, -9])) }; + let cast: Short3 = unsafe { std::intrinsics::simd::simd_cast(Char3([10, -3, -9])) }; println!("{:?}", cast); } diff --git a/tests/ui/simd/issue-85915-simd-ptrs.rs b/tests/ui/simd/issue-85915-simd-ptrs.rs index 2e7baf48ee3..4e2379d0525 100644 --- a/tests/ui/simd/issue-85915-simd-ptrs.rs +++ b/tests/ui/simd/issue-85915-simd-ptrs.rs @@ -3,9 +3,11 @@ // Short form of the generic gather/scatter tests, // verifying simd([*const T; N]) and simd([*mut T; N]) pass typeck and work. -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::{simd_gather, simd_scatter}; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct cptrx4<T>([*const T; 4]); @@ -22,13 +24,6 @@ struct f32x4([f32; 4]); #[derive(Copy, Clone, PartialEq, Debug)] struct i32x4([i32; 4]); - -#[rustc_intrinsic] -unsafe fn simd_gather<T, U, V>(x: T, y: U, z: V) -> T; - -#[rustc_intrinsic] -unsafe fn simd_scatter<T, U, V>(x: T, y: U, z: V) -> (); - fn main() { let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; @@ -39,11 +34,11 @@ fn main() { // reading from *const unsafe { let pointer = &x as *const f32; - let pointers = cptrx4([ + let pointers = cptrx4([ pointer.offset(0) as *const f32, pointer.offset(2), pointer.offset(4), - pointer.offset(6) + pointer.offset(6), ]); let r_strided = simd_gather(default, pointers, mask); @@ -58,7 +53,7 @@ fn main() { pointer.offset(0) as *mut f32, pointer.offset(2), pointer.offset(4), - pointer.offset(6) + pointer.offset(6), ]); let values = f32x4([42_f32, 43_f32, 44_f32, 45_f32]); diff --git a/tests/ui/simd/issue-89193.rs b/tests/ui/simd/issue-89193.rs index 4b4fb9d9169..a6c3017572a 100644 --- a/tests/ui/simd/issue-89193.rs +++ b/tests/ui/simd/issue-89193.rs @@ -3,16 +3,15 @@ // Test that simd gather instructions on slice of usize don't cause crash // See issue #89183 - https://github.com/rust-lang/rust/issues/89193 -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_gather; + #[repr(simd)] #[derive(Copy, Clone, PartialEq, Debug)] struct x4<T>(pub [T; 4]); -#[rustc_intrinsic] -unsafe fn simd_gather<T, U, V>(x: T, y: U, z: V) -> T; - fn main() { let x: [usize; 4] = [10, 11, 12, 13]; let default = x4([0_usize, 1, 2, 3]); @@ -22,12 +21,8 @@ fn main() { unsafe { let pointer = x.as_ptr(); - let pointers = x4([ - pointer.offset(0), - pointer.offset(1), - pointer.offset(2), - pointer.offset(3) - ]); + let pointers = + x4([pointer.offset(0), pointer.offset(1), pointer.offset(2), pointer.offset(3)]); let result = simd_gather(default, pointers, mask); assert_eq!(result, expected); } @@ -39,12 +34,8 @@ fn main() { unsafe { let pointer = x.as_ptr(); - let pointers = x4([ - pointer.offset(0), - pointer.offset(1), - pointer.offset(2), - pointer.offset(3) - ]); + let pointers = + x4([pointer.offset(0), pointer.offset(1), pointer.offset(2), pointer.offset(3)]); let result = simd_gather(default, pointers, mask); assert_eq!(result, expected); } diff --git a/tests/ui/simd/masked-load-store-build-fail.rs b/tests/ui/simd/masked-load-store-build-fail.rs index b8742184eb0..ad2de556103 100644 --- a/tests/ui/simd/masked-load-store-build-fail.rs +++ b/tests/ui/simd/masked-load-store-build-fail.rs @@ -1,12 +1,7 @@ //@ build-fail -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] - -#[rustc_intrinsic] -unsafe fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_masked_store<M, P, T>(mask: M, pointer: P, values: T) -> (); +use std::intrinsics::simd::{simd_masked_load, simd_masked_store}; #[derive(Copy, Clone)] #[repr(simd)] @@ -17,60 +12,28 @@ fn main() { let mut arr = [4u8, 5, 6, 7]; let default = Simd::<u8, 4>([9; 4]); - simd_masked_load( - Simd::<i8, 8>([-1, 0, -1, -1, 0, 0, 0, 0]), - arr.as_ptr(), - default - ); - //~^^^^^ ERROR expected third argument with length 8 (same as input type `Simd<i8, 8>`), found `Simd<u8, 4>` with length 4 + simd_masked_load(Simd::<i8, 8>([-1, 0, -1, -1, 0, 0, 0, 0]), arr.as_ptr(), default); + //~^ ERROR expected third argument with length 8 (same as input type `Simd<i8, 8>`), found `Simd<u8, 4>` with length 4 - simd_masked_load( - Simd::<i8, 4>([-1, 0, -1, -1]), - arr.as_ptr() as *const i8, - default - ); - //~^^^^^ ERROR expected element type `u8` of second argument `*const i8` to be a pointer to the element type `u8` of the first argument `Simd<u8, 4>`, found `u8` != `*_ u8` + simd_masked_load(Simd::<i8, 4>([-1, 0, -1, -1]), arr.as_ptr() as *const i8, default); + //~^ ERROR expected element type `u8` of second argument `*const i8` to be a pointer to the element type `u8` of the first argument `Simd<u8, 4>`, found `u8` != `*_ u8` - simd_masked_load( - Simd::<i8, 4>([-1, 0, -1, -1]), - arr.as_ptr(), - Simd::<u32, 4>([9; 4]) - ); - //~^^^^^ ERROR expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd<u32, 4>`, found `u32` != `*_ u32` + simd_masked_load(Simd::<i8, 4>([-1, 0, -1, -1]), arr.as_ptr(), Simd::<u32, 4>([9; 4])); + //~^ ERROR expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd<u32, 4>`, found `u32` != `*_ u32` - simd_masked_load( - Simd::<u8, 4>([1, 0, 1, 1]), - arr.as_ptr(), - default - ); - //~^^^^^ ERROR expected element type `u8` of third argument `Simd<u8, 4>` to be a signed integer type + simd_masked_load(Simd::<u8, 4>([1, 0, 1, 1]), arr.as_ptr(), default); + //~^ ERROR expected element type `u8` of third argument `Simd<u8, 4>` to be a signed integer type - simd_masked_store( - Simd([-1i8; 4]), - arr.as_ptr(), - Simd([5u32; 4]) - ); - //~^^^^^ ERROR expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd<u32, 4>`, found `u32` != `*mut u32` + simd_masked_store(Simd([-1i8; 4]), arr.as_ptr(), Simd([5u32; 4])); + //~^ ERROR expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd<u32, 4>`, found `u32` != `*mut u32` - simd_masked_store( - Simd([-1i8; 4]), - arr.as_ptr(), - Simd([5u8; 4]) - ); - //~^^^^^ ERROR expected element type `u8` of second argument `*const u8` to be a pointer to the element type `u8` of the first argument `Simd<u8, 4>`, found `u8` != `*mut u8` + simd_masked_store(Simd([-1i8; 4]), arr.as_ptr(), Simd([5u8; 4])); + //~^ ERROR expected element type `u8` of second argument `*const u8` to be a pointer to the element type `u8` of the first argument `Simd<u8, 4>`, found `u8` != `*mut u8` - simd_masked_store( - Simd([-1i8; 4]), - arr.as_mut_ptr(), - Simd([5u8; 2]) - ); - //~^^^^^ ERROR expected third argument with length 4 (same as input type `Simd<i8, 4>`), found `Simd<u8, 2>` with length 2 + simd_masked_store(Simd([-1i8; 4]), arr.as_mut_ptr(), Simd([5u8; 2])); + //~^ ERROR expected third argument with length 4 (same as input type `Simd<i8, 4>`), found `Simd<u8, 2>` with length 2 - simd_masked_store( - Simd([1u32; 4]), - arr.as_mut_ptr(), - Simd([5u8; 4]) - ); - //~^^^^^ ERROR expected element type `u8` of third argument `Simd<u32, 4>` to be a signed integer type + simd_masked_store(Simd([1u32; 4]), arr.as_mut_ptr(), Simd([5u8; 4])); + //~^ ERROR expected element type `u8` of third argument `Simd<u32, 4>` to be a signed integer type } } diff --git a/tests/ui/simd/masked-load-store-build-fail.stderr b/tests/ui/simd/masked-load-store-build-fail.stderr index 8a8d8eb99e2..d57e0aa539f 100644 --- a/tests/ui/simd/masked-load-store-build-fail.stderr +++ b/tests/ui/simd/masked-load-store-build-fail.stderr @@ -1,82 +1,50 @@ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected third argument with length 8 (same as input type `Simd<i8, 8>`), found `Simd<u8, 4>` with length 4 - --> $DIR/masked-load-store-build-fail.rs:20:9 + --> $DIR/masked-load-store-build-fail.rs:15:9 | -LL | / simd_masked_load( -LL | | Simd::<i8, 8>([-1, 0, -1, -1, 0, 0, 0, 0]), -LL | | arr.as_ptr(), -LL | | default -LL | | ); - | |_________^ +LL | simd_masked_load(Simd::<i8, 8>([-1, 0, -1, -1, 0, 0, 0, 0]), arr.as_ptr(), default); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected element type `u8` of second argument `*const i8` to be a pointer to the element type `u8` of the first argument `Simd<u8, 4>`, found `u8` != `*_ u8` - --> $DIR/masked-load-store-build-fail.rs:27:9 + --> $DIR/masked-load-store-build-fail.rs:18:9 | -LL | / simd_masked_load( -LL | | Simd::<i8, 4>([-1, 0, -1, -1]), -LL | | arr.as_ptr() as *const i8, -LL | | default -LL | | ); - | |_________^ +LL | simd_masked_load(Simd::<i8, 4>([-1, 0, -1, -1]), arr.as_ptr() as *const i8, default); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd<u32, 4>`, found `u32` != `*_ u32` - --> $DIR/masked-load-store-build-fail.rs:34:9 + --> $DIR/masked-load-store-build-fail.rs:21:9 | -LL | / simd_masked_load( -LL | | Simd::<i8, 4>([-1, 0, -1, -1]), -LL | | arr.as_ptr(), -LL | | Simd::<u32, 4>([9; 4]) -LL | | ); - | |_________^ +LL | simd_masked_load(Simd::<i8, 4>([-1, 0, -1, -1]), arr.as_ptr(), Simd::<u32, 4>([9; 4])); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected element type `u8` of third argument `Simd<u8, 4>` to be a signed integer type - --> $DIR/masked-load-store-build-fail.rs:41:9 + --> $DIR/masked-load-store-build-fail.rs:24:9 | -LL | / simd_masked_load( -LL | | Simd::<u8, 4>([1, 0, 1, 1]), -LL | | arr.as_ptr(), -LL | | default -LL | | ); - | |_________^ +LL | simd_masked_load(Simd::<u8, 4>([1, 0, 1, 1]), arr.as_ptr(), default); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd<u32, 4>`, found `u32` != `*mut u32` - --> $DIR/masked-load-store-build-fail.rs:48:9 + --> $DIR/masked-load-store-build-fail.rs:27:9 | -LL | / simd_masked_store( -LL | | Simd([-1i8; 4]), -LL | | arr.as_ptr(), -LL | | Simd([5u32; 4]) -LL | | ); - | |_________^ +LL | simd_masked_store(Simd([-1i8; 4]), arr.as_ptr(), Simd([5u32; 4])); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected element type `u8` of second argument `*const u8` to be a pointer to the element type `u8` of the first argument `Simd<u8, 4>`, found `u8` != `*mut u8` - --> $DIR/masked-load-store-build-fail.rs:55:9 + --> $DIR/masked-load-store-build-fail.rs:30:9 | -LL | / simd_masked_store( -LL | | Simd([-1i8; 4]), -LL | | arr.as_ptr(), -LL | | Simd([5u8; 4]) -LL | | ); - | |_________^ +LL | simd_masked_store(Simd([-1i8; 4]), arr.as_ptr(), Simd([5u8; 4])); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected third argument with length 4 (same as input type `Simd<i8, 4>`), found `Simd<u8, 2>` with length 2 - --> $DIR/masked-load-store-build-fail.rs:62:9 + --> $DIR/masked-load-store-build-fail.rs:33:9 | -LL | / simd_masked_store( -LL | | Simd([-1i8; 4]), -LL | | arr.as_mut_ptr(), -LL | | Simd([5u8; 2]) -LL | | ); - | |_________^ +LL | simd_masked_store(Simd([-1i8; 4]), arr.as_mut_ptr(), Simd([5u8; 2])); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected element type `u8` of third argument `Simd<u32, 4>` to be a signed integer type - --> $DIR/masked-load-store-build-fail.rs:69:9 + --> $DIR/masked-load-store-build-fail.rs:36:9 | -LL | / simd_masked_store( -LL | | Simd([1u32; 4]), -LL | | arr.as_mut_ptr(), -LL | | Simd([5u8; 4]) -LL | | ); - | |_________^ +LL | simd_masked_store(Simd([1u32; 4]), arr.as_mut_ptr(), Simd([5u8; 4])); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors diff --git a/tests/ui/simd/masked-load-store-check-fail.rs b/tests/ui/simd/masked-load-store-check-fail.rs index 0f36bf6443f..3ed47cd9ed4 100644 --- a/tests/ui/simd/masked-load-store-check-fail.rs +++ b/tests/ui/simd/masked-load-store-check-fail.rs @@ -1,11 +1,7 @@ //@ check-fail -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] -#[rustc_intrinsic] -unsafe fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_masked_store<M, P, T>(mask: M, pointer: P, values: T) -> (); +use std::intrinsics::simd::{simd_masked_load, simd_masked_store}; #[derive(Copy, Clone)] #[repr(simd)] @@ -16,18 +12,11 @@ fn main() { let mut arr = [4u8, 5, 6, 7]; let default = Simd::<u8, 4>([9; 4]); - let _x: Simd<u8, 2> = simd_masked_load( - Simd::<i8, 4>([-1, 0, -1, -1]), - arr.as_ptr(), - Simd::<u8, 4>([9; 4]) - ); - //~^^ ERROR mismatched types + let _x: Simd<u8, 2> = + simd_masked_load(Simd::<i8, 4>([-1, 0, -1, -1]), arr.as_ptr(), Simd::<u8, 4>([9; 4])); + //~^ ERROR mismatched types - let _x: Simd<u32, 4> = simd_masked_load( - Simd::<u8, 4>([1, 0, 1, 1]), - arr.as_ptr(), - default - ); - //~^^ ERROR mismatched types + let _x: Simd<u32, 4> = simd_masked_load(Simd::<u8, 4>([1, 0, 1, 1]), arr.as_ptr(), default); + //~^ ERROR mismatched types } } diff --git a/tests/ui/simd/masked-load-store-check-fail.stderr b/tests/ui/simd/masked-load-store-check-fail.stderr index fa65798fc94..1c9f9d246df 100644 --- a/tests/ui/simd/masked-load-store-check-fail.stderr +++ b/tests/ui/simd/masked-load-store-check-fail.stderr @@ -1,58 +1,38 @@ error[E0308]: mismatched types - --> $DIR/masked-load-store-check-fail.rs:22:13 + --> $DIR/masked-load-store-check-fail.rs:16:76 | -LL | let _x: Simd<u8, 2> = simd_masked_load( - | ---------------- arguments to this function are incorrect -... -LL | Simd::<u8, 4>([9; 4]) - | ^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `4` +LL | simd_masked_load(Simd::<i8, 4>([-1, 0, -1, -1]), arr.as_ptr(), Simd::<u8, 4>([9; 4])); + | ---------------- arguments to this function are incorrect ^^^^^^^^^^^^^^^^^^^^^ expected `2`, found `4` | = note: expected struct `Simd<_, 2>` found struct `Simd<_, 4>` help: the return type of this call is `Simd<u8, 4>` due to the type of the argument passed - --> $DIR/masked-load-store-check-fail.rs:19:31 + --> $DIR/masked-load-store-check-fail.rs:16:13 | -LL | let _x: Simd<u8, 2> = simd_masked_load( - | _______________________________^ -LL | | Simd::<i8, 4>([-1, 0, -1, -1]), -LL | | arr.as_ptr(), -LL | | Simd::<u8, 4>([9; 4]) - | | --------------------- this argument influences the return type of `simd_masked_load` -LL | | ); - | |_________^ +LL | simd_masked_load(Simd::<i8, 4>([-1, 0, -1, -1]), arr.as_ptr(), Simd::<u8, 4>([9; 4])); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------^ + | | + | this argument influences the return type of `simd_masked_load` note: function defined here - --> $DIR/masked-load-store-check-fail.rs:5:11 - | -LL | unsafe fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; - | ^^^^^^^^^^^^^^^^ --------- + --> $SRC_DIR/core/src/intrinsics/simd.rs:LL:COL error[E0308]: mismatched types - --> $DIR/masked-load-store-check-fail.rs:29:13 + --> $DIR/masked-load-store-check-fail.rs:19:92 | -LL | let _x: Simd<u32, 4> = simd_masked_load( - | ---------------- arguments to this function are incorrect -... -LL | default - | ^^^^^^^ expected `Simd<u32, 4>`, found `Simd<u8, 4>` +LL | let _x: Simd<u32, 4> = simd_masked_load(Simd::<u8, 4>([1, 0, 1, 1]), arr.as_ptr(), default); + | ---------------- arguments to this function are incorrect ^^^^^^^ expected `Simd<u32, 4>`, found `Simd<u8, 4>` | = note: expected struct `Simd<u32, _>` found struct `Simd<u8, _>` help: the return type of this call is `Simd<u8, 4>` due to the type of the argument passed - --> $DIR/masked-load-store-check-fail.rs:26:32 + --> $DIR/masked-load-store-check-fail.rs:19:32 | -LL | let _x: Simd<u32, 4> = simd_masked_load( - | ________________________________^ -LL | | Simd::<u8, 4>([1, 0, 1, 1]), -LL | | arr.as_ptr(), -LL | | default - | | ------- this argument influences the return type of `simd_masked_load` -LL | | ); - | |_________^ +LL | let _x: Simd<u32, 4> = simd_masked_load(Simd::<u8, 4>([1, 0, 1, 1]), arr.as_ptr(), default); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------^ + | | + | this argument influences the return type of `simd_masked_load` note: function defined here - --> $DIR/masked-load-store-check-fail.rs:5:11 - | -LL | unsafe fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; - | ^^^^^^^^^^^^^^^^ --------- + --> $SRC_DIR/core/src/intrinsics/simd.rs:LL:COL error: aborting due to 2 previous errors diff --git a/tests/ui/simd/masked-load-store.rs b/tests/ui/simd/masked-load-store.rs index 4b4195f51f1..69ea76581ee 100644 --- a/tests/ui/simd/masked-load-store.rs +++ b/tests/ui/simd/masked-load-store.rs @@ -1,11 +1,7 @@ //@ run-pass -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] -#[rustc_intrinsic] -unsafe fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; - -#[rustc_intrinsic] -unsafe fn simd_masked_store<M, P, T>(mask: M, pointer: P, values: T) -> (); +use std::intrinsics::simd::{simd_masked_load, simd_masked_store}; #[derive(Copy, Clone)] #[repr(simd)] @@ -16,11 +12,8 @@ fn main() { let a = Simd::<u8, 4>([0, 1, 2, 3]); let b_src = [4u8, 5, 6, 7]; let b_default = Simd::<u8, 4>([9; 4]); - let b: Simd::<u8, 4> = simd_masked_load( - Simd::<i8, 4>([-1, 0, -1, -1]), - b_src.as_ptr(), - b_default - ); + let b: Simd<u8, 4> = + simd_masked_load(Simd::<i8, 4>([-1, 0, -1, -1]), b_src.as_ptr(), b_default); assert_eq!(&b.0, &[4, 9, 6, 7]); diff --git a/tests/ui/simd/monomorphize-shuffle-index.generic.stderr b/tests/ui/simd/monomorphize-shuffle-index.generic.stderr index 8d4bf1e0533..b0742bc5ef8 100644 --- a/tests/ui/simd/monomorphize-shuffle-index.generic.stderr +++ b/tests/ui/simd/monomorphize-shuffle-index.generic.stderr @@ -1,5 +1,5 @@ error: overly complex generic constant - --> $DIR/monomorphize-shuffle-index.rs:32:51 + --> $DIR/monomorphize-shuffle-index.rs:36:51 | LL | return simd_shuffle_const_generic::<_, _, { &Self::I.0 }>(a, b); | ^^----------^^ diff --git a/tests/ui/simd/monomorphize-shuffle-index.rs b/tests/ui/simd/monomorphize-shuffle-index.rs index 026193e6af6..3a074dfd432 100644 --- a/tests/ui/simd/monomorphize-shuffle-index.rs +++ b/tests/ui/simd/monomorphize-shuffle-index.rs @@ -1,19 +1,23 @@ +//@ revisions: old generic generic_with_fn //@[old]run-pass //@[generic_with_fn]run-pass -//@ revisions: old generic generic_with_fn -#![feature(repr_simd, intrinsics, adt_const_params, unsized_const_params, generic_const_exprs)] +#![feature( + repr_simd, + core_intrinsics, + intrinsics, + adt_const_params, + unsized_const_params, + generic_const_exprs +)] #![allow(incomplete_features)] - -#[rustc_intrinsic] #[cfg(old)] -unsafe fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; +use std::intrinsics::simd::simd_shuffle; -#[rustc_intrinsic] #[cfg(any(generic, generic_with_fn))] +#[rustc_intrinsic] unsafe fn simd_shuffle_const_generic<T, U, const I: &'static [u32]>(a: T, b: T) -> U; - #[derive(Copy, Clone)] #[repr(simd)] struct Simd<T, const N: usize>([T; N]); diff --git a/tests/ui/simd/repr_packed.rs b/tests/ui/simd/repr_packed.rs index a666892226e..cc54477ae71 100644 --- a/tests/ui/simd/repr_packed.rs +++ b/tests/ui/simd/repr_packed.rs @@ -1,8 +1,10 @@ //@ run-pass -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(non_camel_case_types)] +use std::intrinsics::simd::simd_add; + #[repr(simd, packed)] struct Simd<T, const N: usize>([T; N]); @@ -22,9 +24,6 @@ fn check_ty<T>() { check_size_align::<T, 15>(); } -#[rustc_intrinsic] -unsafe fn simd_add<T>(a: T, b: T) -> T; - fn main() { check_ty::<u8>(); check_ty::<i16>(); diff --git a/tests/ui/simd/shuffle.rs b/tests/ui/simd/shuffle.rs index 2cae5a1e7de..cd270edcf00 100644 --- a/tests/ui/simd/shuffle.rs +++ b/tests/ui/simd/shuffle.rs @@ -2,14 +2,13 @@ //@ revisions: opt noopt //@[noopt] compile-flags: -Copt-level=0 //@[opt] compile-flags: -O -#![feature(repr_simd, intrinsics)] +#![feature(repr_simd, core_intrinsics)] #![allow(incomplete_features)] #![feature(adt_const_params)] use std::marker::ConstParamTy; -#[rustc_intrinsic] -unsafe fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; +use std::intrinsics::simd::simd_shuffle; #[derive(Copy, Clone, ConstParamTy, PartialEq, Eq)] #[repr(simd)] diff --git a/tests/ui/simd/simd-bitmask-notpow2.rs b/tests/ui/simd/simd-bitmask-notpow2.rs index d7572ef4a2a..4935097065e 100644 --- a/tests/ui/simd/simd-bitmask-notpow2.rs +++ b/tests/ui/simd/simd-bitmask-notpow2.rs @@ -2,14 +2,9 @@ // FIXME: broken codegen on big-endian (https://github.com/rust-lang/rust/issues/127205) // This should be merged into `simd-bitmask` once that's fixed. //@ ignore-endian-big -#![feature(repr_simd, intrinsics)] - -#[rustc_intrinsic] -unsafe fn simd_bitmask<T, U>(v: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_select_bitmask<T, U>(m: T, a: U, b: U) -> U; +#![feature(repr_simd, core_intrinsics)] +use std::intrinsics::simd::{simd_bitmask, simd_select_bitmask}; fn main() { // Non-power-of-2 multi-byte mask. diff --git a/tests/ui/simd/simd-bitmask.rs b/tests/ui/simd/simd-bitmask.rs index 4275ab0f40c..6fcceeaa24b 100644 --- a/tests/ui/simd/simd-bitmask.rs +++ b/tests/ui/simd/simd-bitmask.rs @@ -1,12 +1,7 @@ //@run-pass -#![feature(repr_simd, intrinsics)] - -#[rustc_intrinsic] -unsafe fn simd_bitmask<T, U>(v: T) -> U; - -#[rustc_intrinsic] -unsafe fn simd_select_bitmask<T, U>(m: T, a: U, b: U) -> U; +#![feature(repr_simd, core_intrinsics)] +use std::intrinsics::simd::{simd_bitmask, simd_select_bitmask}; #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/static/static_sized_requirement.rs b/tests/ui/static/static_sized_requirement.rs index 80f93dea054..25e1359607c 100644 --- a/tests/ui/static/static_sized_requirement.rs +++ b/tests/ui/static/static_sized_requirement.rs @@ -1,11 +1,12 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//@ add-core-stubs +//@ check-pass #![feature(no_core, lang_items)] #![no_core] #![crate_type = "lib"] -#[lang = "sized"] -trait Sized {} +extern crate minicore; +use minicore::*; extern "C" { pub static A: u32; diff --git a/tests/ui/structs/default-field-values/invalid-const.stderr b/tests/ui/structs/default-field-values/invalid-const.stderr index f4a3437031b..56d20d8d711 100644 --- a/tests/ui/structs/default-field-values/invalid-const.stderr +++ b/tests/ui/structs/default-field-values/invalid-const.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/invalid-const.rs:5:19 | LL | pub bax: u8 = panic!("asdf"), - | ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/invalid-const.rs:5:19 + | ^^^^^^^^^^^^^^ evaluation panicked: asdf | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/suggestions/abi-typo.stderr b/tests/ui/suggestions/abi-typo.stderr index 5195c43220b..4d89ac16570 100644 --- a/tests/ui/suggestions/abi-typo.stderr +++ b/tests/ui/suggestions/abi-typo.stderr @@ -2,12 +2,14 @@ error[E0703]: invalid ABI: found `cdedl` --> $DIR/abi-typo.rs:2:8 | LL | extern "cdedl" fn cdedl() {} - | ^^^^^^^ - | | - | invalid ABI - | help: did you mean: `"cdecl"` + | ^^^^^^^ invalid ABI | = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions +help: there's a similarly named valid ABI `cdecl` + | +LL - extern "cdedl" fn cdedl() {} +LL + extern "cdecl" fn cdedl() {} + | error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr b/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr index 83a5441e3c0..19a0e4b17d0 100644 --- a/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr +++ b/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr @@ -10,11 +10,16 @@ error: argument types not allowed with return type notation --> $DIR/let-binding-init-expr-as-ty.rs:2:26 | LL | let foo: i32::from_be(num); - | ^^^^^ help: remove the input types: `()` + | ^^^^^ | = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information = help: add `#![feature(return_type_notation)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +help: remove the input types + | +LL - let foo: i32::from_be(num); +LL + let foo: i32::from_be(..); + | error: return type notation not allowed in this position yet --> $DIR/let-binding-init-expr-as-ty.rs:2:14 diff --git a/tests/ui/suggestions/partialeq_suggest_swap_on_e0277.rs b/tests/ui/suggestions/partialeq_suggest_swap_on_e0277.rs new file mode 100644 index 00000000000..2ebbed3c740 --- /dev/null +++ b/tests/ui/suggestions/partialeq_suggest_swap_on_e0277.rs @@ -0,0 +1,11 @@ +struct T(String); + +impl PartialEq<String> for T { + fn eq(&self, other: &String) -> bool { + &self.0 == other + } +} + +fn main() { + String::from("Girls Band Cry") == T(String::from("Girls Band Cry")); //~ can't compare `String` with `T` [E0277] +} diff --git a/tests/ui/suggestions/partialeq_suggest_swap_on_e0277.stderr b/tests/ui/suggestions/partialeq_suggest_swap_on_e0277.stderr new file mode 100644 index 00000000000..ebe103ef19a --- /dev/null +++ b/tests/ui/suggestions/partialeq_suggest_swap_on_e0277.stderr @@ -0,0 +1,24 @@ +error[E0277]: can't compare `String` with `T` + --> $DIR/partialeq_suggest_swap_on_e0277.rs:10:36 + | +LL | String::from("Girls Band Cry") == T(String::from("Girls Band Cry")); + | ^^ no implementation for `String == T` + | + = help: the trait `PartialEq<T>` is not implemented for `String` + = help: the following other types implement trait `PartialEq<Rhs>`: + `String` implements `PartialEq<&str>` + `String` implements `PartialEq<ByteStr>` + `String` implements `PartialEq<ByteString>` + `String` implements `PartialEq<Cow<'_, str>>` + `String` implements `PartialEq<str>` + `String` implements `PartialEq` + = note: `T` implements `PartialEq<String>` +help: consider swapping the equality + | +LL - String::from("Girls Band Cry") == T(String::from("Girls Band Cry")); +LL + T(String::from("Girls Band Cry")) == String::from("Girls Band Cry"); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/target-feature/no-llvm-leaks.rs b/tests/ui/target-feature/no-llvm-leaks.rs index d4f70fe7069..50544b97a96 100644 --- a/tests/ui/target-feature/no-llvm-leaks.rs +++ b/tests/ui/target-feature/no-llvm-leaks.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ revisions: aarch64 x86-64 //@ [aarch64] compile-flags: -Ctarget-feature=+neon,+fp16,+fhm --target=aarch64-unknown-linux-gnu //@ [aarch64] needs-llvm-components: aarch64 @@ -9,12 +10,8 @@ #![feature(intrinsics, rustc_attrs, no_core, lang_items, staged_api)] #![stable(feature = "test", since = "1.0.0")] -// Supporting minimal rust core code -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -impl Copy for bool {} +extern crate minicore; +use minicore::*; #[stable(feature = "test", since = "1.0.0")] #[rustc_const_stable(feature = "test", since = "1.0.0")] diff --git a/tests/ui/target-feature/tied-features.rs b/tests/ui/target-feature/tied-features.rs index c6cdf21a3e3..9aa5291e68c 100644 --- a/tests/ui/target-feature/tied-features.rs +++ b/tests/ui/target-feature/tied-features.rs @@ -1,10 +1,11 @@ +//@ add-core-stubs //@ compile-flags: --crate-type=rlib --target=aarch64-unknown-linux-gnu //@ needs-llvm-components: aarch64 #![feature(no_core, lang_items)] #![no_core] -#[lang="sized"] -trait Sized {} +extern crate minicore; +use minicore::*; pub fn main() { #[target_feature(enable = "pacg")] diff --git a/tests/ui/target-feature/tied-features.stderr b/tests/ui/target-feature/tied-features.stderr index 8d677735e84..49df4f109ba 100644 --- a/tests/ui/target-feature/tied-features.stderr +++ b/tests/ui/target-feature/tied-features.stderr @@ -1,5 +1,5 @@ error: the target features paca, pacg must all be either enabled or disabled together - --> $DIR/tied-features.rs:10:5 + --> $DIR/tied-features.rs:11:5 | LL | #[target_feature(enable = "pacg")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[target_feature(enable = "pacg")] = help: add the missing features in a `target_feature` attribute error: the target features paca, pacg must all be either enabled or disabled together - --> $DIR/tied-features.rs:22:1 + --> $DIR/tied-features.rs:23:1 | LL | #[target_feature(enable = "paca")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | #[target_feature(enable = "paca")] = help: add the missing features in a `target_feature` attribute error: the target features paca, pacg must all be either enabled or disabled together - --> $DIR/tied-features.rs:35:1 + --> $DIR/tied-features.rs:36:1 | LL | #[target_feature(enable = "paca")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmutability/uninhabited.stderr b/tests/ui/transmutability/uninhabited.stderr index b8b7b67f781..39f8bf19c36 100644 --- a/tests/ui/transmutability/uninhabited.stderr +++ b/tests/ui/transmutability/uninhabited.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/uninhabited.rs:41:9 | LL | assert!(false); - | ^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: false', $DIR/uninhabited.rs:41:9 + | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -10,7 +10,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/uninhabited.rs:63:9 | LL | assert!(false); - | ^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: false', $DIR/uninhabited.rs:63:9 + | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -18,7 +18,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/uninhabited.rs:87:9 | LL | assert!(false); - | ^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: false', $DIR/uninhabited.rs:87:9 + | ^^^^^^^^^^^^^^ evaluation panicked: assertion failed: false | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/unsafe-binders/binder-sized-crit.rs b/tests/ui/unsafe-binders/binder-sized-crit.rs new file mode 100644 index 00000000000..37677c0ef69 --- /dev/null +++ b/tests/ui/unsafe-binders/binder-sized-crit.rs @@ -0,0 +1,18 @@ +//@ check-pass + +#![feature(unsafe_binders)] +//~^ WARN the feature `unsafe_binders` is incomplete + +use std::unsafe_binder::wrap_binder; + +struct A { + b: unsafe<> (), +} + +fn main() { + unsafe { + let _ = A { + b: wrap_binder!(()), + }; + } +} diff --git a/tests/ui/unsafe-binders/binder-sized-crit.stderr b/tests/ui/unsafe-binders/binder-sized-crit.stderr new file mode 100644 index 00000000000..3ba6cf2ef8c --- /dev/null +++ b/tests/ui/unsafe-binders/binder-sized-crit.stderr @@ -0,0 +1,11 @@ +warning: the feature `unsafe_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/binder-sized-crit.rs:3:12 + | +LL | #![feature(unsafe_binders)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #130516 <https://github.com/rust-lang/rust/issues/130516> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs index 997bee1e600..89e4b77b6cd 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.rs @@ -3,6 +3,7 @@ trait Foo<const N: Bar<2>> { //~^ WARN trait objects without an explicit `dyn` are deprecated //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| ERROR cycle detected when computing type of `Foo::N` + //~| ERROR cycle detected when computing type of `Foo::N` fn func() {} } diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr index 733b729faf0..a381f2acdce 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr @@ -13,7 +13,7 @@ LL | trait Foo<const N: dyn Bar<2>> { | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:9:20 + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:10:20 | LL | trait Bar<const M: Foo<2>> {} | ^^^^^^ @@ -32,7 +32,7 @@ LL | trait Foo<const N: Bar<2>> { | ^^^^^^^^^^^^^^^ | note: ...which requires computing type of `Bar::M`... - --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:9:11 + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:10:11 | LL | trait Bar<const M: Foo<2>> {} | ^^^^^^^^^^^^^^^ @@ -44,6 +44,26 @@ LL | trait Foo<const N: Bar<2>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error: aborting due to 1 previous error; 2 warnings emitted +error[E0391]: cycle detected when computing type of `Foo::N` + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:11 + | +LL | trait Foo<const N: Bar<2>> { + | ^^^^^^^^^^^^^^^ + | +note: ...which requires computing type of `Bar::M`... + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:10:11 + | +LL | trait Bar<const M: Foo<2>> {} + | ^^^^^^^^^^^^^^^ + = note: ...which again requires computing type of `Foo::N`, completing the cycle +note: cycle used when computing explicit predicates of trait `Foo` + --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:1 + | +LL | trait Foo<const N: Bar<2>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors; 2 warnings emitted For more information about this error, try `rustc --explain E0391`. |
