From ecaefff584d05af91f8e45a6fd38d2aeb1a8fa05 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 26 May 2023 07:57:15 +0300 Subject: [PATCH] entry: fix entry-point stub spans (to point to the actual `fn` name). --- .../src/codegen_cx/entry.rs | 5 ++++- tests/ui/dis/ptr_copy.normal.stderr | 6 +++--- .../lang/consts/nested-ref-in-composite.stderr | 12 ++++++------ .../lang/core/ptr/allocate_const_scalar.stderr | 6 +++--- .../core/ref/zst_member_ref_arg-broken.stderr | 18 +++++++++--------- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs index 3d3a62f876..6b6bee6550 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs @@ -63,7 +63,10 @@ impl<'tcx> CodegenCx<'tcx> { name: String, entry: Entry, ) { - let span = self.tcx.def_span(instance.def_id()); + let span = self + .tcx + .def_ident_span(instance.def_id()) + .unwrap_or_else(|| self.tcx.def_span(instance.def_id())); let hir_params = { let fn_local_def_id = if let Some(id) = instance.def_id().as_local() { id diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index 2242059d6f..416a87115c 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -20,10 +20,10 @@ note: called by `ptr_copy::main` 33 | copy_via_raw_ptr(&i, o); | ^^^^^^^^^^^^^^^^^^^^^^^ note: called by `main` - --> $DIR/ptr_copy.rs:31:1 + --> $DIR/ptr_copy.rs:32:8 | -31 | #[spirv(fragment)] - | ^^^^^^^^^^^^^^^^^^ +32 | pub fn main(i: f32, o: &mut f32) { + | ^^^^ error: aborting due to previous error diff --git a/tests/ui/lang/consts/nested-ref-in-composite.stderr b/tests/ui/lang/consts/nested-ref-in-composite.stderr index 6e91db40d5..632757f31d 100644 --- a/tests/ui/lang/consts/nested-ref-in-composite.stderr +++ b/tests/ui/lang/consts/nested-ref-in-composite.stderr @@ -10,10 +10,10 @@ note: used from within `nested_ref_in_composite::main_pair` 20 | *pair_out = pair_deep_load(&(&123, &3.14)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: called by `main_pair` - --> $DIR/nested-ref-in-composite.rs:18:1 + --> $DIR/nested-ref-in-composite.rs:19:8 | -18 | #[spirv(fragment)] - | ^^^^^^^^^^^^^^^^^^ +19 | pub fn main_pair(pair_out: &mut (u32, f32)) { + | ^^^^^^^^^ error: constant arrays/structs cannot contain pointers to other constants --> $DIR/nested-ref-in-composite.rs:25:19 @@ -27,10 +27,10 @@ note: used from within `nested_ref_in_composite::main_array3` 25 | *array3_out = array3_deep_load(&[&0, &1, &2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: called by `main_array3` - --> $DIR/nested-ref-in-composite.rs:23:1 + --> $DIR/nested-ref-in-composite.rs:24:8 | -23 | #[spirv(fragment)] - | ^^^^^^^^^^^^^^^^^^ +24 | pub fn main_array3(array3_out: &mut [u32; 3]) { + | ^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr index 8c2fca2b50..1e14ba7962 100644 --- a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr +++ b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr @@ -6,10 +6,10 @@ note: used from within `allocate_const_scalar::main` 15 | let _pointer = POINTER; | ^^^^^^^ note: called by `main` - --> $DIR/allocate_const_scalar.rs:13:1 + --> $DIR/allocate_const_scalar.rs:14:8 | -13 | #[spirv(fragment)] - | ^^^^^^^^^^^^^^^^^^ +14 | pub fn main() { + | ^^^^ error: aborting due to previous error diff --git a/tests/ui/lang/core/ref/zst_member_ref_arg-broken.stderr b/tests/ui/lang/core/ref/zst_member_ref_arg-broken.stderr index 95972f2686..d2f24359aa 100644 --- a/tests/ui/lang/core/ref/zst_member_ref_arg-broken.stderr +++ b/tests/ui/lang/core/ref/zst_member_ref_arg-broken.stderr @@ -12,10 +12,10 @@ note: used from within `zst_member_ref_arg_broken::main_scalar` 23 | f(&s.y); | ^^^^^^^ note: called by `main_scalar` - --> $DIR/zst_member_ref_arg-broken.rs:21:1 + --> $DIR/zst_member_ref_arg-broken.rs:22:8 | -21 | #[spirv(fragment)] - | ^^^^^^^^^^^^^^^^^^ +22 | pub fn main_scalar(#[spirv(push_constant)] s: &S) { + | ^^^^^^^^^^^ error: cannot cast between pointer types from `*struct S { u32, u32 }` @@ -31,10 +31,10 @@ note: used from within `zst_member_ref_arg_broken::main_scalar_pair` 28 | f(&s.y); | ^^^^^^^ note: called by `main_scalar_pair` - --> $DIR/zst_member_ref_arg-broken.rs:26:1 + --> $DIR/zst_member_ref_arg-broken.rs:27:8 | -26 | #[spirv(fragment)] - | ^^^^^^^^^^^^^^^^^^ +27 | pub fn main_scalar_pair(#[spirv(push_constant)] s: &S) { + | ^^^^^^^^^^^^^^^^ error: cannot cast between pointer types from `*struct (usize, usize) { u32, u32 }` @@ -50,10 +50,10 @@ note: used from within `zst_member_ref_arg_broken::main_scalar_scalar_pair_neste 33 | f(&s.y); | ^^^^^^^ note: called by `main_scalar_scalar_pair_nested` - --> $DIR/zst_member_ref_arg-broken.rs:31:1 + --> $DIR/zst_member_ref_arg-broken.rs:32:8 | -31 | #[spirv(fragment)] - | ^^^^^^^^^^^^^^^^^^ +32 | pub fn main_scalar_scalar_pair_nested(#[spirv(push_constant)] s: &S<(usize, usize)>) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors