Skip to content

Commit f99a103

Browse files
committed
rustup: update to nightly-2024-09-01 (~1.82).
1 parent edb937b commit f99a103

26 files changed

+130
-158
lines changed

Cargo.lock

+26-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rustc_codegen_spirv/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ regex = { version = "1", features = ["perf"] }
4141

4242
# HACK(eddyb) deps of `rustc_codegen_ssa`, for `pqp_cg_ssa` (see `build.rs`),
4343
# that cannot be handled with just `extern crate` pulling out of the sysroot.
44-
object = { version = "0.32.1", default-features = false, features = ["read_core", "elf", "macho", "pe", "xcoff", "unaligned", "archive", "write", "wasm"] }
44+
object = { version = "0.36.2", default-features = false, features = ["read_core", "elf", "macho", "pe", "xcoff", "unaligned", "archive", "write", "wasm"] }
4545
thorin-dwp = "0.7"
4646

4747
# Normal dependencies.

crates/rustc_codegen_spirv/build.rs

+3-3
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-07-20"
18+
channel = "nightly-2024-09-01"
1919
components = ["rust-src", "rustc-dev", "llvm-tools"]
20-
# commit_hash = 9057c3ffec44926d5e149dc13ff3ce1613b69cce"#;
20+
# commit_hash = a7399ba69d37b019677a9c47fe89ceb8dd82db2d"#;
2121

2222
fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
2323
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
@@ -145,7 +145,7 @@ fn generate_pqp_cg_ssa() -> Result<(), Box<dyn Error>> {
145145
for line in mem::take(&mut src).lines() {
146146
if line.starts_with("#!") {
147147
src += "// ";
148-
if !line.starts_with("#![doc(") {
148+
if !line.starts_with("#![doc(") && line != "#![warn(unreachable_pub)]" {
149149
writeln(&mut cg_ssa_lib_rc_attrs, line);
150150
}
151151
} else if line == "#[macro_use]" || line.starts_with("extern crate ") {

crates/rustc_codegen_spirv/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ fn dig_scalar_pointee<'tcx>(
548548
TyKind::Ref(_, pointee_ty, _) | TyKind::RawPtr(pointee_ty, _) => {
549549
PointeeTy::Ty(cx.layout_of(pointee_ty))
550550
}
551-
TyKind::FnPtr(sig) => PointeeTy::Fn(sig),
551+
TyKind::FnPtr(sig_tys, hdr) => PointeeTy::Fn(sig_tys.with(hdr)),
552552
_ => bug!("Pointer is not `&T`, `*T` or `fn` pointer: {:#?}", layout),
553553
};
554554
return pointee;

crates/rustc_codegen_spirv/src/attr.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,14 @@ impl AggregatedSpirvAttributes {
182182
span: Span,
183183
category: &'static str,
184184
) -> Result<(), MultipleAttrs> {
185-
match slot {
186-
Some(prev) => Err(MultipleAttrs {
185+
if let Some(prev) = slot {
186+
Err(MultipleAttrs {
187187
prev_span: prev.span,
188188
category,
189-
}),
190-
None => {
191-
*slot = Some(Spanned { value, span });
192-
Ok(())
193-
}
189+
})
190+
} else {
191+
*slot = Some(Spanned { value, span });
192+
Ok(())
194193
}
195194
}
196195

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ macro_rules! simple_op {
5656
_ => return None,
5757
};
5858
Some(if signed {
59-
size.sign_extend(x)
59+
size.sign_extend(x) as u128
6060
} else {
6161
size.truncate(x)
6262
})

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

+17-20
Original file line numberDiff line numberDiff line change
@@ -857,12 +857,11 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
857857
place,
858858
} => {
859859
self.check_reg(span, reg);
860-
match place {
861-
Some(place) => Some(OutRegister::Place(*place)),
862-
None => {
863-
self.tcx.dcx().span_err(span, "missing place for register");
864-
None
865-
}
860+
if let Some(place) = place {
861+
Some(OutRegister::Place(*place))
862+
} else {
863+
self.tcx.dcx().span_err(span, "missing place for register");
864+
None
866865
}
867866
}
868867
InlineAsmOperandRef::InOut {
@@ -872,12 +871,11 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
872871
out_place,
873872
} => {
874873
self.check_reg(span, reg);
875-
match out_place {
876-
Some(out_place) => Some(OutRegister::Place(*out_place)),
877-
None => {
878-
self.tcx.dcx().span_err(span, "missing place for register");
879-
None
880-
}
874+
if let Some(out_place) = out_place {
875+
Some(OutRegister::Place(*out_place))
876+
} else {
877+
self.tcx.dcx().span_err(span, "missing place for register");
878+
None
881879
}
882880
}
883881
InlineAsmOperandRef::Const { string: _ } => {
@@ -953,8 +951,8 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
953951
place,
954952
} => {
955953
self.check_reg(span, reg);
956-
match place {
957-
Some(place) => match self.lookup_type(place.val.llval.ty) {
954+
if let Some(place) = place {
955+
match self.lookup_type(place.val.llval.ty) {
958956
SpirvType::Pointer { pointee } => Some(pointee),
959957
other => {
960958
self.tcx.dcx().span_err(
@@ -966,13 +964,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
966964
);
967965
None
968966
}
969-
},
970-
None => {
971-
self.tcx
972-
.dcx()
973-
.span_err(span, "missing place for out register typeof");
974-
None
975967
}
968+
} else {
969+
self.tcx
970+
.dcx()
971+
.span_err(span, "missing place for out register typeof");
972+
None
976973
}
977974
}
978975
InlineAsmOperandRef::InOut {

crates/rustc_codegen_spirv/src/builder_spirv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ impl<'tcx> BuilderSpirv<'tcx> {
577577
(SpirvConst::Scalar(val), Some(SpirvType::Integer(bits, signed))) => {
578578
let size = Size::from_bits(bits);
579579
SpirvConst::Scalar(if signed {
580-
size.sign_extend(val)
580+
size.sign_extend(val) as u128
581581
} else {
582582
size.truncate(val)
583583
})

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
195195
.def(DUMMY_SP, self);
196196
self.constant_composite(struct_ty, elts.iter().map(|f| f.def_cx(self)))
197197
}
198+
fn const_vector(&self, elts: &[Self::Value]) -> Self::Value {
199+
let vector_ty = SpirvType::Vector {
200+
element: elts[0].ty,
201+
count: elts.len() as u32,
202+
}
203+
.def(DUMMY_SP, self);
204+
self.constant_composite(vector_ty, elts.iter().map(|elt| elt.def_cx(self)))
205+
}
198206

199207
fn const_to_opt_uint(&self, v: Self::Value) -> Option<u64> {
200208
self.builder.lookup_const_scalar(v)?.try_into().ok()
@@ -247,10 +255,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
247255
let value = self.static_addr_of(init, alloc.inner().align, None);
248256
(value, AddressSpace::DATA)
249257
}
250-
GlobalAlloc::Function {
251-
instance,
252-
unique: _,
253-
} => (
258+
GlobalAlloc::Function { instance } => (
254259
self.get_fn_addr(instance.polymorphize(self.tcx)),
255260
self.data_layout().instruction_address_space,
256261
),

crates/rustc_codegen_spirv/src/codegen_cx/entry.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,10 @@ impl<'tcx> CodegenCx<'tcx> {
831831
}
832832
}
833833
}
834-
// Emitted earlier.
835-
Err(SpecConstant { .. }) => {}
834+
Err(not_var) => {
835+
// Emitted earlier.
836+
let SpecConstant { .. } = not_var;
837+
}
836838
}
837839
}
838840

crates/rustc_codegen_spirv/src/custom_decorations.rs

+10-55
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use crate::builder_spirv::BuilderSpirv;
55
use crate::custom_insts::{self, CustomInst};
66
use either::Either;
7-
use itertools::Itertools;
87
use rspirv::dr::{Instruction, Module, Operand};
98
use rspirv::spirv::{Decoration, Op, Word};
109
use rustc_data_structures::fx::FxIndexMap;
@@ -14,7 +13,6 @@ use rustc_span::{FileName, SourceFile};
1413
use smallvec::SmallVec;
1514
use std::borrow::Cow;
1615
use std::marker::PhantomData;
17-
use std::ops::Range;
1816
use std::path::PathBuf;
1917
use std::{fmt, iter, slice, str};
2018

@@ -495,61 +493,18 @@ impl<'a> SpanRegenerator<'a> {
495493
// called with `line`/`col` values that are near eachother - thankfully,
496494
// this code should only be hit on the error reporting path anyway.
497495
let line_col_to_bpos = |line: u32, col: u32| {
498-
let line_bpos_range = file.line_bounds(line.checked_sub(1)? as usize);
499-
500-
// Find the special cases (`MultiByteChar`s/`NonNarrowChar`s) in the line.
501-
let multibyte_chars = {
502-
let find = |bpos| {
503-
file.multibyte_chars
504-
.binary_search_by_key(&file.relative_position(bpos), |mbc| mbc.pos)
505-
.unwrap_or_else(|x| x)
506-
};
507-
let Range { start, end } = line_bpos_range;
508-
file.multibyte_chars[find(start)..find(end)].iter()
509-
};
510-
let non_narrow_chars = {
511-
let find = |bpos| {
512-
file.non_narrow_chars
513-
.binary_search_by_key(&file.relative_position(bpos), |nnc| nnc.pos())
514-
.unwrap_or_else(|x| x)
515-
};
516-
let Range { start, end } = line_bpos_range;
517-
file.non_narrow_chars[find(start)..find(end)].iter()
518-
};
519-
let mut special_chars = multibyte_chars
520-
.merge_join_by(non_narrow_chars, |mbc, nnc| mbc.pos.cmp(&nnc.pos()))
521-
.peekable();
522-
523-
// Increment the `BytePos` until we reach the right `col_display`, using
524-
// `MultiByteChar`s/`NonNarrowChar`s to track non-trivial contributions
525-
// (this may look inefficient, but lines tend to be short, and `rustc`
526-
// itself is even worse than this, when it comes to `BytePos` lookups).
496+
let line_idx_in_file = line.checked_sub(1)? as usize;
497+
let line_bpos_range = file.line_bounds(line_idx_in_file);
498+
let line_contents = file.get_line(line_idx_in_file)?;
499+
500+
// Increment the `BytePos` until we reach the right `col_display`.
527501
let (mut cur_bpos, mut cur_col_display) = (line_bpos_range.start, 0);
502+
let mut line_chars = line_contents.chars();
528503
while cur_bpos < line_bpos_range.end && cur_col_display < col {
529-
let next_special_bpos = special_chars
530-
.peek()
531-
.map(|special| {
532-
special
533-
.as_ref()
534-
.map_any(|mbc| mbc.pos, |nnc| nnc.pos())
535-
.reduce(|x, _| x)
536-
})
537-
.map(|rel_bpos| file.absolute_position(rel_bpos));
538-
539-
// Batch trivial chars (i.e. chars 1:1 wrt `BytePos` vs `col_display`).
540-
let following_trivial_chars =
541-
next_special_bpos.unwrap_or(line_bpos_range.end).0 - cur_bpos.0;
542-
if following_trivial_chars > 0 {
543-
let wanted_trivial_chars = following_trivial_chars.min(col - cur_col_display);
544-
cur_bpos.0 += wanted_trivial_chars;
545-
cur_col_display += wanted_trivial_chars;
546-
continue;
547-
}
548-
549-
// Add a special char's `BytePos` and `col_display` contributions.
550-
let mbc_nnc = special_chars.next().unwrap();
551-
cur_bpos.0 += mbc_nnc.as_ref().left().map_or(1, |mbc| mbc.bytes as u32);
552-
cur_col_display += mbc_nnc.as_ref().right().map_or(1, |nnc| nnc.width() as u32);
504+
// Add each char's `BytePos` and `col_display` contributions.
505+
let ch = line_chars.next()?;
506+
cur_bpos.0 += ch.len_utf8() as u32;
507+
cur_col_display += rustc_span::char_width(ch) as u32;
553508
}
554509
Some(cur_bpos)
555510
};

crates/rustc_codegen_spirv/src/lib.rs

+1-1
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+
#![feature(assert_matches)]
56
#![feature(box_patterns)]
67
#![feature(if_let_guard)]
78
#![feature(let_chains)]
@@ -29,7 +30,6 @@
2930
//! [`spirv-tools`]: https://rust-gpu.github.io/rust-gpu/api/spirv_tools
3031
//! [`spirv-tools-sys`]: https://rust-gpu.github.io/rust-gpu/api/spirv_tools_sys
3132
#![feature(rustc_private)]
32-
#![feature(assert_matches)]
3333
#![feature(result_flattening)]
3434
// crate-specific exceptions:
3535
#![allow(

crates/rustc_codegen_spirv/src/link.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -604,12 +604,11 @@ fn do_link(
604604
disambiguated_crate_name_for_dumps,
605605
);
606606

607-
match link_result {
608-
Ok(v) => v,
609-
Err(rustc_errors::ErrorGuaranteed { .. }) => {
610-
sess.dcx().abort_if_errors();
611-
bug!("Linker errored, but no error reported");
612-
}
607+
if let Ok(v) = link_result {
608+
v
609+
} else {
610+
sess.dcx().abort_if_errors();
611+
bug!("Linker errored, but no error reported");
613612
}
614613
}
615614

crates/spirv-std/src/image/sample_with.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ pub struct NoneTy;
1717
/// Helper struct that denotes that the type does exist and is of type T, analog to `Option::Some(T)`
1818
pub struct SomeTy<T>(pub T);
1919

20-
/// Helper struct that allows building image operands. Start with a global function that returns this
21-
/// struct, and then chain additional calls. No care is taken to avoid stating multiple operands that,
22-
/// together, make no sense, such as Lod and Grad.
20+
/// Helper struct that allows building image operands.
21+
///
22+
/// Start with a global function that returns this struct, and then chain additional calls.
23+
/// No care is taken to avoid stating multiple operands that, together, make no sense, such as Lod and Grad.
2324
/// Example: `image.sample_with(coords, sample_with::bias(3.0).sample_index(1))`
2425
pub struct SampleParams<B: OptionTy, L: OptionTy, G: OptionTy, S: OptionTy> {
2526
/// 'Bias' image operand

0 commit comments

Comments
 (0)