diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/CHANGELOG.md b/CHANGELOG.md index 79c9ee5a17..57d691e307 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [PR#1127](https://github.com/EmbarkStudios/rust-gpu/pull/1127) updated `spirv-tools` to `0.10.0`, which follows `vulkan-sdk-1.3.275` - [PR#1101](https://github.com/EmbarkStudios/rust-gpu/pull/1101) added `ignore` and `no_run` to documentation to make `cargo test` pass - [PR#1112](https://github.com/EmbarkStudios/rust-gpu/pull/1112) updated wgpu and winit in example runners +- [PR#1134](https://github.com/EmbarkStudios/rust-gpu/pull/1134) updated toolchain to `nightly-2023-12-21` - [PR#1100](https://github.com/EmbarkStudios/rust-gpu/pull/1100) updated toolchain to `nightly-2023-09-30` - [PR#1091](https://github.com/EmbarkStudios/rust-gpu/pull/1091) updated toolchain to `nightly-2023-08-29` - [PR#1085](https://github.com/EmbarkStudios/rust-gpu/pull/1085) updated toolchain to `nightly-2023-07-08` diff --git a/Cargo.lock b/Cargo.lock index 252d22e370..2eff7a0d97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,17 +18,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" -[[package]] -name = "ahash" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.7" @@ -1157,15 +1146,6 @@ dependencies = [ "bitflags 2.4.2", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash 0.7.7", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -1178,7 +1158,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.7", + "ahash", "allocator-api2", ] @@ -2139,7 +2119,6 @@ version = "0.9.0" dependencies = [ "ar", "either", - "hashbrown 0.11.2", "indexmap 1.9.3", "itertools", "lazy_static", @@ -2160,6 +2139,7 @@ dependencies = [ "spirv-tools", "syn 1.0.109", "tempfile", + "termcolor", ] [[package]] @@ -3428,7 +3408,7 @@ version = "0.29.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c824f11941eeae66ec71111cc2674373c772f482b58939bb4066b642aa2ffcf" dependencies = [ - "ahash 0.8.7", + "ahash", "android-activity", "atomic-waker", "bitflags 2.4.2", diff --git a/crates/rustc_codegen_spirv/Cargo.toml b/crates/rustc_codegen_spirv/Cargo.toml index 13f7b3ea34..872d4372e7 100644 --- a/crates/rustc_codegen_spirv/Cargo.toml +++ b/crates/rustc_codegen_spirv/Cargo.toml @@ -40,13 +40,13 @@ syn = { version = "1", features = ["extra-traits", "full"] } [dependencies] # HACK(eddyb) these only exist to unify features across dependency trees, # in order to avoid multiple separate instances of `rustc_codegen_spirv`. -hashbrown = "0.11" libc = { version = "0.2", features = ["align", "extra_traits"] } num-traits = { version = "0.2", features = ["libm"] } once_cell = "1" regex = { version = "1", features = ["perf"] } # Normal dependencies. +termcolor = "1.2" ar = "0.9.0" either = "1.8.0" indexmap = "1.6.0" diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 6421463ba5..c99006829f 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2023-09-30" +channel = "nightly-2024-03-14" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72"#; +# commit_hash = 3cbb93223f33024db464a4df27a13c7cce870173"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index fbe20ed462..95fd908a80 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -12,7 +12,7 @@ use rustc_middle::query::Providers; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout}; use rustc_middle::ty::GenericArgsRef; use rustc_middle::ty::{ - self, Const, FloatTy, GeneratorArgs, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind, + self, Const, CoroutineArgs, FloatTy, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind, TypeAndMut, UintTy, }; use rustc_middle::{bug, span_bug}; @@ -64,6 +64,9 @@ pub(crate) fn provide(providers: &mut Providers) { ) -> &'tcx FnAbi<'tcx, Ty<'tcx>> { let readjust_arg_abi = |arg: &ArgAbi<'tcx, Ty<'tcx>>| { let mut arg = ArgAbi::new(&tcx, arg.layout, |_, _, _| ArgAttributes::new()); + // FIXME: this is bad! https://github.com/rust-lang/rust/issues/115666 + // + arg.make_direct_deprecated(); // Avoid pointlessly passing ZSTs, just like the official Rust ABI. if arg.layout.is_zst() { @@ -96,7 +99,9 @@ pub(crate) fn provide(providers: &mut Providers) { // FIXME(eddyb) remove this by deriving `Clone` for `LayoutS` upstream. // FIXME(eddyb) the `S` suffix is a naming antipattern, rename upstream. - fn clone_layout(layout: &LayoutS) -> LayoutS { + fn clone_layout( + layout: &LayoutS, + ) -> LayoutS { let LayoutS { ref fields, ref variants, @@ -500,8 +505,10 @@ fn trans_scalar<'tcx>( Primitive::Int(width, signedness) => { SpirvType::Integer(width.size().bits() as u32, signedness).def(span, cx) } + Primitive::F16 => SpirvType::Float(16).def(span, cx), Primitive::F32 => SpirvType::Float(32).def(span, cx), Primitive::F64 => SpirvType::Float(64).def(span, cx), + Primitive::F128 => SpirvType::Float(128).def(span, cx), Primitive::Pointer(_) => { let pointee_ty = dig_scalar_pointee(cx, ty, offset); // Pointers can be recursive. So, record what we're currently translating, and if we're already translating @@ -575,7 +582,7 @@ fn dig_scalar_pointee<'tcx>( let new_pointee = dig_scalar_pointee(cx, field, offset - field_offset); match pointee { Some(old_pointee) if old_pointee != new_pointee => { - cx.tcx.sess.fatal(format!( + cx.tcx.sess.psess.dcx.fatal(format!( "dig_scalar_pointee: unsupported Pointer with different \ pointee types ({old_pointee:?} vs {new_pointee:?}) at offset {offset:?} in {layout:#?}" )); @@ -723,7 +730,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) - if i == 0 { field_names.push(cx.sym.discriminant); } else { - cx.tcx.sess.fatal("Variants::Multiple has multiple fields") + cx.tcx.sess.psess.dcx.fatal("Variants::Multiple has multiple fields") } }; } @@ -744,7 +751,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) - fn def_id_for_spirv_type_adt(layout: TyAndLayout<'_>) -> Option { match *layout.ty.kind() { TyKind::Adt(def, _) => Some(def.did()), - TyKind::Foreign(def_id) | TyKind::Closure(def_id, _) | TyKind::Generator(def_id, ..) => { + TyKind::Foreign(def_id) | TyKind::Closure(def_id, _) | TyKind::Coroutine(def_id, ..) => { Some(def_id) } _ => None, @@ -779,8 +786,8 @@ impl fmt::Display for TyLayoutNameKey<'_> { write!(f, "::{}", def.variants()[index].name)?; } } - if let (TyKind::Generator(_, _, _), Some(index)) = (self.ty.kind(), self.variant) { - write!(f, "::{}", GeneratorArgs::variant_name(index))?; + if let (TyKind::Coroutine(_, _,), Some(index)) = (self.ty.kind(), self.variant) { + write!(f, "::{}", CoroutineArgs::variant_name(index))?; } Ok(()) } @@ -800,6 +807,7 @@ fn trans_intrinsic_type<'tcx>( return Err(cx .tcx .sess + .psess.dcx .err("#[spirv(generic_image)] type must have size 4")); } @@ -843,7 +851,7 @@ fn trans_intrinsic_type<'tcx>( _ => { return Err(cx .tcx - .sess + .sess.psess.dcx .span_err(span, "Invalid sampled type to `Image`.")); } }; @@ -866,7 +874,7 @@ fn trans_intrinsic_type<'tcx>( Some(v) => Ok(v), None => Err(cx .tcx - .sess + .sess.psess.dcx .err(format!("Invalid value for Image const generic: {value}"))), } } @@ -892,7 +900,7 @@ fn trans_intrinsic_type<'tcx>( IntrinsicType::Sampler => { // see SpirvType::sizeof if ty.size != Size::from_bytes(4) { - return Err(cx.tcx.sess.err("#[spirv(sampler)] type must have size 4")); + return Err(cx.tcx.sess.psess.dcx.err("#[spirv(sampler)] type must have size 4")); } Ok(SpirvType::Sampler.def(span, cx)) } @@ -905,7 +913,7 @@ fn trans_intrinsic_type<'tcx>( if ty.size != Size::from_bytes(4) { return Err(cx .tcx - .sess + .sess.psess.dcx .err("#[spirv(sampled_image)] type must have size 4")); } @@ -918,7 +926,7 @@ fn trans_intrinsic_type<'tcx>( } else { Err(cx .tcx - .sess + .sess.psess.dcx .err("#[spirv(sampled_image)] type must have a generic image type")) } } @@ -926,7 +934,7 @@ fn trans_intrinsic_type<'tcx>( if ty.size != Size::from_bytes(4) { return Err(cx .tcx - .sess + .sess.psess.dcx .err("#[spirv(runtime_array)] type must have size 4")); } @@ -938,7 +946,7 @@ fn trans_intrinsic_type<'tcx>( } else { Err(cx .tcx - .sess + .sess.psess.dcx .err("#[spirv(runtime_array)] type must have a generic element type")) } } @@ -953,12 +961,12 @@ fn trans_intrinsic_type<'tcx>( if field_types.len() < 2 { return Err(cx .tcx - .sess + .sess.psess.dcx .span_err(span, "#[spirv(matrix)] type must have at least two fields")); } let elem_type = field_types[0]; if !field_types.iter().all(|&ty| ty == elem_type) { - return Err(cx.tcx.sess.span_err( + return Err(cx.tcx.sess.psess.dcx.span_err( span, "#[spirv(matrix)] type fields must all be the same type", )); @@ -968,10 +976,8 @@ fn trans_intrinsic_type<'tcx>( ty => { return Err(cx .tcx - .sess - .struct_span_err(span, "#[spirv(matrix)] type fields must all be vectors") - .note(format!("field type is {}", ty.debug(elem_type, cx))) - .emit()); + .sess.psess.dcx + .span_err(span, format!("#[spirv(matrix)] type fields must all be vectors, found {}", ty.debug(elem_type, cx)))); } } diff --git a/crates/rustc_codegen_spirv/src/attr.rs b/crates/rustc_codegen_spirv/src/attr.rs index b796e86db6..bae5359cd4 100644 --- a/crates/rustc_codegen_spirv/src/attr.rs +++ b/crates/rustc_codegen_spirv/src/attr.rs @@ -148,13 +148,13 @@ impl AggregatedSpirvAttributes { pub fn parse<'tcx>(cx: &CodegenCx<'tcx>, attrs: &'tcx [Attribute]) -> Self { let mut aggregated_attrs = Self::default(); - // NOTE(eddyb) `delay_span_bug` ensures that if attribute checking fails + // NOTE(eddyb) `span_delayed_bug` ensures that if attribute checking fails // to see an attribute error, it will cause an ICE instead. for parse_attr_result in crate::symbols::parse_attrs_for_checking(&cx.sym, attrs) { let (span, parsed_attr) = match parse_attr_result { Ok(span_and_parsed_attr) => span_and_parsed_attr, Err((span, msg)) => { - cx.tcx.sess.delay_span_bug(span, msg); + cx.tcx.sess.psess.dcx.span_delayed_bug(span, msg); continue; } }; @@ -165,8 +165,8 @@ impl AggregatedSpirvAttributes { category, }) => { cx.tcx - .sess - .delay_span_bug(span, format!("multiple {category} attributes")); + .sess.psess.dcx + .span_delayed_bug(span, format!("multiple {category} attributes")); } } } @@ -278,7 +278,7 @@ impl CheckSpirvAttrVisitor<'_> { let (span, parsed_attr) = match parse_attr_result { Ok(span_and_parsed_attr) => span_and_parsed_attr, Err((span, msg)) => { - self.tcx.sess.span_err(span, msg); + self.tcx.sess.psess.dcx.span_err(span, msg); continue; } }; @@ -317,13 +317,13 @@ impl CheckSpirvAttrVisitor<'_> { | SpirvAttribute::InputAttachmentIndex(_) | SpirvAttribute::SpecConstant(_) => match target { Target::Param => { - let parent_hir_id = self.tcx.hir().parent_id(hir_id); + let mut parent_hir_id = self.tcx.hir().parent_id_iter(hir_id); let parent_is_entry_point = - parse_attrs(self.tcx.hir().attrs(parent_hir_id)) + parse_attrs(self.tcx.hir().attrs(parent_hir_id.next().unwrap())) .filter_map(|r| r.ok()) .any(|(_, attr)| matches!(attr, SpirvAttribute::Entry(_))); if !parent_is_entry_point { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, "attribute is only valid on a parameter of an entry-point function", ); @@ -346,7 +346,7 @@ impl CheckSpirvAttrVisitor<'_> { }; if let Err(msg) = valid { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, format!("`{storage_class:?}` storage class {msg}"), ); @@ -367,7 +367,7 @@ impl CheckSpirvAttrVisitor<'_> { }; match valid_target { Err(Expected(expected_target)) => { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, format!( "attribute is only valid on a {expected_target}, not on a {target}" @@ -381,13 +381,13 @@ impl CheckSpirvAttrVisitor<'_> { category, }) => { self.tcx - .sess + .sess.psess.dcx .struct_span_err( span, format!("only one {category} attribute is allowed on a {target}"), ) .span_note(prev_span, format!("previous {category} attribute")) - .emit(); + ; } }, } @@ -397,7 +397,7 @@ impl CheckSpirvAttrVisitor<'_> { // so we can perform further checks, emit warnings, etc. if let Some(block_attr) = aggregated_attrs.block { - self.tcx.sess.span_warn( + self.tcx.sess.psess.dcx.span_warn( block_attr.span, "#[spirv(block)] is no longer needed and should be removed", ); diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 86766ff75f..7aa9d18927 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -28,7 +28,6 @@ use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange}; use smallvec::SmallVec; use std::borrow::Cow; use std::cell::Cell; -use std::convert::TryInto; use std::iter::{self, empty}; macro_rules! simple_op { @@ -444,7 +443,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// /// That is, try to turn `((_: *T) as *u8).add(offset) as *Leaf` into a series /// of struct field and array/vector element accesses. - fn recover_access_chain_from_offset( + pub(crate) fn recover_access_chain_from_offset( &self, mut ty: ::Type, mut offset: Size, @@ -738,7 +737,12 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { current_span: Default::default(), } } - + fn fadd_algebraic(&mut self, _: ::Value, _: ::Value) -> ::Value { todo!() } + fn fsub_algebraic(&mut self, _: ::Value, _: ::Value) -> ::Value { todo!() } + fn fmul_algebraic(&mut self, _: ::Value, _: ::Value) -> ::Value { todo!() } + fn fdiv_algebraic(&mut self, _: ::Value, _: ::Value) -> ::Value { todo!() } + fn frem_algebraic(&mut self, _: ::Value, _: ::Value) -> ::Value { todo!() } + fn cx(&self) -> &Self::CodegenCx { self.cx } @@ -1373,78 +1377,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { self.gep_help(ty, ptr, indices, true) } - fn struct_gep(&mut self, ty: Self::Type, ptr: Self::Value, idx: u64) -> Self::Value { - let (offset, result_pointee_type) = match self.lookup_type(ty) { - SpirvType::Adt { - field_offsets, - field_types, - .. - } => (field_offsets[idx as usize], field_types[idx as usize]), - SpirvType::Array { element, .. } - | SpirvType::RuntimeArray { element, .. } - | SpirvType::Vector { element, .. } - | SpirvType::Matrix { element, .. } => ( - self.lookup_type(element).sizeof(self).unwrap() * idx, - element, - ), - SpirvType::InterfaceBlock { inner_type } => { - assert_eq!(idx, 0); - (Size::ZERO, inner_type) - } - other => self.fatal(format!( - "struct_gep not on struct, array, or vector type: {other:?}, index {idx}" - )), - }; - let result_type = self.type_ptr_to(result_pointee_type); - - // Special-case field accesses through a `pointercast`, to accesss the - // right field in the original type, for the `Logical` addressing model. - let ptr = ptr.strip_ptrcasts(); - let original_pointee_ty = match self.lookup_type(ptr.ty) { - SpirvType::Pointer { pointee } => pointee, - other => self.fatal(format!("struct_gep called on non-pointer type: {other:?}")), - }; - if let Some((indices, _)) = self.recover_access_chain_from_offset( - original_pointee_ty, - offset, - self.lookup_type(result_pointee_type).sizeof(self), - Some(result_pointee_type), - ) { - let original_ptr = ptr.def(self); - let indices = indices - .into_iter() - .map(|idx| self.constant_u32(self.span(), idx).def(self)) - .collect::>(); - return self - .emit() - .access_chain(result_type, None, original_ptr, indices) - .unwrap() - .with_type(result_type); - } - - // FIXME(eddyb) can we even get to this point, with valid SPIR-V? - - // HACK(eddyb) temporary workaround for untyped pointers upstream. - // FIXME(eddyb) replace with untyped memory SPIR-V + `qptr` or similar. - let ptr = self.pointercast(ptr, self.type_ptr_to(ty)); - - // Important! LLVM, and therefore intel-compute-runtime, require the `getelementptr` instruction (and therefore - // OpAccessChain) on structs to be a constant i32. Not i64! i32. - if idx > u32::MAX as u64 { - self.fatal("struct_gep bigger than u32::MAX"); - } - let index_const = self.constant_u32(self.span(), idx as u32).def(self); - self.emit() - .access_chain( - result_type, - None, - ptr.def(self), - [index_const].iter().cloned(), - ) - .unwrap() - .with_type(result_type) - } - // intcast has the logic for dealing with bools, so use that fn trunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.intcast(val, dest_ty, false) @@ -2282,7 +2214,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { order: AtomicOrdering, failure_order: AtomicOrdering, _weak: bool, - ) -> Self::Value { + ) -> (Self::Value,Self::Value) { assert_ty_eq!(self, cmp.ty, src.ty); let ty = src.ty; @@ -2310,7 +2242,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { ) .unwrap() .with_type(access_ty); - self.bitcast(result, ty) + (self.bitcast(result, ty),self.bitcast(result, ty)) } fn atomic_rmw( @@ -2987,7 +2919,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { Err(FormatArgsNotRecognized(step)) => { if let Some(current_span) = self.current_span { - let mut warn = self.tcx.sess.struct_span_warn( + let mut warn = self.tcx.sess.psess.dcx.struct_span_warn( current_span, "failed to find and remove `format_args!` construction for this `panic!`", ); @@ -3037,7 +2969,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { self.intcast(val, dest_ty, false) } - fn do_not_inline(&mut self, _llret: Self::Value) { + fn apply_attrs_to_cleanup_callsite(&mut self, _llret: Self::Value) { // Ignore } } diff --git a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs index 9d8b886ea8..2d0d5efc8b 100644 --- a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs +++ b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs @@ -12,8 +12,8 @@ use rustc_codegen_ssa::traits::{BuilderMethods, IntrinsicCallMethods}; use rustc_middle::bug; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{FnDef, Instance, ParamEnv, Ty, TyKind}; -use rustc_span::source_map::Span; use rustc_span::sym; +use rustc_span::Span; use rustc_target::abi::call::{FnAbi, PassMode}; use std::assert_matches::assert_matches; @@ -71,7 +71,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { args: &[OperandRef<'tcx, Self::Value>], llresult: Self::Value, _span: Span, - ) { + ) -> Result<(), rustc_middle::ty::Instance<'tcx>> { let callee_ty = instance.ty(self.tcx, ParamEnv::reveal_all()); let (def_id, fn_args) = match *callee_ty.kind() { @@ -98,7 +98,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { sym::breakpoint => { self.abort(); assert!(fn_abi.ret.is_ignore()); - return; + return Ok(()); } sym::volatile_load | sym::unaligned_volatile_load => { @@ -114,7 +114,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { | sym::prefetch_write_instruction => { // ignore assert!(fn_abi.ret.is_ignore()); - return; + return Ok(()); } sym::saturating_add => { @@ -342,6 +342,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { .val .store(self, result); } + Ok(()) } fn abort(&mut self) { diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index 9fec40232e..de44ec6388 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -20,7 +20,8 @@ use rustc_codegen_ssa::traits::{ AbiBuilderMethods, ArgAbiMethods, BackendTypes, BuilderMethods, CoverageInfoBuilderMethods, DebugInfoBuilderMethods, HasCodegen, StaticBuilderMethods, TypeMembershipMethods, }; -use rustc_errors::{DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed}; +use rustc_errors::{Diag,DiagMessage}; +use rustc_errors::ErrorGuaranteed; use rustc_middle::mir::Coverage; use rustc_middle::span_bug; use rustc_middle::ty::layout::{ @@ -29,7 +30,7 @@ use rustc_middle::ty::layout::{ }; use rustc_middle::ty::{Instance, ParamEnv, Ty, TyCtxt}; use rustc_span::def_id::DefId; -use rustc_span::source_map::Span; +use rustc_span::Span; use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode}; use rustc_target::abi::{HasDataLayout, Size, TargetDataLayout}; use rustc_target::spec::{HasTargetSpec, Target}; @@ -68,33 +69,105 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } + pub(crate) fn struct_gep(&mut self, ty: as BackendTypes>::Type, ptr: SpirvValue, idx: u64) -> as BackendTypes>::Value { + let (offset, result_pointee_type) = match self.lookup_type(ty) { + SpirvType::Adt { + field_offsets, + field_types, + .. + } => (field_offsets[idx as usize], field_types[idx as usize]), + SpirvType::Array { element, .. } + | SpirvType::RuntimeArray { element, .. } + | SpirvType::Vector { element, .. } + | SpirvType::Matrix { element, .. } => ( + self.lookup_type(element).sizeof(self).unwrap() * idx, + element, + ), + SpirvType::InterfaceBlock { inner_type } => { + assert_eq!(idx, 0); + (Size::ZERO, inner_type) + } + other => self.fatal(format!( + "struct_gep not on struct, array, or vector type: {other:?}, index {idx}" + )), + }; + let result_type = self.type_ptr_to(result_pointee_type); + + // Special-case field accesses through a `pointercast`, to accesss the + // right field in the original type, for the `Logical` addressing model. + let ptr = ptr.strip_ptrcasts(); + let original_pointee_ty = match self.lookup_type(ptr.ty) { + SpirvType::Pointer { pointee } => pointee, + other => self.fatal(format!("struct_gep called on non-pointer type: {other:?}")), + }; + if let Some((indices, _)) = self.recover_access_chain_from_offset( + original_pointee_ty, + offset, + self.lookup_type(result_pointee_type).sizeof(self), + Some(result_pointee_type), + ) { + let original_ptr = ptr.def(self); + let indices = indices + .into_iter() + .map(|idx| self.constant_u32(self.span(), idx).def(self)) + .collect::>(); + return self + .emit() + .access_chain(result_type, None, original_ptr, indices) + .unwrap() + .with_type(result_type); + } + + // FIXME(eddyb) can we even get to this point, with valid SPIR-V? + + // HACK(eddyb) temporary workaround for untyped pointers upstream. + // FIXME(eddyb) replace with untyped memory SPIR-V + `qptr` or similar. + let ptr = self.pointercast(ptr, self.type_ptr_to(ty)); + + // Important! LLVM, and therefore intel-compute-runtime, require the `getelementptr` instruction (and therefore + // OpAccessChain) on structs to be a constant i32. Not i64! i32. + if idx > u32::MAX as u64 { + self.fatal("struct_gep bigger than u32::MAX"); + } + let index_const = self.constant_u32(self.span(), idx as u32).def(self); + self.emit() + .access_chain( + result_type, + None, + ptr.def(self), + [index_const].iter().cloned(), + ) + .unwrap() + .with_type(result_type) + } + #[track_caller] pub fn struct_err( &self, - msg: impl Into, - ) -> DiagnosticBuilder<'_, ErrorGuaranteed> { + msg: impl Into, + ) -> Diag<'_, ErrorGuaranteed> { if let Some(current_span) = self.current_span { - self.tcx.sess.struct_span_err(current_span, msg) + self.tcx.sess.psess.dcx.struct_span_err(current_span, msg) } else { - self.tcx.sess.struct_err(msg) + self.tcx.sess.psess.dcx.struct_err(msg) } } #[track_caller] - pub fn err(&self, msg: impl Into) { + pub fn err(&self, msg: impl Into) { if let Some(current_span) = self.current_span { - self.tcx.sess.span_err(current_span, msg); + self.tcx.sess.psess.dcx.span_err(current_span, msg); } else { - self.tcx.sess.err(msg); + self.tcx.sess.psess.dcx.err(msg); } } #[track_caller] - pub fn fatal(&self, msg: impl Into) -> ! { + pub fn fatal(&self, msg: impl Into) -> ! { if let Some(current_span) = self.current_span { - self.tcx.sess.span_fatal(current_span, msg) + self.tcx.sess.psess.dcx.span_fatal(current_span, msg) } else { - self.tcx.sess.fatal(msg) + self.tcx.sess.psess.dcx.fatal(msg) } } diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index 97c4d9cfa1..6f168ba539 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -15,7 +15,6 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_middle::{bug, ty::Instance}; use rustc_span::{Span, DUMMY_SP}; use rustc_target::asm::{InlineAsmRegClass, InlineAsmRegOrRegClass, SpirVInlineAsmRegClass}; -use std::convert::TryFrom; pub struct InstructionTable { table: FxHashMap<&'static str, &'static rspirv::grammar::Instruction<'static>>, @@ -51,7 +50,6 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> { Placeholder { operand_idx: 2, modifier: None, span: src/lib.rs:20:23: 20:31 (#0) } ] */ - fn codegen_inline_asm( &mut self, template: &[InlineAsmTemplatePiece], @@ -59,7 +57,8 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> { options: InlineAsmOptions, _line_spans: &[Span], _instance: Instance<'_>, - _dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>, + _bb1 : Option, + _dest_catch_funclet : Option<(Self::BasicBlock, Option<&Self::Funclet>)>, ) { const SUPPORTED_OPTIONS: InlineAsmOptions = InlineAsmOptions::NORETURN; let unsupported_options = options & !SUPPORTED_OPTIONS; @@ -101,7 +100,7 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> { } => { if let Some(modifier) = modifier { self.tcx - .sess + .sess.psess.dcx .span_err(span, format!("asm modifiers are not supported: {modifier}")); } let line = tokens.last_mut().unwrap(); @@ -305,14 +304,14 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Op::TypePointer => { let storage_class = inst.operands[0].unwrap_storage_class(); if storage_class != StorageClass::Generic { - self.struct_err("TypePointer in asm! requires `Generic` storage class") - .note(format!( + let mut err = self.struct_err("TypePointer in asm! requires `Generic` storage class") + ;err.note(format!( "`{storage_class:?}` storage class was specified" - )) - .help(format!( + )); + err.help(format!( "the storage class will be inferred automatically (e.g. to `{storage_class:?}`)" - )) - .emit(); + )); + err.emit(); } SpirvType::Pointer { pointee: inst.operands[1].unwrap_id_ref(), @@ -359,14 +358,14 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { // NOTE(eddyb) allowing the instruction to be added below avoids // spurious "`noreturn` requires a terminator at the end" errors. if let Op::Return | Op::ReturnValue = op { - self.struct_err(format!( + let mut err = self.struct_err(format!( "using `Op{op:?}` to return from within `asm!` is disallowed" - )) - .note( + )); + err.note( "resuming execution, without falling through the end \ of the `asm!` block, is always undefined behavior", - ) - .emit(); + ); + err.emit(); } self.emit() @@ -456,7 +455,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Token::Placeholder(_, span) | Token::Typeof(_, span, _) => { self.tcx .sess - .span_err(span, "cannot use a dynamic value as an instruction type"); + .psess.dcx.span_err(span, "cannot use a dynamic value as an instruction type"); return; } }; @@ -582,7 +581,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { )); } if tokens.next().is_some() { - self.tcx.sess.err(format!( + self.tcx.sess .psess.dcx.err(format!( "too many operands to instruction: {}", instruction.class.opname )); @@ -799,6 +798,8 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { _ => { self.tcx .sess + .psess + .dcx .span_err(span, format!("invalid register: {reg}")); } } @@ -831,7 +832,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } Token::Typeof(_, span, _) => { self.tcx - .sess + .sess.psess.dcx .span_err(span, "cannot assign to a typeof expression"); None } @@ -839,10 +840,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { InlineAsmOperandRef::In { reg, value: _ } => { self.check_reg(span, reg); self.tcx - .sess + .sess.psess.dcx .span_err(span, "in register cannot be assigned to"); None } + InlineAsmOperandRef::Label { .. } => todo!(), + InlineAsmOperandRef::Out { reg, late: _, @@ -852,7 +855,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { match place { Some(place) => Some(OutRegister::Place(*place)), None => { - self.tcx.sess.span_err(span, "missing place for register"); + self.tcx.sess.psess.dcx.span_err(span, "missing place for register"); None } } @@ -867,26 +870,26 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { match out_place { Some(out_place) => Some(OutRegister::Place(*out_place)), None => { - self.tcx.sess.span_err(span, "missing place for register"); + self.tcx.sess.psess.dcx.span_err(span, "missing place for register"); None } } } InlineAsmOperandRef::Const { string: _ } => { self.tcx - .sess + .sess.psess.dcx .span_err(span, "cannot write to const asm argument"); None } InlineAsmOperandRef::SymFn { instance: _ } => { self.tcx - .sess + .sess.psess.dcx .span_err(span, "cannot write to function asm argument"); None } InlineAsmOperandRef::SymStatic { def_id: _ } => { self.tcx - .sess + .sess.psess.dcx .span_err(span, "cannot write to static variable asm argument"); None } @@ -913,6 +916,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { None } Token::Typeof(hole, span, kind) => match hole { + InlineAsmOperandRef::Label { .. } => todo!(), InlineAsmOperandRef::In { reg, value } => { self.check_reg(span, reg); let ty = value.immediate().ty; @@ -921,7 +925,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { TypeofKind::Dereference => match self.lookup_type(ty) { SpirvType::Pointer { pointee } => pointee, other => { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, format!( "cannot use typeof* on non-pointer type: {}", @@ -943,7 +947,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Some(place) => match self.lookup_type(place.llval.ty) { SpirvType::Pointer { pointee } => Some(pointee), other => { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, format!( "out register type not pointer: {}", @@ -955,7 +959,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { }, None => { self.tcx - .sess + .sess.psess.dcx .span_err(span, "missing place for out register typeof"); None } @@ -972,18 +976,18 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } InlineAsmOperandRef::Const { string: _ } => { self.tcx - .sess + .sess.psess.dcx .span_err(span, "cannot take the type of a const asm argument"); None } InlineAsmOperandRef::SymFn { instance: _ } => { self.tcx - .sess + .sess.psess.dcx .span_err(span, "cannot take the type of a function asm argument"); None } InlineAsmOperandRef::SymStatic { def_id: _ } => { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, "cannot take the type of a static variable asm argument", ); @@ -995,6 +999,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { self.check_reg(span, reg); Some(value.immediate().def(self)) } + InlineAsmOperandRef::Label { .. } => todo!(), InlineAsmOperandRef::Out { reg, late: _, @@ -1002,7 +1007,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } => { self.check_reg(span, reg); self.tcx - .sess + .sess.psess.dcx .span_err(span, "out register cannot be used as a value"); None } @@ -1017,19 +1022,19 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } InlineAsmOperandRef::Const { string: _ } => { self.tcx - .sess + .sess.psess.dcx .span_err(span, "const asm argument not supported yet"); None } InlineAsmOperandRef::SymFn { instance: _ } => { self.tcx - .sess + .sess.psess.dcx .span_err(span, "function asm argument not supported yet"); None } InlineAsmOperandRef::SymStatic { def_id: _ } => { self.tcx - .sess + .sess.psess.dcx .span_err(span, "static variable asm argument not supported yet"); None } @@ -1161,13 +1166,13 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { self.err(format!("expected a literal, not a string for a {kind:?}")); } Some(Token::Placeholder(_, span)) => { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, format!("expected a literal, not a dynamic value for a {kind:?}"), ); } Some(Token::Typeof(_, span, _)) => { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, format!("expected a literal, not a type for a {kind:?}"), ); @@ -1363,13 +1368,13 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { self.err(format!("expected a literal, not a string for a {kind:?}")); } Token::Placeholder(_, span) => { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, format!("expected a literal, not a dynamic value for a {kind:?}"), ); } Token::Typeof(_, span, _) => { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, format!("expected a literal, not a type for a {kind:?}"), ); diff --git a/crates/rustc_codegen_spirv/src/builder_spirv.rs b/crates/rustc_codegen_spirv/src/builder_spirv.rs index 6a7c8e72a2..4a8f056caa 100644 --- a/crates/rustc_codegen_spirv/src/builder_spirv.rs +++ b/crates/rustc_codegen_spirv/src/builder_spirv.rs @@ -162,11 +162,10 @@ impl SpirvValue { } SpirvValueKind::IllegalTypeUsed(id) => { - cx.tcx - .sess - .struct_span_err(span, "Can't use type as a value") - .note(format!("Type: *{}", cx.debug_type(id))) - .emit(); + cx + .tcx.sess + .psess.dcx.struct_span_err(span, "Can't use type as a value") + .note(format!("Type: *{}", cx.debug_type(id))); id } @@ -367,7 +366,7 @@ impl Eq for DebugFileKey {} impl Hash for DebugFileKey { fn hash(&self, state: &mut H) { let Self(sf) = self; - sf.name_hash.hash(state); + sf.name.hash(state); sf.src_hash.hash(state); } } @@ -767,7 +766,7 @@ impl<'tcx> BuilderSpirv<'tcx> { FileName::Real(name) => { name.to_string_lossy(FileNameDisplayPreference::Remapped) } - _ => sf.name.prefer_remapped().to_string().into(), + _ => sf.name.prefer_remapped_unconditionaly().to_string().into(), }; let file_name = { // FIXME(eddyb) it should be possible to arena-allocate a diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs index 83b60b4fdd..33b49b536b 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs @@ -65,6 +65,8 @@ impl<'tcx> CodegenCx<'tcx> { _ => self .tcx .sess + .psess + .dcx .fatal(format!("Invalid constant value for bool: {val}")), }, SpirvType::Integer(128, _) => { @@ -72,7 +74,7 @@ impl<'tcx> CodegenCx<'tcx> { self.zombie_no_span(result.def_cx(self), "u128 constant"); result } - other => self.tcx.sess.fatal(format!( + other => self.tcx.sess.psess.dcx.fatal(format!( "constant_int invalid on type {}", other.debug(ty, self) )), @@ -93,7 +95,7 @@ impl<'tcx> CodegenCx<'tcx> { match self.lookup_type(ty) { SpirvType::Float(32) => self.def_constant(ty, SpirvConst::F32((val as f32).to_bits())), SpirvType::Float(64) => self.def_constant(ty, SpirvConst::F64(val.to_bits())), - other => self.tcx.sess.fatal(format!( + other => self.tcx.sess.psess.dcx.fatal(format!( "constant_float invalid on type {}", other.debug(ty, self) )), @@ -214,7 +216,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { size, align, field_types: &field_types, - field_offsets: &field_offsets, + field_offsets: field_offsets.as_slice(), field_names: None, } .def(DUMMY_SP, self); @@ -258,13 +260,21 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { _ => self .tcx .sess + .psess + .dcx .fatal(format!("Invalid constant value for bool: {data}")), }, - other => self.tcx.sess.fatal(format!( + other => self.tcx.sess.psess.dcx.fatal(format!( "scalar_to_backend Primitive::Int not supported on type {}", other.debug(ty, self) )), }, + Primitive::F16 => { + // let res = self.constant_f16(DUMMY_SP, f16::from_bits(data as u16)); + // assert_eq!(res.ty, ty); + // res + todo!() + } Primitive::F32 => { let res = self.constant_f32(DUMMY_SP, f32::from_bits(data as u32)); assert_eq!(res.ty, ty); @@ -275,6 +285,12 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { assert_eq!(res.ty, ty); res } + Primitive::F128 => { + // let res = self.constant_float(ty, f128::from_bits(data as u128)); + // assert_eq!(res.ty, ty); + // res + todo!() + } Primitive::Pointer(_) => { if data == 0 { self.constant_null(ty) @@ -290,12 +306,13 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { } } Scalar::Ptr(ptr, _) => { - let (alloc_id, offset) = ptr.into_parts(); + let (prov, offset) = ptr.into_parts(); + let alloc_id = prov.alloc_id(); let (base_addr, _base_addr_space) = match self.tcx.global_alloc(alloc_id) { GlobalAlloc::Memory(alloc) => { let pointee = match self.lookup_type(ty) { SpirvType::Pointer { pointee } => pointee, - other => self.tcx.sess.fatal(format!( + other => self.tcx.sess.psess.dcx.fatal(format!( "GlobalAlloc::Memory type not implemented: {}", other.debug(ty, self) )), @@ -315,7 +332,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { .unwrap_memory(); let pointee = match self.lookup_type(ty) { SpirvType::Pointer { pointee } => pointee, - other => self.tcx.sess.fatal(format!( + other => self.tcx.sess.psess.dcx.fatal(format!( "GlobalAlloc::VTable type not implemented: {}", other.debug(ty, self) )), @@ -335,6 +352,8 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { } else { self.tcx .sess + .psess + .dcx .fatal("Non-zero scalar_to_backend ptr.offset not supported") // let offset = self.constant_u64(ptr.offset.bytes()); // self.gep(base_addr, once(offset)) @@ -345,8 +364,9 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { } else { self.tcx .sess - .fatal("Non-pointer-typed scalar_to_backend Scalar::Ptr not supported"); - // unsafe { llvm::LLVMConstPtrToInt(llval, llty) } + .psess + .dcx + .fatal("Non-pointer-typed scalar_to_backend Scalar::Ptr not supported") } } } @@ -447,6 +467,8 @@ impl<'tcx> CodegenCx<'tcx> { SpirvType::Void => self .tcx .sess + .psess + .dcx .fatal("cannot create const alloc of type void"), SpirvType::Bool | SpirvType::Integer(..) @@ -465,6 +487,8 @@ impl<'tcx> CodegenCx<'tcx> { other => { self.tcx .sess + .psess + .dcx .fatal(format!("invalid size for integer: {other}")); } }; @@ -476,6 +500,8 @@ impl<'tcx> CodegenCx<'tcx> { other => { self.tcx .sess + .psess + .dcx .fatal(format!("invalid size for float: {other}")); } }, @@ -602,25 +628,35 @@ impl<'tcx> CodegenCx<'tcx> { SpirvType::Function { .. } => self .tcx .sess + .psess + .dcx .fatal("TODO: SpirvType::Function not supported yet in create_const_alloc"), - SpirvType::Image { .. } => self.tcx.sess.fatal("cannot create a constant image value"), + SpirvType::Image { .. } => self.tcx.sess.psess.dcx.fatal("cannot create a constant image value"), SpirvType::Sampler => self .tcx .sess + .psess + .dcx .fatal("cannot create a constant sampler value"), SpirvType::SampledImage { .. } => self .tcx .sess + .psess + .dcx .fatal("cannot create a constant sampled image value"), SpirvType::InterfaceBlock { .. } => self .tcx .sess + .psess + .dcx .fatal("cannot create a constant interface block value"), SpirvType::AccelerationStructureKhr => self .tcx .sess + .psess + .dcx .fatal("cannot create a constant acceleration structure"), - SpirvType::RayQueryKhr => self.tcx.sess.fatal("cannot create a constant ray query"), + SpirvType::RayQueryKhr => self.tcx.sess.psess.dcx.fatal("cannot create a constant ray query"), } } } diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs index 0786c22835..00ce68fedc 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs @@ -167,7 +167,7 @@ impl<'tcx> CodegenCx<'tcx> { self.libm_intrinsics.borrow_mut().insert(fn_id, intrinsic); } None => { - self.tcx.sess.err(format!( + self.tcx.sess.psess.dcx.err(format!( "missing libm intrinsic {symbol_name}, which is {instance}" )); } @@ -279,7 +279,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> { Linkage::External => Some(LinkageType::Export), Linkage::Internal => None, other => { - self.tcx.sess.err(format!( + self.tcx.sess.psess.dcx.err(format!( "TODO: Linkage type {other:?} not supported yet for static var symbol {symbol_name}" )); None @@ -308,7 +308,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> { Linkage::External | Linkage::WeakAny => Some(LinkageType::Export), Linkage::Internal => None, other => { - self.tcx.sess.err(format!( + self.tcx.sess.psess.dcx.err(format!( "TODO: Linkage type {other:?} not supported yet for function symbol {symbol_name}" )); None @@ -330,7 +330,7 @@ impl<'tcx> StaticMethods for CodegenCx<'tcx> { ) } - fn codegen_static(&self, def_id: DefId, _is_mutable: bool) { + fn codegen_static(&self, def_id: DefId,) { let g = self.get_static(def_id); let alloc = match self.tcx.eval_static_initializer(def_id) { @@ -340,7 +340,7 @@ impl<'tcx> StaticMethods for CodegenCx<'tcx> { }; let value_ty = match self.lookup_type(g.ty) { SpirvType::Pointer { pointee } => pointee, - other => self.tcx.sess.fatal(format!( + other => self.tcx.sess.psess.dcx.fatal(format!( "global had non-pointer type {}", other.debug(g.ty, self) )), diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs index 04e8268568..8e41464c2c 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs @@ -76,6 +76,8 @@ impl<'tcx> CodegenCx<'tcx> { } else { self.tcx .sess + .psess + .dcx .span_err(span, format!("cannot declare {name} as an entry point")); return; }; @@ -93,7 +95,7 @@ impl<'tcx> CodegenCx<'tcx> { // the `FnAbi` readjustment to only use `PassMode::Pair` for // pointers to `!Sized` types, but not other `ScalarPair`s. if !matches!(arg_abi.layout.ty.kind(), ty::Ref(..)) { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( hir_param.ty_span, format!( "entry point parameter type not yet supported \ @@ -105,7 +107,7 @@ impl<'tcx> CodegenCx<'tcx> { } // FIXME(eddyb) support these (by just ignoring them) - if there // is any validation concern, it should be done on the types. - PassMode::Ignore => self.tcx.sess.span_fatal( + PassMode::Ignore => self.tcx.sess.psess.dcx.span_fatal( hir_param.ty_span, format!( "entry point parameter type not yet supported \ @@ -123,7 +125,7 @@ impl<'tcx> CodegenCx<'tcx> { if fn_abi.ret.layout.ty.is_unit() { assert_matches!(fn_abi.ret.mode, PassMode::Ignore); } else { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, format!( "entry point should return `()`, not `{}`", @@ -274,7 +276,7 @@ impl<'tcx> CodegenCx<'tcx> { if is_ref { Some(StorageClass::UniformConstant) } else { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( hir_param.ty_span, format!( "entry parameter type must be by-reference: `&{}`", @@ -291,7 +293,7 @@ impl<'tcx> CodegenCx<'tcx> { let storage_class = storage_class_attr.value; if !is_ref { - self.tcx.sess.span_fatal( + self.tcx.sess.psess.dcx.span_fatal( hir_param.ty_span, format!( "invalid entry param type `{}` for storage class `{storage_class:?}` \ @@ -303,13 +305,13 @@ impl<'tcx> CodegenCx<'tcx> { } match deduced_storage_class_from_ty { - Some(deduced) if storage_class == deduced => self.tcx.sess.span_warn( + Some(deduced) if storage_class == deduced => self.tcx.sess.psess.dcx.span_warn( storage_class_attr.span, "redundant storage class attribute, storage class is deduced from type", ), Some(deduced) => { self.tcx - .sess + .sess.psess.dcx .struct_span_err(hir_param.span, "storage class mismatch") .span_label( storage_class_attr.span, @@ -324,8 +326,7 @@ impl<'tcx> CodegenCx<'tcx> { format!( "remove storage class attribute to use `{deduced:?}` as storage class" ), - ) - .emit(); + ); } None => (), } @@ -338,7 +339,7 @@ impl<'tcx> CodegenCx<'tcx> { .unwrap_or_else(|| match (is_ref, explicit_mutbl) { (false, _) => StorageClass::Input, (true, hir::Mutability::Mut) => StorageClass::Output, - (true, hir::Mutability::Not) => self.tcx.sess.span_fatal( + (true, hir::Mutability::Not) => self.tcx.sess.psess.dcx.span_fatal( hir_param.ty_span, format!( "invalid entry param type `{}` (expected `{}` or `&mut {1}`)", @@ -355,7 +356,7 @@ impl<'tcx> CodegenCx<'tcx> { let storage_class_requires_read_only = expected_mutbl_for(storage_class) == hir::Mutability::Not; if !ref_is_read_only && storage_class_requires_read_only { - let mut err = self.tcx.sess.struct_span_err( + let mut err = self.tcx.sess.psess.dcx.struct_span_err( hir_param.ty_span, format!( "entry-point requires {}...", @@ -395,7 +396,7 @@ impl<'tcx> CodegenCx<'tcx> { let mut storage_class = Ok(storage_class); if let Some(spec_constant) = attrs.spec_constant { if ref_or_value_layout.ty != self.tcx.types.u32 { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( hir_param.ty_span, format!( "unsupported `#[spirv(spec_constant)]` type `{}` (expected `{}`)", @@ -403,7 +404,7 @@ impl<'tcx> CodegenCx<'tcx> { ), ); } else if let Some(storage_class) = attrs.storage_class { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( storage_class.span, "`#[spirv(spec_constant)]` cannot have a storage class", ); @@ -494,7 +495,7 @@ impl<'tcx> CodegenCx<'tcx> { // value. We currently only do that with unsized types, so if a type is a pair for some // other reason (e.g. a tuple), we bail. self.tcx - .sess + .sess.psess.dcx .span_fatal(hir_param.ty_span, "pair type not supported yet") } let var_ptr_spirv_type; @@ -518,7 +519,7 @@ impl<'tcx> CodegenCx<'tcx> { match self.lookup_type(value_spirv_type) { SpirvType::RuntimeArray { .. } => {} _ => { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( hir_param.ty_span, "only plain slices are supported as unsized types", ); @@ -538,7 +539,7 @@ impl<'tcx> CodegenCx<'tcx> { // It's OK to use a RuntimeArray and not have a length parameter, but // it's just nicer ergonomics to use a slice. self.tcx - .sess + .sess.psess.dcx .span_warn(hir_param.ty_span, "use &[T] instead of &RuntimeArray"); } None @@ -552,7 +553,7 @@ impl<'tcx> CodegenCx<'tcx> { match self.lookup_type(value_spirv_type) { SpirvType::RuntimeArray { .. } => { if is_unsized_with_len { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( hir_param.ty_span, "uniform_constant must use &RuntimeArray, not &[T]", ); @@ -560,7 +561,7 @@ impl<'tcx> CodegenCx<'tcx> { } _ => { if is_unsized { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( hir_param.ty_span, "only plain slices are supported as unsized types", ); @@ -581,7 +582,7 @@ impl<'tcx> CodegenCx<'tcx> { var_ptr_spirv_type = self.type_ptr_to(value_spirv_type); if is_unsized { - self.tcx.sess.span_fatal( + self.tcx.sess.psess.dcx.span_fatal( hir_param.ty_span, format!( "unsized types are not supported for {}", @@ -644,7 +645,7 @@ impl<'tcx> CodegenCx<'tcx> { let mut decoration_supersedes_location = false; if let Some(builtin) = attrs.builtin { if let Err(SpecConstant { .. }) = storage_class { - self.tcx.sess.span_fatal( + self.tcx.sess.psess.dcx.span_fatal( builtin.span, format!( "`#[spirv(spec_constant)]` cannot be `{:?}` builtin", @@ -661,7 +662,7 @@ impl<'tcx> CodegenCx<'tcx> { } if let Some(descriptor_set) = attrs.descriptor_set { if let Err(SpecConstant { .. }) = storage_class { - self.tcx.sess.span_fatal( + self.tcx.sess.psess.dcx.span_fatal( descriptor_set.span, "`#[spirv(descriptor_set = ...)]` cannot apply to `#[spirv(spec_constant)]`", ); @@ -675,7 +676,7 @@ impl<'tcx> CodegenCx<'tcx> { } if let Some(binding) = attrs.binding { if let Err(SpecConstant { .. }) = storage_class { - self.tcx.sess.span_fatal( + self.tcx.sess.psess.dcx.span_fatal( binding.span, "`#[spirv(binding = ...)]` cannot apply to `#[spirv(spec_constant)]`", ); @@ -689,7 +690,7 @@ impl<'tcx> CodegenCx<'tcx> { } if let Some(flat) = attrs.flat { if let Err(SpecConstant { .. }) = storage_class { - self.tcx.sess.span_fatal( + self.tcx.sess.psess.dcx.span_fatal( flat.span, "`#[spirv(flat)]` cannot apply to `#[spirv(spec_constant)]`", ); @@ -699,7 +700,7 @@ impl<'tcx> CodegenCx<'tcx> { } if let Some(invariant) = attrs.invariant { if storage_class != Ok(StorageClass::Output) { - self.tcx.sess.span_fatal( + self.tcx.sess.psess.dcx.span_fatal( invariant.span, "`#[spirv(invariant)]` is only valid on Output variables", ); @@ -732,17 +733,17 @@ impl<'tcx> CodegenCx<'tcx> { ); } else if is_subpass_input { self.tcx - .sess + .sess.psess.dcx .span_err(hir_param.ty_span, "Missing capability InputAttachment"); } else { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( attachment_index.span, "#[spirv(input_attachment_index)] is only valid on Image types with dim = SubpassData" ); } decoration_supersedes_location = true; } else if is_subpass_input { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( hir_param.ty_span, "Image types with dim = SubpassData require #[spirv(input_attachment_index)] decoration", ); @@ -840,7 +841,7 @@ impl<'tcx> CodegenCx<'tcx> { { self.tcx .sess - .span_err(span, "entry-point parameter cannot contain `bool`s"); + .psess.dcx.span_err(span, "entry-point parameter cannot contain `bool`s"); } // Enforce Vulkan validation rules around `Flat` as accurately as possible, @@ -887,7 +888,7 @@ impl<'tcx> CodegenCx<'tcx> { _ => None, }; if let Some((span, must_or_cannot)) = flat_mismatch { - self.tcx.sess.span_err( + self.tcx.sess.psess.dcx.span_err( span, format!( "`{execution_model:?}` entry-point `{storage_class:?}` parameter \ diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index e9a378d038..4093a6b11f 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -90,8 +90,7 @@ impl<'tcx> CodegenCx<'tcx> { let sym = Symbols::get(); let mut feature_names = tcx - .sess - .target_features + .sess.target_features .iter() .map(|s| s.as_str()) .collect::>(); @@ -106,7 +105,7 @@ impl<'tcx> CodegenCx<'tcx> { .map(|s| s.parse()) .collect::>() .unwrap_or_else(|error| { - tcx.sess.err(error); + tcx.sess.psess.dcx.err(error); Vec::new() }); @@ -269,7 +268,7 @@ impl CodegenArgs { pub fn from_session(sess: &Session) -> Self { match CodegenArgs::parse(&sess.opts.cg.llvm_args) { Ok(ok) => ok, - Err(err) => sess.fatal(format!("Unable to parse llvm-args: {err}")), + Err(err) => sess.psess.dcx.fatal(format!("Unable to parse llvm-args: {err}")), } } diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs index 6effea59b9..3bdd3153d4 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs @@ -9,7 +9,8 @@ use rustc_middle::ty::layout::{ }; use rustc_middle::ty::Ty; use rustc_middle::{bug, span_bug}; -use rustc_span::source_map::{Span, Spanned, DUMMY_SP}; +use rustc_span::source_map::Spanned; +use rustc_span::{Span, DUMMY_SP}; use rustc_target::abi::call::{CastTarget, FnAbi, Reg}; use rustc_target::abi::{Abi, AddressSpace, FieldsShape}; @@ -19,7 +20,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'tcx> { #[inline] fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { if let LayoutError::SizeOverflow(_) = err { - self.tcx.sess.span_fatal(span, err.to_string()) + self.tcx.sess.psess.dcx.span_fatal(span, err.to_string()) } else { span_bug!(span, "failed to get layout for `{}`: {}", ty, err) } @@ -37,7 +38,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'tcx> { fn_abi_request: FnAbiRequest<'tcx>, ) -> ! { if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err { - self.tcx.sess.emit_fatal(Spanned { span, node: err }) + self.tcx.sess.psess.dcx.emit_fatal(Spanned { span, node: err }) } else { match fn_abi_request { FnAbiRequest::OfFnPtr { sig, extra_args } => { @@ -106,22 +107,22 @@ impl<'tcx> LayoutTypeMethods<'tcx> for CodegenCx<'tcx> { } } - fn backend_field_index(&self, layout: TyAndLayout<'tcx>, index: usize) -> u64 { - match layout.abi { - Abi::Scalar(_) | Abi::ScalarPair(..) => { - bug!("backend_field_index({:?}): not applicable", layout); - } - _ => {} - } - match layout.fields { - FieldsShape::Primitive | FieldsShape::Union(_) => { - bug!("backend_field_index({:?}): not applicable", layout) - } - FieldsShape::Array { .. } => index as u64, - // note: codegen_llvm implements this as 1+index*2 due to padding fields - FieldsShape::Arbitrary { .. } => layout.fields.memory_index(index) as u64, - } - } + // fn backend_field_index(&self, layout: TyAndLayout<'tcx>, index: usize) -> u64 { + // match layout.abi { + // Abi::Scalar(_) | Abi::ScalarPair(..) => { + // bug!("backend_field_index({:?}): not applicable", layout); + // } + // _ => {} + // } + // match layout.fields { + // FieldsShape::Primitive | FieldsShape::Union(_) => { + // bug!("backend_field_index({:?}): not applicable", layout) + // } + // FieldsShape::Array { .. } => index as u64, + // // note: codegen_llvm implements this as 1+index*2 due to padding fields + // FieldsShape::Arbitrary { .. } => layout.fields.memory_index(index) as u64, + // } + // } fn scalar_pair_element_backend_type( &self, @@ -163,13 +164,18 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { let ptr_size = self.tcx.data_layout.pointer_size.bits() as u32; SpirvType::Integer(ptr_size, false).def(DUMMY_SP, self) } - + fn type_f16(&self) -> Self::Type { + SpirvType::Float(16).def(DUMMY_SP, self) + } fn type_f32(&self) -> Self::Type { SpirvType::Float(32).def(DUMMY_SP, self) } fn type_f64(&self) -> Self::Type { SpirvType::Float(64).def(DUMMY_SP, self) } + fn type_f128(&self) -> Self::Type { + SpirvType::Float(128).def(DUMMY_SP, self) + } fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type { SpirvType::Array { @@ -194,7 +200,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { align, size, field_types: els, - field_offsets: &field_offsets, + field_offsets: field_offsets.as_slice(), field_names: None, } .def(DUMMY_SP, self) @@ -211,7 +217,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { other => self .tcx .sess - .fatal(format!("Invalid float width in type_kind: {other}")), + .psess.dcx.fatal(format!("Invalid float width in type_kind: {other}")), }, SpirvType::Adt { .. } | SpirvType::InterfaceBlock { .. } => { TypeKind::Struct @@ -240,7 +246,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { match self.lookup_type(ty) { SpirvType::Pointer { pointee } => pointee, SpirvType::Vector { element, .. } => element, - spirv_type => self.tcx.sess.fatal(format!( + spirv_type => self.tcx.sess.psess.dcx.fatal(format!( "element_type called on invalid type: {spirv_type:?}" )), } @@ -253,7 +259,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { ty => self .tcx .sess - .fatal(format!("vector_length called on non-vector type: {ty:?}")), + .psess.dcx.fatal(format!("vector_length called on non-vector type: {ty:?}")), } } @@ -263,7 +269,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { ty => self .tcx .sess - .fatal(format!("float_width called on non-float type: {ty:?}")), + .psess.dcx.fatal(format!("float_width called on non-float type: {ty:?}")), } } @@ -274,7 +280,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { ty => self .tcx .sess - .fatal(format!("int_width called on non-integer type: {ty:?}")), + .psess.dcx.fatal(format!("int_width called on non-integer type: {ty:?}")), } } diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 89e81668f0..0b59ec0dbe 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -16,7 +16,6 @@ //! [`spirv-tools`]: https://embarkstudios.github.io/rust-gpu/api/spirv_tools //! [`spirv-tools-sys`]: https://embarkstudios.github.io/rust-gpu/api/spirv_tools_sys #![feature(rustc_private)] -#![feature(array_methods)] #![feature(assert_matches)] #![feature(result_flattening)] #![feature(lint_reasons)] @@ -39,7 +38,6 @@ compile_error!( "Either \"use-compiled-tools\" (enabled by default) or \"use-installed-tools\" may be enabled." ); - extern crate rustc_apfloat; extern crate rustc_arena; extern crate rustc_ast; @@ -99,7 +97,7 @@ use rustc_codegen_ssa::traits::{ }; use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, ModuleKind}; use rustc_data_structures::fx::FxIndexMap; -use rustc_errors::{ErrorGuaranteed, FatalError, Handler}; +use rustc_errors::{DiagCtxt, ErrorGuaranteed, FatalError}; use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::mir::mono::{MonoItem, MonoItemData}; @@ -237,8 +235,7 @@ impl CodegenBackend for SpirvCodegenBackend { Box::new(rustc_codegen_ssa::base::codegen_crate( Self, tcx, - tcx.sess - .opts + tcx.sess.opts .cg .target_cpu .clone() @@ -253,15 +250,15 @@ impl CodegenBackend for SpirvCodegenBackend { ongoing_codegen: Box, sess: &Session, _outputs: &OutputFilenames, - ) -> Result<(CodegenResults, FxIndexMap), ErrorGuaranteed> { + ) -> (CodegenResults, FxIndexMap) { let (codegen_results, work_products) = ongoing_codegen .downcast::>() .expect("Expected OngoingCodegen, found Box") .join(sess); - sess.compile_status()?; + // sess.psess.dcx.compile_status().unwrap(); - Ok((codegen_results, work_products)) + (codegen_results, work_products) } fn link( @@ -279,7 +276,7 @@ impl CodegenBackend for SpirvCodegenBackend { ); drop(timer); - sess.compile_status()?; + // sess.psess.dcx.compile_status()?; Ok(()) } } @@ -294,7 +291,7 @@ impl WriteBackendMethods for SpirvCodegenBackend { fn run_link( _cgcx: &CodegenContext, - _diag_handler: &Handler, + _diag_handler: &DiagCtxt, _modules: Vec>, ) -> Result, FatalError> { todo!() @@ -326,7 +323,7 @@ impl WriteBackendMethods for SpirvCodegenBackend { unsafe fn optimize( _: &CodegenContext, - _: &Handler, + _: &DiagCtxt, _: &ModuleCodegen, _: &ModuleConfig, ) -> Result<(), FatalError> { @@ -357,7 +354,7 @@ impl WriteBackendMethods for SpirvCodegenBackend { unsafe fn codegen( cgcx: &CodegenContext, - _diag_handler: &Handler, + _diag_handler: &DiagCtxt, module: ModuleCodegen, _config: &ModuleConfig, ) -> Result { @@ -500,7 +497,7 @@ pub fn __rustc_codegen_backend() -> Box { rustc_driver::install_ice_hook( "https://github.com/EmbarkStudios/rust-gpu/issues/new", |handler| { - handler.note_without_error(concat!( + handler.note(concat!( "`rust-gpu` version `", env!("CARGO_PKG_VERSION"), "`" diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index 08df00797b..2e4570dea9 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -87,7 +87,7 @@ pub fn link( ); } other => { - sess.err(format!("CrateType {other:?} not supported yet")); + sess.psess.dcx.err(format!("CrateType {other:?} not supported yet")); } } match out_filename { @@ -124,7 +124,7 @@ fn link_rlib(sess: &Session, codegen_results: &CodegenResults, out_filename: &Pa .. } = lib.kind { - sess.err(format!( + sess.psess.dcx.err(format!( "adding native library to rlib not supported yet: {}", lib.name )); @@ -278,7 +278,7 @@ fn post_link_single_module( (optlevel, false) => format!("optlevel={optlevel:?}"), (optlevel, true) => format!("optlevel={optlevel:?}, debuginfo=None"), }; - sess.warn(format!( + sess.psess.dcx.warn(format!( "`spirv-opt` should have ran ({reason}) but was disabled by `--no-spirv-opt`" )); spv_binary @@ -295,7 +295,7 @@ fn post_link_single_module( let save_modules_timer = sess.timer("link_save_modules"); if let Err(e) = std::fs::write(out_filename, spirv_tools::binary::from_binary(&spv_binary)) { - let mut err = sess.struct_err("failed to serialize spirv-binary to disk"); + let mut err = sess.psess.dcx.struct_err("failed to serialize spirv-binary to disk"); err.note(format!("module `{}`", out_filename.display())); err.note(format!("I/O error: {e:#}")); err.emit(); @@ -342,19 +342,30 @@ fn do_spirv_opt( // TODO: Adds spans here? Not sure how useful with binary, but maybe? - let mut err = match msg.level { + match msg.level { Level::Fatal | Level::InternalError => { // FIXME(eddyb) this was `struct_fatal` but that doesn't seem // necessary and also lacks `.forget_guarantee()`. - sess.struct_err(msg.message).forget_guarantee() + let mut err = sess.psess.dcx.struct_fatal(msg.message); + err.note(format!("module `{}`", filename.display())); + err.emit(); + } + Level::Error => { + let mut err = sess.psess.dcx.struct_err(msg.message); + err.note(format!("module `{}`", filename.display())); + err.emit(); + }, + Level::Warning => { + let mut warn = sess.psess.dcx.struct_warn(msg.message); + warn.note(format!("module `{}`", filename.display())); + warn.emit(); + }, + Level::Info | Level::Debug => { + let mut note = sess.psess.dcx.struct_note(msg.message); + note.note(format!("module `{}`", filename.display())); + note.emit(); } - Level::Error => sess.struct_err(msg.message).forget_guarantee(), - Level::Warning => sess.struct_warn(msg.message), - Level::Info | Level::Debug => sess.struct_note_without_error(msg.message), }; - - err.note(format!("module `{}`", filename.display())); - err.emit(); }, Some(options), ); @@ -363,7 +374,7 @@ fn do_spirv_opt( Ok(spirv_tools::binary::Binary::OwnedU32(words)) => words, Ok(binary) => binary.as_words().to_vec(), Err(e) => { - let mut err = sess.struct_warn(e.to_string()); + let mut err = sess.psess.dcx.struct_warn(e.to_string()); err.note("spirv-opt failed, leaving as unoptimized"); err.note(format!("module `{}`", filename.display())); err.emit(); @@ -383,7 +394,7 @@ fn do_spirv_val( let validator = val::create(sess.target.options.env.parse().ok()); if let Err(e) = validator.validate(spv_binary, Some(options)) { - let mut err = sess.struct_err(e.to_string()); + let mut err = sess.psess.dcx.struct_err(e.to_string()); err.note("spirv-val failed"); err.note(format!("module `{}`", filename.display())); err.emit(); @@ -433,7 +444,7 @@ fn add_upstream_rust_crates( Linkage::Static => rlibs.push(src.rlib.as_ref().unwrap().0.clone()), //Linkage::Dynamic => rlibs.push(src.dylib.as_ref().unwrap().0.clone()), Linkage::Dynamic => { - sess.err("TODO: Linkage::Dynamic not supported yet"); + sess.psess.dcx.err("TODO: Linkage::Dynamic not supported yet"); } } } @@ -467,7 +478,7 @@ fn add_upstream_native_libraries( .. } => {} - _ => sess.fatal(format!( + _ => sess.psess.dcx.fatal(format!( "`NativeLibKind::{:?}` (name={:?}) not supported yet", lib.kind, lib.name )), @@ -480,7 +491,7 @@ fn add_upstream_native_libraries( // (see `compiler/rustc_codegen_ssa/src/back/link.rs`) fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool { match lib.cfg { - Some(ref cfg) => rustc_attr::cfg_matches(cfg, &sess.parse_sess, CRATE_NODE_ID, None), + Some(ref cfg) => rustc_attr::cfg_matches(cfg, sess, CRATE_NODE_ID, None), None => true, } } @@ -600,7 +611,7 @@ fn do_link( match link_result { Ok(v) => v, Err(rustc_errors::ErrorGuaranteed { .. }) => { - sess.abort_if_errors(); + sess.psess.dcx.abort_if_errors(); bug!("Linker errored, but no error reported"); } } diff --git a/crates/rustc_codegen_spirv/src/linker/dce.rs b/crates/rustc_codegen_spirv/src/linker/dce.rs index ac9bf3c7fd..3cc865a741 100644 --- a/crates/rustc_codegen_spirv/src/linker/dce.rs +++ b/crates/rustc_codegen_spirv/src/linker/dce.rs @@ -281,7 +281,7 @@ fn instruction_is_pure(inst: &Instruction) -> bool { | PtrEqual | PtrNotEqual | PtrDiff => true, - Variable => inst.operands.get(0) == Some(&Operand::StorageClass(StorageClass::Function)), + Variable => inst.operands.first() == Some(&Operand::StorageClass(StorageClass::Function)), _ => false, } } diff --git a/crates/rustc_codegen_spirv/src/linker/import_export_link.rs b/crates/rustc_codegen_spirv/src/linker/import_export_link.rs index 160a1dd1c7..9d580a4a29 100644 --- a/crates/rustc_codegen_spirv/src/linker/import_export_link.rs +++ b/crates/rustc_codegen_spirv/src/linker/import_export_link.rs @@ -56,7 +56,7 @@ fn find_import_export_pairs_and_killed_params( }; let type_id = *type_map.get(&id).expect("Unexpected op"); if exports.insert(name, (id, type_id)).is_some() { - return Err(sess.err(format!("Multiple exports found for {name:?}"))); + return Err(sess.psess.dcx.err(format!("Multiple exports found for {name:?}"))); } } let mut any_err = None; @@ -68,7 +68,7 @@ fn find_import_export_pairs_and_killed_params( }; let (export_id, export_type) = match exports.get(name) { None => { - any_err = Some(sess.err(format!("Unresolved symbol {name:?}"))); + any_err = Some(sess.psess.dcx.err(format!("Unresolved symbol {name:?}"))); continue; } Some(&x) => x, @@ -183,17 +183,16 @@ fn check_tys_equal( format_ty(ty_defs, ty, &mut result); result } - Err(sess - .struct_err(format!("Types mismatch for {name:?}")) - .note(format!( + Err({let mut err = sess.psess.dcx + .struct_err(format!("Types mismatch for {name:?}")); + err.note(format!( "import type: {}", format_ty_(&ty_defs, import_type) - )) - .note(format!( + )); + err.note(format!( "export type: {}", format_ty_(&ty_defs, export_type) - )) - .emit()) + ));err.emit()}) } } diff --git a/crates/rustc_codegen_spirv/src/linker/inline.rs b/crates/rustc_codegen_spirv/src/linker/inline.rs index c036464ade..be633b3080 100644 --- a/crates/rustc_codegen_spirv/src/linker/inline.rs +++ b/crates/rustc_codegen_spirv/src/linker/inline.rs @@ -15,7 +15,6 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::ErrorGuaranteed; use rustc_session::Session; use smallvec::SmallVec; -use std::convert::TryInto; use std::mem::{self, take}; type FunctionMap = FxHashMap; @@ -117,7 +116,7 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { if !inlined_to_legalize_dont_inlines.is_empty() { let names = get_names(module); for f in inlined_to_legalize_dont_inlines { - sess.warn(format!( + sess.psess.dcx.warn(format!( "`#[inline(never)]` function `{}` needs to be inlined \ because it has illegal argument or return types", get_name(&names, f) @@ -235,7 +234,7 @@ fn deny_recursion_in_module(sess: &Session, module: &Module) -> super::Result<() let names = get_names(module); let current_name = get_name(&names, module.functions[current].def_id().unwrap()); let next_name = get_name(&names, module.functions[next].def_id().unwrap()); - *has_recursion = Some(sess.err(format!( + *has_recursion = Some(sess.psess.dcx.err(format!( "module has recursion, which is not allowed: `{current_name}` calls `{next_name}`" ))); break; @@ -626,7 +625,7 @@ impl Inliner<'_, '_> { let return_jump = self.id(); // Rewrite OpReturns of the callee. let (mut inlined_callee_blocks, extra_debug_insts_pre_call, extra_debug_insts_post_call) = - self.get_inlined_blocks(callee, call_debug_insts, return_variable, return_jump); + self.get_inlined_blocks(&callee, call_debug_insts, return_variable, return_jump); // Clone the IDs of the callee, because otherwise they'd be defined multiple times if the // fn is inlined multiple times. self.add_clone_id_rules(&mut rewrite_rules, &inlined_callee_blocks); diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 3606779ee9..20983d19bb 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -167,7 +167,7 @@ pub fn link( bound += module.header.as_ref().unwrap().bound - 1; let this_version = module.header.as_ref().unwrap().version(); if version != this_version { - return Err(sess.err(format!( + return Err(sess.psess.dcx.err(format!( "cannot link two modules with different SPIR-V versions: v{}.{} and v{}.{}", version.0, version.1, this_version.0, this_version.1 ))); @@ -425,11 +425,12 @@ pub fn link( Err(e) => format!("could not be saved: {e}"), }; - return Err(sess - .struct_err(format!("{e}")) - .note("while lowering SPIR-V module to SPIR-T (spirt::spv::lower)") - .note(format!("input SPIR-V module {was_saved_msg}")) - .emit()); + return Err({let mut err = sess.psess.dcx + .struct_err(format!("{e}")); + err.note("while lowering SPIR-V module to SPIR-T (spirt::spv::lower)"); + err.note(format!("input SPIR-V module {was_saved_msg}")); + err.emit() + }); } } }; @@ -534,7 +535,7 @@ pub fn link( } if any_spirt_bugs { - let mut note = sess.struct_note_without_error("SPIR-T bugs were reported"); + let mut note = sess.psess.dcx.struct_note("SPIR-T bugs were reported"); note.help(format!( "pretty-printed SPIR-T was saved to {}.html", dump_spirt_file_path.as_ref().unwrap().display() @@ -542,8 +543,8 @@ pub fn link( if opts.dump_spirt_passes.is_none() { note.help("re-run with `RUSTGPU_CODEGEN_ARGS=\"--dump-spirt-passes=$PWD\"` for more details"); } - note.note("pretty-printed SPIR-T is preferred when reporting Rust-GPU issues") - .emit(); + note.note("pretty-printed SPIR-T is preferred when reporting Rust-GPU issues"); + note.emit(); } // NOTE(eddyb) this is late so that `--dump-spirt-passes` is processed, @@ -576,12 +577,12 @@ pub fn link( if ext_inst_set.starts_with(custom_insts::CUSTOM_EXT_INST_SET_PREFIX) { let expected = &custom_insts::CUSTOM_EXT_INST_SET[..]; if ext_inst_set == expected { - return Err(sess.err(format!( + return Err(sess.psess.dcx.err(format!( "`OpExtInstImport {ext_inst_set:?}` should not have been \ left around after SPIR-T passes" ))); } else { - return Err(sess.err(format!( + return Err(sess.psess.dcx.err(format!( "unsupported `OpExtInstImport {ext_inst_set:?}` (expected {expected:?} name - version mismatch?)" ))); diff --git a/crates/rustc_codegen_spirv/src/linker/simple_passes.rs b/crates/rustc_codegen_spirv/src/linker/simple_passes.rs index 7ca44add13..7eab733b1e 100644 --- a/crates/rustc_codegen_spirv/src/linker/simple_passes.rs +++ b/crates/rustc_codegen_spirv/src/linker/simple_passes.rs @@ -244,13 +244,14 @@ pub fn check_fragment_insts(sess: &Session, module: &Module) -> Result<()> { .chain(stack) .collect::>() .join("\n"); - any_err = Some( - sess.struct_err(format!( + any_err = Some({ + let mut err = sess.psess.dcx.struct_err(format!( "{} cannot be used outside a fragment shader", inst.class.opname - )) - .note(note) - .emit(), + )); + err.note(note); + err.emit() + } ); } } diff --git a/crates/rustc_codegen_spirv/src/linker/specializer.rs b/crates/rustc_codegen_spirv/src/linker/specializer.rs index 3fb003b4b1..7403a5dd2a 100644 --- a/crates/rustc_codegen_spirv/src/linker/specializer.rs +++ b/crates/rustc_codegen_spirv/src/linker/specializer.rs @@ -58,7 +58,6 @@ use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use smallvec::SmallVec; use std::collections::{BTreeMap, VecDeque}; -use std::convert::{TryFrom, TryInto}; use std::ops::{Range, RangeTo}; use std::{fmt, io, iter, mem, slice}; diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs index b658c4b09f..77768cd581 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs @@ -3,7 +3,7 @@ use crate::custom_decorations::{ }; use crate::custom_insts::{self, CustomInst, CustomOp}; use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::{Diag as DiagnosticBuilder, DiagMessage}; use rustc_session::Session; use rustc_span::{Span, DUMMY_SP}; use smallvec::SmallVec; @@ -420,7 +420,7 @@ impl DiagnosticReporter<'_> { self.span_regen.spirt_attrs_to_rustc_span(self.cx, attrs) }) .unwrap_or(DUMMY_SP); - let mut err = self.sess.struct_span_err(def_span, reason.to_string()); + let mut err = self.sess.psess.dcx.struct_span_err(def_span, reason.to_string()); for use_origin in use_stack_for_def.iter().rev() { use_origin.note(self.cx, &mut self.span_regen, &mut err); } @@ -463,14 +463,14 @@ impl DiagnosticReporter<'_> { let msg = [prefix, msg.to_string(), suffix].concat(); match level { DiagLevel::Bug(_) | DiagLevel::Error => { - let mut err = self.sess.struct_span_err(def_span, msg); + let mut err = self.sess.psess.dcx.struct_span_err(def_span, msg); for use_origin in use_stack_for_def.iter().rev() { use_origin.note(self.cx, &mut self.span_regen, &mut err); } self.overall_result = Err(err.emit()); } DiagLevel::Warning => { - let mut warn = self.sess.struct_span_warn(def_span, msg); + let mut warn = self.sess.psess.dcx.struct_span_warn(def_span, msg); for use_origin in use_stack_for_def.iter().rev() { use_origin.note(self.cx, &mut self.span_regen, &mut warn); } diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs index cfe24dd31c..a4750586e7 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs @@ -10,7 +10,6 @@ use spirt::{ TypeCtor, TypeDef, Value, }; use std::collections::hash_map::Entry; -use std::convert::{TryFrom, TryInto}; use std::hash::Hash; use std::{iter, slice}; diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 7e92b89f47..3f3b3598cb 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -12,7 +12,6 @@ use std::sync::{Arc, Mutex}; // https://github.com/rust-lang/rust/pull/115393 lands. // We need to construct an emitter as yet another workaround, // see https://github.com/rust-lang/rust/pull/102992. -extern crate termcolor; use termcolor::{ColorSpec, WriteColor}; // https://github.com/colin-kiegel/rust-pretty-assertions/issues/24 @@ -101,12 +100,12 @@ fn link_with_linker_opts( self.0.lock().unwrap().flush() } } - impl WriteColor for BufWriter { + impl rustc_errors::WriteColor for BufWriter { fn supports_color(&self) -> bool { false } - fn set_color(&mut self, _spec: &ColorSpec) -> std::io::Result<()> { + fn set_color(&mut self, _spec: &rustc_errors::ColorSpec) -> std::io::Result<()> { Ok(()) } @@ -122,9 +121,9 @@ fn link_with_linker_opts( // is really a silent unwinding device, that should be treated the same as // `Err(ErrorGuaranteed)` returns from `link`). rustc_driver::catch_fatal_errors(|| { - let mut early_error_handler = rustc_session::EarlyErrorHandler::new( - rustc_session::config::ErrorOutputType::default(), - ); + let mut early_error_handler = + rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default()); + early_error_handler.initialize_checked_jobserver(); let matches = rustc_driver::handle_options( &early_error_handler, &["".to_string(), "x.rs".to_string()], @@ -132,10 +131,14 @@ fn link_with_linker_opts( .unwrap(); let sopts = rustc_session::config::build_session_options(&mut early_error_handler, &matches); + let sysroot = rustc_session::filesearch::materialize_sysroot(sopts.maybe_sysroot.clone()); + let target_cfg = + rustc_session::config::build_target_config(&early_error_handler, &sopts, None, &sysroot); + rustc_span::create_session_globals_then(sopts.edition, || { let mut sess = rustc_session::build_session( - &early_error_handler, + early_error_handler, sopts, CompilerIO { input: Input::Str { @@ -151,15 +154,17 @@ fn link_with_linker_opts( Default::default(), Default::default(), Default::default(), - Default::default(), + target_cfg, + sysroot, rustc_interface::util::rustc_version_str().unwrap_or("unknown"), Default::default(), Default::default(), + Default::default(), ); // HACK(eddyb) inject `write_diags` into `sess`, to work around // the removals in https://github.com/rust-lang/rust/pull/102992. - sess.parse_sess.span_diagnostic = { + sess.psess.dcx = { let fallback_bundle = { extern crate rustc_error_messages; rustc_error_messages::fallback_fluent_bundle( @@ -168,11 +173,11 @@ fn link_with_linker_opts( ) }; let emitter = - rustc_errors::emitter::EmitterWriter::new(Box::new(buf), fallback_bundle) - .sm(Some(sess.parse_sess.clone_source_map())); + rustc_errors::emitter::HumanEmitter::new(Box::new(buf), fallback_bundle) + .sm(Some(sess.psess.clone_source_map())); - rustc_errors::Handler::with_emitter(Box::new(emitter)) - .with_flags(sess.opts.unstable_opts.diagnostic_handler_flags(true)) + rustc_errors::DiagCtxt::new(Box::new(emitter)) + .with_flags(sess.opts.unstable_opts.dcx_flags(true)) }; let res = link( @@ -190,14 +195,14 @@ fn link_with_linker_opts( ), Default::default(), ); - assert_eq!(sess.has_errors(), res.as_ref().err().copied()); + assert_eq!(sess.psess.dcx.has_errors(), res.as_ref().err().copied()); res.map(|res| match res { LinkResult::SingleModule(m) => *m, LinkResult::MultipleModules { .. } => unreachable!(), }) }) }) - .flatten() + .unwrap() .map_err(|_e| { let mut diags = output.unwrap_to_string(); if let Some(diags_without_trailing_newlines) = diags.strip_suffix("\n\n") { diff --git a/crates/rustc_codegen_spirv/src/linker/zombies.rs b/crates/rustc_codegen_spirv/src/linker/zombies.rs index 6e73af472d..8ca0283ced 100644 --- a/crates/rustc_codegen_spirv/src/linker/zombies.rs +++ b/crates/rustc_codegen_spirv/src/linker/zombies.rs @@ -6,7 +6,8 @@ use crate::custom_insts::{self, CustomOp}; use rspirv::dr::{Instruction, Module, Operand}; use rspirv::spirv::{Op, Word}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; -use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed}; +use rustc_errors::ErrorGuaranteed; +use rustc_errors::{Diag,DiagMessage}; use rustc_session::Session; use rustc_span::{Span, DUMMY_SP}; use smallvec::SmallVec; @@ -239,7 +240,7 @@ impl<'a> ZombieReporter<'a> { fn add_use_note_to_err( &mut self, - err: &mut DiagnosticBuilder<'a, ErrorGuaranteed>, + err: &mut Diag<'a, ErrorGuaranteed>, span: Span, zombie: Zombie<'_>, zombie_use: &ZombieUse<'_>, @@ -278,7 +279,7 @@ impl<'a> ZombieReporter<'a> { fn build_errors_keyed_by_leaf_id( &mut self, zombie: Zombie<'_>, - ) -> FxIndexMap> { + ) -> FxIndexMap> { // FIXME(eddyb) this is a bit inefficient, compared to some kind of // "small map", but this is the error path, and being correct is more // important here - in particular, we don't want to ignore *any* leaves. @@ -294,7 +295,7 @@ impl<'a> ZombieReporter<'a> { let reason = self.span_regen.zombie_for_id(zombie.id).unwrap().reason; errors_keyed_by_leaf_id.insert( zombie.id, - self.sess.struct_span_err(span, reason.to_string()), + self.sess.psess.dcx.struct_span_err(span, reason.to_string()), ); } ZombieKind::Uses(zombie_uses) => { diff --git a/crates/rustc_codegen_spirv/src/spirv_type.rs b/crates/rustc_codegen_spirv/src/spirv_type.rs index 73cfdc662f..7952ce5d0e 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type.rs @@ -298,7 +298,7 @@ impl SpirvType<'_> { ref other => cx .tcx .sess - .fatal(format!("def_with_id invalid for type {other:?}")), + .psess.dcx.fatal(format!("def_with_id invalid for type {other:?}")), }; cx.type_cache_def(result, self.tcx_arena_alloc_slices(cx), def_span); result diff --git a/crates/rustc_codegen_spirv/src/symbols.rs b/crates/rustc_codegen_spirv/src/symbols.rs index 4129187b39..60cf1dff51 100644 --- a/crates/rustc_codegen_spirv/src/symbols.rs +++ b/crates/rustc_codegen_spirv/src/symbols.rs @@ -545,7 +545,7 @@ fn parse_attr_int_value(arg: &NestedMetaItem) -> Result { Some(&MetaItemLit { kind: LitKind::Int(x, LitIntType::Unsuffixed), .. - }) if x <= u32::MAX as u128 => Ok(x as u32), + }) if x.get() <= u32::MAX as u128 => Ok(x.get() as u32), _ => Err((arg.span, "attribute value must be integer".to_string())), } } @@ -563,13 +563,13 @@ fn parse_local_size_attr(arg: &NestedMetaItem) -> Result<[u32; 3], ParseAttrErro NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Int(x, LitIntType::Unsuffixed), .. - }) if *x <= u32::MAX as u128 => local_size[idx] = *x as u32, + }) if x.get() <= u32::MAX as u128 => local_size[idx] = x.get() as u32, _ => return Err((lit.span(), "must be a u32 literal".to_string())), } } Ok(local_size) } - Some(tuple) if tuple.is_empty() => Err(( + Some([]) => Err(( arg.span, "#[spirv(compute(threads(x, y, z)))] must have the x dimension specified, trailing ones may be elided".to_string(), )), diff --git a/crates/rustc_codegen_spirv/src/target.rs b/crates/rustc_codegen_spirv/src/target.rs index 6b449605dc..5ccc89eccf 100644 --- a/crates/rustc_codegen_spirv/src/target.rs +++ b/crates/rustc_codegen_spirv/src/target.rs @@ -1,7 +1,7 @@ use rspirv::spirv::MemoryModel; use rustc_target::spec::{Cc, LinkerFlavor, PanicStrategy, Target, TargetOptions}; use spirv_tools::TargetEnv; - +use rustc_target::spec::TargetMetadata; const ARCH: &str = "spirv"; pub struct SpirvTarget { @@ -101,6 +101,7 @@ impl SpirvTarget { data_layout: "e-m:e-p:32:32:32-i64:64-n8:16:32:64".into(), arch: ARCH.into(), options: self.init_target_opts(), + metadata: TargetMetadata::default(), } } } diff --git a/crates/spirv-builder/README.md b/crates/spirv-builder/README.md index ffca313fd1..29faf9be15 100644 --- a/crates/spirv-builder/README.md +++ b/crates/spirv-builder/README.md @@ -2,7 +2,7 @@ # `spirv-builder` -![Rust version](https://img.shields.io/badge/rust-nightly--2023--05--27-purple.svg) +![Rust version](https://img.shields.io/badge/rust-nightly--2023--12--21-purple.svg) This crate gives you `SpirvBuilder`, a tool to build shaders using [rust-gpu][rustgpu]. @@ -31,12 +31,13 @@ const SHADER: &[u8] = include_bytes!(env!("my_shaders.spv")); As `spirv-builder` relies on `rustc_codegen_spirv` being built for it (by Cargo, as a direct dependency), and due to the special nature of the latter (as a `rustc` codegen backend "plugin"), both end up sharing the requirement for a very specific nightly toolchain version of Rust. -**The current Rust toolchain version is: `nightly-2023-05-27`.** +**The current Rust toolchain version is: `nightly-2023-12-21`.** Rust toolchain version history across [rust-gpu releases](https://github.com/EmbarkStudios/rust-gpu/releases) (since `0.4`): |`spirv-builder`
version|Rust toolchain
version| |:-:|:-:| +|`0.10`|`nightly-2023-12-21`| |`0.9`|`nightly-2023-05-27`| |`0.8`|`nightly-2023-04-15`| |`0.7`|`nightly-2023-03-04`| diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 884ca31985..495fb3a115 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2023-09-30" +channel = "nightly-2024-03-14" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72 +# commit_hash = 3cbb93223f33024db464a4df27a13c7cce870173 # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/dis/issue-1062.stderr b/tests/ui/dis/issue-1062.stderr index 49d0ff772f..a19190c5b1 100644 --- a/tests/ui/dis/issue-1062.stderr +++ b/tests/ui/dis/issue-1062.stderr @@ -4,7 +4,7 @@ OpLine %5 11 12 %6 = OpLoad %7 %8 OpLine %5 11 35 %9 = OpLoad %7 %10 -OpLine %11 1142 4 +OpLine %11 1145 4 %12 = OpBitwiseAnd %7 %9 %13 %14 = OpISub %7 %15 %12 %16 = OpShiftLeftLogical %7 %6 %12 diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index 43c045e5b8..06c839cbf0 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:2778:9 + --> $CORE_SRC/intrinsics.rs:2794:9 | -2778 | copy(src, dst, count) +2794 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2764:21 + --> $CORE_SRC/intrinsics.rs:2780:21 | -2764 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +2780 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 @@ -25,5 +25,5 @@ note: called by `main` 32 | pub fn main(i: f32, o: &mut f32) { | ^^^^ -error: aborting due to previous error +error: aborting due to 1 previous error diff --git a/tests/ui/dis/ptr_read.stderr b/tests/ui/dis/ptr_read.stderr index 722af616d8..17cc16c310 100644 --- a/tests/ui/dis/ptr_read.stderr +++ b/tests/ui/dis/ptr_read.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1183 8 +OpLine %8 1215 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_read_method.stderr b/tests/ui/dis/ptr_read_method.stderr index 722af616d8..17cc16c310 100644 --- a/tests/ui/dis/ptr_read_method.stderr +++ b/tests/ui/dis/ptr_read_method.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1183 8 +OpLine %8 1215 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_write.stderr b/tests/ui/dis/ptr_write.stderr index b86b31d184..a34bffdedc 100644 --- a/tests/ui/dis/ptr_write.stderr +++ b/tests/ui/dis/ptr_write.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 35 %9 = OpLoad %10 %4 -OpLine %11 1382 8 +OpLine %11 1415 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/dis/ptr_write_method.stderr b/tests/ui/dis/ptr_write_method.stderr index 013ba2e906..c6607d192d 100644 --- a/tests/ui/dis/ptr_write_method.stderr +++ b/tests/ui/dis/ptr_write_method.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 37 %9 = OpLoad %10 %4 -OpLine %11 1382 8 +OpLine %11 1415 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/image/query/query_levels_err.stderr b/tests/ui/image/query/query_levels_err.stderr index ae524b7ef5..2f03a3f426 100644 --- a/tests/ui/image/query/query_levels_err.stderr +++ b/tests/ui/image/query/query_levels_err.stderr @@ -18,6 +18,6 @@ note: required by a bound in `Image::::query_levels` -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/image/query/query_lod_err.stderr b/tests/ui/image/query/query_lod_err.stderr index 5ad3b758fa..0b6a9a052c 100644 --- a/tests/ui/image/query/query_lod_err.stderr +++ b/tests/ui/image/query/query_lod_err.stderr @@ -18,6 +18,6 @@ note: required by a bound in `Image::::query_lod` -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/image/query/query_size_err.stderr b/tests/ui/image/query/query_size_err.stderr index 9311a1d78b..b35b9c1298 100644 --- a/tests/ui/image/query/query_size_err.stderr +++ b/tests/ui/image/query/query_size_err.stderr @@ -23,6 +23,6 @@ note: required by a bound in `Image::::query_size` -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/image/query/query_size_lod_err.stderr b/tests/ui/image/query/query_size_lod_err.stderr index ed06527761..20464eb29a 100644 --- a/tests/ui/image/query/query_size_lod_err.stderr +++ b/tests/ui/image/query/query_size_lod_err.stderr @@ -18,6 +18,6 @@ note: required by a bound in `Image::::query_size_lod` -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/lang/control_flow/issue_764.stderr b/tests/ui/lang/control_flow/issue_764.stderr index fc05159549..7e5182792d 100644 --- a/tests/ui/lang/control_flow/issue_764.stderr +++ b/tests/ui/lang/control_flow/issue_764.stderr @@ -1,4 +1,4 @@ error: module has recursion, which is not allowed: `<(i32, issue_764::Transform2D) as issue_764::GivesFinalTransform>::get_final_transform` calls `<(i32, issue_764::Transform2D) as issue_764::GivesFinalTransform>::get_final_transform` -error: aborting due to previous error +error: aborting due to 1 previous error diff --git a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr index a85b884892..b52a31b6a3 100644 --- a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr +++ b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr @@ -1,3 +1,12 @@ +warning: the feature `ptr_internals` is internal to the compiler or standard library + --> $DIR/allocate_const_scalar.rs:6:12 + | +6 | #![feature(ptr_internals)] + | ^^^^^^^^^^^^^ + | + = note: using it is strongly discouraged + = note: `#[warn(internal_features)]` on by default + error: pointer has non-null integer address | note: used from within `allocate_const_scalar::main` @@ -11,5 +20,5 @@ note: called by `main` 15 | pub fn main(output: &mut Unique<[u8; 4]>) { | ^^^^ -error: aborting due to previous error +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/lang/core/ptr/allocate_vec_like.stderr b/tests/ui/lang/core/ptr/allocate_vec_like.stderr new file mode 100644 index 0000000000..d4376b8486 --- /dev/null +++ b/tests/ui/lang/core/ptr/allocate_vec_like.stderr @@ -0,0 +1,11 @@ +warning: the feature `ptr_internals` is internal to the compiler or standard library + --> $DIR/allocate_vec_like.rs:4:12 + | +4 | #![feature(ptr_internals)] + | ^^^^^^^^^^^^^ + | + = note: using it is strongly discouraged + = note: `#[warn(internal_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/lang/core/ref/member_ref_arg-broken.stderr b/tests/ui/lang/core/ref/member_ref_arg-broken.stderr index 0c0759c940..66dee4fc15 100644 --- a/tests/ui/lang/core/ref/member_ref_arg-broken.stderr +++ b/tests/ui/lang/core/ref/member_ref_arg-broken.stderr @@ -8,5 +8,5 @@ error: error:0:0 - OpLoad Pointer '$ID[%$ID]' is not a logical pointer. = note: spirv-val failed = note: module `$TEST_BUILD_DIR/lang/core/ref/member_ref_arg-broken.default` -error: aborting due to previous error; 2 warnings emitted +error: aborting due to 1 previous error; 2 warnings emitted diff --git a/tests/ui/lang/core/unwrap_or.stderr b/tests/ui/lang/core/unwrap_or.stderr index 3b3100c773..8448d926fe 100644 --- a/tests/ui/lang/core/unwrap_or.stderr +++ b/tests/ui/lang/core/unwrap_or.stderr @@ -3,9 +3,9 @@ OpLine %5 13 11 %6 = OpCompositeInsert %7 %8 %9 0 %10 = OpCompositeExtract %11 %6 1 -OpLine %12 956 14 +OpLine %12 952 14 %13 = OpBitcast %14 %8 -OpLine %12 956 8 +OpLine %12 952 8 %15 = OpIEqual %16 %13 %17 OpNoLine OpSelectionMerge %18 None diff --git a/tests/ui/spirv-attr/invalid-matrix-type-empty.stderr b/tests/ui/spirv-attr/invalid-matrix-type-empty.stderr index 6a02d04dd9..d34ef0ac5e 100644 --- a/tests/ui/spirv-attr/invalid-matrix-type-empty.stderr +++ b/tests/ui/spirv-attr/invalid-matrix-type-empty.stderr @@ -4,5 +4,5 @@ error: #[spirv(matrix)] type must have at least two fields 7 | pub struct EmptyStruct {} | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 1 previous error diff --git a/tests/ui/spirv-attr/invalid-target.rs b/tests/ui/spirv-attr/invalid-target.rs index 9bc0c525cf..2dbd5bb106 100644 --- a/tests/ui/spirv-attr/invalid-target.rs +++ b/tests/ui/spirv-attr/invalid-target.rs @@ -288,7 +288,8 @@ fn _fn( vertex, // fn-only uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only )] - (1, 2, 3) // expression + (1, 2, 3) + // expression ); match () { diff --git a/tests/ui/spirv-attr/invalid-target.stderr b/tests/ui/spirv-attr/invalid-target.stderr index d659b95039..c8733ab54f 100644 --- a/tests/ui/spirv-attr/invalid-target.stderr +++ b/tests/ui/spirv-attr/invalid-target.stderr @@ -1583,267 +1583,267 @@ error: attribute is only valid on a function parameter, not on a expression | ^^^^^^^^^ error: attribute is only valid on a struct, not on a match arm - --> $DIR/invalid-target.rs:296:13 + --> $DIR/invalid-target.rs:297:13 | -296 | sampler, block, sampled_image, generic_image_type, // struct-only +297 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^ error: attribute is only valid on a struct, not on a match arm - --> $DIR/invalid-target.rs:296:22 + --> $DIR/invalid-target.rs:297:22 | -296 | sampler, block, sampled_image, generic_image_type, // struct-only +297 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^ error: attribute is only valid on a struct, not on a match arm - --> $DIR/invalid-target.rs:296:29 + --> $DIR/invalid-target.rs:297:29 | -296 | sampler, block, sampled_image, generic_image_type, // struct-only +297 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^ error: attribute is only valid on a struct, not on a match arm - --> $DIR/invalid-target.rs:296:44 + --> $DIR/invalid-target.rs:297:44 | -296 | sampler, block, sampled_image, generic_image_type, // struct-only +297 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function, not on a match arm - --> $DIR/invalid-target.rs:297:13 + --> $DIR/invalid-target.rs:298:13 | -297 | vertex, // fn-only +298 | vertex, // fn-only | ^^^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:13 + --> $DIR/invalid-target.rs:299:13 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:22 + --> $DIR/invalid-target.rs:299:22 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:32 + --> $DIR/invalid-target.rs:299:32 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:52 + --> $DIR/invalid-target.rs:299:52 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:65 + --> $DIR/invalid-target.rs:299:65 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:71 + --> $DIR/invalid-target.rs:299:71 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^ error: attribute is only valid on a struct, not on a lifetime parameter - --> $DIR/invalid-target.rs:306:9 + --> $DIR/invalid-target.rs:307:9 | -306 | sampler, block, sampled_image, generic_image_type, // struct-only +307 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^ error: attribute is only valid on a struct, not on a lifetime parameter - --> $DIR/invalid-target.rs:306:18 + --> $DIR/invalid-target.rs:307:18 | -306 | sampler, block, sampled_image, generic_image_type, // struct-only +307 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^ error: attribute is only valid on a struct, not on a lifetime parameter - --> $DIR/invalid-target.rs:306:25 + --> $DIR/invalid-target.rs:307:25 | -306 | sampler, block, sampled_image, generic_image_type, // struct-only +307 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^ error: attribute is only valid on a struct, not on a lifetime parameter - --> $DIR/invalid-target.rs:306:40 + --> $DIR/invalid-target.rs:307:40 | -306 | sampler, block, sampled_image, generic_image_type, // struct-only +307 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function, not on a lifetime parameter - --> $DIR/invalid-target.rs:307:9 + --> $DIR/invalid-target.rs:308:9 | -307 | vertex, // fn-only +308 | vertex, // fn-only | ^^^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:9 + --> $DIR/invalid-target.rs:309:9 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:18 + --> $DIR/invalid-target.rs:309:18 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:28 + --> $DIR/invalid-target.rs:309:28 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:48 + --> $DIR/invalid-target.rs:309:48 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:61 + --> $DIR/invalid-target.rs:309:61 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:67 + --> $DIR/invalid-target.rs:309:67 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^ error: attribute is only valid on a struct, not on a type parameter - --> $DIR/invalid-target.rs:311:9 + --> $DIR/invalid-target.rs:312:9 | -311 | sampler, block, sampled_image, generic_image_type, // struct-only +312 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^ error: attribute is only valid on a struct, not on a type parameter - --> $DIR/invalid-target.rs:311:18 + --> $DIR/invalid-target.rs:312:18 | -311 | sampler, block, sampled_image, generic_image_type, // struct-only +312 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^ error: attribute is only valid on a struct, not on a type parameter - --> $DIR/invalid-target.rs:311:25 + --> $DIR/invalid-target.rs:312:25 | -311 | sampler, block, sampled_image, generic_image_type, // struct-only +312 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^ error: attribute is only valid on a struct, not on a type parameter - --> $DIR/invalid-target.rs:311:40 + --> $DIR/invalid-target.rs:312:40 | -311 | sampler, block, sampled_image, generic_image_type, // struct-only +312 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function, not on a type parameter - --> $DIR/invalid-target.rs:312:9 + --> $DIR/invalid-target.rs:313:9 | -312 | vertex, // fn-only +313 | vertex, // fn-only | ^^^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:9 + --> $DIR/invalid-target.rs:314:9 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:18 + --> $DIR/invalid-target.rs:314:18 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:28 + --> $DIR/invalid-target.rs:314:28 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:48 + --> $DIR/invalid-target.rs:314:48 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:61 + --> $DIR/invalid-target.rs:314:61 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:67 + --> $DIR/invalid-target.rs:314:67 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^ error: attribute is only valid on a struct, not on a const parameter - --> $DIR/invalid-target.rs:316:9 + --> $DIR/invalid-target.rs:317:9 | -316 | sampler, block, sampled_image, generic_image_type, // struct-only +317 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^ error: attribute is only valid on a struct, not on a const parameter - --> $DIR/invalid-target.rs:316:18 + --> $DIR/invalid-target.rs:317:18 | -316 | sampler, block, sampled_image, generic_image_type, // struct-only +317 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^ error: attribute is only valid on a struct, not on a const parameter - --> $DIR/invalid-target.rs:316:25 + --> $DIR/invalid-target.rs:317:25 | -316 | sampler, block, sampled_image, generic_image_type, // struct-only +317 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^ error: attribute is only valid on a struct, not on a const parameter - --> $DIR/invalid-target.rs:316:40 + --> $DIR/invalid-target.rs:317:40 | -316 | sampler, block, sampled_image, generic_image_type, // struct-only +317 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function, not on a const parameter - --> $DIR/invalid-target.rs:317:9 + --> $DIR/invalid-target.rs:318:9 | -317 | vertex, // fn-only +318 | vertex, // fn-only | ^^^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:9 + --> $DIR/invalid-target.rs:319:9 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:18 + --> $DIR/invalid-target.rs:319:18 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:28 + --> $DIR/invalid-target.rs:319:28 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:48 + --> $DIR/invalid-target.rs:319:48 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:61 + --> $DIR/invalid-target.rs:319:61 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:67 + --> $DIR/invalid-target.rs:319:67 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^ error: attribute is only valid on a struct, not on a associated type diff --git a/tests/ui/spirv-attr/invariant-invalid.stderr b/tests/ui/spirv-attr/invariant-invalid.stderr index 4ba05ebacc..8db5f32424 100644 --- a/tests/ui/spirv-attr/invariant-invalid.stderr +++ b/tests/ui/spirv-attr/invariant-invalid.stderr @@ -4,5 +4,5 @@ error: `#[spirv(invariant)]` is only valid on Output variables 7 | pub fn main(#[spirv(invariant)] input: f32) {} | ^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 1 previous error diff --git a/tests/ui/storage_class/runtime_descriptor_array_error.stderr b/tests/ui/storage_class/runtime_descriptor_array_error.stderr index efe0352a43..a6025a5fd0 100644 --- a/tests/ui/storage_class/runtime_descriptor_array_error.stderr +++ b/tests/ui/storage_class/runtime_descriptor_array_error.stderr @@ -10,5 +10,5 @@ warning: use &[T] instead of &RuntimeArray 8 | #[spirv(uniform, descriptor_set = 0, binding = 0)] two: &RuntimeArray, | ^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error; 1 warning emitted +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/target_features_err.stderr b/tests/ui/target_features_err.stderr index 8b5b679cb0..9195a361f2 100644 --- a/tests/ui/target_features_err.stderr +++ b/tests/ui/target_features_err.stderr @@ -1,4 +1,4 @@ error: Invalid Capability: `rayTracingKHR` -error: aborting due to previous error +error: aborting due to 1 previous error