Skip to content

Commit eddebd7

Browse files
committed
Update formatting for nightly-2024-10-12 (~1.83).
1 parent 37892c6 commit eddebd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+313
-417
lines changed

crates/rustc_codegen_spirv/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use rustc_middle::ty::{
1717
};
1818
use rustc_middle::ty::{GenericArgsRef, ScalarInt};
1919
use rustc_middle::{bug, span_bug};
20-
use rustc_span::def_id::DefId;
2120
use rustc_span::DUMMY_SP;
21+
use rustc_span::def_id::DefId;
2222
use rustc_span::{Span, Symbol};
2323
use rustc_target::abi::call::{ArgAbi, ArgAttributes, FnAbi, PassMode};
2424
use rustc_target::abi::{

crates/rustc_codegen_spirv/src/attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_ast::Attribute;
99
use rustc_hir as hir;
1010
use rustc_hir::def_id::LocalModDefId;
1111
use rustc_hir::intravisit::{self, Visitor};
12-
use rustc_hir::{HirId, MethodKind, Target, CRATE_HIR_ID};
12+
use rustc_hir::{CRATE_HIR_ID, HirId, MethodKind, Target};
1313
use rustc_middle::hir::nested_filter;
1414
use rustc_middle::query::Providers;
1515
use rustc_middle::ty::TyCtxt;

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

+17-26
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use crate::spirv_type::SpirvType;
99
use itertools::Itertools;
1010
use rspirv::dr::{InsertPoint, Instruction, Operand};
1111
use rspirv::spirv::{Capability, MemoryModel, MemorySemantics, Op, Scope, StorageClass, Word};
12-
use rustc_apfloat::{ieee, Float, Round, Status};
12+
use rustc_apfloat::{Float, Round, Status, ieee};
13+
use rustc_codegen_ssa::MemFlags;
1314
use rustc_codegen_ssa::common::{
1415
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
1516
};
@@ -19,7 +20,6 @@ use rustc_codegen_ssa::traits::BaseTypeMethods;
1920
use rustc_codegen_ssa::traits::{
2021
BackendTypes, BuilderMethods, ConstMethods, LayoutTypeMethods, OverflowOp,
2122
};
22-
use rustc_codegen_ssa::MemFlags;
2323
use rustc_data_structures::fx::FxHashSet;
2424
use rustc_middle::bug;
2525
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
@@ -949,12 +949,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
949949
};
950950
// TODO: rspirv doesn't have insert_variable function
951951
let result_id = builder.id();
952-
let inst = Instruction::new(
953-
Op::Variable,
954-
Some(ptr_ty),
955-
Some(result_id),
956-
vec![Operand::StorageClass(StorageClass::Function)],
957-
);
952+
let inst = Instruction::new(Op::Variable, Some(ptr_ty), Some(result_id), vec![
953+
Operand::StorageClass(StorageClass::Function),
954+
]);
958955
builder.insert_into_block(index, inst).unwrap();
959956
result_id.with_type(ptr_ty)
960957
}
@@ -1024,16 +1021,13 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
10241021
let ((line_start, col_start), (line_end, col_end)) =
10251022
(line_col_range.start, line_col_range.end);
10261023

1027-
self.custom_inst(
1028-
void_ty,
1029-
CustomInst::SetDebugSrcLoc {
1030-
file: Operand::IdRef(file.file_name_op_string_id),
1031-
line_start: Operand::IdRef(self.const_u32(line_start).def(self)),
1032-
line_end: Operand::IdRef(self.const_u32(line_end).def(self)),
1033-
col_start: Operand::IdRef(self.const_u32(col_start).def(self)),
1034-
col_end: Operand::IdRef(self.const_u32(col_end).def(self)),
1035-
},
1036-
);
1024+
self.custom_inst(void_ty, CustomInst::SetDebugSrcLoc {
1025+
file: Operand::IdRef(file.file_name_op_string_id),
1026+
line_start: Operand::IdRef(self.const_u32(line_start).def(self)),
1027+
line_end: Operand::IdRef(self.const_u32(line_end).def(self)),
1028+
col_start: Operand::IdRef(self.const_u32(col_start).def(self)),
1029+
col_end: Operand::IdRef(self.const_u32(col_end).def(self)),
1030+
});
10371031
}
10381032

10391033
// HACK(eddyb) remove the previous instruction if made irrelevant.
@@ -1381,14 +1375,11 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
13811375
let signed = match ty.kind() {
13821376
ty::Int(_) => true,
13831377
ty::Uint(_) => false,
1384-
other => self.fatal(format!(
1385-
"Unexpected {} type: {other:#?}",
1386-
match oop {
1387-
OverflowOp::Add => "checked add",
1388-
OverflowOp::Sub => "checked sub",
1389-
OverflowOp::Mul => "checked mul",
1390-
}
1391-
)),
1378+
other => self.fatal(format!("Unexpected {} type: {other:#?}", match oop {
1379+
OverflowOp::Add => "checked add",
1380+
OverflowOp::Sub => "checked sub",
1381+
OverflowOp::Mul => "checked mul",
1382+
})),
13921383
};
13931384

13941385
let result = if is_add {

crates/rustc_codegen_spirv/src/builder/intrinsics.rs

+30-40
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use rustc_codegen_ssa::traits::{BuilderMethods, IntrinsicCallMethods};
1515
use rustc_middle::ty::layout::LayoutOf;
1616
use rustc_middle::ty::{FnDef, Instance, ParamEnv, Ty, TyKind};
1717
use rustc_middle::{bug, ty};
18-
use rustc_span::sym;
1918
use rustc_span::Span;
19+
use rustc_span::sym;
2020
use rustc_target::abi::call::{FnAbi, PassMode};
2121
use std::assert_matches::assert_matches;
2222

@@ -161,11 +161,10 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
161161
}
162162
sym::sinf32 | sym::sinf64 => self.gl_op(GLOp::Sin, ret_ty, [args[0].immediate()]),
163163
sym::cosf32 | sym::cosf64 => self.gl_op(GLOp::Cos, ret_ty, [args[0].immediate()]),
164-
sym::powf32 | sym::powf64 => self.gl_op(
165-
GLOp::Pow,
166-
ret_ty,
167-
[args[0].immediate(), args[1].immediate()],
168-
),
164+
sym::powf32 | sym::powf64 => self.gl_op(GLOp::Pow, ret_ty, [
165+
args[0].immediate(),
166+
args[1].immediate(),
167+
]),
169168
sym::expf32 | sym::expf64 => self.gl_op(GLOp::Exp, ret_ty, [args[0].immediate()]),
170169
sym::exp2f32 | sym::exp2f64 => self.gl_op(GLOp::Exp2, ret_ty, [args[0].immediate()]),
171170
sym::logf32 | sym::logf64 => self.gl_op(GLOp::Log, ret_ty, [args[0].immediate()]),
@@ -177,26 +176,20 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
177176
let ln = self.gl_op(GLOp::Log, ret_ty, [args[0].immediate()]);
178177
self.mul(mul, ln)
179178
}
180-
sym::fmaf32 | sym::fmaf64 => self.gl_op(
181-
GLOp::Fma,
182-
ret_ty,
183-
[
184-
args[0].immediate(),
185-
args[1].immediate(),
186-
args[2].immediate(),
187-
],
188-
),
179+
sym::fmaf32 | sym::fmaf64 => self.gl_op(GLOp::Fma, ret_ty, [
180+
args[0].immediate(),
181+
args[1].immediate(),
182+
args[2].immediate(),
183+
]),
189184
sym::fabsf32 | sym::fabsf64 => self.gl_op(GLOp::FAbs, ret_ty, [args[0].immediate()]),
190-
sym::minnumf32 | sym::minnumf64 => self.gl_op(
191-
GLOp::FMin,
192-
ret_ty,
193-
[args[0].immediate(), args[1].immediate()],
194-
),
195-
sym::maxnumf32 | sym::maxnumf64 => self.gl_op(
196-
GLOp::FMax,
197-
ret_ty,
198-
[args[0].immediate(), args[1].immediate()],
199-
),
185+
sym::minnumf32 | sym::minnumf64 => self.gl_op(GLOp::FMin, ret_ty, [
186+
args[0].immediate(),
187+
args[1].immediate(),
188+
]),
189+
sym::maxnumf32 | sym::maxnumf64 => self.gl_op(GLOp::FMax, ret_ty, [
190+
args[0].immediate(),
191+
args[1].immediate(),
192+
]),
200193
sym::copysignf32 | sym::copysignf64 => {
201194
let val = args[0].immediate();
202195
let sign = args[1].immediate();
@@ -403,21 +396,18 @@ impl Builder<'_, '_> {
403396
// so the best thing we can do is use our own custom instruction.
404397
let kind_id = self.emit().string(kind);
405398
let message_debug_printf_fmt_str_id = self.emit().string(message_debug_printf_fmt_str);
406-
self.custom_inst(
407-
void_ty,
408-
CustomInst::Abort {
409-
kind: Operand::IdRef(kind_id),
410-
message_debug_printf: [message_debug_printf_fmt_str_id]
411-
.into_iter()
412-
.chain(
413-
message_debug_printf_args
414-
.into_iter()
415-
.map(|arg| arg.def(self)),
416-
)
417-
.map(Operand::IdRef)
418-
.collect(),
419-
},
420-
);
399+
self.custom_inst(void_ty, CustomInst::Abort {
400+
kind: Operand::IdRef(kind_id),
401+
message_debug_printf: [message_debug_printf_fmt_str_id]
402+
.into_iter()
403+
.chain(
404+
message_debug_printf_args
405+
.into_iter()
406+
.map(|arg| arg.def(self)),
407+
)
408+
.map(Operand::IdRef)
409+
.collect(),
410+
});
421411
self.unreachable();
422412

423413
// HACK(eddyb) we still need an active block in case the user of this

crates/rustc_codegen_spirv/src/builder/libm_intrinsics.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,10 @@ impl Builder<'_, '_> {
230230
}
231231
LibmIntrinsic::Custom(LibmCustomIntrinsic::Cbrt) => {
232232
assert_eq!(args.len(), 1);
233-
self.gl_op(
234-
GLOp::Pow,
235-
result_type,
236-
[args[0], self.constant_float(args[0].ty, 1.0 / 3.0)],
237-
)
233+
self.gl_op(GLOp::Pow, result_type, [
234+
args[0],
235+
self.constant_float(args[0].ty, 1.0 / 3.0),
236+
])
238237
}
239238
LibmIntrinsic::Custom(LibmCustomIntrinsic::Log10) => {
240239
assert_eq!(args.len(), 1);

crates/rustc_codegen_spirv/src/builder/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ use rustc_middle::ty::layout::{
3131
TyAndLayout,
3232
};
3333
use rustc_middle::ty::{Instance, ParamEnv, Ty, TyCtxt};
34-
use rustc_span::def_id::DefId;
3534
use rustc_span::Span;
35+
use rustc_span::def_id::DefId;
3636
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
3737
use rustc_target::abi::{HasDataLayout, Size, TargetDataLayout};
3838
use rustc_target::spec::{HasTargetSpec, Target};

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::builder_spirv::{BuilderCursor, SpirvValue};
66
use crate::codegen_cx::CodegenCx;
77
use crate::spirv_type::SpirvType;
88
use rspirv::dr;
9-
use rspirv::grammar::{reflect, LogicalOperand, OperandKind, OperandQuantifier};
9+
use rspirv::grammar::{LogicalOperand, OperandKind, OperandQuantifier, reflect};
1010
use rspirv::spirv::{
1111
CooperativeMatrixOperands, FPFastMathMode, FragmentShadingRate, FunctionControl,
1212
GroupOperation, ImageOperands, KernelProfilingInfo, LoopControl, MemoryAccess, MemorySemantics,
@@ -17,7 +17,7 @@ use rustc_codegen_ssa::mir::place::PlaceRef;
1717
use rustc_codegen_ssa::traits::{AsmBuilderMethods, InlineAsmOperandRef};
1818
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1919
use rustc_middle::{bug, ty::Instance};
20-
use rustc_span::{Span, DUMMY_SP};
20+
use rustc_span::{DUMMY_SP, Span};
2121
use rustc_target::asm::{InlineAsmRegClass, InlineAsmRegOrRegClass, SpirVInlineAsmRegClass};
2222

2323
pub struct InstructionTable {
@@ -610,7 +610,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
610610
id_to_type_map: &FxHashMap<Word, Word>,
611611
instruction: &dr::Instruction,
612612
) -> Option<Word> {
613-
use crate::spirv_type_constraints::{instruction_signatures, InstSig, TyListPat, TyPat};
613+
use crate::spirv_type_constraints::{InstSig, TyListPat, TyPat, instruction_signatures};
614614

615615
#[derive(Debug)]
616616
struct Unapplicable;

crates/rustc_codegen_spirv/src/builder_spirv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_middle::mir::interpret::ConstAllocation;
2121
use rustc_middle::ty::TyCtxt;
2222
use rustc_span::source_map::SourceMap;
2323
use rustc_span::symbol::Symbol;
24-
use rustc_span::{FileName, FileNameDisplayPreference, SourceFile, Span, DUMMY_SP};
24+
use rustc_span::{DUMMY_SP, FileName, FileNameDisplayPreference, SourceFile, Span};
2525
use rustc_target::abi::Size;
2626
use std::assert_matches::assert_matches;
2727
use std::cell::{RefCell, RefMut};

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use crate::spirv_type::SpirvType;
88
use rspirv::spirv::Word;
99
use rustc_codegen_ssa::traits::{ConstMethods, MiscMethods, StaticMethods};
1010
use rustc_middle::bug;
11-
use rustc_middle::mir::interpret::{alloc_range, ConstAllocation, GlobalAlloc, Scalar};
11+
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar, alloc_range};
1212
use rustc_middle::ty::layout::LayoutOf;
13-
use rustc_span::{Span, DUMMY_SP};
13+
use rustc_span::{DUMMY_SP, Span};
1414
use rustc_target::abi::{self, AddressSpace, Float, HasDataLayout, Integer, Primitive, Size};
1515

1616
impl<'tcx> CodegenCx<'tcx> {
@@ -165,17 +165,11 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
165165
.layout_of(self.tcx.types.str_)
166166
.spirv_type(DUMMY_SP, self);
167167
(
168-
self.def_constant(
169-
self.type_ptr_to(str_ty),
170-
SpirvConst::PtrTo {
171-
pointee: self
172-
.constant_composite(
173-
str_ty,
174-
s.bytes().map(|b| self.const_u8(b).def_cx(self)),
175-
)
176-
.def_cx(self),
177-
},
178-
),
168+
self.def_constant(self.type_ptr_to(str_ty), SpirvConst::PtrTo {
169+
pointee: self
170+
.constant_composite(str_ty, s.bytes().map(|b| self.const_u8(b).def_cx(self)))
171+
.def_cx(self),
172+
}),
179173
self.const_usize(len as u64),
180174
)
181175
}

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}
1717
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
1818
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf};
1919
use rustc_middle::ty::{self, Instance, ParamEnv, TypeVisitableExt};
20-
use rustc_span::def_id::DefId;
2120
use rustc_span::Span;
21+
use rustc_span::def_id::DefId;
2222
use rustc_target::abi::Align;
2323

2424
fn attrs_to_spirv(attrs: &CodegenFnAttrs) -> FunctionControl {
@@ -131,16 +131,13 @@ impl<'tcx> CodegenCx<'tcx> {
131131

132132
let declared = fn_id.with_type(function_type);
133133

134-
let attrs = AggregatedSpirvAttributes::parse(
135-
self,
136-
match self.tcx.def_kind(def_id) {
137-
// This was made to ICE cross-crate at some point, but then got
138-
// reverted in https://github.com/rust-lang/rust/pull/111381.
139-
// FIXME(eddyb) remove this workaround once we rustup past that.
140-
DefKind::Closure => &[],
141-
_ => self.tcx.get_attrs_unchecked(def_id),
142-
},
143-
);
134+
let attrs = AggregatedSpirvAttributes::parse(self, match self.tcx.def_kind(def_id) {
135+
// This was made to ICE cross-crate at some point, but then got
136+
// reverted in https://github.com/rust-lang/rust/pull/111381.
137+
// FIXME(eddyb) remove this workaround once we rustup past that.
138+
DefKind::Closure => &[],
139+
_ => self.tcx.get_attrs_unchecked(def_id),
140+
});
144141
if let Some(entry) = attrs.entry.map(|attr| attr.value) {
145142
let entry_name = entry
146143
.name
@@ -342,12 +339,9 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> {
342339

343340
impl<'tcx> StaticMethods for CodegenCx<'tcx> {
344341
fn static_addr_of(&self, cv: Self::Value, _align: Align, _kind: Option<&str>) -> Self::Value {
345-
self.def_constant(
346-
self.type_ptr_to(cv.ty),
347-
SpirvConst::PtrTo {
348-
pointee: cv.def_cx(self),
349-
},
350-
)
342+
self.def_constant(self.type_ptr_to(cv.ty), SpirvConst::PtrTo {
343+
pointee: cv.def_cx(self),
344+
})
351345
}
352346

353347
fn codegen_static(&self, def_id: DefId) {

crates/rustc_codegen_spirv/src/codegen_cx/entry.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,10 @@ impl<'tcx> CodegenCx<'tcx> {
354354
if !ref_is_read_only && storage_class_requires_read_only {
355355
let mut err = self.tcx.dcx().struct_span_err(
356356
hir_param.ty_span,
357-
format!(
358-
"entry-point requires {}...",
359-
match explicit_mutbl {
360-
hir::Mutability::Not => "interior mutability",
361-
hir::Mutability::Mut => "a mutable reference",
362-
}
363-
),
357+
format!("entry-point requires {}...", match explicit_mutbl {
358+
hir::Mutability::Not => "interior mutability",
359+
hir::Mutability::Mut => "a mutable reference",
360+
}),
364361
);
365362
{
366363
let note_message =
@@ -448,11 +445,9 @@ impl<'tcx> CodegenCx<'tcx> {
448445
let mut emit = self.emit_global();
449446
let spec_const_id =
450447
emit.spec_constant_bit32(value_spirv_type, default.unwrap_or(0));
451-
emit.decorate(
452-
spec_const_id,
453-
Decoration::SpecId,
454-
[Operand::LiteralBit32(id)],
455-
);
448+
emit.decorate(spec_const_id, Decoration::SpecId, [Operand::LiteralBit32(
449+
id,
450+
)]);
456451
(
457452
Err("`#[spirv(spec_constant)]` is not an entry-point interface variable"),
458453
Ok(spec_const_id),
@@ -744,13 +739,12 @@ impl<'tcx> CodegenCx<'tcx> {
744739
..
745740
} => true,
746741
SpirvType::RuntimeArray { element: elt, .. }
747-
| SpirvType::Array { element: elt, .. } => matches!(
748-
self.lookup_type(elt),
749-
SpirvType::Image {
742+
| SpirvType::Array { element: elt, .. } => {
743+
matches!(self.lookup_type(elt), SpirvType::Image {
750744
dim: Dim::DimSubpassData,
751745
..
752-
}
753-
),
746+
})
747+
}
754748
_ => false,
755749
};
756750
if let Some(attachment_index) = attrs.input_attachment_index {

0 commit comments

Comments
 (0)