Skip to content

Commit 73454be

Browse files
committed
Update Rust toolchain to nightly-2025-06-23
1 parent 61bb7a5 commit 73454be

24 files changed

Lines changed: 174 additions & 164 deletions

crates/cust/src/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ unsafe impl Send for Function<'_> {}
213213
unsafe impl Sync for Function<'_> {}
214214

215215
impl Function<'_> {
216-
pub(crate) fn new(inner: CUfunction, _module: &Module) -> Function {
216+
pub(crate) fn new(inner: CUfunction, _module: &Module) -> Function<'_> {
217217
Function {
218218
inner,
219219
module: PhantomData,

crates/cust_raw/build/callbacks.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ impl ParseCallbacks for BindgenCallbacks {
4242
match doxygen_bindgen::transform(&cleaned) {
4343
Ok(res) => Some(res),
4444
Err(err) => {
45-
println!(
46-
"cargo:warning=Problem processing doxygen comment: {}\n{}",
47-
comment, err
48-
);
45+
println!("cargo:warning=Problem processing doxygen comment: {comment}\n{err}");
4946
None
5047
}
5148
}
@@ -184,7 +181,7 @@ impl FunctionRenames {
184181

185182
let expanded = match build.try_expand() {
186183
Ok(expanded) => expanded,
187-
Err(e) => panic!("Failed to expand macros: {}", e),
184+
Err(e) => panic!("Failed to expand macros: {e}"),
188185
};
189186
let expanded = str::from_utf8(&expanded).unwrap();
190187

crates/cust_raw/build/cuda_sdk.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl CudaSdk {
164164
cuda_root: &path::Path,
165165
) -> Result<Vec<path::PathBuf>, Box<dyn error::Error>> {
166166
let (target, triple) = Self::parse_target_triple()?;
167-
assert!(triple.len() >= 3, "Invalid target triple: {:?}", triple);
167+
assert!(triple.len() >= 3, "Invalid target triple: {triple:?}");
168168

169169
let search_dirs = match [triple[0].as_str(), triple[1].as_str(), triple[2].as_str()] {
170170
["x86_64", "pc", "windows"] => {
@@ -248,7 +248,7 @@ impl CudaSdk {
248248
.ok_or("Cannot find CUDA_VERSION from CUDA header file.")?;
249249
let version = version
250250
.parse::<u32>()
251-
.map_err(|_| format!("Cannot parse CUDA_VERSION as u32: '{}'", version))?;
251+
.map_err(|_| format!("Cannot parse CUDA_VERSION as u32: '{version}'"))?;
252252
Ok(version)
253253
}
254254

@@ -264,7 +264,7 @@ impl CudaSdk {
264264
.ok_or("Cannot find CUDART_VERSION from cuda_runtime header file.")?;
265265
let version = version
266266
.parse::<u32>()
267-
.map_err(|_| format!("Cannot parse CUDART_VERSION as u32: '{}'", version))?;
267+
.map_err(|_| format!("Cannot parse CUDART_VERSION as u32: '{version}'"))?;
268268
Ok(version)
269269
}
270270

crates/cust_raw/build/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ fn main() {
5959
let metadata_nvvm_include = env::join_paths(sdk.nvvm_include_paths())
6060
.map(|s| s.to_string_lossy().to_string())
6161
.expect("Failed to build metadata for nvvm_include.");
62-
println!("cargo::metadata=includes={}", metadata_cuda_include);
63-
println!("cargo::metadata=nvvm_includes={}", metadata_nvvm_include);
62+
println!("cargo::metadata=includes={metadata_cuda_include}");
63+
println!("cargo::metadata=nvvm_includes={metadata_nvvm_include}");
6464
// Re-run build script conditions.
6565
println!("cargo::rerun-if-changed=build");
6666
for e in sdk.related_cuda_envs() {
67-
println!("cargo::rerun-if-env-changed={}", e);
67+
println!("cargo::rerun-if-env-changed={e}");
6868
}
6969

7070
create_cuda_driver_bindings(&sdk, &outdir, &manifest_dir);

crates/rustc_codegen_nvvm/build.rs

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,15 @@ fn main() {
2626
}
2727

2828
fn fail(s: &str) -> ! {
29-
println!("\n\n{}\n\n", s);
29+
println!("\n\n{s}\n\n");
3030
std::process::exit(1);
3131
}
3232

3333
#[track_caller]
3434
pub fn output(cmd: &mut Command) -> String {
3535
let output = match cmd.stderr(Stdio::inherit()).output() {
3636
Ok(status) => status,
37-
Err(e) => fail(&format!(
38-
"failed to execute command: {:?}\nerror: {}",
39-
cmd, e
40-
)),
37+
Err(e) => fail(&format!("failed to execute command: {cmd:?}\nerror: {e}")),
4138
};
4239
assert!(
4340
output.status.success(),
@@ -56,11 +53,10 @@ fn target_to_llvm_prebuilt(target: &str) -> String {
5653
// NOTE(RDambrosio016): currently disabled because of weird issues with segfaults and building the C++ shim
5754
// "x86_64-unknown-linux-gnu" => "linux-x86_64",
5855
_ => panic!(
59-
"Unsupported target with no matching prebuilt LLVM: `{}`, install LLVM and set LLVM_CONFIG",
60-
target
56+
"Unsupported target with no matching prebuilt LLVM: `{target}`, install LLVM and set LLVM_CONFIG"
6157
),
6258
};
63-
format!("{}.tar.xz", base)
59+
format!("{base}.tar.xz")
6460
}
6561

6662
fn find_llvm_config(target: &str) -> PathBuf {
@@ -79,8 +75,7 @@ fn find_llvm_config(target: &str) -> PathBuf {
7975
return PathBuf::from(path_to_try);
8076
}
8177
println!(
82-
"cargo:warning=Prebuilt llvm-config version does not start with {}",
83-
REQUIRED_MAJOR_LLVM_VERSION
78+
"cargo:warning=Prebuilt llvm-config version does not start with {REQUIRED_MAJOR_LLVM_VERSION}"
8479
);
8580
} else {
8681
println!("cargo:warning=Failed to run prebuilt llvm-config");
@@ -94,7 +89,7 @@ fn find_llvm_config(target: &str) -> PathBuf {
9489
.unwrap_or_else(|| PREBUILT_LLVM_URL.to_string());
9590

9691
let prebuilt_name = target_to_llvm_prebuilt(target);
97-
url = format!("{}{}", url, prebuilt_name);
92+
url = format!("{url}{prebuilt_name}");
9893

9994
let out = env::var("OUT_DIR").expect("OUT_DIR was not set");
10095
let mut easy = Easy::new();
@@ -139,7 +134,7 @@ fn detect_llvm_link() -> (&'static str, &'static str) {
139134
}
140135

141136
pub fn tracked_env_var_os<K: AsRef<OsStr> + Display>(key: K) -> Option<OsString> {
142-
println!("cargo:rerun-if-env-changed={}", key);
137+
println!("cargo:rerun-if-env-changed={key}");
143138
env::var_os(key)
144139
}
145140

@@ -156,13 +151,12 @@ fn rustc_llvm_build() {
156151
for component in required_components {
157152
assert!(
158153
components.contains(component),
159-
"require llvm component {} but wasn't found",
160-
component
154+
"require llvm component {component} but wasn't found"
161155
);
162156
}
163157

164158
for component in components.iter() {
165-
println!("cargo:rustc-cfg=llvm_component=\"{}\"", component);
159+
println!("cargo:rustc-cfg=llvm_component=\"{component}\"");
166160
}
167161

168162
// Link in our own LLVM shims, compiled with the same flags as LLVM
@@ -255,7 +249,7 @@ fn rustc_llvm_build() {
255249
} else {
256250
"dylib"
257251
};
258-
println!("cargo:rustc-link-lib={}={}", kind, name);
252+
println!("cargo:rustc-link-lib={kind}={name}");
259253
}
260254

261255
// Link in the system libraries that LLVM depends on
@@ -272,11 +266,11 @@ fn rustc_llvm_build() {
272266
cmd.arg(llvm_link_arg).arg("--ldflags");
273267
for lib in output(&mut cmd).split_whitespace() {
274268
if let Some(stripped) = lib.strip_prefix("-LIBPATH:") {
275-
println!("cargo:rustc-link-search=native={}", stripped);
269+
println!("cargo:rustc-link-search=native={stripped}");
276270
} else if let Some(stripped) = lib.strip_prefix("-l") {
277-
println!("cargo:rustc-link-lib={}", stripped);
271+
println!("cargo:rustc-link-lib={stripped}");
278272
} else if let Some(stripped) = lib.strip_prefix("-L") {
279-
println!("cargo:rustc-link-search=native={}", stripped);
273+
println!("cargo:rustc-link-search=native={stripped}");
280274
}
281275
}
282276

@@ -288,9 +282,9 @@ fn rustc_llvm_build() {
288282
if let Some(s) = llvm_linker_flags {
289283
for lib in s.into_string().unwrap().split_whitespace() {
290284
if let Some(stripped) = lib.strip_prefix("-l") {
291-
println!("cargo:rustc-link-lib={}", stripped);
285+
println!("cargo:rustc-link-lib={stripped}");
292286
} else if let Some(stripped) = lib.strip_prefix("-L") {
293-
println!("cargo:rustc-link-search=native={}", stripped);
287+
println!("cargo:rustc-link-search=native={stripped}");
294288
}
295289
}
296290
}
@@ -330,14 +324,14 @@ fn rustc_llvm_build() {
330324
path.parent().unwrap().display()
331325
);
332326
if target.contains("windows") {
333-
println!("cargo:rustc-link-lib=static-nobundle={}", stdcppname);
327+
println!("cargo:rustc-link-lib=static-nobundle={stdcppname}");
334328
} else {
335-
println!("cargo:rustc-link-lib=static={}", stdcppname);
329+
println!("cargo:rustc-link-lib=static={stdcppname}");
336330
}
337331
} else if cxxflags.contains("stdlib=libc++") {
338332
println!("cargo:rustc-link-lib=c++");
339333
} else {
340-
println!("cargo:rustc-link-lib={}", stdcppname);
334+
println!("cargo:rustc-link-lib={stdcppname}");
341335
}
342336
}
343337

@@ -365,6 +359,6 @@ fn link_llvm_system_libs(llvm_config: &Path, components: &[&str]) {
365359
continue;
366360
};
367361

368-
println!("cargo:rustc-link-lib=dylib={}", name);
362+
println!("cargo:rustc-link-lib=dylib={name}");
369363
}
370364
}

crates/rustc_codegen_nvvm/src/abi.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::cmp;
22

33
use libc::c_uint;
44
use rustc_abi::BackendRepr::Scalar;
5+
use rustc_abi::CanonAbi;
56
use rustc_abi::Size;
67
use rustc_abi::{HasDataLayout, Primitive, Reg, RegKind};
78
use rustc_codegen_ssa::mir::operand::OperandRef;
@@ -13,7 +14,7 @@ use rustc_middle::ty::layout::LayoutOf;
1314
pub use rustc_middle::ty::layout::{WIDE_PTR_ADDR, WIDE_PTR_EXTRA};
1415
use rustc_middle::ty::{Ty, TyCtxt, TyKind};
1516
use rustc_target::callconv::{
16-
ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, CastTarget, Conv, FnAbi, PassMode,
17+
ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, CastTarget, FnAbi, PassMode,
1718
};
1819
use tracing::trace;
1920

@@ -28,7 +29,7 @@ pub(crate) fn readjust_fn_abi<'tcx>(
2829
fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
2930
) -> &'tcx FnAbi<'tcx, Ty<'tcx>> {
3031
// dont override anything in the rust abi for now
31-
if fn_abi.conv == Conv::Rust {
32+
if fn_abi.conv == CanonAbi::Rust {
3233
return fn_abi;
3334
}
3435
let readjust_arg_abi = |arg: &ArgAbi<'tcx, Ty<'tcx>>| {
@@ -260,9 +261,6 @@ impl<'ll, 'tcx> ArgAbiBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
260261
) {
261262
arg_abi.store(self, val, dst)
262263
}
263-
fn arg_memory_ty(&self, arg_abi: &ArgAbi<'tcx, Ty<'tcx>>) -> &'ll Type {
264-
arg_abi.memory_ty(self)
265-
}
266264
}
267265

268266
pub(crate) trait FnAbiLlvmExt<'ll, 'tcx> {
@@ -541,7 +539,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
541539
}
542540
}
543541

544-
impl<'tcx> AbiBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
542+
impl<'tcx> AbiBuilderMethods for Builder<'_, '_, 'tcx> {
545543
fn get_param(&mut self, index: usize) -> Self::Value {
546544
let val = llvm::get_param(self.llfn(), index as c_uint);
547545
// trace!("Get param `{:?}`", val);
@@ -551,7 +549,7 @@ impl<'tcx> AbiBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
551549
// destructure so rustc doesnt complain in the call to transmute_llval
552550
let Self { cx, llbuilder } = self;
553551
let map = cx.remapped_integer_args.borrow();
554-
if let Some((_, key)) = map.get(llfnty) {
552+
if let Some((_, key)) = map.get(&llfnty) {
555553
if let Some((_, new_ty)) = key.iter().find(|t| t.0 == index) {
556554
trace!("Casting irregular param {:?} to {:?}", val, new_ty);
557555
return transmute_llval(llbuilder, cx, val, new_ty);

crates/rustc_codegen_nvvm/src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl<'tcx> AsmBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
224224

225225
impl<'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
226226
fn codegen_global_asm(
227-
&self,
227+
&mut self,
228228
template: &[InlineAsmTemplatePiece],
229229
operands: &[GlobalAsmOperandRef],
230230
_options: InlineAsmOptions,

crates/rustc_codegen_nvvm/src/attributes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::llvm::{self, AttributePlace::*, Value};
22
use rustc_ast::{LitKind, MetaItemInner, MetaItemLit};
3-
use rustc_attr_parsing::{InlineAttr, OptimizeAttr};
3+
use rustc_attr_data_structures::{InlineAttr, OptimizeAttr};
44
use rustc_hir::Attribute;
5-
use rustc_middle::{bug, middle::codegen_fn_attrs::CodegenFnAttrFlags, ty};
5+
use rustc_middle::{middle::codegen_fn_attrs::CodegenFnAttrFlags, ty};
66
use rustc_session::{Session, config::OptLevel};
77
use rustc_span::{Symbol, sym};
88

@@ -16,7 +16,7 @@ fn inline(val: &'_ Value, inline: InlineAttr) {
1616
Always => llvm::Attribute::AlwaysInline.apply_llfn(Function, val),
1717
Never => llvm::Attribute::NoInline.apply_llfn(Function, val),
1818
None => {}
19-
Force { .. } => bug!("Force inline should have been inlined away by now"), // TODO: Verify this
19+
Force { .. } => llvm::Attribute::AlwaysInline.apply_llfn(Function, val),
2020
}
2121
}
2222

crates/rustc_codegen_nvvm/src/back.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ pub(crate) unsafe fn codegen(
176176

177177
let llmod = unsafe { module.module_llvm.llmod.as_ref().unwrap() };
178178
let mod_name = module.name.clone();
179-
let module_name = Some(&mod_name[..]);
179+
let module_name = &mod_name[..];
180180

181181
let out = cgcx
182182
.output_filenames
183-
.temp_path(OutputType::Object, module_name);
183+
.temp_path_for_cgu(OutputType::Object, module_name, None);
184184

185185
// nvvm ir *is* llvm ir so emit_ir fits the expectation of llvm ir which is why we
186186
// implement this. this is copy and pasted straight from rustc_codegen_llvm
@@ -189,9 +189,9 @@ pub(crate) unsafe fn codegen(
189189
let _timer = cgcx
190190
.prof
191191
.generic_activity_with_arg("NVVM_module_codegen_emit_ir", &module.name[..]);
192-
let out = cgcx
193-
.output_filenames
194-
.temp_path(OutputType::LlvmAssembly, module_name);
192+
let out =
193+
cgcx.output_filenames
194+
.temp_path_for_cgu(OutputType::LlvmAssembly, module_name, None);
195195
let out = out.to_str().unwrap();
196196

197197
let result = unsafe {
@@ -229,6 +229,7 @@ pub(crate) unsafe fn codegen(
229229
bytecode: None,
230230
assembly: None,
231231
llvm_ir: None,
232+
links_from_incr_cache: vec![],
232233
})
233234
}
234235

@@ -254,7 +255,7 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen
254255
// Instantiate monomorphizations without filling out definitions yet...
255256
let llvm_module = LlvmMod::new(cgu_name.as_str());
256257
{
257-
let cx = CodegenCx::new(tcx, cgu, &llvm_module);
258+
let mut cx = CodegenCx::new(tcx, cgu, &llvm_module);
258259

259260
let mono_items = cx.codegen_unit.items_in_deterministic_order(cx.tcx);
260261

@@ -267,22 +268,27 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen
267268
},
268269
) in &mono_items
269270
{
270-
mono_item.predefine::<Builder<'_, '_, '_>>(&cx, linkage, visibility);
271+
mono_item.predefine::<Builder<'_, '_, '_>>(
272+
&mut cx,
273+
"mono_item",
274+
linkage,
275+
visibility,
276+
);
271277
}
272278

273279
// ... and now that we have everything pre-defined, fill out those definitions.
274-
for &(mono_item, _) in &mono_items {
280+
for &(mono_item, mono_item_data) in &mono_items {
275281
if let MonoItem::Fn(func) = mono_item {
276-
define_or_override_fn(func, &cx);
282+
define_or_override_fn(func, &mut cx);
277283
} else {
278-
mono_item.define::<Builder<'_, '_, '_>>(&cx);
284+
mono_item.define::<Builder<'_, '_, '_>>(&mut cx, "mono_item", mono_item_data);
279285
}
280286
}
281287

282288
// a main function for gpu kernels really makes no sense but
283289
// codegen it anyways.
284290
// sanitize attrs are not allowed in nvvm so do nothing further.
285-
maybe_create_entry_wrapper::<Builder<'_, '_, '_>>(&cx);
291+
maybe_create_entry_wrapper::<Builder<'_, '_, '_>>(&mut cx, cgu);
286292

287293
// Run replace-all-uses-with for statics that need it
288294
for &(old_g, new_g) in cx.statics_to_rauw.borrow().iter() {
@@ -333,13 +339,8 @@ pub(crate) unsafe fn optimize(
333339

334340
let llmod = unsafe { &*module.module_llvm.llmod };
335341

336-
let module_name = module.name.clone();
337-
let module_name = Some(&module_name[..]);
338-
339342
if config.emit_no_opt_bc {
340-
let out = cgcx
341-
.output_filenames
342-
.temp_path_ext("no-opt.bc", module_name);
343+
let out = cgcx.output_filenames.with_extension("no-opt.bc");
343344
let out = path_to_c_string(&out);
344345
unsafe { llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr()) };
345346
}

0 commit comments

Comments
 (0)