Skip to content

Commit 7e29e3b

Browse files
committed
rustup: update to nightly-2024-07-20 (~1.81).
1 parent 6ada56d commit 7e29e3b

File tree

22 files changed

+121
-134
lines changed

22 files changed

+121
-134
lines changed

.cargo/config.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ compiletest = "run --release -p compiletests --"
33

44
[target.'cfg(all())']
55
rustflags = [
6+
# FIXME(eddyb) update/review these lints.
7+
#
68
# BEGIN - Embark standard lints v6 for Rust 1.55+
79
# do not change or add/remove here, but one can add exceptions after this section
810
# for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
@@ -47,7 +49,6 @@ rustflags = [
4749
"-Wclippy::match_wild_err_arm",
4850
"-Wclippy::match_wildcard_for_single_variants",
4951
"-Wclippy::mem_forget",
50-
"-Wclippy::mismatched_target_os",
5152
"-Wclippy::missing_enforced_import_renames",
5253
"-Wclippy::mut_mut",
5354
"-Wclippy::mutex_integer",

crates/rustc_codegen_spirv/build.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use std::{env, fs, mem};
1515
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1616
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
1717
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
18-
channel = "nightly-2024-06-08"
18+
channel = "nightly-2024-07-20"
1919
components = ["rust-src", "rustc-dev", "llvm-tools"]
20-
# commit_hash = 804421dff5542c9c7da5c60257b5dbc849719505"#;
20+
# commit_hash = 9057c3ffec44926d5e149dc13ff3ce1613b69cce"#;
2121

2222
fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
2323
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
@@ -189,8 +189,8 @@ mod win {",
189189
);
190190
} else if relative_path == Path::new("src/mir/place.rs") {
191191
src = src.replace(
192-
"PlaceValue::alloca(bx, layout.size, layout.align.abi)",
193-
"PlaceValue::new_sized(bx.typed_alloca(bx.cx().backend_type(layout), layout.align.abi), layout.align.abi)",
192+
"Self::alloca_size(bx, layout.size, layout)",
193+
"PlaceValue::new_sized(bx.typed_alloca(bx.cx().backend_type(layout), layout.align.abi), layout.align.abi).with_type(layout)",
194194
);
195195
} else if relative_path == Path::new("src/mir/operand.rs") {
196196
src = src.replace("alloca(field.size,", "typed_alloca(llfield_ty,");

crates/rustc_codegen_spirv/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ fn trans_intrinsic_type<'tcx>(
867867

868868
impl FromScalarInt for u32 {
869869
fn from_scalar_int(n: ScalarInt) -> Option<Self> {
870-
n.try_to_u32().ok()
870+
Some(n.try_to_bits(Size::from_bits(32)).ok()?.try_into().unwrap())
871871
}
872872
}
873873

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -2020,13 +2020,11 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
20202020
SpirvType::Pointer { .. } => match op {
20212021
IntEQ => {
20222022
if self.emit().version().unwrap() > (1, 3) {
2023-
let ptr_equal =
2024-
self.emit().ptr_equal(b, None, lhs.def(self), rhs.def(self));
2025-
2026-
ptr_equal.map(|result| {
2027-
self.zombie_ptr_equal(result, "OpPtrEqual");
2028-
result
2029-
})
2023+
self.emit()
2024+
.ptr_equal(b, None, lhs.def(self), rhs.def(self))
2025+
.inspect(|&result| {
2026+
self.zombie_ptr_equal(result, "OpPtrEqual");
2027+
})
20302028
} else {
20312029
let int_ty = self.type_usize();
20322030
let lhs = self
@@ -2039,16 +2037,15 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
20392037
.convert_ptr_to_u(int_ty, None, rhs.def(self))
20402038
.unwrap();
20412039
self.zombie_convert_ptr_to_u(rhs);
2042-
self.emit().i_not_equal(b, None, lhs, rhs)
2040+
self.emit().i_equal(b, None, lhs, rhs)
20432041
}
20442042
}
20452043
IntNE => {
20462044
if self.emit().version().unwrap() > (1, 3) {
20472045
self.emit()
20482046
.ptr_not_equal(b, None, lhs.def(self), rhs.def(self))
2049-
.map(|result| {
2047+
.inspect(|&result| {
20502048
self.zombie_ptr_equal(result, "OpPtrNotEqual");
2051-
result
20522049
})
20532050
} else {
20542051
let int_ty = self.type_usize();

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

+21-17
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
214214
match scalar {
215215
Scalar::Int(int) => {
216216
assert_eq!(int.size(), layout.primitive().size(self));
217-
let data = int.assert_uint(int.size());
217+
let data = int.to_uint(int.size());
218218

219219
if let Primitive::Pointer(_) = layout.primitive() {
220220
if data == 0 {
@@ -247,8 +247,11 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
247247
let value = self.static_addr_of(init, alloc.inner().align, None);
248248
(value, AddressSpace::DATA)
249249
}
250-
GlobalAlloc::Function(fn_instance) => (
251-
self.get_fn_addr(fn_instance.polymorphize(self.tcx)),
250+
GlobalAlloc::Function {
251+
instance,
252+
unique: _,
253+
} => (
254+
self.get_fn_addr(instance.polymorphize(self.tcx)),
252255
self.data_layout().instruction_address_space,
253256
),
254257
GlobalAlloc::VTable(vty, trait_ref) => {
@@ -304,7 +307,21 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
304307
self.def_constant(void_type, SpirvConst::ConstDataFromAlloc(alloc))
305308
}
306309

307-
fn const_bitcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value {
310+
fn const_ptr_byte_offset(&self, val: Self::Value, offset: Size) -> Self::Value {
311+
if offset == Size::ZERO {
312+
val
313+
} else {
314+
// FIXME(eddyb) implement via `OpSpecConstantOp`.
315+
// FIXME(eddyb) this zombies the original value without creating a new one.
316+
let result = val;
317+
self.zombie_no_span(result.def_cx(self), "const_ptr_byte_offset");
318+
result
319+
}
320+
}
321+
}
322+
323+
impl<'tcx> CodegenCx<'tcx> {
324+
pub fn const_bitcast(&self, val: SpirvValue, ty: Word) -> SpirvValue {
308325
// HACK(eddyb) special-case `const_data_from_alloc` + `static_addr_of`
309326
// as the old `from_const_alloc` (now `OperandRef::from_const_alloc`).
310327
if let SpirvValueKind::IllegalConst(_) = val.kind {
@@ -331,20 +348,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
331348
result
332349
}
333350
}
334-
fn const_ptr_byte_offset(&self, val: Self::Value, offset: Size) -> Self::Value {
335-
if offset == Size::ZERO {
336-
val
337-
} else {
338-
// FIXME(eddyb) implement via `OpSpecConstantOp`.
339-
// FIXME(eddyb) this zombies the original value without creating a new one.
340-
let result = val;
341-
self.zombie_no_span(result.def_cx(self), "const_ptr_byte_offset");
342-
result
343-
}
344-
}
345-
}
346351

347-
impl<'tcx> CodegenCx<'tcx> {
348352
// This function comes from `ty::layout`'s `layout_of_uncached`,
349353
// where it's named `scalar_unit`.
350354
pub fn primitive_to_scalar(&self, value: Primitive) -> abi::Scalar {

crates/rustc_codegen_spirv/src/codegen_cx/mod.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,11 @@ impl CodegenArgs {
598598

599599
let matches_opt_path = |name| matches.opt_str(name).map(PathBuf::from);
600600
let matches_opt_dump_dir_path = |name| {
601-
matches_opt_path(name).map(|path| {
601+
matches_opt_path(name).inspect(|path| {
602602
if path.is_file() {
603-
std::fs::remove_file(&path).unwrap();
603+
std::fs::remove_file(path).unwrap();
604604
}
605-
std::fs::create_dir_all(&path).unwrap();
606-
path
605+
std::fs::create_dir_all(path).unwrap();
607606
})
608607
};
609608
// FIXME(eddyb) should these be handled as `-C linker-args="..."` instead?
@@ -852,10 +851,6 @@ impl<'tcx> MiscMethods<'tcx> for CodegenCx<'tcx> {
852851
&self.vtables
853852
}
854853

855-
fn check_overflow(&self) -> bool {
856-
self.tcx.sess.overflow_checks()
857-
}
858-
859854
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function {
860855
self.get_fn_ext(instance)
861856
}

crates/rustc_codegen_spirv/src/codegen_cx/type_.rs

-16
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ impl<'tcx> CodegenCx<'tcx> {
128128
}
129129

130130
impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> {
131-
fn type_i1(&self) -> Self::Type {
132-
SpirvType::Bool.def(DUMMY_SP, self)
133-
}
134131
fn type_i8(&self) -> Self::Type {
135132
SpirvType::Integer(8, false).def(DUMMY_SP, self)
136133
}
@@ -179,19 +176,6 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> {
179176
}
180177
.def(DUMMY_SP, self)
181178
}
182-
fn type_struct(&self, els: &[Self::Type], _packed: bool) -> Self::Type {
183-
// FIXME(eddyb) use `AccumulateVec`s just like `rustc` itself does.
184-
let (field_offsets, size, align) = crate::abi::auto_struct_layout(self, els);
185-
SpirvType::Adt {
186-
def_id: None,
187-
align,
188-
size,
189-
field_types: els,
190-
field_offsets: &field_offsets,
191-
field_names: None,
192-
}
193-
.def(DUMMY_SP, self)
194-
}
195179
fn type_kind(&self, ty: Self::Type) -> TypeKind {
196180
match self.lookup_type(ty) {
197181
SpirvType::Void => TypeKind::Void,

crates/rustc_codegen_spirv/src/custom_insts.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ 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::StableHasher;
46+
use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
4747
use std::hash::Hash;
4848

4949
let mut hasher = StableHasher::new();
5050
SCHEMA.hash(&mut hasher);
51-
let (lo, hi) = hasher.finalize();
52-
(lo as u128) | ((hi as u128) << 64)
51+
hasher.finish::<Hash128>().as_u128()
5352
};
5453
let version = join_cargo_pkg_version_major_minor_patch!("_");
5554
format!("{CUSTOM_EXT_INST_SET_PREFIX}{version}.{schema_hash:x}")

crates/rustc_codegen_spirv/src/lib.rs

+15-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// HACK(eddyb) start of `rustc_codegen_ssa` crate-level attributes (see `build.rs`).
2-
#![feature(rustdoc_internals)]
32
#![allow(internal_features)]
43
#![allow(rustc::diagnostic_outside_of_impl)]
54
#![allow(rustc::untranslatable_diagnostic)]
65
#![feature(box_patterns)]
76
#![feature(if_let_guard)]
87
#![feature(let_chains)]
98
#![feature(negative_impls)]
9+
#![feature(rustdoc_internals)]
1010
#![feature(strict_provenance)]
1111
#![feature(try_blocks)]
1212
// HACK(eddyb) end of `rustc_codegen_ssa` crate-level attributes (see `build.rs`).
@@ -31,7 +31,6 @@
3131
#![feature(rustc_private)]
3232
#![feature(assert_matches)]
3333
#![feature(result_flattening)]
34-
#![feature(lint_reasons)]
3534
// crate-specific exceptions:
3635
#![allow(
3736
unsafe_code, // rustc_codegen_ssa requires unsafe functions in traits to be impl'd
@@ -146,13 +145,13 @@ use maybe_pqp_cg_ssa::{CodegenResults, CompiledModule, ModuleCodegen, ModuleKind
146145
use rspirv::binary::Assemble;
147146
use rustc_ast::expand::allocator::AllocatorKind;
148147
use rustc_data_structures::fx::FxIndexMap;
149-
use rustc_errors::{DiagCtxt, ErrorGuaranteed, FatalError};
148+
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError};
150149
use rustc_metadata::EncodedMetadata;
151150
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
152151
use rustc_middle::mir::mono::{MonoItem, MonoItemData};
153152
use rustc_middle::mir::pretty::write_mir_pretty;
154153
use rustc_middle::ty::print::with_no_trimmed_paths;
155-
use rustc_middle::ty::{self, Instance, InstanceDef, TyCtxt};
154+
use rustc_middle::ty::{self, Instance, InstanceKind, TyCtxt};
156155
use rustc_session::config::{self, OutputFilenames, OutputType};
157156
use rustc_session::Session;
158157
use rustc_span::symbol::{sym, Symbol};
@@ -168,7 +167,7 @@ fn dump_mir(tcx: TyCtxt<'_>, mono_items: &[(MonoItem<'_>, MonoItemData)], path:
168167
let mut file = File::create(path).unwrap();
169168
for &(mono_item, _) in mono_items {
170169
if let MonoItem::Fn(instance) = mono_item {
171-
if matches!(instance.def, InstanceDef::Item(_)) {
170+
if matches!(instance.def, InstanceKind::Item(_)) {
172171
let mut mir = Cursor::new(Vec::new());
173172
if write_mir_pretty(tcx, Some(instance.def_id()), &mut mir).is_ok() {
174173
writeln!(file, "{}", String::from_utf8(mir.into_inner()).unwrap()).unwrap();
@@ -184,7 +183,7 @@ fn is_blocklisted_fn<'tcx>(
184183
instance: Instance<'tcx>,
185184
) -> bool {
186185
// TODO: These sometimes have a constant value of an enum variant with a hole
187-
if let InstanceDef::Item(def_id) = instance.def {
186+
if let InstanceKind::Item(def_id) = instance.def {
188187
if let Some(debug_trait_def_id) = tcx.get_diagnostic_item(sym::Debug) {
189188
// Helper for detecting `<_ as core::fmt::Debug>::fmt` (in impls).
190189
let is_debug_fmt_method = |def_id| match tcx.opt_associated_item(def_id) {
@@ -328,7 +327,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
328327

329328
fn run_link(
330329
_cgcx: &CodegenContext<Self>,
331-
_diag_handler: &DiagCtxt,
330+
_diag_handler: DiagCtxtHandle<'_>,
332331
_modules: Vec<ModuleCodegen<Self::Module>>,
333332
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
334333
todo!()
@@ -360,7 +359,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
360359

361360
unsafe fn optimize(
362361
_: &CodegenContext<Self>,
363-
_: &DiagCtxt,
362+
_: DiagCtxtHandle<'_>,
364363
_: &ModuleCodegen<Self::Module>,
365364
_: &ModuleConfig,
366365
) -> Result<(), FatalError> {
@@ -391,7 +390,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
391390

392391
unsafe fn codegen(
393392
cgcx: &CodegenContext<Self>,
394-
_diag_handler: &DiagCtxt,
393+
_diag_handler: DiagCtxtHandle<'_>,
395394
module: ModuleCodegen<Self::Module>,
396395
_config: &ModuleConfig,
397396
) -> Result<CompiledModule, FatalError> {
@@ -536,16 +535,13 @@ impl Drop for DumpModuleOnPanic<'_, '_, '_> {
536535
#[no_mangle]
537536
pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
538537
// Tweak rustc's default ICE panic hook, to direct people to `rust-gpu`.
539-
rustc_driver::install_ice_hook(
540-
"https://github.com/rust-gpu/rust-gpu/issues/new",
541-
|handler| {
542-
handler.note(concat!(
543-
"`rust-gpu` version `",
544-
env!("CARGO_PKG_VERSION"),
545-
"`"
546-
));
547-
},
548-
);
538+
rustc_driver::install_ice_hook("https://github.com/rust-gpu/rust-gpu/issues/new", |dcx| {
539+
dcx.handle().note(concat!(
540+
"`rust-gpu` version `",
541+
env!("CARGO_PKG_VERSION"),
542+
"`"
543+
));
544+
});
549545

550546
Box::new(SpirvCodegenBackend)
551547
}

crates/rustc_codegen_spirv/src/linker/test.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ fn link_with_linker_opts(
169169

170170
// HACK(eddyb) inject `write_diags` into `sess`, to work around
171171
// the removals in https://github.com/rust-lang/rust/pull/102992.
172-
sess.psess.dcx = {
172+
sess.psess = {
173+
let source_map = sess.psess.clone_source_map();
174+
173175
let fallback_bundle = {
174176
extern crate rustc_error_messages;
175177
rustc_error_messages::fallback_fluent_bundle(
@@ -179,10 +181,13 @@ fn link_with_linker_opts(
179181
};
180182
let emitter =
181183
rustc_errors::emitter::HumanEmitter::new(Box::new(buf), fallback_bundle)
182-
.sm(Some(sess.psess.clone_source_map()));
184+
.sm(Some(source_map.clone()));
183185

184-
rustc_errors::DiagCtxt::new(Box::new(emitter))
185-
.with_flags(sess.opts.unstable_opts.dcx_flags(true))
186+
rustc_session::parse::ParseSess::with_dcx(
187+
rustc_errors::DiagCtxt::new(Box::new(emitter))
188+
.with_flags(sess.opts.unstable_opts.dcx_flags(true)),
189+
source_map,
190+
)
186191
};
187192

188193
let res = link(

crates/spirv-builder/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// FIXME(eddyb) update/review these lints.
2+
//
13
// BEGIN - Embark standard lints v0.4
24
// do not change or add/remove here, but one can add exceptions after this section
35
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
@@ -38,7 +40,6 @@
3840
clippy::match_same_arms,
3941
clippy::match_wildcard_for_single_variants,
4042
clippy::mem_forget,
41-
clippy::mismatched_target_os,
4243
clippy::mut_mut,
4344
clippy::mutex_integer,
4445
clippy::needless_borrow,

crates/spirv-std/macros/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// FIXME(eddyb) update/review these lints.
2+
//
13
// BEGIN - Embark standard lints v0.4
24
// do not change or add/remove here, but one can add exceptions after this section
35
// for more info see: <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
@@ -38,7 +40,6 @@
3840
clippy::match_same_arms,
3941
clippy::match_wildcard_for_single_variants,
4042
clippy::mem_forget,
41-
clippy::mismatched_target_os,
4243
clippy::mut_mut,
4344
clippy::mutex_integer,
4445
clippy::needless_borrow,

0 commit comments

Comments
 (0)