From dbada91cb7ba6a0ad6780eac4da000c27df0fd8c Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 6 Jun 2023 01:08:13 +0300 Subject: [PATCH] rustup: update to `nightly-2023-05-27`. --- CHANGELOG.md | 3 + crates/rustc_codegen_spirv/build.rs | 4 +- crates/rustc_codegen_spirv/src/abi.rs | 6 +- crates/rustc_codegen_spirv/src/attr.rs | 6 +- .../src/builder/builder_methods.rs | 25 ++++++-- .../src/builder/byte_addressable_buffer.rs | 4 +- crates/rustc_codegen_spirv/src/builder/mod.rs | 14 +---- .../src/builder/spirv_asm.rs | 4 +- .../rustc_codegen_spirv/src/builder_spirv.rs | 2 +- .../src/codegen_cx/declare.rs | 2 +- .../src/codegen_cx/entry.rs | 3 +- crates/rustc_codegen_spirv/src/lib.rs | 63 +++++-------------- crates/rustc_codegen_spirv/src/link.rs | 22 +++---- .../src/linker/import_export_link.rs | 6 +- crates/rustc_codegen_spirv/src/linker/mod.rs | 11 ++++ .../src/linker/simple_passes.rs | 4 +- .../src/linker/spirt_passes/diagnostics.rs | 2 +- crates/rustc_codegen_spirv/src/linker/test.rs | 1 + .../rustc_codegen_spirv/src/linker/zombies.rs | 5 +- crates/spirv-builder/README.md | 4 +- crates/spirv-builder/src/lib.rs | 4 ++ crates/spirv-std/src/lib.rs | 1 + rust-toolchain.toml | 4 +- .../ui/arch/debug_printf_type_checking.stderr | 19 +++--- .../ui/dis/entry-pass-mode-cast-array.stderr | 29 +++++++-- tests/ui/dis/issue-731.stderr | 29 +++++++-- tests/ui/dis/ptr_copy.normal.stderr | 8 +-- tests/ui/dis/ptr_read.stderr | 2 +- tests/ui/dis/ptr_read_method.stderr | 2 +- tests/ui/dis/ptr_write.stderr | 2 +- tests/ui/dis/ptr_write_method.stderr | 2 +- tests/ui/image/gather_err.stderr | 6 ++ tests/ui/image/query/query_levels_err.stderr | 3 + tests/ui/image/query/query_lod_err.stderr | 3 + tests/ui/image/query/query_size_err.stderr | 3 + .../ui/image/query/query_size_lod_err.stderr | 3 + .../ui/lang/core/ptr/allocate_const_scalar.rs | 5 +- .../core/ptr/allocate_const_scalar.stderr | 10 +-- tests/ui/lang/core/unwrap_or.stderr | 4 +- 39 files changed, 195 insertions(+), 135 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd38470c57..bf8a59a998 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed 🛠 +- [PR#1071](https://github.com/EmbarkStudios/rust-gpu/pull/1071) updated toolchain to `nightly-2023-05-27` + ## [0.8.0] ### Added ⭐ diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index cdba396c33..0ddd6b78ec 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"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2023-04-15" +channel = "nightly-2023-05-27" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] -# commit_hash = 84dd17b56a931a631a23dfd5ef2018fd3ef49108"#; +# commit_hash = 1a5f8bce74ee432f7cc3aa131bc3d6920e06de10"#; 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 636069e530..f2260dfc80 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -7,9 +7,9 @@ use crate::spirv_type::SpirvType; use rspirv::spirv::{StorageClass, Word}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::ErrorGuaranteed; -use rustc_index::vec::Idx; +use rustc_index::Idx; +use rustc_middle::query::{ExternProviders, Providers}; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout}; -use rustc_middle::ty::query::{ExternProviders, Providers}; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{ self, Const, FloatTy, GeneratorSubsts, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind, @@ -972,7 +972,7 @@ fn trans_intrinsic_type<'tcx>( .tcx .sess .struct_span_err(span, "#[spirv(matrix)] type fields must all be vectors") - .note(&format!("field type is {}", ty.debug(elem_type, cx))) + .note(format!("field type is {}", ty.debug(elem_type, cx))) .emit()); } } diff --git a/crates/rustc_codegen_spirv/src/attr.rs b/crates/rustc_codegen_spirv/src/attr.rs index 313948816b..d668146113 100644 --- a/crates/rustc_codegen_spirv/src/attr.rs +++ b/crates/rustc_codegen_spirv/src/attr.rs @@ -11,7 +11,7 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{HirId, MethodKind, Target, CRATE_HIR_ID}; use rustc_middle::hir::nested_filter; -use rustc_middle::ty::query::Providers; +use rustc_middle::query::Providers; use rustc_middle::ty::TyCtxt; use rustc_span::{Span, Symbol}; use std::rc::Rc; @@ -369,9 +369,9 @@ impl CheckSpirvAttrVisitor<'_> { .sess .struct_span_err( span, - &format!("only one {category} attribute is allowed on a {target}"), + format!("only one {category} attribute is allowed on a {target}"), ) - .span_note(prev_span, &format!("previous {category} attribute")) + .span_note(prev_span, format!("previous {category} attribute")) .emit(); } }, diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 4669c6b338..6af845e7b7 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -18,6 +18,7 @@ use rustc_codegen_ssa::traits::{ use rustc_codegen_ssa::MemFlags; use rustc_data_structures::fx::FxHashSet; use rustc_middle::bug; +use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::ty::Ty; use rustc_span::Span; use rustc_target::abi::call::FnAbi; @@ -760,9 +761,19 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { then_llbb: Self::BasicBlock, else_llbb: Self::BasicBlock, ) { - self.emit() - .branch_conditional(cond.def(self), then_llbb, else_llbb, empty()) - .unwrap(); + let cond = cond.def(self); + + // HACK(eddyb) constant-fold branches early on, as the `core` library is + // starting to get a lot of `if cfg!(debug_assertions)` added to it. + match self.builder.lookup_const_by_id(cond) { + Some(SpirvConst::Bool(true)) => self.br(then_llbb), + Some(SpirvConst::Bool(false)) => self.br(else_llbb), + _ => { + self.emit() + .branch_conditional(cond, then_llbb, else_llbb, empty()) + .unwrap(); + } + } } fn switch( @@ -840,6 +851,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { fn invoke( &mut self, llty: Self::Type, + fn_attrs: Option<&CodegenFnAttrs>, fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>, llfn: Self::Value, args: &[Self::Value], @@ -848,7 +860,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { funclet: Option<&Self::Funclet>, ) -> Self::Value { // Exceptions don't exist, jump directly to then block - let result = self.call(llty, fn_abi, llfn, args, funclet); + let result = self.call(llty, fn_attrs, fn_abi, llfn, args, funclet); self.emit().branch(then).unwrap(); result } @@ -2095,6 +2107,10 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { todo!() } + fn filter_landing_pad(&mut self, _pers_fn: Self::Value) -> (Self::Value, Self::Value) { + todo!() + } + fn resume(&mut self, _exn0: Self::Value, _exn1: Self::Value) { todo!() } @@ -2309,6 +2325,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { fn call( &mut self, callee_ty: Self::Type, + _fn_attrs: Option<&CodegenFnAttrs>, _fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>, callee: Self::Value, args: &[Self::Value], diff --git a/crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs b/crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs index 48327f6623..e918a82f6a 100644 --- a/crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs +++ b/crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs @@ -15,7 +15,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.debug_type(original_type) )); if original_type != invalid_type { - err.note(&format!( + err.note(format!( "due to containing type {}", self.debug_type(invalid_type) )); @@ -210,7 +210,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.debug_type(original_type) )); if original_type != value.ty { - err.note(&format!("due to containing type {}", value.ty)); + err.note(format!("due to containing type {}", value.ty)); } Err(err.emit()) } diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index 4771ad2463..7ac0f4a2f5 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -438,16 +438,4 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for Builder<'_, 'tcx> { } } -impl<'tcx> TypeMembershipMethods<'tcx> for CodegenCx<'tcx> { - fn set_type_metadata(&self, _function: Self::Function, _typeid: String) { - // ignore - } - - fn typeid_metadata(&self, _typeid: String) -> Self::Value { - todo!() - } - - fn set_kcfi_type_metadata(&self, _function: Self::Function, _typeid: u32) { - // ignore - } -} +impl<'tcx> TypeMembershipMethods<'tcx> for CodegenCx<'tcx> {} diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index 976e18cb93..fe02bf9c8e 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -306,10 +306,10 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { 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!( + .note(format!( "`{storage_class:?}` storage class was specified" )) - .help(&format!( + .help(format!( "the storage class will be inferred automatically (e.g. to `{storage_class:?}`)" )) .emit(); diff --git a/crates/rustc_codegen_spirv/src/builder_spirv.rs b/crates/rustc_codegen_spirv/src/builder_spirv.rs index d0899749d4..a2b64a8b69 100644 --- a/crates/rustc_codegen_spirv/src/builder_spirv.rs +++ b/crates/rustc_codegen_spirv/src/builder_spirv.rs @@ -152,7 +152,7 @@ impl SpirvValue { cx.tcx .sess .struct_span_err(span, "Can't use type as a value") - .note(&format!("Type: *{}", cx.debug_type(id))) + .note(format!("Type: *{}", cx.debug_type(id))) .emit(); id diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs index 0f1d86857f..ce28a66f54 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs @@ -36,7 +36,7 @@ fn attrs_to_spirv(attrs: &CodegenFnAttrs) -> FunctionControl { impl<'tcx> CodegenCx<'tcx> { /// Returns a function if it already exists, or declares a header if it doesn't. pub fn get_fn_ext(&self, instance: Instance<'tcx>) -> SpirvValue { - assert!(!instance.substs.needs_infer()); + assert!(!instance.substs.has_infer()); assert!(!instance.substs.has_escaping_bound_vars()); if let Some(&func) = self.instances.borrow().get(&instance) { diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs index 6b6bee6550..0cd3c21fb1 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs @@ -191,6 +191,7 @@ impl<'tcx> CodegenCx<'tcx> { bx.set_span(span); bx.call( entry_func.ty, + None, Some(entry_fn_abi), entry_func, &call_args, @@ -317,7 +318,7 @@ impl<'tcx> CodegenCx<'tcx> { ) .span_help( storage_class_attr.span, - &format!( + format!( "remove storage class attribute to use `{deduced:?}` as storage class" ), ) diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 3e944094be..72bd14c2a1 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -103,8 +103,9 @@ use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility}; use rustc_middle::mir::pretty::write_mir_pretty; +use rustc_middle::query; use rustc_middle::ty::print::with_no_trimmed_paths; -use rustc_middle::ty::{self, query, Instance, InstanceDef, TyCtxt}; +use rustc_middle::ty::{self, Instance, InstanceDef, TyCtxt}; use rustc_session::config::{self, OutputFilenames, OutputType}; use rustc_session::Session; use rustc_span::symbol::{sym, Symbol}; @@ -137,7 +138,7 @@ fn is_blocklisted_fn<'tcx>( instance: Instance<'tcx>, ) -> bool { // TODO: These sometimes have a constant value of an enum variant with a hole - if let InstanceDef::Item(def) = instance.def { + if let InstanceDef::Item(def_id) = instance.def { if let Some(debug_trait_def_id) = tcx.get_diagnostic_item(sym::Debug) { // Helper for detecting `<_ as core::fmt::Debug>::fmt` (in impls). let is_debug_fmt_method = |def_id| match tcx.opt_associated_item(def_id) { @@ -153,12 +154,12 @@ fn is_blocklisted_fn<'tcx>( _ => false, }; - if is_debug_fmt_method(def.did) { + if is_debug_fmt_method(def_id) { return true; } - if tcx.opt_item_ident(def.did).map(|i| i.name) == Some(sym.fmt_decimal) { - if let Some(parent_def_id) = tcx.opt_parent(def.did) { + if tcx.opt_item_ident(def_id).map(|i| i.name) == Some(sym.fmt_decimal) { + if let Some(parent_def_id) = tcx.opt_parent(def_id) { if is_debug_fmt_method(parent_def_id) { return true; } @@ -491,47 +492,17 @@ impl Drop for DumpModuleOnPanic<'_, '_, '_> { /// This is the entrypoint for a hot plugged `rustc_codegen_spirv` #[no_mangle] pub fn __rustc_codegen_backend() -> Box { - // Override rustc's panic hook with our own to override the ICE error - // message, and direct people to `rust-gpu`. - let _rustc_hook = std::panic::take_hook(); - let default_hook = std::panic::take_hook(); - { - // NOTE(eddyb) the reason we can get access to the default panic hook, - // is that `std::panic::take_hook` has this phrase in its documentation: - // - // > If no custom hook is registered, the default hook will be returned. - // - // But just in case (races with other threads?), we can do it a few more - // times, and require that we get the same "boxed" ZST every time. - let more_hooks = [ - std::panic::take_hook(), - std::panic::take_hook(), - std::panic::take_hook(), - std::panic::take_hook(), - ]; - assert_eq!( - std::mem::size_of_val(&*default_hook), - 0, - "failed to acquire default panic hook using `std::panic::take_hook`, \ - or default panic hook not a ZST anymore" - ); - #[allow(clippy::vtable_address_comparisons)] - for other_hook in more_hooks { - assert!( - std::ptr::eq(&*default_hook, &*other_hook), - "failed to acquire default panic hook using `std::panic::take_hook`, \ - or `std::panic::set_hook` was used on another thread" - ); - } - } - std::panic::set_hook(Box::new(move |panic_info| { - default_hook(panic_info); - rustc_driver::report_ice( - panic_info, - "https://github.com/EmbarkStudios/rust-gpu/issues/new", - ); - eprintln!("note: `rust-gpu` version {}\n", env!("CARGO_PKG_VERSION")); - })); + // Tweak rustc's default ICE panic hook, to direct people to `rust-gpu`. + rustc_driver::install_ice_hook( + "https://github.com/EmbarkStudios/rust-gpu/issues/new", + |handler| { + handler.note_without_error(concat!( + "`rust-gpu` version `", + env!("CARGO_PKG_VERSION"), + "`" + )); + }, + ); Box::new(SpirvCodegenBackend) } diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index 1acfde5cb3..84ee4db4d5 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -274,8 +274,8 @@ fn post_link_single_module( 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"); - err.note(&format!("module `{}`", out_filename.display())); - err.note(&format!("I/O error: {e:#}")); + err.note(format!("module `{}`", out_filename.display())); + err.note(format!("I/O error: {e:#}")); err.emit(); } @@ -324,14 +324,14 @@ fn do_spirv_opt( 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() + sess.struct_err(msg.message).forget_guarantee() } - 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), + 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.note(format!("module `{}`", filename.display())); err.emit(); }, Some(options), @@ -341,9 +341,9 @@ 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.struct_warn(e.to_string()); err.note("spirv-opt failed, leaving as unoptimized"); - err.note(&format!("module `{}`", filename.display())); + err.note(format!("module `{}`", filename.display())); err.emit(); spv_binary } @@ -361,9 +361,9 @@ 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.struct_err(e.to_string()); err.note("spirv-val failed"); - err.note(&format!("module `{}`", filename.display())); + err.note(format!("module `{}`", filename.display())); err.emit(); } } 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 0d5ae69c0d..160a1dd1c7 100644 --- a/crates/rustc_codegen_spirv/src/linker/import_export_link.rs +++ b/crates/rustc_codegen_spirv/src/linker/import_export_link.rs @@ -184,12 +184,12 @@ fn check_tys_equal( result } Err(sess - .struct_err(&format!("Types mismatch for {name:?}")) - .note(&format!( + .struct_err(format!("Types mismatch for {name:?}")) + .note(format!( "import type: {}", format_ty_(&ty_defs, import_type) )) - .note(&format!( + .note(format!( "export type: {}", format_ty_(&ty_defs, export_type) )) diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index bd182610e0..9c777eff9f 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -225,6 +225,17 @@ pub fn link( } if opts.early_report_zombies { + // HACK(eddyb) `report_and_remove_zombies` is bad at determining whether + // some things are dead (such as whole blocks), and there's no reason to + // *not* run DCE, given SPIR-T exists and makes DCE mandatory, but we're + // still only going to do the minimum necessary ("block ordering"). + { + let _timer = sess.timer("link_block_ordering_pass-before-report_and_remove_zombies"); + for func in &mut output.functions { + simple_passes::block_ordering_pass(func); + } + } + let _timer = sess.timer("link_report_and_remove_zombies"); zombies::report_and_remove_zombies(sess, opts, &mut output)?; } diff --git a/crates/rustc_codegen_spirv/src/linker/simple_passes.rs b/crates/rustc_codegen_spirv/src/linker/simple_passes.rs index 7bd0ca285a..7ca44add13 100644 --- a/crates/rustc_codegen_spirv/src/linker/simple_passes.rs +++ b/crates/rustc_codegen_spirv/src/linker/simple_passes.rs @@ -245,11 +245,11 @@ pub fn check_fragment_insts(sess: &Session, module: &Module) -> Result<()> { .collect::>() .join("\n"); any_err = Some( - sess.struct_err(&format!( + sess.struct_err(format!( "{} cannot be used outside a fragment shader", inst.class.opname )) - .note(¬e) + .note(note) .emit(), ); } 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 c16b3d62bb..38eeb3016f 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs @@ -425,7 +425,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); + let mut err = self.sess.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); } diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 4b8ea449cc..0dfbcade1c 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -115,6 +115,7 @@ fn link_with_linker_opts( Default::default(), None, None, + rustc_interface::util::rustc_version_str().unwrap_or("unknown"), ); // HACK(eddyb) inject `write_diags` into `sess`, to work around diff --git a/crates/rustc_codegen_spirv/src/linker/zombies.rs b/crates/rustc_codegen_spirv/src/linker/zombies.rs index d91c459abd..6e73af472d 100644 --- a/crates/rustc_codegen_spirv/src/linker/zombies.rs +++ b/crates/rustc_codegen_spirv/src/linker/zombies.rs @@ -292,7 +292,10 @@ impl<'a> ZombieReporter<'a> { match zombie.kind { ZombieKind::Leaf => { 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)); + errors_keyed_by_leaf_id.insert( + zombie.id, + self.sess.struct_span_err(span, reason.to_string()), + ); } ZombieKind::Uses(zombie_uses) => { for zombie_use in zombie_uses { diff --git a/crates/spirv-builder/README.md b/crates/spirv-builder/README.md index 7d3cc9f801..62a52e6f03 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--04--15-purple.svg) +![Rust version](https://img.shields.io/badge/rust-nightly--2023--05--27-purple.svg) This crate gives you `SpirvBuilder`, a tool to build shaders using [rust-gpu][rustgpu]. @@ -31,7 +31,7 @@ const SHADER: &[u8] = include_bytes!(env!("my_shaders.spv")); Because of its nature, `rustc_codegen_spirv`, and therefore `spirv-builder` by extension, require the use of a very specific nightly toolchain of Rust. -**The current toolchain is: `nightly-2023-04-15`.** +**The current toolchain is: `nightly-2023-05-27`.** Toolchains for previous versions of `spirv-builder`: diff --git a/crates/spirv-builder/src/lib.rs b/crates/spirv-builder/src/lib.rs index 1da5627e5a..b38579fff8 100644 --- a/crates/spirv-builder/src/lib.rs +++ b/crates/spirv-builder/src/lib.rs @@ -440,6 +440,10 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result { "-Csymbol-mangling-version=v0".to_string(), "-Zcrate-attr=feature(register_tool)".to_string(), "-Zcrate-attr=register_tool(rust_gpu)".to_string(), + // HACK(eddyb) this is the same configuration that we test with, and + // ensures no unwanted surprises from e.g. `core` debug assertions. + "-Coverflow-checks=off".to_string(), + "-Cdebug-assertions=off".to_string(), ]; // Wrapper for `env::var` that appropriately informs Cargo of the dependency. diff --git a/crates/spirv-std/src/lib.rs b/crates/spirv-std/src/lib.rs index d26e66926f..b9f993565f 100644 --- a/crates/spirv-std/src/lib.rs +++ b/crates/spirv-std/src/lib.rs @@ -89,6 +89,7 @@ #![warn(missing_docs)] #![doc = include_str!("../README.md")] +/// Public re-export of the `spirv-std-macros` crate. #[macro_use] pub extern crate spirv_std_macros as macros; pub use macros::spirv; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 3f12fdf965..639bbf34b6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2023-04-15" +channel = "nightly-2023-05-27" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] -# commit_hash = 84dd17b56a931a631a23dfd5ef2018fd3ef49108 +# commit_hash = 1a5f8bce74ee432f7cc3aa131bc3d6920e06de10 # 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/arch/debug_printf_type_checking.stderr b/tests/ui/arch/debug_printf_type_checking.stderr index 228b6ad358..194c322f59 100644 --- a/tests/ui/arch/debug_printf_type_checking.stderr +++ b/tests/ui/arch/debug_printf_type_checking.stderr @@ -75,9 +75,9 @@ help: the return type of this call is `u32` due to the type of the argument pass | | | this argument influences the return type of `spirv_std` note: function defined here - --> $SPIRV_STD_SRC/lib.rs:134:8 + --> $SPIRV_STD_SRC/lib.rs:135:8 | -134 | pub fn debug_printf_assert_is_type(ty: T) -> T { +135 | pub fn debug_printf_assert_is_type(ty: T) -> T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info) help: change the type of the numeric literal from `u32` to `f32` @@ -102,9 +102,9 @@ help: the return type of this call is `f32` due to the type of the argument pass | | | this argument influences the return type of `spirv_std` note: function defined here - --> $SPIRV_STD_SRC/lib.rs:134:8 + --> $SPIRV_STD_SRC/lib.rs:135:8 | -134 | pub fn debug_printf_assert_is_type(ty: T) -> T { +135 | pub fn debug_printf_assert_is_type(ty: T) -> T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info) help: change the type of the numeric literal from `f32` to `u32` @@ -132,9 +132,12 @@ error[E0277]: the trait bound `{float}: Vector` is not satisfied > and 5 others note: required by a bound in `debug_printf_assert_is_vector` - --> $SPIRV_STD_SRC/lib.rs:141:8 + --> $SPIRV_STD_SRC/lib.rs:142:8 | -141 | V: crate::vector::Vector, +140 | pub fn debug_printf_assert_is_vector< + | ----------------------------- required by a bound in this function +141 | TY: crate::scalar::Scalar, +142 | V: crate::vector::Vector, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `debug_printf_assert_is_vector` error[E0308]: mismatched types @@ -154,9 +157,9 @@ help: the return type of this call is `Vec2` due to the type of the argument pas | | | this argument influences the return type of `spirv_std` note: function defined here - --> $SPIRV_STD_SRC/lib.rs:134:8 + --> $SPIRV_STD_SRC/lib.rs:135:8 | -134 | pub fn debug_printf_assert_is_type(ty: T) -> T { +135 | pub fn debug_printf_assert_is_type(ty: T) -> T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/dis/entry-pass-mode-cast-array.stderr b/tests/ui/dis/entry-pass-mode-cast-array.stderr index 5fd5cdd459..8ea20c5d49 100644 --- a/tests/ui/dis/entry-pass-mode-cast-array.stderr +++ b/tests/ui/dis/entry-pass-mode-cast-array.stderr @@ -3,11 +3,30 @@ OpLine %5 13 12 %6 = OpLoad %7 %8 OpLine %5 14 4 -%9 = OpCompositeExtract %10 %6 0 -%11 = OpFAdd %10 %9 %12 -%13 = OpCompositeInsert %7 %11 %6 0 -OpLine %5 15 4 -OpStore %14 %13 +%9 = OpULessThan %10 %11 %12 OpNoLine +OpSelectionMerge %13 None +OpBranchConditional %9 %14 %15 +%14 = OpLabel +OpLine %5 14 4 +%16 = OpCompositeExtract %17 %6 0 +%18 = OpFAdd %17 %16 %19 +%20 = OpCompositeInsert %7 %18 %6 0 +OpLine %5 15 4 +OpStore %21 %20 +OpNoLine +OpBranch %13 +%15 = OpLabel +OpBranch %22 +%22 = OpLabel +OpLoopMerge %23 %24 None +OpBranch %25 +%25 = OpLabel +OpBranch %24 +%24 = OpLabel +OpBranch %22 +%23 = OpLabel +OpBranch %13 +%13 = OpLabel OpReturn OpFunctionEnd diff --git a/tests/ui/dis/issue-731.stderr b/tests/ui/dis/issue-731.stderr index 78fdc54539..73dd5abe65 100644 --- a/tests/ui/dis/issue-731.stderr +++ b/tests/ui/dis/issue-731.stderr @@ -3,11 +3,30 @@ OpLine %5 11 12 %6 = OpLoad %7 %8 OpLine %5 12 4 -%9 = OpCompositeExtract %10 %6 0 -%11 = OpFAdd %10 %9 %12 -%13 = OpCompositeInsert %7 %11 %6 0 -OpLine %5 13 4 -OpStore %14 %13 +%9 = OpULessThan %10 %11 %12 OpNoLine +OpSelectionMerge %13 None +OpBranchConditional %9 %14 %15 +%14 = OpLabel +OpLine %5 12 4 +%16 = OpCompositeExtract %17 %6 0 +%18 = OpFAdd %17 %16 %19 +%20 = OpCompositeInsert %7 %18 %6 0 +OpLine %5 13 4 +OpStore %21 %20 +OpNoLine +OpBranch %13 +%15 = OpLabel +OpBranch %22 +%22 = OpLabel +OpLoopMerge %23 %24 None +OpBranch %25 +%25 = OpLabel +OpBranch %24 +%24 = OpLabel +OpBranch %22 +%23 = OpLabel +OpBranch %13 +%13 = OpLabel OpReturn OpFunctionEnd diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index fc05bc31fe..15e50f796a 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:2724:9 + --> $CORE_SRC/intrinsics.rs:2760:9 | -2724 | copy(src, dst, count) +2760 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2710:21 + --> $CORE_SRC/intrinsics.rs:2746:21 | -2710 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +2746 | 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 diff --git a/tests/ui/dis/ptr_read.stderr b/tests/ui/dis/ptr_read.stderr index 89590afb70..f00fdb22d8 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 1188 12 +OpLine %8 1178 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 89590afb70..f00fdb22d8 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 1188 12 +OpLine %8 1178 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 c981155e3b..0cf10a1b02 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 1386 8 +OpLine %11 1376 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 35c03ba0b4..b6b4a900db 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 1386 8 +OpLine %11 1376 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/image/gather_err.stderr b/tests/ui/image/gather_err.stderr index 0460a2aa6c..f3d2f4cfe0 100644 --- a/tests/ui/image/gather_err.stderr +++ b/tests/ui/image/gather_err.stderr @@ -11,6 +11,9 @@ error[E0277]: the trait bound `Image: HasGather` is no note: required by a bound in `Image::::gather` --> $SPIRV_STD_SRC/image.rs:197:15 | +190 | pub fn gather( + | ------ required by a bound in this associated function +... 197 | Self: HasGather, | ^^^^^^^^^ required by this bound in `Image::::gather` @@ -27,6 +30,9 @@ error[E0277]: the trait bound `Image: HasGather` is no note: required by a bound in `Image::::gather` --> $SPIRV_STD_SRC/image.rs:197:15 | +190 | pub fn gather( + | ------ required by a bound in this associated function +... 197 | Self: HasGather, | ^^^^^^^^^ required by this bound in `Image::::gather` diff --git a/tests/ui/image/query/query_levels_err.stderr b/tests/ui/image/query/query_levels_err.stderr index 8dc300a8bf..ae524b7ef5 100644 --- a/tests/ui/image/query/query_levels_err.stderr +++ b/tests/ui/image/query/query_levels_err.stderr @@ -12,6 +12,9 @@ error[E0277]: the trait bound `Image: HasQueryLevels` note: required by a bound in `Image::::query_levels` --> $SPIRV_STD_SRC/image.rs:881:15 | +879 | pub fn query_levels(&self) -> u32 + | ------------ required by a bound in this associated function +880 | where 881 | Self: HasQueryLevels, | ^^^^^^^^^^^^^^ required by this bound in `Image::::query_levels` diff --git a/tests/ui/image/query/query_lod_err.stderr b/tests/ui/image/query/query_lod_err.stderr index 696b8774af..5ad3b758fa 100644 --- a/tests/ui/image/query/query_lod_err.stderr +++ b/tests/ui/image/query/query_lod_err.stderr @@ -12,6 +12,9 @@ error[E0277]: the trait bound `Image: HasQueryLevels` note: required by a bound in `Image::::query_lod` --> $SPIRV_STD_SRC/image.rs:907:15 | +901 | pub fn query_lod( + | --------- required by a bound in this associated function +... 907 | Self: HasQueryLevels, | ^^^^^^^^^^^^^^ required by this bound in `Image::::query_lod` diff --git a/tests/ui/image/query/query_size_err.stderr b/tests/ui/image/query/query_size_err.stderr index 4a03ef0854..9311a1d78b 100644 --- a/tests/ui/image/query/query_size_err.stderr +++ b/tests/ui/image/query/query_size_err.stderr @@ -17,6 +17,9 @@ error[E0277]: the trait bound `Image: HasQuerySize` is note: required by a bound in `Image::::query_size` --> $SPIRV_STD_SRC/image.rs:938:15 | +936 | pub fn query_size + Default>(&self) -> Size + | ---------- required by a bound in this associated function +937 | where 938 | Self: HasQuerySize, | ^^^^^^^^^^^^ required by this bound in `Image::::query_size` diff --git a/tests/ui/image/query/query_size_lod_err.stderr b/tests/ui/image/query/query_size_lod_err.stderr index 3f345b9fd3..ed06527761 100644 --- a/tests/ui/image/query/query_size_lod_err.stderr +++ b/tests/ui/image/query/query_size_lod_err.stderr @@ -12,6 +12,9 @@ error[E0277]: the trait bound `Image: HasQuerySizeLod` note: required by a bound in `Image::::query_size_lod` --> $SPIRV_STD_SRC/image.rs:982:15 | +977 | pub fn query_size_lod + Default>( + | -------------- required by a bound in this associated function +... 982 | Self: HasQuerySizeLod, | ^^^^^^^^^^^^^^^ required by this bound in `Image::::query_size_lod` diff --git a/tests/ui/lang/core/ptr/allocate_const_scalar.rs b/tests/ui/lang/core/ptr/allocate_const_scalar.rs index 97ff3ae9a2..02596f69c3 100644 --- a/tests/ui/lang/core/ptr/allocate_const_scalar.rs +++ b/tests/ui/lang/core/ptr/allocate_const_scalar.rs @@ -8,9 +8,10 @@ use spirv_std::spirv; use core::ptr::Unique; + const POINTER: Unique<[u8; 4]> = Unique::<[u8; 4]>::dangling(); #[spirv(fragment)] -pub fn main() { - let _pointer = POINTER; +pub fn main(output: &mut Unique<[u8; 4]>) { + *output = POINTER; } diff --git a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr index 1e14ba7962..a85b884892 100644 --- a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr +++ b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr @@ -1,14 +1,14 @@ error: pointer has non-null integer address | note: used from within `allocate_const_scalar::main` - --> $DIR/allocate_const_scalar.rs:15:20 + --> $DIR/allocate_const_scalar.rs:16:5 | -15 | let _pointer = POINTER; - | ^^^^^^^ +16 | *output = POINTER; + | ^^^^^^^^^^^^^^^^^ note: called by `main` - --> $DIR/allocate_const_scalar.rs:14:8 + --> $DIR/allocate_const_scalar.rs:15:8 | -14 | pub fn main() { +15 | pub fn main(output: &mut Unique<[u8; 4]>) { | ^^^^ error: aborting due to previous error diff --git a/tests/ui/lang/core/unwrap_or.stderr b/tests/ui/lang/core/unwrap_or.stderr index c44f16c894..3b3100c773 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 975 14 +OpLine %12 956 14 %13 = OpBitcast %14 %8 -OpLine %12 975 8 +OpLine %12 956 8 %15 = OpIEqual %16 %13 %17 OpNoLine OpSelectionMerge %18 None