Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3930056

Browse files
committedMay 12, 2025
rustup: update to nightly-2025-03-29 (~1.87).
1 parent f9c818d commit 3930056

20 files changed

+196
-109
lines changed
 

‎crates/rustc_codegen_spirv/build.rs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ use std::{env, fs, mem};
1818
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1919
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
2020
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
21-
channel = "nightly-2025-02-16"
21+
channel = "nightly-2025-03-29"
2222
components = ["rust-src", "rustc-dev", "llvm-tools"]
23-
# commit_hash = 9cd60bd2ccc41bc898d2ad86728f14035d2df72d"#;
23+
# commit_hash = 920d95eaf23d7eb6b415d09868e4f793024fa604"#;
2424

2525
fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
2626
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
@@ -159,9 +159,9 @@ fn generate_pqp_cg_ssa() -> Result<(), Box<dyn Error>> {
159159
}
160160
}
161161

162-
// HACK(eddyb) remove `windows` dependency (from MSVC linker output
163-
// parsing, which `rustc_codegen_spirv` will never invoke anyway).
164162
if relative_path == Path::new("src/back/link.rs") {
163+
// HACK(eddyb) remove `windows` dependency (from MSVC linker output
164+
// parsing, which `rustc_codegen_spirv` will never invoke anyway).
165165
src = src.replace(
166166
"#[cfg(not(windows))]
167167
fn escape_linker_output(",
@@ -179,6 +179,33 @@ mod win {",
179179
"#[cfg(any())]
180180
mod win {",
181181
);
182+
// HACK(eddyb) remove `object` dependency (for Windows `raw_dylib`
183+
// handling, which `rustc_codegen_spirv` will never invoke anyway).
184+
src = src.replace("mod raw_dylib;", "// mod raw_dylib;");
185+
src = src.replace(
186+
"
187+
for output_path in raw_dylib::",
188+
"
189+
#[cfg(any())]
190+
for output_path in raw_dylib::",
191+
);
192+
src = src.replace(
193+
"
194+
for link_path in raw_dylib::",
195+
"
196+
#[cfg(any())]
197+
for link_path in raw_dylib::",
198+
);
199+
}
200+
if relative_path == Path::new("src/back/metadata.rs") {
201+
// HACK(eddyb) remove `object` dependency.
202+
src = src.replace("
203+
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {","
204+
pub(crate) fn create_object_file(_: &Session) -> Option<write::Object<'static>> {
205+
None
206+
}
207+
#[cfg(any())]
208+
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {");
182209
}
183210

184211
// HACK(eddyb) "typed alloca" patches.
@@ -259,6 +286,9 @@ mod win {",
259286
println!("cargo::warning={line}");
260287
}
261288
println!("cargo::warning=");
289+
290+
// HACK(eddyb) allow the warning to be cleared after `lib.rs` is fixed.
291+
println!("cargo:rerun-if-changed=src/lib.rs");
262292
}
263293

264294
// HACK(eddyb) write a file that can be `include!`d from `lib.rs`.

‎crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use itertools::Itertools;
88
use rspirv::spirv::{Dim, ImageFormat, StorageClass, Word};
99
use rustc_abi::ExternAbi as Abi;
1010
use rustc_abi::{
11-
Align, BackendRepr, FieldsShape, LayoutData, Primitive, ReprFlags, ReprOptions, Scalar, Size,
12-
TagEncoding, VariantIdx, Variants,
11+
Align, BackendRepr, FieldIdx, FieldsShape, LayoutData, Primitive, ReprFlags, ReprOptions,
12+
Scalar, Size, TagEncoding, VariantIdx, Variants,
1313
};
1414
use rustc_data_structures::fx::FxHashMap;
1515
use rustc_errors::ErrorGuaranteed;
@@ -106,6 +106,7 @@ pub(crate) fn provide(providers: &mut Providers) {
106106
ref variants,
107107
backend_repr,
108108
largest_niche,
109+
uninhabited,
109110
align,
110111
size,
111112
max_repr_align,
@@ -153,6 +154,7 @@ pub(crate) fn provide(providers: &mut Providers) {
153154
},
154155
backend_repr,
155156
largest_niche,
157+
uninhabited,
156158
align,
157159
size,
158160
max_repr_align,
@@ -201,7 +203,7 @@ pub(crate) fn provide(providers: &mut Providers) {
201203
let trivial_struct = match tcx.hir_node_by_def_id(def_id) {
202204
rustc_hir::Node::Item(item) => match item.kind {
203205
rustc_hir::ItemKind::Struct(
204-
_,
206+
..,
205207
&rustc_hir::Generics {
206208
params:
207209
&[]
@@ -465,7 +467,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
465467
// `ScalarPair`.
466468
// There's a few layers that we go through here. First we inspect layout.backend_repr, then if relevant, layout.fields, etc.
467469
match self.backend_repr {
468-
BackendRepr::Uninhabited => SpirvType::Adt {
470+
_ if self.uninhabited => SpirvType::Adt {
469471
def_id: def_id_for_spirv_type_adt(*self),
470472
size: Some(Size::ZERO),
471473
align: Align::from_bytes(0).unwrap(),
@@ -526,7 +528,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
526528
if let TyKind::Adt(adt, _) = self.ty.kind() {
527529
if let Variants::Single { index } = self.variants {
528530
for i in self.fields.index_by_increasing_offset() {
529-
let field = &adt.variants()[index].fields[i.into()];
531+
let field = &adt.variants()[index].fields[FieldIdx::new(i)];
530532
field_names.push(field.name);
531533
}
532534
}
@@ -545,7 +547,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
545547
}
546548
.def_with_name(cx, span, TyLayoutNameKey::from(*self))
547549
}
548-
BackendRepr::Vector { element, count } => {
550+
BackendRepr::SimdVector { element, count } => {
549551
let elem_spirv = trans_scalar(cx, span, *self, element, Size::ZERO);
550552
SpirvType::Vector {
551553
element: elem_spirv,
@@ -815,7 +817,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -
815817
field_offsets.push(offset);
816818
if let Variants::Single { index } = ty.variants {
817819
if let TyKind::Adt(adt, _) = ty.ty.kind() {
818-
let field = &adt.variants()[index].fields[i.into()];
820+
let field = &adt.variants()[index].fields[FieldIdx::new(i)];
819821
field_names.push(field.name);
820822
} else {
821823
// FIXME(eddyb) this looks like something that should exist in rustc.

‎crates/rustc_codegen_spirv/src/attr.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ fn target_from_impl_item(tcx: TyCtxt<'_>, impl_item: &hir::ImplItem<'_>) -> Targ
253253
match impl_item.kind {
254254
hir::ImplItemKind::Const(..) => Target::AssocConst,
255255
hir::ImplItemKind::Fn(..) => {
256-
let parent_owner_id = tcx.hir().get_parent_item(impl_item.hir_id());
257-
let containing_item = tcx.hir().expect_item(parent_owner_id.def_id);
256+
let parent_owner_id = tcx.hir_get_parent_item(impl_item.hir_id());
257+
let containing_item = tcx.hir_expect_item(parent_owner_id.def_id);
258258
let containing_impl_is_for_trait = match &containing_item.kind {
259259
hir::ItemKind::Impl(hir::Impl { of_trait, .. }) => of_trait.is_some(),
260260
_ => unreachable!("parent of an ImplItem must be an Impl"),
@@ -280,7 +280,7 @@ impl CheckSpirvAttrVisitor<'_> {
280280

281281
let parse_attrs = |attrs| crate::symbols::parse_attrs_for_checking(&self.sym, attrs);
282282

283-
let attrs = self.tcx.hir().attrs(hir_id);
283+
let attrs = self.tcx.hir_attrs(hir_id);
284284
for parse_attr_result in parse_attrs(attrs) {
285285
let (span, parsed_attr) = match parse_attr_result {
286286
Ok(span_and_parsed_attr) => span_and_parsed_attr,
@@ -326,10 +326,9 @@ impl CheckSpirvAttrVisitor<'_> {
326326
| SpirvAttribute::SpecConstant(_) => match target {
327327
Target::Param => {
328328
let parent_hir_id = self.tcx.parent_hir_id(hir_id);
329-
let parent_is_entry_point =
330-
parse_attrs(self.tcx.hir().attrs(parent_hir_id))
331-
.filter_map(|r| r.ok())
332-
.any(|(_, attr)| matches!(attr, SpirvAttribute::Entry(_)));
329+
let parent_is_entry_point = parse_attrs(self.tcx.hir_attrs(parent_hir_id))
330+
.filter_map(|r| r.ok())
331+
.any(|(_, attr)| matches!(attr, SpirvAttribute::Entry(_)));
333332
if !parent_is_entry_point {
334333
self.tcx.dcx().span_err(
335334
span,
@@ -417,8 +416,8 @@ impl CheckSpirvAttrVisitor<'_> {
417416
impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
418417
type NestedFilter = nested_filter::OnlyBodies;
419418

420-
fn nested_visit_map(&mut self) -> Self::Map {
421-
self.tcx.hir()
419+
fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
420+
self.tcx
422421
}
423422

424423
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
@@ -497,8 +496,7 @@ fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
497496
tcx,
498497
sym: Symbols::get(),
499498
};
500-
tcx.hir()
501-
.visit_item_likes_in_module(module_def_id, check_spirv_attr_visitor);
499+
tcx.hir_visit_item_likes_in_module(module_def_id, check_spirv_attr_visitor);
502500
if module_def_id.is_top_level_module() {
503501
check_spirv_attr_visitor.check_spirv_attributes(CRATE_HIR_ID, Target::Mod);
504502
}

‎crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
18511851
place.val.llval,
18521852
place.val.align,
18531853
);
1854-
OperandValue::Immediate(self.to_immediate(llval, place.layout))
1854+
OperandValue::Immediate(llval)
18551855
} else if let BackendRepr::ScalarPair(a, b) = place.layout.backend_repr {
18561856
let b_offset = a
18571857
.primitive()

‎crates/rustc_codegen_spirv/src/builder/intrinsics.rs

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,10 @@ impl Builder<'_, '_> {
4646
),
4747
};
4848
let int_ty = SpirvType::Integer(width, false).def(self.span(), self);
49-
let (mask_sign, mask_value) = match width {
50-
32 => (
51-
self.constant_u32(self.span(), 1 << 31),
52-
self.constant_u32(self.span(), u32::MAX >> 1),
53-
),
54-
64 => (
55-
self.constant_u64(self.span(), 1 << 63),
56-
self.constant_u64(self.span(), u64::MAX >> 1),
57-
),
58-
_ => bug!("copysign must have width 32 or 64, not {}", width),
49+
let [mask_sign, mask_value] = {
50+
let sign_bit = 1u128.checked_shl(width - 1).unwrap();
51+
let value_mask = sign_bit - 1;
52+
[sign_bit, value_mask].map(|v| self.constant_int(int_ty, v))
5953
};
6054
let val_bits = self.bitcast(val, int_ty);
6155
let sign_bits = self.bitcast(sign, int_ty);
@@ -154,30 +148,44 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
154148
result
155149
}
156150

157-
sym::sqrtf32 | sym::sqrtf64 => self.gl_op(GLOp::Sqrt, ret_ty, [args[0].immediate()]),
158-
sym::powif32 | sym::powif64 => {
151+
sym::sqrtf32 | sym::sqrtf64 | sym::sqrtf128 => {
152+
self.gl_op(GLOp::Sqrt, ret_ty, [args[0].immediate()])
153+
}
154+
sym::powif32 | sym::powif64 | sym::powif128 => {
159155
let float = self.sitofp(args[1].immediate(), args[0].immediate().ty);
160156
self.gl_op(GLOp::Pow, ret_ty, [args[0].immediate(), float])
161157
}
162-
sym::sinf32 | sym::sinf64 => self.gl_op(GLOp::Sin, ret_ty, [args[0].immediate()]),
163-
sym::cosf32 | sym::cosf64 => self.gl_op(GLOp::Cos, ret_ty, [args[0].immediate()]),
164-
sym::powf32 | sym::powf64 => self.gl_op(
158+
sym::sinf32 | sym::sinf64 | sym::sinf128 => {
159+
self.gl_op(GLOp::Sin, ret_ty, [args[0].immediate()])
160+
}
161+
sym::cosf32 | sym::cosf64 | sym::cosf128 => {
162+
self.gl_op(GLOp::Cos, ret_ty, [args[0].immediate()])
163+
}
164+
sym::powf32 | sym::powf64 | sym::powf128 => self.gl_op(
165165
GLOp::Pow,
166166
ret_ty,
167167
[args[0].immediate(), args[1].immediate()],
168168
),
169-
sym::expf32 | sym::expf64 => self.gl_op(GLOp::Exp, ret_ty, [args[0].immediate()]),
170-
sym::exp2f32 | sym::exp2f64 => self.gl_op(GLOp::Exp2, ret_ty, [args[0].immediate()]),
171-
sym::logf32 | sym::logf64 => self.gl_op(GLOp::Log, ret_ty, [args[0].immediate()]),
172-
sym::log2f32 | sym::log2f64 => self.gl_op(GLOp::Log2, ret_ty, [args[0].immediate()]),
173-
sym::log10f32 | sym::log10f64 => {
169+
sym::expf32 | sym::expf64 | sym::expf128 => {
170+
self.gl_op(GLOp::Exp, ret_ty, [args[0].immediate()])
171+
}
172+
sym::exp2f32 | sym::exp2f64 | sym::exp2f128 => {
173+
self.gl_op(GLOp::Exp2, ret_ty, [args[0].immediate()])
174+
}
175+
sym::logf32 | sym::logf64 | sym::logf128 => {
176+
self.gl_op(GLOp::Log, ret_ty, [args[0].immediate()])
177+
}
178+
sym::log2f32 | sym::log2f64 | sym::log2f128 => {
179+
self.gl_op(GLOp::Log2, ret_ty, [args[0].immediate()])
180+
}
181+
sym::log10f32 | sym::log10f64 | sym::log10f128 => {
174182
// spir-v glsl doesn't have log10, so,
175183
// log10(x) == (1 / ln(10)) * ln(x)
176184
let mul = self.constant_float(args[0].immediate().ty, 1.0 / 10.0f64.ln());
177185
let ln = self.gl_op(GLOp::Log, ret_ty, [args[0].immediate()]);
178186
self.fmul(mul, ln)
179187
}
180-
sym::fmaf32 | sym::fmaf64 => self.gl_op(
188+
sym::fmaf32 | sym::fmaf64 | sym::fmaf128 => self.gl_op(
181189
GLOp::Fma,
182190
ret_ty,
183191
[
@@ -186,30 +194,37 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
186194
args[2].immediate(),
187195
],
188196
),
189-
sym::fabsf32 | sym::fabsf64 => self.gl_op(GLOp::FAbs, ret_ty, [args[0].immediate()]),
190-
sym::minnumf32 | sym::minnumf64 => self.gl_op(
197+
sym::fabsf32 | sym::fabsf64 | sym::fabsf128 => {
198+
self.gl_op(GLOp::FAbs, ret_ty, [args[0].immediate()])
199+
}
200+
sym::minnumf32 | sym::minnumf64 | sym::minnumf128 => self.gl_op(
191201
GLOp::FMin,
192202
ret_ty,
193203
[args[0].immediate(), args[1].immediate()],
194204
),
195-
sym::maxnumf32 | sym::maxnumf64 => self.gl_op(
205+
sym::maxnumf32 | sym::maxnumf64 | sym::maxnumf128 => self.gl_op(
196206
GLOp::FMax,
197207
ret_ty,
198208
[args[0].immediate(), args[1].immediate()],
199209
),
200-
sym::copysignf32 | sym::copysignf64 => {
210+
sym::copysignf32 | sym::copysignf64 | sym::copysignf128 => {
201211
let val = args[0].immediate();
202212
let sign = args[1].immediate();
203213
self.copysign(val, sign)
204214
}
205-
sym::floorf32 | sym::floorf64 => self.gl_op(GLOp::Floor, ret_ty, [args[0].immediate()]),
206-
sym::ceilf32 | sym::ceilf64 => self.gl_op(GLOp::Ceil, ret_ty, [args[0].immediate()]),
207-
sym::truncf32 | sym::truncf64 => self.gl_op(GLOp::Trunc, ret_ty, [args[0].immediate()]),
208-
sym::rintf32 | sym::rintf64 => {
215+
sym::floorf32 | sym::floorf64 | sym::floorf128 => {
216+
self.gl_op(GLOp::Floor, ret_ty, [args[0].immediate()])
217+
}
218+
sym::ceilf32 | sym::ceilf64 | sym::ceilf128 => {
219+
self.gl_op(GLOp::Ceil, ret_ty, [args[0].immediate()])
220+
}
221+
sym::truncf32 | sym::truncf64 | sym::truncf128 => {
222+
self.gl_op(GLOp::Trunc, ret_ty, [args[0].immediate()])
223+
}
224+
sym::round_ties_even_f32 | sym::round_ties_even_f64 | sym::round_ties_even_f128 => {
209225
self.gl_op(GLOp::RoundEven, ret_ty, [args[0].immediate()])
210226
}
211-
// TODO: Correctness of all these rounds
212-
sym::nearbyintf32 | sym::nearbyintf64 | sym::roundf32 | sym::roundf64 => {
227+
sym::roundf32 | sym::roundf64 | sym::roundf128 => {
213228
self.gl_op(GLOp::Round, ret_ty, [args[0].immediate()])
214229
}
215230

‎crates/rustc_codegen_spirv/src/builder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<'a, 'tcx> ArgAbiBuilderMethods<'tcx> for Builder<'a, 'tcx> {
260260
}
261261
}
262262

263-
impl<'a, 'tcx> AbiBuilderMethods<'tcx> for Builder<'a, 'tcx> {
263+
impl AbiBuilderMethods for Builder<'_, '_> {
264264
fn get_param(&mut self, index: usize) -> Self::Value {
265265
self.function_parameter_values.borrow()[&self.current_fn.def(self)][index]
266266
}

‎crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,13 @@ impl<'tcx> CodegenCx<'tcx> {
109109
}
110110
}
111111

112-
impl<'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'tcx> {
112+
impl ConstCodegenMethods for CodegenCx<'_> {
113113
fn const_null(&self, t: Self::Type) -> Self::Value {
114114
self.constant_null(t)
115115
}
116116
fn const_undef(&self, ty: Self::Type) -> Self::Value {
117117
self.undef(ty)
118118
}
119-
fn is_undef(&self, v: Self::Value) -> bool {
120-
matches!(self.builder.lookup_const(v), Some(SpirvConst::Undef))
121-
}
122119
fn const_poison(&self, ty: Self::Type) -> Self::Value {
123120
// No distinction between undef and poison.
124121
self.const_undef(ty)
@@ -319,7 +316,12 @@ impl<'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'tcx> {
319316
// the actual value generation until after a pointer to this value is cast
320317
// to its final type (e.g. that will be loaded as).
321318
// FIXME(eddyb) replace this with `qptr` handling of constant data.
322-
fn const_data_from_alloc(&self, alloc: ConstAllocation<'tcx>) -> Self::Value {
319+
fn const_data_from_alloc(&self, alloc: ConstAllocation<'_>) -> Self::Value {
320+
// HACK(eddyb) the `ConstCodegenMethods` trait no longer guarantees the
321+
// lifetime that `alloc` is interned for, but since it *is* interned,
322+
// we can cheaply recover it (see also the `ty::Lift` infrastructure).
323+
let alloc = self.tcx.lift(alloc).unwrap();
324+
323325
let void_type = SpirvType::Void.def(DUMMY_SP, self);
324326
self.def_constant(void_type, SpirvConst::ConstDataFromAlloc(alloc))
325327
}

‎crates/rustc_codegen_spirv/src/codegen_cx/entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'tcx> CodegenCx<'tcx> {
8282
.span_err(span, format!("cannot declare {name} as an entry point"));
8383
return;
8484
};
85-
self.tcx.hir().body_owned_by(fn_local_def_id).params
85+
self.tcx.hir_body_owned_by(fn_local_def_id).params
8686
};
8787
for (arg_abi, hir_param) in fn_abi.args.iter().zip(hir_params) {
8888
match arg_abi.mode {
@@ -429,7 +429,7 @@ impl<'tcx> CodegenCx<'tcx> {
429429
call_args: &mut Vec<SpirvValue>,
430430
decoration_locations: &mut FxHashMap<StorageClass, u32>,
431431
) {
432-
let attrs = AggregatedSpirvAttributes::parse(self, self.tcx.hir().attrs(hir_param.hir_id));
432+
let attrs = AggregatedSpirvAttributes::parse(self, self.tcx.hir_attrs(hir_param.hir_id));
433433

434434
let EntryParamDeducedFromRustRefOrValue {
435435
value_layout,

‎crates/rustc_codegen_spirv/src/codegen_cx/type_.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,17 @@ impl<'tcx> LayoutTypeCodegenMethods<'tcx> for CodegenCx<'tcx> {
9797

9898
fn is_backend_immediate(&self, layout: TyAndLayout<'tcx>) -> bool {
9999
match layout.backend_repr {
100-
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true,
100+
BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => true,
101101
BackendRepr::ScalarPair(..) => false,
102-
BackendRepr::Uninhabited | BackendRepr::Memory { .. } => layout.is_zst(),
102+
BackendRepr::Memory { .. } => layout.is_zst(),
103103
}
104104
}
105105

106106
fn is_backend_scalar_pair(&self, layout: TyAndLayout<'tcx>) -> bool {
107107
match layout.backend_repr {
108108
BackendRepr::ScalarPair(..) => true,
109-
BackendRepr::Uninhabited
110-
| BackendRepr::Scalar(_)
111-
| BackendRepr::Vector { .. }
109+
BackendRepr::Scalar(_)
110+
| BackendRepr::SimdVector { .. }
112111
| BackendRepr::Memory { .. } => false,
113112
}
114113
}
@@ -130,7 +129,7 @@ impl<'tcx> CodegenCx<'tcx> {
130129
}
131130
}
132131

133-
impl<'tcx> BaseTypeCodegenMethods<'tcx> for CodegenCx<'tcx> {
132+
impl BaseTypeCodegenMethods for CodegenCx<'_> {
134133
fn type_i8(&self) -> Self::Type {
135134
SpirvType::Integer(8, false).def(DUMMY_SP, self)
136135
}

‎crates/rustc_codegen_spirv/src/custom_insts.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ lazy_static! {
4343
/// achieved by hashing the `SCHEMA` constant from `def_custom_insts!` below
4444
pub static ref CUSTOM_EXT_INST_SET: String = {
4545
let schema_hash = {
46-
use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
46+
use rustc_data_structures::stable_hasher::StableHasher;
47+
use rustc_hashes::Hash128;
4748
use std::hash::Hash;
4849

4950
let mut hasher = StableHasher::new();

‎crates/rustc_codegen_spirv/src/lib.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(internal_features)]
33
#![allow(rustc::diagnostic_outside_of_impl)]
44
#![allow(rustc::untranslatable_diagnostic)]
5+
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
56
#![feature(assert_matches)]
67
#![feature(box_patterns)]
78
#![feature(debug_closure_helpers)]
@@ -10,6 +11,7 @@
1011
#![feature(let_chains)]
1112
#![feature(negative_impls)]
1213
#![feature(rustdoc_internals)]
14+
#![feature(string_from_utf8_lossy_owned)]
1315
#![feature(trait_alias)]
1416
#![feature(try_blocks)]
1517
// HACK(eddyb) end of `rustc_codegen_ssa` crate-level attributes (see `build.rs`).
@@ -96,6 +98,8 @@ extern crate rustc_driver;
9698
#[cfg(rustc_codegen_spirv_disable_pqp_cg_ssa)]
9799
extern crate rustc_errors;
98100
#[cfg(rustc_codegen_spirv_disable_pqp_cg_ssa)]
101+
extern crate rustc_hashes;
102+
#[cfg(rustc_codegen_spirv_disable_pqp_cg_ssa)]
99103
extern crate rustc_hir;
100104
#[cfg(rustc_codegen_spirv_disable_pqp_cg_ssa)]
101105
extern crate rustc_index;
@@ -260,15 +264,21 @@ impl CodegenBackend for SpirvCodegenBackend {
260264
rustc_errors::DEFAULT_LOCALE_RESOURCE
261265
}
262266

263-
fn target_features_cfg(&self, sess: &Session, _allow_unstable: bool) -> Vec<Symbol> {
267+
fn target_features_cfg(&self, sess: &Session) -> (Vec<Symbol>, Vec<Symbol>) {
264268
let cmdline = sess.opts.cg.target_feature.split(',');
265269
let cfg = sess.target.options.features.split(',');
266-
cfg.chain(cmdline)
270+
271+
let all_target_features: Vec<_> = cfg
272+
.chain(cmdline)
267273
.filter(|l| l.starts_with('+'))
268274
.map(|l| &l[1..])
269275
.filter(|l| !l.is_empty())
270276
.map(Symbol::intern)
271-
.collect()
277+
.collect();
278+
279+
// HACK(eddyb) the second list is "including unstable target features",
280+
// but there is no reason to make a distinction for SPIR-V ones.
281+
(all_target_features.clone(), all_target_features)
272282
}
273283

274284
fn provide(&self, providers: &mut rustc_middle::util::Providers) {
@@ -368,7 +378,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
368378
unsafe fn optimize(
369379
_: &CodegenContext<Self>,
370380
_: DiagCtxtHandle<'_>,
371-
_: &ModuleCodegen<Self::Module>,
381+
_: &mut ModuleCodegen<Self::Module>,
372382
_: &ModuleConfig,
373383
) -> Result<(), FatalError> {
374384
// TODO: Implement
@@ -385,6 +395,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
385395
.to_vec(),
386396
name: thin_module.name().to_string(),
387397
kind: ModuleKind::Regular,
398+
thin_lto_buffer: None,
388399
};
389400
Ok(module)
390401
}
@@ -419,6 +430,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
419430
bytecode: None,
420431
assembly: None,
421432
llvm_ir: None,
433+
links_from_incr_cache: vec![],
422434
})
423435
}
424436

@@ -515,6 +527,7 @@ impl ExtraBackendMethods for SpirvCodegenBackend {
515527
name: cgu_name.to_string(),
516528
module_llvm: spirv_module,
517529
kind: ModuleKind::Regular,
530+
thin_lto_buffer: None,
518531
},
519532
0,
520533
)

‎crates/rustc_codegen_spirv/src/linker/specializer.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ use crate::spirv_type_constraints::{self, InstSig, StorageClassPat, TyListPat, T
5454
use indexmap::{IndexMap, IndexSet};
5555
use rspirv::dr::{Builder, Function, Instruction, Module, Operand};
5656
use rspirv::spirv::{Op, StorageClass, Word};
57-
use rustc_data_structures::captures::Captures;
5857
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
5958
use smallvec::SmallVec;
6059
use std::collections::{BTreeMap, VecDeque};
@@ -1112,10 +1111,10 @@ impl<'a> Match<'a> {
11121111
self
11131112
}
11141113

1115-
fn debug_with_infer_cx<'b>(
1114+
fn debug_with_infer_cx<'b, T: Specialization>(
11161115
&'b self,
1117-
cx: &'b InferCx<'a, impl Specialization>,
1118-
) -> impl fmt::Debug + Captures<'a> + '_ {
1116+
cx: &'b InferCx<'a, T>,
1117+
) -> impl fmt::Debug + use<'a, 'b, T> {
11191118
fn debug_var_found<'a, A: smallvec::Array<Item = T> + 'a, T: 'a, TD: fmt::Display>(
11201119
var_found: &'a SmallIntMap<impl smallvec::Array<Item = SmallVec<A>>>,
11211120
display: &'a impl Fn(&'a T) -> TD,

‎crates/rustc_codegen_spirv/src/symbols.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::builder::libm_intrinsics;
33
use rspirv::spirv::{BuiltIn, ExecutionMode, ExecutionModel, StorageClass};
44
use rustc_ast::ast::{LitIntType, LitKind, MetaItemInner, MetaItemLit};
55
use rustc_data_structures::fx::FxHashMap;
6-
use rustc_hir::{AttrKind, Attribute};
6+
use rustc_hir::Attribute;
77
use rustc_span::Span;
88
use rustc_span::symbol::{Ident, Symbol};
99
use std::rc::Rc;
@@ -447,8 +447,8 @@ pub(crate) fn parse_attrs_for_checking<'a>(
447447
attrs: &'a [Attribute],
448448
) -> impl Iterator<Item = Result<(Span, SpirvAttribute), ParseAttrError>> + 'a {
449449
attrs.iter().flat_map(move |attr| {
450-
let (whole_attr_error, args) = match attr.kind {
451-
AttrKind::Normal(ref item) => {
450+
let (whole_attr_error, args) = match attr {
451+
Attribute::Unparsed(item) => {
452452
// #[...]
453453
let s = &item.path.segments;
454454
if s.len() > 1 && s[0].name == sym.rust_gpu {
@@ -457,7 +457,7 @@ pub(crate) fn parse_attrs_for_checking<'a>(
457457
// #[rust_gpu::...] but not #[rust_gpu::spirv]
458458
(
459459
Some(Err((
460-
attr.span,
460+
attr.span(),
461461
"unknown `rust_gpu` attribute, expected `rust_gpu::spirv`"
462462
.to_string(),
463463
))),
@@ -470,7 +470,7 @@ pub(crate) fn parse_attrs_for_checking<'a>(
470470
// #[rust_gpu::spirv]
471471
(
472472
Some(Err((
473-
attr.span,
473+
attr.span(),
474474
"#[rust_gpu::spirv(..)] attribute must have at least one argument"
475475
.to_string(),
476476
))),
@@ -482,7 +482,7 @@ pub(crate) fn parse_attrs_for_checking<'a>(
482482
(None, Default::default())
483483
}
484484
}
485-
AttrKind::DocComment(..) => (None, Default::default()), // doccomment
485+
Attribute::Parsed(_) => (None, Default::default()),
486486
};
487487

488488
whole_attr_error

‎rust-toolchain.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[toolchain]
2-
channel = "nightly-2025-02-16"
2+
channel = "nightly-2025-03-29"
33
components = ["rust-src", "rustc-dev", "llvm-tools"]
4-
# commit_hash = 9cd60bd2ccc41bc898d2ad86728f14035d2df72d
4+
# commit_hash = 920d95eaf23d7eb6b415d09868e4f793024fa604
55

66
# Whenever changing the nightly channel, update the commit hash above, and make
77
# sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also.

‎tests/ui/arch/debug_printf_type_checking.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ help: the return type of this call is `u32` due to the type of the argument pass
7373
21 | debug_printf!("%f", 11_u32);
7474
| ^^^^^^^^^^^^^^^^^^^^------^
7575
| |
76-
| this argument influences the return type of `spirv_std`
76+
| this argument influences the return type of `debug_printf_assert_is_type`
7777
note: function defined here
7878
--> $SPIRV_STD_SRC/lib.rs:134:8
7979
|
@@ -101,7 +101,7 @@ help: the return type of this call is `f32` due to the type of the argument pass
101101
22 | debug_printf!("%u", 11.0_f32);
102102
| ^^^^^^^^^^^^^^^^^^^^--------^
103103
| |
104-
| this argument influences the return type of `spirv_std`
104+
| this argument influences the return type of `debug_printf_assert_is_type`
105105
note: function defined here
106106
--> $SPIRV_STD_SRC/lib.rs:134:8
107107
|
@@ -155,7 +155,7 @@ help: the return type of this call is `Vec2` due to the type of the argument pas
155155
24 | debug_printf!("%f", Vec2::splat(33.3));
156156
| ^^^^^^^^^^^^^^^^^^^^-----------------^
157157
| |
158-
| this argument influences the return type of `spirv_std`
158+
| this argument influences the return type of `debug_printf_assert_is_type`
159159
note: function defined here
160160
--> $SPIRV_STD_SRC/lib.rs:134:8
161161
|

‎tests/ui/dis/ptr_copy.normal.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: cannot memcpy dynamically sized data
2-
--> $CORE_SRC/intrinsics/mod.rs:4543:9
2+
--> $CORE_SRC/intrinsics/mod.rs:3854:9
33
|
4-
4543 | copy(src, dst, count)
4+
3854 | copy(src, dst, count)
55
| ^^^^^^^^^^^^^^^^^^^^^
66
|
77
note: used from within `core::intrinsics::copy::<f32>`
8-
--> $CORE_SRC/intrinsics/mod.rs:4520:21
8+
--> $CORE_SRC/intrinsics/mod.rs:3834:21
99
|
10-
4520 | pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
10+
3834 | pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
1111
| ^^^^
1212
note: called by `ptr_copy::copy_via_raw_ptr`
1313
--> $DIR/ptr_copy.rs:28:18
@@ -28,25 +28,25 @@ note: called by `main`
2828
error: cannot cast between pointer types
2929
from `*f32`
3030
to `*struct () { }`
31-
--> $CORE_SRC/intrinsics/mod.rs:4531:9
31+
--> $CORE_SRC/intrinsics/mod.rs:3842:9
3232
|
33-
4531 | / ub_checks::assert_unsafe_precondition!(
34-
4532 | | check_language_ub,
35-
4533 | | "ptr::copy requires that both pointer arguments are aligned and non-null",
33+
3842 | / ub_checks::assert_unsafe_precondition!(
34+
3843 | | check_language_ub,
35+
3844 | | "ptr::copy requires that both pointer arguments are aligned and non-null",
3636
... |
37-
4541 | | && ub_checks::maybe_is_aligned_and_not_null(dst, align, zero_size)
38-
4542 | | );
37+
3852 | | && ub_checks::maybe_is_aligned_and_not_null(dst, align, zero_size)
38+
3853 | | );
3939
| |_________^
4040
|
4141
note: used from within `core::intrinsics::copy::<f32>`
42-
--> $CORE_SRC/intrinsics/mod.rs:4531:9
42+
--> $CORE_SRC/intrinsics/mod.rs:3842:9
4343
|
44-
4531 | / ub_checks::assert_unsafe_precondition!(
45-
4532 | | check_language_ub,
46-
4533 | | "ptr::copy requires that both pointer arguments are aligned and non-null",
44+
3842 | / ub_checks::assert_unsafe_precondition!(
45+
3843 | | check_language_ub,
46+
3844 | | "ptr::copy requires that both pointer arguments are aligned and non-null",
4747
... |
48-
4541 | | && ub_checks::maybe_is_aligned_and_not_null(dst, align, zero_size)
49-
4542 | | );
48+
3852 | | && ub_checks::maybe_is_aligned_and_not_null(dst, align, zero_size)
49+
3853 | | );
5050
| |_________^
5151
note: called by `ptr_copy::copy_via_raw_ptr`
5252
--> $DIR/ptr_copy.rs:28:18

‎tests/ui/dis/ptr_write.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
%7 = OpLabel
55
OpLine %8 7 35
66
%9 = OpLoad %10 %4
7-
OpLine %11 1582 8
7+
OpLine %11 1580 8
88
OpStore %6 %9
99
OpNoLine
1010
OpReturn

‎tests/ui/dis/ptr_write_method.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
%7 = OpLabel
55
OpLine %8 7 37
66
%9 = OpLoad %10 %4
7-
OpLine %11 1582 8
7+
OpLine %11 1580 8
88
OpStore %6 %9
99
OpNoLine
1010
OpReturn

‎tests/ui/lang/core/unwrap_or.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ OpLine %5 13 11
66
OpLine %12 999 14
77
%13 = OpBitcast %14 %8
88
OpLine %12 999 8
9-
%15 = OpIEqual %16 %13 %17
9+
%15 = OpINotEqual %16 %13 %17
1010
OpNoLine
1111
OpSelectionMerge %18 None
1212
OpBranchConditional %15 %19 %20
@@ -15,7 +15,7 @@ OpBranch %18
1515
%20 = OpLabel
1616
OpBranch %18
1717
%18 = OpLabel
18-
%21 = OpPhi %11 %22 %19 %10 %20
18+
%21 = OpPhi %11 %10 %19 %22 %20
1919
OpLine %5 13 4
2020
OpStore %23 %21
2121
OpNoLine

‎tests/ui/spirv-attr/invalid-target.stderr

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2620,5 +2620,33 @@ error: attribute is only valid on a function parameter, not on a foreign functio
26202620
87 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only
26212621
| ^^^^^^^^^
26222622

2623-
error: aborting due to 437 previous errors
2623+
error: unconstrained opaque type
2624+
--> $DIR/invalid-target.rs:118:18
2625+
|
2626+
118 | type _OpaqueTy = impl Copy;
2627+
| ^^^^^^^^^
2628+
|
2629+
= note: `_OpaqueTy` must be used in combination with a concrete type within the same crate
2630+
2631+
error[E0308]: mismatched types
2632+
--> $DIR/invalid-target.rs:121:5
2633+
|
2634+
118 | type _OpaqueTy = impl Copy;
2635+
| --------- the expected opaque type
2636+
119 |
2637+
120 | fn _opaque_ty_definer() -> _OpaqueTy {
2638+
| --------- expected `_OpaqueTy` because of return type
2639+
121 | ()
2640+
| ^^ expected opaque type, found `()`
2641+
|
2642+
= note: expected opaque type `_OpaqueTy`
2643+
found unit type `()`
2644+
note: this item must have a `#[define_opaque(_OpaqueTy)]` attribute to be able to define hidden types
2645+
--> $DIR/invalid-target.rs:120:4
2646+
|
2647+
120 | fn _opaque_ty_definer() -> _OpaqueTy {
2648+
| ^^^^^^^^^^^^^^^^^^
2649+
2650+
error: aborting due to 439 previous errors
26242651

2652+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)
Please sign in to comment.