From c86a7ef793b2186e15a74ab37b642f8859fec0f3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 28 Feb 2025 17:15:17 +0100 Subject: [PATCH 01/11] Fully qualify `Result` in generated doctest code --- src/librustdoc/doctest/make.rs | 2 +- src/librustdoc/doctest/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/doctest/make.rs b/src/librustdoc/doctest/make.rs index 4792bc525a592..9935074877bc8 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 fa6cca3681be5..e2b964bf5af57 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)?; From aac65f562b3e9351d4a4336c270ce13c130de467 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 28 Feb 2025 16:29:07 +0100 Subject: [PATCH 02/11] =?UTF-8?q?rename=20BackendRepr::Vector=20=E2=86=92?= =?UTF-8?q?=20SimdVector?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compiler/rustc_abi/src/callconv.rs | 2 +- compiler/rustc_abi/src/layout.rs | 12 ++++-- compiler/rustc_abi/src/layout/ty.rs | 2 +- compiler/rustc_abi/src/lib.rs | 28 ++++++------- .../src/abi/pass_mode.rs | 4 +- .../src/intrinsics/mod.rs | 2 +- .../src/value_and_place.rs | 8 ++-- .../rustc_codegen_gcc/src/intrinsic/mod.rs | 2 +- compiler/rustc_codegen_gcc/src/type_of.rs | 10 ++--- compiler/rustc_codegen_llvm/src/asm.rs | 39 ++++++++++--------- compiler/rustc_codegen_llvm/src/intrinsic.rs | 2 +- compiler/rustc_codegen_llvm/src/type_of.rs | 10 ++--- .../rustc_codegen_ssa/src/mir/naked_asm.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/operand.rs | 6 +-- compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 2 +- .../src/interpret/validity.rs | 2 +- .../src/util/check_validity_requirement.rs | 2 +- compiler/rustc_mir_transform/src/gvn.rs | 2 +- .../src/mono_checks/abi_check.rs | 2 +- .../rustc_smir/src/rustc_smir/convert/abi.rs | 2 +- .../rustc_target/src/callconv/loongarch.rs | 4 +- compiler/rustc_target/src/callconv/mod.rs | 6 +-- compiler/rustc_target/src/callconv/riscv.rs | 4 +- compiler/rustc_target/src/callconv/s390x.rs | 4 +- compiler/rustc_target/src/callconv/x86.rs | 2 +- compiler/rustc_target/src/callconv/x86_64.rs | 2 +- .../rustc_target/src/callconv/x86_win64.rs | 2 +- compiler/rustc_target/src/callconv/xtensa.rs | 2 +- compiler/rustc_ty_utils/src/abi.rs | 2 +- compiler/rustc_ty_utils/src/layout.rs | 2 +- .../rustc_ty_utils/src/layout/invariant.rs | 2 +- .../rust-analyzer/crates/hir-ty/src/layout.rs | 2 +- 32 files changed, 92 insertions(+), 83 deletions(-) diff --git a/compiler/rustc_abi/src/callconv.rs b/compiler/rustc_abi/src/callconv.rs index 4529ab8058e9a..a21e1aee9b08a 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 3f83787ea3765..d3ae6a29f10f4 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -386,13 +386,15 @@ impl LayoutCalculator { 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 LayoutCalculator { 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 LayoutCalculator { 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 221e990ae863b..03f3f043c218e 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 81e4e255f3799..2197dd68eaf69 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 LayoutData { /// 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 LayoutData { /// 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_codegen_cranelift/src/abi/pass_mode.rs b/compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs index b28c4c9539cef..06d89bc9ea7d7 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 4d9bed8652cbd..6735ae024d1c5 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 1b3f86c8405de..cc739fefcd066 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/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index f8672c0729998..f38622074f18b 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/type_of.rs b/compiler/rustc_codegen_gcc/src/type_of.rs index bac4fc51300a2..ae98b3d0b56e2 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 be5673eddf93e..e8a697431571f 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/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 1169b9c067d73..0272667e22399 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/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index ba01fbff38539..4e7096da502d0 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/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs index 0593fb420c306..96d1ab018f60d 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 461cf1b8acdaf..4b33bdeadba4d 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 d24e48b37a46f..67555d4033207 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_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 40dec0cb39e7b..eb3f552cd2787 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 6426bca2332d4..d7e97f32bae92 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_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 29521d4272010..981dedd5b5c7e 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 4c8dd933317ef..9f26da7d5c64b 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_smir/src/rustc_smir/convert/abi.rs b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs index a627e0e69b62f..62cbab9b723cc 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_target/src/callconv/loongarch.rs b/compiler/rustc_target/src/callconv/loongarch.rs index 3fa67c624a7be..209d7483e612a 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(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 1c044fe98b3ef..198d08864bec3 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 785175229b031..7368e225efa74 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(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 4f69e32b2e3df..1ba792c5acc5a 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(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 7e5aab0201b6d..73aff85a0ad88 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 ab306e202396b..300b19f62e722 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 4d99a9f9ba064..8f8597ea662a8 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(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 6c030cb3bf770..b687f0e20c660 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_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 74ab65b4f58b7..e317768ff602c 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 2ab6b8e17c4cc..1a82d17130755 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 c695e2887fd6f..7423a156a217a 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/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index e2ab336d2e466..a4e49e0aa10ab 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, From cdef38812dd4de2a3fa3b3512b64c28c278ff7cc Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Fri, 28 Feb 2025 17:50:38 +0100 Subject: [PATCH 03/11] Use correct error message casing for `io::const_error`s Error messages are supposed to start with lowercase letters, but a lot of `io::const_error` messages did not. This fixes them to start with a lowercase letter. I did consider adding a const check for this to the macro, but some of them start with proper nouns that make sense to uppercase them. See https://doc.rust-lang.org/1.85.0/std/error/trait.Error.html --- library/std/src/io/error.rs | 2 +- library/std/src/os/windows/io/socket.rs | 2 +- .../sys/net/connection/xous/tcplistener.rs | 20 +++++----- .../src/sys/net/connection/xous/tcpstream.rs | 38 +++++++++---------- .../std/src/sys/net/connection/xous/udp.rs | 34 ++++++++--------- library/std/src/sys/pal/hermit/thread.rs | 2 +- library/std/src/sys/pal/uefi/helpers.rs | 10 ++--- library/std/src/sys/pal/uefi/os.rs | 12 +++--- library/std/src/sys/pal/uefi/process.rs | 2 +- library/std/src/sys/pal/uefi/stdio.rs | 2 +- library/std/src/sys/pal/unix/os.rs | 4 +- .../sys/pal/unix/process/process_fuchsia.rs | 4 +- .../src/sys/pal/unix/process/process_unix.rs | 2 +- library/std/src/sys/pal/unix/thread.rs | 4 +- library/std/src/sys/pal/unix/time.rs | 2 +- library/std/src/sys/pal/windows/fs.rs | 4 +- library/test/src/formatters/junit.rs | 6 +-- 17 files changed, 75 insertions(+), 75 deletions(-) diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index 30bc0e3b08833..5aa048c4cbc85 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 2bc6ce222ae5c..1c228914de93f 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 851d2eb8178d4..7f13ca5592040 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 7f7bbfb7fed34..283b1fe9a33b9 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 ab5bd357b6123..f35970bc32152 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 { 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 4a7afddbec107..bb68a824fc313 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 ec2da4e4ee7a4..cb6aacd0063d4 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) -> 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(protocol_guid: Guid) -> io::Result> { 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) -> 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 = boot_services.cast(); @@ -213,7 +213,7 @@ pub(crate) fn device_path_to_text(path: NonNull) -> 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 = @@ -490,7 +490,7 @@ pub(crate) fn get_device_path_from_map(map: &Path) -> io::Result io::Result { 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 c73a6350357a4..a47c8dbcaaafc 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 d049d19bc83ee..257e321dd03d7 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 78404b4afa790..3a238d160cb57 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 { ); 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 { #[cfg(target_os = "l4re")] pub fn current_exe() -> io::Result { 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 b7a35718757ae..4ddc96356b996 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 aa7406dd54874..1f3abd4cc1286 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 { diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 4c5757b890ada..3dedc8d1257cb 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> { 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> { } } 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 e224980e95f31..0271626380c5f 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 dce5a429cb0d4..623a7d89ba5a0 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/test/src/formatters/junit.rs b/library/test/src/formatters/junit.rs index 36158b0258a6f..84153a9d05b59 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 OutputFormatter for JunitFormatter { 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( From 2d3639d55915748aeef28cab982492581d2a0bfc Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Fri, 28 Feb 2025 14:27:22 -0500 Subject: [PATCH 04/11] tests: adapt for LLVM 21 changes Per discussion in #137799 we don't really need this readonly attribute, so let's just drop it so the test passes on LLVM 21. Fixes #137799. --- tests/codegen/issues/issue-114312.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/codegen/issues/issue-114312.rs b/tests/codegen/issues/issue-114312.rs index e9418249089dd..61355dd5873ca 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 From a9ca11320a36e9c729b7d4a15959701c72f2f961 Mon Sep 17 00:00:00 2001 From: Boxy Date: Fri, 28 Feb 2025 20:27:19 +0000 Subject: [PATCH 05/11] Update query normalizer docs --- .../src/traits/query/normalize.rs | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index 2ef9d5421ba6c..6bf76eaee5c64 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(self, value: T) -> Result, NoSolution> where T: TypeFoldable>, @@ -210,8 +209,6 @@ impl<'a, 'tcx> FallibleTypeFolder> 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. From adb5ecabdb09ff6f329bbf9b7721036db983f546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 28 Feb 2025 20:05:43 +0000 Subject: [PATCH 06/11] Tweak invalid RTN errors Make suggestions verbose. When encountering `method(type)` bound, suggest `method(..)` instead of `method()`. ``` error: argument types not allowed with return type notation --> $DIR/bad-inputs-and-output.rs:9:23 | LL | fn foo>() {} | ^^^^^ | help: remove the input types | LL - fn foo>() {} LL + fn foo>() {} | ``` When encountering both return type and arg list that isn't `..`, suggest replacing both. ``` error: return type not allowed with return type notation --> $DIR/bad-inputs-and-output.rs:12:25 | LL | fn bar (): Send>>() {} | ^^^^^^ | help: use the right argument notation and remove the return type | LL - fn bar (): Send>>() {} LL + fn bar>() {} | ``` When encountering a return type, suggest removing it including the leading whitespace. ``` error: return type not allowed with return type notation --> $DIR/bad-inputs-and-output.rs:24:45 | LL | fn bay_path() where T::method(..) -> (): Send {} | ^^^^^ | help: remove the return type | LL - fn bay_path() where T::method(..) -> (): Send {} LL + fn bay_path() where T::method(..): Send {} | ``` --- compiler/rustc_ast_lowering/messages.ftl | 4 +- compiler/rustc_ast_lowering/src/errors.rs | 21 +++++- compiler/rustc_ast_lowering/src/lib.rs | 32 +++++---- compiler/rustc_ast_lowering/src/path.rs | 34 ++++++---- compiler/rustc_parse/src/errors.rs | 3 +- compiler/rustc_parse/src/parser/path.rs | 5 +- .../bad-inputs-and-output.rs | 3 + .../bad-inputs-and-output.stderr | 68 ++++++++++++++++--- .../let-binding-init-expr-as-ty.stderr | 7 +- 9 files changed, 133 insertions(+), 44 deletions(-) diff --git a/compiler/rustc_ast_lowering/messages.ftl b/compiler/rustc_ast_lowering/messages.ftl index 1b91c33742d8b..5f1726f7f0aa8 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 diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index f31e2db051d81..d402c5abc194e 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -372,24 +372,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 Ret>` or `T: Tr Ret>`, suggest `T: Tr`. +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/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 1c69937eed07a..13edcc10c9e2a 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 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 55d0647731324..6b6244b05aa9b 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 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_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 173c68b3a7224..5bf1a11954ed3 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 c24305ea9a866..7698df3b5546c 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -378,11 +378,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/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 f00aaec1a8c2c..90fd2c2b4f326 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() where T::method(i32): Send {} fn bar_path() where T::method() -> (): Send {} //~^ ERROR return type not allowed with return type notation +fn bay_path() where T::method(..) -> (): Send {} +//~^ ERROR return type not allowed with return type notation + fn baz_path() 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 c6b9f3eff90ec..bd02b7d6534a9 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() where T::method(..) -> (): Send {} + | ^^^^^ + | +help: remove the return type + | +LL - fn bay_path() where T::method(..) -> (): Send {} +LL + fn bay_path() 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() where ::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() where ::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() where ::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>() {} - | ^^^^^ help: remove the input types: `()` + | ^^^^^ + | +help: remove the input types + | +LL - fn foo>() {} +LL + fn foo>() {} + | error: return type not allowed with return type notation --> $DIR/bad-inputs-and-output.rs:12:25 | LL | fn bar (): Send>>() {} - | ^^^^^^ help: remove the return type + | ^^^^^^ + | +help: use the right argument notation and remove the return type + | +LL - fn bar (): Send>>() {} +LL + fn bar>() {} + | error: return type notation arguments must be elided with `..` --> $DIR/bad-inputs-and-output.rs:15:23 | LL | fn baz>() {} - | ^^ help: add `..`: `(..)` + | ^^ + | +help: use the correct syntax by adding `..` to the arguments + | +LL | fn baz>() {} + | ++ error: argument types not allowed with return type notation --> $DIR/bad-inputs-and-output.rs:18:40 | LL | fn foo_path() where T::method(i32): Send {} - | ^^^^^ help: remove the input types: `()` + | ^^^^^ + | +help: remove the input types + | +LL - fn foo_path() where T::method(i32): Send {} +LL + fn foo_path() 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() where T::method() -> (): Send {} - | ^^^^^^ help: remove the return type + | ^^^^^^ + | +help: use the right argument notation and remove the return type + | +LL - fn bar_path() where T::method() -> (): Send {} +LL + fn bar_path() 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() where T::method(): Send {} - | ^^ help: add `..`: `(..)` + | ^^ + | +help: use the correct syntax by adding `..` to the arguments + | +LL | fn baz_path() 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/suggestions/let-binding-init-expr-as-ty.stderr b/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr index 83a5441e3c0c6..19a0e4b17d029 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 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 From 4c1f51bf6ecc68fb6eb4b90ea6b0d0b027146aee Mon Sep 17 00:00:00 2001 From: Luigi Sartor Piucco Date: Fri, 28 Feb 2025 14:24:16 -0300 Subject: [PATCH 07/11] Fix link failure on AVR (incompatible ISA error) Fixes #137739. A reproducer of the issue is present there. I believe the root cause was introducing the avr-none target (which has no CPU by default) and trying to get the ISA revision from there. This commit uses the `target-cpu` option instead, which is already required to be present for the target. Co-authored-by: tones111 --- compiler/rustc_codegen_ssa/src/back/metadata.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index 236507ac0cd28..3aacbcde1a783 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 { // 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() { From 45492662c7671e477492eba7c919bc99f7031132 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Mon, 24 Feb 2025 21:56:26 +0100 Subject: [PATCH 08/11] correct the docs on `simd_` comparison operators these all also accept integer vectors as arguments --- library/core/src/intrinsics/simd.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs index 3bde183fefb71..3aec66e9961e5 100644 --- a/library/core/src/intrinsics/simd.rs +++ b/library/core/src/intrinsics/simd.rs @@ -26,28 +26,28 @@ pub unsafe fn simd_extract(_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(_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(_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(_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(_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. @@ -116,8 +116,7 @@ pub unsafe fn simd_xor(_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(_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. @@ -187,7 +185,7 @@ pub unsafe fn simd_fmax(_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 integer or floating-point primitive types. /// /// `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(_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 integer or floating-point primitive types. /// /// `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(_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 integer or floating-point primitive types. /// /// `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(_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 integer or floating-point primitive types. /// /// `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(_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 integer or floating-point primitive types. /// /// `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(_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 integer or floating-point primitive types. /// /// `U` must be a vector of integers with the same number of elements and element size as `T`. /// From 854e9f48033e2cfe8615ed3b24ceccb137addd46 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Fri, 28 Feb 2025 22:46:54 +0100 Subject: [PATCH 09/11] intrinsics::simd: document that masks must be signed integer vectors this is because they may be widened, and that only works when sign extension is used: zero extension would produce invalid results --- library/core/src/intrinsics/simd.rs | 54 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs index 3aec66e9961e5..cceb6b0917afa 100644 --- a/library/core/src/intrinsics/simd.rs +++ b/library/core/src/intrinsics/simd.rs @@ -71,7 +71,7 @@ pub unsafe fn simd_rem(_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(_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,21 +95,21 @@ pub unsafe fn simd_shr(_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(_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(_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(_x: T, _y: T) -> T; @@ -151,7 +151,7 @@ pub unsafe fn simd_as(_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 `-::Min` due to overflow, but it is not UB with this intrinsic. #[rustc_intrinsic] @@ -185,7 +185,7 @@ pub unsafe fn simd_fmax(_x: T, _y: T) -> T; /// Tests elementwise equality of two vectors. /// -/// `T` must be a vector of integer or 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`. /// @@ -196,7 +196,7 @@ pub unsafe fn simd_eq(_x: T, _y: T) -> U; /// Tests elementwise inequality equality of two vectors. /// -/// `T` must be a vector of integer or 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`. /// @@ -207,7 +207,7 @@ pub unsafe fn simd_ne(_x: T, _y: T) -> U; /// Tests if `x` is less than `y`, elementwise. /// -/// `T` must be a vector of integer or 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`. /// @@ -218,7 +218,7 @@ pub unsafe fn simd_lt(_x: T, _y: T) -> U; /// Tests if `x` is less than or equal to `y`, elementwise. /// -/// `T` must be a vector of integer or 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`. /// @@ -229,7 +229,7 @@ pub unsafe fn simd_le(_x: T, _y: T) -> U; /// Tests if `x` is greater than `y`, elementwise. /// -/// `T` must be a vector of integer or 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`. /// @@ -240,7 +240,7 @@ pub unsafe fn simd_gt(_x: T, _y: T) -> U; /// Tests if `x` is greater than or equal to `y`, elementwise. /// -/// `T` must be a vector of integer or 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`. /// @@ -271,7 +271,7 @@ pub unsafe fn simd_shuffle(_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 @@ -292,7 +292,7 @@ pub unsafe fn simd_gather(_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. @@ -316,7 +316,7 @@ pub unsafe fn simd_scatter(_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`. @@ -339,7 +339,7 @@ pub unsafe fn simd_masked_load(_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`. @@ -373,7 +373,7 @@ pub unsafe fn simd_saturating_sub(_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`. /// @@ -385,7 +385,7 @@ pub unsafe fn simd_reduce_add_ordered(_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] @@ -394,7 +394,7 @@ pub unsafe fn simd_reduce_add_unordered(_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`. /// @@ -406,7 +406,7 @@ pub unsafe fn simd_reduce_mul_ordered(_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] @@ -435,7 +435,7 @@ pub unsafe fn simd_reduce_any(_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`. /// @@ -446,7 +446,7 @@ pub unsafe fn simd_reduce_max(_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`. /// @@ -457,7 +457,7 @@ pub unsafe fn simd_reduce_min(_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] @@ -466,7 +466,7 @@ pub unsafe fn simd_reduce_and(_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] @@ -475,7 +475,7 @@ pub unsafe fn simd_reduce_or(_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] @@ -521,9 +521,9 @@ pub unsafe fn simd_bitmask(_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 From 340a24910fe3a7e5949eec766801c053dbd05de0 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Sat, 1 Mar 2025 12:53:11 +0800 Subject: [PATCH 10/11] triagebot: only ping me for constck Per the [Zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/rustbot.20pings). --- triagebot.toml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/triagebot.toml b/triagebot.toml index f9eb09ff34381..7702d4133acac 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -706,7 +706,11 @@ cc = ["@antoyo", "@GuillaumeGomez"] [mentions."compiler/rustc_const_eval/src/"] message = "Some changes occurred to the CTFE machinery" -cc = ["@rust-lang/wg-const-eval"] +cc = ["@RalfJung", "@oli-obk", "@lcnr"] + +[mentions."compiler/rustc_const_eval/src/check_consts"] +message = "Some changes occurred to constck" +cc = ["@fee1-dead"] [mentions."compiler/rustc_const_eval/src/interpret"] message = "Some changes occurred to the CTFE / Miri interpreter" @@ -730,7 +734,7 @@ cc = ["@compiler-errors", "@lcnr"] [mentions."compiler/rustc_middle/src/mir/interpret"] message = "Some changes occurred to the CTFE / Miri interpreter" -cc = ["@rust-lang/miri", "@rust-lang/wg-const-eval"] +cc = ["@rust-lang/miri", "@RalfJung", "@oli-obk", "@lcnr"] [mentions."compiler/rustc_mir_transform/src/"] message = "Some changes occurred to MIR optimizations" @@ -803,7 +807,7 @@ message = """ Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter gets adapted for the changes, if necessary. """ -cc = ["@rust-lang/miri", "@rust-lang/wg-const-eval"] +cc = ["@rust-lang/miri", "@RalfJung", "@oli-obk", "@lcnr"] [mentions."library/portable-simd"] message = """ From 2f4b9ddf897a6d8a492a9b01ef84cd43b1f62ca1 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Sat, 1 Mar 2025 12:23:33 +0800 Subject: [PATCH 11/11] Update `const_conditions` and `explicit_implied_const_bounds` docs Move documentation to query definitions, and add docs to `explicit_implied_const_bounds`. --- .../src/collect/predicates_of.rs | 10 +++------- compiler/rustc_middle/src/query/mod.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 5b511d270743b..44e172a7b7085 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -940,12 +940,6 @@ impl<'tcx> ItemCtxt<'tcx> { } } -/// Compute the conditions that need to hold for a conditionally-const item to be const. -/// That is, compute the set of `~const` where clauses for a given item. -/// -/// This query also computes the `~const` where clauses for associated types, which are -/// not "const", but which have item bounds which may be `~const`. These must hold for -/// the `~const` item bound to hold. pub(super) fn const_conditions<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, @@ -1063,7 +1057,9 @@ pub(super) fn explicit_implied_const_bounds<'tcx>( def_id: LocalDefId, ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::PolyTraitRef<'tcx>, Span)]> { if !tcx.is_conditionally_const(def_id) { - bug!("const_conditions invoked for item that is not conditionally const: {def_id:?}"); + bug!( + "explicit_implied_const_bounds invoked for item that is not conditionally const: {def_id:?}" + ); } let bounds = match tcx.opt_rpitit_info(def_id.to_def_id()) { diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 46a960d9945e4..1302027aabb36 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -748,6 +748,15 @@ rustc_queries! { } } + /// Compute the conditions that need to hold for a conditionally-const item to be const. + /// That is, compute the set of `~const` where clauses for a given item. + /// + /// This can be thought of as the `~const` equivalent of `predicates_of`. These are the + /// predicates that need to be proven at usage sites, and can be assumed at definition. + /// + /// This query also computes the `~const` where clauses for associated types, which are + /// not "const", but which have item bounds which may be `~const`. These must hold for + /// the `~const` item bound to hold. query const_conditions( key: DefId ) -> ty::ConstConditions<'tcx> { @@ -757,6 +766,11 @@ rustc_queries! { separate_provide_extern } + /// Compute the const bounds that are implied for a conditionally-const item. + /// + /// This can be though of as the `~const` equivalent of `explicit_item_bounds`. These + /// are the predicates that need to proven at definition sites, and can be assumed at + /// usage sites. query explicit_implied_const_bounds( key: DefId ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::PolyTraitRef<'tcx>, Span)]> {