From 0415c11726b80534deb06fba1b210c40f1968115 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 24 Aug 2025 10:47:04 +0000 Subject: [PATCH 001/108] Directly raise fatal errors inside the codegen backends As opposed to passing it around through Result. --- src/back/lto.rs | 33 ++++++++++++++++----------------- src/back/write.rs | 7 +++---- src/lib.rs | 12 +++++------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index d558dfbc1c45..fcee6b6df623 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -29,7 +29,7 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput}; use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file}; use rustc_data_structures::memmap::Mmap; -use rustc_errors::{DiagCtxtHandle, FatalError}; +use rustc_errors::DiagCtxtHandle; use rustc_middle::bug; use rustc_middle::dep_graph::WorkProduct; use rustc_session::config::Lto; @@ -51,12 +51,11 @@ fn prepare_lto( cgcx: &CodegenContext, each_linked_rlib_for_lto: &[PathBuf], dcx: DiagCtxtHandle<'_>, -) -> Result { +) -> LtoData { let tmp_path = match tempdir() { Ok(tmp_path) => tmp_path, Err(error) => { - eprintln!("Cannot create temporary directory: {}", error); - return Err(FatalError); + dcx.fatal(format!("Cannot create temporary directory: {}", error)); } }; @@ -91,15 +90,14 @@ fn prepare_lto( upstream_modules.push((module, CString::new(name).unwrap())); } Err(e) => { - dcx.emit_err(e); - return Err(FatalError); + dcx.emit_fatal(e); } } } } } - Ok(LtoData { upstream_modules, tmp_path }) + LtoData { upstream_modules, tmp_path } } fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> { @@ -114,10 +112,10 @@ pub(crate) fn run_fat( cgcx: &CodegenContext, each_linked_rlib_for_lto: &[PathBuf], modules: Vec>, -) -> Result, FatalError> { +) -> ModuleCodegen { let dcx = cgcx.create_dcx(); let dcx = dcx.handle(); - let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx)?; + let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx); /*let symbols_below_threshold = lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::>();*/ fat_lto( @@ -137,7 +135,7 @@ fn fat_lto( mut serialized_modules: Vec<(SerializedModule, CString)>, tmp_path: TempDir, //symbols_below_threshold: &[String], -) -> Result, FatalError> { +) -> ModuleCodegen { let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module"); info!("going for a fat lto"); @@ -261,7 +259,7 @@ fn fat_lto( // of now. module.module_llvm.temp_dir = Some(tmp_path); - Ok(module) + module } pub struct ModuleBuffer(PathBuf); @@ -286,10 +284,10 @@ pub(crate) fn run_thin( each_linked_rlib_for_lto: &[PathBuf], modules: Vec<(String, ThinBuffer)>, cached_modules: Vec<(SerializedModule, WorkProduct)>, -) -> Result<(Vec>, Vec), FatalError> { +) -> (Vec>, Vec) { let dcx = cgcx.create_dcx(); let dcx = dcx.handle(); - let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx)?; + let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx); if cgcx.opts.cg.linker_plugin_lto.enabled() { unreachable!( "We should never reach this case if the LTO step \ @@ -355,7 +353,7 @@ fn thin_lto( tmp_path: TempDir, cached_modules: Vec<(SerializedModule, WorkProduct)>, //_symbols_below_threshold: &[String], -) -> Result<(Vec>, Vec), FatalError> { +) -> (Vec>, Vec) { let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_global_analysis"); info!("going for that thin, thin LTO"); @@ -518,13 +516,13 @@ fn thin_lto( // TODO: save the directory so that it gets deleted later. std::mem::forget(tmp_path); - Ok((opt_jobs, copy_jobs)) + (opt_jobs, copy_jobs) } pub fn optimize_thin_module( thin_module: ThinModule, _cgcx: &CodegenContext, -) -> Result, FatalError> { +) -> ModuleCodegen { //let dcx = cgcx.create_dcx(); //let module_name = &thin_module.shared.module_names[thin_module.idx]; @@ -634,7 +632,8 @@ pub fn optimize_thin_module( save_temp_bitcode(cgcx, &module, "thin-lto-after-pm"); } }*/ - Ok(module) + #[allow(clippy::let_and_return)] + module } pub struct ThinBuffer { diff --git a/src/back/write.rs b/src/back/write.rs index c1231142c658..84bc70162719 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -6,7 +6,6 @@ use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, Mo use rustc_codegen_ssa::{CompiledModule, ModuleCodegen}; use rustc_fs_util::link_or_copy; use rustc_session::config::OutputType; -use rustc_span::fatal_error::FatalError; use rustc_target::spec::SplitDebuginfo; use crate::base::add_pic_option; @@ -17,7 +16,7 @@ pub(crate) fn codegen( cgcx: &CodegenContext, module: ModuleCodegen, config: &ModuleConfig, -) -> Result { +) -> CompiledModule { let dcx = cgcx.create_dcx(); let dcx = dcx.handle(); @@ -246,7 +245,7 @@ pub(crate) fn codegen( } } - Ok(module.into_compiled_module( + module.into_compiled_module( config.emit_obj != EmitObj::None, cgcx.target_can_use_split_dwarf && cgcx.split_debuginfo == SplitDebuginfo::Unpacked, config.emit_bc, @@ -254,7 +253,7 @@ pub(crate) fn codegen( config.emit_ir, &cgcx.output_filenames, cgcx.invocation_temp.as_deref(), - )) + ) } pub(crate) fn save_temp_bitcode( diff --git a/src/lib.rs b/src/lib.rs index 4025aba82da3..2d7df79ba95f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,7 +110,6 @@ use rustc_middle::util::Providers; use rustc_session::Session; use rustc_session::config::{OptLevel, OutputFilenames}; use rustc_span::Symbol; -use rustc_span::fatal_error::FatalError; use rustc_target::spec::RelocModel; use tempfile::TempDir; @@ -362,7 +361,7 @@ impl WriteBackendMethods for GccCodegenBackend { _exported_symbols_for_lto: &[String], each_linked_rlib_for_lto: &[PathBuf], modules: Vec>, - ) -> Result, FatalError> { + ) -> ModuleCodegen { back::lto::run_fat(cgcx, each_linked_rlib_for_lto, modules) } @@ -373,7 +372,7 @@ impl WriteBackendMethods for GccCodegenBackend { each_linked_rlib_for_lto: &[PathBuf], modules: Vec<(String, Self::ThinBuffer)>, cached_modules: Vec<(SerializedModule, WorkProduct)>, - ) -> Result<(Vec>, Vec), FatalError> { + ) -> (Vec>, Vec) { back::lto::run_thin(cgcx, each_linked_rlib_for_lto, modules, cached_modules) } @@ -390,15 +389,14 @@ impl WriteBackendMethods for GccCodegenBackend { _dcx: DiagCtxtHandle<'_>, module: &mut ModuleCodegen, config: &ModuleConfig, - ) -> Result<(), FatalError> { + ) { module.module_llvm.context.set_optimization_level(to_gcc_opt_level(config.opt_level)); - Ok(()) } fn optimize_thin( cgcx: &CodegenContext, thin: ThinModule, - ) -> Result, FatalError> { + ) -> ModuleCodegen { back::lto::optimize_thin_module(thin, cgcx) } @@ -406,7 +404,7 @@ impl WriteBackendMethods for GccCodegenBackend { cgcx: &CodegenContext, module: ModuleCodegen, config: &ModuleConfig, - ) -> Result { + ) -> CompiledModule { back::write::codegen(cgcx, module, config) } From a224101061040360986a1d553039ae0627fb1026 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 26 Aug 2025 17:18:15 +0200 Subject: [PATCH 002/108] Merge commit 'feb42827f11a7ae241ceecc81e9ae556fb6ba214' into subtree-update_cg_gcc_2025-08-26 --- .github/workflows/m68k.yml | 38 ++++++++++++++------------------ Cargo.lock | 8 +++---- Cargo.toml | 2 +- build_system/src/fmt.rs | 30 +++++++++++++++++++++++-- build_system/src/test.rs | 2 +- libgccjit.version | 2 +- rust-toolchain | 2 +- src/intrinsic/simd.rs | 1 - src/lib.rs | 2 +- tests/failing-run-make-tests.txt | 3 --- tests/failing-ui-tests.txt | 4 +++- tests/run/int.rs | 10 ++++----- tests/run/int_overflow.rs | 2 +- tests/run/structs.rs | 8 ++----- tests/run/volatile.rs | 8 ++----- tests/run/volatile2.rs | 12 ++++++++-- 16 files changed, 75 insertions(+), 59 deletions(-) diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 759d0d59e268..e49c62d6c931 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -82,20 +82,16 @@ jobs: - name: Build sample project with target defined as JSON spec run: | ./y.sh prepare --only-libcore --cross - ./y.sh build --sysroot --features compiler-builtins-no-f16-f128 --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json + ./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ./y.sh cargo build --manifest-path=./tests/hello-world/Cargo.toml --target ${{ github.workspace }}/target_specs/m68k-unknown-linux-gnu.json ./y.sh clean all - name: Build run: | ./y.sh prepare --only-libcore --cross - ./y.sh build --sysroot --features compiler-builtins-no-f16-f128 --target-triple m68k-unknown-linux-gnu + ./y.sh build --sysroot --target-triple m68k-unknown-linux-gnu ./y.sh test --mini-tests --target-triple m68k-unknown-linux-gnu - # FIXME: since https://github.com/rust-lang/rust/pull/140809, we cannot run programs for architectures not - # supported by the object crate, since this adds a dependency on symbols.o for the panic runtime. - # And as such, a wrong order of the object files in the linker command now fails with an undefined reference - # to some symbols like __rustc::rust_panic. - #CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests --target-triple m68k-unknown-linux-gnu + CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests --target-triple m68k-unknown-linux-gnu ./y.sh clean all - name: Prepare dependencies @@ -104,23 +100,21 @@ jobs: git config --global user.name "User" ./y.sh prepare --cross - # FIXME: We cannot run programs for architectures not supported by the object crate. See comment above. - #- name: Run tests - #run: | - #./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot --sysroot-features compiler-builtins-no-f16-f128 ${{ matrix.commands }} + - name: Run tests + run: | + ./y.sh test --target-triple m68k-unknown-linux-gnu --release --clean --build-sysroot ${{ matrix.commands }} - # FIXME: We cannot run programs for architectures not supported by the object crate. See comment above. - #- name: Run Hello World! - #run: | - #./y.sh build --target-triple m68k-unknown-linux-gnu + - name: Run Hello World! + run: | + ./y.sh build --target-triple m68k-unknown-linux-gnu - #vm_dir=$(pwd)/vm - #cd tests/hello-world - #CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu - #sudo cp target/m68k-unknown-linux-gnu/debug/hello_world $vm_dir/home/ - #sudo chroot $vm_dir qemu-m68k-static /home/hello_world > hello_world_stdout - #expected_output="40" - #test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1) + vm_dir=$(pwd)/vm + cd tests/hello-world + CG_RUSTFLAGS="-Clinker=m68k-unknown-linux-gnu-gcc" ../../y.sh cargo build --target m68k-unknown-linux-gnu + sudo cp target/m68k-unknown-linux-gnu/debug/hello_world $vm_dir/home/ + sudo chroot $vm_dir qemu-m68k-static /home/hello_world > hello_world_stdout + expected_output="40" + test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1) # Summary job for the merge queue. # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! diff --git a/Cargo.lock b/Cargo.lock index 7f35c1a80bda..a5b972baf98e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,18 +56,18 @@ dependencies = [ [[package]] name = "gccjit" -version = "2.7.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae99a89184220d967dd300139f2d2ae7d52c1a69d632b24aacc57c54625254ce" +checksum = "4a0e310ef75f396cd11b2443b353d55376656ca92c13cba36f92b7aff346ac1a" dependencies = [ "gccjit_sys", ] [[package]] name = "gccjit_sys" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24edb7bfe2b7b27c6d09ed23eebfcab0b359c8fe978433f902943e6f127a0f1b" +checksum = "95ed7572b30cd32430294dde6fb70822d58e67c6846a548647e8739776a0125b" dependencies = [ "libc", ] diff --git a/Cargo.toml b/Cargo.toml index 193348d1ef60..6031933bd2d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ default = ["master"] [dependencies] object = { version = "0.37.0", default-features = false, features = ["std", "read"] } tempfile = "3.20" -gccjit = "2.7" +gccjit = "2.8" #gccjit = { git = "https://github.com/rust-lang/gccjit.rs" } # Local copy. diff --git a/build_system/src/fmt.rs b/build_system/src/fmt.rs index 7e6594f50f93..91535f217e35 100644 --- a/build_system/src/fmt.rs +++ b/build_system/src/fmt.rs @@ -1,7 +1,7 @@ use std::ffi::OsStr; use std::path::Path; -use crate::utils::run_command_with_output; +use crate::utils::{run_command_with_output, walk_dir}; fn show_usage() { println!( @@ -32,5 +32,31 @@ pub fn run() -> Result<(), String> { if check { &[&"cargo", &"fmt", &"--check"] } else { &[&"cargo", &"fmt"] }; run_command_with_output(cmd, Some(Path::new(".")))?; - run_command_with_output(cmd, Some(Path::new("build_system"))) + run_command_with_output(cmd, Some(Path::new("build_system")))?; + + run_rustfmt_recursively("tests/run", check) +} + +fn run_rustfmt_recursively

(dir: P, check: bool) -> Result<(), String> +where + P: AsRef, +{ + walk_dir( + dir, + &mut |dir| run_rustfmt_recursively(dir, check), + &mut |file_path| { + if file_path.extension().filter(|ext| ext == &OsStr::new("rs")).is_some() { + let rustfmt_cmd: &[&dyn AsRef] = if check { + &[&"rustfmt", &"--check", &file_path] + } else { + &[&"rustfmt", &file_path] + }; + + run_command_with_output(rustfmt_cmd, Some(Path::new("."))) + } else { + Ok(()) + } + }, + true, + ) } diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 2c8271c36a94..3dd3fce2eec5 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -531,7 +531,7 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result { r#"change-id = 115898 [rust] -codegen-backends = [] +codegen-backends = ["gcc"] deny-warnings = false verbose-tests = true diff --git a/libgccjit.version b/libgccjit.version index f62154968d3d..dc9a00128646 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -04ce66d8c918de9273bd7101638ad8724edf5e21 +4e995bd73c4490edfe5080ec6014d63aa9abed5f diff --git a/rust-toolchain b/rust-toolchain index 058e734be5cf..04d33dfb116c 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-08-03" +channel = "nightly-2025-08-25" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] diff --git a/src/intrinsic/simd.rs b/src/intrinsic/simd.rs index fdc15d580eff..41363d6313d6 100644 --- a/src/intrinsic/simd.rs +++ b/src/intrinsic/simd.rs @@ -1497,7 +1497,6 @@ fn simd_funnel_shift<'a, 'gcc, 'tcx>( let index = bx.context.new_rvalue_from_int(bx.int_type, i as i32); let a_val = bx.context.new_vector_access(None, a, index).to_rvalue(); let a_val = bx.context.new_bitcast(None, a_val, unsigned_type); - // TODO: we probably need to use gcc_int_cast instead. let a_val = bx.gcc_int_cast(a_val, new_int_type); let b_val = bx.context.new_vector_access(None, b, index).to_rvalue(); let b_val = bx.context.new_bitcast(None, b_val, unsigned_type); diff --git a/src/lib.rs b/src/lib.rs index 2d7df79ba95f..ff1708d6e957 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -361,7 +361,7 @@ impl WriteBackendMethods for GccCodegenBackend { _exported_symbols_for_lto: &[String], each_linked_rlib_for_lto: &[PathBuf], modules: Vec>, - ) -> ModuleCodegen { + ) -> Result, FatalError> { back::lto::run_fat(cgcx, each_linked_rlib_for_lto, modules) } diff --git a/tests/failing-run-make-tests.txt b/tests/failing-run-make-tests.txt index 29032b321fa7..c5e22970c660 100644 --- a/tests/failing-run-make-tests.txt +++ b/tests/failing-run-make-tests.txt @@ -6,7 +6,6 @@ tests/run-make/doctests-keep-binaries/ tests/run-make/doctests-runtool/ tests/run-make/emit-shared-files/ tests/run-make/exit-code/ -tests/run-make/issue-64153/ tests/run-make/llvm-ident/ tests/run-make/native-link-modifier-bundle/ tests/run-make/remap-path-prefix-dwarf/ @@ -34,8 +33,6 @@ tests/run-make/c-link-to-rust-staticlib/ tests/run-make/foreign-double-unwind/ tests/run-make/foreign-exceptions/ tests/run-make/glibc-staticlib-args/ -tests/run-make/issue-36710/ -tests/run-make/issue-68794-textrel-on-minimal-lib/ tests/run-make/lto-smoke-c/ tests/run-make/return-non-c-like-enum/ diff --git a/tests/failing-ui-tests.txt b/tests/failing-ui-tests.txt index 41fb4729c07d..e2615bce190e 100644 --- a/tests/failing-ui-tests.txt +++ b/tests/failing-ui-tests.txt @@ -20,7 +20,7 @@ tests/ui/drop/dynamic-drop.rs tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs tests/ui/simd/issue-17170.rs tests/ui/simd/issue-39720.rs -tests/ui/issues/issue-14875.rs +tests/ui/drop/panic-during-drop-14875.rs tests/ui/issues/issue-29948.rs tests/ui/process/println-with-broken-pipe.rs tests/ui/lto/thin-lto-inlines2.rs @@ -86,3 +86,5 @@ tests/ui/panics/unwind-force-no-unwind-tables.rs tests/ui/attributes/fn-align-dyn.rs tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs tests/ui/explicit-tail-calls/recursion-etc.rs +tests/ui/explicit-tail-calls/indexer.rs +tests/ui/explicit-tail-calls/drop-order.rs diff --git a/tests/run/int.rs b/tests/run/int.rs index e20ecc23679d..78675acb5447 100644 --- a/tests/run/int.rs +++ b/tests/run/int.rs @@ -7,12 +7,10 @@ fn main() { use std::hint::black_box; macro_rules! check { - ($ty:ty, $expr:expr) => { - { - const EXPECTED: $ty = $expr; - assert_eq!($expr, EXPECTED); - } - }; + ($ty:ty, $expr:expr) => {{ + const EXPECTED: $ty = $expr; + assert_eq!($expr, EXPECTED); + }}; } check!(u32, (2220326408_u32 + black_box(1)) >> (32 - 6)); diff --git a/tests/run/int_overflow.rs b/tests/run/int_overflow.rs index 78872159f62d..78e1cac57e03 100644 --- a/tests/run/int_overflow.rs +++ b/tests/run/int_overflow.rs @@ -12,7 +12,7 @@ fn main() { let arg_count = std::env::args().count(); let int = isize::MAX; - let _int = int + arg_count as isize; // overflow + let _int = int + arg_count as isize; // overflow // If overflow checking is disabled, we should reach here. #[cfg(not(debug_assertions))] diff --git a/tests/run/structs.rs b/tests/run/structs.rs index da73cbed9ae9..e08e67837bec 100644 --- a/tests/run/structs.rs +++ b/tests/run/structs.rs @@ -27,12 +27,8 @@ fn one() -> isize { #[no_mangle] extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 { - let test = Test { - field: one(), - }; - let two = Two { - two: 2, - }; + let test = Test { field: one() }; + let two = Two { two: 2 }; unsafe { libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.field); libc::printf(b"%ld\n\0" as *const u8 as *const i8, two.two); diff --git a/tests/run/volatile.rs b/tests/run/volatile.rs index 94a7bdc5c066..dc11fbfa600d 100644 --- a/tests/run/volatile.rs +++ b/tests/run/volatile.rs @@ -12,15 +12,11 @@ struct Struct { func: unsafe fn(*const ()), } -fn func(_ptr: *const ()) { -} +fn func(_ptr: *const ()) {} fn main() { let mut x = MaybeUninit::<&Struct>::uninit(); - x.write(&Struct { - pointer: std::ptr::null(), - func, - }); + x.write(&Struct { pointer: std::ptr::null(), func }); let x = unsafe { x.assume_init() }; let value = unsafe { (x as *const Struct).read_volatile() }; println!("{:?}", value); diff --git a/tests/run/volatile2.rs b/tests/run/volatile2.rs index bdcb82598789..ada112687d3b 100644 --- a/tests/run/volatile2.rs +++ b/tests/run/volatile2.rs @@ -7,7 +7,14 @@ mod libc { #[link(name = "c")] extern "C" { pub fn sigaction(signum: i32, act: *const sigaction, oldact: *mut sigaction) -> i32; - pub fn mmap(addr: *mut (), len: usize, prot: i32, flags: i32, fd: i32, offset: i64) -> *mut (); + pub fn mmap( + addr: *mut (), + len: usize, + prot: i32, + flags: i32, + fd: i32, + offset: i64, + ) -> *mut (); pub fn mprotect(addr: *mut (), len: usize, prot: i32) -> i32; } @@ -54,7 +61,8 @@ fn main() { libc::MAP_PRIVATE | libc::MAP_ANONYMOUS, -1, 0, - ).cast(); + ) + .cast(); if STORAGE == libc::MAP_FAILED { panic!("error: mmap failed"); } From 059f00d46368e12f5c08268d36fce629b44145b7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 26 Aug 2025 17:25:45 +0200 Subject: [PATCH 003/108] Fix sync conflict --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index ff1708d6e957..2d7df79ba95f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -361,7 +361,7 @@ impl WriteBackendMethods for GccCodegenBackend { _exported_symbols_for_lto: &[String], each_linked_rlib_for_lto: &[PathBuf], modules: Vec>, - ) -> Result, FatalError> { + ) -> ModuleCodegen { back::lto::run_fat(cgcx, each_linked_rlib_for_lto, modules) } From 26736f9ad253510299b6a7b4e20799d47f47010c Mon Sep 17 00:00:00 2001 From: Waffle Lapkin Date: Thu, 31 Jul 2025 19:03:22 +0200 Subject: [PATCH 004/108] fix target-pointer-width in tests --- target_specs/m68k-unknown-linux-gnu.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_specs/m68k-unknown-linux-gnu.json b/target_specs/m68k-unknown-linux-gnu.json index 95ea06106fb1..b13b640a7c7e 100644 --- a/target_specs/m68k-unknown-linux-gnu.json +++ b/target_specs/m68k-unknown-linux-gnu.json @@ -22,5 +22,5 @@ "unix" ], "target-mcount": "_mcount", - "target-pointer-width": "32" + "target-pointer-width": 32 } From 01ef5520fb5f827d64ac3df239585530b469cc8c Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 28 Aug 2025 12:31:44 -0400 Subject: [PATCH 005/108] Update GCC version --- libgccjit.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgccjit.version b/libgccjit.version index dc9a00128646..8ed7e0f5fb08 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -4e995bd73c4490edfe5080ec6014d63aa9abed5f +4a8c8ec7c375a2f6bb5ca832efa45375a590bb5d From c1477c33f4b25acaf565d564bbf37fc92749e098 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 28 Aug 2025 10:26:29 +0000 Subject: [PATCH 006/108] Special case allocator module submission to avoid special casing it elsewhere A lot of places had special handling just in case they would get an allocator module even though most of these places could never get one or would have a trivial implementation for the allocator module. Moving all handling of the allocator module to a single place simplifies things a fair bit. --- src/back/lto.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index fcee6b6df623..9d8ce2383f2b 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -204,7 +204,7 @@ fn fat_lto( let path = tmp_path.path().to_path_buf().join(&module.name); let path = path.to_str().expect("path"); let context = &module.module_llvm.context; - let config = cgcx.config(module.kind); + let config = &cgcx.module_config; // NOTE: we need to set the optimization level here in order for LTO to do its job. context.set_optimization_level(to_gcc_opt_level(config.opt_level)); context.add_command_line_option("-flto=auto"); From fada75d9cdada10354725415b509987723521fec Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Fri, 5 Sep 2025 21:39:29 +0800 Subject: [PATCH 007/108] cg_gcc: run `run-make-cargo` tests --- build_system/src/test.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 3dd3fce2eec5..1823aa71f408 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -1083,11 +1083,12 @@ where fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> { test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?; + test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo")?; test_rustc_inner(env, args, |_| Ok(false), false, "ui") } fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { - let result1 = test_rustc_inner( + let run_make_result = test_rustc_inner( env, args, retain_files_callback("tests/failing-run-make-tests.txt", "run-make"), @@ -1095,7 +1096,15 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { "run-make", ); - let result2 = test_rustc_inner( + let run_make_cargo_result = test_rustc_inner( + env, + args, + retain_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"), + false, + "run-make", + ); + + let ui_result = test_rustc_inner( env, args, retain_files_callback("tests/failing-ui-tests.txt", "ui"), @@ -1103,7 +1112,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { "ui", ); - result1.and(result2) + run_make_result.and(run_make_cargo_result).and(ui_result) } fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { @@ -1120,6 +1129,13 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { remove_files_callback("tests/failing-run-make-tests.txt", "run-make"), false, "run-make", + )?; + test_rustc_inner( + env, + args, + remove_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"), + false, + "run-make-cargo", ) } From 03aa02fbc0e86b9184d0023e0f3a749b2ddf8c3f Mon Sep 17 00:00:00 2001 From: dvermd <315743+dvermd@users.noreply.github.com> Date: Fri, 5 Sep 2025 23:56:16 +0200 Subject: [PATCH 008/108] Rework some build_system/utils return value Signed-off-by: dvermd <315743+dvermd@users.noreply.github.com> --- build_system/src/utils.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/build_system/src/utils.rs b/build_system/src/utils.rs index fc948c54b24a..112322f8688c 100644 --- a/build_system/src/utils.rs +++ b/build_system/src/utils.rs @@ -112,8 +112,7 @@ pub fn run_command_with_output( cwd: Option<&Path>, ) -> Result<(), String> { let exit_status = exec_command(input, cwd, None)?; - check_exit_status(input, cwd, exit_status, None, true)?; - Ok(()) + check_exit_status(input, cwd, exit_status, None, true) } pub fn run_command_with_output_and_env( @@ -122,8 +121,7 @@ pub fn run_command_with_output_and_env( env: Option<&HashMap>, ) -> Result<(), String> { let exit_status = exec_command(input, cwd, env)?; - check_exit_status(input, cwd, exit_status, None, true)?; - Ok(()) + check_exit_status(input, cwd, exit_status, None, true) } #[cfg(not(unix))] @@ -133,8 +131,7 @@ pub fn run_command_with_output_and_env_no_err( env: Option<&HashMap>, ) -> Result<(), String> { let exit_status = exec_command(input, cwd, env)?; - check_exit_status(input, cwd, exit_status, None, false)?; - Ok(()) + check_exit_status(input, cwd, exit_status, None, false) } pub fn cargo_install(to_install: &str) -> Result<(), String> { From bd33abfa9080be914463591a8db25ade82342187 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 15 Aug 2025 13:12:19 +0000 Subject: [PATCH 009/108] Remove thin_link_data method from ThinBufferMethods It is only used within cg_llvm. --- src/back/lto.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index 9d8ce2383f2b..d475d2c7da99 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -650,10 +650,6 @@ impl ThinBufferMethods for ThinBuffer { fn data(&self) -> &[u8] { &[] } - - fn thin_link_data(&self) -> &[u8] { - unimplemented!(); - } } pub struct ThinData; //(Arc); From 79955e1cb513285ff174f435445e2c503511150b Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 4 Sep 2025 15:16:55 +0000 Subject: [PATCH 010/108] Remove want_summary argument from prepare_thin It is always false nowadays. ThinLTO summary writing is instead done by llvm_optimize. --- src/back/lto.rs | 7 ++----- src/lib.rs | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index d475d2c7da99..d29bba2570f6 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -305,12 +305,9 @@ pub(crate) fn run_thin( ) } -pub(crate) fn prepare_thin( - module: ModuleCodegen, - _emit_summary: bool, -) -> (String, ThinBuffer) { +pub(crate) fn prepare_thin(module: ModuleCodegen) -> (String, ThinBuffer) { let name = module.name; - //let buffer = ThinBuffer::new(module.module_llvm.context, true, emit_summary); + //let buffer = ThinBuffer::new(module.module_llvm.context, true); let buffer = ThinBuffer::new(&module.module_llvm.context); (name, buffer) } diff --git a/src/lib.rs b/src/lib.rs index 2d7df79ba95f..f76f933cad4a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -408,11 +408,8 @@ impl WriteBackendMethods for GccCodegenBackend { back::write::codegen(cgcx, module, config) } - fn prepare_thin( - module: ModuleCodegen, - emit_summary: bool, - ) -> (String, Self::ThinBuffer) { - back::lto::prepare_thin(module, emit_summary) + fn prepare_thin(module: ModuleCodegen) -> (String, Self::ThinBuffer) { + back::lto::prepare_thin(module) } fn serialize_module(_module: ModuleCodegen) -> (String, Self::ModuleBuffer) { From bd303ca85af8799bf01727b6ea6bf0886d1397ca Mon Sep 17 00:00:00 2001 From: dvermd <315743+dvermd@users.noreply.github.com> Date: Sat, 6 Sep 2025 00:05:09 +0200 Subject: [PATCH 011/108] Always pass git options to run_command Signed-off-by: dvermd <315743+dvermd@users.noreply.github.com> --- build_system/src/prepare.rs | 72 ++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/build_system/src/prepare.rs b/build_system/src/prepare.rs index 35a6e20fb86b..1e97e8d93274 100644 --- a/build_system/src/prepare.rs +++ b/build_system/src/prepare.rs @@ -1,5 +1,7 @@ +use std::ffi::OsStr; use std::fs; use std::path::{Path, PathBuf}; +use std::process::Output; use crate::rustc_info::get_rustc_path; use crate::utils::{ @@ -7,6 +9,41 @@ use crate::utils::{ run_command_with_output, walk_dir, }; +// This is needed on systems where nothing is configured. +// git really needs something here, or it will fail. +// Even using --author is not enough. +const GIT_CMD: [&dyn AsRef; 9] = [ + &"git", + &"-c", + &"user.name=None", + &"-c", + &"user.email=none@example.com", + &"-c", + &"core.autocrlf=false", + &"-c", + &"commit.gpgSign=false", +]; + +fn run_git_command( + command: &dyn AsRef, + input: &[&dyn AsRef], + cwd: Option<&Path>, +) -> Result { + let git_cmd = + &GIT_CMD.into_iter().chain([command]).chain(input.iter().cloned()).collect::>()[..]; + run_command(git_cmd, cwd) +} + +fn run_git_command_with_output( + command: &dyn AsRef, + input: &[&dyn AsRef], + cwd: Option<&Path>, +) -> Result<(), String> { + let git_cmd = + &GIT_CMD.into_iter().chain([command]).chain(input.iter().cloned()).collect::>()[..]; + run_command_with_output(git_cmd, cwd) +} + fn prepare_libcore( sysroot_path: &Path, libgccjit12_patches: bool, @@ -55,19 +92,12 @@ fn prepare_libcore( run_command(&[&"cp", &"-r", &rustlib_dir.join("library"), &sysroot_dir], None)?; println!("[GIT] init (cwd): `{}`", sysroot_dir.display()); - run_command(&[&"git", &"init"], Some(&sysroot_dir))?; + run_git_command(&"init", &[], Some(&sysroot_dir))?; println!("[GIT] add (cwd): `{}`", sysroot_dir.display()); - run_command(&[&"git", &"add", &"."], Some(&sysroot_dir))?; + run_git_command(&"add", &[&"."], Some(&sysroot_dir))?; println!("[GIT] commit (cwd): `{}`", sysroot_dir.display()); - // This is needed on systems where nothing is configured. - // git really needs something here, or it will fail. - // Even using --author is not enough. - run_command(&[&"git", &"config", &"user.email", &"none@example.com"], Some(&sysroot_dir))?; - run_command(&[&"git", &"config", &"user.name", &"None"], Some(&sysroot_dir))?; - run_command(&[&"git", &"config", &"core.autocrlf", &"false"], Some(&sysroot_dir))?; - run_command(&[&"git", &"config", &"commit.gpgSign", &"false"], Some(&sysroot_dir))?; - run_command(&[&"git", &"commit", &"-m", &"Initial commit", &"-q"], Some(&sysroot_dir))?; + run_git_command(&"commit", &[&"-m", &"Initial commit", &"-q"], Some(&sysroot_dir))?; let mut patches = Vec::new(); walk_dir( @@ -105,10 +135,11 @@ fn prepare_libcore( for file_path in patches { println!("[GIT] apply `{}`", file_path.display()); let path = Path::new("../../..").join(file_path); - run_command_with_output(&[&"git", &"apply", &path], Some(&sysroot_dir))?; - run_command_with_output(&[&"git", &"add", &"-A"], Some(&sysroot_dir))?; - run_command_with_output( - &[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())], + run_git_command_with_output(&"apply", &[&path], Some(&sysroot_dir))?; + run_git_command_with_output(&"add", &[&"-A"], Some(&sysroot_dir))?; + run_git_command_with_output( + &"commit", + &[&"-m", &format!("Patch {}", path.display())], Some(&sysroot_dir), )?; } @@ -124,10 +155,11 @@ fn prepare_rand() -> Result<(), String> { let rand_dir = Path::new("build/rand"); println!("[GIT] apply `{file_path}`"); let path = Path::new("../..").join(file_path); - run_command_with_output(&[&"git", &"apply", &path], Some(rand_dir))?; - run_command_with_output(&[&"git", &"add", &"-A"], Some(rand_dir))?; - run_command_with_output( - &[&"git", &"commit", &"--no-gpg-sign", &"-m", &format!("Patch {}", path.display())], + run_git_command_with_output(&"apply", &[&path], Some(rand_dir))?; + run_git_command_with_output(&"add", &[&"-A"], Some(rand_dir))?; + run_git_command_with_output( + &"commit", + &[&"-m", &format!("Patch {}", path.display())], Some(rand_dir), )?; @@ -154,8 +186,8 @@ where println!("`{}` has already been cloned", clone_result.repo_name); } let repo_path = Path::new(crate::BUILD_DIR).join(&clone_result.repo_name); - run_command(&[&"git", &"checkout", &"--", &"."], Some(&repo_path))?; - run_command(&[&"git", &"checkout", &checkout_commit], Some(&repo_path))?; + run_git_command(&"checkout", &[&"--", &"."], Some(&repo_path))?; + run_git_command(&"checkout", &[&checkout_commit], Some(&repo_path))?; if let Some(extra) = extra { extra(&repo_path)?; } From a211d63b8381638ee2ac00834103168c184192c6 Mon Sep 17 00:00:00 2001 From: Boxy Date: Thu, 21 Aug 2025 16:50:54 +0100 Subject: [PATCH 012/108] erase_regions to erase_and_anonymize_regions --- src/type_of.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/type_of.rs b/src/type_of.rs index 093f902bc3d8..93202483eed8 100644 --- a/src/type_of.rs +++ b/src/type_of.rs @@ -240,7 +240,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { // Make sure lifetimes are erased, to avoid generating distinct LLVM // types for Rust types that only differ in the choice of lifetimes. - let normal_ty = cx.tcx.erase_regions(self.ty); + let normal_ty = cx.tcx.erase_and_anonymize_regions(self.ty); let mut defer = None; let ty = if self.ty != normal_ty { From 2d2aad3ce623c5047b4263621b4738deab168a54 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sat, 7 Jun 2025 22:56:22 +0200 Subject: [PATCH 013/108] allow `#[rustc_align_static(N)]` on `static`s We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`. --- src/consts.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/consts.rs b/src/consts.rs index 619277eba8b8..7fe8fc122b3c 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -81,6 +81,8 @@ impl<'gcc, 'tcx> StaticCodegenMethods for CodegenCx<'gcc, 'tcx> { if global.to_rvalue().get_type() != val_llty { global.to_rvalue().set_type(val_llty); } + + // NOTE: Alignment from attributes has already been applied to the allocation. set_global_alignment(self, global, alloc.align); global.global_set_initializer_rvalue(value); From b5b58d1e343c33f36bfa4dd10b69db4e2dc111ac Mon Sep 17 00:00:00 2001 From: Zachary S Date: Fri, 12 Sep 2025 09:49:41 -0500 Subject: [PATCH 014/108] Remove unreachable unsized arg handling in `store_fn_arg/store_arg` in codegen --- src/intrinsic/mod.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index eb0a5336a1f1..84fa56cf9030 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -730,7 +730,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { if self.is_sized_indirect() { OperandValue::Ref(PlaceValue::new_sized(val, self.layout.align.abi)).store(bx, dst) } else if self.is_unsized_indirect() { - bug!("unsized `ArgAbi` must be handled through `store_fn_arg`"); + bug!("unsized `ArgAbi` cannot be stored"); } else if let PassMode::Cast { ref cast, .. } = self.mode { // FIXME(eddyb): Figure out when the simpler Store is safe, clang // uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}. @@ -797,12 +797,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { OperandValue::Pair(next(), next()).store(bx, dst); } PassMode::Indirect { meta_attrs: Some(_), .. } => { - let place_val = PlaceValue { - llval: next(), - llextra: Some(next()), - align: self.layout.align.abi, - }; - OperandValue::Ref(place_val).store(bx, dst); + bug!("unsized `ArgAbi` cannot be stored"); } PassMode::Direct(_) | PassMode::Indirect { meta_attrs: None, .. } From dbc3ace11c9fd2fe8d22e9d1042cc0ffcd86bf05 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 16 Sep 2025 08:51:29 -0400 Subject: [PATCH 015/108] Update to nightly-2025-09-16 --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 04d33dfb116c..f6c840429607 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-08-25" +channel = "nightly-2025-09-16" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] From b072f38bea38a4fded7c2aa6bec9ea8583fea8c8 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 16 Sep 2025 09:49:55 -0400 Subject: [PATCH 016/108] Ignore failing test --- tests/failing-ui-tests.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/failing-ui-tests.txt b/tests/failing-ui-tests.txt index e2615bce190e..9a44034c127c 100644 --- a/tests/failing-ui-tests.txt +++ b/tests/failing-ui-tests.txt @@ -88,3 +88,4 @@ tests/ui/linkage-attr/raw-dylib/elf/glibc-x86_64.rs tests/ui/explicit-tail-calls/recursion-etc.rs tests/ui/explicit-tail-calls/indexer.rs tests/ui/explicit-tail-calls/drop-order.rs +tests/ui/c-variadic/valid.rs From 8ecf880743ac8ef8fdcb044c6b30c7dd778befe2 Mon Sep 17 00:00:00 2001 From: Karan Janthe Date: Sat, 23 Aug 2025 23:10:48 +0000 Subject: [PATCH 017/108] added typetree support for memcpy --- src/builder.rs | 1 + src/intrinsic/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/builder.rs b/src/builder.rs index f7a7a3f8c7e3..5657620879ca 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1383,6 +1383,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { _src_align: Align, size: RValue<'gcc>, flags: MemFlags, + _tt: Option, // Autodiff TypeTrees are LLVM-only, ignored in GCC backend ) { assert!(!flags.contains(MemFlags::NONTEMPORAL), "non-temporal memcpy not supported"); let size = self.intcast(size, self.type_size_t(), false); diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index 84fa56cf9030..3b897a198350 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -771,6 +771,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> { scratch_align, bx.const_usize(self.layout.size.bytes()), MemFlags::empty(), + None, ); bx.lifetime_end(scratch, scratch_size); From ee849b0db25b33b95971eb8a3bc78f1f78cfb6c3 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 20 Sep 2025 17:57:17 -0400 Subject: [PATCH 018/108] Switch to Ubuntu Plucky repository because Oracular is not supported anymore --- .github/workflows/stdarch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stdarch.yml b/.github/workflows/stdarch.yml index 20d009f08a79..184f122cc1c1 100644 --- a/.github/workflows/stdarch.yml +++ b/.github/workflows/stdarch.yml @@ -41,7 +41,7 @@ jobs: # TODO: remove when we have binutils version 2.43 in the repo. - name: Install more recent binutils run: | - echo "deb http://archive.ubuntu.com/ubuntu oracular main universe" | sudo tee /etc/apt/sources.list.d/oracular-copies.list + echo "deb http://archive.ubuntu.com/ubuntu plucky main universe" | sudo tee /etc/apt/sources.list.d/plucky-copies.list sudo apt-get update sudo apt-get install binutils From 7c12d9d4f1fdc4eafea1d42f33b463817d714029 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 20 Sep 2025 19:35:26 -0400 Subject: [PATCH 019/108] Disable funnel shift tests since they fail --- build_system/src/test.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 1823aa71f408..a892d97356ca 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -714,7 +714,8 @@ fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> { let path = get_sysroot_dir().join("sysroot_src/library/coretests"); let _ = remove_dir_all(path.join("target")); // TODO(antoyo): run in release mode when we fix the failures. - run_cargo_command(&[&"test"], Some(&path), env, args)?; + // TODO(antoyo): Stop skipping funnel shift tests when those operations are fixed. + run_cargo_command(&[&"test", &"--", &"--skip", &"test_funnel_shift"], Some(&path), env, args)?; Ok(()) } From b9a2e046f0d936051802039855085514e4ec77ca Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 21 Sep 2025 13:48:22 +0900 Subject: [PATCH 020/108] Support ctr and lr as clobber-only registers in PowerPC inline assembly --- src/asm.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/asm.rs b/src/asm.rs index 17e2e028b16f..a14881c502cf 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -698,8 +698,12 @@ fn reg_class_to_gcc(reg_class: InlineAsmRegClass) -> &'static str { InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => "b", InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => "f", InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => "v", - InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::cr) - | InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer) => { + InlineAsmRegClass::PowerPC( + PowerPCInlineAsmRegClass::cr + | PowerPCInlineAsmRegClass::ctr + | PowerPCInlineAsmRegClass::lr + | PowerPCInlineAsmRegClass::xer, + ) => { unreachable!("clobber-only") } InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => "r", @@ -777,8 +781,12 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => { cx.type_vector(cx.type_i32(), 4) } - InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::cr) - | InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer) => { + InlineAsmRegClass::PowerPC( + PowerPCInlineAsmRegClass::cr + | PowerPCInlineAsmRegClass::ctr + | PowerPCInlineAsmRegClass::lr + | PowerPCInlineAsmRegClass::xer, + ) => { unreachable!("clobber-only") } InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => cx.type_i32(), From 8f244364983a740eca94e5b4cc28a14070c3b3e4 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 7 Sep 2025 12:31:35 -0400 Subject: [PATCH 021/108] Add panic=immediate-abort --- src/base.rs | 4 ++-- src/intrinsic/mod.rs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/base.rs b/src/base.rs index e9d72e457a08..e8672f49580b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -15,9 +15,9 @@ use rustc_middle::mir::mono::Visibility; use rustc_middle::ty::TyCtxt; use rustc_session::config::DebugInfo; use rustc_span::Symbol; +use rustc_target::spec::RelocModel; #[cfg(feature = "master")] use rustc_target::spec::SymbolVisibility; -use rustc_target::spec::{PanicStrategy, RelocModel}; use crate::builder::Builder; use crate::context::CodegenCx; @@ -101,7 +101,7 @@ pub fn compile_codegen_unit( // Instantiate monomorphizations without filling out definitions yet... let context = new_context(tcx); - if tcx.sess.panic_strategy() == PanicStrategy::Unwind { + if tcx.sess.panic_strategy().unwinds() { context.add_command_line_option("-fexceptions"); context.add_driver_option("-fexceptions"); } diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index 84fa56cf9030..a915f5d64188 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -29,7 +29,6 @@ use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{self, Instance, Ty}; use rustc_span::{Span, Symbol, sym}; use rustc_target::callconv::{ArgAbi, PassMode}; -use rustc_target::spec::PanicStrategy; #[cfg(feature = "master")] use crate::abi::FnAbiGccExt; @@ -1334,7 +1333,7 @@ fn try_intrinsic<'a, 'b, 'gcc, 'tcx>( _catch_func: RValue<'gcc>, dest: PlaceRef<'tcx, RValue<'gcc>>, ) { - if bx.sess().panic_strategy() == PanicStrategy::Abort { + if !bx.sess().panic_strategy().unwinds() { bx.call(bx.type_void(), None, None, try_func, &[data], None, None); // Return 0 unconditionally from the intrinsic call; // we can never unwind. From 994d3e1fd9c795f24e7546c5e375884d5cebb36e Mon Sep 17 00:00:00 2001 From: Caleb Zulawski Date: Tue, 16 Sep 2025 02:23:24 -0400 Subject: [PATCH 022/108] Add an attribute to check the number of lanes in a SIMD vector after monomorphization Unify zero-length and oversized SIMD errors --- src/context.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/context.rs b/src/context.rs index 665cf22ddbae..9815fb07eaae 100644 --- a/src/context.rs +++ b/src/context.rs @@ -529,7 +529,10 @@ impl<'gcc, 'tcx> HasX86AbiOpt for CodegenCx<'gcc, 'tcx> { impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> { #[inline] fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { - if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err { + if let LayoutError::SizeOverflow(_) + | LayoutError::InvalidSimd { .. } + | LayoutError::ReferencesError(_) = err + { self.tcx.dcx().emit_fatal(respan(span, err.into_diagnostic())) } else { self.tcx.dcx().emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err }) @@ -545,7 +548,9 @@ impl<'gcc, 'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> { span: Span, fn_abi_request: FnAbiRequest<'tcx>, ) -> ! { - if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err { + if let FnAbiError::Layout(LayoutError::SizeOverflow(_) | LayoutError::InvalidSimd { .. }) = + err + { self.tcx.dcx().emit_fatal(respan(span, err)) } else { match fn_abi_request { From 7587323505cba4a5c39599f69921d0bec65c1dce Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 28 Sep 2025 12:08:44 -0400 Subject: [PATCH 023/108] Add a leading dash to linker plugin arguments in the gcc codegen --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index f76f933cad4a..ec7eab8489ab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,6 +184,10 @@ impl CodegenBackend for GccCodegenBackend { crate::DEFAULT_LOCALE_RESOURCE } + fn name(&self) -> &'static str { + "gcc" + } + fn init(&self, _sess: &Session) { #[cfg(feature = "master")] { From 9159b616298016af15361ba91aedd8fd343e6d0e Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sun, 28 Sep 2025 14:40:39 -0700 Subject: [PATCH 024/108] remove explicit deref of AbiAlign for most methods Much of the compiler calls functions on Align projected from AbiAlign. AbiAlign impls Deref to its inner Align, so we can simplify these away. Also, it will minimize disruption when AbiAlign is removed. For now, preserve usages that might resolve to PartialOrd or PartialEq, as those have odd inference. --- src/context.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/context.rs b/src/context.rs index 9815fb07eaae..c9ae96777de4 100644 --- a/src/context.rs +++ b/src/context.rs @@ -147,7 +147,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { let layout = tcx .layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(rust_type)) .unwrap(); - let align = layout.align.abi.bytes(); + let align = layout.align.bytes(); // For types with size 1, the alignment can be 1 and only 1 // So, we can skip the call to ``get_aligned`. // In the future, we can add a GCC API to query the type align, @@ -186,9 +186,9 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { (i128_type, u128_type) } else { /*let layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.types.i128)).unwrap(); - let i128_align = layout.align.abi.bytes(); + let i128_align = layout.align.bytes(); let layout = tcx.layout_of(ParamEnv::reveal_all().and(tcx.types.u128)).unwrap(); - let u128_align = layout.align.abi.bytes();*/ + let u128_align = layout.align.bytes();*/ // TODO(antoyo): re-enable the alignment when libgccjit fixed the issue in // gcc_jit_context_new_array_constructor (it should not use reinterpret_cast). From a2b536a2b4cf362392d892fc53a8ca131add3319 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 29 Sep 2025 09:31:00 -0400 Subject: [PATCH 025/108] Update to nightly-2025-09-30 --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index f6c840429607..ec625481add1 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-09-16" +channel = "nightly-2025-09-30" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] From 0127601faae6b2ff9c43f5c2ba694b47fff52413 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 22 Sep 2025 14:44:40 -0400 Subject: [PATCH 026/108] Stop ignoring the clippy lint suspicious_else_formatting --- src/intrinsic/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index eb0bd9cf71f4..db9f32bad5a7 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -272,10 +272,6 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc .or_else(|| get_simple_function_f128(self, name)) .or_else(|| get_simple_function_f128_2args(self, name)); - // FIXME(tempdragon): Re-enable `clippy::suspicious_else_formatting` if the following issue is solved: - // https://github.com/rust-lang/rust-clippy/issues/12497 - // and leave `else if use_integer_compare` to be placed "as is". - #[allow(clippy::suspicious_else_formatting)] let value = match name { _ if simple.is_some() => { let func = simple.expect("simple intrinsic function"); From 3fdf349ba18b56addcb059bdd146ab07455e3264 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 22 Sep 2025 17:29:43 -0400 Subject: [PATCH 027/108] Fix and re-enable mini-core test --- example/mini_core.rs | 2 +- example/mini_core_hello_world.rs | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 9dfb12be2436..5afedf9d4017 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -671,7 +671,7 @@ pub mod intrinsics { #[rustc_intrinsic] pub unsafe fn ctlz_nonzero(x: T) -> u32; #[rustc_intrinsic] - pub fn needs_drop() -> bool; + pub const fn needs_drop() -> bool; #[rustc_intrinsic] pub fn bitreverse(x: T) -> T; #[rustc_intrinsic] diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 092fd6a76409..1e601d42413c 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -198,8 +198,6 @@ fn main() { assert_eq!(intrinsics::align_of::() as u8, 2); assert_eq!(intrinsics::align_of_val(&a) as u8, intrinsics::align_of::<&str>() as u8); - /* - * TODO: re-enable in the next sync. let u8_needs_drop = const { intrinsics::needs_drop::() }; assert!(!u8_needs_drop); let slice_needs_drop = const { intrinsics::needs_drop::<[u8]>() }; @@ -208,7 +206,6 @@ fn main() { assert!(noisy_drop); let noisy_unsized_drop = const { intrinsics::needs_drop::() }; assert!(noisy_unsized_drop); - */ Unique { pointer: 0 as *const &str, From 5e6e797e79d411e0bc787689896947fb2b139ef7 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Wed, 24 Sep 2025 13:06:00 -0400 Subject: [PATCH 028/108] Remove passing run-make tests --- tests/failing-run-make-tests.txt | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/tests/failing-run-make-tests.txt b/tests/failing-run-make-tests.txt index c5e22970c660..822aaec0edeb 100644 --- a/tests/failing-run-make-tests.txt +++ b/tests/failing-run-make-tests.txt @@ -1,35 +1,11 @@ -tests/run-make/a-b-a-linker-guard/ -tests/run-make/CURRENT_RUSTC_VERSION/ tests/run-make/cross-lang-lto/ tests/run-make/cross-lang-lto-upstream-rlibs/ -tests/run-make/doctests-keep-binaries/ -tests/run-make/doctests-runtool/ -tests/run-make/emit-shared-files/ -tests/run-make/exit-code/ tests/run-make/llvm-ident/ tests/run-make/native-link-modifier-bundle/ tests/run-make/remap-path-prefix-dwarf/ -tests/run-make/repr128-dwarf/ tests/run-make/rlib-format-packed-bundled-libs/ tests/run-make/rlib-format-packed-bundled-libs-2/ -tests/run-make/rustdoc-determinism/ -tests/run-make/rustdoc-error-lines/ -tests/run-make/rustdoc-map-file/ -tests/run-make/rustdoc-output-path/ -tests/run-make/rustdoc-scrape-examples-invalid-expr/ -tests/run-make/rustdoc-scrape-examples-multiple/ -tests/run-make/rustdoc-scrape-examples-ordering/ -tests/run-make/rustdoc-scrape-examples-remap/ -tests/run-make/rustdoc-scrape-examples-test/ -tests/run-make/rustdoc-scrape-examples-whitespace/ -tests/run-make/rustdoc-scrape-examples-macros/ -tests/run-make/rustdoc-with-out-dir-option/ -tests/run-make/rustdoc-verify-output-files/ -tests/run-make/rustdoc-themes/ -tests/run-make/rustdoc-with-short-out-dir-option/ -tests/run-make/rustdoc-with-output-option/ tests/run-make/arguments-non-c-like-enum/ -tests/run-make/c-link-to-rust-staticlib/ tests/run-make/foreign-double-unwind/ tests/run-make/foreign-exceptions/ tests/run-make/glibc-staticlib-args/ From f951feee5476aaf0eab7f3c7c15b0a7dad0ced36 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Wed, 24 Sep 2025 13:05:36 -0400 Subject: [PATCH 029/108] Clean all test directories --- build_system/src/clean.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build_system/src/clean.rs b/build_system/src/clean.rs index a441ed613f94..43f01fdf35ec 100644 --- a/build_system/src/clean.rs +++ b/build_system/src/clean.rs @@ -69,8 +69,13 @@ fn clean_all() -> Result<(), String> { } fn clean_ui_tests() -> Result<(), String> { - let path = Path::new(crate::BUILD_DIR).join("rust/build/x86_64-unknown-linux-gnu/test/ui/"); - run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None)?; + let directories = ["run-make", "run-make-cargo", "ui"]; + for directory in directories { + let path = Path::new(crate::BUILD_DIR) + .join("rust/build/x86_64-unknown-linux-gnu/test/") + .join(directory); + run_command(&[&"find", &path, &"-name", &"stamp", &"-delete"], None)?; + } Ok(()) } From 8deca81cf289efdb1a10cec19d46633b5ab5a46f Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 22 Sep 2025 15:52:03 -0400 Subject: [PATCH 030/108] Fix shifting a value of a smaller type to a bigger type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: FranΓ§ois Bernier --- build_system/src/test.rs | 3 +-- src/int.rs | 17 +++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index a892d97356ca..1823aa71f408 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -714,8 +714,7 @@ fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> { let path = get_sysroot_dir().join("sysroot_src/library/coretests"); let _ = remove_dir_all(path.join("target")); // TODO(antoyo): run in release mode when we fix the failures. - // TODO(antoyo): Stop skipping funnel shift tests when those operations are fixed. - run_cargo_command(&[&"test", &"--", &"--skip", &"test_funnel_shift"], Some(&path), env, args)?; + run_cargo_command(&[&"test"], Some(&path), env, args)?; Ok(()) } diff --git a/src/int.rs b/src/int.rs index 9fb7f6bad684..aa1d3b6b091c 100644 --- a/src/int.rs +++ b/src/int.rs @@ -83,12 +83,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { let a_size = a_type.get_size(); let b_size = b_type.get_size(); match a_size.cmp(&b_size) { - std::cmp::Ordering::Less => { - let a = self.context.new_cast(self.location, a, b_type); - a >> b - } std::cmp::Ordering::Equal => a >> b, - std::cmp::Ordering::Greater => { + _ => { + // NOTE: it is OK to cast even if b has a type bigger than a because b has + // been masked by codegen_ssa before calling Builder::lshr or + // Builder::ashr. let b = self.context.new_cast(self.location, b, a_type); a >> b } @@ -692,12 +691,10 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { let a_size = a_type.get_size(); let b_size = b_type.get_size(); match a_size.cmp(&b_size) { - std::cmp::Ordering::Less => { - let a = self.context.new_cast(self.location, a, b_type); - a << b - } std::cmp::Ordering::Equal => a << b, - std::cmp::Ordering::Greater => { + _ => { + // NOTE: it is OK to cast even if b has a type bigger than a because b has + // been masked by codegen_ssa before calling Builder::shl. let b = self.context.new_cast(self.location, b, a_type); a << b } From 243ef31f1e5684a7ce3f2617beb7267faddf90c1 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Mon, 22 Sep 2025 17:26:12 -0400 Subject: [PATCH 031/108] Add test for cross-language LTO --- .github/workflows/release.yml | 17 ++++++++++++++++- tests/cross_lang_lto/Cargo.lock | 7 +++++++ tests/cross_lang_lto/Cargo.toml | 6 ++++++ tests/cross_lang_lto/add.c | 5 +++++ tests/cross_lang_lto/src/main.rs | 18 ++++++++++++++++++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/cross_lang_lto/Cargo.lock create mode 100644 tests/cross_lang_lto/Cargo.toml create mode 100644 tests/cross_lang_lto/add.c create mode 100644 tests/cross_lang_lto/src/main.rs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7e2583aad39..65ceb6919066 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,7 +82,7 @@ jobs: printf '[profile.release]\nlto = "fat"\n' >> build/build_sysroot/sysroot_src/library/Cargo.toml EMBED_LTO_BITCODE=1 ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} - - name: Run y.sh cargo build + - name: LTO test run: | EMBED_LTO_BITCODE=1 CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml call_found=$(objdump -dj .text tests/hello-world/target/release/hello_world | grep -c "call .*mylib.*my_func" ) ||: @@ -92,6 +92,21 @@ jobs: exit 1 fi + - name: Cross-language LTO test + run: | + pushd tests/cross_lang_lto + gcc -c -flto add.c -masm=intel -fPIC -O3 + ar rcs libadd.a add.o + popd + + EMBED_LTO_BITCODE=1 CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml + call_found=$(objdump -dj .text tests/cross_lang_lto/target/release/cross_lang_lto | grep -c "call .*my_add" ) ||: + if [ $call_found -gt 0 ]; then + echo "ERROR: call my_add found in asm" + echo "Test is done with cross-language LTO enabled, hence inlining should occur across object files" + exit 1 + fi + # Summary job for the merge queue. # ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB! success_release: diff --git a/tests/cross_lang_lto/Cargo.lock b/tests/cross_lang_lto/Cargo.lock new file mode 100644 index 000000000000..a0c9d2df383d --- /dev/null +++ b/tests/cross_lang_lto/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "cross_lang_lto" +version = "0.1.0" diff --git a/tests/cross_lang_lto/Cargo.toml b/tests/cross_lang_lto/Cargo.toml new file mode 100644 index 000000000000..777e6548df2b --- /dev/null +++ b/tests/cross_lang_lto/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "cross_lang_lto" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/tests/cross_lang_lto/add.c b/tests/cross_lang_lto/add.c new file mode 100644 index 000000000000..cc59f113bc19 --- /dev/null +++ b/tests/cross_lang_lto/add.c @@ -0,0 +1,5 @@ +#include + +uint32_t my_add(uint32_t a, uint32_t b) { + return a + b; +} diff --git a/tests/cross_lang_lto/src/main.rs b/tests/cross_lang_lto/src/main.rs new file mode 100644 index 000000000000..a7180b333963 --- /dev/null +++ b/tests/cross_lang_lto/src/main.rs @@ -0,0 +1,18 @@ +/* + * Compile the C code with: + * gcc -c -flto add.c -ffat-lto-objects + * ar rcs libadd.a add.o + * + * Compile the Rust code with: + * EMBED_LTO_BITCODE=1 CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" y cargo run --release + */ + +#[link(name="add")] +unsafe extern "C" { + fn my_add(a: u32, b: u32) -> u32; +} + +fn main() { + let res = unsafe { my_add(30, 12) }; + println!("{}", res); +} From c9145e1e58f9fddb8be884978f33d8859c3c5604 Mon Sep 17 00:00:00 2001 From: dianqk Date: Wed, 18 Jun 2025 22:04:48 +0800 Subject: [PATCH 032/108] codegen: Generate `dbg_value` for the ref statement --- src/debuginfo.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 4c8585192a1b..0f015cc23f52 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -29,13 +29,24 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> { _variable_alloca: Self::Value, _direct_offset: Size, _indirect_offsets: &[Size], - _fragment: Option>, + _fragment: &Option>, ) { // FIXME(tempdragon): Not sure if this is correct, probably wrong but still keep it here. #[cfg(feature = "master")] _variable_alloca.set_location(_dbg_loc); } + fn dbg_var_value( + &mut self, + _dbg_var: Self::DIVariable, + _dbg_loc: Self::DILocation, + _value: Self::Value, + _direct_offset: Size, + _indirect_offsets: &[Size], + _fragment: &Option>, + ) { + } + fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) { // TODO(antoyo): insert reference to gdb debug scripts section global. } From 130a8e9ccf51a55f1cd84cd9750850800f0a8821 Mon Sep 17 00:00:00 2001 From: Arthur Bied-Charreton <136271426+winstonallo@users.noreply.github.com> Date: Wed, 8 Oct 2025 10:49:01 +0200 Subject: [PATCH 033/108] Add `dejagnu` to the quickstart installation command line --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 859bb1568f4e..3c6e595d2123 100644 --- a/Readme.md +++ b/Readme.md @@ -57,7 +57,7 @@ To build it (most of these instructions come from [here](https://gcc.gnu.org/onl ```bash $ git clone https://github.com/rust-lang/gcc -$ sudo apt install flex libmpfr-dev libgmp-dev libmpc3 libmpc-dev +$ sudo apt install flex libmpfr-dev libgmp-dev libmpc3 libmpc-dev dejagnu $ mkdir gcc-build gcc-install $ cd gcc-build $ ../gcc/configure \ From a90977912c9881b571e08e24914a1dbb560abbf7 Mon Sep 17 00:00:00 2001 From: Arthur Bied-Charreton <136271426+winstonallo@users.noreply.github.com> Date: Wed, 8 Oct 2025 14:39:01 +0200 Subject: [PATCH 034/108] Move dejagnu install step to libgccjit tests documentation --- Readme.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 3c6e595d2123..32aa2935aaa0 100644 --- a/Readme.md +++ b/Readme.md @@ -57,7 +57,7 @@ To build it (most of these instructions come from [here](https://gcc.gnu.org/onl ```bash $ git clone https://github.com/rust-lang/gcc -$ sudo apt install flex libmpfr-dev libgmp-dev libmpc3 libmpc-dev dejagnu +$ sudo apt install flex libmpfr-dev libgmp-dev libmpc3 libmpc-dev $ mkdir gcc-build gcc-install $ cd gcc-build $ ../gcc/configure \ @@ -70,15 +70,22 @@ $ ../gcc/configure \ $ make -j4 # You can replace `4` with another number depending on how many cores you have. ``` -If you want to run libgccjit tests, you will need to also enable the C++ language in the `configure`: +If you want to run libgccjit tests, you will need to +* Enable the C++ language in the `configure` step: ```bash --enable-languages=jit,c++ ``` +* Install [dejagnu](https://www.gnu.org/software/dejagnu/#downloading) to run the tests + +```bash +$ sudo apt install dejagnu +``` Then to run libgccjit tests: ```bash +$ sudo apt install dejagnu $ cd gcc # from the `gcc-build` folder $ make check-jit # To run one specific test: From 87c59b812194140dfc16c554c6805c3a280038d5 Mon Sep 17 00:00:00 2001 From: Arthur Bied-Charreton <136271426+winstonallo@users.noreply.github.com> Date: Wed, 8 Oct 2025 14:39:52 +0200 Subject: [PATCH 035/108] Remove dejagnu install from libgccjit tests run instructions --- Readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/Readme.md b/Readme.md index 32aa2935aaa0..5ebdef15a5ce 100644 --- a/Readme.md +++ b/Readme.md @@ -85,7 +85,6 @@ $ sudo apt install dejagnu Then to run libgccjit tests: ```bash -$ sudo apt install dejagnu $ cd gcc # from the `gcc-build` folder $ make check-jit # To run one specific test: From d7e37d98cc595fcddea93194332de512967d000c Mon Sep 17 00:00:00 2001 From: Arthur Bied-Charreton <136271426+winstonallo@users.noreply.github.com> Date: Wed, 8 Oct 2025 14:40:47 +0200 Subject: [PATCH 036/108] Add colon to Install dejagnu step for consistency --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 5ebdef15a5ce..9cdd59f94f81 100644 --- a/Readme.md +++ b/Readme.md @@ -76,7 +76,7 @@ If you want to run libgccjit tests, you will need to ```bash --enable-languages=jit,c++ ``` -* Install [dejagnu](https://www.gnu.org/software/dejagnu/#downloading) to run the tests +* Install [dejagnu](https://www.gnu.org/software/dejagnu/#downloading) to run the tests: ```bash $ sudo apt install dejagnu From 5384032d284cccdc12181ba74e9367768901c52f Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 3 Oct 2025 11:27:03 -0400 Subject: [PATCH 037/108] Update GCC version --- libgccjit.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgccjit.version b/libgccjit.version index 8ed7e0f5fb08..93cff753b14d 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -4a8c8ec7c375a2f6bb5ca832efa45375a590bb5d +0256a7539a83aa26aade8cca138d9c69634a51b1 From b70b3041712b9821395d5244900f4a52a70d3020 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 20 May 2025 07:12:55 -0400 Subject: [PATCH 038/108] Remove EMBED_LTO_BITCODE --- .github/workflows/release.yml | 6 +- Readme.md | 10 --- src/back/write.rs | 112 +++++++++++----------------------- 3 files changed, 40 insertions(+), 88 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65ceb6919066..a577c2eed712 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,7 +62,7 @@ jobs: - name: Build run: | ./y.sh prepare --only-libcore - EMBED_LTO_BITCODE=1 ./y.sh build --sysroot --release --release-sysroot + ./y.sh build --sysroot --release --release-sysroot ./y.sh test --cargo-tests ./y.sh clean all @@ -80,11 +80,11 @@ jobs: # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. # FIXME(antoyo): this should probably not be needed since we embed the LTO bitcode. printf '[profile.release]\nlto = "fat"\n' >> build/build_sysroot/sysroot_src/library/Cargo.toml - EMBED_LTO_BITCODE=1 ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} + ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} - name: LTO test run: | - EMBED_LTO_BITCODE=1 CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml + CHANNEL="release" ./y.sh cargo build --release --manifest-path tests/hello-world/Cargo.toml call_found=$(objdump -dj .text tests/hello-world/target/release/hello_world | grep -c "call .*mylib.*my_func" ) ||: if [ $call_found -gt 0 ]; then echo "ERROR: call my_func found in asm" diff --git a/Readme.md b/Readme.md index 9cdd59f94f81..cd6aeae4b42e 100644 --- a/Readme.md +++ b/Readme.md @@ -141,16 +141,6 @@ $ CHANNEL="release" $CG_GCCJIT_DIR/y.sh cargo run If you compiled cg_gccjit in debug mode (aka you didn't pass `--release` to `./y.sh test`) you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely. -### LTO - -To use LTO, you need to set the variable `EMBED_LTO_BITCODE=1` in addition to setting `lto = "fat"` in the `Cargo.toml`. - -Failing to set `EMBED_LTO_BITCODE` will give you the following error: - -``` -error: failed to copy bitcode to object file: No such file or directory (os error 2) -``` - ### Rustc If you want to run `rustc` directly, you can do so with: diff --git a/src/back/write.rs b/src/back/write.rs index 84bc70162719..02537e89abad 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -26,11 +26,6 @@ pub(crate) fn codegen( let should_combine_object_files = module.module_llvm.should_combine_object_files; - // NOTE: Only generate object files with GIMPLE when this environment variable is set for - // now because this requires a particular setup (same gcc/lto1/lto-wrapper commit as libgccjit). - // TODO(antoyo): remove this environment variable. - let fat_lto = env::var("EMBED_LTO_BITCODE").as_deref() == Ok("1"); - let bc_out = cgcx.output_filenames.temp_path_for_cgu( OutputType::Bitcode, &module.name, @@ -43,80 +38,44 @@ pub(crate) fn codegen( ); if config.bitcode_needed() { - if fat_lto { + let _timer = cgcx + .prof + .generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name); + + // TODO(antoyo) + /*if let Some(bitcode_filename) = bc_out.file_name() { + cgcx.prof.artifact_size( + "llvm_bitcode", + bitcode_filename.to_string_lossy(), + data.len() as u64, + ); + }*/ + + if config.emit_bc || config.emit_obj == EmitObj::Bitcode { let _timer = cgcx .prof - .generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name); + .generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name); + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. + context.add_command_line_option("-ffat-lto-objects"); + context + .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); + } - // TODO(antoyo) - /*if let Some(bitcode_filename) = bc_out.file_name() { - cgcx.prof.artifact_size( - "llvm_bitcode", - bitcode_filename.to_string_lossy(), - data.len() as u64, - ); - }*/ + if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) { + let _timer = cgcx + .prof + .generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name); + // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? + //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); - if config.emit_bc || config.emit_obj == EmitObj::Bitcode { - let _timer = cgcx.prof.generic_activity_with_arg( - "GCC_module_codegen_emit_bitcode", - &*module.name, - ); - context.add_command_line_option("-flto=auto"); - context.add_command_line_option("-flto-partition=one"); - // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. - context.add_command_line_option("-ffat-lto-objects"); - context.compile_to_file( - OutputKind::ObjectFile, - bc_out.to_str().expect("path to str"), - ); - } - - if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) { - let _timer = cgcx.prof.generic_activity_with_arg( - "GCC_module_codegen_embed_bitcode", - &*module.name, - ); - // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? - //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); - - context.add_command_line_option("-flto=auto"); - context.add_command_line_option("-flto-partition=one"); - context.add_command_line_option("-ffat-lto-objects"); - // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument). - context.compile_to_file( - OutputKind::ObjectFile, - bc_out.to_str().expect("path to str"), - ); - } - } else { - if config.emit_bc || config.emit_obj == EmitObj::Bitcode { - let _timer = cgcx.prof.generic_activity_with_arg( - "GCC_module_codegen_emit_bitcode", - &*module.name, - ); - context.compile_to_file( - OutputKind::ObjectFile, - bc_out.to_str().expect("path to str"), - ); - } - - if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) { - // TODO(antoyo): we might want to emit to emit an error here, saying to set the - // environment variable EMBED_LTO_BITCODE. - let _timer = cgcx.prof.generic_activity_with_arg( - "GCC_module_codegen_embed_bitcode", - &*module.name, - ); - // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? - //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); - - // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument). - context.compile_to_file( - OutputKind::ObjectFile, - bc_out.to_str().expect("path to str"), - ); - } + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + context.add_command_line_option("-ffat-lto-objects"); + // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument). + context + .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); } } @@ -166,6 +125,9 @@ pub(crate) fn codegen( context.dump_to_file(path, true); } if should_combine_object_files { + let fat_lto = config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full); + // We need to check if we're doing LTO since this code is also used for the + // dummy ThinLTO implementation to combine the object files. if fat_lto { context.add_command_line_option("-flto=auto"); context.add_command_line_option("-flto-partition=one"); From af86f4e351f828a0b475016765996e347ee2e70b Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 20 May 2025 09:26:22 -0400 Subject: [PATCH 039/108] Fix to do LTO when requested --- src/back/lto.rs | 10 +++++----- src/back/write.rs | 8 ++++---- src/base.rs | 4 ++-- src/lib.rs | 11 +++++++++-- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index d29bba2570f6..fdd4bdb0e397 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -38,7 +38,7 @@ use tempfile::{TempDir, tempdir}; use crate::back::write::save_temp_bitcode; use crate::errors::LtoBitcodeFromRlib; -use crate::{GccCodegenBackend, GccContext, SyncContext, to_gcc_opt_level}; +use crate::{GccCodegenBackend, GccContext, LtoMode, SyncContext, to_gcc_opt_level}; struct LtoData { // TODO(antoyo): use symbols_below_threshold. @@ -228,7 +228,7 @@ fn fat_lto( info!("linking {:?}", name); match bc_decoded { SerializedModule::Local(ref module_buffer) => { - module.module_llvm.should_combine_object_files = true; + module.module_llvm.lto_mode = LtoMode::Fat; module .module_llvm .context @@ -533,7 +533,7 @@ pub fn optimize_thin_module( // that LLVM Context and Module. //let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names); //let llmod_raw = parse_module(llcx, module_name, thin_module.data(), &dcx)? as *const _; - let mut should_combine_object_files = false; + let mut lto_mode = LtoMode::None; let context = match thin_module.shared.thin_buffers.get(thin_module.idx) { Some(thin_buffer) => Arc::clone(&thin_buffer.context), None => { @@ -544,7 +544,7 @@ pub fn optimize_thin_module( SerializedModule::Local(ref module_buffer) => { let path = module_buffer.0.to_str().expect("path"); context.add_driver_option(path); - should_combine_object_files = true; + lto_mode = LtoMode::Thin; /*module.module_llvm.should_combine_object_files = true; module .module_llvm @@ -563,7 +563,7 @@ pub fn optimize_thin_module( thin_module.name().to_string(), GccContext { context, - should_combine_object_files, + lto_mode, // TODO(antoyo): use the correct relocation model here. relocation_model: RelocModel::Pic, temp_dir: None, diff --git a/src/back/write.rs b/src/back/write.rs index 02537e89abad..1bc0402298b4 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -10,7 +10,7 @@ use rustc_target::spec::SplitDebuginfo; use crate::base::add_pic_option; use crate::errors::CopyBitcode; -use crate::{GccCodegenBackend, GccContext}; +use crate::{GccCodegenBackend, GccContext, LtoMode}; pub(crate) fn codegen( cgcx: &CodegenContext, @@ -24,7 +24,7 @@ pub(crate) fn codegen( { let context = &module.module_llvm.context; - let should_combine_object_files = module.module_llvm.should_combine_object_files; + let lto_mode = module.module_llvm.lto_mode; let bc_out = cgcx.output_filenames.temp_path_for_cgu( OutputType::Bitcode, @@ -124,8 +124,8 @@ pub(crate) fn codegen( context.set_debug_info(true); context.dump_to_file(path, true); } - if should_combine_object_files { - let fat_lto = config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full); + if lto_mode != LtoMode::None { + let fat_lto = lto_mode == LtoMode::Fat; // We need to check if we're doing LTO since this code is also used for the // dummy ThinLTO implementation to combine the object files. if fat_lto { diff --git a/src/base.rs b/src/base.rs index e8672f49580b..4616e46b8c9b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -21,7 +21,7 @@ use rustc_target::spec::SymbolVisibility; use crate::builder::Builder; use crate::context::CodegenCx; -use crate::{GccContext, LockedTargetInfo, SyncContext, gcc_util, new_context}; +use crate::{GccContext, LockedTargetInfo, LtoMode, SyncContext, gcc_util, new_context}; #[cfg(feature = "master")] pub fn visibility_to_gcc(visibility: Visibility) -> gccjit::Visibility { @@ -247,7 +247,7 @@ pub fn compile_codegen_unit( GccContext { context: Arc::new(SyncContext::new(context)), relocation_model: tcx.sess.relocation_model(), - should_combine_object_files: false, + lto_mode: LtoMode::None, temp_dir: None, }, ) diff --git a/src/lib.rs b/src/lib.rs index ec7eab8489ab..79f7d21711ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -290,7 +290,7 @@ impl ExtraBackendMethods for GccCodegenBackend { let mut mods = GccContext { context: Arc::new(SyncContext::new(new_context(tcx))), relocation_model: tcx.sess.relocation_model(), - should_combine_object_files: false, + lto_mode: LtoMode::None, temp_dir: None, }; @@ -319,12 +319,19 @@ impl ExtraBackendMethods for GccCodegenBackend { } } +#[derive(Clone, Copy, PartialEq)] +pub enum LtoMode { + None, + Thin, + Fat, +} + pub struct GccContext { context: Arc, /// This field is needed in order to be able to set the flag -fPIC when necessary when doing /// LTO. relocation_model: RelocModel, - should_combine_object_files: bool, + lto_mode: LtoMode, // Temporary directory used by LTO. We keep it here so that it's not removed before linking. temp_dir: Option, } From b0777f2c07364554dce2110d03460c5f190297c3 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 20 May 2025 21:15:48 -0400 Subject: [PATCH 040/108] Fix to not do LTO when LTO is not enabled in gcc --- src/back/lto.rs | 1 + src/back/write.rs | 24 +++++++++++++++--------- src/base.rs | 6 ++++-- src/lib.rs | 43 +++++++++++++++++++++++++++++++++++++------ 4 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index fdd4bdb0e397..e9088a4e6e89 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -564,6 +564,7 @@ pub fn optimize_thin_module( GccContext { context, lto_mode, + lto_supported: false, // TODO(antoyo): check if this is correct to use this value. // TODO(antoyo): use the correct relocation model here. relocation_model: RelocModel::Pic, temp_dir: None, diff --git a/src/back/write.rs b/src/back/write.rs index 1bc0402298b4..a59839251192 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -25,6 +25,7 @@ pub(crate) fn codegen( let context = &module.module_llvm.context; let lto_mode = module.module_llvm.lto_mode; + let lto_supported = module.module_llvm.lto_supported; let bc_out = cgcx.output_filenames.temp_path_for_cgu( OutputType::Bitcode, @@ -51,14 +52,17 @@ pub(crate) fn codegen( ); }*/ + // TODO: only emit if libgccjit is compiled with LTO enabled? if config.emit_bc || config.emit_obj == EmitObj::Bitcode { let _timer = cgcx .prof .generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name); - context.add_command_line_option("-flto=auto"); - context.add_command_line_option("-flto-partition=one"); - // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. - context.add_command_line_option("-ffat-lto-objects"); + if lto_supported { + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. + context.add_command_line_option("-ffat-lto-objects"); + } context .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); } @@ -67,12 +71,14 @@ pub(crate) fn codegen( let _timer = cgcx .prof .generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name); - // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? - //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); + if lto_supported { + // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes? + //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data); - context.add_command_line_option("-flto=auto"); - context.add_command_line_option("-flto-partition=one"); - context.add_command_line_option("-ffat-lto-objects"); + context.add_command_line_option("-flto=auto"); + context.add_command_line_option("-flto-partition=one"); + context.add_command_line_option("-ffat-lto-objects"); + } // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument). context .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); diff --git a/src/base.rs b/src/base.rs index 4616e46b8c9b..7cf3a2375879 100644 --- a/src/base.rs +++ b/src/base.rs @@ -74,6 +74,7 @@ pub fn compile_codegen_unit( tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: LockedTargetInfo, + lto_supported: bool, ) -> (ModuleCodegen, u64) { let prof_timer = tcx.prof.generic_activity("codegen_module"); let start_time = Instant::now(); @@ -82,7 +83,7 @@ pub fn compile_codegen_unit( let (module, _) = tcx.dep_graph.with_task( dep_node, tcx, - (cgu_name, target_info), + (cgu_name, target_info, lto_supported), module_codegen, Some(dep_graph::hash_result), ); @@ -95,7 +96,7 @@ pub fn compile_codegen_unit( fn module_codegen( tcx: TyCtxt<'_>, - (cgu_name, target_info): (Symbol, LockedTargetInfo), + (cgu_name, target_info, lto_supported): (Symbol, LockedTargetInfo, bool), ) -> ModuleCodegen { let cgu = tcx.codegen_unit(cgu_name); // Instantiate monomorphizations without filling out definitions yet... @@ -247,6 +248,7 @@ pub fn compile_codegen_unit( GccContext { context: Arc::new(SyncContext::new(context)), relocation_model: tcx.sess.relocation_model(), + lto_supported, lto_mode: LtoMode::None, temp_dir: None, }, diff --git a/src/lib.rs b/src/lib.rs index 79f7d21711ef..f48d94526621 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,10 +82,7 @@ use std::any::Any; use std::fmt::Debug; use std::ops::Deref; use std::path::PathBuf; -#[cfg(not(feature = "master"))] -use std::sync::atomic::AtomicBool; -#[cfg(not(feature = "master"))] -use std::sync::atomic::Ordering; +use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; use back::lto::{ThinBuffer, ThinData}; @@ -177,6 +174,7 @@ impl LockedTargetInfo { #[derive(Clone)] pub struct GccCodegenBackend { target_info: LockedTargetInfo, + lto_supported: Arc, } impl CodegenBackend for GccCodegenBackend { @@ -202,6 +200,29 @@ impl CodegenBackend for GccCodegenBackend { **self.target_info.info.lock().expect("lock") = context.get_target_info(); } + // TODO: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. + { + let temp_dir = TempDir::new().expect("cannot create temporary directory"); + let temp_file = temp_dir.into_path().join("result.asm"); + let context = Context::default(); + let object_file_path = temp_file.to_str().expect("path to str"); + context.compile_to_file(gccjit::OutputKind::ObjectFile, object_file_path); + + //let temp_dir = TempDir::new().expect("cannot create temporary directory"); + //let temp_file = temp_dir.into_path().join("result.asm"); + let check_context = Context::default(); + check_context.add_driver_option("-x"); + check_context.add_driver_option("lto"); + check_context.add_driver_option(object_file_path); + check_context.set_print_errors_to_stderr(false); + //context.compile_to_file(gccjit::OutputKind::ObjectFile, temp_file.to_str().expect("path to str")); + // FIXME: compile gives the error as expected, but compile_to_file doesn't. + check_context.compile(); + let error = check_context.get_last_error(); + let lto_supported = error == Ok(None); + self.lto_supported.store(lto_supported, Ordering::SeqCst); + } + #[cfg(feature = "master")] gccjit::set_global_personality_function_name(b"rust_eh_personality\0"); @@ -291,6 +312,7 @@ impl ExtraBackendMethods for GccCodegenBackend { context: Arc::new(SyncContext::new(new_context(tcx))), relocation_model: tcx.sess.relocation_model(), lto_mode: LtoMode::None, + lto_supported: false, temp_dir: None, }; @@ -305,7 +327,12 @@ impl ExtraBackendMethods for GccCodegenBackend { tcx: TyCtxt<'_>, cgu_name: Symbol, ) -> (ModuleCodegen, u64) { - base::compile_codegen_unit(tcx, cgu_name, self.target_info.clone()) + base::compile_codegen_unit( + tcx, + cgu_name, + self.target_info.clone(), + self.lto_supported.load(Ordering::SeqCst), + ) } fn target_machine_factory( @@ -332,6 +359,7 @@ pub struct GccContext { /// LTO. relocation_model: RelocModel, lto_mode: LtoMode, + lto_supported: bool, // Temporary directory used by LTO. We keep it here so that it's not removed before linking. temp_dir: Option, } @@ -443,7 +471,10 @@ pub fn __rustc_codegen_backend() -> Box { supports_128bit_integers: AtomicBool::new(false), }))); - Box::new(GccCodegenBackend { target_info: LockedTargetInfo { info } }) + Box::new(GccCodegenBackend { + lto_supported: Arc::new(AtomicBool::new(false)), + target_info: LockedTargetInfo { info }, + }) } fn to_gcc_opt_level(optlevel: Option) -> OptimizationLevel { From 2f2a83450755d1e8e4ae43ace2e7817549e5cbcf Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 15 Jun 2025 09:43:44 -0400 Subject: [PATCH 041/108] Fix to forward lto_supported and lto_mode where needed --- src/back/lto.rs | 6 ++++-- src/lib.rs | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index e9088a4e6e89..9071c4900131 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -21,6 +21,7 @@ use std::ffi::{CStr, CString}; use std::fs::{self, File}; use std::path::{Path, PathBuf}; use std::sync::Arc; +use std::sync::atomic::Ordering; use gccjit::{Context, OutputKind}; use object::read::archive::ArchiveFile; @@ -38,7 +39,7 @@ use tempfile::{TempDir, tempdir}; use crate::back::write::save_temp_bitcode; use crate::errors::LtoBitcodeFromRlib; -use crate::{GccCodegenBackend, GccContext, LtoMode, SyncContext, to_gcc_opt_level}; +use crate::{GccCodegenBackend, GccContext, LTO_SUPPORTED, LtoMode, SyncContext, to_gcc_opt_level}; struct LtoData { // TODO(antoyo): use symbols_below_threshold. @@ -559,12 +560,13 @@ pub fn optimize_thin_module( Arc::new(SyncContext::new(context)) } }; + let lto_supported = LTO_SUPPORTED.load(Ordering::SeqCst); let module = ModuleCodegen::new_regular( thin_module.name().to_string(), GccContext { context, lto_mode, - lto_supported: false, // TODO(antoyo): check if this is correct to use this value. + lto_supported, // TODO(antoyo): use the correct relocation model here. relocation_model: RelocModel::Pic, temp_dir: None, diff --git a/src/lib.rs b/src/lib.rs index f48d94526621..ec3f5a919ab7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -177,6 +177,8 @@ pub struct GccCodegenBackend { lto_supported: Arc, } +static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false); + impl CodegenBackend for GccCodegenBackend { fn locale_resource(&self) -> &'static str { crate::DEFAULT_LOCALE_RESOURCE @@ -200,7 +202,7 @@ impl CodegenBackend for GccCodegenBackend { **self.target_info.info.lock().expect("lock") = context.get_target_info(); } - // TODO: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. + // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. { let temp_dir = TempDir::new().expect("cannot create temporary directory"); let temp_file = temp_dir.into_path().join("result.asm"); @@ -220,6 +222,7 @@ impl CodegenBackend for GccCodegenBackend { check_context.compile(); let error = check_context.get_last_error(); let lto_supported = error == Ok(None); + LTO_SUPPORTED.store(lto_supported, Ordering::SeqCst); self.lto_supported.store(lto_supported, Ordering::SeqCst); } @@ -308,11 +311,12 @@ impl ExtraBackendMethods for GccCodegenBackend { kind: AllocatorKind, alloc_error_handler_kind: AllocatorKind, ) -> Self::Module { + let lto_supported = self.lto_supported.load(Ordering::SeqCst); let mut mods = GccContext { context: Arc::new(SyncContext::new(new_context(tcx))), relocation_model: tcx.sess.relocation_model(), lto_mode: LtoMode::None, - lto_supported: false, + lto_supported, temp_dir: None, }; From 0166bfc4fb5af4efb86aee5136263e0a21de47a0 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 1 Jul 2025 09:27:34 -0400 Subject: [PATCH 042/108] Fix clippy warning --- Cargo.toml | 1 + src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6031933bd2d2..2afa0c2a1665 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ gccjit = "2.8" [dev-dependencies] boml = "0.3.1" lang_tester = "0.8.0" +tempfile = "3.20.0" [profile.dev] # By compiling dependencies with optimizations, performing tests gets much faster. diff --git a/src/lib.rs b/src/lib.rs index ec3f5a919ab7..f30f3f1ed158 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -205,7 +205,7 @@ impl CodegenBackend for GccCodegenBackend { // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. { let temp_dir = TempDir::new().expect("cannot create temporary directory"); - let temp_file = temp_dir.into_path().join("result.asm"); + let temp_file = temp_dir.keep().join("result.asm"); let context = Context::default(); let object_file_path = temp_file.to_str().expect("path to str"); context.compile_to_file(gccjit::OutputKind::ObjectFile, object_file_path); From 7a5ee0f585c978e4cba8b53736c85820ba0ef816 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 15 Jun 2025 13:43:04 -0400 Subject: [PATCH 043/108] Only check if LTO is enabled when using the master branch of libgccjit --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f30f3f1ed158..1e14d6bd60db 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,8 +202,15 @@ impl CodegenBackend for GccCodegenBackend { **self.target_info.info.lock().expect("lock") = context.get_target_info(); } - // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. + // While not required by the API, we gate this code on the master feature to make sure we + // don't abort the process while checking if LTO is supported. + // The following could will emit a fatal error if LTO is not supported and older versions + // of libgccjit (the ones without this commit: + // https://github.com/rust-lang/gcc/commit/a073b06800f064b3917a6113d4cc2a0c19a10fda) will + // abort on fatal errors. + #[cfg(feature = "master")] { + // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. let temp_dir = TempDir::new().expect("cannot create temporary directory"); let temp_file = temp_dir.keep().join("result.asm"); let context = Context::default(); From 81bbe140a5d222ee809b397b5655f74280094e17 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 15 Jun 2025 17:44:59 -0400 Subject: [PATCH 044/108] Remove comment --- src/back/write.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/back/write.rs b/src/back/write.rs index a59839251192..9f3ac6f682ec 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -52,7 +52,6 @@ pub(crate) fn codegen( ); }*/ - // TODO: only emit if libgccjit is compiled with LTO enabled? if config.emit_bc || config.emit_obj == EmitObj::Bitcode { let _timer = cgcx .prof From ea362b21f0a31c453394642d38a5f0a6d50cfa7f Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 9 Oct 2025 15:40:06 -0400 Subject: [PATCH 045/108] Fix to remove messages to stderr when LTO is not suppported by using the new API gccjit::is_lto_supported --- Cargo.lock | 8 ++++---- Cargo.toml | 3 +-- src/lib.rs | 31 +++---------------------------- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5b972baf98e..181d3aa89bc8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,18 +56,18 @@ dependencies = [ [[package]] name = "gccjit" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0e310ef75f396cd11b2443b353d55376656ca92c13cba36f92b7aff346ac1a" +checksum = "60362e038e71e4bdc1a5b23fb45e1aba587b5947fe0db58f4871d95608f89eca" dependencies = [ "gccjit_sys", ] [[package]] name = "gccjit_sys" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ed7572b30cd32430294dde6fb70822d58e67c6846a548647e8739776a0125b" +checksum = "ddd542c8414e122217551c6af6b7d33acf51a227aee85276f218c087525e01bb" dependencies = [ "libc", ] diff --git a/Cargo.toml b/Cargo.toml index 2afa0c2a1665..d3ff2757857b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ default = ["master"] [dependencies] object = { version = "0.37.0", default-features = false, features = ["std", "read"] } tempfile = "3.20" -gccjit = "2.8" +gccjit = "2.10" #gccjit = { git = "https://github.com/rust-lang/gccjit.rs" } # Local copy. @@ -33,7 +33,6 @@ gccjit = "2.8" [dev-dependencies] boml = "0.3.1" lang_tester = "0.8.0" -tempfile = "3.20.0" [profile.dev] # By compiling dependencies with optimizations, performing tests gets much faster. diff --git a/src/lib.rs b/src/lib.rs index 1e14d6bd60db..9854f3843c40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,39 +202,14 @@ impl CodegenBackend for GccCodegenBackend { **self.target_info.info.lock().expect("lock") = context.get_target_info(); } - // While not required by the API, we gate this code on the master feature to make sure we - // don't abort the process while checking if LTO is supported. - // The following could will emit a fatal error if LTO is not supported and older versions - // of libgccjit (the ones without this commit: - // https://github.com/rust-lang/gcc/commit/a073b06800f064b3917a6113d4cc2a0c19a10fda) will - // abort on fatal errors. #[cfg(feature = "master")] { - // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode. - let temp_dir = TempDir::new().expect("cannot create temporary directory"); - let temp_file = temp_dir.keep().join("result.asm"); - let context = Context::default(); - let object_file_path = temp_file.to_str().expect("path to str"); - context.compile_to_file(gccjit::OutputKind::ObjectFile, object_file_path); - - //let temp_dir = TempDir::new().expect("cannot create temporary directory"); - //let temp_file = temp_dir.into_path().join("result.asm"); - let check_context = Context::default(); - check_context.add_driver_option("-x"); - check_context.add_driver_option("lto"); - check_context.add_driver_option(object_file_path); - check_context.set_print_errors_to_stderr(false); - //context.compile_to_file(gccjit::OutputKind::ObjectFile, temp_file.to_str().expect("path to str")); - // FIXME: compile gives the error as expected, but compile_to_file doesn't. - check_context.compile(); - let error = check_context.get_last_error(); - let lto_supported = error == Ok(None); + let lto_supported = gccjit::is_lto_supported(); LTO_SUPPORTED.store(lto_supported, Ordering::SeqCst); self.lto_supported.store(lto_supported, Ordering::SeqCst); - } - #[cfg(feature = "master")] - gccjit::set_global_personality_function_name(b"rust_eh_personality\0"); + gccjit::set_global_personality_function_name(b"rust_eh_personality\0"); + } #[cfg(not(feature = "master"))] { From 1e4b27349b8376af1946b6ef2261c88526918d01 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 9 Oct 2025 15:48:29 -0400 Subject: [PATCH 046/108] Update GCC version --- libgccjit.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgccjit.version b/libgccjit.version index 93cff753b14d..b8d4166542bc 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -0256a7539a83aa26aade8cca138d9c69634a51b1 +28b84db392ac0a572f1a2a2a1317aa5f2bc742cb From 7b71e5408d497d2121cb6a08f36dc31880963fa9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 26 Jun 2025 13:44:01 +0000 Subject: [PATCH 047/108] Support #[alloc_error_handler] without the allocator shim Currently it is possible to avoid linking the allocator shim when __rust_no_alloc_shim_is_unstable_v2 is defined when linking rlibs directly as some build systems need. However this requires liballoc to be compiled with --cfg no_global_oom_handling, which places huge restrictions on what functions you can call and makes it impossible to use libstd. Or alternatively you have to define __rust_alloc_error_handler and (when using libstd) __rust_alloc_error_handler_should_panic using #[rustc_std_internal_symbol]. With this commit you can either use libstd and define __rust_alloc_error_handler_should_panic or not use libstd and use #[alloc_error_handler] instead. Both options are still unstable though. Eventually the alloc_error_handler may either be removed entirely (though the PR for that has been stale for years now) or we may start using weak symbols for it instead. For the latter case this commit is a prerequisite anyway. --- src/allocator.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 2a95a7368aac..3f99612fcdb0 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -2,8 +2,8 @@ use gccjit::FnAttribute; use gccjit::{Context, FunctionType, RValue, ToRValue, Type}; use rustc_ast::expand::allocator::{ - ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, - alloc_error_handler_name, default_fn_name, global_fn_name, + ALLOC_ERROR_HANDLER, ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, + default_fn_name, global_fn_name, }; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; @@ -61,15 +61,17 @@ pub(crate) unsafe fn codegen( } } - // FIXME(bjorn3): Add noreturn attribute - create_wrapper_function( - tcx, - context, - &mangle_internal_symbol(tcx, "__rust_alloc_error_handler"), - Some(&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind))), - &[usize, usize], - None, - ); + if alloc_error_handler_kind == AllocatorKind::Default { + // FIXME(bjorn3): Add noreturn attribute + create_wrapper_function( + tcx, + context, + &mangle_internal_symbol(tcx, &global_fn_name(ALLOC_ERROR_HANDLER)), + Some(&mangle_internal_symbol(tcx, &default_fn_name(ALLOC_ERROR_HANDLER))), + &[usize, usize], + None, + ); + } create_const_value_function( tcx, From 5f0d88ffcf4c97c062746e2c4dc4e68d5eab9cbc Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 9 Oct 2025 14:08:55 +0000 Subject: [PATCH 048/108] Move computation of allocator shim contents to cg_ssa In the future this should make it easier to use weak symbols for the allocator shim on platforms that properly support weak symbols. And it would allow reusing the allocator shim code for handling default implementations of the upcoming externally implementable items feature on platforms that don't properly support weak symbols. --- src/allocator.rs | 64 +++++++++++++++++++----------------------------- src/lib.rs | 7 +++--- 2 files changed, 28 insertions(+), 43 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index 3f99612fcdb0..647569694b04 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -2,8 +2,7 @@ use gccjit::FnAttribute; use gccjit::{Context, FunctionType, RValue, ToRValue, Type}; use rustc_ast::expand::allocator::{ - ALLOC_ERROR_HANDLER, ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, - default_fn_name, global_fn_name, + AllocatorMethod, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, default_fn_name, global_fn_name, }; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; @@ -18,8 +17,7 @@ pub(crate) unsafe fn codegen( tcx: TyCtxt<'_>, mods: &mut GccContext, _module_name: &str, - kind: AllocatorKind, - alloc_error_handler_kind: AllocatorKind, + methods: &[AllocatorMethod], ) { let context = &mods.context; let usize = match tcx.sess.target.pointer_width { @@ -31,46 +29,34 @@ pub(crate) unsafe fn codegen( let i8 = context.new_type::(); let i8p = i8.make_pointer(); - if kind == AllocatorKind::Default { - for method in ALLOCATOR_METHODS { - let mut types = Vec::with_capacity(method.inputs.len()); - for input in method.inputs.iter() { - match input.ty { - AllocatorTy::Layout => { - types.push(usize); - types.push(usize); - } - AllocatorTy::Ptr => types.push(i8p), - AllocatorTy::Usize => types.push(usize), + for method in methods { + let mut types = Vec::with_capacity(method.inputs.len()); + for input in method.inputs.iter() { + match input.ty { + AllocatorTy::Layout => { + types.push(usize); + types.push(usize); + } + AllocatorTy::Ptr => types.push(i8p), + AllocatorTy::Usize => types.push(usize), - AllocatorTy::ResultPtr | AllocatorTy::Unit => panic!("invalid allocator arg"), + AllocatorTy::Never | AllocatorTy::ResultPtr | AllocatorTy::Unit => { + panic!("invalid allocator arg") } } - let output = match method.output { - AllocatorTy::ResultPtr => Some(i8p), - AllocatorTy::Unit => None, - - AllocatorTy::Layout | AllocatorTy::Usize | AllocatorTy::Ptr => { - panic!("invalid allocator output") - } - }; - let from_name = mangle_internal_symbol(tcx, &global_fn_name(method.name)); - let to_name = mangle_internal_symbol(tcx, &default_fn_name(method.name)); - - create_wrapper_function(tcx, context, &from_name, Some(&to_name), &types, output); } - } + let output = match method.output { + AllocatorTy::ResultPtr => Some(i8p), + AllocatorTy::Never | AllocatorTy::Unit => None, - if alloc_error_handler_kind == AllocatorKind::Default { - // FIXME(bjorn3): Add noreturn attribute - create_wrapper_function( - tcx, - context, - &mangle_internal_symbol(tcx, &global_fn_name(ALLOC_ERROR_HANDLER)), - Some(&mangle_internal_symbol(tcx, &default_fn_name(ALLOC_ERROR_HANDLER))), - &[usize, usize], - None, - ); + AllocatorTy::Layout | AllocatorTy::Usize | AllocatorTy::Ptr => { + panic!("invalid allocator output") + } + }; + let from_name = mangle_internal_symbol(tcx, &global_fn_name(method.name)); + let to_name = mangle_internal_symbol(tcx, &default_fn_name(method.name)); + + create_wrapper_function(tcx, context, &from_name, Some(&to_name), &types, output); } create_const_value_function( diff --git a/src/lib.rs b/src/lib.rs index ec7eab8489ab..c85ed0ebb339 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,7 +92,7 @@ use back::lto::{ThinBuffer, ThinData}; use gccjit::{CType, Context, OptimizationLevel}; #[cfg(feature = "master")] use gccjit::{TargetInfo, Version}; -use rustc_ast::expand::allocator::AllocatorKind; +use rustc_ast::expand::allocator::AllocatorMethod; use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule}; use rustc_codegen_ssa::back::write::{ CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryFn, @@ -284,8 +284,7 @@ impl ExtraBackendMethods for GccCodegenBackend { &self, tcx: TyCtxt<'_>, module_name: &str, - kind: AllocatorKind, - alloc_error_handler_kind: AllocatorKind, + methods: &[AllocatorMethod], ) -> Self::Module { let mut mods = GccContext { context: Arc::new(SyncContext::new(new_context(tcx))), @@ -295,7 +294,7 @@ impl ExtraBackendMethods for GccCodegenBackend { }; unsafe { - allocator::codegen(tcx, &mut mods, module_name, kind, alloc_error_handler_kind); + allocator::codegen(tcx, &mut mods, module_name, methods); } mods } From e83aa35949dbdce1f042ed9aba739a5a77c52f76 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 09:39:02 -0400 Subject: [PATCH 049/108] Remove remaining usage of EMBED_LTO_BITCODE --- .github/workflows/release.yml | 2 +- tests/cross_lang_lto/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a577c2eed712..99cc123941fa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -99,7 +99,7 @@ jobs: ar rcs libadd.a add.o popd - EMBED_LTO_BITCODE=1 CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml + CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml call_found=$(objdump -dj .text tests/cross_lang_lto/target/release/cross_lang_lto | grep -c "call .*my_add" ) ||: if [ $call_found -gt 0 ]; then echo "ERROR: call my_add found in asm" diff --git a/tests/cross_lang_lto/src/main.rs b/tests/cross_lang_lto/src/main.rs index a7180b333963..3c64248ba2a0 100644 --- a/tests/cross_lang_lto/src/main.rs +++ b/tests/cross_lang_lto/src/main.rs @@ -4,7 +4,7 @@ * ar rcs libadd.a add.o * * Compile the Rust code with: - * EMBED_LTO_BITCODE=1 CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" y cargo run --release + * CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" y cargo run --release */ #[link(name="add")] From a50f0b42ab57fdb4d97898ff96b872eb22a605c6 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 09:39:50 -0400 Subject: [PATCH 050/108] Remove failing-lto-tests.txt --- .github/workflows/release.yml | 3 --- tests/failing-lto-tests.txt | 33 --------------------------------- 2 files changed, 36 deletions(-) delete mode 100644 tests/failing-lto-tests.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99cc123941fa..7803230087fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,9 +72,6 @@ jobs: git config --global user.name "User" ./y.sh prepare - - name: Add more failing tests because of undefined symbol errors (FIXME) - run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt - - name: Run tests run: | # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. diff --git a/tests/failing-lto-tests.txt b/tests/failing-lto-tests.txt deleted file mode 100644 index bf0633f73200..000000000000 --- a/tests/failing-lto-tests.txt +++ /dev/null @@ -1,33 +0,0 @@ -tests/ui/lint/unsafe_code/forge_unsafe_block.rs -tests/ui/lint/unused-qualification-in-derive-expansion.rs -tests/ui/macros/macro-quote-test.rs -tests/ui/macros/proc_macro.rs -tests/ui/panic-runtime/lto-unwind.rs -tests/ui/resolve/derive-macro-1.rs -tests/ui/resolve/derive-macro-2.rs -tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs -tests/ui/rfcs/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs -tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs -tests/ui/rust-2018/suggestions-not-always-applicable.rs -tests/ui/rust-2021/reserved-prefixes-via-macro.rs -tests/ui/underscore-imports/duplicate.rs -tests/ui/async-await/issues/issue-60674.rs -tests/ui/attributes/main-removed-2/main.rs -tests/ui/cfg/assume-incomplete-release/assume-incomplete.rs -tests/ui/crate-loading/cross-compiled-proc-macro.rs -tests/ui/derives/derive-marker-tricky.rs -tests/ui/diagnostic_namespace/existing_proc_macros.rs -tests/ui/fmt/format-args-capture-issue-106408.rs -tests/ui/fmt/indoc-issue-106408.rs -tests/ui/hygiene/issue-77523-def-site-async-await.rs -tests/ui/inherent-impls-overlap-check/no-overlap.rs -tests/ui/enum-discriminant/issue-46519.rs -tests/ui/issues/issue-45731.rs -tests/ui/lint/test-allow-dead-extern-static-no-warning.rs -tests/ui/macros/macro-comma-behavior-rpass.rs -tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs -tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs -tests/ui/macros/stringify.rs -tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs -tests/ui/binding/fn-arg-incomplete-pattern-drop-order.rs -tests/ui/lto/debuginfo-lto-alloc.rs From 784f11d17781774b775439699d5fef2f148e23e3 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 15:02:25 -0400 Subject: [PATCH 051/108] Do not generate fat objects when not needed --- src/back/write.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/back/write.rs b/src/back/write.rs index 9f3ac6f682ec..b654b34992c4 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -59,8 +59,6 @@ pub(crate) fn codegen( if lto_supported { context.add_command_line_option("-flto=auto"); context.add_command_line_option("-flto-partition=one"); - // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. - context.add_command_line_option("-ffat-lto-objects"); } context .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); From e44d493cee3654be0c01fd39f92140a5795bea56 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 15:02:34 -0400 Subject: [PATCH 052/108] Correctly embed the bitcode when compiling the sysroot --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7803230087fd..52f94dc2970a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,9 +75,7 @@ jobs: - name: Run tests run: | # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. - # FIXME(antoyo): this should probably not be needed since we embed the LTO bitcode. - printf '[profile.release]\nlto = "fat"\n' >> build/build_sysroot/sysroot_src/library/Cargo.toml - ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} + CG_RUSTFLAGS="-Cembed-bitcode=yes" ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} - name: LTO test run: | From 2cd4f6737533e6a72fa7ac8d4bba3e3d2c6b7ac9 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 11 Oct 2025 15:38:48 -0400 Subject: [PATCH 053/108] Clean the sysroot destination directory before copying the content into it --- build_system/src/build.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build_system/src/build.rs b/build_system/src/build.rs index 94b40319f4a7..6aa5faec4c81 100644 --- a/build_system/src/build.rs +++ b/build_system/src/build.rs @@ -149,6 +149,9 @@ pub fn build_sysroot(env: &HashMap, config: &ConfigInfo) -> Resu // Copy files to sysroot let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple)); + // To avoid errors like "multiple candidates for `rmeta` dependency `core` found", we clean the + // sysroot directory before copying the sysroot build artifacts. + let _ = fs::remove_dir_all(&sysroot_path); create_dir(&sysroot_path)?; let mut copier = |dir_to_copy: &Path| { // FIXME: should not use shell command! From 5544f5debba20d6e22e58f68dccc57fb09e6e4eb Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 12 Oct 2025 09:48:47 -0400 Subject: [PATCH 054/108] Remove passing tests from failing-ui-tests.txt --- build_system/src/test.rs | 52 +++++++++++++++++++++++--------------- tests/failing-ui-tests.txt | 12 --------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 1823aa71f408..d66cba3b0d11 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -910,6 +910,7 @@ fn test_rustc_inner( prepare_files_callback: F, run_error_pattern_test: bool, test_type: &str, + run_ignored_tests: bool, ) -> Result<(), String> where F: Fn(&Path) -> Result, @@ -1061,30 +1062,34 @@ where env.get_mut("RUSTFLAGS").unwrap().clear(); - run_command_with_output_and_env( - &[ - &"./x.py", - &"test", - &"--run", - &"always", - &"--stage", - &"0", - &"--set", - &"build.compiletest-allow-stage0=true", - &format!("tests/{test_type}"), - &"--compiletest-rustc-args", - &rustc_args, - ], - Some(&rust_path), - Some(&env), - )?; + let test_dir = format!("tests/{test_type}"); + let mut command: Vec<&dyn AsRef> = vec![ + &"./x.py", + &"test", + &"--run", + &"always", + &"--stage", + &"0", + &"--set", + &"build.compiletest-allow-stage0=true", + &test_dir, + &"--compiletest-rustc-args", + &rustc_args, + ]; + + if run_ignored_tests { + command.push(&"--"); + command.push(&"--ignored"); + } + + run_command_with_output_and_env(&command, Some(&rust_path), Some(&env))?; Ok(()) } fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> { - test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?; - test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo")?; - test_rustc_inner(env, args, |_| Ok(false), false, "ui") + test_rustc_inner(env, args, |_| Ok(false), false, "run-make", false)?; + test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo", false)?; + test_rustc_inner(env, args, |_| Ok(false), false, "ui", false) } fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { @@ -1094,6 +1099,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { retain_files_callback("tests/failing-run-make-tests.txt", "run-make"), false, "run-make", + true, ); let run_make_cargo_result = test_rustc_inner( @@ -1102,6 +1108,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { retain_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"), false, "run-make", + true, ); let ui_result = test_rustc_inner( @@ -1110,6 +1117,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { retain_files_callback("tests/failing-ui-tests.txt", "ui"), false, "ui", + true, ); run_make_result.and(run_make_cargo_result).and(ui_result) @@ -1122,6 +1130,7 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { remove_files_callback("tests/failing-ui-tests.txt", "ui"), false, "ui", + false, )?; test_rustc_inner( env, @@ -1129,6 +1138,7 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { remove_files_callback("tests/failing-run-make-tests.txt", "run-make"), false, "run-make", + false, )?; test_rustc_inner( env, @@ -1136,6 +1146,7 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { remove_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"), false, "run-make-cargo", + false, ) } @@ -1146,6 +1157,7 @@ fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String remove_files_callback("tests/failing-ice-tests.txt", "ui"), true, "ui", + false, ) } diff --git a/tests/failing-ui-tests.txt b/tests/failing-ui-tests.txt index 9a44034c127c..cc00432ceb54 100644 --- a/tests/failing-ui-tests.txt +++ b/tests/failing-ui-tests.txt @@ -1,5 +1,3 @@ -tests/ui/allocator/no_std-alloc-error-handler-custom.rs -tests/ui/allocator/no_std-alloc-error-handler-default.rs tests/ui/asm/may_unwind.rs tests/ui/asm/x86_64/may_unwind.rs tests/ui/drop/dynamic-drop-async.rs @@ -17,7 +15,6 @@ tests/ui/panic-runtime/link-to-abort.rs tests/ui/parser/unclosed-delimiter-in-dep.rs tests/ui/consts/missing_span_in_backtrace.rs tests/ui/drop/dynamic-drop.rs -tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs tests/ui/simd/issue-17170.rs tests/ui/simd/issue-39720.rs tests/ui/drop/panic-during-drop-14875.rs @@ -31,11 +28,9 @@ tests/ui/coroutine/resume-after-return.rs tests/ui/simd/masked-load-store.rs tests/ui/simd/repr_packed.rs tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs -tests/ui/consts/try-operator.rs tests/ui/coroutine/unwind-abort-mix.rs tests/ui/consts/issue-miri-1910.rs tests/ui/consts/const_cmp_type_id.rs -tests/ui/consts/issue-73976-monomorphic.rs tests/ui/consts/issue-94675.rs tests/ui/traits/const-traits/const-drop-fail.rs tests/ui/runtime/on-broken-pipe/child-processes.rs @@ -53,7 +48,6 @@ tests/ui/sanitizer/cfi/virtual-auto.rs tests/ui/sanitizer/cfi/sized-associated-ty.rs tests/ui/sanitizer/cfi/can-reveal-opaques.rs tests/ui/sanitizer/kcfi-mangling.rs -tests/ui/statics/const_generics.rs tests/ui/backtrace/dylib-dep.rs tests/ui/delegation/fn-header.rs tests/ui/consts/const-eval/parse_ints.rs @@ -74,13 +68,7 @@ tests/ui/codegen/equal-pointers-unequal/strict-provenance/zero.rs tests/ui/simd/simd-bitmask-notpow2.rs tests/ui/codegen/StackColoring-not-blowup-stack-issue-40883.rs tests/ui/numbers-arithmetic/u128-as-f32.rs -tests/ui/lto/all-crates.rs -tests/ui/uninhabited/uninhabited-transparent-return-abi.rs -tests/ui/coroutine/panic-drops-resume.rs -tests/ui/coroutine/panic-drops.rs -tests/ui/coroutine/panic-safe.rs tests/ui/process/nofile-limit.rs -tests/ui/simd/intrinsic/generic-arithmetic-pass.rs tests/ui/linking/no-gc-encapsulation-symbols.rs tests/ui/panics/unwind-force-no-unwind-tables.rs tests/ui/attributes/fn-align-dyn.rs From a93f53190410f7f0e0b9e1d2c319a6be821a4be1 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 12 Oct 2025 11:03:13 -0400 Subject: [PATCH 055/108] Stop removing some test directories --- build_system/src/test.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index d66cba3b0d11..dbdaf2a63ef2 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -945,17 +945,7 @@ where rust_path.join("tests/ui"), &mut |dir| { let dir_name = dir.file_name().and_then(|name| name.to_str()).unwrap_or(""); - if [ - "abi", - "extern", - "unsized-locals", - "proc-macro", - "threads-sendsync", - "borrowck", - "test-attrs", - ] - .contains(&dir_name) - { + if ["abi", "extern", "proc-macro", "threads-sendsync"].contains(&dir_name) { remove_dir_all(dir).map_err(|error| { format!("Failed to remove folder `{}`: {:?}", dir.display(), error) })?; From 2064793089c2d8656deda40dfee8e8d10b709f21 Mon Sep 17 00:00:00 2001 From: Paul Murphy Date: Fri, 19 Sep 2025 11:15:04 -0500 Subject: [PATCH 056/108] Allow vector-scalar (vs) registers in ppc inline assembly Where supported, VSX is a 64x128b register set which encompasses both the floating point and vector registers. In the type tests, xvsqrtdp is used as it is the only two-argument vsx opcode supported by all targets on llvm. If you need to copy a vsx register, the preferred way is "xxlor xt, xa, xa". --- src/asm.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/asm.rs b/src/asm.rs index a14881c502cf..81cdfc68737f 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -698,6 +698,7 @@ fn reg_class_to_gcc(reg_class: InlineAsmRegClass) -> &'static str { InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => "b", InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => "f", InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => "v", + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vsreg) => "wa", InlineAsmRegClass::PowerPC( PowerPCInlineAsmRegClass::cr | PowerPCInlineAsmRegClass::ctr @@ -778,9 +779,9 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg) => cx.type_i32(), InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => cx.type_i32(), InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => cx.type_f64(), - InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vreg) => { - cx.type_vector(cx.type_i32(), 4) - } + InlineAsmRegClass::PowerPC( + PowerPCInlineAsmRegClass::vreg | PowerPCInlineAsmRegClass::vsreg, + ) => cx.type_vector(cx.type_i32(), 4), InlineAsmRegClass::PowerPC( PowerPCInlineAsmRegClass::cr | PowerPCInlineAsmRegClass::ctr @@ -957,6 +958,13 @@ fn modifier_to_gcc( InlineAsmRegClass::LoongArch(_) => None, InlineAsmRegClass::Mips(_) => None, InlineAsmRegClass::Nvptx(_) => None, + InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::vsreg) => { + if modifier.is_none() { + Some('x') + } else { + modifier + } + } InlineAsmRegClass::PowerPC(_) => None, InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) | InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::freg) => None, From d96167fc9a3e8e412b9933f423ab993336e7ee85 Mon Sep 17 00:00:00 2001 From: Paul Murphy Date: Mon, 22 Sep 2025 09:28:21 -0500 Subject: [PATCH 057/108] Implement ppc/ppc64 preserves_flags option for inline asm Implemented preserves_flags on powerpc by making it do nothing. This prevents having two different ways to mark `cr0` as clobbered. clang and gcc alias `cr0` to `cc`. The gcc inline documentation does not state what this does on powerpc* targets, but inspection of the source shows it is equivalent to condition register field `cr0`, so it should not be added. --- src/asm.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/asm.rs b/src/asm.rs index 81cdfc68737f..f237861b1595 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -546,9 +546,16 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { } if !options.contains(InlineAsmOptions::PRESERVES_FLAGS) { - // TODO(@Commeownist): I'm not 100% sure this one clobber is sufficient - // on all architectures. For instance, what about FP stack? - extended_asm.add_clobber("cc"); + match asm_arch { + InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => { + // "cc" is cr0 on powerpc. + } + // TODO(@Commeownist): I'm not 100% sure this one clobber is sufficient + // on all architectures. For instance, what about FP stack? + _ => { + extended_asm.add_clobber("cc"); + } + } } if !options.contains(InlineAsmOptions::NOMEM) { extended_asm.add_clobber("memory"); From 28724dc5418a79597e2eb229f2b12a398cff08ee Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 14 Oct 2025 14:36:01 -0500 Subject: [PATCH 058/108] rustdoc: add regression test for #146216 --- tests/rustdoc-js/alias-path-distance-146214.js | 9 +++++++++ tests/rustdoc-js/alias-path-distance-146214.rs | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/rustdoc-js/alias-path-distance-146214.js create mode 100644 tests/rustdoc-js/alias-path-distance-146214.rs diff --git a/tests/rustdoc-js/alias-path-distance-146214.js b/tests/rustdoc-js/alias-path-distance-146214.js new file mode 100644 index 000000000000..30413bf9ee2b --- /dev/null +++ b/tests/rustdoc-js/alias-path-distance-146214.js @@ -0,0 +1,9 @@ +// exact-check + +// consider path distance for doc aliases +// regression test for + +const EXPECTED = { + 'query': 'Foo::zzz', + 'others': [{ 'path': 'alias_path_distance::Foo', 'name': 'baz' }], +}; diff --git a/tests/rustdoc-js/alias-path-distance-146214.rs b/tests/rustdoc-js/alias-path-distance-146214.rs new file mode 100644 index 000000000000..09d1068e3ede --- /dev/null +++ b/tests/rustdoc-js/alias-path-distance-146214.rs @@ -0,0 +1,14 @@ +#![crate_name = "alias_path_distance"] + +pub struct Foo; +pub struct Bar; + +impl Foo { + #[doc(alias = "zzz")] + pub fn baz() {} +} + +impl Bar { + #[doc(alias = "zzz")] + pub fn baz() {} +} From 7a6274373c8d945dcdfc7446c4d4e84b1ee29ff9 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 14 Oct 2025 14:36:48 -0500 Subject: [PATCH 059/108] rustdoc: add regression test for #140968 --- tests/rustdoc-js/alias-rank-lower-140968.js | 10 ++++++++++ tests/rustdoc-js/alias-rank-lower-140968.rs | 6 ++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/rustdoc-js/alias-rank-lower-140968.js create mode 100644 tests/rustdoc-js/alias-rank-lower-140968.rs diff --git a/tests/rustdoc-js/alias-rank-lower-140968.js b/tests/rustdoc-js/alias-rank-lower-140968.js new file mode 100644 index 000000000000..976fd314e429 --- /dev/null +++ b/tests/rustdoc-js/alias-rank-lower-140968.js @@ -0,0 +1,10 @@ +// rank doc aliases lower than exact matches +// regression test for + +const EXPECTED = { + 'query': 'Foo', + 'others': [ + { 'path': 'alias_rank_lower', 'name': 'Foo' }, + { 'path': 'alias_rank_lower', 'name': 'Bar' }, + ], +}; diff --git a/tests/rustdoc-js/alias-rank-lower-140968.rs b/tests/rustdoc-js/alias-rank-lower-140968.rs new file mode 100644 index 000000000000..1b0d2abfdcdc --- /dev/null +++ b/tests/rustdoc-js/alias-rank-lower-140968.rs @@ -0,0 +1,6 @@ +#![crate_name = "alias_rank_lower"] + +pub struct Foo; + +#[doc(alias = "Foo")] +pub struct Bar; From c5d02bbaf3715156f99d71248aa5925d7d2867b9 Mon Sep 17 00:00:00 2001 From: Diggory Blake Date: Sun, 6 Jul 2025 20:58:14 +0100 Subject: [PATCH 060/108] Restrict sysroot crate imports to those defined in this repo. It's common to import dependencies from the sysroot via `extern crate` rather than use an explicit cargo dependency, when it's necessary to use the same dependency version as used by rustc itself. However, this is dangerous for crates.io crates, since rustc may not pull in the dependency on some targets, or may pull in multiple versions. In both cases, the `extern crate` fails to resolve. To address this, re-export all such dependencies from the appropriate `rustc_*` crates, and use this alias from crates which would otherwise need to use `extern crate`. --- src/back/lto.rs | 1 + src/back/write.rs | 1 + src/consts.rs | 1 + src/gcc_util.rs | 2 +- src/lib.rs | 7 +------ 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/back/lto.rs b/src/back/lto.rs index d29bba2570f6..598bbe74007d 100644 --- a/src/back/lto.rs +++ b/src/back/lto.rs @@ -30,6 +30,7 @@ use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file}; use rustc_data_structures::memmap::Mmap; use rustc_errors::DiagCtxtHandle; +use rustc_log::tracing::info; use rustc_middle::bug; use rustc_middle::dep_graph::WorkProduct; use rustc_session::config::Lto; diff --git a/src/back/write.rs b/src/back/write.rs index 84bc70162719..8ba730e32502 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -5,6 +5,7 @@ use rustc_codegen_ssa::back::link::ensure_removed; use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig}; use rustc_codegen_ssa::{CompiledModule, ModuleCodegen}; use rustc_fs_util::link_or_copy; +use rustc_log::tracing::debug; use rustc_session::config::OutputType; use rustc_target::spec::SplitDebuginfo; diff --git a/src/consts.rs b/src/consts.rs index 7fe8fc122b3c..ec7d4b285a3f 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -8,6 +8,7 @@ use rustc_codegen_ssa::traits::{ use rustc_hir::attrs::Linkage; use rustc_hir::def::DefKind; use rustc_hir::def_id::LOCAL_CRATE; +use rustc_log::tracing::trace; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc_middle::mir::interpret::{ self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint, diff --git a/src/gcc_util.rs b/src/gcc_util.rs index 42ba40692b75..702704ddf136 100644 --- a/src/gcc_util.rs +++ b/src/gcc_util.rs @@ -1,8 +1,8 @@ #[cfg(feature = "master")] use gccjit::Context; use rustc_codegen_ssa::target_features; +use rustc_data_structures::smallvec::{SmallVec, smallvec}; use rustc_session::Session; -use smallvec::{SmallVec, smallvec}; fn gcc_features_by_flags(sess: &Session, features: &mut Vec) { target_features::retpoline_features_by_flags(sess, features); diff --git a/src/lib.rs b/src/lib.rs index ec7eab8489ab..e6d1dcccd442 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,12 +25,6 @@ #![deny(clippy::pattern_type_mismatch)] #![allow(clippy::needless_lifetimes, clippy::uninlined_format_args)] -// These crates are pulled from the sysroot because they are part of -// rustc's public API, so we need to ensure version compatibility. -extern crate smallvec; -#[macro_use] -extern crate tracing; - // The rustc crates we need extern crate rustc_abi; extern crate rustc_apfloat; @@ -44,6 +38,7 @@ extern crate rustc_hir; extern crate rustc_index; #[cfg(feature = "master")] extern crate rustc_interface; +extern crate rustc_log; extern crate rustc_macros; extern crate rustc_middle; extern crate rustc_session; From 07072812ca00473176be7df5a0ed18517c9c0889 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 14 Oct 2025 15:16:11 -0500 Subject: [PATCH 061/108] rustdoc: account for path distance in doc aliases --- src/librustdoc/html/static/js/search.js | 13 +++++++++++-- tests/rustdoc-js/alias-path-distance-146214.js | 18 ++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 0929d351463c..f187d8d70339 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -3933,16 +3933,25 @@ class DocSearch { * @returns {Promise} */ const handleAlias = async(name, alias, dist, index) => { + const item = nonnull(await this.getRow(alias, false)); + // space both is an alias for ::, + // and is also allowed to appear in doc alias names + const path_dist = name.includes(" ") || parsedQuery.elems.length === 0 ? + 0 : checkRowPath(parsedQuery.elems[0].pathWithoutLast, item); + // path distance exceeds max, omit alias from results + if (path_dist === null) { + return null; + } return { id: alias, dist, - path_dist: 0, + path_dist, index, alias: name, is_alias: true, elems: [], // only used in type-based queries returned: [], // only used in type-based queries - item: nonnull(await this.getRow(alias, false)), + item, }; }; /** diff --git a/tests/rustdoc-js/alias-path-distance-146214.js b/tests/rustdoc-js/alias-path-distance-146214.js index 30413bf9ee2b..722cf00de910 100644 --- a/tests/rustdoc-js/alias-path-distance-146214.js +++ b/tests/rustdoc-js/alias-path-distance-146214.js @@ -3,7 +3,17 @@ // consider path distance for doc aliases // regression test for -const EXPECTED = { - 'query': 'Foo::zzz', - 'others': [{ 'path': 'alias_path_distance::Foo', 'name': 'baz' }], -}; +const EXPECTED = [ + { + 'query': 'Foo::zzz', + 'others': [ + { 'path': 'alias_path_distance::Foo', 'name': 'baz' }, + ], + }, + { + 'query': '"Foo::zzz"', + 'others': [ + { 'path': 'alias_path_distance::Foo', 'name': 'baz' }, + ], + }, +]; From 936805e3dbb33fa424d7a9f4a456401b196674b1 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 10 Oct 2025 21:29:29 -0400 Subject: [PATCH 062/108] Fix ICE on offsetted ZST pointer A grep for `const_usize.*align` found the same code copied to rustc_codegen_gcc but I don't see other cases where we get this wrong. --- src/common.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common.rs b/src/common.rs index 28848ca61845..7c2969e58718 100644 --- a/src/common.rs +++ b/src/common.rs @@ -5,7 +5,7 @@ use rustc_codegen_ssa::traits::{ BaseTypeCodegenMethods, ConstCodegenMethods, MiscCodegenMethods, StaticCodegenMethods, }; use rustc_middle::mir::Mutability; -use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; +use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, PointerArithmetic, Scalar}; use rustc_middle::ty::layout::LayoutOf; use crate::context::CodegenCx; @@ -247,8 +247,8 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> { // This avoids generating a zero-sized constant value and actually needing a // real address at runtime. if alloc.inner().len() == 0 { - assert_eq!(offset.bytes(), 0); - let val = self.const_usize(alloc.inner().align.bytes()); + let val = alloc.inner().align.bytes().wrapping_add(offset.bytes()); + let val = self.const_usize(self.tcx.truncate_to_target_usize(val)); return if matches!(layout.primitive(), Pointer(_)) { self.context.new_cast(None, val, ty) } else { From 0f5c80a560ed77790ccfc5b06e488ff5e0403cab Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Mon, 20 Oct 2025 20:36:55 +0000 Subject: [PATCH 063/108] remove broken link --- src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1f342061ec59..71500ded0203 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,5 @@ /* * TODO(antoyo): implement equality in libgccjit based on https://zpz.github.io/blog/overloading-equality-operator-in-cpp-class-hierarchy/ (for type equality?) - * TODO(antoyo): support #[inline] attributes. - * TODO(antoyo): support LTO (gcc's equivalent to Full LTO is -flto -flto-partition=one β€” https://documentation.suse.com/sbp/all/html/SBP-GCC-10/index.html). * For Thin LTO, this might be helpful: // cspell:disable-next-line * In gcc 4.6 -fwhopr was removed and became default with -flto. The non-whopr path can still be executed via -flto-partition=none. From 77a97960514f6d24573e95abf1e02e7337abc193 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 25 Oct 2025 20:10:39 -0400 Subject: [PATCH 064/108] Fix RAM usage by splitting deeply nested expressions --- src/builder.rs | 61 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index 5657620879ca..481b12d842f4 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -668,32 +668,38 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { } fn add(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_add(a, b) + self.assign_to_var(self.gcc_add(a, b)) } fn fadd(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - a + b + self.assign_to_var(a + b) } // TODO(antoyo): should we also override the `unchecked_` versions? fn sub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_sub(a, b) + self.assign_to_var(self.gcc_sub(a, b)) } fn fsub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - a - b + self.assign_to_var(a - b) } fn mul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_mul(a, b) + self.assign_to_var(self.gcc_mul(a, b)) } fn fmul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.cx.context.new_binary_op(self.location, BinaryOp::Mult, a.get_type(), a, b) + self.assign_to_var(self.cx.context.new_binary_op( + self.location, + BinaryOp::Mult, + a.get_type(), + a, + b, + )) } fn udiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_udiv(a, b) + self.assign_to_var(self.gcc_udiv(a, b)) } fn exactudiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { @@ -702,11 +708,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { let a = self.gcc_int_cast(a, a_type); let b_type = b.get_type().to_unsigned(self); let b = self.gcc_int_cast(b, b_type); - self.gcc_udiv(a, b) + self.assign_to_var(self.gcc_udiv(a, b)) } fn sdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_sdiv(a, b) + self.assign_to_var(self.gcc_sdiv(a, b)) } fn exactsdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { @@ -715,19 +721,19 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { // should be the same. let typ = a.get_type().to_signed(self); let b = self.gcc_int_cast(b, typ); - self.gcc_sdiv(a, b) + self.assign_to_var(self.gcc_sdiv(a, b)) } fn fdiv(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - a / b + self.assign_to_var(a / b) } fn urem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_urem(a, b) + self.assign_to_var(self.gcc_urem(a, b)) } fn srem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - self.gcc_srem(a, b) + self.assign_to_var(self.gcc_srem(a, b)) } fn frem(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { @@ -865,22 +871,26 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { fn fadd_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - set_rvalue_location(self, lhs + rhs) + let result = set_rvalue_location(self, lhs + rhs); + self.assign_to_var(result) } fn fsub_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - set_rvalue_location(self, lhs - rhs) + let result = set_rvalue_location(self, lhs - rhs); + self.assign_to_var(result) } fn fmul_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - set_rvalue_location(self, lhs * rhs) + let result = set_rvalue_location(self, lhs * rhs); + self.assign_to_var(result) } fn fdiv_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - set_rvalue_location(self, lhs / rhs) + let result = set_rvalue_location(self, lhs / rhs); + self.assign_to_var(result) } fn frem_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { @@ -892,22 +902,22 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { fn fadd_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - lhs + rhs + self.assign_to_var(lhs + rhs) } fn fsub_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - lhs - rhs + self.assign_to_var(lhs - rhs) } fn fmul_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - lhs * rhs + self.assign_to_var(lhs * rhs) } fn fdiv_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { // NOTE: it seems like we cannot enable fast-mode for a single operation in GCC. - lhs / rhs + self.assign_to_var(lhs / rhs) } fn frem_algebraic(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> { @@ -2409,6 +2419,15 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { let res = then_vals | else_vals; self.bitcast_if_needed(res, result_type) } + + // GCC doesn't like deeply nested expressions. + // By assigning intermediate expressions to a variable, this allow us to avoid deeply nested + // expressions and GCC will use much less RAM. + fn assign_to_var(&self, value: RValue<'gcc>) -> RValue<'gcc> { + let var = self.current_func().new_local(self.location, value.get_type(), "opResult"); + self.llbb().add_assignment(self.location, var, value); + var.to_rvalue() + } } fn difference_or_zero<'gcc>( From f3ab60b1d0b6730c025d0ed57bc78524d0359b07 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sun, 26 Oct 2025 19:34:27 -0400 Subject: [PATCH 065/108] Implement reg vector type --- src/abi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/abi.rs b/src/abi.rs index 0b359f1c5c81..93862a6b00ba 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -88,7 +88,7 @@ impl GccType for Reg { 64 => cx.type_f64(), _ => bug!("unsupported float: {:?}", self), }, - RegKind::Vector => unimplemented!(), //cx.type_vector(cx.type_i8(), self.size.bytes()), + RegKind::Vector => cx.type_vector(cx.type_i8(), self.size.bytes()), } } } From 36c35d7ae499ec1d7deee5fc9d8645cf400ba0e2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 28 Oct 2025 15:56:02 +0100 Subject: [PATCH 066/108] Regenerate intrinsics --- src/intrinsic/archs.rs | 156 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) diff --git a/src/intrinsic/archs.rs b/src/intrinsic/archs.rs index d1b2a93243d2..c51bcbcedd67 100644 --- a/src/intrinsic/archs.rs +++ b/src/intrinsic/archs.rs @@ -85,12 +85,41 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { fn amdgcn(name: &str, full_name: &str) -> &'static str { match name { // amdgcn + "add.max.i32" => "__builtin_amdgcn_add_max_i32", + "add.max.u32" => "__builtin_amdgcn_add_max_u32", + "add.min.i32" => "__builtin_amdgcn_add_min_i32", + "add.min.u32" => "__builtin_amdgcn_add_min_u32", "alignbyte" => "__builtin_amdgcn_alignbyte", "ashr.pk.i8.i32" => "__builtin_amdgcn_ashr_pk_i8_i32", "ashr.pk.u8.i32" => "__builtin_amdgcn_ashr_pk_u8_i32", "buffer.wbinvl1" => "__builtin_amdgcn_buffer_wbinvl1", "buffer.wbinvl1.sc" => "__builtin_amdgcn_buffer_wbinvl1_sc", "buffer.wbinvl1.vol" => "__builtin_amdgcn_buffer_wbinvl1_vol", + "cluster.id.x" => "__builtin_amdgcn_cluster_id_x", + "cluster.id.y" => "__builtin_amdgcn_cluster_id_y", + "cluster.id.z" => "__builtin_amdgcn_cluster_id_z", + "cluster.load.async.to.lds.b128" => { + "__builtin_amdgcn_cluster_load_async_to_lds_b128" + } + "cluster.load.async.to.lds.b32" => { + "__builtin_amdgcn_cluster_load_async_to_lds_b32" + } + "cluster.load.async.to.lds.b64" => { + "__builtin_amdgcn_cluster_load_async_to_lds_b64" + } + "cluster.load.async.to.lds.b8" => { + "__builtin_amdgcn_cluster_load_async_to_lds_b8" + } + "cluster.workgroup.flat.id" => "__builtin_amdgcn_cluster_workgroup_flat_id", + "cluster.workgroup.id.x" => "__builtin_amdgcn_cluster_workgroup_id_x", + "cluster.workgroup.id.y" => "__builtin_amdgcn_cluster_workgroup_id_y", + "cluster.workgroup.id.z" => "__builtin_amdgcn_cluster_workgroup_id_z", + "cluster.workgroup.max.flat.id" => { + "__builtin_amdgcn_cluster_workgroup_max_flat_id" + } + "cluster.workgroup.max.id.x" => "__builtin_amdgcn_cluster_workgroup_max_id_x", + "cluster.workgroup.max.id.y" => "__builtin_amdgcn_cluster_workgroup_max_id_y", + "cluster.workgroup.max.id.z" => "__builtin_amdgcn_cluster_workgroup_max_id_z", "cubeid" => "__builtin_amdgcn_cubeid", "cubema" => "__builtin_amdgcn_cubema", "cubesc" => "__builtin_amdgcn_cubesc", @@ -101,18 +130,36 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "cvt.f32.fp8" => "__builtin_amdgcn_cvt_f32_fp8", "cvt.f32.fp8.e5m3" => "__builtin_amdgcn_cvt_f32_fp8_e5m3", "cvt.off.f32.i4" => "__builtin_amdgcn_cvt_off_f32_i4", + "cvt.pk.bf8.f16" => "__builtin_amdgcn_cvt_pk_bf8_f16", "cvt.pk.bf8.f32" => "__builtin_amdgcn_cvt_pk_bf8_f32", "cvt.pk.f16.bf8" => "__builtin_amdgcn_cvt_pk_f16_bf8", "cvt.pk.f16.fp8" => "__builtin_amdgcn_cvt_pk_f16_fp8", "cvt.pk.f32.bf8" => "__builtin_amdgcn_cvt_pk_f32_bf8", "cvt.pk.f32.fp8" => "__builtin_amdgcn_cvt_pk_f32_fp8", + "cvt.pk.fp8.f16" => "__builtin_amdgcn_cvt_pk_fp8_f16", "cvt.pk.fp8.f32" => "__builtin_amdgcn_cvt_pk_fp8_f32", + "cvt.pk.fp8.f32.e5m3" => "__builtin_amdgcn_cvt_pk_fp8_f32_e5m3", "cvt.pk.i16" => "__builtin_amdgcn_cvt_pk_i16", "cvt.pk.u16" => "__builtin_amdgcn_cvt_pk_u16", "cvt.pk.u8.f32" => "__builtin_amdgcn_cvt_pk_u8_f32", "cvt.pknorm.i16" => "__builtin_amdgcn_cvt_pknorm_i16", "cvt.pknorm.u16" => "__builtin_amdgcn_cvt_pknorm_u16", "cvt.pkrtz" => "__builtin_amdgcn_cvt_pkrtz", + "cvt.scale.pk16.bf16.bf6" => "__builtin_amdgcn_cvt_scale_pk16_bf16_bf6", + "cvt.scale.pk16.bf16.fp6" => "__builtin_amdgcn_cvt_scale_pk16_bf16_fp6", + "cvt.scale.pk16.f16.bf6" => "__builtin_amdgcn_cvt_scale_pk16_f16_bf6", + "cvt.scale.pk16.f16.fp6" => "__builtin_amdgcn_cvt_scale_pk16_f16_fp6", + "cvt.scale.pk16.f32.bf6" => "__builtin_amdgcn_cvt_scale_pk16_f32_bf6", + "cvt.scale.pk16.f32.fp6" => "__builtin_amdgcn_cvt_scale_pk16_f32_fp6", + "cvt.scale.pk8.bf16.bf8" => "__builtin_amdgcn_cvt_scale_pk8_bf16_bf8", + "cvt.scale.pk8.bf16.fp4" => "__builtin_amdgcn_cvt_scale_pk8_bf16_fp4", + "cvt.scale.pk8.bf16.fp8" => "__builtin_amdgcn_cvt_scale_pk8_bf16_fp8", + "cvt.scale.pk8.f16.bf8" => "__builtin_amdgcn_cvt_scale_pk8_f16_bf8", + "cvt.scale.pk8.f16.fp4" => "__builtin_amdgcn_cvt_scale_pk8_f16_fp4", + "cvt.scale.pk8.f16.fp8" => "__builtin_amdgcn_cvt_scale_pk8_f16_fp8", + "cvt.scale.pk8.f32.bf8" => "__builtin_amdgcn_cvt_scale_pk8_f32_bf8", + "cvt.scale.pk8.f32.fp4" => "__builtin_amdgcn_cvt_scale_pk8_f32_fp4", + "cvt.scale.pk8.f32.fp8" => "__builtin_amdgcn_cvt_scale_pk8_f32_fp8", "cvt.scalef32.2xpk16.bf6.f32" => "__builtin_amdgcn_cvt_scalef32_2xpk16_bf6_f32", "cvt.scalef32.2xpk16.fp6.f32" => "__builtin_amdgcn_cvt_scalef32_2xpk16_fp6_f32", "cvt.scalef32.f16.bf8" => "__builtin_amdgcn_cvt_scalef32_f16_bf8", @@ -137,6 +184,12 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "cvt.scalef32.pk.fp8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_bf16", "cvt.scalef32.pk.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_f16", "cvt.scalef32.pk.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_pk_fp8_f32", + "cvt.scalef32.pk16.bf6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk16_bf6_bf16", + "cvt.scalef32.pk16.bf6.f16" => "__builtin_amdgcn_cvt_scalef32_pk16_bf6_f16", + "cvt.scalef32.pk16.bf6.f32" => "__builtin_amdgcn_cvt_scalef32_pk16_bf6_f32", + "cvt.scalef32.pk16.fp6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk16_fp6_bf16", + "cvt.scalef32.pk16.fp6.f16" => "__builtin_amdgcn_cvt_scalef32_pk16_fp6_f16", + "cvt.scalef32.pk16.fp6.f32" => "__builtin_amdgcn_cvt_scalef32_pk16_fp6_f32", "cvt.scalef32.pk32.bf16.bf6" => "__builtin_amdgcn_cvt_scalef32_pk32_bf16_bf6", "cvt.scalef32.pk32.bf16.fp6" => "__builtin_amdgcn_cvt_scalef32_pk32_bf16_fp6", "cvt.scalef32.pk32.bf6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk32_bf6_bf16", @@ -147,6 +200,15 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "cvt.scalef32.pk32.f32.fp6" => "__builtin_amdgcn_cvt_scalef32_pk32_f32_fp6", "cvt.scalef32.pk32.fp6.bf16" => "__builtin_amdgcn_cvt_scalef32_pk32_fp6_bf16", "cvt.scalef32.pk32.fp6.f16" => "__builtin_amdgcn_cvt_scalef32_pk32_fp6_f16", + "cvt.scalef32.pk8.bf8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk8_bf8_bf16", + "cvt.scalef32.pk8.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_pk8_bf8_f16", + "cvt.scalef32.pk8.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_pk8_bf8_f32", + "cvt.scalef32.pk8.fp4.bf16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp4_bf16", + "cvt.scalef32.pk8.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp4_f16", + "cvt.scalef32.pk8.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_pk8_fp4_f32", + "cvt.scalef32.pk8.fp8.bf16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp8_bf16", + "cvt.scalef32.pk8.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_pk8_fp8_f16", + "cvt.scalef32.pk8.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_pk8_fp8_f32", "cvt.scalef32.sr.bf8.bf16" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_bf16", "cvt.scalef32.sr.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_f16", "cvt.scalef32.sr.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_bf8_f32", @@ -156,6 +218,24 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "cvt.scalef32.sr.pk.fp4.bf16" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_bf16", "cvt.scalef32.sr.pk.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_f16", "cvt.scalef32.sr.pk.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk_fp4_f32", + "cvt.scalef32.sr.pk16.bf6.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_bf6_bf16" + } + "cvt.scalef32.sr.pk16.bf6.f16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_bf6_f16" + } + "cvt.scalef32.sr.pk16.bf6.f32" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_bf6_f32" + } + "cvt.scalef32.sr.pk16.fp6.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_fp6_bf16" + } + "cvt.scalef32.sr.pk16.fp6.f16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_fp6_f16" + } + "cvt.scalef32.sr.pk16.fp6.f32" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk16_fp6_f32" + } "cvt.scalef32.sr.pk32.bf6.bf16" => { "__builtin_amdgcn_cvt_scalef32_sr_pk32_bf6_bf16" } @@ -174,10 +254,30 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "cvt.scalef32.sr.pk32.fp6.f32" => { "__builtin_amdgcn_cvt_scalef32_sr_pk32_fp6_f32" } + "cvt.scalef32.sr.pk8.bf8.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_bf16" + } + "cvt.scalef32.sr.pk8.bf8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_f16", + "cvt.scalef32.sr.pk8.bf8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_bf8_f32", + "cvt.scalef32.sr.pk8.fp4.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_bf16" + } + "cvt.scalef32.sr.pk8.fp4.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_f16", + "cvt.scalef32.sr.pk8.fp4.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp4_f32", + "cvt.scalef32.sr.pk8.fp8.bf16" => { + "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_bf16" + } + "cvt.scalef32.sr.pk8.fp8.f16" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_f16", + "cvt.scalef32.sr.pk8.fp8.f32" => "__builtin_amdgcn_cvt_scalef32_sr_pk8_fp8_f32", "cvt.sr.bf16.f32" => "__builtin_amdgcn_cvt_sr_bf16_f32", + "cvt.sr.bf8.f16" => "__builtin_amdgcn_cvt_sr_bf8_f16", "cvt.sr.bf8.f32" => "__builtin_amdgcn_cvt_sr_bf8_f32", "cvt.sr.f16.f32" => "__builtin_amdgcn_cvt_sr_f16_f32", + "cvt.sr.fp8.f16" => "__builtin_amdgcn_cvt_sr_fp8_f16", "cvt.sr.fp8.f32" => "__builtin_amdgcn_cvt_sr_fp8_f32", + "cvt.sr.fp8.f32.e5m3" => "__builtin_amdgcn_cvt_sr_fp8_f32_e5m3", + "cvt.sr.pk.bf16.f32" => "__builtin_amdgcn_cvt_sr_pk_bf16_f32", + "cvt.sr.pk.f16.f32" => "__builtin_amdgcn_cvt_sr_pk_f16_f32", "dispatch.id" => "__builtin_amdgcn_dispatch_id", "dot4.f32.bf8.bf8" => "__builtin_amdgcn_dot4_f32_bf8_bf8", "dot4.f32.bf8.fp8" => "__builtin_amdgcn_dot4_f32_bf8_fp8", @@ -297,8 +397,20 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "mqsad.u32.u8" => "__builtin_amdgcn_mqsad_u32_u8", "msad.u8" => "__builtin_amdgcn_msad_u8", "perm" => "__builtin_amdgcn_perm", + "perm.pk16.b4.u4" => "__builtin_amdgcn_perm_pk16_b4_u4", + "perm.pk16.b6.u4" => "__builtin_amdgcn_perm_pk16_b6_u4", + "perm.pk16.b8.u4" => "__builtin_amdgcn_perm_pk16_b8_u4", + "permlane.bcast" => "__builtin_amdgcn_permlane_bcast", + "permlane.down" => "__builtin_amdgcn_permlane_down", + "permlane.idx.gen" => "__builtin_amdgcn_permlane_idx_gen", + "permlane.up" => "__builtin_amdgcn_permlane_up", + "permlane.xor" => "__builtin_amdgcn_permlane_xor", "permlane16.var" => "__builtin_amdgcn_permlane16_var", "permlanex16.var" => "__builtin_amdgcn_permlanex16_var", + "pk.add.max.i16" => "__builtin_amdgcn_pk_add_max_i16", + "pk.add.max.u16" => "__builtin_amdgcn_pk_add_max_u16", + "pk.add.min.i16" => "__builtin_amdgcn_pk_add_min_i16", + "pk.add.min.u16" => "__builtin_amdgcn_pk_add_min_u16", "prng.b32" => "__builtin_amdgcn_prng_b32", "qsad.pk.u16.u8" => "__builtin_amdgcn_qsad_pk_u16_u8", "queue.ptr" => "__builtin_amdgcn_queue_ptr", @@ -306,11 +418,15 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "rcp.legacy" => "__builtin_amdgcn_rcp_legacy", "rsq.legacy" => "__builtin_amdgcn_rsq_legacy", "s.barrier" => "__builtin_amdgcn_s_barrier", + "s.barrier.init" => "__builtin_amdgcn_s_barrier_init", + "s.barrier.join" => "__builtin_amdgcn_s_barrier_join", + "s.barrier.leave" => "__builtin_amdgcn_s_barrier_leave", "s.barrier.signal" => "__builtin_amdgcn_s_barrier_signal", "s.barrier.signal.isfirst" => "__builtin_amdgcn_s_barrier_signal_isfirst", "s.barrier.signal.var" => "__builtin_amdgcn_s_barrier_signal_var", "s.barrier.wait" => "__builtin_amdgcn_s_barrier_wait", "s.buffer.prefetch.data" => "__builtin_amdgcn_s_buffer_prefetch_data", + "s.cluster.barrier" => "__builtin_amdgcn_s_cluster_barrier", "s.dcache.inv" => "__builtin_amdgcn_s_dcache_inv", "s.dcache.inv.vol" => "__builtin_amdgcn_s_dcache_inv_vol", "s.dcache.wb" => "__builtin_amdgcn_s_dcache_wb", @@ -1900,6 +2016,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vfneg.hf.128B" => "__builtin_HEXAGON_V6_vfneg_hf_128B", "V6.vfneg.sf" => "__builtin_HEXAGON_V6_vfneg_sf", "V6.vfneg.sf.128B" => "__builtin_HEXAGON_V6_vfneg_sf_128B", + "V6.vgather.vscattermh" => "__builtin_HEXAGON_V6_vgather_vscattermh", + "V6.vgather.vscattermh.128B" => "__builtin_HEXAGON_V6_vgather_vscattermh_128B", "V6.vgathermh" => "__builtin_HEXAGON_V6_vgathermh", "V6.vgathermh.128B" => "__builtin_HEXAGON_V6_vgathermh_128B", "V6.vgathermhq" => "__builtin_HEXAGON_V6_vgathermhq", @@ -2382,6 +2500,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vsub.hf.f8.128B" => "__builtin_HEXAGON_V6_vsub_hf_f8_128B", "V6.vsub.hf.hf" => "__builtin_HEXAGON_V6_vsub_hf_hf", "V6.vsub.hf.hf.128B" => "__builtin_HEXAGON_V6_vsub_hf_hf_128B", + "V6.vsub.hf.mix" => "__builtin_HEXAGON_V6_vsub_hf_mix", + "V6.vsub.hf.mix.128B" => "__builtin_HEXAGON_V6_vsub_hf_mix_128B", "V6.vsub.qf16" => "__builtin_HEXAGON_V6_vsub_qf16", "V6.vsub.qf16.128B" => "__builtin_HEXAGON_V6_vsub_qf16_128B", "V6.vsub.qf16.mix" => "__builtin_HEXAGON_V6_vsub_qf16_mix", @@ -2396,6 +2516,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "V6.vsub.sf.bf.128B" => "__builtin_HEXAGON_V6_vsub_sf_bf_128B", "V6.vsub.sf.hf" => "__builtin_HEXAGON_V6_vsub_sf_hf", "V6.vsub.sf.hf.128B" => "__builtin_HEXAGON_V6_vsub_sf_hf_128B", + "V6.vsub.sf.mix" => "__builtin_HEXAGON_V6_vsub_sf_mix", + "V6.vsub.sf.mix.128B" => "__builtin_HEXAGON_V6_vsub_sf_mix_128B", "V6.vsub.sf.sf" => "__builtin_HEXAGON_V6_vsub_sf_sf", "V6.vsub.sf.sf.128B" => "__builtin_HEXAGON_V6_vsub_sf_sf_128B", "V6.vsubb" => "__builtin_HEXAGON_V6_vsubb", @@ -4883,6 +5005,26 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "f2ull.rp.ftz" => "__nvvm_f2ull_rp_ftz", "f2ull.rz" => "__nvvm_f2ull_rz", "f2ull.rz.ftz" => "__nvvm_f2ull_rz_ftz", + "f32x4.to.e2m1x4.rs.relu.satfinite" => { + "__nvvm_f32x4_to_e2m1x4_rs_relu_satfinite" + } + "f32x4.to.e2m1x4.rs.satfinite" => "__nvvm_f32x4_to_e2m1x4_rs_satfinite", + "f32x4.to.e2m3x4.rs.relu.satfinite" => { + "__nvvm_f32x4_to_e2m3x4_rs_relu_satfinite" + } + "f32x4.to.e2m3x4.rs.satfinite" => "__nvvm_f32x4_to_e2m3x4_rs_satfinite", + "f32x4.to.e3m2x4.rs.relu.satfinite" => { + "__nvvm_f32x4_to_e3m2x4_rs_relu_satfinite" + } + "f32x4.to.e3m2x4.rs.satfinite" => "__nvvm_f32x4_to_e3m2x4_rs_satfinite", + "f32x4.to.e4m3x4.rs.relu.satfinite" => { + "__nvvm_f32x4_to_e4m3x4_rs_relu_satfinite" + } + "f32x4.to.e4m3x4.rs.satfinite" => "__nvvm_f32x4_to_e4m3x4_rs_satfinite", + "f32x4.to.e5m2x4.rs.relu.satfinite" => { + "__nvvm_f32x4_to_e5m2x4_rs_relu_satfinite" + } + "f32x4.to.e5m2x4.rs.satfinite" => "__nvvm_f32x4_to_e5m2x4_rs_satfinite", "fabs.d" => "__nvvm_fabs_d", "fabs.f" => "__nvvm_fabs_f", "fabs.ftz.f" => "__nvvm_fabs_ftz_f", @@ -4902,10 +5044,18 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "ff.to.ue8m0x2.rz.satfinite" => "__nvvm_ff_to_ue8m0x2_rz_satfinite", "ff2bf16x2.rn" => "__nvvm_ff2bf16x2_rn", "ff2bf16x2.rn.relu" => "__nvvm_ff2bf16x2_rn_relu", + "ff2bf16x2.rs" => "__nvvm_ff2bf16x2_rs", + "ff2bf16x2.rs.relu" => "__nvvm_ff2bf16x2_rs_relu", + "ff2bf16x2.rs.relu.satfinite" => "__nvvm_ff2bf16x2_rs_relu_satfinite", + "ff2bf16x2.rs.satfinite" => "__nvvm_ff2bf16x2_rs_satfinite", "ff2bf16x2.rz" => "__nvvm_ff2bf16x2_rz", "ff2bf16x2.rz.relu" => "__nvvm_ff2bf16x2_rz_relu", "ff2f16x2.rn" => "__nvvm_ff2f16x2_rn", "ff2f16x2.rn.relu" => "__nvvm_ff2f16x2_rn_relu", + "ff2f16x2.rs" => "__nvvm_ff2f16x2_rs", + "ff2f16x2.rs.relu" => "__nvvm_ff2f16x2_rs_relu", + "ff2f16x2.rs.relu.satfinite" => "__nvvm_ff2f16x2_rs_relu_satfinite", + "ff2f16x2.rs.satfinite" => "__nvvm_ff2f16x2_rs_satfinite", "ff2f16x2.rz" => "__nvvm_ff2f16x2_rz", "ff2f16x2.rz.relu" => "__nvvm_ff2f16x2_rz_relu", "floor.d" => "__nvvm_floor_d", @@ -5129,6 +5279,7 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "read.ptx.sreg.envreg8" => "__nvvm_read_ptx_sreg_envreg8", "read.ptx.sreg.envreg9" => "__nvvm_read_ptx_sreg_envreg9", "read.ptx.sreg.globaltimer" => "__nvvm_read_ptx_sreg_globaltimer", + "read.ptx.sreg.globaltimer.lo" => "__nvvm_read_ptx_sreg_globaltimer_lo", "read.ptx.sreg.gridid" => "__nvvm_read_ptx_sreg_gridid", // [DUPLICATE]: "read.ptx.sreg.gridid" => "__nvvm_read_ptx_sreg_", "read.ptx.sreg.laneid" => "__nvvm_read_ptx_sreg_laneid", @@ -5803,6 +5954,8 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "altivec.vupklsw" => "__builtin_altivec_vupklsw", "bcdadd" => "__builtin_ppc_bcdadd", "bcdadd.p" => "__builtin_ppc_bcdadd_p", + "bcdcopysign" => "__builtin_ppc_bcdcopysign", + "bcdsetsign" => "__builtin_ppc_bcdsetsign", "bcdsub" => "__builtin_ppc_bcdsub", "bcdsub.p" => "__builtin_ppc_bcdsub_p", "bpermd" => "__builtin_bpermd", @@ -6160,6 +6313,9 @@ fn map_arch_intrinsic(full_name: &str) -> &'static str { "aes64im" => "__builtin_riscv_aes64im", "aes64ks1i" => "__builtin_riscv_aes64ks1i", "aes64ks2" => "__builtin_riscv_aes64ks2", + "mips.ehb" => "__builtin_riscv_mips_ehb", + "mips.ihb" => "__builtin_riscv_mips_ihb", + "mips.pause" => "__builtin_riscv_mips_pause", "sha512sig0" => "__builtin_riscv_sha512sig0", "sha512sig0h" => "__builtin_riscv_sha512sig0h", "sha512sig0l" => "__builtin_riscv_sha512sig0l", From 02608ff7b568dadcc844a6a687f168a21c5d48b5 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 1 Nov 2025 11:21:17 -0400 Subject: [PATCH 067/108] Update to nightly-2025-11-01 --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index ec625481add1..b7765a0d591f 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-09-30" +channel = "nightly-2025-11-01" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] From cd5a50d5088c4a86610f3a1bbde15c536b26b12f Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 1 Nov 2025 11:31:16 -0400 Subject: [PATCH 068/108] Fix mini_core tests --- example/mini_core.rs | 24 +++++++++++++++++++++--- example/mini_core_hello_world.rs | 10 +++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/example/mini_core.rs b/example/mini_core.rs index 5afedf9d4017..64a5b431bd07 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -603,7 +603,7 @@ impl, U: ?Sized, A: Allocator> CoerceUnsized> fo impl Box { pub fn new(val: T) -> Box { unsafe { - let size = intrinsics::size_of::(); + let size = size_of::(); let ptr = libc::malloc(size); intrinsics::copy(&val as *const T as *const u8, ptr, size); Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, Global) @@ -657,11 +657,11 @@ pub mod intrinsics { #[rustc_intrinsic] pub fn abort() -> !; #[rustc_intrinsic] - pub fn size_of() -> usize; + pub const fn size_of() -> usize; #[rustc_intrinsic] pub unsafe fn size_of_val(val: *const T) -> usize; #[rustc_intrinsic] - pub fn align_of() -> usize; + pub const fn align_of() -> usize; #[rustc_intrinsic] pub unsafe fn align_of_val(val: *const T) -> usize; #[rustc_intrinsic] @@ -699,6 +699,24 @@ pub mod libc { } } +pub const fn size_of() -> usize { + ::SIZE +} + +pub const fn align_of() -> usize { + ::ALIGN +} + +trait SizedTypeProperties: Sized { + #[lang = "mem_size_const"] + const SIZE: usize = intrinsics::size_of::(); + + #[lang = "mem_align_const"] + const ALIGN: usize = intrinsics::align_of::(); +} + +impl SizedTypeProperties for T {} + #[lang = "index"] pub trait Index { type Output: ?Sized; diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 1e601d42413c..45154ff072f4 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -90,8 +90,8 @@ fn start( ) -> isize { if argc == 3 { unsafe { puts(*argv); } - unsafe { puts(*((argv as usize + intrinsics::size_of::<*const u8>()) as *const *const u8)); } - unsafe { puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const u8)); } + unsafe { puts(*((argv as usize + size_of::<*const u8>()) as *const *const u8)); } + unsafe { puts(*((argv as usize + 2 * size_of::<*const u8>()) as *const *const u8)); } } main().report(); @@ -154,7 +154,7 @@ fn main() { let slice = &[0, 1] as &[i32]; let slice_ptr = slice as *const [i32] as *const i32; - let align = intrinsics::align_of::<*const i32>(); + let align = align_of::<*const i32>(); assert_eq!(slice_ptr as usize % align, 0); //return; @@ -195,8 +195,8 @@ fn main() { assert_eq!(intrinsics::size_of_val(a) as u8, 8); assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4); - assert_eq!(intrinsics::align_of::() as u8, 2); - assert_eq!(intrinsics::align_of_val(&a) as u8, intrinsics::align_of::<&str>() as u8); + assert_eq!(align_of::() as u8, 2); + assert_eq!(intrinsics::align_of_val(&a) as u8, align_of::<&str>() as u8); let u8_needs_drop = const { intrinsics::needs_drop::() }; assert!(!u8_needs_drop); From 76a7e795f2545f82a8c3e91d16e4acc10724c308 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 4 Nov 2025 08:51:47 -0500 Subject: [PATCH 069/108] Update to nightly-2025-11-04 --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index b7765a0d591f..9813bbea00c4 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2025-11-01" +channel = "nightly-2025-11-04" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] From dcc2f33c672a9803ff36e4ca36c6012695d82597 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 4 Nov 2025 16:22:37 +0100 Subject: [PATCH 070/108] Update GCC submodule --- src/gcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gcc b/src/gcc index 4e995bd73c44..28b84db392ac 160000 --- a/src/gcc +++ b/src/gcc @@ -1 +1 @@ -Subproject commit 4e995bd73c4490edfe5080ec6014d63aa9abed5f +Subproject commit 28b84db392ac0a572f1a2a2a1317aa5f2bc742cb From 883b2dc4204236841c70ee982ee4049ad91c5fde Mon Sep 17 00:00:00 2001 From: yukang Date: Thu, 6 Nov 2025 08:48:09 +0800 Subject: [PATCH 071/108] Provide more general note for borrowing outside of closure --- .../src/diagnostics/region_errors.rs | 11 +++++++++++ .../borrowed-data-escapes-closure-148392.rs | 13 +++++++++++++ .../borrowed-data-escapes-closure-148392.stderr | 14 ++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 tests/ui/borrowck/borrowed-data-escapes-closure-148392.rs create mode 100644 tests/ui/borrowck/borrowed-data-escapes-closure-148392.stderr diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index bad5f03e4127..05826bea66bf 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -690,6 +690,17 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { ); diag.span_label(*span, format!("`{fr_name}` escapes the {escapes_from} body here")); + } else { + diag.span_label( + *span, + format!("a temporary borrow escapes the {escapes_from} body here"), + ); + if let Some((Some(outlived_name), _)) = outlived_fr_name_and_span { + diag.help(format!( + "`{outlived_name}` is declared outside the {escapes_from}, \ + so any data borrowed inside the {escapes_from} cannot be stored into it" + )); + } } // Only show an extra note if we can find an 'error region' for both of the region diff --git a/tests/ui/borrowck/borrowed-data-escapes-closure-148392.rs b/tests/ui/borrowck/borrowed-data-escapes-closure-148392.rs new file mode 100644 index 000000000000..c682e221c009 --- /dev/null +++ b/tests/ui/borrowck/borrowed-data-escapes-closure-148392.rs @@ -0,0 +1,13 @@ +// Test for issue #148392 +// Provides helpful explanations even for anonymous references +// under the scenario of escaping closure + +#![allow(unused)] + +fn main() { + let a = 0; + let mut b = None; + move || { + b = Some(&a); //~ ERROR borrowed data escapes outside of closure + }; +} diff --git a/tests/ui/borrowck/borrowed-data-escapes-closure-148392.stderr b/tests/ui/borrowck/borrowed-data-escapes-closure-148392.stderr new file mode 100644 index 000000000000..a3e09659dd64 --- /dev/null +++ b/tests/ui/borrowck/borrowed-data-escapes-closure-148392.stderr @@ -0,0 +1,14 @@ +error[E0521]: borrowed data escapes outside of closure + --> $DIR/borrowed-data-escapes-closure-148392.rs:11:9 + | +LL | let mut b = None; + | ----- `b` declared here, outside of the closure body +LL | move || { +LL | b = Some(&a); + | ^^^^^^^^^^^^ a temporary borrow escapes the closure body here + | + = help: `b` is declared outside the closure, so any data borrowed inside the closure cannot be stored into it + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0521`. From b032fac34e5be72aa02748eadd4e8d8917a7e758 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 6 Nov 2025 18:07:49 +0100 Subject: [PATCH 072/108] stabilize duration_from_nanos_u128 --- library/core/src/time.rs | 7 +++---- library/coretests/tests/lib.rs | 1 - src/tools/miri/src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/library/core/src/time.rs b/library/core/src/time.rs index f721fcd6156c..51a01545f5cf 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -317,7 +317,6 @@ impl Duration { /// # Examples /// /// ``` - /// #![feature(duration_from_nanos_u128)] /// use std::time::Duration; /// /// let nanos = 10_u128.pow(24) + 321; @@ -326,12 +325,12 @@ impl Duration { /// assert_eq!(10_u64.pow(15), duration.as_secs()); /// assert_eq!(321, duration.subsec_nanos()); /// ``` - #[unstable(feature = "duration_from_nanos_u128", issue = "139201")] - // This is necessary because of const `try_from`, but can be removed if a trait-free impl is used instead - #[rustc_const_unstable(feature = "duration_from_nanos_u128", issue = "139201")] + #[stable(feature = "duration_from_nanos_u128", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "duration_from_nanos_u128", since = "CURRENT_RUSTC_VERSION")] #[must_use] #[inline] #[track_caller] + #[rustc_allow_const_fn_unstable(const_trait_impl, const_convert)] // for `u64::try_from` pub const fn from_nanos_u128(nanos: u128) -> Duration { const NANOS_PER_SEC: u128 = self::NANOS_PER_SEC as u128; let Ok(secs) = u64::try_from(nanos / NANOS_PER_SEC) else { diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index 80b62038c40e..e190536abcf9 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -42,7 +42,6 @@ #![feature(drop_guard)] #![feature(duration_constants)] #![feature(duration_constructors)] -#![feature(duration_from_nanos_u128)] #![feature(error_generic_member_access)] #![feature(exact_div)] #![feature(exact_size_is_empty)] diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs index b756fbb901bc..0b40c76e251f 100644 --- a/src/tools/miri/src/lib.rs +++ b/src/tools/miri/src/lib.rs @@ -17,7 +17,7 @@ #![feature(derive_coerce_pointee)] #![feature(arbitrary_self_types)] #![feature(iter_advance_by)] -#![feature(duration_from_nanos_u128)] +#![cfg_attr(bootstrap, feature(duration_from_nanos_u128))] // Configure clippy and other lints #![allow( clippy::collapsible_else_if, From 0006737ca11f83add31d702fabcedd5a8616adfc Mon Sep 17 00:00:00 2001 From: yukang Date: Sun, 9 Nov 2025 16:11:32 +0800 Subject: [PATCH 073/108] Fix the typo error caused span ice --- compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index 5d22a8b8e30a..99351f6b8161 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -749,7 +749,7 @@ fn shrink_file( let hi_byte = spans.iter().map(|s| s.hi()).max()?; let hi_loc = sm.lookup_char_pos(hi_byte); - let hi = lo_loc.file.line_bounds(hi_loc.line.saturating_sub(1)).end; + let hi = hi_loc.file.line_bounds(hi_loc.line.saturating_sub(1)).end; let bounding_span = Span::with_root_ctxt(lo, hi); let source = sm.span_to_snippet(bounding_span).unwrap_or_default(); From 8573ee6478d390e6401615d2fc9202695af6dc62 Mon Sep 17 00:00:00 2001 From: yukang Date: Sun, 9 Nov 2025 16:17:48 +0800 Subject: [PATCH 074/108] Fix ICE caused by span boundaries due to macro expansion --- .../src/annotate_snippet_emitter_writer.rs | 10 ++++- .../ice-line-bounds-issue-148732.rs | 8 ++++ .../ice-line-bounds-issue-148732.stderr | 37 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 tests/ui/delegation/ice-line-bounds-issue-148732.rs create mode 100644 tests/ui/delegation/ice-line-bounds-issue-148732.stderr diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index 99351f6b8161..b3254927a582 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -745,14 +745,20 @@ fn shrink_file( ) -> Option<(Span, String, usize)> { let lo_byte = spans.iter().map(|s| s.lo()).min()?; let lo_loc = sm.lookup_char_pos(lo_byte); - let lo = lo_loc.file.line_bounds(lo_loc.line.saturating_sub(1)).start; let hi_byte = spans.iter().map(|s| s.hi()).max()?; let hi_loc = sm.lookup_char_pos(hi_byte); + + if lo_loc.file.name != hi_loc.file.name { + // this may happen when spans cross file boundaries due to macro expansion. + return None; + } + + let lo = lo_loc.file.line_bounds(lo_loc.line.saturating_sub(1)).start; let hi = hi_loc.file.line_bounds(hi_loc.line.saturating_sub(1)).end; let bounding_span = Span::with_root_ctxt(lo, hi); - let source = sm.span_to_snippet(bounding_span).unwrap_or_default(); + let source = sm.span_to_snippet(bounding_span).ok()?; let offset_line = sm.doctest_offset_line(file_name, lo_loc.line); Some((bounding_span, source, offset_line)) diff --git a/tests/ui/delegation/ice-line-bounds-issue-148732.rs b/tests/ui/delegation/ice-line-bounds-issue-148732.rs new file mode 100644 index 000000000000..699e7d86f258 --- /dev/null +++ b/tests/ui/delegation/ice-line-bounds-issue-148732.rs @@ -0,0 +1,8 @@ +reuse a as b { + //~^ ERROR cannot find function `a` in this scope + //~| ERROR functions delegation is not yet fully implemented + dbg!(b); + //~^ ERROR missing lifetime specifier +} + +fn main() {} diff --git a/tests/ui/delegation/ice-line-bounds-issue-148732.stderr b/tests/ui/delegation/ice-line-bounds-issue-148732.stderr new file mode 100644 index 000000000000..7cbba401724a --- /dev/null +++ b/tests/ui/delegation/ice-line-bounds-issue-148732.stderr @@ -0,0 +1,37 @@ + WARN rustc_errors::emitter Invalid span $SRC_DIR/std/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/std/src/macros.rs" }) } + WARN rustc_errors::emitter Invalid span $SRC_DIR/std/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/std/src/macros.rs" }) } + WARN rustc_errors::emitter Invalid span $SRC_DIR/std/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/std/src/macros.rs" }) } +error[E0106]: missing lifetime specifier + --> $DIR/ice-line-bounds-issue-148732.rs:4:5 + | +LL | dbg!(b); + | ^^^^^^^ expected named lifetime parameter + | + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) + | + +error[E0425]: cannot find function `a` in this scope + --> $DIR/ice-line-bounds-issue-148732.rs:1:7 + | +LL | reuse a as b { + | ^ not found in this scope + +error[E0658]: functions delegation is not yet fully implemented + --> $DIR/ice-line-bounds-issue-148732.rs:1:1 + | +LL | / reuse a as b { +LL | | +LL | | +LL | | dbg!(b); +LL | | +LL | | } + | |_^ + | + = note: see issue #118212 for more information + = help: add `#![feature(fn_delegation)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0106, E0425, E0658. +For more information about an error, try `rustc --explain E0106`. From 725b213606e229517c08c9a6e9ea54411118b46d Mon Sep 17 00:00:00 2001 From: yukang Date: Sun, 9 Nov 2025 17:13:35 +0800 Subject: [PATCH 075/108] add regression test for 148684 --- .../src/annotate_snippet_emitter_writer.rs | 2 +- .../structs/ice-line-bounds-issue-148684.rs | 9 ++++++++ .../ice-line-bounds-issue-148684.stderr | 22 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/ui/structs/ice-line-bounds-issue-148684.rs create mode 100644 tests/ui/structs/ice-line-bounds-issue-148684.stderr diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index b3254927a582..4756909d3187 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -749,7 +749,7 @@ fn shrink_file( let hi_byte = spans.iter().map(|s| s.hi()).max()?; let hi_loc = sm.lookup_char_pos(hi_byte); - if lo_loc.file.name != hi_loc.file.name { + if lo_loc.file.stable_id != hi_loc.file.stable_id { // this may happen when spans cross file boundaries due to macro expansion. return None; } diff --git a/tests/ui/structs/ice-line-bounds-issue-148684.rs b/tests/ui/structs/ice-line-bounds-issue-148684.rs new file mode 100644 index 000000000000..56065fb0de30 --- /dev/null +++ b/tests/ui/structs/ice-line-bounds-issue-148684.rs @@ -0,0 +1,9 @@ +struct A { + b: Vec, + c: usize, +} + +fn main() { + A(2, vec![]) + //~^ ERROR expected function, tuple struct or tuple variant, found struct `A` +} diff --git a/tests/ui/structs/ice-line-bounds-issue-148684.stderr b/tests/ui/structs/ice-line-bounds-issue-148684.stderr new file mode 100644 index 000000000000..d6900a9fd6ac --- /dev/null +++ b/tests/ui/structs/ice-line-bounds-issue-148684.stderr @@ -0,0 +1,22 @@ + WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } + WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } + WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } + WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } + WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } + WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } +error[E0423]: expected function, tuple struct or tuple variant, found struct `A` + --> $DIR/ice-line-bounds-issue-148684.rs:7:5 + | +LL | / struct A { +LL | | b: Vec, +LL | | c: usize, +LL | | } + | |_- `A` defined here +... +LL | A(2, vec![]) + | ^^^^^^^^^^^^ + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0423`. From 3ba87c4b33b746e32725955ee9852443f4ae3bb4 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 11 Nov 2025 11:51:59 -0600 Subject: [PATCH 076/108] rustdoc: expand regression test for #146214 --- tests/rustdoc-js/alias-path-distance-146214.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/rustdoc-js/alias-path-distance-146214.js b/tests/rustdoc-js/alias-path-distance-146214.js index 722cf00de910..b8224047fe4d 100644 --- a/tests/rustdoc-js/alias-path-distance-146214.js +++ b/tests/rustdoc-js/alias-path-distance-146214.js @@ -16,4 +16,17 @@ const EXPECTED = [ { 'path': 'alias_path_distance::Foo', 'name': 'baz' }, ], }, + { + 'query': 'Foo::zzzz', + 'others': [ + { 'path': 'alias_path_distance::Foo', 'name': 'baz' }, + ], + }, + { + 'query': 'zzzz', + 'others': [ + { 'path': 'alias_path_distance::Foo', 'name': 'baz' }, + { 'path': 'alias_path_distance::Bar', 'name': 'baz' }, + ], + }, ]; From 1bfad0199f0984c6c5a5dcc22cf18ab793e17ab9 Mon Sep 17 00:00:00 2001 From: Lucas Baumann Date: Mon, 10 Nov 2025 15:18:16 +0100 Subject: [PATCH 077/108] fix rtsan_nonblocking_async lint closure ICE --- compiler/rustc_codegen_ssa/src/codegen_attrs.rs | 14 ++++++++------ tests/ui/sanitize-attr/invalid-sanitize.rs | 5 +++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 720f8061c4e6..ad4482383a45 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -468,16 +468,18 @@ fn check_result( }) } - // warn for nonblocking async fn. + // warn for nonblocking async functions, blocks and closures. // This doesn't behave as expected, because the executor can run blocking code without the sanitizer noticing. if codegen_fn_attrs.sanitizers.rtsan_setting == RtsanSetting::Nonblocking && let Some(sanitize_span) = interesting_spans.sanitize - // async function - && (tcx.asyncness(did).is_async() || (tcx.is_closure_like(did.into()) + // async fn + && (tcx.asyncness(did).is_async() // async block - && (tcx.coroutine_is_async(did.into()) - // async closure - || tcx.coroutine_is_async(tcx.coroutine_for_closure(did))))) + || tcx.is_coroutine(did.into()) + // async closure + || (tcx.is_closure_like(did.into()) + && tcx.hir_node_by_def_id(did).expect_closure().kind + != rustc_hir::ClosureKind::Closure)) { let hir_id = tcx.local_def_id_to_hir_id(did); tcx.node_span_lint( diff --git a/tests/ui/sanitize-attr/invalid-sanitize.rs b/tests/ui/sanitize-attr/invalid-sanitize.rs index 63eef5166484..6846b6ff228b 100644 --- a/tests/ui/sanitize-attr/invalid-sanitize.rs +++ b/tests/ui/sanitize-attr/invalid-sanitize.rs @@ -37,4 +37,9 @@ fn test() { #[sanitize(realtime = "nonblocking")] //~ WARN: the async executor can run blocking code, without realtime sanitizer catching it [rtsan_nonblocking_async] async || {} }; + + let _regular_closure = { + #[sanitize(realtime = "nonblocking")] // no warning on a regular closure + || 0 + }; } From f5f91cc4a740dace9a882d35d5e28dc6d4aefe56 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 12 Nov 2025 00:00:39 +0100 Subject: [PATCH 078/108] add a test for combining RPIT with explicit tail calls --- tests/ui/explicit-tail-calls/rpit.rs | 20 ++++++++++++++++++++ tests/ui/explicit-tail-calls/rpit.stderr | 12 ++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/ui/explicit-tail-calls/rpit.rs create mode 100644 tests/ui/explicit-tail-calls/rpit.stderr diff --git a/tests/ui/explicit-tail-calls/rpit.rs b/tests/ui/explicit-tail-calls/rpit.rs new file mode 100644 index 000000000000..0d1f2c78fd13 --- /dev/null +++ b/tests/ui/explicit-tail-calls/rpit.rs @@ -0,0 +1,20 @@ +#![feature(explicit_tail_calls)] +#![expect(incomplete_features)] + +// Regression test for https://github.com/rust-lang/rust/issues/139305. +// +// Combining return position impl trait (RPIT) with guaranteed tail calls does not +// currently work, but at least it does not ICE. + +fn foo(x: u32, y: u32) -> u32 { + x + y +} + +fn bar(x: u32, y: u32) -> impl ToString { + become foo(x, y); + //~^ ERROR mismatched signatures +} + +fn main() { + assert_eq!(bar(1, 2).to_string(), "3"); +} diff --git a/tests/ui/explicit-tail-calls/rpit.stderr b/tests/ui/explicit-tail-calls/rpit.stderr new file mode 100644 index 000000000000..9c181db8b801 --- /dev/null +++ b/tests/ui/explicit-tail-calls/rpit.stderr @@ -0,0 +1,12 @@ +error: mismatched signatures + --> $DIR/rpit.rs:14:5 + | +LL | become foo(x, y); + | ^^^^^^^^^^^^^^^^ + | + = note: `become` requires caller and callee to have matching signatures + = note: caller signature: `fn(u32, u32) -> impl ToString` + = note: callee signature: `fn(u32, u32) -> u32` + +error: aborting due to 1 previous error + From 9d4620dde743d1f719279d3c1f4b40e13a80604d Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 1 Nov 2025 14:37:47 +1100 Subject: [PATCH 079/108] Set up snapshot tests for bootstrap's path-to-step handling --- src/bootstrap/src/core/build_steps/test.rs | 7 + src/bootstrap/src/core/builder/cli_paths.rs | 3 + .../builder/cli_paths/snapshots/x_build.snap | 23 +++ .../src/core/builder/cli_paths/tests.rs | 136 ++++++++++++++++++ src/bootstrap/src/core/builder/mod.rs | 14 ++ 5 files changed, 183 insertions(+) create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_build.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/tests.rs diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index be05b92a0973..9c9bb7cc1ed3 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -3413,6 +3413,13 @@ impl Step for Bootstrap { .env("INSTA_WORKSPACE_ROOT", &builder.src) .env("RUSTC_BOOTSTRAP", "1"); + if builder.config.cmd.bless() { + // Tell `insta` to automatically bless any failing `.snap` files. + // Unlike compiletest blessing, the tests might still report failure. + // Does not bless inline snapshots. + cargo.env("INSTA_UPDATE", "always"); + } + run_cargo_test(cargo, &[], &[], None, host, builder); } diff --git a/src/bootstrap/src/core/builder/cli_paths.rs b/src/bootstrap/src/core/builder/cli_paths.rs index aa81c4684eab..fef1979465e8 100644 --- a/src/bootstrap/src/core/builder/cli_paths.rs +++ b/src/bootstrap/src/core/builder/cli_paths.rs @@ -7,6 +7,9 @@ use std::path::PathBuf; use crate::core::builder::{Builder, Kind, PathSet, ShouldRun, StepDescription}; +#[cfg(test)] +mod tests; + pub(crate) const PATH_REMAP: &[(&str, &[&str])] = &[ // bootstrap.toml uses `rust-analyzer-proc-macro-srv`, but the // actual path is `proc-macro-srv-cli` diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build.snap new file mode 100644 index 000000000000..f8c6deccb3bc --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build.snap @@ -0,0 +1,23 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: build +--- +[Build] compile::Std + targets: [aarch64-unknown-linux-gnu] + - Set({build::library}) + - Set({build::library/alloc}) + - Set({build::library/compiler-builtins/compiler-builtins}) + - Set({build::library/core}) + - Set({build::library/panic_abort}) + - Set({build::library/panic_unwind}) + - Set({build::library/proc_macro}) + - Set({build::library/rustc-std-workspace-core}) + - Set({build::library/std}) + - Set({build::library/std_detect}) + - Set({build::library/sysroot}) + - Set({build::library/test}) + - Set({build::library/unwind}) +[Build] tool::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({build::src/librustdoc}) + - Set({build::src/tools/rustdoc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/tests.rs b/src/bootstrap/src/core/builder/cli_paths/tests.rs new file mode 100644 index 000000000000..614c67f36253 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/tests.rs @@ -0,0 +1,136 @@ +use std::collections::{BTreeSet, HashSet}; +use std::fs; +use std::path::{Path, PathBuf}; +use std::sync::{Arc, Mutex}; + +use crate::Build; +use crate::core::builder::cli_paths::match_paths_to_steps_and_run; +use crate::core::builder::{Builder, StepDescription}; +use crate::utils::tests::TestCtx; + +fn render_steps_for_cli_args(args_str: &str) -> String { + // Split a single string into a step kind and subsequent arguments. + // E.g. "test ui" => ("test", &["ui"]) + let args = args_str.split_ascii_whitespace().collect::>(); + let (kind, args) = args.split_first().unwrap(); + + // Arbitrary tuple to represent the host system. + let hosts = &["x86_64-unknown-linux-gnu"]; + // Arbitrary tuple to represent the target system, which might not be the host. + let targets = &["aarch64-unknown-linux-gnu"]; + + let config = TestCtx::new() + .config(kind) + // `test::Bootstrap` is only run by default in CI, causing inconsistency. + .arg("--ci=false") + .args(args) + .hosts(hosts) + .targets(targets) + .create_config(); + let mut build = Build::new(config); + // Some rustdoc test steps are only run by default if nodejs is + // configured/discovered, causing inconsistency. + build.config.nodejs = Some(PathBuf::from("node")); + let mut builder = Builder::new(&build); + + // Tell the builder to log steps that it would run, instead of running them. + let mut buf = Arc::new(Mutex::new(String::new())); + let buf2 = Arc::clone(&buf); + builder.log_cli_step_for_tests = Some(Box::new(move |step_desc, pathsets, targets| { + use std::fmt::Write; + let mut buf = buf2.lock().unwrap(); + + let StepDescription { name, kind, .. } = step_desc; + // Strip boilerplate to make step names easier to read. + let name = name.strip_prefix("bootstrap::core::build_steps::").unwrap_or(name); + + writeln!(buf, "[{kind:?}] {name}").unwrap(); + writeln!(buf, " targets: {targets:?}").unwrap(); + for pathset in pathsets { + // Normalize backslashes in paths, to avoid snapshot differences on Windows. + // FIXME(Zalathar): Doing a string-replace on + // is a bit unprincipled, but it's good enough for now. + let pathset_str = format!("{pathset:?}").replace('\\', "/"); + writeln!(buf, " - {pathset_str}").unwrap(); + } + })); + + builder.execute_cli(); + + String::clone(&buf.lock().unwrap()) +} + +fn snapshot_test_inner(name: &str, args_str: &str) { + let mut settings = insta::Settings::clone_current(); + // Use the test name as the snapshot filename, not its whole fully-qualified name. + settings.set_prepend_module_to_snapshot(false); + settings.bind(|| { + insta::assert_snapshot!(name, render_steps_for_cli_args(args_str), args_str); + }); +} + +/// Keep the snapshots directory tidy by forbidding `.snap` files that don't +/// correspond to a test name. +fn no_unused_snapshots_inner(known_test_names: &[&str]) { + let known_test_names = known_test_names.iter().copied().collect::>(); + + let mut unexpected_file_names = BTreeSet::new(); + + // FIXME(Zalathar): Is there a better way to locate the snapshots dir? + for entry in walkdir::WalkDir::new("src/core/builder/cli_paths/snapshots") + .into_iter() + .map(Result::unwrap) + { + let meta = entry.metadata().unwrap(); + if !meta.is_file() { + continue; + } + + let name = entry.file_name().to_str().unwrap(); + if let Some(name_stub) = name.strip_suffix(".snap") + && !known_test_names.contains(name_stub) + { + unexpected_file_names.insert(name.to_owned()); + } + } + + assert!( + unexpected_file_names.is_empty(), + "Found snapshot files that don't correspond to a test name: {unexpected_file_names:#?}", + ); +} + +macro_rules! declare_tests { + ( + $( ($name:ident, $args:literal) ),* $(,)? + ) => { + $( + #[test] + fn $name() { + snapshot_test_inner(stringify!($name), $args); + } + )* + + #[test] + fn no_unused_snapshots() { + let known_test_names = &[ $( stringify!($name), )* ]; + no_unused_snapshots_inner(known_test_names); + } + }; +} + +// Snapshot tests for bootstrap's command-line path-to-step handling. +// +// To bless these tests as necessary, choose one: +// - Run `INSTA_UPDATE=always ./x test bootstrap` +// - Run `./x test bootstrap --bless` +// - Follow the instructions for `cargo-insta` in bootstrap's README.md +// +// These snapshot tests capture _current_ behavior, to prevent unintended +// changes or regressions. If the current behavior is wrong or undersirable, +// then any fix will necessarily have to re-bless the affected tests! +declare_tests!( + // tidy-alphabetical-start + (x_build, "build"), + // tidy-alphabetical-end +); diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 43faf92fe6d9..9124442e7f37 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -66,6 +66,12 @@ pub struct Builder<'a> { /// Cached list of submodules from self.build.src. submodule_paths_cache: OnceLock>, + + /// When enabled by tests, this causes the top-level steps that _would_ be + /// executed to be logged instead. Used by snapshot tests of command-line + /// paths-to-steps handling. + #[expect(clippy::type_complexity)] + log_cli_step_for_tests: Option>, } impl Deref for Builder<'_> { @@ -447,6 +453,13 @@ impl StepDescription { // Determine the targets participating in this rule. let targets = if self.is_host { &builder.hosts } else { &builder.targets }; + // Log the step that's about to run, for snapshot tests. + if let Some(ref log_cli_step) = builder.log_cli_step_for_tests { + log_cli_step(self, &pathsets, targets); + // Return so that the step won't actually run in snapshot tests. + return; + } + for target in targets { let run = RunConfig { builder, paths: pathsets.clone(), target: *target }; (self.make_run)(run); @@ -1079,6 +1092,7 @@ impl<'a> Builder<'a> { time_spent_on_dependencies: Cell::new(Duration::new(0, 0)), paths, submodule_paths_cache: Default::default(), + log_cli_step_for_tests: None, } } From 2412e1555c7ef097677befc8e9379569c3cadc43 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 1 Nov 2025 18:15:13 +1100 Subject: [PATCH 080/108] Add several snapshot tests for path-to-step handling --- .../cli_paths/snapshots/x_build_compiler.snap | 84 +++++++ .../snapshots/x_build_compiletest.snap | 7 + .../cli_paths/snapshots/x_build_library.snap | 22 ++ .../cli_paths/snapshots/x_build_llvm.snap | 7 + .../cli_paths/snapshots/x_build_rustc.snap | 7 + .../snapshots/x_build_rustc_llvm.snap | 7 + .../cli_paths/snapshots/x_build_rustdoc.snap | 7 + .../cli_paths/snapshots/x_build_sysroot.snap | 7 + .../builder/cli_paths/snapshots/x_check.snap | 134 +++++++++++ .../snapshots/x_check_bootstrap.snap | 7 + .../cli_paths/snapshots/x_check_compiler.snap | 82 +++++++ .../snapshots/x_check_compiletest.snap | 7 + ...eck_compiletest_include_default_paths.snap | 137 +++++++++++ .../cli_paths/snapshots/x_check_library.snap | 21 ++ .../cli_paths/snapshots/x_check_rustc.snap | 7 + .../cli_paths/snapshots/x_check_rustdoc.snap | 7 + .../builder/cli_paths/snapshots/x_dist.snap | 34 +++ .../builder/cli_paths/snapshots/x_test.snap | 212 ++++++++++++++++++ .../cli_paths/snapshots/x_test_coverage.snap | 7 + .../snapshots/x_test_coverage_map.snap | 7 + .../snapshots/x_test_coverage_run.snap | 7 + .../x_test_coverage_skip_coverage_run.snap | 7 + .../cli_paths/snapshots/x_test_debuginfo.snap | 7 + .../cli_paths/snapshots/x_test_library.snap | 20 ++ .../snapshots/x_test_librustdoc.snap | 7 + .../snapshots/x_test_librustdoc_rustdoc.snap | 13 ++ .../cli_paths/snapshots/x_test_rustdoc.snap | 13 ++ .../snapshots/x_test_skip_coverage.snap | 211 +++++++++++++++++ .../snapshots/x_test_skip_tests.snap | 157 +++++++++++++ .../snapshots/x_test_skip_tests_etc.snap | 136 +++++++++++ .../cli_paths/snapshots/x_test_tests.snap | 64 ++++++ .../snapshots/x_test_tests_skip_coverage.snap | 61 +++++ .../cli_paths/snapshots/x_test_tests_ui.snap | 7 + .../cli_paths/snapshots/x_test_tidy.snap | 7 + .../snapshots/x_test_tidyselftest.snap | 7 + .../cli_paths/snapshots/x_test_ui.snap | 7 + .../src/core/builder/cli_paths/tests.rs | 42 ++++ 37 files changed, 1583 insertions(+) create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiletest.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_library.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_llvm.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustc.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustc_llvm.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustdoc.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_sysroot.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_bootstrap.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_library.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_rustc.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_rustdoc.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_dist.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_map.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_run.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_skip_coverage_run.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_debuginfo.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_librustdoc.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_librustdoc_rustdoc.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_rustdoc.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests_skip_coverage.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests_ui.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tidy.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tidyselftest.snap create mode 100644 src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_ui.snap diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap new file mode 100644 index 000000000000..721ecaf4c487 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiler.snap @@ -0,0 +1,84 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: build compiler +--- +[Build] compile::Rustc + targets: [x86_64-unknown-linux-gnu] + - Set({build::compiler/rustc_abi}) + - Set({build::compiler/rustc_arena}) + - Set({build::compiler/rustc_ast}) + - Set({build::compiler/rustc_ast_ir}) + - Set({build::compiler/rustc_ast_lowering}) + - Set({build::compiler/rustc_ast_passes}) + - Set({build::compiler/rustc_ast_pretty}) + - Set({build::compiler/rustc_attr_parsing}) + - Set({build::compiler/rustc_baked_icu_data}) + - Set({build::compiler/rustc_borrowck}) + - Set({build::compiler/rustc_builtin_macros}) + - Set({build::compiler/rustc_codegen_llvm}) + - Set({build::compiler/rustc_codegen_ssa}) + - Set({build::compiler/rustc_const_eval}) + - Set({build::compiler/rustc_data_structures}) + - Set({build::compiler/rustc_driver}) + - Set({build::compiler/rustc_driver_impl}) + - Set({build::compiler/rustc_error_codes}) + - Set({build::compiler/rustc_error_messages}) + - Set({build::compiler/rustc_errors}) + - Set({build::compiler/rustc_expand}) + - Set({build::compiler/rustc_feature}) + - Set({build::compiler/rustc_fluent_macro}) + - Set({build::compiler/rustc_fs_util}) + - Set({build::compiler/rustc_graphviz}) + - Set({build::compiler/rustc_hashes}) + - Set({build::compiler/rustc_hir}) + - Set({build::compiler/rustc_hir_analysis}) + - Set({build::compiler/rustc_hir_id}) + - Set({build::compiler/rustc_hir_pretty}) + - Set({build::compiler/rustc_hir_typeck}) + - Set({build::compiler/rustc_incremental}) + - Set({build::compiler/rustc_index}) + - Set({build::compiler/rustc_index_macros}) + - Set({build::compiler/rustc_infer}) + - Set({build::compiler/rustc_interface}) + - Set({build::compiler/rustc_lexer}) + - Set({build::compiler/rustc_lint}) + - Set({build::compiler/rustc_lint_defs}) + - Set({build::compiler/rustc_llvm}) + - Set({build::compiler/rustc_log}) + - Set({build::compiler/rustc_macros}) + - Set({build::compiler/rustc_metadata}) + - Set({build::compiler/rustc_middle}) + - Set({build::compiler/rustc_mir_build}) + - Set({build::compiler/rustc_mir_dataflow}) + - Set({build::compiler/rustc_mir_transform}) + - Set({build::compiler/rustc_monomorphize}) + - Set({build::compiler/rustc_next_trait_solver}) + - Set({build::compiler/rustc_parse}) + - Set({build::compiler/rustc_parse_format}) + - Set({build::compiler/rustc_passes}) + - Set({build::compiler/rustc_pattern_analysis}) + - Set({build::compiler/rustc_privacy}) + - Set({build::compiler/rustc_proc_macro}) + - Set({build::compiler/rustc_public}) + - Set({build::compiler/rustc_public_bridge}) + - Set({build::compiler/rustc_query_impl}) + - Set({build::compiler/rustc_query_system}) + - Set({build::compiler/rustc_resolve}) + - Set({build::compiler/rustc_sanitizers}) + - Set({build::compiler/rustc_serialize}) + - Set({build::compiler/rustc_session}) + - Set({build::compiler/rustc_span}) + - Set({build::compiler/rustc_symbol_mangling}) + - Set({build::compiler/rustc_target}) + - Set({build::compiler/rustc_thread_pool}) + - Set({build::compiler/rustc_trait_selection}) + - Set({build::compiler/rustc_traits}) + - Set({build::compiler/rustc_transmute}) + - Set({build::compiler/rustc_ty_utils}) + - Set({build::compiler/rustc_type_ir}) + - Set({build::compiler/rustc_type_ir_macros}) + - Set({build::compiler/rustc_windows_rc}) +[Build] compile::Assemble + targets: [x86_64-unknown-linux-gnu] + - Set({build::compiler}) + - Set({build::compiler/rustc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiletest.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiletest.snap new file mode 100644 index 000000000000..97f60bfa0370 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_compiletest.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: build compiletest +--- +[Build] tool::Compiletest + targets: [aarch64-unknown-linux-gnu] + - Set({build::src/tools/compiletest}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_library.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_library.snap new file mode 100644 index 000000000000..3fccd99850b8 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_library.snap @@ -0,0 +1,22 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: build library +--- +[Build] compile::Std + targets: [aarch64-unknown-linux-gnu] + - Set({build::library}) + - Set({build::library/alloc}) + - Set({build::library/compiler-builtins/compiler-builtins}) + - Set({build::library/core}) + - Set({build::library/panic_abort}) + - Set({build::library/panic_unwind}) + - Set({build::library/proc_macro}) + - Set({build::library/rustc-std-workspace-core}) + - Set({build::library/std}) + - Set({build::library/std_detect}) + - Set({build::library/sysroot}) + - Set({build::library/test}) + - Set({build::library/unwind}) +[Build] compile::StartupObjects + targets: [aarch64-unknown-linux-gnu] + - Set({build::library/rtstartup}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_llvm.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_llvm.snap new file mode 100644 index 000000000000..f4764a5279a7 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_llvm.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: build llvm +--- +[Build] llvm::Llvm + targets: [x86_64-unknown-linux-gnu] + - Set({build::src/llvm-project/llvm}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustc.snap new file mode 100644 index 000000000000..a6d3d13154ed --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustc.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: build rustc +--- +[Build] compile::Assemble + targets: [x86_64-unknown-linux-gnu] + - Set({build::compiler/rustc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustc_llvm.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustc_llvm.snap new file mode 100644 index 000000000000..30f598ddb781 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustc_llvm.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: build rustc_llvm +--- +[Build] compile::Rustc + targets: [x86_64-unknown-linux-gnu] + - Set({build::compiler/rustc_llvm}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustdoc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustdoc.snap new file mode 100644 index 000000000000..9a98092d714f --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_rustdoc.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: build rustdoc +--- +[Build] tool::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({build::src/tools/rustdoc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_sysroot.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_sysroot.snap new file mode 100644 index 000000000000..a397095800a7 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_build_sysroot.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: build sysroot +--- +[Build] compile::Std + targets: [aarch64-unknown-linux-gnu] + - Set({build::library/sysroot}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap new file mode 100644 index 000000000000..0fe26fac57fc --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check.snap @@ -0,0 +1,134 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: check +--- +[Check] check::Rustc + targets: [x86_64-unknown-linux-gnu] + - Set({check::compiler}) + - Set({check::compiler/rustc}) + - Set({check::compiler/rustc_abi}) + - Set({check::compiler/rustc_arena}) + - Set({check::compiler/rustc_ast}) + - Set({check::compiler/rustc_ast_ir}) + - Set({check::compiler/rustc_ast_lowering}) + - Set({check::compiler/rustc_ast_passes}) + - Set({check::compiler/rustc_ast_pretty}) + - Set({check::compiler/rustc_attr_parsing}) + - Set({check::compiler/rustc_baked_icu_data}) + - Set({check::compiler/rustc_borrowck}) + - Set({check::compiler/rustc_builtin_macros}) + - Set({check::compiler/rustc_codegen_llvm}) + - Set({check::compiler/rustc_codegen_ssa}) + - Set({check::compiler/rustc_const_eval}) + - Set({check::compiler/rustc_data_structures}) + - Set({check::compiler/rustc_driver}) + - Set({check::compiler/rustc_driver_impl}) + - Set({check::compiler/rustc_error_codes}) + - Set({check::compiler/rustc_error_messages}) + - Set({check::compiler/rustc_errors}) + - Set({check::compiler/rustc_expand}) + - Set({check::compiler/rustc_feature}) + - Set({check::compiler/rustc_fluent_macro}) + - Set({check::compiler/rustc_fs_util}) + - Set({check::compiler/rustc_graphviz}) + - Set({check::compiler/rustc_hashes}) + - Set({check::compiler/rustc_hir}) + - Set({check::compiler/rustc_hir_analysis}) + - Set({check::compiler/rustc_hir_id}) + - Set({check::compiler/rustc_hir_pretty}) + - Set({check::compiler/rustc_hir_typeck}) + - Set({check::compiler/rustc_incremental}) + - Set({check::compiler/rustc_index}) + - Set({check::compiler/rustc_index_macros}) + - Set({check::compiler/rustc_infer}) + - Set({check::compiler/rustc_interface}) + - Set({check::compiler/rustc_lexer}) + - Set({check::compiler/rustc_lint}) + - Set({check::compiler/rustc_lint_defs}) + - Set({check::compiler/rustc_llvm}) + - Set({check::compiler/rustc_log}) + - Set({check::compiler/rustc_macros}) + - Set({check::compiler/rustc_metadata}) + - Set({check::compiler/rustc_middle}) + - Set({check::compiler/rustc_mir_build}) + - Set({check::compiler/rustc_mir_dataflow}) + - Set({check::compiler/rustc_mir_transform}) + - Set({check::compiler/rustc_monomorphize}) + - Set({check::compiler/rustc_next_trait_solver}) + - Set({check::compiler/rustc_parse}) + - Set({check::compiler/rustc_parse_format}) + - Set({check::compiler/rustc_passes}) + - Set({check::compiler/rustc_pattern_analysis}) + - Set({check::compiler/rustc_privacy}) + - Set({check::compiler/rustc_proc_macro}) + - Set({check::compiler/rustc_public}) + - Set({check::compiler/rustc_public_bridge}) + - Set({check::compiler/rustc_query_impl}) + - Set({check::compiler/rustc_query_system}) + - Set({check::compiler/rustc_resolve}) + - Set({check::compiler/rustc_sanitizers}) + - Set({check::compiler/rustc_serialize}) + - Set({check::compiler/rustc_session}) + - Set({check::compiler/rustc_span}) + - Set({check::compiler/rustc_symbol_mangling}) + - Set({check::compiler/rustc_target}) + - Set({check::compiler/rustc_thread_pool}) + - Set({check::compiler/rustc_trait_selection}) + - Set({check::compiler/rustc_traits}) + - Set({check::compiler/rustc_transmute}) + - Set({check::compiler/rustc_ty_utils}) + - Set({check::compiler/rustc_type_ir}) + - Set({check::compiler/rustc_type_ir_macros}) + - Set({check::compiler/rustc_windows_rc}) +[Check] check::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/librustdoc, check::src/tools/rustdoc}) +[Check] check::CraneliftCodegenBackend + targets: [x86_64-unknown-linux-gnu] + - Set({check::cg_clif}) + - Set({check::rustc_codegen_cranelift}) +[Check] check::GccCodegenBackend + targets: [x86_64-unknown-linux-gnu] + - Set({check::cg_gcc}) + - Set({check::rustc_codegen_gcc}) +[Check] check::Clippy + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/clippy}) +[Check] check::Miri + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/miri}) +[Check] check::CargoMiri + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/miri/cargo-miri}) +[Check] check::MiroptTestTools + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/miropt-test-tools}) +[Check] check::Rustfmt + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/rustfmt}) +[Check] check::RustAnalyzer + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/rust-analyzer}) +[Check] check::TestFloatParse + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/test-float-parse}) +[Check] check::FeaturesStatusDump + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/features-status-dump}) +[Check] check::Std + targets: [aarch64-unknown-linux-gnu] + - Set({check::library}) + - Set({check::library/alloc}) + - Set({check::library/alloctests}) + - Set({check::library/compiler-builtins/compiler-builtins}) + - Set({check::library/core}) + - Set({check::library/coretests}) + - Set({check::library/panic_abort}) + - Set({check::library/panic_unwind}) + - Set({check::library/proc_macro}) + - Set({check::library/rustc-std-workspace-core}) + - Set({check::library/std}) + - Set({check::library/std_detect}) + - Set({check::library/sysroot}) + - Set({check::library/test}) + - Set({check::library/unwind}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_bootstrap.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_bootstrap.snap new file mode 100644 index 000000000000..a746783b3909 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_bootstrap.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: check bootstrap +--- +[Check] check::Bootstrap + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/bootstrap}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap new file mode 100644 index 000000000000..71d9c0fafb80 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiler.snap @@ -0,0 +1,82 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: check compiler +--- +[Check] check::Rustc + targets: [x86_64-unknown-linux-gnu] + - Set({check::compiler}) + - Set({check::compiler/rustc}) + - Set({check::compiler/rustc_abi}) + - Set({check::compiler/rustc_arena}) + - Set({check::compiler/rustc_ast}) + - Set({check::compiler/rustc_ast_ir}) + - Set({check::compiler/rustc_ast_lowering}) + - Set({check::compiler/rustc_ast_passes}) + - Set({check::compiler/rustc_ast_pretty}) + - Set({check::compiler/rustc_attr_parsing}) + - Set({check::compiler/rustc_baked_icu_data}) + - Set({check::compiler/rustc_borrowck}) + - Set({check::compiler/rustc_builtin_macros}) + - Set({check::compiler/rustc_codegen_llvm}) + - Set({check::compiler/rustc_codegen_ssa}) + - Set({check::compiler/rustc_const_eval}) + - Set({check::compiler/rustc_data_structures}) + - Set({check::compiler/rustc_driver}) + - Set({check::compiler/rustc_driver_impl}) + - Set({check::compiler/rustc_error_codes}) + - Set({check::compiler/rustc_error_messages}) + - Set({check::compiler/rustc_errors}) + - Set({check::compiler/rustc_expand}) + - Set({check::compiler/rustc_feature}) + - Set({check::compiler/rustc_fluent_macro}) + - Set({check::compiler/rustc_fs_util}) + - Set({check::compiler/rustc_graphviz}) + - Set({check::compiler/rustc_hashes}) + - Set({check::compiler/rustc_hir}) + - Set({check::compiler/rustc_hir_analysis}) + - Set({check::compiler/rustc_hir_id}) + - Set({check::compiler/rustc_hir_pretty}) + - Set({check::compiler/rustc_hir_typeck}) + - Set({check::compiler/rustc_incremental}) + - Set({check::compiler/rustc_index}) + - Set({check::compiler/rustc_index_macros}) + - Set({check::compiler/rustc_infer}) + - Set({check::compiler/rustc_interface}) + - Set({check::compiler/rustc_lexer}) + - Set({check::compiler/rustc_lint}) + - Set({check::compiler/rustc_lint_defs}) + - Set({check::compiler/rustc_llvm}) + - Set({check::compiler/rustc_log}) + - Set({check::compiler/rustc_macros}) + - Set({check::compiler/rustc_metadata}) + - Set({check::compiler/rustc_middle}) + - Set({check::compiler/rustc_mir_build}) + - Set({check::compiler/rustc_mir_dataflow}) + - Set({check::compiler/rustc_mir_transform}) + - Set({check::compiler/rustc_monomorphize}) + - Set({check::compiler/rustc_next_trait_solver}) + - Set({check::compiler/rustc_parse}) + - Set({check::compiler/rustc_parse_format}) + - Set({check::compiler/rustc_passes}) + - Set({check::compiler/rustc_pattern_analysis}) + - Set({check::compiler/rustc_privacy}) + - Set({check::compiler/rustc_proc_macro}) + - Set({check::compiler/rustc_public}) + - Set({check::compiler/rustc_public_bridge}) + - Set({check::compiler/rustc_query_impl}) + - Set({check::compiler/rustc_query_system}) + - Set({check::compiler/rustc_resolve}) + - Set({check::compiler/rustc_sanitizers}) + - Set({check::compiler/rustc_serialize}) + - Set({check::compiler/rustc_session}) + - Set({check::compiler/rustc_span}) + - Set({check::compiler/rustc_symbol_mangling}) + - Set({check::compiler/rustc_target}) + - Set({check::compiler/rustc_thread_pool}) + - Set({check::compiler/rustc_trait_selection}) + - Set({check::compiler/rustc_traits}) + - Set({check::compiler/rustc_transmute}) + - Set({check::compiler/rustc_ty_utils}) + - Set({check::compiler/rustc_type_ir}) + - Set({check::compiler/rustc_type_ir_macros}) + - Set({check::compiler/rustc_windows_rc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest.snap new file mode 100644 index 000000000000..8f772bc55b82 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: check compiletest +--- +[Check] check::Compiletest + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/compiletest}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap new file mode 100644 index 000000000000..dae515c67ec6 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_compiletest_include_default_paths.snap @@ -0,0 +1,137 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: check compiletest --include-default-paths +--- +[Check] check::Rustc + targets: [x86_64-unknown-linux-gnu] + - Set({check::compiler}) + - Set({check::compiler/rustc}) + - Set({check::compiler/rustc_abi}) + - Set({check::compiler/rustc_arena}) + - Set({check::compiler/rustc_ast}) + - Set({check::compiler/rustc_ast_ir}) + - Set({check::compiler/rustc_ast_lowering}) + - Set({check::compiler/rustc_ast_passes}) + - Set({check::compiler/rustc_ast_pretty}) + - Set({check::compiler/rustc_attr_parsing}) + - Set({check::compiler/rustc_baked_icu_data}) + - Set({check::compiler/rustc_borrowck}) + - Set({check::compiler/rustc_builtin_macros}) + - Set({check::compiler/rustc_codegen_llvm}) + - Set({check::compiler/rustc_codegen_ssa}) + - Set({check::compiler/rustc_const_eval}) + - Set({check::compiler/rustc_data_structures}) + - Set({check::compiler/rustc_driver}) + - Set({check::compiler/rustc_driver_impl}) + - Set({check::compiler/rustc_error_codes}) + - Set({check::compiler/rustc_error_messages}) + - Set({check::compiler/rustc_errors}) + - Set({check::compiler/rustc_expand}) + - Set({check::compiler/rustc_feature}) + - Set({check::compiler/rustc_fluent_macro}) + - Set({check::compiler/rustc_fs_util}) + - Set({check::compiler/rustc_graphviz}) + - Set({check::compiler/rustc_hashes}) + - Set({check::compiler/rustc_hir}) + - Set({check::compiler/rustc_hir_analysis}) + - Set({check::compiler/rustc_hir_id}) + - Set({check::compiler/rustc_hir_pretty}) + - Set({check::compiler/rustc_hir_typeck}) + - Set({check::compiler/rustc_incremental}) + - Set({check::compiler/rustc_index}) + - Set({check::compiler/rustc_index_macros}) + - Set({check::compiler/rustc_infer}) + - Set({check::compiler/rustc_interface}) + - Set({check::compiler/rustc_lexer}) + - Set({check::compiler/rustc_lint}) + - Set({check::compiler/rustc_lint_defs}) + - Set({check::compiler/rustc_llvm}) + - Set({check::compiler/rustc_log}) + - Set({check::compiler/rustc_macros}) + - Set({check::compiler/rustc_metadata}) + - Set({check::compiler/rustc_middle}) + - Set({check::compiler/rustc_mir_build}) + - Set({check::compiler/rustc_mir_dataflow}) + - Set({check::compiler/rustc_mir_transform}) + - Set({check::compiler/rustc_monomorphize}) + - Set({check::compiler/rustc_next_trait_solver}) + - Set({check::compiler/rustc_parse}) + - Set({check::compiler/rustc_parse_format}) + - Set({check::compiler/rustc_passes}) + - Set({check::compiler/rustc_pattern_analysis}) + - Set({check::compiler/rustc_privacy}) + - Set({check::compiler/rustc_proc_macro}) + - Set({check::compiler/rustc_public}) + - Set({check::compiler/rustc_public_bridge}) + - Set({check::compiler/rustc_query_impl}) + - Set({check::compiler/rustc_query_system}) + - Set({check::compiler/rustc_resolve}) + - Set({check::compiler/rustc_sanitizers}) + - Set({check::compiler/rustc_serialize}) + - Set({check::compiler/rustc_session}) + - Set({check::compiler/rustc_span}) + - Set({check::compiler/rustc_symbol_mangling}) + - Set({check::compiler/rustc_target}) + - Set({check::compiler/rustc_thread_pool}) + - Set({check::compiler/rustc_trait_selection}) + - Set({check::compiler/rustc_traits}) + - Set({check::compiler/rustc_transmute}) + - Set({check::compiler/rustc_ty_utils}) + - Set({check::compiler/rustc_type_ir}) + - Set({check::compiler/rustc_type_ir_macros}) + - Set({check::compiler/rustc_windows_rc}) +[Check] check::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/librustdoc, check::src/tools/rustdoc}) +[Check] check::CraneliftCodegenBackend + targets: [x86_64-unknown-linux-gnu] + - Set({check::cg_clif}) + - Set({check::rustc_codegen_cranelift}) +[Check] check::GccCodegenBackend + targets: [x86_64-unknown-linux-gnu] + - Set({check::cg_gcc}) + - Set({check::rustc_codegen_gcc}) +[Check] check::Clippy + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/clippy}) +[Check] check::Miri + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/miri}) +[Check] check::CargoMiri + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/miri/cargo-miri}) +[Check] check::MiroptTestTools + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/miropt-test-tools}) +[Check] check::Rustfmt + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/rustfmt}) +[Check] check::RustAnalyzer + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/rust-analyzer}) +[Check] check::TestFloatParse + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/test-float-parse}) +[Check] check::FeaturesStatusDump + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/features-status-dump}) +[Check] check::Std + targets: [aarch64-unknown-linux-gnu] + - Set({check::library}) + - Set({check::library/alloc}) + - Set({check::library/alloctests}) + - Set({check::library/compiler-builtins/compiler-builtins}) + - Set({check::library/core}) + - Set({check::library/coretests}) + - Set({check::library/panic_abort}) + - Set({check::library/panic_unwind}) + - Set({check::library/proc_macro}) + - Set({check::library/rustc-std-workspace-core}) + - Set({check::library/std}) + - Set({check::library/std_detect}) + - Set({check::library/sysroot}) + - Set({check::library/test}) + - Set({check::library/unwind}) +[Check] check::Compiletest + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/compiletest}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_library.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_library.snap new file mode 100644 index 000000000000..1a41aa98555b --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_library.snap @@ -0,0 +1,21 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: check library +--- +[Check] check::Std + targets: [aarch64-unknown-linux-gnu] + - Set({check::library}) + - Set({check::library/alloc}) + - Set({check::library/alloctests}) + - Set({check::library/compiler-builtins/compiler-builtins}) + - Set({check::library/core}) + - Set({check::library/coretests}) + - Set({check::library/panic_abort}) + - Set({check::library/panic_unwind}) + - Set({check::library/proc_macro}) + - Set({check::library/rustc-std-workspace-core}) + - Set({check::library/std}) + - Set({check::library/std_detect}) + - Set({check::library/sysroot}) + - Set({check::library/test}) + - Set({check::library/unwind}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_rustc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_rustc.snap new file mode 100644 index 000000000000..9aed81d2c22d --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_rustc.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: check rustc +--- +[Check] check::Rustc + targets: [x86_64-unknown-linux-gnu] + - Set({check::compiler/rustc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_rustdoc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_rustdoc.snap new file mode 100644 index 000000000000..0a6b84f803c1 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_check_rustdoc.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: check rustdoc +--- +[Check] check::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({check::src/tools/rustdoc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_dist.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_dist.snap new file mode 100644 index 000000000000..2fc8ca143dd0 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_dist.snap @@ -0,0 +1,34 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: dist +--- +[Dist] dist::Docs + targets: [aarch64-unknown-linux-gnu] + - Set({dist::rust-docs}) +[Dist] dist::JsonDocs + targets: [aarch64-unknown-linux-gnu] + - Set({dist::rust-docs-json}) +[Dist] dist::Mingw + targets: [aarch64-unknown-linux-gnu] + - Set({dist::rust-mingw}) +[Dist] dist::Rustc + targets: [x86_64-unknown-linux-gnu] + - Set({dist::rustc}) +[Dist] dist::Std + targets: [aarch64-unknown-linux-gnu] + - Set({dist::rust-std}) +[Dist] dist::RustcDev + targets: [x86_64-unknown-linux-gnu] + - Set({dist::rustc-dev}) +[Dist] dist::Src + targets: [x86_64-unknown-linux-gnu] + - Set({dist::rust-src}) +[Dist] dist::RustDev + targets: [x86_64-unknown-linux-gnu] + - Set({dist::rust-dev}) +[Dist] dist::PlainSourceTarball + targets: [x86_64-unknown-linux-gnu] + - Set({dist::rustc-src}) +[Dist] dist::ReproducibleArtifacts + targets: [x86_64-unknown-linux-gnu] + - Set({dist::reproducible-artifacts}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap new file mode 100644 index 000000000000..b9cb897a7569 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -0,0 +1,212 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test +--- +[Test] test::Tidy + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tidy}) +[Test] test::Ui + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/ui) +[Test] test::Crashes + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/crashes) +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Set({test::coverage-map}) + - Set({test::coverage-run}) + - Suite(test::tests/coverage) +[Test] test::MirOpt + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/mir-opt) +[Test] test::CodegenLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-llvm) +[Test] test::CodegenUnits + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-units) +[Test] test::AssemblyLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/assembly-llvm) +[Test] test::Incremental + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/incremental) +[Test] test::Debuginfo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/debuginfo) +[Test] test::UiFullDeps + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/ui-fulldeps) +[Test] test::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc) +[Test] test::CoverageRunRustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/coverage-run-rustdoc) +[Test] test::Pretty + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/pretty) +[Test] test::CodegenCranelift + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_cranelift}) +[Test] test::CodegenGCC + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_gcc}) +[Test] test::Crate + targets: [aarch64-unknown-linux-gnu] + - Set({test::library/alloc}) + - Set({test::library/alloctests}) + - Set({test::library/compiler-builtins/compiler-builtins}) + - Set({test::library/core}) + - Set({test::library/coretests}) + - Set({test::library/panic_abort}) + - Set({test::library/panic_unwind}) + - Set({test::library/proc_macro}) + - Set({test::library/rustc-std-workspace-core}) + - Set({test::library/std}) + - Set({test::library/std_detect}) + - Set({test::library/sysroot}) + - Set({test::library/test}) + - Set({test::library/unwind}) +[Test] test::CrateLibrustc + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler}) + - Set({test::compiler/rustc}) + - Set({test::compiler/rustc_abi}) + - Set({test::compiler/rustc_arena}) + - Set({test::compiler/rustc_ast}) + - Set({test::compiler/rustc_ast_ir}) + - Set({test::compiler/rustc_ast_lowering}) + - Set({test::compiler/rustc_ast_passes}) + - Set({test::compiler/rustc_ast_pretty}) + - Set({test::compiler/rustc_attr_parsing}) + - Set({test::compiler/rustc_baked_icu_data}) + - Set({test::compiler/rustc_borrowck}) + - Set({test::compiler/rustc_builtin_macros}) + - Set({test::compiler/rustc_codegen_llvm}) + - Set({test::compiler/rustc_codegen_ssa}) + - Set({test::compiler/rustc_const_eval}) + - Set({test::compiler/rustc_data_structures}) + - Set({test::compiler/rustc_driver}) + - Set({test::compiler/rustc_driver_impl}) + - Set({test::compiler/rustc_error_codes}) + - Set({test::compiler/rustc_error_messages}) + - Set({test::compiler/rustc_errors}) + - Set({test::compiler/rustc_expand}) + - Set({test::compiler/rustc_feature}) + - Set({test::compiler/rustc_fluent_macro}) + - Set({test::compiler/rustc_fs_util}) + - Set({test::compiler/rustc_graphviz}) + - Set({test::compiler/rustc_hashes}) + - Set({test::compiler/rustc_hir}) + - Set({test::compiler/rustc_hir_analysis}) + - Set({test::compiler/rustc_hir_id}) + - Set({test::compiler/rustc_hir_pretty}) + - Set({test::compiler/rustc_hir_typeck}) + - Set({test::compiler/rustc_incremental}) + - Set({test::compiler/rustc_index}) + - Set({test::compiler/rustc_index_macros}) + - Set({test::compiler/rustc_infer}) + - Set({test::compiler/rustc_interface}) + - Set({test::compiler/rustc_lexer}) + - Set({test::compiler/rustc_lint}) + - Set({test::compiler/rustc_lint_defs}) + - Set({test::compiler/rustc_llvm}) + - Set({test::compiler/rustc_log}) + - Set({test::compiler/rustc_macros}) + - Set({test::compiler/rustc_metadata}) + - Set({test::compiler/rustc_middle}) + - Set({test::compiler/rustc_mir_build}) + - Set({test::compiler/rustc_mir_dataflow}) + - Set({test::compiler/rustc_mir_transform}) + - Set({test::compiler/rustc_monomorphize}) + - Set({test::compiler/rustc_next_trait_solver}) + - Set({test::compiler/rustc_parse}) + - Set({test::compiler/rustc_parse_format}) + - Set({test::compiler/rustc_passes}) + - Set({test::compiler/rustc_pattern_analysis}) + - Set({test::compiler/rustc_privacy}) + - Set({test::compiler/rustc_proc_macro}) + - Set({test::compiler/rustc_public}) + - Set({test::compiler/rustc_public_bridge}) + - Set({test::compiler/rustc_query_impl}) + - Set({test::compiler/rustc_query_system}) + - Set({test::compiler/rustc_resolve}) + - Set({test::compiler/rustc_sanitizers}) + - Set({test::compiler/rustc_serialize}) + - Set({test::compiler/rustc_session}) + - Set({test::compiler/rustc_span}) + - Set({test::compiler/rustc_symbol_mangling}) + - Set({test::compiler/rustc_target}) + - Set({test::compiler/rustc_thread_pool}) + - Set({test::compiler/rustc_trait_selection}) + - Set({test::compiler/rustc_traits}) + - Set({test::compiler/rustc_transmute}) + - Set({test::compiler/rustc_ty_utils}) + - Set({test::compiler/rustc_type_ir}) + - Set({test::compiler/rustc_type_ir_macros}) + - Set({test::compiler/rustc_windows_rc}) +[Test] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/librustdoc, test::src/tools/rustdoc}) +[Test] test::CrateRustdocJsonTypes + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/rustdoc-json-types}) +[Test] test::CrateBootstrap + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/coverage-dump}) + - Set({test::src/tools/jsondoclint}) + - Set({test::src/tools/replace-version-placeholder}) + - Set({test::tidyselftest}) +[Test] test::Linkcheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/linkchecker}) +[Test] test::TierCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tier-check}) +[Test] test::RustAnalyzer + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-analyzer}) +[Test] test::ErrorIndex + targets: [x86_64-unknown-linux-gnu] + - Set({test::error-index}) + - Set({test::src/tools/error_index_generator}) +[Test] test::RustdocBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustdoc}) +[Test] test::UnstableBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/unstable-book}) +[Test] test::RustcBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustc}) +[Test] test::RustdocJSStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js-std) +[Test] test::RustdocJSNotStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js) +[Test] test::RustdocTheme + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rustdoc-themes}) +[Test] test::RustdocUi + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-ui) +[Test] test::RustdocJson + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-json) +[Test] test::HtmlCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/html-checker}) +[Test] test::RustInstaller + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-installer}) +[Test] test::TestFloatParse + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/test-float-parse}) +[Test] test::RunMake + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make) +[Test] test::RunMakeCargo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make-cargo) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage.snap new file mode 100644 index 000000000000..3b78d842dd70 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test coverage +--- +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/coverage) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_map.snap new file mode 100644 index 000000000000..fd79a0c8ad6a --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_map.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test coverage-map +--- +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Set({test::coverage-map}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_run.snap new file mode 100644 index 000000000000..8ffadc424348 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_run.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test coverage-run +--- +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Set({test::coverage-run}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_skip_coverage_run.snap new file mode 100644 index 000000000000..76da4c82151a --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_coverage_skip_coverage_run.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test coverage --skip=coverage-run +--- +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/coverage) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_debuginfo.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_debuginfo.snap new file mode 100644 index 000000000000..d462e1f7917d --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_debuginfo.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test debuginfo +--- +[Test] test::Debuginfo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/debuginfo) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap new file mode 100644 index 000000000000..dfc397597a87 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap @@ -0,0 +1,20 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test library +--- +[Test] test::Crate + targets: [aarch64-unknown-linux-gnu] + - Set({test::library/alloc}) + - Set({test::library/alloctests}) + - Set({test::library/compiler-builtins/compiler-builtins}) + - Set({test::library/core}) + - Set({test::library/coretests}) + - Set({test::library/panic_abort}) + - Set({test::library/panic_unwind}) + - Set({test::library/proc_macro}) + - Set({test::library/rustc-std-workspace-core}) + - Set({test::library/std}) + - Set({test::library/std_detect}) + - Set({test::library/sysroot}) + - Set({test::library/test}) + - Set({test::library/unwind}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_librustdoc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_librustdoc.snap new file mode 100644 index 000000000000..bd217dbe692a --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_librustdoc.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test librustdoc +--- +[Test] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/librustdoc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_librustdoc_rustdoc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_librustdoc_rustdoc.snap new file mode 100644 index 000000000000..6522a7e8edaf --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_librustdoc_rustdoc.snap @@ -0,0 +1,13 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test librustdoc rustdoc +--- +[Test] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/librustdoc, test::src/tools/rustdoc}) +[Test] test::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc) +[Test] test::RustdocBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustdoc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_rustdoc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_rustdoc.snap new file mode 100644 index 000000000000..337ad33fe35f --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_rustdoc.snap @@ -0,0 +1,13 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test rustdoc +--- +[Test] test::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc) +[Test] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rustdoc}) +[Test] test::RustdocBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustdoc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap new file mode 100644 index 000000000000..04253bba5ef7 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -0,0 +1,211 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test --skip=coverage +--- +[Test] test::Tidy + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tidy}) +[Test] test::Ui + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/ui) +[Test] test::Crashes + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/crashes) +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Set({test::coverage-map}) + - Set({test::coverage-run}) +[Test] test::MirOpt + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/mir-opt) +[Test] test::CodegenLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-llvm) +[Test] test::CodegenUnits + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-units) +[Test] test::AssemblyLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/assembly-llvm) +[Test] test::Incremental + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/incremental) +[Test] test::Debuginfo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/debuginfo) +[Test] test::UiFullDeps + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/ui-fulldeps) +[Test] test::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc) +[Test] test::CoverageRunRustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/coverage-run-rustdoc) +[Test] test::Pretty + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/pretty) +[Test] test::CodegenCranelift + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_cranelift}) +[Test] test::CodegenGCC + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_gcc}) +[Test] test::Crate + targets: [aarch64-unknown-linux-gnu] + - Set({test::library/alloc}) + - Set({test::library/alloctests}) + - Set({test::library/compiler-builtins/compiler-builtins}) + - Set({test::library/core}) + - Set({test::library/coretests}) + - Set({test::library/panic_abort}) + - Set({test::library/panic_unwind}) + - Set({test::library/proc_macro}) + - Set({test::library/rustc-std-workspace-core}) + - Set({test::library/std}) + - Set({test::library/std_detect}) + - Set({test::library/sysroot}) + - Set({test::library/test}) + - Set({test::library/unwind}) +[Test] test::CrateLibrustc + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler}) + - Set({test::compiler/rustc}) + - Set({test::compiler/rustc_abi}) + - Set({test::compiler/rustc_arena}) + - Set({test::compiler/rustc_ast}) + - Set({test::compiler/rustc_ast_ir}) + - Set({test::compiler/rustc_ast_lowering}) + - Set({test::compiler/rustc_ast_passes}) + - Set({test::compiler/rustc_ast_pretty}) + - Set({test::compiler/rustc_attr_parsing}) + - Set({test::compiler/rustc_baked_icu_data}) + - Set({test::compiler/rustc_borrowck}) + - Set({test::compiler/rustc_builtin_macros}) + - Set({test::compiler/rustc_codegen_llvm}) + - Set({test::compiler/rustc_codegen_ssa}) + - Set({test::compiler/rustc_const_eval}) + - Set({test::compiler/rustc_data_structures}) + - Set({test::compiler/rustc_driver}) + - Set({test::compiler/rustc_driver_impl}) + - Set({test::compiler/rustc_error_codes}) + - Set({test::compiler/rustc_error_messages}) + - Set({test::compiler/rustc_errors}) + - Set({test::compiler/rustc_expand}) + - Set({test::compiler/rustc_feature}) + - Set({test::compiler/rustc_fluent_macro}) + - Set({test::compiler/rustc_fs_util}) + - Set({test::compiler/rustc_graphviz}) + - Set({test::compiler/rustc_hashes}) + - Set({test::compiler/rustc_hir}) + - Set({test::compiler/rustc_hir_analysis}) + - Set({test::compiler/rustc_hir_id}) + - Set({test::compiler/rustc_hir_pretty}) + - Set({test::compiler/rustc_hir_typeck}) + - Set({test::compiler/rustc_incremental}) + - Set({test::compiler/rustc_index}) + - Set({test::compiler/rustc_index_macros}) + - Set({test::compiler/rustc_infer}) + - Set({test::compiler/rustc_interface}) + - Set({test::compiler/rustc_lexer}) + - Set({test::compiler/rustc_lint}) + - Set({test::compiler/rustc_lint_defs}) + - Set({test::compiler/rustc_llvm}) + - Set({test::compiler/rustc_log}) + - Set({test::compiler/rustc_macros}) + - Set({test::compiler/rustc_metadata}) + - Set({test::compiler/rustc_middle}) + - Set({test::compiler/rustc_mir_build}) + - Set({test::compiler/rustc_mir_dataflow}) + - Set({test::compiler/rustc_mir_transform}) + - Set({test::compiler/rustc_monomorphize}) + - Set({test::compiler/rustc_next_trait_solver}) + - Set({test::compiler/rustc_parse}) + - Set({test::compiler/rustc_parse_format}) + - Set({test::compiler/rustc_passes}) + - Set({test::compiler/rustc_pattern_analysis}) + - Set({test::compiler/rustc_privacy}) + - Set({test::compiler/rustc_proc_macro}) + - Set({test::compiler/rustc_public}) + - Set({test::compiler/rustc_public_bridge}) + - Set({test::compiler/rustc_query_impl}) + - Set({test::compiler/rustc_query_system}) + - Set({test::compiler/rustc_resolve}) + - Set({test::compiler/rustc_sanitizers}) + - Set({test::compiler/rustc_serialize}) + - Set({test::compiler/rustc_session}) + - Set({test::compiler/rustc_span}) + - Set({test::compiler/rustc_symbol_mangling}) + - Set({test::compiler/rustc_target}) + - Set({test::compiler/rustc_thread_pool}) + - Set({test::compiler/rustc_trait_selection}) + - Set({test::compiler/rustc_traits}) + - Set({test::compiler/rustc_transmute}) + - Set({test::compiler/rustc_ty_utils}) + - Set({test::compiler/rustc_type_ir}) + - Set({test::compiler/rustc_type_ir_macros}) + - Set({test::compiler/rustc_windows_rc}) +[Test] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/librustdoc, test::src/tools/rustdoc}) +[Test] test::CrateRustdocJsonTypes + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/rustdoc-json-types}) +[Test] test::CrateBootstrap + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/coverage-dump}) + - Set({test::src/tools/jsondoclint}) + - Set({test::src/tools/replace-version-placeholder}) + - Set({test::tidyselftest}) +[Test] test::Linkcheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/linkchecker}) +[Test] test::TierCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tier-check}) +[Test] test::RustAnalyzer + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-analyzer}) +[Test] test::ErrorIndex + targets: [x86_64-unknown-linux-gnu] + - Set({test::error-index}) + - Set({test::src/tools/error_index_generator}) +[Test] test::RustdocBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustdoc}) +[Test] test::UnstableBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/unstable-book}) +[Test] test::RustcBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustc}) +[Test] test::RustdocJSStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js-std) +[Test] test::RustdocJSNotStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js) +[Test] test::RustdocTheme + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rustdoc-themes}) +[Test] test::RustdocUi + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-ui) +[Test] test::RustdocJson + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-json) +[Test] test::HtmlCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/html-checker}) +[Test] test::RustInstaller + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-installer}) +[Test] test::TestFloatParse + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/test-float-parse}) +[Test] test::RunMake + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make) +[Test] test::RunMakeCargo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make-cargo) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap new file mode 100644 index 000000000000..f10589548f66 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -0,0 +1,157 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test --skip=tests +--- +[Test] test::Tidy + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tidy}) +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Set({test::coverage-map}) + - Set({test::coverage-run}) +[Test] test::CodegenCranelift + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_cranelift}) +[Test] test::CodegenGCC + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_gcc}) +[Test] test::Crate + targets: [aarch64-unknown-linux-gnu] + - Set({test::library/alloc}) + - Set({test::library/alloctests}) + - Set({test::library/compiler-builtins/compiler-builtins}) + - Set({test::library/core}) + - Set({test::library/coretests}) + - Set({test::library/panic_abort}) + - Set({test::library/panic_unwind}) + - Set({test::library/proc_macro}) + - Set({test::library/rustc-std-workspace-core}) + - Set({test::library/std}) + - Set({test::library/std_detect}) + - Set({test::library/sysroot}) + - Set({test::library/test}) + - Set({test::library/unwind}) +[Test] test::CrateLibrustc + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler}) + - Set({test::compiler/rustc}) + - Set({test::compiler/rustc_abi}) + - Set({test::compiler/rustc_arena}) + - Set({test::compiler/rustc_ast}) + - Set({test::compiler/rustc_ast_ir}) + - Set({test::compiler/rustc_ast_lowering}) + - Set({test::compiler/rustc_ast_passes}) + - Set({test::compiler/rustc_ast_pretty}) + - Set({test::compiler/rustc_attr_parsing}) + - Set({test::compiler/rustc_baked_icu_data}) + - Set({test::compiler/rustc_borrowck}) + - Set({test::compiler/rustc_builtin_macros}) + - Set({test::compiler/rustc_codegen_llvm}) + - Set({test::compiler/rustc_codegen_ssa}) + - Set({test::compiler/rustc_const_eval}) + - Set({test::compiler/rustc_data_structures}) + - Set({test::compiler/rustc_driver}) + - Set({test::compiler/rustc_driver_impl}) + - Set({test::compiler/rustc_error_codes}) + - Set({test::compiler/rustc_error_messages}) + - Set({test::compiler/rustc_errors}) + - Set({test::compiler/rustc_expand}) + - Set({test::compiler/rustc_feature}) + - Set({test::compiler/rustc_fluent_macro}) + - Set({test::compiler/rustc_fs_util}) + - Set({test::compiler/rustc_graphviz}) + - Set({test::compiler/rustc_hashes}) + - Set({test::compiler/rustc_hir}) + - Set({test::compiler/rustc_hir_analysis}) + - Set({test::compiler/rustc_hir_id}) + - Set({test::compiler/rustc_hir_pretty}) + - Set({test::compiler/rustc_hir_typeck}) + - Set({test::compiler/rustc_incremental}) + - Set({test::compiler/rustc_index}) + - Set({test::compiler/rustc_index_macros}) + - Set({test::compiler/rustc_infer}) + - Set({test::compiler/rustc_interface}) + - Set({test::compiler/rustc_lexer}) + - Set({test::compiler/rustc_lint}) + - Set({test::compiler/rustc_lint_defs}) + - Set({test::compiler/rustc_llvm}) + - Set({test::compiler/rustc_log}) + - Set({test::compiler/rustc_macros}) + - Set({test::compiler/rustc_metadata}) + - Set({test::compiler/rustc_middle}) + - Set({test::compiler/rustc_mir_build}) + - Set({test::compiler/rustc_mir_dataflow}) + - Set({test::compiler/rustc_mir_transform}) + - Set({test::compiler/rustc_monomorphize}) + - Set({test::compiler/rustc_next_trait_solver}) + - Set({test::compiler/rustc_parse}) + - Set({test::compiler/rustc_parse_format}) + - Set({test::compiler/rustc_passes}) + - Set({test::compiler/rustc_pattern_analysis}) + - Set({test::compiler/rustc_privacy}) + - Set({test::compiler/rustc_proc_macro}) + - Set({test::compiler/rustc_public}) + - Set({test::compiler/rustc_public_bridge}) + - Set({test::compiler/rustc_query_impl}) + - Set({test::compiler/rustc_query_system}) + - Set({test::compiler/rustc_resolve}) + - Set({test::compiler/rustc_sanitizers}) + - Set({test::compiler/rustc_serialize}) + - Set({test::compiler/rustc_session}) + - Set({test::compiler/rustc_span}) + - Set({test::compiler/rustc_symbol_mangling}) + - Set({test::compiler/rustc_target}) + - Set({test::compiler/rustc_thread_pool}) + - Set({test::compiler/rustc_trait_selection}) + - Set({test::compiler/rustc_traits}) + - Set({test::compiler/rustc_transmute}) + - Set({test::compiler/rustc_ty_utils}) + - Set({test::compiler/rustc_type_ir}) + - Set({test::compiler/rustc_type_ir_macros}) + - Set({test::compiler/rustc_windows_rc}) +[Test] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/librustdoc, test::src/tools/rustdoc}) +[Test] test::CrateRustdocJsonTypes + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/rustdoc-json-types}) +[Test] test::CrateBootstrap + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/coverage-dump}) + - Set({test::src/tools/jsondoclint}) + - Set({test::src/tools/replace-version-placeholder}) + - Set({test::tidyselftest}) +[Test] test::Linkcheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/linkchecker}) +[Test] test::TierCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tier-check}) +[Test] test::RustAnalyzer + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-analyzer}) +[Test] test::ErrorIndex + targets: [x86_64-unknown-linux-gnu] + - Set({test::error-index}) + - Set({test::src/tools/error_index_generator}) +[Test] test::RustdocBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustdoc}) +[Test] test::UnstableBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/unstable-book}) +[Test] test::RustcBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustc}) +[Test] test::RustdocTheme + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rustdoc-themes}) +[Test] test::HtmlCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/html-checker}) +[Test] test::RustInstaller + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-installer}) +[Test] test::TestFloatParse + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/test-float-parse}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap new file mode 100644 index 000000000000..65e05dfaef2d --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap @@ -0,0 +1,136 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test --skip=tests --skip=coverage-map --skip=coverage-run --skip=library --skip=tidyselftest +--- +[Test] test::Tidy + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tidy}) +[Test] test::CodegenCranelift + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_cranelift}) +[Test] test::CodegenGCC + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler/rustc_codegen_gcc}) +[Test] test::CrateLibrustc + targets: [x86_64-unknown-linux-gnu] + - Set({test::compiler}) + - Set({test::compiler/rustc}) + - Set({test::compiler/rustc_abi}) + - Set({test::compiler/rustc_arena}) + - Set({test::compiler/rustc_ast}) + - Set({test::compiler/rustc_ast_ir}) + - Set({test::compiler/rustc_ast_lowering}) + - Set({test::compiler/rustc_ast_passes}) + - Set({test::compiler/rustc_ast_pretty}) + - Set({test::compiler/rustc_attr_parsing}) + - Set({test::compiler/rustc_baked_icu_data}) + - Set({test::compiler/rustc_borrowck}) + - Set({test::compiler/rustc_builtin_macros}) + - Set({test::compiler/rustc_codegen_llvm}) + - Set({test::compiler/rustc_codegen_ssa}) + - Set({test::compiler/rustc_const_eval}) + - Set({test::compiler/rustc_data_structures}) + - Set({test::compiler/rustc_driver}) + - Set({test::compiler/rustc_driver_impl}) + - Set({test::compiler/rustc_error_codes}) + - Set({test::compiler/rustc_error_messages}) + - Set({test::compiler/rustc_errors}) + - Set({test::compiler/rustc_expand}) + - Set({test::compiler/rustc_feature}) + - Set({test::compiler/rustc_fluent_macro}) + - Set({test::compiler/rustc_fs_util}) + - Set({test::compiler/rustc_graphviz}) + - Set({test::compiler/rustc_hashes}) + - Set({test::compiler/rustc_hir}) + - Set({test::compiler/rustc_hir_analysis}) + - Set({test::compiler/rustc_hir_id}) + - Set({test::compiler/rustc_hir_pretty}) + - Set({test::compiler/rustc_hir_typeck}) + - Set({test::compiler/rustc_incremental}) + - Set({test::compiler/rustc_index}) + - Set({test::compiler/rustc_index_macros}) + - Set({test::compiler/rustc_infer}) + - Set({test::compiler/rustc_interface}) + - Set({test::compiler/rustc_lexer}) + - Set({test::compiler/rustc_lint}) + - Set({test::compiler/rustc_lint_defs}) + - Set({test::compiler/rustc_llvm}) + - Set({test::compiler/rustc_log}) + - Set({test::compiler/rustc_macros}) + - Set({test::compiler/rustc_metadata}) + - Set({test::compiler/rustc_middle}) + - Set({test::compiler/rustc_mir_build}) + - Set({test::compiler/rustc_mir_dataflow}) + - Set({test::compiler/rustc_mir_transform}) + - Set({test::compiler/rustc_monomorphize}) + - Set({test::compiler/rustc_next_trait_solver}) + - Set({test::compiler/rustc_parse}) + - Set({test::compiler/rustc_parse_format}) + - Set({test::compiler/rustc_passes}) + - Set({test::compiler/rustc_pattern_analysis}) + - Set({test::compiler/rustc_privacy}) + - Set({test::compiler/rustc_proc_macro}) + - Set({test::compiler/rustc_public}) + - Set({test::compiler/rustc_public_bridge}) + - Set({test::compiler/rustc_query_impl}) + - Set({test::compiler/rustc_query_system}) + - Set({test::compiler/rustc_resolve}) + - Set({test::compiler/rustc_sanitizers}) + - Set({test::compiler/rustc_serialize}) + - Set({test::compiler/rustc_session}) + - Set({test::compiler/rustc_span}) + - Set({test::compiler/rustc_symbol_mangling}) + - Set({test::compiler/rustc_target}) + - Set({test::compiler/rustc_thread_pool}) + - Set({test::compiler/rustc_trait_selection}) + - Set({test::compiler/rustc_traits}) + - Set({test::compiler/rustc_transmute}) + - Set({test::compiler/rustc_ty_utils}) + - Set({test::compiler/rustc_type_ir}) + - Set({test::compiler/rustc_type_ir_macros}) + - Set({test::compiler/rustc_windows_rc}) +[Test] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/librustdoc, test::src/tools/rustdoc}) +[Test] test::CrateRustdocJsonTypes + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/rustdoc-json-types}) +[Test] test::CrateBootstrap + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/coverage-dump}) + - Set({test::src/tools/jsondoclint}) + - Set({test::src/tools/replace-version-placeholder}) +[Test] test::Linkcheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/linkchecker}) +[Test] test::TierCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tier-check}) +[Test] test::RustAnalyzer + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-analyzer}) +[Test] test::ErrorIndex + targets: [x86_64-unknown-linux-gnu] + - Set({test::error-index}) + - Set({test::src/tools/error_index_generator}) +[Test] test::RustdocBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustdoc}) +[Test] test::UnstableBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/unstable-book}) +[Test] test::RustcBook + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/doc/rustc}) +[Test] test::RustdocTheme + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rustdoc-themes}) +[Test] test::HtmlCheck + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/html-checker}) +[Test] test::RustInstaller + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/rust-installer}) +[Test] test::TestFloatParse + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/test-float-parse}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests.snap new file mode 100644 index 000000000000..b38af13d49c3 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests.snap @@ -0,0 +1,64 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test tests +--- +[Test] test::AssemblyLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/assembly-llvm) +[Test] test::CodegenLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-llvm) +[Test] test::CodegenUnits + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-units) +[Test] test::Coverage + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/coverage) +[Test] test::CoverageRunRustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/coverage-run-rustdoc) +[Test] test::Crashes + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/crashes) +[Test] test::Debuginfo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/debuginfo) +[Test] test::Incremental + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/incremental) +[Test] test::MirOpt + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/mir-opt) +[Test] test::Pretty + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/pretty) +[Test] test::RunMake + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make) +[Test] test::RunMakeCargo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make-cargo) +[Test] test::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc) +[Test] test::RustdocGUI + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-gui) +[Test] test::RustdocJSNotStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js) +[Test] test::RustdocJSStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js-std) +[Test] test::RustdocJson + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-json) +[Test] test::RustdocUi + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-ui) +[Test] test::Ui + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/ui) +[Test] test::UiFullDeps + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/ui-fulldeps) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests_skip_coverage.snap new file mode 100644 index 000000000000..6a158ea62bb3 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests_skip_coverage.snap @@ -0,0 +1,61 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test tests --skip=coverage +--- +[Test] test::AssemblyLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/assembly-llvm) +[Test] test::CodegenLlvm + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-llvm) +[Test] test::CodegenUnits + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/codegen-units) +[Test] test::CoverageRunRustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/coverage-run-rustdoc) +[Test] test::Crashes + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/crashes) +[Test] test::Debuginfo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/debuginfo) +[Test] test::Incremental + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/incremental) +[Test] test::MirOpt + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/mir-opt) +[Test] test::Pretty + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/pretty) +[Test] test::RunMake + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make) +[Test] test::RunMakeCargo + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/run-make-cargo) +[Test] test::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc) +[Test] test::RustdocGUI + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-gui) +[Test] test::RustdocJSNotStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js) +[Test] test::RustdocJSStd + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-js-std) +[Test] test::RustdocJson + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-json) +[Test] test::RustdocUi + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/rustdoc-ui) +[Test] test::Ui + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/ui) +[Test] test::UiFullDeps + targets: [x86_64-unknown-linux-gnu] + - Suite(test::tests/ui-fulldeps) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests_ui.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests_ui.snap new file mode 100644 index 000000000000..1288af72fd5d --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tests_ui.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test tests/ui +--- +[Test] test::Ui + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/ui) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tidy.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tidy.snap new file mode 100644 index 000000000000..b2bebf39e120 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tidy.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test tidy +--- +[Test] test::Tidy + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/tidy}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tidyselftest.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tidyselftest.snap new file mode 100644 index 000000000000..945c82ef1cd0 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_tidyselftest.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test tidyselftest +--- +[Test] test::CrateBootstrap + targets: [x86_64-unknown-linux-gnu] + - Set({test::tidyselftest}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_ui.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_ui.snap new file mode 100644 index 000000000000..5c764959cdae --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_ui.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: test ui +--- +[Test] test::Ui + targets: [aarch64-unknown-linux-gnu] + - Suite(test::tests/ui) diff --git a/src/bootstrap/src/core/builder/cli_paths/tests.rs b/src/bootstrap/src/core/builder/cli_paths/tests.rs index 614c67f36253..7115d400c844 100644 --- a/src/bootstrap/src/core/builder/cli_paths/tests.rs +++ b/src/bootstrap/src/core/builder/cli_paths/tests.rs @@ -132,5 +132,47 @@ macro_rules! declare_tests { declare_tests!( // tidy-alphabetical-start (x_build, "build"), + (x_build_compiler, "build compiler"), + (x_build_compiletest, "build compiletest"), + (x_build_library, "build library"), + (x_build_llvm, "build llvm"), + (x_build_rustc, "build rustc"), + (x_build_rustc_llvm, "build rustc_llvm"), + (x_build_rustdoc, "build rustdoc"), + (x_build_sysroot, "build sysroot"), + (x_check, "check"), + (x_check_bootstrap, "check bootstrap"), + (x_check_compiler, "check compiler"), + (x_check_compiletest, "check compiletest"), + (x_check_compiletest_include_default_paths, "check compiletest --include-default-paths"), + (x_check_library, "check library"), + (x_check_rustc, "check rustc"), + (x_check_rustdoc, "check rustdoc"), + (x_dist, "dist"), + (x_test, "test"), + (x_test_coverage, "test coverage"), + (x_test_coverage_map, "test coverage-map"), + (x_test_coverage_run, "test coverage-run"), + // FIXME(Zalathar): Currently this doesn't actually skip the coverage-run tests! + (x_test_coverage_skip_coverage_run, "test coverage --skip=coverage-run"), + (x_test_debuginfo, "test debuginfo"), + (x_test_library, "test library"), + (x_test_librustdoc, "test librustdoc"), + (x_test_librustdoc_rustdoc, "test librustdoc rustdoc"), + (x_test_rustdoc, "test rustdoc"), + (x_test_skip_coverage, "test --skip=coverage"), + // FIXME(Zalathar): This doesn't skip the coverage-map or coverage-run tests. + (x_test_skip_tests, "test --skip=tests"), + // From `src/ci/docker/scripts/stage_2_test_set2.sh`. + ( + x_test_skip_tests_etc, + "test --skip=tests --skip=coverage-map --skip=coverage-run --skip=library --skip=tidyselftest" + ), + (x_test_tests, "test tests"), + (x_test_tests_skip_coverage, "test tests --skip=coverage"), + (x_test_tests_ui, "test tests/ui"), + (x_test_tidy, "test tidy"), + (x_test_tidyselftest, "test tidyselftest"), + (x_test_ui, "test ui"), // tidy-alphabetical-end ); From 9f3d84b226b7cf0edbad98566d49cfb8ea129b9f Mon Sep 17 00:00:00 2001 From: Liigo Zhuang Date: Tue, 4 Nov 2025 17:08:52 +0800 Subject: [PATCH 081/108] rustdoc: add `=` shortcut to expand all sections. Essentially, `=` is "`+` without shift". Current `+` shortcut requires an extra `shift`, unless you use numpad `+`. --- src/librustdoc/html/static/js/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 3ea9de381eca..dff40485e9a9 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -683,6 +683,7 @@ function preLoadCss(cssUrl) { break; case "+": + case "=": ev.preventDefault(); expandAllDocs(); break; @@ -1620,7 +1621,7 @@ function preLoadCss(cssUrl) { ["↓", "Move down in search results"], ["← / β†’", "Switch result tab (when results focused)"], ["⏎", "Go to active search result"], - ["+", "Expand all sections"], + ["+ / =", "Expand all sections"], ["-", "Collapse all sections"], // for the sake of brevity, we don't say "inherit impl blocks", // although that would be more correct, From 4a2c9a11d5ae222a5669586755ce469cdd09960e Mon Sep 17 00:00:00 2001 From: yukang Date: Wed, 12 Nov 2025 17:47:15 +0800 Subject: [PATCH 082/108] skip invalid span in error emitter --- .../src/annotate_snippet_emitter_writer.rs | 27 +++++++++++-------- .../ice-line-bounds-issue-148732.stderr | 3 --- .../ice-line-bounds-issue-148684.stderr | 6 ----- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index 4756909d3187..5b1fffd21d18 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -350,22 +350,27 @@ impl AnnotateSnippetEmitter { "all spans must be disjoint", ); + let lo = subst.parts.iter().map(|part| part.span.lo()).min()?; + let lo_file = sm.lookup_source_file(lo); + let hi = subst.parts.iter().map(|part| part.span.hi()).max()?; + let hi_file = sm.lookup_source_file(hi); + + // The different spans might belong to different contexts, if so ignore suggestion. + if lo_file.stable_id != hi_file.stable_id { + return None; + } + + // We can't splice anything if the source is unavailable. + if !sm.ensure_source_file_source_present(&lo_file) { + return None; + } + // Account for cases where we are suggesting the same code that's already // there. This shouldn't happen often, but in some cases for multipart // suggestions it's much easier to handle it here than in the origin. subst.parts.retain(|p| is_different(sm, &p.snippet, p.span)); - let item_span = subst.parts.first()?; - let file = sm.lookup_source_file(item_span.span.lo()); - if should_show_source_code( - &self.ignored_directories_in_source_blocks, - sm, - &file, - ) { - Some(subst) - } else { - None - } + if subst.parts.is_empty() { None } else { Some(subst) } }) .collect::>(); diff --git a/tests/ui/delegation/ice-line-bounds-issue-148732.stderr b/tests/ui/delegation/ice-line-bounds-issue-148732.stderr index 7cbba401724a..c65b1560818d 100644 --- a/tests/ui/delegation/ice-line-bounds-issue-148732.stderr +++ b/tests/ui/delegation/ice-line-bounds-issue-148732.stderr @@ -1,6 +1,3 @@ - WARN rustc_errors::emitter Invalid span $SRC_DIR/std/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/std/src/macros.rs" }) } - WARN rustc_errors::emitter Invalid span $SRC_DIR/std/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/std/src/macros.rs" }) } - WARN rustc_errors::emitter Invalid span $SRC_DIR/std/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/std/src/macros.rs" }) } error[E0106]: missing lifetime specifier --> $DIR/ice-line-bounds-issue-148732.rs:4:5 | diff --git a/tests/ui/structs/ice-line-bounds-issue-148684.stderr b/tests/ui/structs/ice-line-bounds-issue-148684.stderr index d6900a9fd6ac..f26d96cd1172 100644 --- a/tests/ui/structs/ice-line-bounds-issue-148684.stderr +++ b/tests/ui/structs/ice-line-bounds-issue-148684.stderr @@ -1,9 +1,3 @@ - WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } - WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } - WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } - WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } - WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } - WARN rustc_errors::emitter Invalid span $SRC_DIR/alloc/src/macros.rs:LL:COL (#4), error=SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "$SRC_DIR/alloc/src/macros.rs" }) } error[E0423]: expected function, tuple struct or tuple variant, found struct `A` --> $DIR/ice-line-bounds-issue-148684.rs:7:5 | From 756751bf0cd1e843b31a6ca00eecabc1ab65ecb6 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 5 Nov 2025 11:37:23 +0100 Subject: [PATCH 083/108] Expose expr_unsafe in LoweringContext. --- compiler/rustc_ast_lowering/src/expr.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index c6f24c1a19b4..b602577e18ea 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -924,7 +924,7 @@ impl<'hir> LoweringContext<'_, 'hir> { arena_vec![self; new_unchecked, get_context], ), }; - self.arena.alloc(self.expr_unsafe(call)) + self.arena.alloc(self.expr_unsafe(span, call)) }; // `::std::task::Poll::Ready(result) => break result` @@ -1832,7 +1832,7 @@ impl<'hir> LoweringContext<'_, 'hir> { arena_vec![self; iter], )); // `unsafe { ... }` - let iter = self.arena.alloc(self.expr_unsafe(iter)); + let iter = self.arena.alloc(self.expr_unsafe(head_span, iter)); let kind = self.make_lowered_await(head_span, iter, FutureKind::AsyncIterator); self.arena.alloc(hir::Expr { hir_id: self.next_id(), kind, span: head_span }) } @@ -1887,7 +1887,7 @@ impl<'hir> LoweringContext<'_, 'hir> { arena_vec![self; iter], )); // `unsafe { ... }` - let iter = self.arena.alloc(self.expr_unsafe(iter)); + let iter = self.arena.alloc(self.expr_unsafe(head_span, iter)); let inner_match_expr = self.arena.alloc(self.expr_match( for_span, iter, @@ -2262,9 +2262,12 @@ impl<'hir> LoweringContext<'_, 'hir> { self.expr(span, expr_path) } - fn expr_unsafe(&mut self, expr: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> { + pub(super) fn expr_unsafe( + &mut self, + span: Span, + expr: &'hir hir::Expr<'hir>, + ) -> hir::Expr<'hir> { let hir_id = self.next_id(); - let span = expr.span; self.expr( span, hir::ExprKind::Block( From d66d15be2b28d4d8ee7d0d83589d8ea98e3f096a Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 10 Nov 2025 15:10:52 +0100 Subject: [PATCH 084/108] New format_args!()+fmt::Arguments implementation. --- compiler/rustc_ast_lowering/src/expr.rs | 39 +- compiler/rustc_ast_lowering/src/format.rs | 456 +++++++++------------- compiler/rustc_hir/src/lang_items.rs | 3 - compiler/rustc_span/src/symbol.rs | 5 +- library/core/src/fmt/mod.rs | 231 ++++++----- library/core/src/fmt/rt.rs | 81 +--- library/core/src/panicking.rs | 20 +- library/core/src/ub_checks.rs | 2 +- 8 files changed, 368 insertions(+), 469 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index b602577e18ea..f904b2b670a2 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -13,7 +13,7 @@ use rustc_middle::span_bug; use rustc_middle::ty::TyCtxt; use rustc_session::errors::report_lit_error; use rustc_span::source_map::{Spanned, respan}; -use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym}; +use rustc_span::{ByteSymbol, DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym}; use thin_vec::{ThinVec, thin_vec}; use visit::{Visitor, walk_expr}; @@ -2103,26 +2103,6 @@ impl<'hir> LoweringContext<'_, 'hir> { self.arena.alloc(self.expr(sp, hir::ExprKind::Tup(&[]))) } - fn expr_uint(&mut self, sp: Span, ty: ast::UintTy, value: u128) -> hir::Expr<'hir> { - let lit = hir::Lit { - span: self.lower_span(sp), - node: ast::LitKind::Int(value.into(), ast::LitIntType::Unsigned(ty)), - }; - self.expr(sp, hir::ExprKind::Lit(lit)) - } - - pub(super) fn expr_usize(&mut self, sp: Span, value: usize) -> hir::Expr<'hir> { - self.expr_uint(sp, ast::UintTy::Usize, value as u128) - } - - pub(super) fn expr_u32(&mut self, sp: Span, value: u32) -> hir::Expr<'hir> { - self.expr_uint(sp, ast::UintTy::U32, value as u128) - } - - pub(super) fn expr_u16(&mut self, sp: Span, value: u16) -> hir::Expr<'hir> { - self.expr_uint(sp, ast::UintTy::U16, value as u128) - } - pub(super) fn expr_str(&mut self, sp: Span, value: Symbol) -> hir::Expr<'hir> { let lit = hir::Lit { span: self.lower_span(sp), @@ -2131,6 +2111,14 @@ impl<'hir> LoweringContext<'_, 'hir> { self.expr(sp, hir::ExprKind::Lit(lit)) } + pub(super) fn expr_byte_str(&mut self, sp: Span, value: ByteSymbol) -> hir::Expr<'hir> { + let lit = hir::Lit { + span: self.lower_span(sp), + node: ast::LitKind::ByteStr(value, ast::StrStyle::Cooked), + }; + self.expr(sp, hir::ExprKind::Lit(lit)) + } + pub(super) fn expr_call_mut( &mut self, span: Span, @@ -2305,15 +2293,6 @@ impl<'hir> LoweringContext<'_, 'hir> { self.arena.alloc(self.expr_block(b)) } - pub(super) fn expr_array_ref( - &mut self, - span: Span, - elements: &'hir [hir::Expr<'hir>], - ) -> hir::Expr<'hir> { - let array = self.arena.alloc(self.expr(span, hir::ExprKind::Array(elements))); - self.expr_ref(span, array) - } - pub(super) fn expr_ref(&mut self, span: Span, expr: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> { self.expr(span, hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Not, expr)) } diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index c5bbc2b81188..526dfcd744da 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -4,7 +4,7 @@ use rustc_ast::*; use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; use rustc_session::config::FmtDebug; -use rustc_span::{DesugaringKind, Ident, Span, Symbol, sym}; +use rustc_span::{ByteSymbol, DesugaringKind, Ident, Span, Symbol, sym}; use super::LoweringContext; @@ -89,28 +89,31 @@ impl<'hir> LoweringContext<'_, 'hir> { let mut was_inlined = vec![false; fmt.arguments.all_args().len()]; let mut inlined_anything = false; - for i in 0..fmt.template.len() { - let FormatArgsPiece::Placeholder(placeholder) = &fmt.template[i] else { continue }; - let Ok(arg_index) = placeholder.argument.index else { continue }; + let mut i = 0; - let mut literal = None; - - if let FormatTrait::Display = placeholder.format_trait + while i < fmt.template.len() { + if let FormatArgsPiece::Placeholder(placeholder) = &fmt.template[i] + && let Ok(arg_index) = placeholder.argument.index + && let FormatTrait::Display = placeholder.format_trait && placeholder.format_options == Default::default() && let arg = fmt.arguments.all_args()[arg_index].expr.peel_parens_and_refs() && let ExprKind::Lit(lit) = arg.kind + && let Some(literal) = self.try_inline_lit(lit) { - literal = self.try_inline_lit(lit); - } - - if let Some(literal) = literal { // Now we need to mutate the outer FormatArgs. // If this is the first time, this clones the outer FormatArgs. let fmt = fmt.to_mut(); // Replace the placeholder with the literal. - fmt.template[i] = FormatArgsPiece::Literal(literal); + if literal.is_empty() { + fmt.template.remove(i); + } else { + fmt.template[i] = FormatArgsPiece::Literal(literal); + i += 1; + } was_inlined[arg_index] = true; inlined_anything = true; + } else { + i += 1; } } @@ -265,136 +268,21 @@ fn make_argument<'hir>( ctx.expr_call_mut(sp, new_fn, std::slice::from_ref(arg)) } -/// Generate a hir expression for a format_args Count. +/// Get the value for a `width` or `precision` field. /// -/// Generates: -/// -/// ```text -/// ::Is(…) -/// ``` -/// -/// or -/// -/// ```text -/// ::Param(…) -/// ``` -/// -/// or -/// -/// ```text -/// ::Implied -/// ``` -fn make_count<'hir>( - ctx: &mut LoweringContext<'_, 'hir>, - sp: Span, - count: &Option, +/// Returns the value and whether it is indirect (an indexed argument) or not. +fn make_count( + count: &FormatCount, argmap: &mut FxIndexMap<(usize, ArgumentType), Option>, -) -> hir::Expr<'hir> { +) -> (bool, u16) { match count { - Some(FormatCount::Literal(n)) => { - let count_is = ctx.arena.alloc(ctx.expr_lang_item_type_relative( - sp, - hir::LangItem::FormatCount, - sym::Is, - )); - let value = ctx.arena.alloc_from_iter([ctx.expr_u16(sp, *n)]); - ctx.expr_call_mut(sp, count_is, value) - } - Some(FormatCount::Argument(arg)) => { - if let Ok(arg_index) = arg.index { - let (i, _) = argmap.insert_full((arg_index, ArgumentType::Usize), arg.span); - let count_param = ctx.arena.alloc(ctx.expr_lang_item_type_relative( - sp, - hir::LangItem::FormatCount, - sym::Param, - )); - let value = ctx.arena.alloc_from_iter([ctx.expr_usize(sp, i)]); - ctx.expr_call_mut(sp, count_param, value) - } else { - ctx.expr( - sp, - hir::ExprKind::Err( - ctx.dcx().span_delayed_bug(sp, "lowered bad format_args count"), - ), - ) - } - } - None => ctx.expr_lang_item_type_relative(sp, hir::LangItem::FormatCount, sym::Implied), - } -} - -/// Generate a hir expression for a format_args placeholder specification. -/// -/// Generates -/// -/// ```text -/// , -/// width: , -/// } -/// ``` -fn make_format_spec<'hir>( - ctx: &mut LoweringContext<'_, 'hir>, - sp: Span, - placeholder: &FormatPlaceholder, - argmap: &mut FxIndexMap<(usize, ArgumentType), Option>, -) -> hir::Expr<'hir> { - let position = match placeholder.argument.index { - Ok(arg_index) => { - let (i, _) = argmap.insert_full( - (arg_index, ArgumentType::Format(placeholder.format_trait)), - placeholder.span, - ); - ctx.expr_usize(sp, i) - } - Err(_) => ctx.expr( - sp, - hir::ExprKind::Err(ctx.dcx().span_delayed_bug(sp, "lowered bad format_args count")), + FormatCount::Literal(n) => (false, *n), + FormatCount::Argument(arg) => ( + true, + argmap.insert_full((arg.index.unwrap_or(usize::MAX), ArgumentType::Usize), arg.span).0 + as u16, ), - }; - let &FormatOptions { - ref width, - ref precision, - alignment, - fill, - sign, - alternate, - zero_pad, - debug_hex, - } = &placeholder.format_options; - let fill = fill.unwrap_or(' '); - // These need to match the constants in library/core/src/fmt/rt.rs. - let align = match alignment { - Some(FormatAlignment::Left) => 0, - Some(FormatAlignment::Right) => 1, - Some(FormatAlignment::Center) => 2, - None => 3, - }; - // This needs to match the constants in library/core/src/fmt/rt.rs. - let flags: u32 = fill as u32 - | ((sign == Some(FormatSign::Plus)) as u32) << 21 - | ((sign == Some(FormatSign::Minus)) as u32) << 22 - | (alternate as u32) << 23 - | (zero_pad as u32) << 24 - | ((debug_hex == Some(FormatDebugHex::Lower)) as u32) << 25 - | ((debug_hex == Some(FormatDebugHex::Upper)) as u32) << 26 - | (width.is_some() as u32) << 27 - | (precision.is_some() as u32) << 28 - | align << 29 - | 1 << 31; // Highest bit always set. - let flags = ctx.expr_u32(sp, flags); - let precision = make_count(ctx, sp, precision, argmap); - let width = make_count(ctx, sp, width, argmap); - let position = ctx.expr_field(Ident::new(sym::position, sp), ctx.arena.alloc(position), sp); - let flags = ctx.expr_field(Ident::new(sym::flags, sp), ctx.arena.alloc(flags), sp); - let precision = ctx.expr_field(Ident::new(sym::precision, sp), ctx.arena.alloc(precision), sp); - let width = ctx.expr_field(Ident::new(sym::width, sp), ctx.arena.alloc(width), sp); - let placeholder = - ctx.arena.alloc(ctx.make_lang_item_qpath(hir::LangItem::FormatPlaceholder, sp, None)); - let fields = ctx.arena.alloc_from_iter([position, flags, precision, width]); - ctx.expr(sp, hir::ExprKind::Struct(placeholder, fields, hir::StructTailExpr::None)) + } } fn expand_format_args<'hir>( @@ -405,85 +293,135 @@ fn expand_format_args<'hir>( ) -> hir::ExprKind<'hir> { let macsp = ctx.lower_span(macsp); - let mut incomplete_lit = String::new(); - let lit_pieces = - ctx.arena.alloc_from_iter(fmt.template.iter().enumerate().filter_map(|(i, piece)| { - match piece { - &FormatArgsPiece::Literal(s) => { - // Coalesce adjacent literal pieces. - if let Some(FormatArgsPiece::Literal(_)) = fmt.template.get(i + 1) { - incomplete_lit.push_str(s.as_str()); - None - } else if !incomplete_lit.is_empty() { - incomplete_lit.push_str(s.as_str()); - let s = Symbol::intern(&incomplete_lit); - incomplete_lit.clear(); - Some(ctx.expr_str(fmt.span, s)) - } else { - Some(ctx.expr_str(fmt.span, s)) - } - } - &FormatArgsPiece::Placeholder(_) => { - // Inject empty string before placeholders when not already preceded by a literal piece. - if i == 0 || matches!(fmt.template[i - 1], FormatArgsPiece::Placeholder(_)) { - Some(ctx.expr_str(fmt.span, sym::empty)) - } else { - None - } - } - } - })); - let lit_pieces = ctx.expr_array_ref(fmt.span, lit_pieces); - - // Whether we'll use the `Arguments::new_v1_formatted` form (true), - // or the `Arguments::new_v1` form (false). - let mut use_format_options = false; - // Create a list of all _unique_ (argument, format trait) combinations. // E.g. "{0} {0:x} {0} {1}" -> [(0, Display), (0, LowerHex), (1, Display)] + // + // We use usize::MAX for arguments that don't exist, because that can never be a valid index + // into the arguments array. let mut argmap = FxIndexMap::default(); - for piece in &fmt.template { - let FormatArgsPiece::Placeholder(placeholder) = piece else { continue }; - if placeholder.format_options != Default::default() { - // Can't use basic form if there's any formatting options. - use_format_options = true; - } - if let Ok(index) = placeholder.argument.index { - if argmap - .insert((index, ArgumentType::Format(placeholder.format_trait)), placeholder.span) - .is_some() - { - // Duplicate (argument, format trait) combination, - // which we'll only put once in the args array. - use_format_options = true; + + let mut incomplete_lit = String::new(); + + let mut implicit_arg_index = 0; + + let mut bytecode = Vec::new(); + + let template = if fmt.template.is_empty() { + // Treat empty templates as a single literal piece (with an empty string), + // so we produce `from_str("")` for those. + &[FormatArgsPiece::Literal(sym::empty)][..] + } else { + &fmt.template[..] + }; + + for (i, piece) in template.iter().enumerate() { + match piece { + &FormatArgsPiece::Literal(sym) => { + // Coalesce adjacent literal pieces. + if let Some(FormatArgsPiece::Literal(_)) = template.get(i + 1) { + incomplete_lit.push_str(sym.as_str()); + continue; + } + let mut s = if incomplete_lit.is_empty() { + sym.as_str() + } else { + incomplete_lit.push_str(sym.as_str()); + &incomplete_lit + }; + + // If this is the last piece and was the only piece, that means + // there are no placeholders and the entire format string is just a literal. + // + // In that case, we can just use `from_str`. + if i + 1 == template.len() && bytecode.is_empty() { + // Generate: + // ::from_str("meow") + let from_str = ctx.arena.alloc(ctx.expr_lang_item_type_relative( + macsp, + hir::LangItem::FormatArguments, + if allow_const { sym::from_str } else { sym::from_str_nonconst }, + )); + let sym = if incomplete_lit.is_empty() { sym } else { Symbol::intern(s) }; + let s = ctx.expr_str(fmt.span, sym); + let args = ctx.arena.alloc_from_iter([s]); + return hir::ExprKind::Call(from_str, args); + } + + while !s.is_empty() { + let len = s.floor_char_boundary(127); + bytecode.push(len as u8); + bytecode.extend(&s.as_bytes()[..len]); + s = &s[len..]; + } + + incomplete_lit.clear(); + } + FormatArgsPiece::Placeholder(p) => { + let i = bytecode.len(); + bytecode.push(0x80); + + let position = argmap + .insert_full( + ( + p.argument.index.unwrap_or(usize::MAX), + ArgumentType::Format(p.format_trait), + ), + p.span, + ) + .0 as u64; + + // This needs to match the constants in library/core/src/fmt/rt.rs. + let o = &p.format_options; + let align = match o.alignment { + Some(FormatAlignment::Left) => 0, + Some(FormatAlignment::Right) => 1, + Some(FormatAlignment::Center) => 2, + None => 3, + }; + let flags: u32 = o.fill.unwrap_or(' ') as u32 + | ((o.sign == Some(FormatSign::Plus)) as u32) << 21 + | ((o.sign == Some(FormatSign::Minus)) as u32) << 22 + | (o.alternate as u32) << 23 + | (o.zero_pad as u32) << 24 + | ((o.debug_hex == Some(FormatDebugHex::Lower)) as u32) << 25 + | ((o.debug_hex == Some(FormatDebugHex::Upper)) as u32) << 26 + | (o.width.is_some() as u32) << 27 + | (o.precision.is_some() as u32) << 28 + | align << 29 + | 1 << 31; + if flags != 0xE000_0020 { + bytecode[i] |= 1; + bytecode.extend_from_slice(&flags.to_le_bytes()); + if let Some(val) = &o.width { + let (indirect, val) = make_count(val, &mut argmap); + bytecode[i] |= 1 << 1 | (indirect as u8) << 4; + bytecode.extend_from_slice(&val.to_le_bytes()); + } + if let Some(val) = &o.precision { + let (indirect, val) = make_count(val, &mut argmap); + bytecode[i] |= 1 << 2 | (indirect as u8) << 5; + bytecode.extend_from_slice(&val.to_le_bytes()); + } + } + if implicit_arg_index != position { + bytecode[i] |= 1 << 3; + bytecode.extend_from_slice(&(position as u16).to_le_bytes()); + } + implicit_arg_index = position + 1; } } } - let format_options = use_format_options.then(|| { - // Generate: - // &[format_spec_0, format_spec_1, format_spec_2] - let elements = ctx.arena.alloc_from_iter(fmt.template.iter().filter_map(|piece| { - let FormatArgsPiece::Placeholder(placeholder) = piece else { return None }; - Some(make_format_spec(ctx, macsp, placeholder, &mut argmap)) - })); - ctx.expr_array_ref(macsp, elements) - }); + assert!(incomplete_lit.is_empty()); + + // Zero terminator. + bytecode.push(0); + + // Ensure all argument indexes actually fit in 16 bits, as we truncated them to 16 bits before. + assert!(argmap.len() <= u16::MAX as usize); let arguments = fmt.arguments.all_args(); - if allow_const && arguments.is_empty() && argmap.is_empty() { - // Generate: - // ::new_const(lit_pieces) - let new = ctx.arena.alloc(ctx.expr_lang_item_type_relative( - macsp, - hir::LangItem::FormatArguments, - sym::new_const, - )); - let new_args = ctx.arena.alloc_from_iter([lit_pieces]); - return hir::ExprKind::Call(new, new_args); - } - let (let_statements, args) = if arguments.is_empty() { // Generate: // [] @@ -512,22 +450,30 @@ fn expand_format_args<'hir>( // ]; let args = ctx.arena.alloc_from_iter(argmap.iter().map( |(&(arg_index, ty), &placeholder_span)| { - let arg = &arguments[arg_index]; - let placeholder_span = - placeholder_span.unwrap_or(arg.expr.span).with_ctxt(macsp.ctxt()); - let arg_span = match arg.kind { - FormatArgumentKind::Captured(_) => placeholder_span, - _ => arg.expr.span.with_ctxt(macsp.ctxt()), - }; - let args_ident_expr = ctx.expr_ident(macsp, args_ident, args_hir_id); - let arg = ctx.arena.alloc(ctx.expr( - arg_span, - hir::ExprKind::Field( - args_ident_expr, - Ident::new(sym::integer(arg_index), macsp), - ), - )); - make_argument(ctx, placeholder_span, arg, ty) + if let Some(arg) = arguments.get(arg_index) { + let placeholder_span = + placeholder_span.unwrap_or(arg.expr.span).with_ctxt(macsp.ctxt()); + let arg_span = match arg.kind { + FormatArgumentKind::Captured(_) => placeholder_span, + _ => arg.expr.span.with_ctxt(macsp.ctxt()), + }; + let args_ident_expr = ctx.expr_ident(macsp, args_ident, args_hir_id); + let arg = ctx.arena.alloc(ctx.expr( + arg_span, + hir::ExprKind::Field( + args_ident_expr, + Ident::new(sym::integer(arg_index), macsp), + ), + )); + make_argument(ctx, placeholder_span, arg, ty) + } else { + ctx.expr( + macsp, + hir::ExprKind::Err( + ctx.dcx().span_delayed_bug(macsp, "missing format_args argument"), + ), + ) + } }, )); let args = ctx.arena.alloc(ctx.expr(macsp, hir::ExprKind::Array(args))); @@ -540,58 +486,38 @@ fn expand_format_args<'hir>( }; // Generate: - // &args - let args = ctx.expr_ref(macsp, args); - - let call = if let Some(format_options) = format_options { - // Generate: - // unsafe { - // ::new_v1_formatted( - // lit_pieces, - // args, - // format_options, - // ) - // } - let new_v1_formatted = ctx.arena.alloc(ctx.expr_lang_item_type_relative( + // unsafe { + // ::new(b"…", &args) + // } + let template = ctx.expr_byte_str(macsp, ByteSymbol::intern(&bytecode)); + let call = { + let new = ctx.arena.alloc(ctx.expr_lang_item_type_relative( macsp, hir::LangItem::FormatArguments, - sym::new_v1_formatted, + sym::new, )); - let args = ctx.arena.alloc_from_iter([lit_pieces, args, format_options]); - let call = ctx.expr_call(macsp, new_v1_formatted, args); - let hir_id = ctx.next_id(); - hir::ExprKind::Block( - ctx.arena.alloc(hir::Block { - stmts: &[], - expr: Some(call), - hir_id, - rules: hir::BlockCheckMode::UnsafeBlock(hir::UnsafeSource::CompilerGenerated), - span: macsp, - targeted_by_break: false, - }), - None, - ) - } else { - // Generate: - // ::new_v1( - // lit_pieces, - // args, - // ) - let new_v1 = ctx.arena.alloc(ctx.expr_lang_item_type_relative( - macsp, - hir::LangItem::FormatArguments, - sym::new_v1, - )); - let new_args = ctx.arena.alloc_from_iter([lit_pieces, args]); - hir::ExprKind::Call(new_v1, new_args) + let args = ctx.expr_ref(macsp, args); + let new_args = ctx.arena.alloc_from_iter([template, args]); + ctx.expr_call(macsp, new, new_args) }; + let call = hir::ExprKind::Block( + ctx.arena.alloc(hir::Block { + stmts: &[], + expr: Some(call), + hir_id: ctx.next_id(), + rules: hir::BlockCheckMode::UnsafeBlock(hir::UnsafeSource::CompilerGenerated), + span: macsp, + targeted_by_break: false, + }), + None, + ); if !let_statements.is_empty() { // Generate: // { // super let … // super let … - // ::new_…(…) + // ::new(…) // } let call = ctx.arena.alloc(ctx.expr(macsp, call)); let block = ctx.block_all(macsp, ctx.arena.alloc_from_iter(let_statements), Some(call)); diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index 20bf742e7fc7..ed0cf2716028 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -329,9 +329,6 @@ language_item_table! { // Lang items needed for `format_args!()`. FormatArgument, sym::format_argument, format_argument, Target::Struct, GenericRequirement::None; FormatArguments, sym::format_arguments, format_arguments, Target::Struct, GenericRequirement::None; - FormatCount, sym::format_count, format_count, Target::Enum, GenericRequirement::None; - FormatPlaceholder, sym::format_placeholder, format_placeholder, Target::Struct, GenericRequirement::None; - FormatUnsafeArg, sym::format_unsafe_arg, format_unsafe_arg, Target::Struct, GenericRequirement::None; ExchangeMalloc, sym::exchange_malloc, exchange_malloc_fn, Target::Fn, GenericRequirement::None; DropInPlace, sym::drop_in_place, drop_in_place_fn, Target::Fn, GenericRequirement::Minimum(1); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 60a5aa2378e2..a4d86e5df9a9 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1096,10 +1096,7 @@ symbols! { format_args_nl, format_argument, format_arguments, - format_count, format_macro, - format_placeholder, - format_unsafe_arg, framework, freeze, freeze_impls, @@ -1114,7 +1111,9 @@ symbols! { from_output, from_residual, from_size_align_unchecked, + from_str, from_str_method, + from_str_nonconst, from_u16, from_usize, from_yeet, diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 502ca4aefe10..43355cc98628 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -7,7 +7,8 @@ use crate::char::{EscapeDebugExtArgs, MAX_LEN_UTF8}; use crate::marker::{PhantomData, PointeeSized}; use crate::num::fmt as numfmt; use crate::ops::Deref; -use crate::{iter, result, str}; +use crate::ptr::NonNull; +use crate::{iter, mem, result, str}; mod builders; #[cfg(not(no_fp_fmt_parse))] @@ -616,15 +617,8 @@ impl<'a> Formatter<'a> { #[stable(feature = "rust1", since = "1.0.0")] #[derive(Copy, Clone)] pub struct Arguments<'a> { - // Format string pieces to print. - pieces: &'a [&'static str], - - // Placeholder specs, or `None` if all specs are default (as in "{}{}"). - fmt: Option<&'a [rt::Placeholder]>, - - // Dynamic arguments for interpolation, to be interleaved with string - // pieces. (Every argument is preceded by a string piece.) - args: &'a [rt::Argument<'a>], + template: NonNull, + args: NonNull>, } #[doc(hidden)] @@ -636,20 +630,49 @@ impl<'a> Arguments<'a> { /// when using `format!`. Note: this is neither the lower nor upper bound. #[inline] pub fn estimated_capacity(&self) -> usize { - let pieces_length: usize = self.pieces.iter().map(|x| x.len()).sum(); + if let Some(s) = self.as_str() { + return s.len(); + } + // Iterate over the template, counting the length of literal pieces. + let mut length = 0usize; + let mut starts_with_placeholder = false; + let mut template = self.template; + loop { + // SAFETY: We can assume the template is valid. + unsafe { + let n = template.read(); + if n == 0 { + // End of template. + break; + } else if n < 128 { + // Literal string piece. + length += n as usize; + template = template.add(1 + n as usize); + } else { + // Placeholder piece. + if length == 0 { + starts_with_placeholder = true; + } + // Skip remainder of placeholder: + let skip = (n & 1 == 1) as usize * 4 + + (n & 2 == 2) as usize * 2 + + (n & 4 == 4) as usize * 2 + + (n & 8 == 8) as usize * 2; + template = template.add(1 + skip as usize); + } + } + } - if self.args.is_empty() { - pieces_length - } else if !self.pieces.is_empty() && self.pieces[0].is_empty() && pieces_length < 16 { - // If the format string starts with an argument, + if starts_with_placeholder && length < 16 { + // If the format string starts with a placeholder, // don't preallocate anything, unless length - // of pieces is significant. + // of literal pieces is significant. 0 } else { - // There are some arguments, so any additional push + // There are some placeholders, so any additional push // will reallocate the string. To avoid that, // we're "pre-doubling" the capacity here. - pieces_length.checked_mul(2).unwrap_or(0) + length.wrapping_mul(2) } } } @@ -702,10 +725,20 @@ impl<'a> Arguments<'a> { #[must_use] #[inline] pub const fn as_str(&self) -> Option<&'static str> { - match (self.pieces, self.args) { - ([], []) => Some(""), - ([s], []) => Some(s), - _ => None, + // SAFETY: During const eval, `self.args` must have come from a usize, + // not a pointer, because that's the only way to creat a fmt::Arguments in const. + // Outside const eval, transmuting a pointer to a usize is fine. + let bits: usize = unsafe { mem::transmute(self.args) }; + if bits & 1 == 1 { + // SAFETY: This fmt::Arguments stores a &'static str. + Some(unsafe { + str::from_utf8_unchecked(crate::slice::from_raw_parts( + self.template.as_ptr(), + bits >> 1, + )) + }) + } else { + None } } @@ -1448,86 +1481,96 @@ pub trait UpperExp: PointeeSized { /// /// [`write!`]: crate::write! #[stable(feature = "rust1", since = "1.0.0")] -pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result { - let mut formatter = Formatter::new(output, FormattingOptions::new()); - let mut idx = 0; +pub fn write(output: &mut dyn Write, fmt: Arguments<'_>) -> Result { + if let Some(s) = fmt.as_str() { + return output.write_str(s); + } - match args.fmt { - None => { - // We can use default formatting parameters for all arguments. - for (i, arg) in args.args.iter().enumerate() { - // SAFETY: args.args and args.pieces come from the same Arguments, - // which guarantees the indexes are always within bounds. - let piece = unsafe { args.pieces.get_unchecked(i) }; - if !piece.is_empty() { - formatter.buf.write_str(*piece)?; + let mut template = fmt.template; + let args = fmt.args; + + let mut arg_index = 0; + + // This must match the encoding from `expand_format_args` in + // compiler/rustc_ast_lowering/src/format.rs. + loop { + // SAFETY: We can assume the template is valid. + let n = unsafe { + let n = template.read(); + template = template.add(1); + n + }; + + if n == 0 { + // End of template. + return Ok(()); + } else if n < 128 { + // Literal string piece of length `n`. + + // SAFETY: We can assume the strings in the template are valid. + let s = unsafe { + let s = crate::str::from_raw_parts(template.as_ptr(), n as usize); + template = template.add(n as usize); + s + }; + output.write_str(s)?; + } else if n == 128 { + // Placeholder for next argument with default options. + // + // Having this as a separate case improves performance for the common case. + + // SAFETY: We can assume the template only refers to arguments that exist. + unsafe { + args.add(arg_index) + .as_ref() + .fmt(&mut Formatter::new(output, FormattingOptions::new()))?; + } + arg_index += 1; + } else { + // Placeholder with custom options. + + let mut opt = FormattingOptions::new(); + + // SAFETY: We can assume the template is valid. + unsafe { + if n & 1 != 0 { + opt.flags = u32::from_le_bytes(template.cast_array().read()); + template = template.add(4); } - - // SAFETY: There are no formatting parameters and hence no - // count arguments. + if n & 2 != 0 { + opt.width = u16::from_le_bytes(template.cast_array().read()); + template = template.add(2); + } + if n & 4 != 0 { + opt.precision = u16::from_le_bytes(template.cast_array().read()); + template = template.add(2); + } + if n & 8 != 0 { + arg_index = usize::from(u16::from_le_bytes(template.cast_array().read())); + template = template.add(2); + } + } + if n & 16 != 0 { + // Dynamic width from a usize argument. + // SAFETY: We can assume the template only refers to arguments that exist. unsafe { - arg.fmt(&mut formatter)?; + opt.width = args.add(opt.width as usize).as_ref().as_u16().unwrap_unchecked(); } - idx += 1; } - } - Some(fmt) => { - // Every spec has a corresponding argument that is preceded by - // a string piece. - for (i, arg) in fmt.iter().enumerate() { - // SAFETY: fmt and args.pieces come from the same Arguments, - // which guarantees the indexes are always within bounds. - let piece = unsafe { args.pieces.get_unchecked(i) }; - if !piece.is_empty() { - formatter.buf.write_str(*piece)?; + if n & 32 != 0 { + // Dynamic precision from a usize argument. + // SAFETY: We can assume the template only refers to arguments that exist. + unsafe { + opt.precision = + args.add(opt.precision as usize).as_ref().as_u16().unwrap_unchecked(); } - // SAFETY: arg and args.args come from the same Arguments, - // which guarantees the indexes are always within bounds. - unsafe { run(&mut formatter, arg, args.args) }?; - idx += 1; } - } - } - // There can be only one trailing string piece left. - if let Some(piece) = args.pieces.get(idx) { - formatter.buf.write_str(*piece)?; - } - - Ok(()) -} - -unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::Placeholder, args: &[rt::Argument<'_>]) -> Result { - let (width, precision) = - // SAFETY: arg and args come from the same Arguments, - // which guarantees the indexes are always within bounds. - unsafe { (getcount(args, &arg.width), getcount(args, &arg.precision)) }; - - let options = FormattingOptions { flags: arg.flags, width, precision }; - - // Extract the correct argument - debug_assert!(arg.position < args.len()); - // SAFETY: arg and args come from the same Arguments, - // which guarantees its index is always within bounds. - let value = unsafe { args.get_unchecked(arg.position) }; - - // Set all the formatting options. - fmt.options = options; - - // Then actually do some printing - // SAFETY: this is a placeholder argument. - unsafe { value.fmt(fmt) } -} - -unsafe fn getcount(args: &[rt::Argument<'_>], cnt: &rt::Count) -> u16 { - match *cnt { - rt::Count::Is(n) => n, - rt::Count::Implied => 0, - rt::Count::Param(i) => { - debug_assert!(i < args.len()); - // SAFETY: cnt and args come from the same Arguments, - // which guarantees this index is always within bounds. - unsafe { args.get_unchecked(i).as_u16().unwrap_unchecked() } + // SAFETY: We can assume the template only refers to arguments that exist. + unsafe { + args.add(arg_index).as_ref().fmt(&mut Formatter::new(output, opt))?; + } + arg_index += 1; } } } diff --git a/library/core/src/fmt/rt.rs b/library/core/src/fmt/rt.rs index fb858a057261..6629873a567a 100644 --- a/library/core/src/fmt/rt.rs +++ b/library/core/src/fmt/rt.rs @@ -8,30 +8,9 @@ use super::*; use crate::hint::unreachable_unchecked; +use crate::mem; use crate::ptr::NonNull; -#[lang = "format_placeholder"] -#[derive(Copy, Clone)] -pub struct Placeholder { - pub position: usize, - pub flags: u32, - pub precision: Count, - pub width: Count, -} - -/// Used by [width](https://doc.rust-lang.org/std/fmt/#width) -/// and [precision](https://doc.rust-lang.org/std/fmt/#precision) specifiers. -#[lang = "format_count"] -#[derive(Copy, Clone)] -pub enum Count { - /// Specified with a literal number, stores the value - Is(u16), - /// Specified using `$` and `*` syntaxes, stores the index into `args` - Param(usize), - /// Not specified - Implied, -} - #[derive(Copy, Clone)] enum ArgumentType<'a> { Placeholder { @@ -56,6 +35,7 @@ enum ArgumentType<'a> { /// precision and width. #[lang = "format_argument"] #[derive(Copy, Clone)] +#[repr(align(2))] pub struct Argument<'a> { ty: ArgumentType<'a>, } @@ -187,52 +167,33 @@ impl Argument<'_> { /// Used by the format_args!() macro to create a fmt::Arguments object. #[doc(hidden)] -#[unstable(feature = "fmt_internals", issue = "none")] #[rustc_diagnostic_item = "FmtArgumentsNew"] impl<'a> Arguments<'a> { #[inline] - pub const fn new_const(pieces: &'a [&'static str; N]) -> Self { - const { assert!(N <= 1) }; - Arguments { pieces, fmt: None, args: &[] } + pub unsafe fn new( + template: &'a [u8; N], + args: &'a [rt::Argument<'a>; M], + ) -> Arguments<'a> { + // SAFETY: ... + unsafe { Arguments { template: mem::transmute(template), args: mem::transmute(args) } } } - /// When using the format_args!() macro, this function is used to generate the - /// Arguments structure. - /// - /// This function should _not_ be const, to make sure we don't accept - /// format_args!() and panic!() with arguments in const, even when not evaluated: - /// - /// ```compile_fail,E0015 - /// const _: () = if false { panic!("a {}", "a") }; - /// ``` #[inline] - pub fn new_v1( - pieces: &'a [&'static str; P], - args: &'a [rt::Argument<'a>; A], - ) -> Arguments<'a> { - const { assert!(P >= A && P <= A + 1, "invalid args") } - Arguments { pieces, fmt: None, args } + pub const fn from_str(s: &'static str) -> Arguments<'a> { + // SAFETY: This is the "static str" representation of fmt::Arguments. + unsafe { + Arguments { + template: mem::transmute(s.as_ptr()), + args: mem::transmute(s.len() << 1 | 1), + } + } } - /// Specifies nonstandard formatting parameters. - /// - /// SAFETY: the following invariants must be held: - /// 1. The `pieces` slice must be at least as long as `fmt`. - /// 2. Every `rt::Placeholder::position` value within `fmt` must be a valid index of `args`. - /// 3. Every `rt::Count::Param` within `fmt` must contain a valid index of `args`. - /// - /// This function should _not_ be const, to make sure we don't accept - /// format_args!() and panic!() with arguments in const, even when not evaluated: - /// - /// ```compile_fail,E0015 - /// const _: () = if false { panic!("a {:1}", "a") }; - /// ``` + // Same as `from_str`, but not const. + // Used by format_args!() expansion when arguments are inlined, + // e.g. format_args!("{}", 123), which is not allowed in const. #[inline] - pub unsafe fn new_v1_formatted( - pieces: &'a [&'static str], - args: &'a [rt::Argument<'a>], - fmt: &'a [rt::Placeholder], - ) -> Arguments<'a> { - Arguments { pieces, fmt: Some(fmt), args } + pub fn from_str_nonconst(s: &'static str) -> Arguments<'a> { + Arguments::from_str(s) } } diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 448f4ffc3dae..fa758ebf4667 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -136,18 +136,18 @@ pub const fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>, force_no_backtrace: boo #[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable #[lang = "panic"] // used by lints and miri for panics pub const fn panic(expr: &'static str) -> ! { - // Use Arguments::new_const instead of format_args!("{expr}") to potentially + // Use Arguments::from_str instead of format_args!("{expr}") to potentially // reduce size overhead. The format_args! macro uses str's Display trait to // write expr, which calls Formatter::pad, which must accommodate string // truncation and padding (even though none is used here). Using - // Arguments::new_const may allow the compiler to omit Formatter::pad from the + // Arguments::from_str may allow the compiler to omit Formatter::pad from the // output binary, saving up to a few kilobytes. - // However, this optimization only works for `'static` strings: `new_const` also makes this + // However, this optimization only works for `'static` strings: `from_str` also makes this // message return `Some` from `Arguments::as_str`, which means it can become part of the panic // payload without any allocation or copying. Shorter-lived strings would become invalid as // stack frames get popped during unwinding, and couldn't be directly referenced from the // payload. - panic_fmt(fmt::Arguments::new_const(&[expr])); + panic_fmt(fmt::Arguments::from_str(expr)); } // We generate functions for usage by compiler-generated assertions. @@ -171,13 +171,7 @@ macro_rules! panic_const { #[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable #[lang = stringify!($lang)] pub const fn $lang() -> ! { - // Use Arguments::new_const instead of format_args!("{expr}") to potentially - // reduce size overhead. The format_args! macro uses str's Display trait to - // write expr, which calls Formatter::pad, which must accommodate string - // truncation and padding (even though none is used here). Using - // Arguments::new_const may allow the compiler to omit Formatter::pad from the - // output binary, saving up to a few kilobytes. - panic_fmt(fmt::Arguments::new_const(&[$message])); + panic_fmt(fmt::Arguments::from_str($message)); } )+ } @@ -227,7 +221,7 @@ pub mod panic_const { #[rustc_nounwind] #[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable pub const fn panic_nounwind(expr: &'static str) -> ! { - panic_nounwind_fmt(fmt::Arguments::new_const(&[expr]), /* force_no_backtrace */ false); + panic_nounwind_fmt(fmt::Arguments::from_str(expr), /* force_no_backtrace */ false); } /// Like `panic_nounwind`, but also inhibits showing a backtrace. @@ -235,7 +229,7 @@ pub const fn panic_nounwind(expr: &'static str) -> ! { #[cfg_attr(panic = "immediate-abort", inline)] #[rustc_nounwind] pub fn panic_nounwind_nobacktrace(expr: &'static str) -> ! { - panic_nounwind_fmt(fmt::Arguments::new_const(&[expr]), /* force_no_backtrace */ true); + panic_nounwind_fmt(fmt::Arguments::from_str(expr), /* force_no_backtrace */ true); } #[inline] diff --git a/library/core/src/ub_checks.rs b/library/core/src/ub_checks.rs index 514ff93c9820..50e02320748b 100644 --- a/library/core/src/ub_checks.rs +++ b/library/core/src/ub_checks.rs @@ -70,7 +70,7 @@ macro_rules! assert_unsafe_precondition { let msg = concat!("unsafe precondition(s) violated: ", $message, "\n\nThis indicates a bug in the program. \ This Undefined Behavior check is optional, and cannot be relied on for safety."); - ::core::panicking::panic_nounwind_fmt(::core::fmt::Arguments::new_const(&[msg]), false); + ::core::panicking::panic_nounwind_fmt(::core::fmt::Arguments::from_str(msg), false); } } From 7b42543f817a9dc3b3c83546a4b0062dbbaf9271 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 10 Nov 2025 15:11:17 +0100 Subject: [PATCH 085/108] Bless tests. --- .../item-collection/opaque-return-impls.rs | 2 +- tests/coverage/abort.cov-map | 5 +- tests/coverage/assert.cov-map | 10 +- tests/coverage/async2.cov-map | 20 ++-- .../coverage/attr/trait-impl-inherit.cov-map | 5 +- tests/coverage/bad_counter_ids.cov-map | 44 +++----- tests/coverage/closure.cov-map | 97 +++++++---------- tests/coverage/closure_macro.cov-map | 18 ++- tests/coverage/closure_macro_async.cov-map | 18 ++- tests/coverage/conditions.cov-map | 87 +++++++-------- tests/coverage/coverage_attr_closure.cov-map | 15 +-- tests/coverage/drop_trait.cov-map | 10 +- tests/coverage/generics.cov-map | 15 +-- tests/coverage/inline-dead.cov-map | 5 +- tests/coverage/inner_items.cov-map | 5 +- tests/coverage/issue-83601.cov-map | 7 +- tests/coverage/issue-84561.cov-map | 63 ++++------- tests/coverage/loops_branches.cov-map | 18 +-- tests/coverage/macro_in_closure.cov-map | 10 +- tests/coverage/no_cov_crate.cov-map | 25 ++--- tests/coverage/overflow.cov-map | 12 +- tests/coverage/panic_unwind.cov-map | 5 +- tests/coverage/partial_eq.cov-map | 7 +- tests/coverage/rustfmt-skip.cov-map | 7 +- tests/coverage/sort_groups.cov-map | 28 ++--- tests/coverage/unused_mod.cov-map | 10 +- tests/coverage/uses_crate.cov-map | 20 ++-- tests/coverage/uses_inline_crate.cov-map | 20 ++-- tests/incremental/hashes/inherent_impls.rs | 20 +--- .../hygiene/auxiliary/cached_hygiene.rs | 2 +- tests/incremental/string_constant.rs | 2 +- tests/mir-opt/gvn.slices.GVN.panic-abort.diff | 15 ++- .../mir-opt/gvn.slices.GVN.panic-unwind.diff | 15 ++- ...fg-pre-optimizations.after.panic-abort.mir | 1 - ...g-pre-optimizations.after.panic-unwind.mir | 1 - ...mes.foo.ScalarReplacementOfAggregates.diff | 103 +++++++++--------- tests/pretty/issue-4264.pp | 7 +- .../run-make/symbol-mangling-hashed/rmake.rs | 4 +- .../ui/consts/recursive-const-in-impl.stderr | 2 +- tests/ui/unpretty/exhaustive.hir.stdout | 4 +- .../ui/unpretty/flattened-format-args.stdout | 5 +- 41 files changed, 322 insertions(+), 447 deletions(-) diff --git a/tests/codegen-units/item-collection/opaque-return-impls.rs b/tests/codegen-units/item-collection/opaque-return-impls.rs index 7d5f4f5b6698..2859e1679918 100644 --- a/tests/codegen-units/item-collection/opaque-return-impls.rs +++ b/tests/codegen-units/item-collection/opaque-return-impls.rs @@ -86,4 +86,4 @@ pub fn foo3() -> Box> { //~ MONO_ITEM fn foo3 //~ MONO_ITEM fn std::boxed::Box::::new //~ MONO_ITEM fn Counter::new -//~ MONO_ITEM fn core::fmt::rt::>::new_const::<1> +//~ MONO_ITEM fn core::fmt::rt::>::from_str diff --git a/tests/coverage/abort.cov-map b/tests/coverage/abort.cov-map index 4d8ea874bd79..b6bd0edebaae 100644 --- a/tests/coverage/abort.cov-map +++ b/tests/coverage/abort.cov-map @@ -37,16 +37,15 @@ Number of file 0 mappings: 16 Highest counter ID seen: c4 Function name: abort::might_abort -Raw bytes (41): 0x[01, 01, 01, 01, 05, 07, 01, 03, 01, 00, 2e, 01, 01, 08, 00, 14, 05, 01, 09, 00, 11, 05, 00, 12, 00, 1f, 05, 01, 09, 00, 0f, 02, 01, 0c, 02, 06, 02, 03, 01, 00, 02] +Raw bytes (36): 0x[01, 01, 01, 01, 05, 06, 01, 03, 01, 00, 2e, 01, 01, 08, 00, 14, 05, 01, 09, 00, 11, 05, 01, 09, 00, 0f, 02, 01, 0c, 02, 06, 02, 03, 01, 00, 02] Number of files: 1 - file 0 => $DIR/abort.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 7 +Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 3, 1) to (start + 0, 46) - Code(Counter(0)) at (prev + 1, 8) to (start + 0, 20) - Code(Counter(1)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 31) - Code(Counter(1)) at (prev + 1, 9) to (start + 0, 15) - Code(Expression(0, Sub)) at (prev + 1, 12) to (start + 2, 6) = (c0 - c1) diff --git a/tests/coverage/assert.cov-map b/tests/coverage/assert.cov-map index 07a0d4c8c27e..543ab8962828 100644 --- a/tests/coverage/assert.cov-map +++ b/tests/coverage/assert.cov-map @@ -29,18 +29,14 @@ Number of file 0 mappings: 12 Highest counter ID seen: c3 Function name: assert::might_fail_assert -Raw bytes (36): 0x[01, 01, 01, 01, 05, 06, 01, 04, 01, 00, 28, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 20, 01, 01, 05, 00, 0f, 02, 00, 25, 00, 3d, 05, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 04, 01, 00, 28, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0f, 05, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/assert.rs -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 6 +Number of expressions: 0 +Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 4, 1) to (start + 0, 40) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 32) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) -- Code(Expression(0, Sub)) at (prev + 0, 37) to (start + 0, 61) - = (c0 - c1) - Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c1 diff --git a/tests/coverage/async2.cov-map b/tests/coverage/async2.cov-map index cc6295170980..9fb5e8e4ef37 100644 --- a/tests/coverage/async2.cov-map +++ b/tests/coverage/async2.cov-map @@ -8,14 +8,13 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: async2::async_func::{closure#0} -Raw bytes (49): 0x[01, 01, 00, 09, 01, 0f, 17, 00, 18, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 26, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 11, 01, 01, 08, 00, 09, 01, 00, 0a, 02, 06, 00, 02, 05, 00, 06, 01, 01, 01, 00, 02] +Raw bytes (44): 0x[01, 01, 00, 08, 01, 0f, 17, 00, 18, 01, 01, 05, 00, 0d, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 11, 01, 01, 08, 00, 09, 01, 00, 0a, 02, 06, 00, 02, 05, 00, 06, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async2.rs Number of expressions: 0 -Number of file 0 mappings: 9 +Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 15, 23) to (start + 0, 24) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 38) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 17) - Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) @@ -34,26 +33,24 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: async2::async_func_just_println::{closure#0} -Raw bytes (24): 0x[01, 01, 00, 04, 01, 17, 24, 00, 25, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 33, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 17, 24, 00, 25, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async2.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 23, 36) to (start + 0, 37) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 51) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: async2::main -Raw bytes (49): 0x[01, 01, 00, 09, 01, 1b, 01, 00, 0a, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 23, 01, 02, 05, 00, 13, 01, 02, 05, 00, 17, 01, 00, 18, 00, 22, 01, 01, 05, 00, 17, 01, 00, 18, 00, 2f, 01, 01, 01, 00, 02] +Raw bytes (44): 0x[01, 01, 00, 08, 01, 1b, 01, 00, 0a, 01, 01, 05, 00, 0d, 01, 02, 05, 00, 13, 01, 02, 05, 00, 17, 01, 00, 18, 00, 22, 01, 01, 05, 00, 17, 01, 00, 18, 00, 2f, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async2.rs Number of expressions: 0 -Number of file 0 mappings: 9 +Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 27, 1) to (start + 0, 10) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 35) - Code(Counter(0)) at (prev + 2, 5) to (start + 0, 19) - Code(Counter(0)) at (prev + 2, 5) to (start + 0, 23) - Code(Counter(0)) at (prev + 0, 24) to (start + 0, 34) @@ -63,14 +60,13 @@ Number of file 0 mappings: 9 Highest counter ID seen: c0 Function name: async2::non_async_func -Raw bytes (49): 0x[01, 01, 00, 09, 01, 07, 01, 00, 14, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 2a, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 11, 01, 01, 08, 00, 09, 01, 00, 0a, 02, 06, 00, 02, 05, 00, 06, 01, 01, 01, 00, 02] +Raw bytes (44): 0x[01, 01, 00, 08, 01, 07, 01, 00, 14, 01, 01, 05, 00, 0d, 01, 01, 09, 00, 0a, 01, 00, 0d, 00, 11, 01, 01, 08, 00, 09, 01, 00, 0a, 02, 06, 00, 02, 05, 00, 06, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async2.rs Number of expressions: 0 -Number of file 0 mappings: 9 +Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 7, 1) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 42) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 0, 13) to (start + 0, 17) - Code(Counter(0)) at (prev + 1, 8) to (start + 0, 9) diff --git a/tests/coverage/attr/trait-impl-inherit.cov-map b/tests/coverage/attr/trait-impl-inherit.cov-map index bf10083dd290..6aedd1043f97 100644 --- a/tests/coverage/attr/trait-impl-inherit.cov-map +++ b/tests/coverage/attr/trait-impl-inherit.cov-map @@ -1,12 +1,11 @@ Function name: ::f -Raw bytes (24): 0x[01, 01, 00, 04, 01, 11, 05, 00, 10, 01, 01, 09, 00, 11, 01, 00, 12, 00, 1a, 01, 01, 05, 00, 06] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 11, 05, 00, 10, 01, 01, 09, 00, 11, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/trait-impl-inherit.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 17, 5) to (start + 0, 16) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 18) to (start + 0, 26) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: c0 diff --git a/tests/coverage/bad_counter_ids.cov-map b/tests/coverage/bad_counter_ids.cov-map index 8b1b177f906e..309b29220144 100644 --- a/tests/coverage/bad_counter_ids.cov-map +++ b/tests/coverage/bad_counter_ids.cov-map @@ -1,108 +1,96 @@ Function name: bad_counter_ids::eq_bad -Raw bytes (29): 0x[01, 01, 00, 05, 01, 24, 01, 00, 0c, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 11, 01, 01, 05, 00, 0f, 00, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 24, 01, 00, 0c, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0f, 00, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/bad_counter_ids.rs Number of expressions: 0 -Number of file 0 mappings: 5 +Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 36, 1) to (start + 0, 12) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 17) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) - Code(Zero) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: bad_counter_ids::eq_bad_message -Raw bytes (34): 0x[01, 01, 00, 06, 01, 29, 01, 00, 14, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 11, 01, 01, 05, 00, 0f, 01, 00, 20, 00, 2b, 00, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 29, 01, 00, 14, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0f, 00, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/bad_counter_ids.rs Number of expressions: 0 -Number of file 0 mappings: 6 +Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 41, 1) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 17) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) -- Code(Counter(0)) at (prev + 0, 32) to (start + 0, 43) - Code(Zero) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: bad_counter_ids::eq_good -Raw bytes (29): 0x[01, 01, 00, 05, 01, 10, 01, 00, 0d, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 11, 01, 01, 05, 00, 0f, 01, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 10, 01, 00, 0d, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0f, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/bad_counter_ids.rs Number of expressions: 0 -Number of file 0 mappings: 5 +Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 16, 1) to (start + 0, 13) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 17) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: bad_counter_ids::eq_good_message -Raw bytes (34): 0x[01, 01, 00, 06, 01, 15, 01, 00, 15, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 11, 01, 01, 05, 00, 0f, 00, 00, 20, 00, 2b, 01, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 15, 01, 00, 15, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0f, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/bad_counter_ids.rs Number of expressions: 0 -Number of file 0 mappings: 6 +Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 21, 1) to (start + 0, 21) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 17) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) -- Code(Zero) at (prev + 0, 32) to (start + 0, 43) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: bad_counter_ids::ne_bad -Raw bytes (29): 0x[01, 01, 00, 05, 01, 2e, 01, 00, 0c, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 11, 01, 01, 05, 00, 0f, 00, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 2e, 01, 00, 0c, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0f, 00, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/bad_counter_ids.rs Number of expressions: 0 -Number of file 0 mappings: 5 +Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 46, 1) to (start + 0, 12) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 17) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) - Code(Zero) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: bad_counter_ids::ne_bad_message -Raw bytes (34): 0x[01, 01, 00, 06, 01, 33, 01, 00, 14, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 11, 01, 01, 05, 00, 0f, 01, 00, 20, 00, 2b, 00, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 33, 01, 00, 14, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0f, 00, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/bad_counter_ids.rs Number of expressions: 0 -Number of file 0 mappings: 6 +Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 51, 1) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 17) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) -- Code(Counter(0)) at (prev + 0, 32) to (start + 0, 43) - Code(Zero) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: bad_counter_ids::ne_good -Raw bytes (29): 0x[01, 01, 00, 05, 01, 1a, 01, 00, 0d, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 11, 01, 01, 05, 00, 0f, 01, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 1a, 01, 00, 0d, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0f, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/bad_counter_ids.rs Number of expressions: 0 -Number of file 0 mappings: 5 +Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 26, 1) to (start + 0, 13) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 17) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: bad_counter_ids::ne_good_message -Raw bytes (34): 0x[01, 01, 00, 06, 01, 1f, 01, 00, 15, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 11, 01, 01, 05, 00, 0f, 00, 00, 20, 00, 2b, 01, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 1f, 01, 00, 15, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0f, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/bad_counter_ids.rs Number of expressions: 0 -Number of file 0 mappings: 6 +Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 31, 1) to (start + 0, 21) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 17) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) -- Code(Zero) at (prev + 0, 32) to (start + 0, 43) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 diff --git a/tests/coverage/closure.cov-map b/tests/coverage/closure.cov-map index ee8934f0a846..d713145d8612 100644 --- a/tests/coverage/closure.cov-map +++ b/tests/coverage/closure.cov-map @@ -1,10 +1,10 @@ Function name: closure::main -Raw bytes (336): 0x[01, 01, 01, 01, 05, 42, 01, 09, 01, 00, 0a, 01, 04, 09, 00, 10, 01, 00, 13, 00, 2e, 01, 01, 09, 00, 11, 01, 00, 14, 00, 1c, 01, 02, 09, 00, 18, 01, 00, 1b, 00, 43, 01, 01, 05, 00, 0d, 01, 01, 09, 00, 20, 01, 02, 09, 00, 14, 01, 02, 0d, 00, 1b, 01, 0d, 05, 00, 10, 01, 00, 13, 00, 3b, 01, 02, 09, 00, 0a, 01, 0a, 05, 00, 0d, 01, 01, 09, 00, 20, 01, 02, 09, 00, 14, 01, 02, 0d, 00, 1b, 01, 02, 0d, 00, 0e, 01, 04, 05, 00, 10, 01, 00, 13, 00, 17, 01, 01, 05, 00, 0d, 01, 01, 09, 00, 20, 01, 02, 09, 00, 14, 01, 02, 0d, 00, 1b, 01, 0d, 05, 00, 10, 01, 00, 13, 00, 17, 01, 02, 09, 00, 0a, 01, 0a, 05, 00, 0d, 01, 01, 09, 00, 20, 01, 02, 09, 00, 14, 01, 02, 0d, 00, 1b, 01, 02, 0d, 00, 0e, 01, 05, 09, 00, 16, 01, 0a, 05, 00, 0d, 01, 01, 09, 00, 28, 01, 02, 09, 00, 1a, 01, 01, 0e, 00, 12, 01, 01, 0e, 00, 11, 01, 02, 0d, 00, 1a, 01, 02, 0e, 00, 15, 01, 04, 09, 00, 18, 01, 0c, 09, 00, 16, 01, 00, 19, 00, 1b, 01, 01, 09, 00, 1e, 01, 03, 09, 00, 29, 01, 01, 09, 00, 2d, 01, 01, 09, 00, 24, 01, 05, 09, 00, 24, 01, 02, 09, 00, 21, 01, 04, 09, 00, 21, 01, 04, 09, 00, 28, 01, 09, 09, 00, 32, 01, 04, 09, 00, 33, 01, 07, 09, 00, 4b, 01, 08, 09, 00, 48, 01, 0a, 09, 00, 47, 01, 08, 09, 00, 44, 01, 0a, 08, 00, 10, 05, 00, 11, 04, 06, 05, 01, 09, 00, 30, 02, 03, 05, 00, 06, 01, 01, 05, 00, 28, 01, 01, 05, 00, 46, 01, 01, 05, 00, 43, 01, 01, 01, 00, 02] +Raw bytes (311): 0x[01, 01, 01, 01, 05, 3d, 01, 09, 01, 00, 0a, 01, 04, 09, 00, 10, 01, 00, 13, 00, 2e, 01, 01, 09, 00, 11, 01, 00, 14, 00, 1c, 01, 02, 09, 00, 18, 01, 00, 1b, 00, 43, 01, 01, 05, 00, 0d, 01, 03, 09, 00, 14, 01, 02, 0d, 00, 1b, 01, 0d, 05, 00, 10, 01, 00, 13, 00, 3b, 01, 02, 09, 00, 0a, 01, 0a, 05, 00, 0d, 01, 03, 09, 00, 14, 01, 02, 0d, 00, 1b, 01, 02, 0d, 00, 0e, 01, 04, 05, 00, 10, 01, 00, 13, 00, 17, 01, 01, 05, 00, 0d, 01, 03, 09, 00, 14, 01, 02, 0d, 00, 1b, 01, 0d, 05, 00, 10, 01, 00, 13, 00, 17, 01, 02, 09, 00, 0a, 01, 0a, 05, 00, 0d, 01, 03, 09, 00, 14, 01, 02, 0d, 00, 1b, 01, 02, 0d, 00, 0e, 01, 05, 09, 00, 16, 01, 0a, 05, 00, 0d, 01, 03, 09, 00, 1a, 01, 01, 0e, 00, 12, 01, 01, 0e, 00, 11, 01, 02, 0d, 00, 1a, 01, 02, 0e, 00, 15, 01, 04, 09, 00, 18, 01, 0c, 09, 00, 16, 01, 00, 19, 00, 1b, 01, 01, 09, 00, 1e, 01, 03, 09, 00, 29, 01, 01, 09, 00, 2d, 01, 01, 09, 00, 24, 01, 05, 09, 00, 24, 01, 02, 09, 00, 21, 01, 04, 09, 00, 21, 01, 04, 09, 00, 28, 01, 09, 09, 00, 32, 01, 04, 09, 00, 33, 01, 07, 09, 00, 4b, 01, 08, 09, 00, 48, 01, 0a, 09, 00, 47, 01, 08, 09, 00, 44, 01, 0a, 08, 00, 10, 05, 00, 11, 04, 06, 05, 01, 09, 00, 30, 02, 03, 05, 00, 06, 01, 01, 05, 00, 28, 01, 01, 05, 00, 46, 01, 01, 05, 00, 43, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 66 +Number of file 0 mappings: 61 - Code(Counter(0)) at (prev + 9, 1) to (start + 0, 10) - Code(Counter(0)) at (prev + 4, 9) to (start + 0, 16) - Code(Counter(0)) at (prev + 0, 19) to (start + 0, 46) @@ -13,35 +13,30 @@ Number of file 0 mappings: 66 - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 24) - Code(Counter(0)) at (prev + 0, 27) to (start + 0, 67) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 32) -- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 20) +- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 20) - Code(Counter(0)) at (prev + 2, 13) to (start + 0, 27) - Code(Counter(0)) at (prev + 13, 5) to (start + 0, 16) - Code(Counter(0)) at (prev + 0, 19) to (start + 0, 59) - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 10, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 32) -- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 20) +- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 20) - Code(Counter(0)) at (prev + 2, 13) to (start + 0, 27) - Code(Counter(0)) at (prev + 2, 13) to (start + 0, 14) - Code(Counter(0)) at (prev + 4, 5) to (start + 0, 16) - Code(Counter(0)) at (prev + 0, 19) to (start + 0, 23) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 32) -- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 20) +- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 20) - Code(Counter(0)) at (prev + 2, 13) to (start + 0, 27) - Code(Counter(0)) at (prev + 13, 5) to (start + 0, 16) - Code(Counter(0)) at (prev + 0, 19) to (start + 0, 23) - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 10, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 32) -- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 20) +- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 20) - Code(Counter(0)) at (prev + 2, 13) to (start + 0, 27) - Code(Counter(0)) at (prev + 2, 13) to (start + 0, 14) - Code(Counter(0)) at (prev + 5, 9) to (start + 0, 22) - Code(Counter(0)) at (prev + 10, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 40) -- Code(Counter(0)) at (prev + 2, 9) to (start + 0, 26) +- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 26) - Code(Counter(0)) at (prev + 1, 14) to (start + 0, 18) - Code(Counter(0)) at (prev + 1, 14) to (start + 0, 17) - Code(Counter(0)) at (prev + 2, 13) to (start + 0, 26) @@ -94,74 +89,68 @@ Number of file 0 mappings: 9 Highest counter ID seen: c1 Function name: closure::main::{closure#10} (unused) -Raw bytes (25): 0x[01, 01, 00, 04, 00, 9b, 01, 07, 00, 08, 00, 00, 09, 00, 11, 00, 00, 12, 00, 1e, 00, 00, 20, 00, 21] +Raw bytes (20): 0x[01, 01, 00, 03, 00, 9b, 01, 07, 00, 08, 00, 00, 09, 00, 11, 00, 00, 20, 00, 21] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Zero) at (prev + 155, 7) to (start + 0, 8) - Code(Zero) at (prev + 0, 9) to (start + 0, 17) -- Code(Zero) at (prev + 0, 18) to (start + 0, 30) - Code(Zero) at (prev + 0, 32) to (start + 0, 33) Highest counter ID seen: (none) Function name: closure::main::{closure#11} (unused) -Raw bytes (25): 0x[01, 01, 00, 04, 00, 9f, 01, 07, 00, 08, 00, 00, 09, 00, 11, 00, 00, 12, 00, 1e, 00, 00, 20, 00, 21] +Raw bytes (20): 0x[01, 01, 00, 03, 00, 9f, 01, 07, 00, 08, 00, 00, 09, 00, 11, 00, 00, 20, 00, 21] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Zero) at (prev + 159, 7) to (start + 0, 8) - Code(Zero) at (prev + 0, 9) to (start + 0, 17) -- Code(Zero) at (prev + 0, 18) to (start + 0, 30) - Code(Zero) at (prev + 0, 32) to (start + 0, 33) Highest counter ID seen: (none) Function name: closure::main::{closure#12} (unused) -Raw bytes (15): 0x[01, 01, 00, 02, 00, a7, 01, 01, 00, 09, 00, 00, 0a, 00, 16] +Raw bytes (10): 0x[01, 01, 00, 01, 00, a7, 01, 01, 00, 09] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 2 +Number of file 0 mappings: 1 - Code(Zero) at (prev + 167, 1) to (start + 0, 9) -- Code(Zero) at (prev + 0, 10) to (start + 0, 22) Highest counter ID seen: (none) Function name: closure::main::{closure#13} (unused) -Raw bytes (15): 0x[01, 01, 00, 02, 00, ac, 01, 0d, 00, 15, 00, 01, 11, 00, 1d] +Raw bytes (10): 0x[01, 01, 00, 01, 00, ac, 01, 0d, 00, 15] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 2 +Number of file 0 mappings: 1 - Code(Zero) at (prev + 172, 13) to (start + 0, 21) -- Code(Zero) at (prev + 1, 17) to (start + 0, 29) Highest counter ID seen: (none) Function name: closure::main::{closure#14} -Raw bytes (27): 0x[01, 01, 01, 01, 05, 04, 01, b4, 01, 11, 00, 21, 01, 01, 14, 00, 1b, 05, 00, 1e, 00, 25, 02, 00, 2f, 00, 33] +Raw bytes (22): 0x[01, 01, 01, 01, 05, 03, 01, b5, 01, 14, 00, 1b, 05, 00, 1e, 00, 25, 02, 00, 2f, 00, 33] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 180, 17) to (start + 0, 33) -- Code(Counter(0)) at (prev + 1, 20) to (start + 0, 27) +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 181, 20) to (start + 0, 27) - Code(Counter(1)) at (prev + 0, 30) to (start + 0, 37) - Code(Expression(0, Sub)) at (prev + 0, 47) to (start + 0, 51) = (c0 - c1) Highest counter ID seen: c1 Function name: closure::main::{closure#15} -Raw bytes (42): 0x[01, 01, 01, 01, 05, 07, 01, bb, 01, 09, 00, 0a, 01, 01, 0d, 00, 15, 01, 01, 11, 00, 21, 01, 01, 14, 00, 1b, 05, 00, 1e, 00, 25, 02, 00, 2f, 00, 33, 01, 02, 09, 00, 0a] +Raw bytes (37): 0x[01, 01, 01, 01, 05, 06, 01, bb, 01, 09, 00, 0a, 01, 01, 0d, 00, 15, 01, 02, 14, 00, 1b, 05, 00, 1e, 00, 25, 02, 00, 2f, 00, 33, 01, 02, 09, 00, 0a] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 7 +Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 187, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 21) -- Code(Counter(0)) at (prev + 1, 17) to (start + 0, 33) -- Code(Counter(0)) at (prev + 1, 20) to (start + 0, 27) +- Code(Counter(0)) at (prev + 2, 20) to (start + 0, 27) - Code(Counter(1)) at (prev + 0, 30) to (start + 0, 37) - Code(Expression(0, Sub)) at (prev + 0, 47) to (start + 0, 51) = (c0 - c1) @@ -169,30 +158,28 @@ Number of file 0 mappings: 7 Highest counter ID seen: c1 Function name: closure::main::{closure#16} -Raw bytes (27): 0x[01, 01, 01, 01, 05, 04, 01, c6, 01, 11, 00, 21, 01, 01, 14, 00, 1b, 05, 00, 1e, 00, 25, 02, 00, 2f, 00, 33] +Raw bytes (22): 0x[01, 01, 01, 01, 05, 03, 01, c7, 01, 14, 00, 1b, 05, 00, 1e, 00, 25, 02, 00, 2f, 00, 33] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 198, 17) to (start + 0, 33) -- Code(Counter(0)) at (prev + 1, 20) to (start + 0, 27) +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 199, 20) to (start + 0, 27) - Code(Counter(1)) at (prev + 0, 30) to (start + 0, 37) - Code(Expression(0, Sub)) at (prev + 0, 47) to (start + 0, 51) = (c0 - c1) Highest counter ID seen: c1 Function name: closure::main::{closure#17} -Raw bytes (42): 0x[01, 01, 01, 01, 05, 07, 01, cd, 01, 09, 00, 0a, 01, 01, 0d, 00, 15, 01, 01, 11, 00, 21, 01, 01, 14, 00, 1b, 05, 00, 1e, 00, 25, 02, 00, 2f, 00, 33, 01, 02, 09, 00, 0a] +Raw bytes (37): 0x[01, 01, 01, 01, 05, 06, 01, cd, 01, 09, 00, 0a, 01, 01, 0d, 00, 15, 01, 02, 14, 00, 1b, 05, 00, 1e, 00, 25, 02, 00, 2f, 00, 33, 01, 02, 09, 00, 0a] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 7 +Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 205, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 21) -- Code(Counter(0)) at (prev + 1, 17) to (start + 0, 33) -- Code(Counter(0)) at (prev + 1, 20) to (start + 0, 27) +- Code(Counter(0)) at (prev + 2, 20) to (start + 0, 27) - Code(Counter(1)) at (prev + 0, 30) to (start + 0, 37) - Code(Expression(0, Sub)) at (prev + 0, 47) to (start + 0, 51) = (c0 - c1) @@ -257,12 +244,12 @@ Number of file 0 mappings: 9 Highest counter ID seen: c1 Function name: closure::main::{closure#2} -Raw bytes (51): 0x[01, 01, 01, 01, 05, 09, 01, 68, 05, 00, 06, 01, 01, 0d, 00, 1a, 01, 00, 1d, 00, 1e, 01, 01, 0c, 00, 14, 05, 00, 15, 02, 0a, 02, 02, 09, 00, 0a, 01, 01, 09, 00, 10, 01, 00, 11, 00, 17, 01, 01, 05, 00, 06] +Raw bytes (46): 0x[01, 01, 01, 01, 05, 08, 01, 68, 05, 00, 06, 01, 01, 0d, 00, 1a, 01, 00, 1d, 00, 1e, 01, 01, 0c, 00, 14, 05, 00, 15, 02, 0a, 02, 02, 09, 00, 0a, 01, 01, 09, 00, 10, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 9 +Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 104, 5) to (start + 0, 6) - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 26) - Code(Counter(0)) at (prev + 0, 29) to (start + 0, 30) @@ -271,7 +258,6 @@ Number of file 0 mappings: 9 - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10) = (c0 - c1) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 16) -- Code(Counter(0)) at (prev + 0, 17) to (start + 0, 23) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: c1 @@ -291,56 +277,51 @@ Number of file 0 mappings: 7 Highest counter ID seen: (none) Function name: closure::main::{closure#5} -Raw bytes (15): 0x[01, 01, 00, 02, 01, 8c, 01, 3d, 00, 45, 01, 00, 46, 00, 4e] +Raw bytes (10): 0x[01, 01, 00, 01, 01, 8c, 01, 3d, 00, 45] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 2 +Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 140, 61) to (start + 0, 69) -- Code(Counter(0)) at (prev + 0, 70) to (start + 0, 78) Highest counter ID seen: c0 Function name: closure::main::{closure#6} -Raw bytes (15): 0x[01, 01, 00, 02, 01, 8d, 01, 41, 00, 49, 01, 00, 4a, 00, 56] +Raw bytes (10): 0x[01, 01, 00, 01, 01, 8d, 01, 41, 00, 49] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 2 +Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 141, 65) to (start + 0, 73) -- Code(Counter(0)) at (prev + 0, 74) to (start + 0, 86) Highest counter ID seen: c0 Function name: closure::main::{closure#7} (unused) -Raw bytes (15): 0x[01, 01, 00, 02, 00, 8e, 01, 3b, 00, 43, 00, 00, 44, 00, 50] +Raw bytes (10): 0x[01, 01, 00, 01, 00, 8e, 01, 3b, 00, 43] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 2 +Number of file 0 mappings: 1 - Code(Zero) at (prev + 142, 59) to (start + 0, 67) -- Code(Zero) at (prev + 0, 68) to (start + 0, 80) Highest counter ID seen: (none) Function name: closure::main::{closure#8} (unused) -Raw bytes (25): 0x[01, 01, 00, 04, 00, 93, 01, 3b, 00, 3c, 00, 00, 3d, 00, 45, 00, 00, 46, 00, 52, 00, 00, 54, 00, 55] +Raw bytes (20): 0x[01, 01, 00, 03, 00, 93, 01, 3b, 00, 3c, 00, 00, 3d, 00, 45, 00, 00, 54, 00, 55] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Zero) at (prev + 147, 59) to (start + 0, 60) - Code(Zero) at (prev + 0, 61) to (start + 0, 69) -- Code(Zero) at (prev + 0, 70) to (start + 0, 82) - Code(Zero) at (prev + 0, 84) to (start + 0, 85) Highest counter ID seen: (none) Function name: closure::main::{closure#9} (unused) -Raw bytes (25): 0x[01, 01, 00, 04, 00, 95, 01, 38, 00, 39, 00, 01, 09, 00, 11, 00, 00, 12, 00, 1e, 00, 01, 05, 00, 06] +Raw bytes (20): 0x[01, 01, 00, 03, 00, 95, 01, 38, 00, 39, 00, 01, 09, 00, 11, 00, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Zero) at (prev + 149, 56) to (start + 0, 57) - Code(Zero) at (prev + 1, 9) to (start + 0, 17) -- Code(Zero) at (prev + 0, 18) to (start + 0, 30) - Code(Zero) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: (none) diff --git a/tests/coverage/closure_macro.cov-map b/tests/coverage/closure_macro.cov-map index 3ab1d7f5fba8..dd3629771085 100644 --- a/tests/coverage/closure_macro.cov-map +++ b/tests/coverage/closure_macro.cov-map @@ -10,15 +10,14 @@ Number of file 0 mappings: 3 Highest counter ID seen: c0 Function name: closure_macro::main -Raw bytes (66): 0x[01, 01, 01, 01, 05, 0c, 01, 21, 01, 00, 24, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 20, 02, 01, 09, 00, 0f, 01, 00, 12, 00, 1b, 01, 00, 1c, 00, 34, 05, 00, 54, 00, 55, 02, 02, 09, 00, 1f, 02, 00, 22, 00, 2e, 02, 01, 0d, 00, 2d, 02, 01, 05, 00, 0b, 01, 01, 01, 00, 02] +Raw bytes (61): 0x[01, 01, 01, 01, 05, 0b, 01, 21, 01, 00, 24, 01, 01, 05, 00, 0d, 02, 01, 09, 00, 0f, 01, 00, 12, 00, 1b, 01, 00, 1c, 00, 34, 05, 00, 54, 00, 55, 02, 02, 09, 00, 1f, 02, 00, 22, 00, 2e, 02, 01, 0d, 00, 2d, 02, 01, 05, 00, 0b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/closure_macro.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 12 +Number of file 0 mappings: 11 - Code(Counter(0)) at (prev + 33, 1) to (start + 0, 36) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 32) - Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 15) = (c0 - c1) - Code(Counter(0)) at (prev + 0, 18) to (start + 0, 27) @@ -36,25 +35,22 @@ Number of file 0 mappings: 12 Highest counter ID seen: c1 Function name: closure_macro::main::{closure#0} -Raw bytes (60): 0x[01, 01, 03, 01, 05, 01, 0b, 05, 09, 0a, 01, 10, 1c, 00, 1d, 01, 02, 11, 00, 18, 01, 00, 1b, 00, 22, 01, 01, 10, 00, 21, 05, 01, 11, 00, 19, 05, 00, 1a, 00, 1e, 05, 01, 11, 00, 27, 02, 02, 11, 00, 16, 06, 00, 17, 00, 1e, 01, 02, 09, 00, 0a] +Raw bytes (51): 0x[01, 01, 01, 01, 05, 09, 01, 10, 1c, 00, 1d, 01, 02, 11, 00, 18, 01, 00, 1b, 00, 22, 01, 01, 10, 00, 21, 05, 01, 11, 00, 19, 05, 01, 11, 00, 27, 02, 02, 11, 00, 16, 02, 00, 17, 00, 1e, 01, 02, 09, 00, 0a] Number of files: 1 - file 0 => $DIR/closure_macro.rs -Number of expressions: 3 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Expression(2, Add) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -Number of file 0 mappings: 10 +Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 16, 28) to (start + 0, 29) - Code(Counter(0)) at (prev + 2, 17) to (start + 0, 24) - Code(Counter(0)) at (prev + 0, 27) to (start + 0, 34) - Code(Counter(0)) at (prev + 1, 16) to (start + 0, 33) - Code(Counter(1)) at (prev + 1, 17) to (start + 0, 25) -- Code(Counter(1)) at (prev + 0, 26) to (start + 0, 30) - Code(Counter(1)) at (prev + 1, 17) to (start + 0, 39) - Code(Expression(0, Sub)) at (prev + 2, 17) to (start + 0, 22) = (c0 - c1) -- Code(Expression(1, Sub)) at (prev + 0, 23) to (start + 0, 30) - = (c0 - (c1 + c2)) +- Code(Expression(0, Sub)) at (prev + 0, 23) to (start + 0, 30) + = (c0 - c1) - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) Highest counter ID seen: c1 diff --git a/tests/coverage/closure_macro_async.cov-map b/tests/coverage/closure_macro_async.cov-map index b5f4cee0ec44..b6dd4a930c78 100644 --- a/tests/coverage/closure_macro_async.cov-map +++ b/tests/coverage/closure_macro_async.cov-map @@ -19,15 +19,14 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: closure_macro_async::test::{closure#0} -Raw bytes (66): 0x[01, 01, 01, 01, 05, 0c, 01, 25, 2b, 00, 2c, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 20, 02, 01, 09, 00, 0f, 01, 00, 12, 00, 1b, 01, 00, 1c, 00, 34, 05, 00, 54, 00, 55, 02, 02, 09, 00, 1f, 02, 00, 22, 00, 2e, 02, 01, 0d, 00, 2d, 02, 01, 05, 00, 0b, 01, 01, 01, 00, 02] +Raw bytes (61): 0x[01, 01, 01, 01, 05, 0b, 01, 25, 2b, 00, 2c, 01, 01, 05, 00, 0d, 02, 01, 09, 00, 0f, 01, 00, 12, 00, 1b, 01, 00, 1c, 00, 34, 05, 00, 54, 00, 55, 02, 02, 09, 00, 1f, 02, 00, 22, 00, 2e, 02, 01, 0d, 00, 2d, 02, 01, 05, 00, 0b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/closure_macro_async.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 12 +Number of file 0 mappings: 11 - Code(Counter(0)) at (prev + 37, 43) to (start + 0, 44) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 32) - Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 15) = (c0 - c1) - Code(Counter(0)) at (prev + 0, 18) to (start + 0, 27) @@ -45,25 +44,22 @@ Number of file 0 mappings: 12 Highest counter ID seen: c1 Function name: closure_macro_async::test::{closure#0}::{closure#0} -Raw bytes (60): 0x[01, 01, 03, 01, 05, 01, 0b, 05, 09, 0a, 01, 14, 1c, 00, 1d, 01, 02, 11, 00, 18, 01, 00, 1b, 00, 22, 01, 01, 10, 00, 21, 05, 01, 11, 00, 19, 05, 00, 1a, 00, 1e, 05, 01, 11, 00, 27, 02, 02, 11, 00, 16, 06, 00, 17, 00, 1e, 01, 02, 09, 00, 0a] +Raw bytes (51): 0x[01, 01, 01, 01, 05, 09, 01, 14, 1c, 00, 1d, 01, 02, 11, 00, 18, 01, 00, 1b, 00, 22, 01, 01, 10, 00, 21, 05, 01, 11, 00, 19, 05, 01, 11, 00, 27, 02, 02, 11, 00, 16, 02, 00, 17, 00, 1e, 01, 02, 09, 00, 0a] Number of files: 1 - file 0 => $DIR/closure_macro_async.rs -Number of expressions: 3 +Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(0), rhs = Expression(2, Add) -- expression 2 operands: lhs = Counter(1), rhs = Counter(2) -Number of file 0 mappings: 10 +Number of file 0 mappings: 9 - Code(Counter(0)) at (prev + 20, 28) to (start + 0, 29) - Code(Counter(0)) at (prev + 2, 17) to (start + 0, 24) - Code(Counter(0)) at (prev + 0, 27) to (start + 0, 34) - Code(Counter(0)) at (prev + 1, 16) to (start + 0, 33) - Code(Counter(1)) at (prev + 1, 17) to (start + 0, 25) -- Code(Counter(1)) at (prev + 0, 26) to (start + 0, 30) - Code(Counter(1)) at (prev + 1, 17) to (start + 0, 39) - Code(Expression(0, Sub)) at (prev + 2, 17) to (start + 0, 22) = (c0 - c1) -- Code(Expression(1, Sub)) at (prev + 0, 23) to (start + 0, 30) - = (c0 - (c1 + c2)) +- Code(Expression(0, Sub)) at (prev + 0, 23) to (start + 0, 30) + = (c0 - c1) - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) Highest counter ID seen: c1 diff --git a/tests/coverage/conditions.cov-map b/tests/coverage/conditions.cov-map index 29d9604085ed..c6eba8c8b3ab 100644 --- a/tests/coverage/conditions.cov-map +++ b/tests/coverage/conditions.cov-map @@ -1,8 +1,8 @@ Function name: conditions::main -Raw bytes (656): 0x[01, 01, 57, 05, 09, 01, 05, 09, 5d, 09, 27, 5d, 61, 27, 65, 5d, 61, 09, 23, 27, 65, 5d, 61, 01, 03, 03, 0d, 11, 51, 11, 4f, 51, 55, 4f, 59, 51, 55, 11, 4b, 4f, 59, 51, 55, 03, 9f, 01, 0d, 11, 0d, 11, 0d, 11, 0d, 11, 0d, 11, 0d, 11, 0d, 11, 9f, 01, 15, 0d, 11, 19, 45, 19, 97, 01, 45, 49, 97, 01, 4d, 45, 49, 19, 93, 01, 97, 01, 4d, 45, 49, 9f, 01, 9b, 02, 0d, 11, 15, 19, 15, 19, 15, 19, 15, 19, 15, 19, 1d, 21, 15, 19, 9b, 02, 1d, 15, 19, 21, 39, 21, e3, 01, 39, 3d, e3, 01, 41, 39, 3d, 21, df, 01, e3, 01, 41, 39, 3d, 9b, 02, d7, 02, 15, 19, 1d, 21, 9b, 02, d7, 02, 15, 19, 1d, 21, 9b, 02, d7, 02, 15, 19, 1d, 21, 9b, 02, d7, 02, 15, 19, 1d, 21, 9b, 02, d7, 02, 15, 19, 1d, 21, 25, 29, 1d, 21, d7, 02, 25, 1d, 21, 29, 2d, 29, cf, 02, 2d, 31, cf, 02, 35, 2d, 31, 29, cb, 02, cf, 02, 35, 2d, 31, d7, 02, db, 02, 1d, 21, 25, 29, 53, 01, 03, 01, 00, 0a, 01, 01, 09, 00, 16, 01, 00, 19, 00, 1a, 01, 01, 08, 00, 0c, 01, 00, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 03, 09, 00, 0a, 01, 00, 10, 00, 1d, 05, 01, 09, 00, 17, 05, 01, 09, 00, 0a, 06, 01, 0f, 00, 1c, 09, 01, 0c, 00, 19, 0a, 00, 1d, 00, 2a, 0e, 00, 2e, 00, 3c, 23, 00, 3d, 02, 0a, 1e, 02, 09, 00, 0a, 09, 01, 09, 00, 17, 09, 01, 09, 00, 12, 2a, 02, 09, 00, 0f, 03, 03, 09, 00, 16, 03, 00, 19, 00, 1a, 03, 01, 08, 00, 0c, 03, 00, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 02, 08, 00, 15, 0d, 00, 16, 02, 06, 2e, 02, 0f, 00, 1c, 11, 01, 0c, 00, 19, 32, 00, 1d, 00, 2a, 36, 00, 2e, 00, 3c, 4b, 00, 3d, 02, 0a, 46, 02, 09, 00, 0a, 11, 01, 09, 00, 17, 52, 02, 09, 00, 0f, 9f, 01, 03, 08, 00, 0c, 9f, 01, 01, 0d, 00, 1a, 9f, 01, 00, 1d, 00, 1e, 9f, 01, 01, 0c, 00, 10, 9f, 01, 00, 11, 02, 0a, 00, 02, 09, 00, 0a, 9f, 01, 02, 0c, 00, 19, 15, 00, 1a, 02, 0a, 72, 04, 11, 00, 1e, 19, 01, 10, 00, 1d, 7a, 00, 21, 00, 2e, 7e, 00, 32, 00, 40, 93, 01, 00, 41, 02, 0e, 8e, 01, 02, 0d, 00, 0e, 19, 01, 0d, 00, 1b, 9a, 01, 02, 0d, 00, 13, 00, 02, 05, 00, 06, 9b, 02, 02, 09, 00, 16, 9b, 02, 00, 19, 00, 1a, 9b, 02, 01, 08, 00, 0c, 9b, 02, 00, 0d, 02, 06, 00, 02, 05, 00, 06, d7, 02, 02, 09, 00, 0a, 9b, 02, 00, 10, 00, 1d, 1d, 00, 1e, 02, 06, be, 01, 02, 0f, 00, 1c, 21, 01, 0c, 00, 19, c6, 01, 00, 1d, 00, 2a, ca, 01, 00, 2e, 00, 3c, df, 01, 00, 3d, 02, 0a, da, 01, 02, 09, 00, 0a, 21, 01, 09, 00, 17, 96, 02, 02, 0d, 00, 20, 96, 02, 00, 23, 00, 2c, 96, 02, 01, 09, 00, 11, 96, 02, 00, 12, 00, 1b, 96, 02, 01, 09, 00, 0f, db, 02, 03, 09, 00, 0a, d7, 02, 00, 10, 00, 1d, 25, 00, 1e, 02, 06, aa, 02, 02, 0f, 00, 1c, 29, 01, 0c, 00, 19, b2, 02, 00, 1d, 00, 2a, b6, 02, 00, 2e, 00, 3c, cb, 02, 00, 3d, 02, 0a, c6, 02, 02, 09, 00, 0a, 29, 01, 09, 00, 17, d2, 02, 02, 09, 00, 0f, 01, 02, 01, 00, 02] +Raw bytes (642): 0x[01, 01, 54, 05, 09, 01, 05, 09, 5d, 09, 27, 5d, 61, 27, 65, 5d, 61, 09, 23, 27, 65, 5d, 61, 01, 03, 03, 0d, 11, 51, 11, 4f, 51, 55, 4f, 59, 51, 55, 11, 4b, 4f, 59, 51, 55, 03, 9f, 01, 0d, 11, 0d, 11, 0d, 11, 0d, 11, 0d, 11, 0d, 11, 0d, 11, 9f, 01, 15, 0d, 11, 19, 45, 19, 97, 01, 45, 49, 97, 01, 4d, 45, 49, 19, 93, 01, 97, 01, 4d, 45, 49, 9f, 01, 8f, 02, 0d, 11, 15, 19, 15, 19, 15, 19, 15, 19, 15, 19, 1d, 21, 15, 19, 8f, 02, 1d, 15, 19, 21, 39, 21, e3, 01, 39, 3d, e3, 01, 41, 39, 3d, 21, df, 01, e3, 01, 41, 39, 3d, 8f, 02, cb, 02, 15, 19, 1d, 21, 8f, 02, cb, 02, 15, 19, 1d, 21, 8f, 02, cb, 02, 15, 19, 1d, 21, 8f, 02, cb, 02, 15, 19, 1d, 21, 25, 29, 1d, 21, cb, 02, 25, 1d, 21, 29, 2d, 29, c3, 02, 2d, 31, c3, 02, 35, 2d, 31, 29, bf, 02, c3, 02, 35, 2d, 31, cb, 02, cf, 02, 1d, 21, 25, 29, 52, 01, 03, 01, 00, 0a, 01, 01, 09, 00, 16, 01, 00, 19, 00, 1a, 01, 01, 08, 00, 0c, 01, 00, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 03, 09, 00, 0a, 01, 00, 10, 00, 1d, 05, 01, 09, 00, 17, 05, 01, 09, 00, 0a, 06, 01, 0f, 00, 1c, 09, 01, 0c, 00, 19, 0a, 00, 1d, 00, 2a, 0e, 00, 2e, 00, 3c, 23, 00, 3d, 02, 0a, 1e, 02, 09, 00, 0a, 09, 01, 09, 00, 17, 09, 01, 09, 00, 12, 2a, 02, 09, 00, 0f, 03, 03, 09, 00, 16, 03, 00, 19, 00, 1a, 03, 01, 08, 00, 0c, 03, 00, 0d, 02, 06, 00, 02, 05, 00, 06, 03, 02, 08, 00, 15, 0d, 00, 16, 02, 06, 2e, 02, 0f, 00, 1c, 11, 01, 0c, 00, 19, 32, 00, 1d, 00, 2a, 36, 00, 2e, 00, 3c, 4b, 00, 3d, 02, 0a, 46, 02, 09, 00, 0a, 11, 01, 09, 00, 17, 52, 02, 09, 00, 0f, 9f, 01, 03, 08, 00, 0c, 9f, 01, 01, 0d, 00, 1a, 9f, 01, 00, 1d, 00, 1e, 9f, 01, 01, 0c, 00, 10, 9f, 01, 00, 11, 02, 0a, 00, 02, 09, 00, 0a, 9f, 01, 02, 0c, 00, 19, 15, 00, 1a, 02, 0a, 72, 04, 11, 00, 1e, 19, 01, 10, 00, 1d, 7a, 00, 21, 00, 2e, 7e, 00, 32, 00, 40, 93, 01, 00, 41, 02, 0e, 8e, 01, 02, 0d, 00, 0e, 19, 01, 0d, 00, 1b, 9a, 01, 02, 0d, 00, 13, 00, 02, 05, 00, 06, 8f, 02, 02, 09, 00, 16, 8f, 02, 00, 19, 00, 1a, 8f, 02, 01, 08, 00, 0c, 8f, 02, 00, 0d, 02, 06, 00, 02, 05, 00, 06, cb, 02, 02, 09, 00, 0a, 8f, 02, 00, 10, 00, 1d, 1d, 00, 1e, 02, 06, be, 01, 02, 0f, 00, 1c, 21, 01, 0c, 00, 19, c6, 01, 00, 1d, 00, 2a, ca, 01, 00, 2e, 00, 3c, df, 01, 00, 3d, 02, 0a, da, 01, 02, 09, 00, 0a, 21, 01, 09, 00, 17, 8a, 02, 02, 0d, 00, 20, 8a, 02, 00, 23, 00, 2c, 8a, 02, 01, 09, 00, 11, 8a, 02, 01, 09, 00, 0f, cf, 02, 03, 09, 00, 0a, cb, 02, 00, 10, 00, 1d, 25, 00, 1e, 02, 06, 9e, 02, 02, 0f, 00, 1c, 29, 01, 0c, 00, 19, a6, 02, 00, 1d, 00, 2a, aa, 02, 00, 2e, 00, 3c, bf, 02, 00, 3d, 02, 0a, ba, 02, 02, 09, 00, 0a, 29, 01, 09, 00, 17, c6, 02, 02, 09, 00, 0f, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => $DIR/conditions.rs -Number of expressions: 87 +Number of expressions: 84 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) - expression 1 operands: lhs = Counter(0), rhs = Counter(1) - expression 2 operands: lhs = Counter(2), rhs = Counter(23) @@ -41,7 +41,7 @@ Number of expressions: 87 - expression 35 operands: lhs = Counter(6), rhs = Expression(36, Add) - expression 36 operands: lhs = Expression(37, Add), rhs = Counter(19) - expression 37 operands: lhs = Counter(17), rhs = Counter(18) -- expression 38 operands: lhs = Expression(39, Add), rhs = Expression(70, Add) +- expression 38 operands: lhs = Expression(39, Add), rhs = Expression(67, Add) - expression 39 operands: lhs = Counter(3), rhs = Counter(4) - expression 40 operands: lhs = Counter(5), rhs = Counter(6) - expression 41 operands: lhs = Counter(5), rhs = Counter(6) @@ -50,7 +50,7 @@ Number of expressions: 87 - expression 44 operands: lhs = Counter(5), rhs = Counter(6) - expression 45 operands: lhs = Counter(7), rhs = Counter(8) - expression 46 operands: lhs = Counter(5), rhs = Counter(6) -- expression 47 operands: lhs = Expression(70, Add), rhs = Counter(7) +- expression 47 operands: lhs = Expression(67, Add), rhs = Counter(7) - expression 48 operands: lhs = Counter(5), rhs = Counter(6) - expression 49 operands: lhs = Counter(8), rhs = Counter(14) - expression 50 operands: lhs = Counter(8), rhs = Expression(56, Add) @@ -60,37 +60,34 @@ Number of expressions: 87 - expression 54 operands: lhs = Counter(8), rhs = Expression(55, Add) - expression 55 operands: lhs = Expression(56, Add), rhs = Counter(16) - expression 56 operands: lhs = Counter(14), rhs = Counter(15) -- expression 57 operands: lhs = Expression(70, Add), rhs = Expression(85, Add) +- expression 57 operands: lhs = Expression(67, Add), rhs = Expression(82, Add) - expression 58 operands: lhs = Counter(5), rhs = Counter(6) - expression 59 operands: lhs = Counter(7), rhs = Counter(8) -- expression 60 operands: lhs = Expression(70, Add), rhs = Expression(85, Add) +- expression 60 operands: lhs = Expression(67, Add), rhs = Expression(82, Add) - expression 61 operands: lhs = Counter(5), rhs = Counter(6) - expression 62 operands: lhs = Counter(7), rhs = Counter(8) -- expression 63 operands: lhs = Expression(70, Add), rhs = Expression(85, Add) +- expression 63 operands: lhs = Expression(67, Add), rhs = Expression(82, Add) - expression 64 operands: lhs = Counter(5), rhs = Counter(6) - expression 65 operands: lhs = Counter(7), rhs = Counter(8) -- expression 66 operands: lhs = Expression(70, Add), rhs = Expression(85, Add) +- expression 66 operands: lhs = Expression(67, Add), rhs = Expression(82, Add) - expression 67 operands: lhs = Counter(5), rhs = Counter(6) - expression 68 operands: lhs = Counter(7), rhs = Counter(8) -- expression 69 operands: lhs = Expression(70, Add), rhs = Expression(85, Add) -- expression 70 operands: lhs = Counter(5), rhs = Counter(6) -- expression 71 operands: lhs = Counter(7), rhs = Counter(8) -- expression 72 operands: lhs = Counter(9), rhs = Counter(10) -- expression 73 operands: lhs = Counter(7), rhs = Counter(8) -- expression 74 operands: lhs = Expression(85, Add), rhs = Counter(9) -- expression 75 operands: lhs = Counter(7), rhs = Counter(8) -- expression 76 operands: lhs = Counter(10), rhs = Counter(11) -- expression 77 operands: lhs = Counter(10), rhs = Expression(83, Add) -- expression 78 operands: lhs = Counter(11), rhs = Counter(12) -- expression 79 operands: lhs = Expression(83, Add), rhs = Counter(13) +- expression 69 operands: lhs = Counter(9), rhs = Counter(10) +- expression 70 operands: lhs = Counter(7), rhs = Counter(8) +- expression 71 operands: lhs = Expression(82, Add), rhs = Counter(9) +- expression 72 operands: lhs = Counter(7), rhs = Counter(8) +- expression 73 operands: lhs = Counter(10), rhs = Counter(11) +- expression 74 operands: lhs = Counter(10), rhs = Expression(80, Add) +- expression 75 operands: lhs = Counter(11), rhs = Counter(12) +- expression 76 operands: lhs = Expression(80, Add), rhs = Counter(13) +- expression 77 operands: lhs = Counter(11), rhs = Counter(12) +- expression 78 operands: lhs = Counter(10), rhs = Expression(79, Add) +- expression 79 operands: lhs = Expression(80, Add), rhs = Counter(13) - expression 80 operands: lhs = Counter(11), rhs = Counter(12) -- expression 81 operands: lhs = Counter(10), rhs = Expression(82, Add) -- expression 82 operands: lhs = Expression(83, Add), rhs = Counter(13) -- expression 83 operands: lhs = Counter(11), rhs = Counter(12) -- expression 84 operands: lhs = Expression(85, Add), rhs = Expression(86, Add) -- expression 85 operands: lhs = Counter(7), rhs = Counter(8) -- expression 86 operands: lhs = Counter(9), rhs = Counter(10) -Number of file 0 mappings: 83 +- expression 81 operands: lhs = Expression(82, Add), rhs = Expression(83, Add) +- expression 82 operands: lhs = Counter(7), rhs = Counter(8) +- expression 83 operands: lhs = Counter(9), rhs = Counter(10) +Number of file 0 mappings: 82 - Code(Counter(0)) at (prev + 3, 1) to (start + 0, 10) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 22) - Code(Counter(0)) at (prev + 0, 25) to (start + 0, 26) @@ -172,18 +169,18 @@ Number of file 0 mappings: 83 - Code(Expression(38, Sub)) at (prev + 2, 13) to (start + 0, 19) = ((c3 + c4) - (c5 + c6)) - Code(Zero) at (prev + 2, 5) to (start + 0, 6) -- Code(Expression(70, Add)) at (prev + 2, 9) to (start + 0, 22) +- Code(Expression(67, Add)) at (prev + 2, 9) to (start + 0, 22) = (c5 + c6) -- Code(Expression(70, Add)) at (prev + 0, 25) to (start + 0, 26) +- Code(Expression(67, Add)) at (prev + 0, 25) to (start + 0, 26) = (c5 + c6) -- Code(Expression(70, Add)) at (prev + 1, 8) to (start + 0, 12) +- Code(Expression(67, Add)) at (prev + 1, 8) to (start + 0, 12) = (c5 + c6) -- Code(Expression(70, Add)) at (prev + 0, 13) to (start + 2, 6) +- Code(Expression(67, Add)) at (prev + 0, 13) to (start + 2, 6) = (c5 + c6) - Code(Zero) at (prev + 2, 5) to (start + 0, 6) -- Code(Expression(85, Add)) at (prev + 2, 9) to (start + 0, 10) +- Code(Expression(82, Add)) at (prev + 2, 9) to (start + 0, 10) = (c7 + c8) -- Code(Expression(70, Add)) at (prev + 0, 16) to (start + 0, 29) +- Code(Expression(67, Add)) at (prev + 0, 16) to (start + 0, 29) = (c5 + c6) - Code(Counter(7)) at (prev + 0, 30) to (start + 2, 6) - Code(Expression(47, Sub)) at (prev + 2, 15) to (start + 0, 28) @@ -198,34 +195,32 @@ Number of file 0 mappings: 83 - Code(Expression(54, Sub)) at (prev + 2, 9) to (start + 0, 10) = (c8 - ((c14 + c15) + c16)) - Code(Counter(8)) at (prev + 1, 9) to (start + 0, 23) -- Code(Expression(69, Sub)) at (prev + 2, 13) to (start + 0, 32) +- Code(Expression(66, Sub)) at (prev + 2, 13) to (start + 0, 32) = ((c5 + c6) - (c7 + c8)) -- Code(Expression(69, Sub)) at (prev + 0, 35) to (start + 0, 44) +- Code(Expression(66, Sub)) at (prev + 0, 35) to (start + 0, 44) = ((c5 + c6) - (c7 + c8)) -- Code(Expression(69, Sub)) at (prev + 1, 9) to (start + 0, 17) +- Code(Expression(66, Sub)) at (prev + 1, 9) to (start + 0, 17) = ((c5 + c6) - (c7 + c8)) -- Code(Expression(69, Sub)) at (prev + 0, 18) to (start + 0, 27) +- Code(Expression(66, Sub)) at (prev + 1, 9) to (start + 0, 15) = ((c5 + c6) - (c7 + c8)) -- Code(Expression(69, Sub)) at (prev + 1, 9) to (start + 0, 15) - = ((c5 + c6) - (c7 + c8)) -- Code(Expression(86, Add)) at (prev + 3, 9) to (start + 0, 10) +- Code(Expression(83, Add)) at (prev + 3, 9) to (start + 0, 10) = (c9 + c10) -- Code(Expression(85, Add)) at (prev + 0, 16) to (start + 0, 29) +- Code(Expression(82, Add)) at (prev + 0, 16) to (start + 0, 29) = (c7 + c8) - Code(Counter(9)) at (prev + 0, 30) to (start + 2, 6) -- Code(Expression(74, Sub)) at (prev + 2, 15) to (start + 0, 28) +- Code(Expression(71, Sub)) at (prev + 2, 15) to (start + 0, 28) = ((c7 + c8) - c9) - Code(Counter(10)) at (prev + 1, 12) to (start + 0, 25) -- Code(Expression(76, Sub)) at (prev + 0, 29) to (start + 0, 42) +- Code(Expression(73, Sub)) at (prev + 0, 29) to (start + 0, 42) = (c10 - c11) -- Code(Expression(77, Sub)) at (prev + 0, 46) to (start + 0, 60) +- Code(Expression(74, Sub)) at (prev + 0, 46) to (start + 0, 60) = (c10 - (c11 + c12)) -- Code(Expression(82, Add)) at (prev + 0, 61) to (start + 2, 10) +- Code(Expression(79, Add)) at (prev + 0, 61) to (start + 2, 10) = ((c11 + c12) + c13) -- Code(Expression(81, Sub)) at (prev + 2, 9) to (start + 0, 10) +- Code(Expression(78, Sub)) at (prev + 2, 9) to (start + 0, 10) = (c10 - ((c11 + c12) + c13)) - Code(Counter(10)) at (prev + 1, 9) to (start + 0, 23) -- Code(Expression(84, Sub)) at (prev + 2, 9) to (start + 0, 15) +- Code(Expression(81, Sub)) at (prev + 2, 9) to (start + 0, 15) = ((c7 + c8) - (c9 + c10)) - Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2) Highest counter ID seen: c10 diff --git a/tests/coverage/coverage_attr_closure.cov-map b/tests/coverage/coverage_attr_closure.cov-map index deba65f22cca..aea805df303e 100644 --- a/tests/coverage/coverage_attr_closure.cov-map +++ b/tests/coverage/coverage_attr_closure.cov-map @@ -1,24 +1,22 @@ Function name: coverage_attr_closure::GLOBAL_CLOSURE_ON::{closure#0} -Raw bytes (24): 0x[01, 01, 00, 04, 01, 06, 0f, 00, 10, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 17, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 06, 0f, 00, 10, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/coverage_attr_closure.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 6, 15) to (start + 0, 16) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 23) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: coverage_attr_closure::contains_closures_off::{closure#0} (unused) -Raw bytes (24): 0x[01, 01, 00, 04, 00, 1d, 13, 00, 14, 00, 01, 09, 00, 11, 00, 00, 12, 00, 1b, 00, 01, 05, 00, 06] +Raw bytes (19): 0x[01, 01, 00, 03, 00, 1d, 13, 00, 14, 00, 01, 09, 00, 11, 00, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/coverage_attr_closure.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Zero) at (prev + 29, 19) to (start + 0, 20) - Code(Zero) at (prev + 1, 9) to (start + 0, 17) -- Code(Zero) at (prev + 0, 18) to (start + 0, 27) - Code(Zero) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: (none) @@ -35,14 +33,13 @@ Number of file 0 mappings: 4 Highest counter ID seen: c0 Function name: coverage_attr_closure::contains_closures_on::{closure#0} (unused) -Raw bytes (24): 0x[01, 01, 00, 04, 00, 11, 13, 00, 14, 00, 01, 09, 00, 11, 00, 00, 12, 00, 1b, 00, 01, 05, 00, 06] +Raw bytes (19): 0x[01, 01, 00, 03, 00, 11, 13, 00, 14, 00, 01, 09, 00, 11, 00, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/coverage_attr_closure.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Zero) at (prev + 17, 19) to (start + 0, 20) - Code(Zero) at (prev + 1, 9) to (start + 0, 17) -- Code(Zero) at (prev + 0, 18) to (start + 0, 27) - Code(Zero) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: (none) diff --git a/tests/coverage/drop_trait.cov-map b/tests/coverage/drop_trait.cov-map index dcf9dbd8c647..b4a1499d5f95 100644 --- a/tests/coverage/drop_trait.cov-map +++ b/tests/coverage/drop_trait.cov-map @@ -1,21 +1,20 @@ Function name: ::drop -Raw bytes (24): 0x[01, 01, 00, 04, 01, 09, 05, 00, 17, 01, 01, 09, 00, 11, 01, 00, 12, 00, 24, 01, 01, 05, 00, 06] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 09, 05, 00, 17, 01, 01, 09, 00, 11, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/drop_trait.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 9, 5) to (start + 0, 23) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 18) to (start + 0, 36) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: c0 Function name: drop_trait::main -Raw bytes (69): 0x[01, 01, 00, 0d, 01, 0e, 01, 00, 1c, 01, 01, 09, 00, 15, 01, 00, 18, 00, 30, 01, 02, 09, 00, 0d, 01, 00, 10, 00, 2a, 01, 02, 08, 00, 0c, 01, 01, 09, 00, 11, 01, 00, 12, 00, 29, 01, 01, 10, 00, 16, 00, 01, 05, 00, 06, 00, 02, 0d, 00, 28, 00, 02, 05, 00, 0b, 01, 01, 01, 00, 02] +Raw bytes (64): 0x[01, 01, 00, 0c, 01, 0e, 01, 00, 1c, 01, 01, 09, 00, 15, 01, 00, 18, 00, 30, 01, 02, 09, 00, 0d, 01, 00, 10, 00, 2a, 01, 02, 08, 00, 0c, 01, 01, 09, 00, 11, 01, 01, 10, 00, 16, 00, 01, 05, 00, 06, 00, 02, 0d, 00, 28, 00, 02, 05, 00, 0b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/drop_trait.rs Number of expressions: 0 -Number of file 0 mappings: 13 +Number of file 0 mappings: 12 - Code(Counter(0)) at (prev + 14, 1) to (start + 0, 28) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 21) - Code(Counter(0)) at (prev + 0, 24) to (start + 0, 48) @@ -23,7 +22,6 @@ Number of file 0 mappings: 13 - Code(Counter(0)) at (prev + 0, 16) to (start + 0, 42) - Code(Counter(0)) at (prev + 2, 8) to (start + 0, 12) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 18) to (start + 0, 41) - Code(Counter(0)) at (prev + 1, 16) to (start + 0, 22) - Code(Zero) at (prev + 1, 5) to (start + 0, 6) - Code(Zero) at (prev + 2, 13) to (start + 0, 40) diff --git a/tests/coverage/generics.cov-map b/tests/coverage/generics.cov-map index 7f9b7ee0f471..0d9cf9a1449b 100644 --- a/tests/coverage/generics.cov-map +++ b/tests/coverage/generics.cov-map @@ -1,12 +1,11 @@ Function name: as core::ops::drop::Drop>::drop -Raw bytes (24): 0x[01, 01, 00, 04, 01, 11, 05, 00, 17, 01, 01, 09, 00, 11, 01, 00, 12, 00, 24, 01, 01, 05, 00, 06] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 11, 05, 00, 17, 01, 01, 09, 00, 11, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/generics.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 17, 5) to (start + 0, 23) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 18) to (start + 0, 36) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: c0 @@ -22,14 +21,13 @@ Number of file 0 mappings: 3 Highest counter ID seen: c0 Function name: as core::ops::drop::Drop>::drop -Raw bytes (24): 0x[01, 01, 00, 04, 01, 11, 05, 00, 17, 01, 01, 09, 00, 11, 01, 00, 12, 00, 24, 01, 01, 05, 00, 06] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 11, 05, 00, 17, 01, 01, 09, 00, 11, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/generics.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 17, 5) to (start + 0, 23) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 18) to (start + 0, 36) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: c0 @@ -45,11 +43,11 @@ Number of file 0 mappings: 3 Highest counter ID seen: c0 Function name: generics::main -Raw bytes (99): 0x[01, 01, 00, 13, 01, 16, 01, 00, 1c, 01, 01, 09, 00, 18, 01, 00, 1b, 00, 33, 01, 01, 05, 00, 10, 01, 00, 11, 00, 1d, 01, 02, 09, 00, 10, 01, 00, 13, 00, 2f, 01, 01, 05, 00, 08, 01, 00, 09, 00, 15, 01, 01, 05, 00, 08, 01, 00, 09, 00, 15, 01, 02, 08, 00, 0c, 01, 01, 09, 00, 11, 01, 00, 12, 00, 29, 01, 01, 10, 00, 16, 00, 01, 05, 00, 06, 00, 02, 0d, 00, 28, 00, 02, 05, 00, 0b, 01, 01, 01, 00, 02] +Raw bytes (94): 0x[01, 01, 00, 12, 01, 16, 01, 00, 1c, 01, 01, 09, 00, 18, 01, 00, 1b, 00, 33, 01, 01, 05, 00, 10, 01, 00, 11, 00, 1d, 01, 02, 09, 00, 10, 01, 00, 13, 00, 2f, 01, 01, 05, 00, 08, 01, 00, 09, 00, 15, 01, 01, 05, 00, 08, 01, 00, 09, 00, 15, 01, 02, 08, 00, 0c, 01, 01, 09, 00, 11, 01, 01, 10, 00, 16, 00, 01, 05, 00, 06, 00, 02, 0d, 00, 28, 00, 02, 05, 00, 0b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/generics.rs Number of expressions: 0 -Number of file 0 mappings: 19 +Number of file 0 mappings: 18 - Code(Counter(0)) at (prev + 22, 1) to (start + 0, 28) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 24) - Code(Counter(0)) at (prev + 0, 27) to (start + 0, 51) @@ -63,7 +61,6 @@ Number of file 0 mappings: 19 - Code(Counter(0)) at (prev + 0, 9) to (start + 0, 21) - Code(Counter(0)) at (prev + 2, 8) to (start + 0, 12) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 18) to (start + 0, 41) - Code(Counter(0)) at (prev + 1, 16) to (start + 0, 22) - Code(Zero) at (prev + 1, 5) to (start + 0, 6) - Code(Zero) at (prev + 2, 13) to (start + 0, 40) diff --git a/tests/coverage/inline-dead.cov-map b/tests/coverage/inline-dead.cov-map index 95a5f6bf68b7..c461b3a6eedc 100644 --- a/tests/coverage/inline-dead.cov-map +++ b/tests/coverage/inline-dead.cov-map @@ -25,14 +25,13 @@ Number of file 0 mappings: 5 Highest counter ID seen: c1 Function name: inline_dead::main -Raw bytes (39): 0x[01, 01, 00, 07, 01, 04, 01, 00, 0a, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 12, 01, 00, 14, 00, 21, 01, 02, 09, 00, 0a, 01, 03, 05, 00, 0d, 01, 01, 01, 00, 02] +Raw bytes (34): 0x[01, 01, 00, 06, 01, 04, 01, 00, 0a, 01, 01, 05, 00, 0d, 01, 00, 14, 00, 21, 01, 02, 09, 00, 0a, 01, 03, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/inline-dead.rs Number of expressions: 0 -Number of file 0 mappings: 7 +Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 4, 1) to (start + 0, 10) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 18) - Code(Counter(0)) at (prev + 0, 20) to (start + 0, 33) - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) - Code(Counter(0)) at (prev + 3, 5) to (start + 0, 13) diff --git a/tests/coverage/inner_items.cov-map b/tests/coverage/inner_items.cov-map index ca6ddfda2ddf..0e3ed47bbc67 100644 --- a/tests/coverage/inner_items.cov-map +++ b/tests/coverage/inner_items.cov-map @@ -53,18 +53,17 @@ Number of file 0 mappings: 16 Highest counter ID seen: c2 Function name: inner_items::main::in_func -Raw bytes (44): 0x[01, 01, 00, 08, 01, 12, 05, 00, 17, 01, 01, 0d, 00, 0e, 01, 00, 11, 00, 12, 01, 01, 0d, 00, 0e, 01, 00, 11, 00, 16, 01, 01, 09, 00, 11, 01, 00, 12, 00, 1a, 01, 01, 05, 00, 06] +Raw bytes (39): 0x[01, 01, 00, 07, 01, 12, 05, 00, 17, 01, 01, 0d, 00, 0e, 01, 00, 11, 00, 12, 01, 01, 0d, 00, 0e, 01, 00, 11, 00, 16, 01, 01, 09, 00, 11, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/inner_items.rs Number of expressions: 0 -Number of file 0 mappings: 8 +Number of file 0 mappings: 7 - Code(Counter(0)) at (prev + 18, 5) to (start + 0, 23) - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 14) - Code(Counter(0)) at (prev + 0, 17) to (start + 0, 18) - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 14) - Code(Counter(0)) at (prev + 0, 17) to (start + 0, 22) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 18) to (start + 0, 26) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: c0 diff --git a/tests/coverage/issue-83601.cov-map b/tests/coverage/issue-83601.cov-map index e42b5591c0fb..6d89397023c6 100644 --- a/tests/coverage/issue-83601.cov-map +++ b/tests/coverage/issue-83601.cov-map @@ -1,9 +1,9 @@ Function name: issue_83601::main -Raw bytes (74): 0x[01, 01, 00, 0e, 01, 06, 01, 00, 0a, 01, 01, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 01, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 14, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 14, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 14, 01, 01, 01, 00, 02] +Raw bytes (59): 0x[01, 01, 00, 0b, 01, 06, 01, 00, 0a, 01, 01, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 01, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/issue-83601.rs Number of expressions: 0 -Number of file 0 mappings: 14 +Number of file 0 mappings: 11 - Code(Counter(0)) at (prev + 6, 1) to (start + 0, 10) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 12) - Code(Counter(0)) at (prev + 0, 15) to (start + 0, 21) @@ -12,11 +12,8 @@ Number of file 0 mappings: 14 - Code(Counter(0)) at (prev + 0, 15) to (start + 0, 21) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 diff --git a/tests/coverage/issue-84561.cov-map b/tests/coverage/issue-84561.cov-map index e5bb1afdcc26..ca009260cddc 100644 --- a/tests/coverage/issue-84561.cov-map +++ b/tests/coverage/issue-84561.cov-map @@ -1,14 +1,13 @@ Function name: ::fmt -Raw bytes (42): 0x[01, 01, 01, 01, 05, 07, 01, 8a, 01, 05, 00, 43, 01, 01, 09, 00, 0f, 01, 00, 10, 00, 11, 01, 00, 13, 00, 24, 05, 00, 25, 00, 26, 02, 01, 09, 00, 0f, 01, 01, 05, 00, 06] +Raw bytes (37): 0x[01, 01, 01, 01, 05, 06, 01, 8a, 01, 05, 00, 43, 01, 01, 09, 00, 0f, 01, 00, 10, 00, 11, 05, 00, 25, 00, 26, 02, 01, 09, 00, 0f, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/issue-84561.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 7 +Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 138, 5) to (start + 0, 67) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 15) - Code(Counter(0)) at (prev + 0, 16) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 19) to (start + 0, 36) - Code(Counter(1)) at (prev + 0, 37) to (start + 0, 38) - Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 15) = (c0 - c1) @@ -29,54 +28,48 @@ Number of file 0 mappings: 5 Highest counter ID seen: c0 Function name: issue_84561::test1 -Raw bytes (65): 0x[01, 01, 00, 0c, 01, 9a, 01, 01, 00, 0b, 01, 01, 05, 00, 0b, 05, 00, 0c, 00, 1e, 01, 01, 05, 00, 0b, 09, 00, 0c, 00, 1e, 01, 01, 0d, 00, 0e, 01, 01, 05, 00, 0b, 0d, 00, 0c, 00, 1e, 01, 01, 05, 02, 06, 01, 03, 05, 00, 0b, 11, 00, 0c, 00, 1e, 01, 01, 01, 00, 02] +Raw bytes (45): 0x[01, 01, 00, 08, 01, 9a, 01, 01, 00, 0b, 01, 01, 05, 00, 0b, 01, 01, 05, 00, 0b, 01, 01, 0d, 00, 0e, 01, 01, 05, 00, 0b, 01, 01, 05, 02, 06, 01, 03, 05, 00, 0b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/issue-84561.rs Number of expressions: 0 -Number of file 0 mappings: 12 +Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 154, 1) to (start + 0, 11) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 11) -- Code(Counter(1)) at (prev + 0, 12) to (start + 0, 30) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 11) -- Code(Counter(2)) at (prev + 0, 12) to (start + 0, 30) - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 14) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 11) -- Code(Counter(3)) at (prev + 0, 12) to (start + 0, 30) - Code(Counter(0)) at (prev + 1, 5) to (start + 2, 6) - Code(Counter(0)) at (prev + 3, 5) to (start + 0, 11) -- Code(Counter(4)) at (prev + 0, 12) to (start + 0, 30) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c4 +Highest counter ID seen: c0 Function name: issue_84561::test2 -Raw bytes (25): 0x[01, 01, 00, 04, 01, b0, 01, 01, 00, 0b, 01, 01, 05, 00, 10, 05, 00, 11, 00, 23, 01, 01, 01, 00, 02] +Raw bytes (20): 0x[01, 01, 00, 03, 01, b0, 01, 01, 00, 0b, 01, 01, 05, 00, 10, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/issue-84561.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 176, 1) to (start + 0, 11) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 16) -- Code(Counter(1)) at (prev + 0, 17) to (start + 0, 35) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) -Highest counter ID seen: c1 +Highest counter ID seen: c0 Function name: issue_84561::test2::call_print -Raw bytes (25): 0x[01, 01, 00, 04, 01, a7, 01, 09, 00, 1f, 01, 01, 0d, 00, 13, 01, 00, 14, 00, 18, 01, 01, 09, 00, 0a] +Raw bytes (20): 0x[01, 01, 00, 03, 01, a7, 01, 09, 00, 1f, 01, 01, 0d, 00, 13, 01, 01, 09, 00, 0a] Number of files: 1 - file 0 => $DIR/issue-84561.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 167, 9) to (start + 0, 31) - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 19) -- Code(Counter(0)) at (prev + 0, 20) to (start + 0, 24) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 10) Highest counter ID seen: c0 Function name: issue_84561::test3 -Raw bytes (409): 0x[01, 01, 0a, 01, 05, 01, 09, 01, 0d, 11, 15, 1d, 21, 19, 1d, 19, 1d, 19, 1d, 27, 25, 1d, 21, 4d, 01, 08, 01, 00, 0b, 01, 01, 09, 00, 10, 01, 00, 13, 00, 2e, 01, 01, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 01, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 14, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 14, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 14, 01, 02, 05, 00, 0f, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0f, 01, 01, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 14, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 14, 01, 02, 05, 00, 0f, 00, 00, 20, 00, 24, 00, 00, 29, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 01, 01, 05, 00, 0f, 00, 05, 09, 00, 0d, 00, 03, 09, 00, 10, 00, 02, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 01, 04, 09, 00, 10, 01, 00, 13, 00, 2e, 01, 02, 05, 00, 0f, 01, 04, 05, 00, 0f, 01, 04, 05, 00, 0f, 01, 04, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 04, 08, 00, 0f, 05, 01, 09, 00, 13, 02, 05, 09, 00, 13, 01, 05, 08, 00, 0f, 09, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 06, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 01, 03, 05, 00, 0f, 01, 01, 0c, 00, 13, 0d, 01, 0d, 00, 13, 0a, 02, 0d, 00, 13, 11, 04, 05, 00, 0f, 11, 02, 0c, 00, 13, 15, 01, 0d, 00, 13, 0e, 02, 0d, 00, 13, 27, 03, 05, 00, 0f, 19, 01, 0c, 00, 13, 1d, 01, 0d, 00, 17, 1d, 04, 0d, 00, 13, 1e, 02, 0d, 00, 17, 1e, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 1e, 02, 15, 00, 1b, 21, 04, 0d, 00, 13, 22, 03, 09, 00, 19, 25, 02, 05, 00, 0f, 25, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02] +Raw bytes (340): 0x[01, 01, 08, 01, 05, 01, 09, 01, 0d, 11, 15, 1d, 21, 19, 1d, 19, 1d, 19, 1d, 40, 01, 08, 01, 00, 0b, 01, 01, 09, 00, 10, 01, 00, 13, 00, 2e, 01, 01, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 01, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0d, 01, 02, 05, 00, 0f, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0f, 01, 01, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0f, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0d, 01, 02, 05, 00, 0f, 00, 00, 29, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 01, 01, 05, 00, 0f, 00, 08, 09, 00, 10, 00, 02, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 01, 04, 09, 00, 10, 01, 00, 13, 00, 2e, 01, 02, 05, 00, 0f, 01, 04, 05, 00, 0f, 01, 04, 05, 00, 0f, 01, 04, 09, 00, 0c, 01, 00, 0f, 00, 15, 01, 01, 05, 00, 0f, 01, 04, 08, 00, 0f, 05, 01, 09, 00, 13, 02, 05, 09, 00, 13, 01, 05, 08, 00, 0f, 09, 01, 09, 00, 13, 06, 06, 09, 00, 13, 01, 06, 05, 00, 0f, 01, 01, 0c, 00, 13, 0d, 01, 0d, 00, 13, 0a, 02, 0d, 00, 13, 11, 04, 05, 00, 0f, 11, 02, 0c, 00, 13, 15, 01, 0d, 00, 13, 0e, 02, 0d, 00, 13, 13, 03, 05, 00, 0f, 19, 01, 0c, 00, 13, 1d, 01, 0d, 00, 17, 1d, 04, 0d, 00, 13, 1e, 02, 0d, 00, 17, 1e, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 1e, 02, 15, 00, 1b, 21, 04, 0d, 00, 13, 25, 05, 05, 00, 0f, 00, 05, 05, 00, 0f, 00, 05, 01, 00, 02] Number of files: 1 - file 0 => $DIR/issue-84561.rs -Number of expressions: 10 +Number of expressions: 8 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) - expression 1 operands: lhs = Counter(0), rhs = Counter(2) - expression 2 operands: lhs = Counter(0), rhs = Counter(3) @@ -85,9 +78,7 @@ Number of expressions: 10 - expression 5 operands: lhs = Counter(6), rhs = Counter(7) - expression 6 operands: lhs = Counter(6), rhs = Counter(7) - expression 7 operands: lhs = Counter(6), rhs = Counter(7) -- expression 8 operands: lhs = Expression(9, Add), rhs = Counter(9) -- expression 9 operands: lhs = Counter(7), rhs = Counter(8) -Number of file 0 mappings: 77 +Number of file 0 mappings: 64 - Code(Counter(0)) at (prev + 8, 1) to (start + 0, 11) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 16) - Code(Counter(0)) at (prev + 0, 19) to (start + 0, 46) @@ -98,11 +89,8 @@ Number of file 0 mappings: 77 - Code(Counter(0)) at (prev + 0, 15) to (start + 0, 21) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 20) - Code(Counter(0)) at (prev + 2, 5) to (start + 0, 15) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) @@ -111,19 +99,14 @@ Number of file 0 mappings: 77 - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) -- Code(Zero) at (prev + 0, 32) to (start + 0, 48) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 20) - Code(Counter(0)) at (prev + 2, 5) to (start + 0, 15) -- Code(Zero) at (prev + 0, 32) to (start + 0, 36) - Code(Zero) at (prev + 0, 41) to (start + 0, 48) - Code(Zero) at (prev + 0, 51) to (start + 0, 65) - Code(Zero) at (prev + 0, 75) to (start + 0, 90) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 15) -- Code(Zero) at (prev + 5, 9) to (start + 0, 13) -- Code(Zero) at (prev + 3, 9) to (start + 0, 16) +- Code(Zero) at (prev + 8, 9) to (start + 0, 16) - Code(Zero) at (prev + 2, 13) to (start + 0, 27) - Code(Zero) at (prev + 2, 13) to (start + 0, 28) - Code(Counter(0)) at (prev + 4, 9) to (start + 0, 16) @@ -140,11 +123,9 @@ Number of file 0 mappings: 77 = (c0 - c1) - Code(Counter(0)) at (prev + 5, 8) to (start + 0, 15) - Code(Counter(2)) at (prev + 1, 9) to (start + 0, 19) -- Code(Zero) at (prev + 3, 13) to (start + 0, 29) -- Code(Expression(1, Sub)) at (prev + 3, 9) to (start + 0, 19) +- Code(Expression(1, Sub)) at (prev + 6, 9) to (start + 0, 19) = (c0 - c2) -- Code(Zero) at (prev + 3, 13) to (start + 0, 29) -- Code(Counter(0)) at (prev + 3, 5) to (start + 0, 15) +- Code(Counter(0)) at (prev + 6, 5) to (start + 0, 15) - Code(Counter(0)) at (prev + 1, 12) to (start + 0, 19) - Code(Counter(3)) at (prev + 1, 13) to (start + 0, 19) - Code(Expression(2, Sub)) at (prev + 2, 13) to (start + 0, 19) @@ -154,7 +135,7 @@ Number of file 0 mappings: 77 - Code(Counter(5)) at (prev + 1, 13) to (start + 0, 19) - Code(Expression(3, Sub)) at (prev + 2, 13) to (start + 0, 19) = (c4 - c5) -- Code(Expression(9, Add)) at (prev + 3, 5) to (start + 0, 15) +- Code(Expression(4, Add)) at (prev + 3, 5) to (start + 0, 15) = (c7 + c8) - Code(Counter(6)) at (prev + 1, 12) to (start + 0, 19) - Code(Counter(7)) at (prev + 1, 13) to (start + 0, 23) @@ -167,12 +148,8 @@ Number of file 0 mappings: 77 - Code(Expression(7, Sub)) at (prev + 2, 21) to (start + 0, 27) = (c6 - c7) - Code(Counter(8)) at (prev + 4, 13) to (start + 0, 19) -- Code(Expression(8, Sub)) at (prev + 3, 9) to (start + 0, 25) - = ((c7 + c8) - c9) -- Code(Counter(9)) at (prev + 2, 5) to (start + 0, 15) -- Code(Counter(9)) at (prev + 3, 9) to (start + 0, 34) -- Code(Zero) at (prev + 2, 5) to (start + 0, 15) -- Code(Zero) at (prev + 3, 9) to (start + 0, 44) -- Code(Zero) at (prev + 2, 1) to (start + 0, 2) +- Code(Counter(9)) at (prev + 5, 5) to (start + 0, 15) +- Code(Zero) at (prev + 5, 5) to (start + 0, 15) +- Code(Zero) at (prev + 5, 1) to (start + 0, 2) Highest counter ID seen: c9 diff --git a/tests/coverage/loops_branches.cov-map b/tests/coverage/loops_branches.cov-map index 96dd70504413..8d6cc0a470c0 100644 --- a/tests/coverage/loops_branches.cov-map +++ b/tests/coverage/loops_branches.cov-map @@ -1,5 +1,5 @@ Function name: ::fmt -Raw bytes (139): 0x[01, 01, 05, 01, 05, 0b, 0f, 01, 09, 05, 0d, 0d, 09, 19, 01, 09, 05, 00, 43, 01, 01, 0c, 00, 10, 01, 01, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 01, 01, 0d, 00, 0e, 01, 01, 0d, 00, 13, 01, 00, 14, 00, 15, 01, 00, 17, 00, 1d, 05, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, 09, 03, 0d, 00, 0e, 02, 00, 12, 00, 17, 09, 01, 10, 00, 14, 09, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 09, 01, 11, 00, 12, 09, 01, 11, 00, 17, 09, 00, 18, 00, 19, 09, 00, 1b, 00, 21, 06, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 12, 03, 09, 00, 0f, 01, 01, 05, 00, 06] +Raw bytes (129): 0x[01, 01, 05, 01, 05, 0b, 0f, 01, 09, 05, 0d, 0d, 09, 17, 01, 09, 05, 00, 43, 01, 01, 0c, 00, 10, 01, 01, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 01, 01, 0d, 00, 0e, 01, 01, 0d, 00, 13, 01, 00, 14, 00, 15, 05, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, 09, 03, 0d, 00, 0e, 02, 00, 12, 00, 17, 09, 01, 10, 00, 14, 09, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 09, 01, 11, 00, 12, 09, 01, 11, 00, 17, 09, 00, 18, 00, 19, 06, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 12, 03, 09, 00, 0f, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/loops_branches.rs Number of expressions: 5 @@ -8,7 +8,7 @@ Number of expressions: 5 - expression 2 operands: lhs = Counter(0), rhs = Counter(2) - expression 3 operands: lhs = Counter(1), rhs = Counter(3) - expression 4 operands: lhs = Counter(3), rhs = Counter(2) -Number of file 0 mappings: 25 +Number of file 0 mappings: 23 - Code(Counter(0)) at (prev + 9, 5) to (start + 0, 67) - Code(Counter(0)) at (prev + 1, 12) to (start + 0, 16) - Code(Counter(0)) at (prev + 1, 16) to (start + 0, 21) @@ -17,7 +17,6 @@ Number of file 0 mappings: 25 - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 14) - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 19) - Code(Counter(0)) at (prev + 0, 20) to (start + 0, 21) -- Code(Counter(0)) at (prev + 0, 23) to (start + 0, 29) - Code(Counter(1)) at (prev + 0, 30) to (start + 0, 31) - Code(Zero) at (prev + 1, 16) to (start + 1, 10) - Code(Counter(2)) at (prev + 3, 13) to (start + 0, 14) @@ -30,7 +29,6 @@ Number of file 0 mappings: 25 - Code(Counter(2)) at (prev + 1, 17) to (start + 0, 18) - Code(Counter(2)) at (prev + 1, 17) to (start + 0, 23) - Code(Counter(2)) at (prev + 0, 24) to (start + 0, 25) -- Code(Counter(2)) at (prev + 0, 27) to (start + 0, 33) - Code(Expression(1, Sub)) at (prev + 0, 34) to (start + 0, 35) = ((c0 + c2) - (c1 + c3)) - Code(Zero) at (prev + 1, 20) to (start + 1, 14) @@ -40,7 +38,7 @@ Number of file 0 mappings: 25 Highest counter ID seen: c2 Function name: ::fmt -Raw bytes (139): 0x[01, 01, 05, 01, 05, 0b, 0f, 01, 09, 0d, 05, 0d, 09, 19, 01, 22, 05, 00, 43, 01, 01, 0c, 00, 11, 00, 00, 12, 01, 0a, 01, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 01, 01, 0d, 00, 0e, 01, 01, 0d, 00, 13, 01, 00, 14, 00, 15, 01, 00, 17, 00, 1d, 05, 00, 1e, 00, 1f, 09, 02, 0d, 00, 0e, 02, 00, 12, 00, 17, 09, 01, 10, 00, 15, 00, 00, 16, 01, 0e, 09, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 09, 01, 11, 00, 12, 09, 01, 11, 00, 17, 09, 00, 18, 00, 19, 09, 00, 1b, 00, 21, 06, 00, 22, 00, 23, 12, 03, 09, 00, 0f, 01, 01, 05, 00, 06] +Raw bytes (129): 0x[01, 01, 05, 01, 05, 0b, 0f, 01, 09, 0d, 05, 0d, 09, 17, 01, 22, 05, 00, 43, 01, 01, 0c, 00, 11, 00, 00, 12, 01, 0a, 01, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 01, 01, 0d, 00, 0e, 01, 01, 0d, 00, 13, 01, 00, 14, 00, 15, 05, 00, 1e, 00, 1f, 09, 02, 0d, 00, 0e, 02, 00, 12, 00, 17, 09, 01, 10, 00, 15, 00, 00, 16, 01, 0e, 09, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 09, 01, 11, 00, 12, 09, 01, 11, 00, 17, 09, 00, 18, 00, 19, 06, 00, 22, 00, 23, 12, 03, 09, 00, 0f, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => $DIR/loops_branches.rs Number of expressions: 5 @@ -49,7 +47,7 @@ Number of expressions: 5 - expression 2 operands: lhs = Counter(0), rhs = Counter(2) - expression 3 operands: lhs = Counter(3), rhs = Counter(1) - expression 4 operands: lhs = Counter(3), rhs = Counter(2) -Number of file 0 mappings: 25 +Number of file 0 mappings: 23 - Code(Counter(0)) at (prev + 34, 5) to (start + 0, 67) - Code(Counter(0)) at (prev + 1, 12) to (start + 0, 17) - Code(Zero) at (prev + 0, 18) to (start + 1, 10) @@ -59,7 +57,6 @@ Number of file 0 mappings: 25 - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 14) - Code(Counter(0)) at (prev + 1, 13) to (start + 0, 19) - Code(Counter(0)) at (prev + 0, 20) to (start + 0, 21) -- Code(Counter(0)) at (prev + 0, 23) to (start + 0, 29) - Code(Counter(1)) at (prev + 0, 30) to (start + 0, 31) - Code(Counter(2)) at (prev + 2, 13) to (start + 0, 14) - Code(Expression(0, Sub)) at (prev + 0, 18) to (start + 0, 23) @@ -72,7 +69,6 @@ Number of file 0 mappings: 25 - Code(Counter(2)) at (prev + 1, 17) to (start + 0, 18) - Code(Counter(2)) at (prev + 1, 17) to (start + 0, 23) - Code(Counter(2)) at (prev + 0, 24) to (start + 0, 25) -- Code(Counter(2)) at (prev + 0, 27) to (start + 0, 33) - Code(Expression(1, Sub)) at (prev + 0, 34) to (start + 0, 35) = ((c0 + c2) - (c3 + c1)) - Code(Expression(4, Sub)) at (prev + 3, 9) to (start + 0, 15) @@ -81,20 +77,18 @@ Number of file 0 mappings: 25 Highest counter ID seen: c2 Function name: loops_branches::main -Raw bytes (54): 0x[01, 01, 00, 0a, 01, 37, 01, 00, 0a, 01, 01, 09, 00, 13, 01, 00, 16, 00, 1f, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 14, 01, 01, 09, 00, 15, 01, 00, 18, 00, 23, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 12, 01, 01, 01, 00, 02] +Raw bytes (44): 0x[01, 01, 00, 08, 01, 37, 01, 00, 0a, 01, 01, 09, 00, 13, 01, 00, 16, 00, 1f, 01, 01, 05, 00, 0d, 01, 01, 09, 00, 15, 01, 00, 18, 00, 23, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/loops_branches.rs Number of expressions: 0 -Number of file 0 mappings: 10 +Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 55, 1) to (start + 0, 10) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 19) - Code(Counter(0)) at (prev + 0, 22) to (start + 0, 31) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 21) - Code(Counter(0)) at (prev + 0, 24) to (start + 0, 35) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 18) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 diff --git a/tests/coverage/macro_in_closure.cov-map b/tests/coverage/macro_in_closure.cov-map index 3529d0c4c321..1a3960196acd 100644 --- a/tests/coverage/macro_in_closure.cov-map +++ b/tests/coverage/macro_in_closure.cov-map @@ -1,22 +1,20 @@ Function name: macro_in_closure::NO_BLOCK::{closure#0} -Raw bytes (14): 0x[01, 01, 00, 02, 01, 07, 1c, 00, 24, 01, 00, 25, 00, 2c] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 07, 1c, 00, 24] Number of files: 1 - file 0 => $DIR/macro_in_closure.rs Number of expressions: 0 -Number of file 0 mappings: 2 +Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 7, 28) to (start + 0, 36) -- Code(Counter(0)) at (prev + 0, 37) to (start + 0, 44) Highest counter ID seen: c0 Function name: macro_in_closure::WITH_BLOCK::{closure#0} -Raw bytes (24): 0x[01, 01, 00, 04, 01, 09, 1e, 00, 1f, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 15, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 09, 1e, 00, 1f, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/macro_in_closure.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 9, 30) to (start + 0, 31) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 21) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 diff --git a/tests/coverage/no_cov_crate.cov-map b/tests/coverage/no_cov_crate.cov-map index ca3c95fe84c4..bdbce570b196 100644 --- a/tests/coverage/no_cov_crate.cov-map +++ b/tests/coverage/no_cov_crate.cov-map @@ -1,36 +1,33 @@ Function name: no_cov_crate::add_coverage_1 -Raw bytes (24): 0x[01, 01, 00, 04, 01, 16, 01, 00, 14, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 22, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 16, 01, 00, 14, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/no_cov_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 22, 1) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 34) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: no_cov_crate::add_coverage_2 -Raw bytes (24): 0x[01, 01, 00, 04, 01, 1a, 01, 00, 14, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 22, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 1a, 01, 00, 14, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/no_cov_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 26, 1) to (start + 0, 20) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 34) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: no_cov_crate::add_coverage_not_called (unused) -Raw bytes (24): 0x[01, 01, 00, 04, 00, 1f, 01, 00, 1d, 00, 01, 05, 00, 0d, 00, 00, 0e, 00, 26, 00, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 00, 1f, 01, 00, 1d, 00, 01, 05, 00, 0d, 00, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/no_cov_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Zero) at (prev + 31, 1) to (start + 0, 29) - Code(Zero) at (prev + 1, 5) to (start + 0, 13) -- Code(Zero) at (prev + 0, 14) to (start + 0, 38) - Code(Zero) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: (none) @@ -57,28 +54,26 @@ Number of file 0 mappings: 14 Highest counter ID seen: c0 Function name: no_cov_crate::nested_fns::outer -Raw bytes (34): 0x[01, 01, 00, 06, 01, 33, 05, 00, 20, 01, 01, 09, 00, 11, 01, 00, 12, 00, 26, 01, 01, 09, 00, 1a, 01, 00, 1b, 00, 22, 01, 0a, 05, 00, 06] +Raw bytes (29): 0x[01, 01, 00, 05, 01, 33, 05, 00, 20, 01, 01, 09, 00, 11, 01, 01, 09, 00, 1a, 01, 00, 1b, 00, 22, 01, 0a, 05, 00, 06] Number of files: 1 - file 0 => $DIR/no_cov_crate.rs Number of expressions: 0 -Number of file 0 mappings: 6 +Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 51, 5) to (start + 0, 32) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 18) to (start + 0, 38) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 26) - Code(Counter(0)) at (prev + 0, 27) to (start + 0, 34) - Code(Counter(0)) at (prev + 10, 5) to (start + 0, 6) Highest counter ID seen: c0 Function name: no_cov_crate::nested_fns::outer_both_covered -Raw bytes (34): 0x[01, 01, 00, 06, 01, 41, 05, 00, 2d, 01, 01, 09, 00, 11, 01, 00, 12, 00, 26, 01, 01, 09, 00, 0e, 01, 00, 0f, 00, 16, 01, 09, 05, 00, 06] +Raw bytes (29): 0x[01, 01, 00, 05, 01, 41, 05, 00, 2d, 01, 01, 09, 00, 11, 01, 01, 09, 00, 0e, 01, 00, 0f, 00, 16, 01, 09, 05, 00, 06] Number of files: 1 - file 0 => $DIR/no_cov_crate.rs Number of expressions: 0 -Number of file 0 mappings: 6 +Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 65, 5) to (start + 0, 45) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(0)) at (prev + 0, 18) to (start + 0, 38) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 14) - Code(Counter(0)) at (prev + 0, 15) to (start + 0, 22) - Code(Counter(0)) at (prev + 9, 5) to (start + 0, 6) diff --git a/tests/coverage/overflow.cov-map b/tests/coverage/overflow.cov-map index 18b0503b9e7c..22a4ed0d49cd 100644 --- a/tests/coverage/overflow.cov-map +++ b/tests/coverage/overflow.cov-map @@ -1,5 +1,5 @@ Function name: overflow::main -Raw bytes (96): 0x[01, 01, 06, 05, 01, 05, 17, 01, 09, 05, 13, 17, 0d, 01, 09, 10, 01, 10, 01, 00, 1c, 01, 01, 09, 00, 16, 01, 00, 19, 00, 1b, 05, 01, 0b, 00, 18, 02, 01, 0c, 00, 1a, 09, 00, 1b, 03, 0a, 09, 01, 11, 00, 17, 09, 00, 1a, 00, 28, 06, 02, 13, 00, 20, 0d, 00, 21, 03, 0a, 0d, 01, 11, 00, 17, 0d, 00, 1a, 00, 28, 0e, 02, 09, 00, 0a, 02, 01, 09, 00, 17, 01, 02, 05, 00, 0b, 01, 01, 01, 00, 02] +Raw bytes (86): 0x[01, 01, 06, 05, 01, 05, 17, 01, 09, 05, 13, 17, 0d, 01, 09, 0e, 01, 10, 01, 00, 1c, 01, 01, 09, 00, 16, 01, 00, 19, 00, 1b, 05, 01, 0b, 00, 18, 02, 01, 0c, 00, 1a, 09, 00, 1b, 03, 0a, 09, 01, 11, 00, 17, 06, 02, 13, 00, 20, 0d, 00, 21, 03, 0a, 0d, 01, 11, 00, 17, 0e, 02, 09, 00, 0a, 02, 01, 09, 00, 17, 01, 02, 05, 00, 0b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/overflow.rs Number of expressions: 6 @@ -9,7 +9,7 @@ Number of expressions: 6 - expression 3 operands: lhs = Counter(1), rhs = Expression(4, Add) - expression 4 operands: lhs = Expression(5, Add), rhs = Counter(3) - expression 5 operands: lhs = Counter(0), rhs = Counter(2) -Number of file 0 mappings: 16 +Number of file 0 mappings: 14 - Code(Counter(0)) at (prev + 16, 1) to (start + 0, 28) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 22) - Code(Counter(0)) at (prev + 0, 25) to (start + 0, 27) @@ -18,12 +18,10 @@ Number of file 0 mappings: 16 = (c1 - c0) - Code(Counter(2)) at (prev + 0, 27) to (start + 3, 10) - Code(Counter(2)) at (prev + 1, 17) to (start + 0, 23) -- Code(Counter(2)) at (prev + 0, 26) to (start + 0, 40) - Code(Expression(1, Sub)) at (prev + 2, 19) to (start + 0, 32) = (c1 - (c0 + c2)) - Code(Counter(3)) at (prev + 0, 33) to (start + 3, 10) - Code(Counter(3)) at (prev + 1, 17) to (start + 0, 23) -- Code(Counter(3)) at (prev + 0, 26) to (start + 0, 40) - Code(Expression(3, Sub)) at (prev + 2, 9) to (start + 0, 10) = (c1 - ((c0 + c2) + c3)) - Code(Expression(0, Sub)) at (prev + 1, 9) to (start + 0, 23) @@ -33,12 +31,12 @@ Number of file 0 mappings: 16 Highest counter ID seen: c3 Function name: overflow::might_overflow -Raw bytes (76): 0x[01, 01, 01, 01, 05, 0e, 01, 05, 01, 00, 26, 01, 01, 08, 00, 12, 05, 00, 13, 02, 06, 02, 02, 05, 00, 06, 01, 01, 09, 00, 0f, 01, 00, 12, 00, 1e, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 26, 01, 01, 09, 00, 0f, 01, 00, 12, 00, 21, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 2f, 01, 01, 05, 00, 0b, 01, 01, 01, 00, 02] +Raw bytes (66): 0x[01, 01, 01, 01, 05, 0c, 01, 05, 01, 00, 26, 01, 01, 08, 00, 12, 05, 00, 13, 02, 06, 02, 02, 05, 00, 06, 01, 01, 09, 00, 0f, 01, 00, 12, 00, 1e, 01, 01, 05, 00, 0d, 01, 01, 09, 00, 0f, 01, 00, 12, 00, 21, 01, 01, 05, 00, 0d, 01, 01, 05, 00, 0b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/overflow.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 14 +Number of file 0 mappings: 12 - Code(Counter(0)) at (prev + 5, 1) to (start + 0, 38) - Code(Counter(0)) at (prev + 1, 8) to (start + 0, 18) - Code(Counter(1)) at (prev + 0, 19) to (start + 2, 6) @@ -47,11 +45,9 @@ Number of file 0 mappings: 14 - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 15) - Code(Counter(0)) at (prev + 0, 18) to (start + 0, 30) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 38) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 15) - Code(Counter(0)) at (prev + 0, 18) to (start + 0, 33) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 47) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 11) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c1 diff --git a/tests/coverage/panic_unwind.cov-map b/tests/coverage/panic_unwind.cov-map index ff656d3d8d58..42a358778619 100644 --- a/tests/coverage/panic_unwind.cov-map +++ b/tests/coverage/panic_unwind.cov-map @@ -29,16 +29,15 @@ Number of file 0 mappings: 12 Highest counter ID seen: c3 Function name: panic_unwind::might_panic -Raw bytes (41): 0x[01, 01, 01, 01, 05, 07, 01, 04, 01, 00, 23, 01, 01, 08, 00, 14, 05, 01, 09, 00, 11, 05, 00, 12, 00, 20, 05, 01, 09, 00, 0f, 02, 01, 0c, 02, 06, 02, 03, 01, 00, 02] +Raw bytes (36): 0x[01, 01, 01, 01, 05, 06, 01, 04, 01, 00, 23, 01, 01, 08, 00, 14, 05, 01, 09, 00, 11, 05, 01, 09, 00, 0f, 02, 01, 0c, 02, 06, 02, 03, 01, 00, 02] Number of files: 1 - file 0 => $DIR/panic_unwind.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 7 +Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 4, 1) to (start + 0, 35) - Code(Counter(0)) at (prev + 1, 8) to (start + 0, 20) - Code(Counter(1)) at (prev + 1, 9) to (start + 0, 17) -- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 32) - Code(Counter(1)) at (prev + 1, 9) to (start + 0, 15) - Code(Expression(0, Sub)) at (prev + 1, 12) to (start + 2, 6) = (c0 - c1) diff --git a/tests/coverage/partial_eq.cov-map b/tests/coverage/partial_eq.cov-map index 0a81be749128..8def64a3f546 100644 --- a/tests/coverage/partial_eq.cov-map +++ b/tests/coverage/partial_eq.cov-map @@ -11,19 +11,18 @@ Number of file 0 mappings: 4 Highest counter ID seen: c0 Function name: partial_eq::main -Raw bytes (49): 0x[01, 01, 00, 09, 01, 11, 01, 00, 0a, 01, 01, 09, 00, 16, 01, 00, 19, 00, 25, 01, 01, 09, 00, 16, 01, 00, 19, 00, 25, 01, 02, 05, 00, 0d, 01, 01, 09, 00, 1b, 01, 03, 09, 00, 26, 01, 02, 01, 00, 02] +Raw bytes (44): 0x[01, 01, 00, 08, 01, 11, 01, 00, 0a, 01, 01, 09, 00, 16, 01, 00, 19, 00, 25, 01, 01, 09, 00, 16, 01, 00, 19, 00, 25, 01, 02, 05, 00, 0d, 01, 04, 09, 00, 26, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => $DIR/partial_eq.rs Number of expressions: 0 -Number of file 0 mappings: 9 +Number of file 0 mappings: 8 - Code(Counter(0)) at (prev + 17, 1) to (start + 0, 10) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 22) - Code(Counter(0)) at (prev + 0, 25) to (start + 0, 37) - Code(Counter(0)) at (prev + 1, 9) to (start + 0, 22) - Code(Counter(0)) at (prev + 0, 25) to (start + 0, 37) - Code(Counter(0)) at (prev + 2, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 1, 9) to (start + 0, 27) -- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 38) +- Code(Counter(0)) at (prev + 4, 9) to (start + 0, 38) - Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2) Highest counter ID seen: c0 diff --git a/tests/coverage/rustfmt-skip.cov-map b/tests/coverage/rustfmt-skip.cov-map index bb673a411bfd..25e4995ea6da 100644 --- a/tests/coverage/rustfmt-skip.cov-map +++ b/tests/coverage/rustfmt-skip.cov-map @@ -1,12 +1,11 @@ Function name: rustfmt_skip::main -Raw bytes (24): 0x[01, 01, 00, 04, 01, 0a, 01, 00, 0a, 01, 02, 05, 00, 0d, 01, 03, 09, 00, 10, 01, 02, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 0a, 01, 00, 0a, 01, 02, 05, 00, 0d, 01, 05, 01, 00, 02] Number of files: 1 - file 0 => $DIR/rustfmt-skip.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 10, 1) to (start + 0, 10) - Code(Counter(0)) at (prev + 2, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 16) -- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2) +- Code(Counter(0)) at (prev + 5, 1) to (start + 0, 2) Highest counter ID seen: c0 diff --git a/tests/coverage/sort_groups.cov-map b/tests/coverage/sort_groups.cov-map index 70cf7cff4b67..29d54d88a87e 100644 --- a/tests/coverage/sort_groups.cov-map +++ b/tests/coverage/sort_groups.cov-map @@ -1,63 +1,59 @@ Function name: sort_groups::generic_fn::<&str> -Raw bytes (36): 0x[01, 01, 01, 01, 05, 06, 01, 11, 01, 00, 1d, 01, 01, 08, 00, 0c, 05, 00, 0d, 02, 06, 05, 01, 09, 00, 11, 02, 01, 05, 00, 06, 01, 01, 01, 00, 02] +Raw bytes (31): 0x[01, 01, 01, 01, 05, 05, 01, 11, 01, 00, 1d, 01, 01, 08, 00, 0c, 05, 00, 0d, 02, 06, 02, 02, 05, 00, 06, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/sort_groups.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 6 +Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 17, 1) to (start + 0, 29) - Code(Counter(0)) at (prev + 1, 8) to (start + 0, 12) - Code(Counter(1)) at (prev + 0, 13) to (start + 2, 6) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 17) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 6) +- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6) = (c0 - c1) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c1 Function name: sort_groups::generic_fn::<()> -Raw bytes (36): 0x[01, 01, 01, 01, 05, 06, 01, 11, 01, 00, 1d, 01, 01, 08, 00, 0c, 05, 00, 0d, 02, 06, 05, 01, 09, 00, 11, 02, 01, 05, 00, 06, 01, 01, 01, 00, 02] +Raw bytes (31): 0x[01, 01, 01, 01, 05, 05, 01, 11, 01, 00, 1d, 01, 01, 08, 00, 0c, 05, 00, 0d, 02, 06, 02, 02, 05, 00, 06, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/sort_groups.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 6 +Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 17, 1) to (start + 0, 29) - Code(Counter(0)) at (prev + 1, 8) to (start + 0, 12) - Code(Counter(1)) at (prev + 0, 13) to (start + 2, 6) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 17) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 6) +- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6) = (c0 - c1) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c1 Function name: sort_groups::generic_fn:: -Raw bytes (36): 0x[01, 01, 01, 01, 05, 06, 01, 11, 01, 00, 1d, 01, 01, 08, 00, 0c, 05, 00, 0d, 02, 06, 05, 01, 09, 00, 11, 02, 01, 05, 00, 06, 01, 01, 01, 00, 02] +Raw bytes (31): 0x[01, 01, 01, 01, 05, 05, 01, 11, 01, 00, 1d, 01, 01, 08, 00, 0c, 05, 00, 0d, 02, 06, 02, 02, 05, 00, 06, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/sort_groups.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 6 +Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 17, 1) to (start + 0, 29) - Code(Counter(0)) at (prev + 1, 8) to (start + 0, 12) - Code(Counter(1)) at (prev + 0, 13) to (start + 2, 6) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 17) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 6) +- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6) = (c0 - c1) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c1 Function name: sort_groups::generic_fn:: -Raw bytes (36): 0x[01, 01, 01, 01, 05, 06, 01, 11, 01, 00, 1d, 01, 01, 08, 00, 0c, 05, 00, 0d, 02, 06, 05, 01, 09, 00, 11, 02, 01, 05, 00, 06, 01, 01, 01, 00, 02] +Raw bytes (31): 0x[01, 01, 01, 01, 05, 05, 01, 11, 01, 00, 1d, 01, 01, 08, 00, 0c, 05, 00, 0d, 02, 06, 02, 02, 05, 00, 06, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/sort_groups.rs Number of expressions: 1 - expression 0 operands: lhs = Counter(0), rhs = Counter(1) -Number of file 0 mappings: 6 +Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 17, 1) to (start + 0, 29) - Code(Counter(0)) at (prev + 1, 8) to (start + 0, 12) - Code(Counter(1)) at (prev + 0, 13) to (start + 2, 6) -- Code(Counter(1)) at (prev + 1, 9) to (start + 0, 17) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 6) +- Code(Expression(0, Sub)) at (prev + 2, 5) to (start + 0, 6) = (c0 - c1) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c1 diff --git a/tests/coverage/unused_mod.cov-map b/tests/coverage/unused_mod.cov-map index ea419edbdafe..ab8aad618e51 100644 --- a/tests/coverage/unused_mod.cov-map +++ b/tests/coverage/unused_mod.cov-map @@ -1,24 +1,22 @@ Function name: unused_mod::main -Raw bytes (24): 0x[01, 01, 00, 04, 01, 04, 01, 00, 0a, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 1c, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 04, 01, 00, 0a, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/unused_mod.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 4, 1) to (start + 0, 10) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 28) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: unused_mod::unused_module::never_called_function (unused) -Raw bytes (24): 0x[01, 02, 00, 04, 00, 02, 01, 00, 1f, 00, 01, 05, 00, 0d, 00, 00, 0e, 00, 21, 00, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 02, 00, 03, 00, 02, 01, 00, 1f, 00, 01, 05, 00, 0d, 00, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/auxiliary/unused_mod_helper.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Zero) at (prev + 2, 1) to (start + 0, 31) - Code(Zero) at (prev + 1, 5) to (start + 0, 13) -- Code(Zero) at (prev + 0, 14) to (start + 0, 33) - Code(Zero) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: (none) diff --git a/tests/coverage/uses_crate.cov-map b/tests/coverage/uses_crate.cov-map index 8f3c63aba5ce..fd65fa03dcdb 100644 --- a/tests/coverage/uses_crate.cov-map +++ b/tests/coverage/uses_crate.cov-map @@ -1,48 +1,44 @@ Function name: used_crate::used_from_bin_crate_and_lib_crate_generic_function::> -Raw bytes (24): 0x[01, 01, 00, 04, 01, 1b, 01, 00, 4c, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 4f, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 1b, 01, 00, 4c, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/auxiliary/used_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 27, 1) to (start + 0, 76) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 79) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec> -Raw bytes (24): 0x[01, 01, 00, 04, 01, 13, 01, 00, 43, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 46, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 13, 01, 00, 43, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/auxiliary/used_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 19, 1) to (start + 0, 67) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 70) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: used_crate::used_only_from_bin_crate_generic_function::<&str> -Raw bytes (24): 0x[01, 01, 00, 04, 01, 13, 01, 00, 43, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 46, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 13, 01, 00, 43, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/auxiliary/used_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 19, 1) to (start + 0, 67) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 70) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str> -Raw bytes (24): 0x[01, 01, 00, 04, 01, 1f, 01, 00, 5b, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 5e, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 1f, 01, 00, 5b, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/auxiliary/used_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 31, 1) to (start + 0, 91) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 94) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 diff --git a/tests/coverage/uses_inline_crate.cov-map b/tests/coverage/uses_inline_crate.cov-map index 52f3f94ce642..863f6df7adb7 100644 --- a/tests/coverage/uses_inline_crate.cov-map +++ b/tests/coverage/uses_inline_crate.cov-map @@ -1,12 +1,11 @@ Function name: used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::> -Raw bytes (24): 0x[01, 01, 00, 04, 01, 2c, 01, 00, 4c, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 4f, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 2c, 01, 00, 4c, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/auxiliary/used_inline_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 44, 1) to (start + 0, 76) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 79) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 @@ -31,38 +30,35 @@ Number of file 0 mappings: 10 Highest counter ID seen: c1 Function name: used_inline_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec> -Raw bytes (24): 0x[01, 01, 00, 04, 01, 21, 01, 00, 43, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 46, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 21, 01, 00, 43, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/auxiliary/used_inline_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 33, 1) to (start + 0, 67) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 70) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: used_inline_crate::used_only_from_bin_crate_generic_function::<&str> -Raw bytes (24): 0x[01, 01, 00, 04, 01, 21, 01, 00, 43, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 46, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 21, 01, 00, 43, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/auxiliary/used_inline_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 33, 1) to (start + 0, 67) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 70) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str> -Raw bytes (24): 0x[01, 01, 00, 04, 01, 31, 01, 00, 5b, 01, 01, 05, 00, 0d, 01, 00, 0e, 00, 5e, 01, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 31, 01, 00, 5b, 01, 01, 05, 00, 0d, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => $DIR/auxiliary/used_inline_crate.rs Number of expressions: 0 -Number of file 0 mappings: 4 +Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 49, 1) to (start + 0, 91) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 13) -- Code(Counter(0)) at (prev + 0, 14) to (start + 0, 94) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 diff --git a/tests/incremental/hashes/inherent_impls.rs b/tests/incremental/hashes/inherent_impls.rs index 66d6c2b7246c..ebcab178f209 100644 --- a/tests/incremental/hashes/inherent_impls.rs +++ b/tests/incremental/hashes/inherent_impls.rs @@ -72,15 +72,9 @@ impl Foo { // This should affect the method itself, but not the impl. #[cfg(any(cfail1,cfail4))] impl Foo { - //------------ - //--------------- - //---------------------------------------------------------------- - // + //----------------------------------------------------------------------------- //-------------------------- - //------------ - //--------------- - //---------------------------------------------------------------- - // + //----------------------------------------------------------------------------- //-------------------------- #[inline] pub fn method_body_inlined() { @@ -94,15 +88,9 @@ impl Foo { #[rustc_clean(cfg="cfail5")] #[rustc_clean(cfg="cfail6")] impl Foo { - #[rustc_clean( - cfg="cfail2", - except="opt_hir_owner_nodes,optimized_mir,promoted_mir,typeck" - )] + #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")] #[rustc_clean(cfg="cfail3")] - #[rustc_clean( - cfg="cfail5", - except="opt_hir_owner_nodes,optimized_mir,promoted_mir,typeck" - )] + #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")] #[rustc_clean(cfg="cfail6")] #[inline] pub fn method_body_inlined() { diff --git a/tests/incremental/hygiene/auxiliary/cached_hygiene.rs b/tests/incremental/hygiene/auxiliary/cached_hygiene.rs index a49715761582..67b54e641430 100644 --- a/tests/incremental/hygiene/auxiliary/cached_hygiene.rs +++ b/tests/incremental/hygiene/auxiliary/cached_hygiene.rs @@ -13,7 +13,7 @@ macro_rules! first_macro { } } -#[rustc_clean(except="opt_hir_owner_nodes,typeck,optimized_mir,promoted_mir", cfg="rpass2")] +#[rustc_clean(except="opt_hir_owner_nodes,typeck,optimized_mir", cfg="rpass2")] #[inline(always)] pub fn changed_fn() { // This will cause additional hygiene to be generate, diff --git a/tests/incremental/string_constant.rs b/tests/incremental/string_constant.rs index 901e2f0c59b0..4200df87ec65 100644 --- a/tests/incremental/string_constant.rs +++ b/tests/incremental/string_constant.rs @@ -17,7 +17,7 @@ pub mod x { } #[cfg(cfail2)] - #[rustc_clean(except = "opt_hir_owner_nodes,promoted_mir", cfg = "cfail2")] + #[rustc_clean(except = "opt_hir_owner_nodes,optimized_mir", cfg = "cfail2")] pub fn x() { println!("{}", "2"); } diff --git a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff index 091c3bd5c7b2..b7872fc9952b 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff @@ -209,9 +209,10 @@ + _27 = &(*_12); _26 = &(*_27); StorageLive(_28); - _28 = Option::>::None; +- _28 = Option::>::None; - _22 = assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind unreachable; -+ _22 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, move _28) -> unwind unreachable; ++ _28 = const Option::>::None; ++ _22 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, const Option::>::None) -> unwind unreachable; } bb7: { @@ -311,11 +312,15 @@ + _53 = &(*_38); _52 = &(*_53); StorageLive(_54); - _54 = Option::>::None; +- _54 = Option::>::None; - _48 = assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind unreachable; -+ _48 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, move _54) -> unwind unreachable; ++ _54 = const Option::>::None; ++ _48 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, const Option::>::None) -> unwind unreachable; } } - ALLOC0 (size: 18, align: 1) { .. } +- ALLOC0 (size: 18, align: 1) { .. } ++ ALLOC0 (size: 16, align: 8) { .. } ++ ++ ALLOC1 (size: 18, align: 1) { .. } diff --git a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff index 9768956c9c87..37817b48c199 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff @@ -209,9 +209,10 @@ + _27 = &(*_12); _26 = &(*_27); StorageLive(_28); - _28 = Option::>::None; +- _28 = Option::>::None; - _22 = assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind continue; -+ _22 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, move _28) -> unwind continue; ++ _28 = const Option::>::None; ++ _22 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, const Option::>::None) -> unwind continue; } bb7: { @@ -311,11 +312,15 @@ + _53 = &(*_38); _52 = &(*_53); StorageLive(_54); - _54 = Option::>::None; +- _54 = Option::>::None; - _48 = assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind continue; -+ _48 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, move _54) -> unwind continue; ++ _54 = const Option::>::None; ++ _48 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, const Option::>::None) -> unwind continue; } } - ALLOC0 (size: 18, align: 1) { .. } +- ALLOC0 (size: 18, align: 1) { .. } ++ ALLOC0 (size: 16, align: 8) { .. } ++ ++ ALLOC1 (size: 18, align: 1) { .. } diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-abort.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-abort.mir index ae7b2cc0b6fc..910983ee79d3 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-abort.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-abort.mir @@ -164,7 +164,6 @@ fn array_casts() -> () { _31 = &(*_32); StorageLive(_33); _33 = Option::>::None; - Retag(_33); _27 = core::panicking::assert_failed::(move _28, move _29, move _31, move _33) -> unwind unreachable; } } diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-unwind.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-unwind.mir index 789bc3426384..8cc6bce0e6bd 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-unwind.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-unwind.mir @@ -164,7 +164,6 @@ fn array_casts() -> () { _31 = &(*_32); StorageLive(_33); _33 = Option::>::None; - Retag(_33); _27 = core::panicking::assert_failed::(move _28, move _29, move _31, move _33) -> unwind continue; } } diff --git a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff index 056dc4c42c11..4b867d4325c8 100644 --- a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff @@ -17,23 +17,22 @@ let mut _17: &std::boxed::Box; let mut _18: core::fmt::rt::Argument<'_>; let mut _19: &u32; - let mut _20: &[&str; 3]; - let _21: &[&str; 3]; - let _22: [&str; 3]; - let mut _23: &[core::fmt::rt::Argument<'_>; 2]; - let _24: &[core::fmt::rt::Argument<'_>; 2]; - let mut _26: &std::boxed::Box; - let mut _27: &u32; - let mut _28: bool; + let mut _20: &[u8; 7]; + let _21: &[u8; 7]; + let mut _22: &[core::fmt::rt::Argument<'_>; 2]; + let _23: &[core::fmt::rt::Argument<'_>; 2]; + let mut _24: &std::boxed::Box; + let mut _25: &u32; + let mut _26: bool; + let mut _27: isize; + let mut _28: isize; let mut _29: isize; - let mut _30: isize; - let mut _31: isize; -+ let _32: std::result::Result, ::Err>; -+ let _33: u32; ++ let _30: std::result::Result, ::Err>; ++ let _31: u32; scope 1 { - debug foo => _1; -+ debug ((foo: Foo).0: std::result::Result, ::Err>) => _32; -+ debug ((foo: Foo).1: u32) => _33; ++ debug ((foo: Foo).0: std::result::Result, ::Err>) => _30; ++ debug ((foo: Foo).1: u32) => _31; let _5: std::result::Result, ::Err>; scope 2 { debug x => _5; @@ -44,16 +43,15 @@ debug x => _8; let _8: std::boxed::Box; let _12: (&std::boxed::Box, &u32); -+ let _34: &std::boxed::Box; -+ let _35: &u32; ++ let _32: &std::boxed::Box; ++ let _33: &u32; scope 5 { - debug args => _12; -+ debug ((args: (&Box, &u32)).0: &std::boxed::Box) => _34; -+ debug ((args: (&Box, &u32)).1: &u32) => _35; ++ debug ((args: (&Box, &u32)).0: &std::boxed::Box) => _32; ++ debug ((args: (&Box, &u32)).1: &u32) => _33; let _15: [core::fmt::rt::Argument<'_>; 2]; scope 6 { debug args => _15; - let mut _25: &[&str; 3]; } } } @@ -62,10 +60,10 @@ } bb0: { - _28 = const false; + _26 = const false; - StorageLive(_1); -+ StorageLive(_32); -+ StorageLive(_33); ++ StorageLive(_30); ++ StorageLive(_31); + nop; StorageLive(_2); StorageLive(_3); @@ -79,17 +77,17 @@ _2 = Result::, ::Err>::Ok(move _3); StorageDead(_3); - _1 = Foo:: { x: move _2, y: const 7_u32 }; -+ _32 = move _2; -+ _33 = const 7_u32; ++ _30 = move _2; ++ _31 = const 7_u32; + nop; StorageDead(_2); StorageLive(_5); - _28 = const true; + _26 = const true; - _5 = move (_1.0: std::result::Result, ::Err>); -+ _5 = move _32; ++ _5 = move _30; StorageLive(_6); - _6 = copy (_1.1: u32); -+ _6 = copy _33; ++ _6 = copy _31; _7 = discriminant(_5); switchInt(move _7) -> [0: bb2, otherwise: bb7]; } @@ -101,25 +99,25 @@ StorageLive(_10); StorageLive(_11); - StorageLive(_12); -+ StorageLive(_34); -+ StorageLive(_35); ++ StorageLive(_32); ++ StorageLive(_33); + nop; StorageLive(_13); _13 = &_8; StorageLive(_14); _14 = &_6; - _12 = (move _13, move _14); -+ _34 = move _13; -+ _35 = move _14; ++ _32 = move _13; ++ _33 = move _14; + nop; StorageDead(_14); StorageDead(_13); StorageLive(_15); StorageLive(_16); StorageLive(_17); -- _26 = copy (_12.0: &std::boxed::Box); -+ _26 = copy _34; - _17 = &(*_26); +- _24 = copy (_12.0: &std::boxed::Box); ++ _24 = copy _32; + _17 = &(*_24); _16 = core::fmt::rt::Argument::<'_>::new_display::>(move _17) -> [return: bb3, unwind unreachable]; } @@ -127,9 +125,9 @@ StorageDead(_17); StorageLive(_18); StorageLive(_19); -- _27 = copy (_12.1: &u32); -+ _27 = copy _35; - _19 = &(*_27); +- _25 = copy (_12.1: &u32); ++ _25 = copy _33; + _19 = &(*_25); _18 = core::fmt::rt::Argument::<'_>::new_display::(move _19) -> [return: bb4, unwind unreachable]; } @@ -140,19 +138,18 @@ StorageDead(_16); StorageLive(_20); StorageLive(_21); - _25 = const foo::::promoted[0]; - _21 = &(*_25); + _21 = const b"\x80\x01 \x80\x01\n\x00"; _20 = &(*_21); + StorageLive(_22); StorageLive(_23); - StorageLive(_24); - _24 = &_15; - _23 = &(*_24); - _11 = core::fmt::rt::>::new_v1::<3, 2>(move _20, move _23) -> [return: bb5, unwind unreachable]; + _23 = &_15; + _22 = &(*_23); + _11 = core::fmt::rt::>::new::<7, 2>(move _20, move _22) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_24); StorageDead(_23); + StorageDead(_22); StorageDead(_21); StorageDead(_20); _10 = _eprint(move _11) -> [return: bb6, unwind unreachable]; @@ -162,8 +159,8 @@ StorageDead(_11); StorageDead(_15); - StorageDead(_12); -+ StorageDead(_34); -+ StorageDead(_35); ++ StorageDead(_32); ++ StorageDead(_33); + nop; StorageDead(_10); _9 = const (); @@ -184,16 +181,16 @@ bb9: { StorageDead(_6); - _29 = discriminant(_5); - switchInt(move _29) -> [0: bb10, otherwise: bb11]; + _27 = discriminant(_5); + switchInt(move _27) -> [0: bb10, otherwise: bb11]; } bb10: { - _28 = const false; + _26 = const false; StorageDead(_5); - StorageDead(_1); -+ StorageDead(_32); -+ StorageDead(_33); ++ StorageDead(_30); ++ StorageDead(_31); + nop; return; } @@ -203,3 +200,7 @@ } } + ALLOC0 (size: 7, align: 1) { + 80 01 20 80 01 0a 00 β”‚ .. .... + } + diff --git a/tests/pretty/issue-4264.pp b/tests/pretty/issue-4264.pp index 1344923f4c47..c4517574a466 100644 --- a/tests/pretty/issue-4264.pp +++ b/tests/pretty/issue-4264.pp @@ -32,11 +32,10 @@ fn bar() ({ ((::alloc::__export::must_use as fn(String) -> String {must_use::})(({ ((::alloc::fmt::format as - for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const + for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::from_str as - fn(&[&'static str; 1]) -> Arguments<'_> {core::fmt::rt::>::new_const::<1>})((&([("test" - as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>)) - as String) + fn(&'static str) -> Arguments<'_> {core::fmt::rt::>::from_str})(("test" + as &str)) as Arguments<'_>)) as String) } as String)) as String); } as ()) type Foo = [i32; (3 as usize)]; diff --git a/tests/run-make/symbol-mangling-hashed/rmake.rs b/tests/run-make/symbol-mangling-hashed/rmake.rs index 136e6b9fa3a9..0eeba1f9e372 100644 --- a/tests/run-make/symbol-mangling-hashed/rmake.rs +++ b/tests/run-make/symbol-mangling-hashed/rmake.rs @@ -61,7 +61,7 @@ fn main() { } let expected_prefix = adjust_symbol_prefix!("_RNxC12hashed_dylib"); - if dynamic_symbols.iter().filter(|sym| sym.starts_with(expected_prefix)).count() != 2 { + if dynamic_symbols.iter().filter(|sym| sym.starts_with(expected_prefix)).count() != 1 { eprintln!("exported dynamic symbols: {:#?}", dynamic_symbols); panic!("expected two dynamic symbols starting with `{expected_prefix}`"); } @@ -88,7 +88,7 @@ fn main() { } let expected_rlib_prefix = adjust_symbol_prefix!("_RNxC11hashed_rlib"); - if dynamic_symbols.iter().filter(|sym| sym.starts_with(expected_rlib_prefix)).count() != 2 { + if dynamic_symbols.iter().filter(|sym| sym.starts_with(expected_rlib_prefix)).count() != 1 { eprintln!("exported dynamic symbols: {:#?}", dynamic_symbols); panic!("expected two exported symbols starting with `{expected_rlib_prefix}`"); } diff --git a/tests/ui/consts/recursive-const-in-impl.stderr b/tests/ui/consts/recursive-const-in-impl.stderr index 035d9c2f21c5..ec5ad52fadd4 100644 --- a/tests/ui/consts/recursive-const-in-impl.stderr +++ b/tests/ui/consts/recursive-const-in-impl.stderr @@ -5,7 +5,7 @@ LL | println!("{}", Thing::::X); | ^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "14"]` attribute to your crate (`recursive_const_in_impl`) - = note: query depth increased by 9 when simplifying constant for the type system `main::promoted[1]` + = note: query depth increased by 9 when simplifying constant for the type system `main::promoted[0]` = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/unpretty/exhaustive.hir.stdout b/tests/ui/unpretty/exhaustive.hir.stdout index ee22c3aeba9d..55b699728224 100644 --- a/tests/ui/unpretty/exhaustive.hir.stdout +++ b/tests/ui/unpretty/exhaustive.hir.stdout @@ -390,11 +390,11 @@ mod expressions { /// ExprKind::FormatArgs fn expr_format_args() { let expr; - format_arguments::new_const(&[]); + format_arguments::from_str(""); { super let args = (&expr,); super let args = [format_argument::new_display(args.0)]; - format_arguments::new_v1(&[""], &args) + unsafe { format_arguments::new(b"\x80\x00", &args) } }; } } diff --git a/tests/ui/unpretty/flattened-format-args.stdout b/tests/ui/unpretty/flattened-format-args.stdout index 233c9f1c91bd..b47205e96a6a 100644 --- a/tests/ui/unpretty/flattened-format-args.stdout +++ b/tests/ui/unpretty/flattened-format-args.stdout @@ -13,7 +13,10 @@ fn main() { ::std::io::_print({ super let args = (&x,); super let args = [format_argument::new_display(args.0)]; - format_arguments::new_v1(&["a 123 b ", " xyz\n"], &args) + unsafe { + format_arguments::new(b"\x08a 123 b \x80\x05 xyz\n\x00", + &args) + } }); }; } From be7a559a8adfcbd3a89c1ae732cd52cf9fe84b42 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 10 Nov 2025 15:11:28 +0100 Subject: [PATCH 086/108] Make clippy happy. --- src/tools/clippy/clippy_utils/src/sym.rs | 1 - .../tests/ui/author/macro_in_closure.stdout | 21 ++++++++----------- .../tests/ui/author/macro_in_loop.stdout | 21 ++++++++----------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/tools/clippy/clippy_utils/src/sym.rs b/src/tools/clippy/clippy_utils/src/sym.rs index 8e8a80a6a9c9..c2523540f007 100644 --- a/src/tools/clippy/clippy_utils/src/sym.rs +++ b/src/tools/clippy/clippy_utils/src/sym.rs @@ -166,7 +166,6 @@ generate! { from_ne_bytes, from_ptr, from_raw, - from_str, from_str_radix, fs, fuse, diff --git a/src/tools/clippy/tests/ui/author/macro_in_closure.stdout b/src/tools/clippy/tests/ui/author/macro_in_closure.stdout index 786c61e0c018..52a9c5b2c67d 100644 --- a/src/tools/clippy/tests/ui/author/macro_in_closure.stdout +++ b/src/tools/clippy/tests/ui/author/macro_in_closure.stdout @@ -30,19 +30,16 @@ if let StmtKind::Let(local) = stmt.kind && let PatKind::Binding(BindingMode::NONE, _, name1, None) = local2.pat.kind && name1.as_str() == "args" && let Some(trailing_expr) = block1.expr - && let ExprKind::Call(func2, args2) = trailing_expr.kind - && paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed + && let ExprKind::Block(block2, None) = trailing_expr.kind + && block2.stmts.is_empty() + && let Some(trailing_expr1) = block2.expr + && let ExprKind::Call(func2, args2) = trailing_expr1.kind + && paths::CORE_FMT_RT_NEW.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed && args2.len() == 2 - && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[0].kind - && let ExprKind::Array(elements2) = inner1.kind - && elements2.len() == 2 - && let ExprKind::Lit(ref lit) = elements2[0].kind - && let LitKind::Str(s, _) = lit.node - && s.as_str() == "" - && let ExprKind::Lit(ref lit1) = elements2[1].kind - && let LitKind::Str(s1, _) = lit1.node - && s1.as_str() == "\n" - && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[1].kind + && let ExprKind::Lit(ref lit) = args2[0].kind + && let LitKind::ByteStr(ref vec) = lit.node + && let [[128, 1, 10, 0]] = **vec + && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[1].kind && block.expr.is_none() && let PatKind::Binding(BindingMode::NONE, _, name2, None) = local.pat.kind && name2.as_str() == "print_text" diff --git a/src/tools/clippy/tests/ui/author/macro_in_loop.stdout b/src/tools/clippy/tests/ui/author/macro_in_loop.stdout index ba3b7e244204..18484f6ffc56 100644 --- a/src/tools/clippy/tests/ui/author/macro_in_loop.stdout +++ b/src/tools/clippy/tests/ui/author/macro_in_loop.stdout @@ -41,19 +41,16 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo && let PatKind::Binding(BindingMode::NONE, _, name2, None) = local1.pat.kind && name2.as_str() == "args" && let Some(trailing_expr) = block2.expr - && let ExprKind::Call(func2, args2) = trailing_expr.kind - && paths::CORE_FMT_RT_NEW_V1.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed + && let ExprKind::Block(block3, None) = trailing_expr.kind + && block3.stmts.is_empty() + && let Some(trailing_expr1) = block3.expr + && let ExprKind::Call(func2, args2) = trailing_expr1.kind + && paths::CORE_FMT_RT_NEW.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed && args2.len() == 2 - && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[0].kind - && let ExprKind::Array(elements2) = inner1.kind - && elements2.len() == 2 - && let ExprKind::Lit(ref lit2) = elements2[0].kind - && let LitKind::Str(s, _) = lit2.node - && s.as_str() == "" - && let ExprKind::Lit(ref lit3) = elements2[1].kind - && let LitKind::Str(s1, _) = lit3.node - && s1.as_str() == "\n" - && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner2) = args2[1].kind + && let ExprKind::Lit(ref lit2) = args2[0].kind + && let LitKind::ByteStr(ref vec) = lit2.node + && let [[128, 1, 10, 0]] = **vec + && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[1].kind && block1.expr.is_none() && block.expr.is_none() { From 564c78fe62c7a1a8fc7ebaf81a15876bccf4234a Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 11 Nov 2025 17:16:54 +0100 Subject: [PATCH 087/108] Remove the 'always set' bit from FormattingOptions. We don't need it anymore. --- compiler/rustc_ast_lowering/src/format.rs | 5 ++--- library/core/src/fmt/mod.rs | 14 +++----------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index 526dfcd744da..d8a602c949a9 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -387,9 +387,8 @@ fn expand_format_args<'hir>( | ((o.debug_hex == Some(FormatDebugHex::Upper)) as u32) << 26 | (o.width.is_some() as u32) << 27 | (o.precision.is_some() as u32) << 28 - | align << 29 - | 1 << 31; - if flags != 0xE000_0020 { + | align << 29; + if flags != 0x6000_0020 { bytecode[i] |= 1; bytecode.extend_from_slice(&flags.to_le_bytes()); if let Some(val) = &o.width { diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 43355cc98628..b28d92b75a2e 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -289,7 +289,7 @@ pub struct FormattingOptions { /// ```text /// 31 30 29 28 27 26 25 24 23 22 21 20 0 /// β”Œβ”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” - /// β”‚ 1 β”‚ align β”‚ p β”‚ w β”‚ X?β”‚ x?β”‚'0'β”‚ # β”‚ - β”‚ + β”‚ fill β”‚ + /// β”‚ 0 β”‚ align β”‚ p β”‚ w β”‚ X?β”‚ x?β”‚'0'β”‚ # β”‚ - β”‚ + β”‚ fill β”‚ /// β””β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ /// β”‚ β”‚ β”‚ β”‚ β””β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ /// β”‚ β”‚ β”‚ β”‚ β”‚ └─ The fill character (21 bits char). @@ -300,10 +300,7 @@ pub struct FormattingOptions { /// β”‚ β”œβ”€ 1: Align right. (>) /// β”‚ β”œβ”€ 2: Align center. (^) /// β”‚ └─ 3: Alignment not set. (default) - /// └─ Always set. - /// This makes it possible to distinguish formatting flags from - /// a &str size when stored in (the upper bits of) the same field. - /// (fmt::Arguments will make use of this property in the future.) + /// └─ Always zero. /// ``` // Note: This could use a special niche type with range 0x8000_0000..=0xfdd0ffff. // It's unclear if that's useful, though. @@ -329,7 +326,6 @@ mod flags { pub(super) const ALIGN_RIGHT: u32 = 1 << 29; pub(super) const ALIGN_CENTER: u32 = 2 << 29; pub(super) const ALIGN_UNKNOWN: u32 = 3 << 29; - pub(super) const ALWAYS_SET: u32 = 1 << 31; } impl FormattingOptions { @@ -345,11 +341,7 @@ impl FormattingOptions { /// - no [`DebugAsHex`] output mode. #[unstable(feature = "formatting_options", issue = "118117")] pub const fn new() -> Self { - Self { - flags: ' ' as u32 | flags::ALIGN_UNKNOWN | flags::ALWAYS_SET, - width: 0, - precision: 0, - } + Self { flags: ' ' as u32 | flags::ALIGN_UNKNOWN, width: 0, precision: 0 } } /// Sets or removes the sign (the `+` or the `-` flag). From 560b12d0948296d972a7bb3bfe144a16be0aa5b2 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 11 Nov 2025 17:17:23 +0100 Subject: [PATCH 088/108] Don't encode zero width or precision in fmt string. --- compiler/rustc_ast_lowering/src/format.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index d8a602c949a9..39e2630ed913 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -393,13 +393,19 @@ fn expand_format_args<'hir>( bytecode.extend_from_slice(&flags.to_le_bytes()); if let Some(val) = &o.width { let (indirect, val) = make_count(val, &mut argmap); - bytecode[i] |= 1 << 1 | (indirect as u8) << 4; - bytecode.extend_from_slice(&val.to_le_bytes()); + // Only encode if nonzero; zero is the default. + if indirect || val != 0 { + bytecode[i] |= 1 << 1 | (indirect as u8) << 4; + bytecode.extend_from_slice(&val.to_le_bytes()); + } } if let Some(val) = &o.precision { let (indirect, val) = make_count(val, &mut argmap); - bytecode[i] |= 1 << 2 | (indirect as u8) << 5; - bytecode.extend_from_slice(&val.to_le_bytes()); + // Only encode if nonzero; zero is the default. + if indirect || val != 0 { + bytecode[i] |= 1 << 2 | (indirect as u8) << 5; + bytecode.extend_from_slice(&val.to_le_bytes()); + } } } if implicit_arg_index != position { From 04c5e7b54a0ae02a4e03dd472cd05b65ddd16791 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 11 Nov 2025 17:17:53 +0100 Subject: [PATCH 089/108] Document fmt::Arguments internal representation. --- compiler/rustc_ast_lowering/src/format.rs | 9 +- library/core/src/fmt/mod.rs | 145 +++++++++++++++++- library/core/src/fmt/rt.rs | 36 +---- .../item-collection/opaque-return-impls.rs | 2 +- ...mes.foo.ScalarReplacementOfAggregates.diff | 2 +- tests/pretty/issue-4264.pp | 2 +- 6 files changed, 150 insertions(+), 46 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index 39e2630ed913..f16579e99945 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -314,6 +314,8 @@ fn expand_format_args<'hir>( &fmt.template[..] }; + // See library/core/src/fmt/mod.rs for the format string encoding format. + for (i, piece) in template.iter().enumerate() { match piece { &FormatArgsPiece::Literal(sym) => { @@ -347,6 +349,7 @@ fn expand_format_args<'hir>( return hir::ExprKind::Call(from_str, args); } + // Encode the literal in chunks of up to 127 bytes, split at utf-8 boundaries. while !s.is_empty() { let len = s.floor_char_boundary(127); bytecode.push(len as u8); @@ -357,6 +360,7 @@ fn expand_format_args<'hir>( incomplete_lit.clear(); } FormatArgsPiece::Placeholder(p) => { + // Push the start byte and remember its index so we can set the option bits later. let i = bytecode.len(); bytecode.push(0x80); @@ -370,7 +374,7 @@ fn expand_format_args<'hir>( ) .0 as u64; - // This needs to match the constants in library/core/src/fmt/rt.rs. + // This needs to match the constants in library/core/src/fmt/mod.rs. let o = &p.format_options; let align = match o.alignment { Some(FormatAlignment::Left) => 0, @@ -378,6 +382,7 @@ fn expand_format_args<'hir>( Some(FormatAlignment::Center) => 2, None => 3, }; + let default_flags = 0x6000_0020; let flags: u32 = o.fill.unwrap_or(' ') as u32 | ((o.sign == Some(FormatSign::Plus)) as u32) << 21 | ((o.sign == Some(FormatSign::Minus)) as u32) << 22 @@ -388,7 +393,7 @@ fn expand_format_args<'hir>( | (o.width.is_some() as u32) << 27 | (o.precision.is_some() as u32) << 28 | align << 29; - if flags != 0x6000_0020 { + if flags != default_flags { bytecode[i] |= 1; bytecode.extend_from_slice(&flags.to_le_bytes()); if let Some(val) = &o.width { diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index b28d92b75a2e..f7335ddf470b 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -605,6 +605,101 @@ impl<'a> Formatter<'a> { /// ``` /// /// [`format()`]: ../../std/fmt/fn.format.html +// +// Internal representation: +// +// fmt::Arguments is represented in one of two ways: +// +// 1) String literal representation (e.g. format_args!("hello")) +// β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +// template: β”‚ *const u8 β”‚ ─▷ "hello" +// β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€ +// args: β”‚ len β”‚1β”‚ (lowest bit is 1; field contains `len << 1 | 1`) +// β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”˜ +// In this representation, there are no placeholders and `fmt::Arguments::as_str()` returns Some. +// The pointer points to the start of a static `str`. The length is given by `args as usize >> 1`. +// (The length of a `&str` is isize::MAX at most, so it always fits in a usize minus one bit.) +// +// `fmt::Arguments::from_str()` constructs this representation from a `&'static str`. +// +// 2) Placeholders representation (e.g. format_args!("hello {name}\n")) +// β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +// template: β”‚ *const u8 β”‚ ─▷ b"\x06hello \x80\x01\n\x00" +// β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ +// args: β”‚ &'a [Argument<'a>; _] 0β”‚ (lower bit is 0 due to alignment of Argument type) +// β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +// In this representation, the template is a byte sequence encoding both the literal string pieces +// and the placeholders (including their options/flags). +// +// The `args` pointer points to an array of `fmt::Argument<'a>` values, of sufficient length to +// match the placeholders in the template. +// +// `fmt::Arguments::new()` constructs this representation from a template byte slice and a slice +// of arguments. This function is unsafe, as the template is assumed to be valid and the args +// slice is assumed to have elements matching the template. +// +// The template byte sequence is the concatenation of parts of the following types: +// +// - Literal string piece (1-127 bytes): +// β”Œβ”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +// β”‚lenβ”‚ `len` bytes (utf-8) β”‚ (e.g. b"\x06hello ") +// β””β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +// Pieces that must be formatted verbatim (e.g. "hello " and "\n" in "hello {name}\n") +// are represented as a single byte containing their length followed directly by the bytes +// of the string. +// +// Pieces can be 127 bytes at most. Longer pieces are split into multiple pieces (at utf-8 +// boundaries). +// +// - Placeholder: +// β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β” +// β”‚0b10______β”‚ flags β”Š width β”Š precision β”Š arg_index β”Š (e.g. b"\x82\x05\0") +// β””β”€β”€β”€β”€β”‚β”‚β”‚β”‚β”‚β”‚β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”˜ +// β”‚β”‚β”‚β”‚β”‚β”‚ 32 bit 16 bit 16 bit 16 bit +// │││││└─ flags present +// ││││└─ width present +// │││└─ precision present +// ││└─ arg_index present +// │└─ width indirect +// └─ precision indirect +// +// Fully default placeholder, without any options: +// β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +// β”‚0b10000000β”‚ (b"\x80") +// β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +// +// Placeholders (e.g. `{name}` in "hello {name}") are represented as a byte with the highest +// bit set, followed by zero or more fields depending on the flags set in the first byte. +// +// The fields are stored as little endian. +// +// The `flags` fields corresponds to the `flags` field of `FormattingOptions`. +// See doc comment of `FormattingOptions::flags` for details. +// +// The `width` and `precision` fields correspond to their respective fields in +// `FormattingOptions`. However, if their "indirect" flag is set, the field contains the +// index in the `args` array where the dynamic width or precision is stored, rather than the +// value directly. +// +// The `arg_index` field is the index into the `args` array for the argument to be +// formatted. +// +// If omitted, the flags, width and precision of the default FormattingOptions::new() are +// used. +// +// If the `arg_index` is omitted, the next argument in the `args` array is used (starting +// at 0). +// +// - End: +// β”Œβ”€β”€β”€β” +// β”‚ 0 β”‚ ("\0") +// β””β”€β”€β”€β”˜ +// A single zero byte marks the end of the template. +// +// (Note that a zero byte may also occur naturally as part of the string pieces or flags, +// width, precision and arg_index fields above. That is, the template byte sequence ends +// with a 0 byte, but isn't terminated by the first 0 byte.) +// #[lang = "format_arguments"] #[stable(feature = "rust1", since = "1.0.0")] #[derive(Copy, Clone)] @@ -613,6 +708,42 @@ pub struct Arguments<'a> { args: NonNull>, } +/// Used by the format_args!() macro to create a fmt::Arguments object. +#[doc(hidden)] +#[rustc_diagnostic_item = "FmtArgumentsNew"] +#[unstable(feature = "fmt_internals", issue = "none")] +impl<'a> Arguments<'a> { + // SAFETY: The caller must ensure that the provided template and args encode a valid + // fmt::Arguments, as documented above. + #[inline] + pub unsafe fn new( + template: &'a [u8; N], + args: &'a [rt::Argument<'a>; M], + ) -> Arguments<'a> { + // SAFETY: Responsibility of the caller. + unsafe { Arguments { template: mem::transmute(template), args: mem::transmute(args) } } + } + + #[inline] + pub const fn from_str(s: &'static str) -> Arguments<'a> { + // SAFETY: This is the "static str" representation of fmt::Arguments; see above. + unsafe { + Arguments { + template: mem::transmute(s.as_ptr()), + args: mem::transmute(s.len() << 1 | 1), + } + } + } + + // Same as `from_str`, but not const. + // Used by format_args!() expansion when arguments are inlined, + // e.g. format_args!("{}", 123), which is not allowed in const. + #[inline] + pub fn from_str_nonconst(s: &'static str) -> Arguments<'a> { + Arguments::from_str(s) + } +} + #[doc(hidden)] #[unstable(feature = "fmt_internals", issue = "none")] impl<'a> Arguments<'a> { @@ -646,10 +777,10 @@ impl<'a> Arguments<'a> { starts_with_placeholder = true; } // Skip remainder of placeholder: - let skip = (n & 1 == 1) as usize * 4 - + (n & 2 == 2) as usize * 2 - + (n & 4 == 4) as usize * 2 - + (n & 8 == 8) as usize * 2; + let skip = (n & 1 != 0) as usize * 4 // flags (32 bit) + + (n & 2 != 0) as usize * 2 // width (16 bit) + + (n & 4 != 0) as usize * 2 // precision (16 bit) + + (n & 8 != 0) as usize * 2; // arg_index (16 bit) template = template.add(1 + skip as usize); } } @@ -718,11 +849,13 @@ impl<'a> Arguments<'a> { #[inline] pub const fn as_str(&self) -> Option<&'static str> { // SAFETY: During const eval, `self.args` must have come from a usize, - // not a pointer, because that's the only way to creat a fmt::Arguments in const. + // not a pointer, because that's the only way to create a fmt::Arguments in const. + // (I.e. only fmt::Arguments::from_str is const, fmt::Arguments::new is not.) + // // Outside const eval, transmuting a pointer to a usize is fine. let bits: usize = unsafe { mem::transmute(self.args) }; if bits & 1 == 1 { - // SAFETY: This fmt::Arguments stores a &'static str. + // SAFETY: This fmt::Arguments stores a &'static str. See encoding documentation above. Some(unsafe { str::from_utf8_unchecked(crate::slice::from_raw_parts( self.template.as_ptr(), diff --git a/library/core/src/fmt/rt.rs b/library/core/src/fmt/rt.rs index 6629873a567a..93f4c57abcc8 100644 --- a/library/core/src/fmt/rt.rs +++ b/library/core/src/fmt/rt.rs @@ -8,7 +8,6 @@ use super::*; use crate::hint::unreachable_unchecked; -use crate::mem; use crate::ptr::NonNull; #[derive(Copy, Clone)] @@ -35,7 +34,7 @@ enum ArgumentType<'a> { /// precision and width. #[lang = "format_argument"] #[derive(Copy, Clone)] -#[repr(align(2))] +#[repr(align(2))] // To ensure pointers to this always have their lowest bit cleared. pub struct Argument<'a> { ty: ArgumentType<'a>, } @@ -164,36 +163,3 @@ impl Argument<'_> { } } } - -/// Used by the format_args!() macro to create a fmt::Arguments object. -#[doc(hidden)] -#[rustc_diagnostic_item = "FmtArgumentsNew"] -impl<'a> Arguments<'a> { - #[inline] - pub unsafe fn new( - template: &'a [u8; N], - args: &'a [rt::Argument<'a>; M], - ) -> Arguments<'a> { - // SAFETY: ... - unsafe { Arguments { template: mem::transmute(template), args: mem::transmute(args) } } - } - - #[inline] - pub const fn from_str(s: &'static str) -> Arguments<'a> { - // SAFETY: This is the "static str" representation of fmt::Arguments. - unsafe { - Arguments { - template: mem::transmute(s.as_ptr()), - args: mem::transmute(s.len() << 1 | 1), - } - } - } - - // Same as `from_str`, but not const. - // Used by format_args!() expansion when arguments are inlined, - // e.g. format_args!("{}", 123), which is not allowed in const. - #[inline] - pub fn from_str_nonconst(s: &'static str) -> Arguments<'a> { - Arguments::from_str(s) - } -} diff --git a/tests/codegen-units/item-collection/opaque-return-impls.rs b/tests/codegen-units/item-collection/opaque-return-impls.rs index 2859e1679918..1659b62175b7 100644 --- a/tests/codegen-units/item-collection/opaque-return-impls.rs +++ b/tests/codegen-units/item-collection/opaque-return-impls.rs @@ -86,4 +86,4 @@ pub fn foo3() -> Box> { //~ MONO_ITEM fn foo3 //~ MONO_ITEM fn std::boxed::Box::::new //~ MONO_ITEM fn Counter::new -//~ MONO_ITEM fn core::fmt::rt::>::from_str +//~ MONO_ITEM fn std::fmt::Arguments::<'_>::from_str diff --git a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff index 4b867d4325c8..68f6b45f29e8 100644 --- a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff @@ -144,7 +144,7 @@ StorageLive(_23); _23 = &_15; _22 = &(*_23); - _11 = core::fmt::rt::>::new::<7, 2>(move _20, move _22) -> [return: bb5, unwind unreachable]; + _11 = Arguments::<'_>::new::<7, 2>(move _20, move _22) -> [return: bb5, unwind unreachable]; } bb5: { diff --git a/tests/pretty/issue-4264.pp b/tests/pretty/issue-4264.pp index c4517574a466..4eee6655cf6f 100644 --- a/tests/pretty/issue-4264.pp +++ b/tests/pretty/issue-4264.pp @@ -34,7 +34,7 @@ fn bar() ({ ((::alloc::fmt::format as for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::from_str as - fn(&'static str) -> Arguments<'_> {core::fmt::rt::>::from_str})(("test" + fn(&'static str) -> Arguments<'_> {Arguments::<'_>::from_str})(("test" as &str)) as Arguments<'_>)) as String) } as String)) as String); } as ()) From ef1e3cadfdd921f79c325af534b90db1f448c686 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 11 Nov 2025 20:16:25 +0100 Subject: [PATCH 090/108] Bless clippy tests. --- src/tools/clippy/tests/ui/author/macro_in_closure.stdout | 2 +- src/tools/clippy/tests/ui/author/macro_in_loop.stdout | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/clippy/tests/ui/author/macro_in_closure.stdout b/src/tools/clippy/tests/ui/author/macro_in_closure.stdout index 52a9c5b2c67d..4b899202243f 100644 --- a/src/tools/clippy/tests/ui/author/macro_in_closure.stdout +++ b/src/tools/clippy/tests/ui/author/macro_in_closure.stdout @@ -34,7 +34,7 @@ if let StmtKind::Let(local) = stmt.kind && block2.stmts.is_empty() && let Some(trailing_expr1) = block2.expr && let ExprKind::Call(func2, args2) = trailing_expr1.kind - && paths::CORE_FMT_RT_NEW.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed + && paths::CORE_FMT_ARGUMENTS_NEW.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed && args2.len() == 2 && let ExprKind::Lit(ref lit) = args2[0].kind && let LitKind::ByteStr(ref vec) = lit.node diff --git a/src/tools/clippy/tests/ui/author/macro_in_loop.stdout b/src/tools/clippy/tests/ui/author/macro_in_loop.stdout index 18484f6ffc56..c40ee463b6c9 100644 --- a/src/tools/clippy/tests/ui/author/macro_in_loop.stdout +++ b/src/tools/clippy/tests/ui/author/macro_in_loop.stdout @@ -45,7 +45,7 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo && block3.stmts.is_empty() && let Some(trailing_expr1) = block3.expr && let ExprKind::Call(func2, args2) = trailing_expr1.kind - && paths::CORE_FMT_RT_NEW.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed + && paths::CORE_FMT_ARGUMENTS_NEW.matches_path(cx, func2) // Add the path to `clippy_utils::paths` if needed && args2.len() == 2 && let ExprKind::Lit(ref lit2) = args2[0].kind && let LitKind::ByteStr(ref vec) = lit2.node From 3f85b01256a5933fbdb9b7fcb69ce4bdd00def41 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Nov 2025 03:20:46 +0100 Subject: [PATCH 091/108] Clarify internal fmt::Arguments documentation. --- library/core/src/fmt/mod.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index f7335ddf470b..9335a8866ef1 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -641,17 +641,19 @@ impl<'a> Formatter<'a> { // The template byte sequence is the concatenation of parts of the following types: // // - Literal string piece (1-127 bytes): +// Pieces that must be formatted verbatim (e.g. "hello " and "\n" in "hello {name}\n") +// are represented as a single byte containing their length followed directly by the bytes +// of the string: // β”Œβ”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” // β”‚lenβ”‚ `len` bytes (utf-8) β”‚ (e.g. b"\x06hello ") // β””β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ -// Pieces that must be formatted verbatim (e.g. "hello " and "\n" in "hello {name}\n") -// are represented as a single byte containing their length followed directly by the bytes -// of the string. // -// Pieces can be 127 bytes at most. Longer pieces are split into multiple pieces (at utf-8 -// boundaries). +// These strings can be 127 bytes at most, such that the `len` byte always has the highest +// bit cleared. Longer pieces are split into multiple pieces (at utf-8 boundaries). // // - Placeholder: +// Placeholders (e.g. `{name}` in "hello {name}") are represented as a byte with the highest +// bit set, followed by zero or more fields depending on the flags set in the first byte: // β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β” // β”‚0b10______β”‚ flags β”Š width β”Š precision β”Š arg_index β”Š (e.g. b"\x82\x05\0") // β””β”€β”€β”€β”€β”‚β”‚β”‚β”‚β”‚β”‚β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”˜ @@ -663,14 +665,14 @@ impl<'a> Formatter<'a> { // │└─ width indirect // └─ precision indirect // -// Fully default placeholder, without any options: +// All fields other than the first byte are optional and only present when +// their corresponding flag is set in the first byte. +// +// So, a fully default placeholder without any options is just a single byte: // β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” // β”‚0b10000000β”‚ (b"\x80") // β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ // -// Placeholders (e.g. `{name}` in "hello {name}") are represented as a byte with the highest -// bit set, followed by zero or more fields depending on the flags set in the first byte. -// // The fields are stored as little endian. // // The `flags` fields corresponds to the `flags` field of `FormattingOptions`. @@ -691,10 +693,10 @@ impl<'a> Formatter<'a> { // at 0). // // - End: +// A single zero byte marks the end of the template: // β”Œβ”€β”€β”€β” // β”‚ 0 β”‚ ("\0") // β””β”€β”€β”€β”˜ -// A single zero byte marks the end of the template. // // (Note that a zero byte may also occur naturally as part of the string pieces or flags, // width, precision and arg_index fields above. That is, the template byte sequence ends @@ -1616,6 +1618,8 @@ pub fn write(output: &mut dyn Write, fmt: Arguments<'_>) -> Result { let mut arg_index = 0; + // See comment on `fmt::Arguments` for the details of how the template is encoded. + // This must match the encoding from `expand_format_args` in // compiler/rustc_ast_lowering/src/format.rs. loop { From f92c5f1c09a7123912b7d277e4813b002ed957aa Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Nov 2025 03:31:25 +0100 Subject: [PATCH 092/108] Change assert to span_err. --- compiler/rustc_ast_lowering/src/format.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index f16579e99945..30f114ea0bf4 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -428,7 +428,9 @@ fn expand_format_args<'hir>( bytecode.push(0); // Ensure all argument indexes actually fit in 16 bits, as we truncated them to 16 bits before. - assert!(argmap.len() <= u16::MAX as usize); + if argmap.len() > u16::MAX as usize { + ctx.dcx().span_err(macsp, "too many format arguments"); + } let arguments = fmt.arguments.all_args(); From 8b20d0d0a1b2fb7989ee2b0d2a6a3c8b38676ad3 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Nov 2025 12:34:55 +0100 Subject: [PATCH 093/108] Allow larger string pieces in fmt::Arguments repr. --- compiler/rustc_ast_lowering/src/format.rs | 13 ++-- library/core/src/fmt/mod.rs | 60 ++++++++++++++----- ...mes.foo.ScalarReplacementOfAggregates.diff | 4 +- tests/ui/unpretty/exhaustive.hir.stdout | 2 +- .../ui/unpretty/flattened-format-args.stdout | 2 +- 5 files changed, 58 insertions(+), 23 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index 30f114ea0bf4..380cbfa5fe01 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -349,10 +349,15 @@ fn expand_format_args<'hir>( return hir::ExprKind::Call(from_str, args); } - // Encode the literal in chunks of up to 127 bytes, split at utf-8 boundaries. + // Encode the literal in chunks of up to u16::MAX bytes, split at utf-8 boundaries. while !s.is_empty() { - let len = s.floor_char_boundary(127); - bytecode.push(len as u8); + let len = s.floor_char_boundary(usize::from(u16::MAX)); + if len < 0x80 { + bytecode.push(len as u8); + } else { + bytecode.push(0x80); + bytecode.extend_from_slice(&(len as u16).to_le_bytes()); + } bytecode.extend(&s.as_bytes()[..len]); s = &s[len..]; } @@ -362,7 +367,7 @@ fn expand_format_args<'hir>( FormatArgsPiece::Placeholder(p) => { // Push the start byte and remember its index so we can set the option bits later. let i = bytecode.len(); - bytecode.push(0x80); + bytecode.push(0xC0); let position = argmap .insert_full( diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 9335a8866ef1..88f5dbdc6162 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -4,6 +4,7 @@ use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell}; use crate::char::{EscapeDebugExtArgs, MAX_LEN_UTF8}; +use crate::hint::assert_unchecked; use crate::marker::{PhantomData, PointeeSized}; use crate::num::fmt as numfmt; use crate::ops::Deref; @@ -640,22 +641,29 @@ impl<'a> Formatter<'a> { // // The template byte sequence is the concatenation of parts of the following types: // -// - Literal string piece (1-127 bytes): +// - Literal string piece: // Pieces that must be formatted verbatim (e.g. "hello " and "\n" in "hello {name}\n") -// are represented as a single byte containing their length followed directly by the bytes -// of the string: +// appear literally in the template byte sequence, prefixed by their length. +// +// For pieces of up to 127 bytes, these are represented as a single byte containing the +// length followed directly by the bytes of the string: // β”Œβ”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” // β”‚lenβ”‚ `len` bytes (utf-8) β”‚ (e.g. b"\x06hello ") // β””β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ // -// These strings can be 127 bytes at most, such that the `len` byte always has the highest -// bit cleared. Longer pieces are split into multiple pieces (at utf-8 boundaries). +// For larger pieces up to u16::MAX bytes, these are represented as a 0x80 followed by +// their length in 16-bit little endian, followed by the bytes of the string: +// β”Œβ”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +// β”‚0x80β”‚ len β”‚ `len` bytes (utf-8) β”‚ (e.g. b"\x80\x00\x01hello … ") +// β””β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +// +// Longer pieces are split into multiple pieces of max u16::MAX bytes (at utf-8 boundaries). // // - Placeholder: // Placeholders (e.g. `{name}` in "hello {name}") are represented as a byte with the highest -// bit set, followed by zero or more fields depending on the flags set in the first byte: +// two bits set, followed by zero or more fields depending on the flags in the first byte: // β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”¬β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β” -// β”‚0b10______β”‚ flags β”Š width β”Š precision β”Š arg_index β”Š (e.g. b"\x82\x05\0") +// β”‚0b11______β”‚ flags β”Š width β”Š precision β”Š arg_index β”Š (e.g. b"\xC2\x05\0") // β””β”€β”€β”€β”€β”‚β”‚β”‚β”‚β”‚β”‚β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”΄β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”˜ // β”‚β”‚β”‚β”‚β”‚β”‚ 32 bit 16 bit 16 bit 16 bit // │││││└─ flags present @@ -665,12 +673,12 @@ impl<'a> Formatter<'a> { // │└─ width indirect // └─ precision indirect // -// All fields other than the first byte are optional and only present when -// their corresponding flag is set in the first byte. +// All fields other than the first byte are optional and only present when their +// corresponding flag is set in the first byte. // // So, a fully default placeholder without any options is just a single byte: // β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” -// β”‚0b10000000β”‚ (b"\x80") +// β”‚0b11000000β”‚ (b"\xC0") // β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ // // The fields are stored as little endian. @@ -766,14 +774,21 @@ impl<'a> Arguments<'a> { // SAFETY: We can assume the template is valid. unsafe { let n = template.read(); + template = template.add(1); if n == 0 { // End of template. break; } else if n < 128 { - // Literal string piece. + // Short literal string piece. length += n as usize; - template = template.add(1 + n as usize); + template = template.add(n as usize); + } else if n == 128 { + // Long literal string piece. + let len = usize::from(u16::from_le_bytes(template.cast_array().read())); + length += len; + template = template.add(2 + len); } else { + assert_unchecked(n >= 0xC0); // Placeholder piece. if length == 0 { starts_with_placeholder = true; @@ -783,7 +798,7 @@ impl<'a> Arguments<'a> { + (n & 2 != 0) as usize * 2 // width (16 bit) + (n & 4 != 0) as usize * 2 // precision (16 bit) + (n & 8 != 0) as usize * 2; // arg_index (16 bit) - template = template.add(1 + skip as usize); + template = template.add(skip as usize); } } } @@ -1633,7 +1648,7 @@ pub fn write(output: &mut dyn Write, fmt: Arguments<'_>) -> Result { if n == 0 { // End of template. return Ok(()); - } else if n < 128 { + } else if n < 0x80 { // Literal string piece of length `n`. // SAFETY: We can assume the strings in the template are valid. @@ -1643,7 +1658,19 @@ pub fn write(output: &mut dyn Write, fmt: Arguments<'_>) -> Result { s }; output.write_str(s)?; - } else if n == 128 { + } else if n == 0x80 { + // Literal string piece with a 16-bit length. + + // SAFETY: We can assume the strings in the template are valid. + let s = unsafe { + let len = usize::from(u16::from_le_bytes(template.cast_array().read())); + template = template.add(2); + let s = crate::str::from_raw_parts(template.as_ptr(), len); + template = template.add(len); + s + }; + output.write_str(s)?; + } else if n == 0xC0 { // Placeholder for next argument with default options. // // Having this as a separate case improves performance for the common case. @@ -1656,6 +1683,9 @@ pub fn write(output: &mut dyn Write, fmt: Arguments<'_>) -> Result { } arg_index += 1; } else { + // SAFETY: We can assume the template is valid. + unsafe { assert_unchecked(n > 0xC0) }; + // Placeholder with custom options. let mut opt = FormattingOptions::new(); diff --git a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff index 68f6b45f29e8..7012cc5aa7f6 100644 --- a/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa/lifetimes.foo.ScalarReplacementOfAggregates.diff @@ -138,7 +138,7 @@ StorageDead(_16); StorageLive(_20); StorageLive(_21); - _21 = const b"\x80\x01 \x80\x01\n\x00"; + _21 = const b"\xc0\x01 \xc0\x01\n\x00"; _20 = &(*_21); StorageLive(_22); StorageLive(_23); @@ -201,6 +201,6 @@ } ALLOC0 (size: 7, align: 1) { - 80 01 20 80 01 0a 00 β”‚ .. .... + c0 01 20 c0 01 0a 00 β”‚ .. .... } diff --git a/tests/ui/unpretty/exhaustive.hir.stdout b/tests/ui/unpretty/exhaustive.hir.stdout index 55b699728224..3f0a2006e968 100644 --- a/tests/ui/unpretty/exhaustive.hir.stdout +++ b/tests/ui/unpretty/exhaustive.hir.stdout @@ -394,7 +394,7 @@ mod expressions { { super let args = (&expr,); super let args = [format_argument::new_display(args.0)]; - unsafe { format_arguments::new(b"\x80\x00", &args) } + unsafe { format_arguments::new(b"\xc0\x00", &args) } }; } } diff --git a/tests/ui/unpretty/flattened-format-args.stdout b/tests/ui/unpretty/flattened-format-args.stdout index b47205e96a6a..5c7866dcf39f 100644 --- a/tests/ui/unpretty/flattened-format-args.stdout +++ b/tests/ui/unpretty/flattened-format-args.stdout @@ -14,7 +14,7 @@ fn main() { super let args = (&x,); super let args = [format_argument::new_display(args.0)]; unsafe { - format_arguments::new(b"\x08a 123 b \x80\x05 xyz\n\x00", + format_arguments::new(b"\x08a 123 b \xc0\x05 xyz\n\x00", &args) } }); From 9b4843196c0514ef51e8dcee8526ce72cacc123b Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Nov 2025 12:44:59 +0100 Subject: [PATCH 094/108] Bless coverage tests. --- tests/coverage/assert.coverage | 1 - tests/coverage/bad_counter_ids.coverage | 2 -- tests/coverage/closure.coverage | 26 ++++++++++++------------- tests/coverage/issue-84561.coverage | 18 +++++++---------- tests/coverage/partial_eq.coverage | 2 +- tests/coverage/rustfmt-skip.coverage | 2 +- 6 files changed, 22 insertions(+), 29 deletions(-) diff --git a/tests/coverage/assert.coverage b/tests/coverage/assert.coverage index dfd919660f55..8b0d337980bc 100644 --- a/tests/coverage/assert.coverage +++ b/tests/coverage/assert.coverage @@ -4,7 +4,6 @@ LL| 4|fn might_fail_assert(one_plus_one: u32) { LL| 4| println!("does 1 + 1 = {}?", one_plus_one); LL| 4| assert_eq!(1 + 1, one_plus_one, "the argument was wrong"); - ^1 LL| 3|} LL| | LL| 1|fn main() -> Result<(), u8> { diff --git a/tests/coverage/bad_counter_ids.coverage b/tests/coverage/bad_counter_ids.coverage index f6c69913cdd2..b56bee592bb5 100644 --- a/tests/coverage/bad_counter_ids.coverage +++ b/tests/coverage/bad_counter_ids.coverage @@ -21,7 +21,6 @@ LL| 1|fn eq_good_message() { LL| 1| println!("b"); LL| 1| assert_eq!(Foo(1), Foo(1), "message b"); - ^0 LL| 1|} LL| | LL| 1|fn ne_good() { @@ -32,7 +31,6 @@ LL| 1|fn ne_good_message() { LL| 1| println!("d"); LL| 1| assert_ne!(Foo(1), Foo(3), "message d"); - ^0 LL| 1|} LL| | LL| 1|fn eq_bad() { diff --git a/tests/coverage/closure.coverage b/tests/coverage/closure.coverage index d44ecf5a69e2..64e6006bbe8c 100644 --- a/tests/coverage/closure.coverage +++ b/tests/coverage/closure.coverage @@ -15,7 +15,7 @@ LL| | LL| 1| let mut some_string = Some(String::from("the string content")); LL| 1| println!( - LL| 1| "The string or alt: {}" + LL| | "The string or alt: {}" LL| | , LL| 1| some_string LL| | . @@ -45,7 +45,7 @@ LL| 0| "alt string 2".to_owned() LL| 0| }; LL| 1| println!( - LL| 1| "The string or alt: {}" + LL| | "The string or alt: {}" LL| | , LL| 1| some_string LL| | . @@ -57,7 +57,7 @@ LL| | LL| 1| some_string = None; LL| 1| println!( - LL| 1| "The string or alt: {}" + LL| | "The string or alt: {}" LL| | , LL| 1| some_string LL| | . @@ -87,7 +87,7 @@ LL| 1| "alt string 4".to_owned() LL| 1| }; LL| 1| println!( - LL| 1| "The string or alt: {}" + LL| | "The string or alt: {}" LL| | , LL| 1| some_string LL| | . @@ -109,7 +109,7 @@ LL| 5| format!("'{}'", val) LL| 5| }; LL| 1| println!( - LL| 1| "Repeated, quoted string: {:?}" + LL| | "Repeated, quoted string: {:?}" LL| | , LL| 1| std::iter::repeat("repeat me") LL| 1| .take(5) @@ -139,15 +139,15 @@ LL| | LL| 1| let short_used_covered_closure_macro = | used_arg: u8 | println!("called"); LL| 1| let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called"); - ^0 ^0 + ^0 LL| 1| let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called"); - ^0 ^0 + ^0 LL| | LL| | LL| | LL| | LL| 1| let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") }; - ^0^0 ^0 ^0 + ^0^0 ^0 LL| | LL| 1| let _shortish_unused_closure = | _unused_arg: u8 | { ^0 @@ -174,14 +174,14 @@ LL| 1| let _short_unused_closure_line_break_no_block2 = LL| | | _unused_arg: u8 | LL| 0| println!( - LL| 0| "not called" + LL| | "not called" LL| | ) LL| | ; LL| | LL| 1| let short_used_not_covered_closure_line_break_no_block_embedded_branch = LL| | | _unused_arg: u8 | LL| | println!( - LL| 0| "not called: {}", + LL| | "not called: {}", LL| 0| if is_true { "check" } else { "me" } LL| | ) LL| | ; @@ -190,7 +190,7 @@ LL| | | _unused_arg: u8 | LL| 0| { LL| 0| println!( - LL| 0| "not called: {}", + LL| | "not called: {}", LL| 0| if is_true { "check" } else { "me" } LL| | ) LL| 0| } @@ -199,7 +199,7 @@ LL| 1| let short_used_covered_closure_line_break_no_block_embedded_branch = LL| | | _unused_arg: u8 | LL| | println!( - LL| 1| "not called: {}", + LL| | "not called: {}", LL| 1| if is_true { "check" } else { "me" } ^0 LL| | ) @@ -209,7 +209,7 @@ LL| | | _unused_arg: u8 | LL| 1| { LL| 1| println!( - LL| 1| "not called: {}", + LL| | "not called: {}", LL| 1| if is_true { "check" } else { "me" } ^0 LL| | ) diff --git a/tests/coverage/issue-84561.coverage b/tests/coverage/issue-84561.coverage index 781f1e97f5ab..8a8396e95d2b 100644 --- a/tests/coverage/issue-84561.coverage +++ b/tests/coverage/issue-84561.coverage @@ -22,18 +22,17 @@ LL| 1| assert_ne!(bar, Foo(3)); LL| 1| assert_ne!(Foo(0), Foo(4)); LL| 1| assert_eq!(Foo(3), Foo(3), "with a message"); - ^0 LL| 1| println!("{:?}", bar); LL| 1| println!("{:?}", Foo(1)); LL| | LL| 1| assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" }); - ^0 ^0 ^0 ^0 + ^0 ^0 ^0 LL| 1| assert_ne!( LL| | Foo(0) LL| | , LL| | Foo(5) LL| | , - LL| 0| "{}" + LL| | "{}" LL| | , LL| | if LL| 0| is_true @@ -78,13 +77,13 @@ LL| 1| assert_ne!( LL| | Foo(0), LL| | Foo(4), - LL| 0| "with a message" + LL| | "with a message" LL| | ); LL| | } else { LL| 0| assert_eq!( LL| | Foo(3), LL| | Foo(3), - LL| 0| "with a message" + LL| | "with a message" LL| | ); LL| | } LL| 1| assert_ne!( @@ -122,17 +121,17 @@ LL| 0| Foo(1) LL| | }, LL| | Foo(5), - LL| 0| "with a message" + LL| | "with a message" LL| | ); LL| 1| assert_eq!( LL| | Foo(1), LL| | Foo(3), - LL| 1| "this assert should fail" + LL| | "this assert should fail" LL| | ); LL| 0| assert_eq!( LL| | Foo(3), LL| | Foo(3), - LL| 0| "this assert should not be reached" + LL| | "this assert should not be reached" LL| | ); LL| 0|} LL| | @@ -156,12 +155,9 @@ LL| | LL| 1|fn test1() { LL| 1| debug!("debug is enabled"); - ^0 LL| 1| debug!("debug is enabled"); - ^0 LL| 1| let _ = 0; LL| 1| debug!("debug is enabled"); - ^0 LL| 1| unsafe { LL| 1| DEBUG_LEVEL_ENABLED = true; LL| 1| } diff --git a/tests/coverage/partial_eq.coverage b/tests/coverage/partial_eq.coverage index 0662ce2c3000..6efe6d71245e 100644 --- a/tests/coverage/partial_eq.coverage +++ b/tests/coverage/partial_eq.coverage @@ -19,7 +19,7 @@ LL| 1| let version_3_3_0 = Version::new(3, 3, 0); LL| | LL| 1| println!( - LL| 1| "{:?} < {:?} = {}", + LL| | "{:?} < {:?} = {}", LL| | version_3_2_1, LL| | version_3_3_0, LL| 1| version_3_2_1 < version_3_3_0, // diff --git a/tests/coverage/rustfmt-skip.coverage b/tests/coverage/rustfmt-skip.coverage index b7276cf0ee8b..08471181f41b 100644 --- a/tests/coverage/rustfmt-skip.coverage +++ b/tests/coverage/rustfmt-skip.coverage @@ -12,7 +12,7 @@ LL| 1| println!( LL| | // Keep this on a separate line, to distinguish instrumentation of LL| | // `println!` from instrumentation of its arguments. - LL| 1| "hello" + LL| | "hello" LL| | ); LL| 1|} From fda03011effa8a42edb1f93e553e279eb6fcc7bf Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Nov 2025 14:25:37 +0100 Subject: [PATCH 095/108] Fix comment about potential niche in FormattingOptions. --- library/core/src/fmt/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 88f5dbdc6162..e00e48bcfeb7 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -303,7 +303,7 @@ pub struct FormattingOptions { /// β”‚ └─ 3: Alignment not set. (default) /// └─ Always zero. /// ``` - // Note: This could use a special niche type with range 0x8000_0000..=0xfdd0ffff. + // Note: This could use a pattern type with range 0x0000_0000..=0x7dd0ffff. // It's unclear if that's useful, though. flags: u32, /// Width if width flag (bit 27) above is set. Otherwise, always 0. From 832a52569235d2773c62bdd4e05cebc7ba89fd70 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Nov 2025 14:30:20 +0100 Subject: [PATCH 096/108] Add debug assert. --- compiler/rustc_ast_lowering/src/format.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index 380cbfa5fe01..ea22accee73a 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -349,6 +349,10 @@ fn expand_format_args<'hir>( return hir::ExprKind::Call(from_str, args); } + // It shouldn't be possible to have an empty literal here. Encoding an empty literal + // would result in a single 0 byte, which marks the end of the template byte sequence. + debug_assert!(!s.is_empty()); + // Encode the literal in chunks of up to u16::MAX bytes, split at utf-8 boundaries. while !s.is_empty() { let len = s.floor_char_boundary(usize::from(u16::MAX)); From 2a14add94d04349c254946a44998e6c2be7988bd Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Nov 2025 14:31:11 +0100 Subject: [PATCH 097/108] Clarify comment. --- library/core/src/fmt/rt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/fmt/rt.rs b/library/core/src/fmt/rt.rs index 93f4c57abcc8..5221783e7290 100644 --- a/library/core/src/fmt/rt.rs +++ b/library/core/src/fmt/rt.rs @@ -34,7 +34,7 @@ enum ArgumentType<'a> { /// precision and width. #[lang = "format_argument"] #[derive(Copy, Clone)] -#[repr(align(2))] // To ensure pointers to this always have their lowest bit cleared. +#[repr(align(2))] // To ensure pointers to this struct always have their lowest bit cleared. pub struct Argument<'a> { ty: ArgumentType<'a>, } From 83a0d71e6deeb04d6473eb9d193299cb9063d6ac Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Nov 2025 14:33:41 +0100 Subject: [PATCH 098/108] Add comment. --- library/core/src/panicking.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index fa758ebf4667..3609dd1fe2e0 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -171,6 +171,7 @@ macro_rules! panic_const { #[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable #[lang = stringify!($lang)] pub const fn $lang() -> ! { + // See the comment in `panic(&'static str)` for why we use `Arguments::from_str` here. panic_fmt(fmt::Arguments::from_str($message)); } )+ From e9d212ddce98fa572eff05d109cf692317d1c235 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Nov 2025 14:43:05 +0100 Subject: [PATCH 099/108] Bless clippy tests. --- src/tools/clippy/tests/ui/author/macro_in_closure.stdout | 2 +- src/tools/clippy/tests/ui/author/macro_in_loop.stdout | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/clippy/tests/ui/author/macro_in_closure.stdout b/src/tools/clippy/tests/ui/author/macro_in_closure.stdout index 4b899202243f..43753c3288c0 100644 --- a/src/tools/clippy/tests/ui/author/macro_in_closure.stdout +++ b/src/tools/clippy/tests/ui/author/macro_in_closure.stdout @@ -38,7 +38,7 @@ if let StmtKind::Let(local) = stmt.kind && args2.len() == 2 && let ExprKind::Lit(ref lit) = args2[0].kind && let LitKind::ByteStr(ref vec) = lit.node - && let [[128, 1, 10, 0]] = **vec + && let [[192, 1, 10, 0]] = **vec && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[1].kind && block.expr.is_none() && let PatKind::Binding(BindingMode::NONE, _, name2, None) = local.pat.kind diff --git a/src/tools/clippy/tests/ui/author/macro_in_loop.stdout b/src/tools/clippy/tests/ui/author/macro_in_loop.stdout index c40ee463b6c9..561a2dcbd7fe 100644 --- a/src/tools/clippy/tests/ui/author/macro_in_loop.stdout +++ b/src/tools/clippy/tests/ui/author/macro_in_loop.stdout @@ -49,7 +49,7 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo && args2.len() == 2 && let ExprKind::Lit(ref lit2) = args2[0].kind && let LitKind::ByteStr(ref vec) = lit2.node - && let [[128, 1, 10, 0]] = **vec + && let [[192, 1, 10, 0]] = **vec && let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner1) = args2[1].kind && block1.expr.is_none() && block.expr.is_none() From cfbdc2c36d002ed80dbc1cd918d84f6c18e901be Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Nov 2025 14:56:58 +0100 Subject: [PATCH 100/108] Simplify loop in format_args lowering. --- compiler/rustc_ast_lowering/src/format.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index ea22accee73a..602635af1324 100644 --- a/compiler/rustc_ast_lowering/src/format.rs +++ b/compiler/rustc_ast_lowering/src/format.rs @@ -89,9 +89,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let mut was_inlined = vec![false; fmt.arguments.all_args().len()]; let mut inlined_anything = false; - let mut i = 0; - - while i < fmt.template.len() { + for i in 0..fmt.template.len() { if let FormatArgsPiece::Placeholder(placeholder) = &fmt.template[i] && let Ok(arg_index) = placeholder.argument.index && let FormatTrait::Display = placeholder.format_trait @@ -104,16 +102,9 @@ impl<'hir> LoweringContext<'_, 'hir> { // If this is the first time, this clones the outer FormatArgs. let fmt = fmt.to_mut(); // Replace the placeholder with the literal. - if literal.is_empty() { - fmt.template.remove(i); - } else { - fmt.template[i] = FormatArgsPiece::Literal(literal); - i += 1; - } + fmt.template[i] = FormatArgsPiece::Literal(literal); was_inlined[arg_index] = true; inlined_anything = true; - } else { - i += 1; } } @@ -349,10 +340,6 @@ fn expand_format_args<'hir>( return hir::ExprKind::Call(from_str, args); } - // It shouldn't be possible to have an empty literal here. Encoding an empty literal - // would result in a single 0 byte, which marks the end of the template byte sequence. - debug_assert!(!s.is_empty()); - // Encode the literal in chunks of up to u16::MAX bytes, split at utf-8 boundaries. while !s.is_empty() { let len = s.floor_char_boundary(usize::from(u16::MAX)); From dae003b04b2c2be12a690bc5c82b097b696ea18b Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Thu, 13 Nov 2025 01:36:35 +0900 Subject: [PATCH 101/108] fix: Do not ICE when missing match arm with ill-formed subty is met --- compiler/rustc_pattern_analysis/src/rustc.rs | 13 ++++++- ...r-with-ill-formed-inner-ty-issue-148192.rs | 20 ++++++++++ ...th-ill-formed-inner-ty-issue-148192.stderr | 37 +++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/ui/pattern/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs create mode 100644 tests/ui/pattern/missing-ctor-with-ill-formed-inner-ty-issue-148192.stderr diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index c3f6eaccfabc..df86233c2b05 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -191,7 +191,18 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { variant.fields.iter().map(move |field| { let ty = field.ty(self.tcx, args); // `field.ty()` doesn't normalize after instantiating. - let ty = self.tcx.normalize_erasing_regions(self.typing_env, ty); + let ty = + self.tcx.try_normalize_erasing_regions(self.typing_env, ty).unwrap_or_else(|e| { + self.tcx.dcx().span_delayed_bug( + self.scrut_span, + format!( + "Failed to normalize {:?} in typing_env={:?} while getting variant sub tys for {ty:?}", + e.get_type_for_failure(), + self.typing_env, + ), + ); + ty + }); let ty = self.reveal_opaque_ty(ty); (field, ty) }) diff --git a/tests/ui/pattern/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs b/tests/ui/pattern/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs new file mode 100644 index 000000000000..4ad47352e002 --- /dev/null +++ b/tests/ui/pattern/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs @@ -0,0 +1,20 @@ +trait WhereTrait { + type Type; +} + +fn foo(e: Enum) { + if let Enum::Map(_) = e {} + + match e { + //~^ ERROR: non-exhaustive patterns: `Enum::Map2(_)` not covered + Enum::Map(_) => (), + } +} + +enum Enum { + Map(()), + Map2(<() as WhereTrait>::Type), + //~^ ERROR: the trait bound `(): WhereTrait` is not satisfied +} + +fn main() {} diff --git a/tests/ui/pattern/missing-ctor-with-ill-formed-inner-ty-issue-148192.stderr b/tests/ui/pattern/missing-ctor-with-ill-formed-inner-ty-issue-148192.stderr new file mode 100644 index 000000000000..4e1bd3689e3d --- /dev/null +++ b/tests/ui/pattern/missing-ctor-with-ill-formed-inner-ty-issue-148192.stderr @@ -0,0 +1,37 @@ +error[E0277]: the trait bound `(): WhereTrait` is not satisfied + --> $DIR/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs:16:10 + | +LL | Map2(<() as WhereTrait>::Type), + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `WhereTrait` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs:1:1 + | +LL | trait WhereTrait { + | ^^^^^^^^^^^^^^^^ + +error[E0004]: non-exhaustive patterns: `Enum::Map2(_)` not covered + --> $DIR/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs:8:11 + | +LL | match e { + | ^ pattern `Enum::Map2(_)` not covered + | +note: `Enum` defined here + --> $DIR/missing-ctor-with-ill-formed-inner-ty-issue-148192.rs:14:6 + | +LL | enum Enum { + | ^^^^ +LL | Map(()), +LL | Map2(<() as WhereTrait>::Type), + | ---- not covered + = note: the matched value is of type `Enum` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Enum::Map(_) => (), +LL ~ Enum::Map2(_) => todo!(), + | + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0004, E0277. +For more information about an error, try `rustc --explain E0004`. From 554a6396d87d31406785a33989ff1abba001fac4 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Wed, 12 Nov 2025 10:08:16 -0700 Subject: [PATCH 102/108] Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 445fe4a68f46..2d4fa139552e 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 445fe4a68f469bf936b2fd81de2c503b233a7f4f +Subproject commit 2d4fa139552ebdd5f091a1401ed03f7dc62cb43f From c09185c8ac15628602b2f0d81a8bc0ce32bd544f Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Wed, 12 Nov 2025 21:39:58 +0200 Subject: [PATCH 103/108] Remove explicit install of `eslint` inside of `tidy`'s Dockerfile `tidy` will already install it (when needed) due to it being in `package.json` --- src/ci/docker/host-x86_64/tidy/Dockerfile | 5 ----- src/ci/docker/host-x86_64/tidy/eslint.version | 1 - 2 files changed, 6 deletions(-) delete mode 100644 src/ci/docker/host-x86_64/tidy/eslint.version diff --git a/src/ci/docker/host-x86_64/tidy/Dockerfile b/src/ci/docker/host-x86_64/tidy/Dockerfile index 2dda51b155e9..133192e8ac21 100644 --- a/src/ci/docker/host-x86_64/tidy/Dockerfile +++ b/src/ci/docker/host-x86_64/tidy/Dockerfile @@ -28,9 +28,6 @@ COPY scripts/nodejs.sh /scripts/ RUN sh /scripts/nodejs.sh /node ENV PATH="/node/bin:${PATH}" -# Install eslint -COPY host-x86_64/tidy/eslint.version /tmp/ - COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh @@ -40,8 +37,6 @@ RUN pip3 install --no-deps --no-cache-dir --require-hashes -r /tmp/reuse-require COPY host-x86_64/pr-check-1/validate-toolstate.sh /scripts/ -RUN bash -c 'npm install -g eslint@$(cat /tmp/eslint.version)' - # NOTE: intentionally uses python2 for x.py so we can test it still works. # validate-toolstate only runs in our CI, so it's ok for it to only support python3. ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \ diff --git a/src/ci/docker/host-x86_64/tidy/eslint.version b/src/ci/docker/host-x86_64/tidy/eslint.version deleted file mode 100644 index 42890ac0095a..000000000000 --- a/src/ci/docker/host-x86_64/tidy/eslint.version +++ /dev/null @@ -1 +0,0 @@ -8.57.1 From b1e8d562dbe947b3814ec315569a8f466fee1677 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Wed, 12 Nov 2025 16:56:21 -0500 Subject: [PATCH 104/108] bootstrap: dont require cmake if local-rebuild is enabled This is for people rebuilding stdlib directly from stage 0 with the full toolchain from rust-src rustup component. The toolchain itself should have sufficient LLVM tools, so CMake and LLVM are not required when `build.local-rebuild = true` --- src/bootstrap/src/core/sanity.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index e5afb31213ce..78cd7ab2539f 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -142,6 +142,7 @@ pub fn check(build: &mut Build) { // We need cmake, but only if we're actually building LLVM or sanitizers. let building_llvm = !build.config.llvm_from_ci + && !build.config.local_rebuild && build.hosts.iter().any(|host| { build.config.llvm_enabled(*host) && build From e921e28c7a86bb36f3f6167e4eddcd0628418f1c Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Thu, 13 Nov 2025 10:14:24 +0200 Subject: [PATCH 105/108] Upgrade `stringdex` to 0.0.3 --- Cargo.lock | 10 +-- src/librustdoc/Cargo.toml | 2 +- src/librustdoc/html/render/search_index.rs | 85 ++++++++++++---------- 3 files changed, 53 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c095e0eefa8..306dddfe37f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1289,7 +1289,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.60.2", ] [[package]] @@ -2155,7 +2155,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.53.3", ] [[package]] @@ -4907,7 +4907,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -5275,9 +5275,9 @@ dependencies = [ [[package]] name = "stringdex" -version = "0.0.2" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18b3bd4f10d15ef859c40291769f0d85209de6b0f1c30713ff9cdf45ac43ea36" +checksum = "556a6126952cb2f5150057c98a77cc6c771027dea2825bf7fa03d3d638b0a4f8" dependencies = [ "stacker", ] diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index e1408bb7e5bc..9b8bc2d2a04e 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -21,7 +21,7 @@ rustdoc-json-types = { path = "../rustdoc-json-types" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" smallvec = "1.8.1" -stringdex = "=0.0.2" +stringdex = "=0.0.3" tempfile = "3" threadpool = "1.8.1" tikv-jemalloc-sys = { version = "0.6.1", optional = true, features = ['override_allocator_on_supported_platforms'] } diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 9c072eed51ae..3514c517d913 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -3,7 +3,9 @@ mod serde; use std::collections::BTreeSet; use std::collections::hash_map::Entry; +use std::io; use std::path::Path; +use std::string::FromUtf8Error; use ::serde::de::{self, Deserializer, Error as _}; use ::serde::ser::{SerializeSeq, Serializer}; @@ -95,21 +97,22 @@ impl SerializedSearchIndex { ) -> Result<(), Error> { let root_path = doc_root.join(format!("search.index/root{resource_suffix}.js")); let column_path = doc_root.join(format!("search.index/{column_name}/")); + + let mut consume = |_, cell: &[u8]| { + column.push(String::from_utf8(cell.to_vec())?); + Ok::<_, FromUtf8Error>(()) + }; + stringdex_internals::read_data_from_disk_column( root_path, column_name.as_bytes(), column_path.clone(), - &mut |_id, item| { - column.push(String::from_utf8(item.to_vec())?); - Ok(()) - }, - ) - .map_err( - |error: stringdex_internals::ReadDataError>| Error { - file: column_path, - error: format!("failed to read column from disk: {error}"), - }, + &mut consume, ) + .map_err(|error| Error { + file: column_path, + error: format!("failed to read column from disk: {error}"), + }) } fn perform_read_serde( resource_suffix: &str, @@ -119,25 +122,26 @@ impl SerializedSearchIndex { ) -> Result<(), Error> { let root_path = doc_root.join(format!("search.index/root{resource_suffix}.js")); let column_path = doc_root.join(format!("search.index/{column_name}/")); + + let mut consume = |_, cell: &[u8]| { + if cell.is_empty() { + column.push(None); + } else { + column.push(Some(serde_json::from_slice(cell)?)); + } + Ok::<_, serde_json::Error>(()) + }; + stringdex_internals::read_data_from_disk_column( root_path, column_name.as_bytes(), column_path.clone(), - &mut |_id, item| { - if item.is_empty() { - column.push(None); - } else { - column.push(Some(serde_json::from_slice(item)?)); - } - Ok(()) - }, - ) - .map_err( - |error: stringdex_internals::ReadDataError>| Error { - file: column_path, - error: format!("failed to read column from disk: {error}"), - }, + &mut consume, ) + .map_err(|error| Error { + file: column_path, + error: format!("failed to read column from disk: {error}"), + }) } fn perform_read_postings( resource_suffix: &str, @@ -147,23 +151,28 @@ impl SerializedSearchIndex { ) -> Result<(), Error> { let root_path = doc_root.join(format!("search.index/root{resource_suffix}.js")); let column_path = doc_root.join(format!("search.index/{column_name}/")); + + fn consumer( + column: &mut Vec>>, + ) -> impl FnMut(u32, &[u8]) -> io::Result<()> { + |_, cell| { + let mut postings = Vec::new(); + encode::read_postings_from_string(&mut postings, cell); + column.push(postings); + Ok(()) + } + } + stringdex_internals::read_data_from_disk_column( root_path, column_name.as_bytes(), column_path.clone(), - &mut |_id, buf| { - let mut postings = Vec::new(); - encode::read_postings_from_string(&mut postings, buf); - column.push(postings); - Ok(()) - }, - ) - .map_err( - |error: stringdex_internals::ReadDataError>| Error { - file: column_path, - error: format!("failed to read column from disk: {error}"), - }, + &mut consumer(column), ) + .map_err(|error| Error { + file: column_path, + error: format!("failed to read column from disk: {error}"), + }) } assert_eq!(names.len(), path_data.len()); @@ -1055,12 +1064,12 @@ impl Serialize for TypeData { let mut buf = Vec::new(); encode::write_postings_to_string(&self.inverted_function_inputs_index, &mut buf); let mut serialized_result = Vec::new(); - stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result); + stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result).unwrap(); seq.serialize_element(&str::from_utf8(&serialized_result).unwrap())?; buf.clear(); serialized_result.clear(); encode::write_postings_to_string(&self.inverted_function_output_index, &mut buf); - stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result); + stringdex_internals::encode::write_base64_to_bytes(&buf, &mut serialized_result).unwrap(); seq.serialize_element(&str::from_utf8(&serialized_result).unwrap())?; if self.search_unbox { seq.serialize_element(&1)?; From ccd87959edaa1e851d58f0b342e7e679039de898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 13 Nov 2025 10:29:26 +0100 Subject: [PATCH 106/108] Revert "Rollup merge of #146627 - madsmtm:jemalloc-simplify, r=jdonszelmann" This reverts commit 5dc3c19417d0fbfd979c5a1ecd8bebe2d8d9110e, reversing changes made to 11339a0ef5ed586bb7ea4f85a9b7287880caac3a. --- Cargo.lock | 6 ++-- compiler/rustc/Cargo.toml | 4 +-- compiler/rustc/src/main.rs | 63 ++++++++++++++++++++++++++-------- src/librustdoc/Cargo.toml | 3 +- src/librustdoc/lib.rs | 40 ++++++++++++++++++--- src/tools/clippy/Cargo.toml | 3 +- src/tools/clippy/src/driver.rs | 36 +++++++++++++++++-- src/tools/miri/Cargo.toml | 4 +-- src/tools/miri/src/bin/miri.rs | 46 ++++++++++++++++++++++--- 9 files changed, 167 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c095e0eefa8..d2b96e6d1027 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -600,7 +600,6 @@ dependencies = [ "serde_json", "tempfile", "termize", - "tikv-jemalloc-sys", "toml 0.9.7", "ui_test", "walkdir", @@ -4807,7 +4806,6 @@ dependencies = [ "stringdex", "tempfile", "threadpool", - "tikv-jemalloc-sys", "tracing", "tracing-subscriber", "tracing-tree", @@ -5539,9 +5537,9 @@ version = "0.1.0" [[package]] name = "tikv-jemalloc-sys" -version = "0.6.1+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" +version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8aa5b2ab86a2cefa406d889139c162cbb230092f7d1d7cbc1716405d852a3b" +checksum = "cd3c60906412afa9c2b5b5a48ca6a5abe5736aec9eb48ad05037a677e52e4e2d" dependencies = [ "cc", "libc", diff --git a/compiler/rustc/Cargo.toml b/compiler/rustc/Cargo.toml index d2ab70895eb3..9ef8fa75062a 100644 --- a/compiler/rustc/Cargo.toml +++ b/compiler/rustc/Cargo.toml @@ -21,9 +21,9 @@ rustc_public_bridge = { path = "../rustc_public_bridge" } # tidy-alphabetical-end [dependencies.tikv-jemalloc-sys] -version = "0.6.1" +version = "0.6.0" optional = true -features = ['override_allocator_on_supported_platforms'] +features = ['unprefixed_malloc_on_supported_platforms'] [features] # tidy-alphabetical-start diff --git a/compiler/rustc/src/main.rs b/compiler/rustc/src/main.rs index 89c61cdf00a5..ca1bb59e59d6 100644 --- a/compiler/rustc/src/main.rs +++ b/compiler/rustc/src/main.rs @@ -7,25 +7,26 @@ // distribution. The obvious way to do this is with the `#[global_allocator]` // mechanism. However, for complicated reasons (see // https://github.com/rust-lang/rust/pull/81782#issuecomment-784438001 for some -// details) that mechanism doesn't work here. Also, we'd like to use a -// consistent allocator across the rustc <-> llvm boundary, and -// `#[global_allocator]` wouldn't provide that. +// details) that mechanism doesn't work here. Also, we must use a consistent +// allocator across the rustc <-> llvm boundary, and `#[global_allocator]` +// wouldn't provide that. // -// Instead, we use a lower-level mechanism, namely the -// `"override_allocator_on_supported_platforms"` Cargo feature of jemalloc-sys. -// -// This makes jemalloc-sys override the libc/system allocator's implementation -// of `malloc`, `free`, etc.. This means that Rust's `System` allocator, which -// calls `libc::malloc()` et al., is actually calling into jemalloc. +// Instead, we use a lower-level mechanism. rustc is linked with jemalloc in a +// way such that jemalloc's implementation of `malloc`, `free`, etc., override +// the libc allocator's implementation. This means that Rust's `System` +// allocator, which calls `libc::malloc()` et al., is actually calling into +// jemalloc. // // A consequence of not using `GlobalAlloc` (and the `tikv-jemallocator` crate // provides an impl of that trait, which is called `Jemalloc`) is that we // cannot use the sized deallocation APIs (`sdallocx`) that jemalloc provides. // It's unclear how much performance is lost because of this. // -// NOTE: Even though Cargo passes `--extern` with `tikv_jemalloc_sys`, we still need to `use` the -// crate for the compiler to see the `#[used]`, see https://github.com/rust-lang/rust/issues/64402. -// This is similarly required if we used a crate with `#[global_allocator]`. +// As for the symbol overrides in `main` below: we're pulling in a static copy +// of jemalloc. We need to actually reference its symbols for it to get linked. +// The two crates we link to here, `std` and `rustc_driver`, are both dynamic +// libraries. So we must reference jemalloc symbols one way or another, because +// this file is the only object code in the rustc executable. // // NOTE: if you are reading this comment because you want to set a custom `global_allocator` for // benchmarking, consider using the benchmarks in the `rustc-perf` collector suite instead: @@ -35,9 +36,43 @@ // to compare their performance, see // https://github.com/rust-lang/rust/commit/b90cfc887c31c3e7a9e6d462e2464db1fe506175#diff-43914724af6e464c1da2171e4a9b6c7e607d5bc1203fa95c0ab85be4122605ef // for an example of how to do so. -#[cfg(feature = "jemalloc")] -use tikv_jemalloc_sys as _; fn main() { + // See the comment at the top of this file for an explanation of this. + #[cfg(feature = "jemalloc")] + { + use std::os::raw::{c_int, c_void}; + + use tikv_jemalloc_sys as jemalloc_sys; + + #[used] + static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::calloc; + #[used] + static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int = + jemalloc_sys::posix_memalign; + #[used] + static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::aligned_alloc; + #[used] + static _F4: unsafe extern "C" fn(usize) -> *mut c_void = jemalloc_sys::malloc; + #[used] + static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc; + #[used] + static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free; + + // On OSX, jemalloc doesn't directly override malloc/free, but instead + // registers itself with the allocator's zone APIs in a ctor. However, + // the linker doesn't seem to consider ctors as "used" when statically + // linking, so we need to explicitly depend on the function. + #[cfg(target_os = "macos")] + { + unsafe extern "C" { + fn _rjem_je_zone_register(); + } + + #[used] + static _F7: unsafe extern "C" fn() = _rjem_je_zone_register; + } + } + rustc_driver::main() } diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index e1408bb7e5bc..63412e2b9373 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -24,7 +24,6 @@ smallvec = "1.8.1" stringdex = "=0.0.2" tempfile = "3" threadpool = "1.8.1" -tikv-jemalloc-sys = { version = "0.6.1", optional = true, features = ['override_allocator_on_supported_platforms'] } tracing = "0.1" tracing-tree = "0.3.0" unicode-segmentation = "1.9" @@ -43,7 +42,7 @@ minifier = { version = "0.3.2", default-features = false } expect-test = "1.4.0" [features] -jemalloc = ["dep:tikv-jemalloc-sys"] +jemalloc = [] [package.metadata.rust-analyzer] rustc_private = true diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 57db12d2cb5d..e88180c3033b 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -61,6 +61,11 @@ extern crate rustc_target; extern crate rustc_trait_selection; extern crate test; +// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs +// about jemalloc. +#[cfg(feature = "jemalloc")] +extern crate tikv_jemalloc_sys as jemalloc_sys; + use std::env::{self, VarError}; use std::io::{self, IsTerminal}; use std::path::Path; @@ -72,10 +77,6 @@ use rustc_interface::interface; use rustc_middle::ty::TyCtxt; use rustc_session::config::{ErrorOutputType, RustcOptGroup, make_crate_type_option}; use rustc_session::{EarlyDiagCtxt, getopts}; -/// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs -/// and https://github.com/rust-lang/rust/pull/146627 for why we need this `use` statement. -#[cfg(feature = "jemalloc")] -use tikv_jemalloc_sys as _; use tracing::info; use crate::clean::utils::DOC_RUST_LANG_ORG_VERSION; @@ -123,6 +124,37 @@ mod visit_ast; mod visit_lib; pub fn main() { + // See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs + // about jemalloc. + #[cfg(feature = "jemalloc")] + { + use std::os::raw::{c_int, c_void}; + + #[used] + static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::calloc; + #[used] + static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int = + jemalloc_sys::posix_memalign; + #[used] + static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::aligned_alloc; + #[used] + static _F4: unsafe extern "C" fn(usize) -> *mut c_void = jemalloc_sys::malloc; + #[used] + static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc; + #[used] + static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free; + + #[cfg(target_os = "macos")] + { + unsafe extern "C" { + fn _rjem_je_zone_register(); + } + + #[used] + static _F7: unsafe extern "C" fn() = _rjem_je_zone_register; + } + } + let mut early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default()); rustc_driver::install_ice_hook( diff --git a/src/tools/clippy/Cargo.toml b/src/tools/clippy/Cargo.toml index f0f9c05e4330..fee885d8fa7e 100644 --- a/src/tools/clippy/Cargo.toml +++ b/src/tools/clippy/Cargo.toml @@ -31,7 +31,6 @@ tempfile = { version = "3.20", optional = true } termize = "0.2" color-print = "0.3.4" anstream = "0.6.18" -tikv-jemalloc-sys = { version = "0.6.1", optional = true, features = ['override_allocator_on_supported_platforms'] } [dev-dependencies] cargo_metadata = "0.18.1" @@ -57,7 +56,7 @@ rustc_tools_util = { path = "rustc_tools_util", version = "0.4.2" } [features] integration = ["dep:tempfile"] internal = ["dep:clippy_lints_internal", "dep:tempfile"] -jemalloc = ["dep:tikv-jemalloc-sys"] +jemalloc = [] [package.metadata.rust-analyzer] # This package uses #[feature(rustc_private)] diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index a8db5dddf22f..abc706b7772f 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -13,10 +13,10 @@ extern crate rustc_interface; extern crate rustc_session; extern crate rustc_span; -/// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs -/// and https://github.com/rust-lang/rust/pull/146627 for why we need this `use` statement. +// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs +// about jemalloc. #[cfg(feature = "jemalloc")] -use tikv_jemalloc_sys as _; +extern crate tikv_jemalloc_sys as jemalloc_sys; use clippy_utils::sym; use declare_clippy_lint::LintListBuilder; @@ -189,6 +189,36 @@ const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/ne #[expect(clippy::too_many_lines)] pub fn main() { + // See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs + // about jemalloc. + #[cfg(feature = "jemalloc")] + { + use std::os::raw::{c_int, c_void}; + + #[used] + static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::calloc; + #[used] + static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int = jemalloc_sys::posix_memalign; + #[used] + static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::aligned_alloc; + #[used] + static _F4: unsafe extern "C" fn(usize) -> *mut c_void = jemalloc_sys::malloc; + #[used] + static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc; + #[used] + static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free; + + #[cfg(target_os = "macos")] + { + unsafe extern "C" { + fn _rjem_je_zone_register(); + } + + #[used] + static _F7: unsafe extern "C" fn() = _rjem_je_zone_register; + } + } + let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default()); rustc_driver::init_rustc_env_logger(&early_dcx); diff --git a/src/tools/miri/Cargo.toml b/src/tools/miri/Cargo.toml index 5341b3a48692..8bb4f1c16093 100644 --- a/src/tools/miri/Cargo.toml +++ b/src/tools/miri/Cargo.toml @@ -33,8 +33,8 @@ serde_json = { version = "1.0", optional = true } # But only for some targets, it fails for others. Rustc configures this in its CI, but we can't # easily use that since we support of-tree builds. [target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies.tikv-jemalloc-sys] -version = "0.6.1" -features = ['override_allocator_on_supported_platforms'] +version = "0.6.0" +features = ['unprefixed_malloc_on_supported_platforms'] [target.'cfg(unix)'.dependencies] libc = "0.2" diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index 8b4445e379a2..920fc2948191 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -20,11 +20,6 @@ extern crate rustc_middle; extern crate rustc_session; extern crate rustc_span; -/// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs -/// and https://github.com/rust-lang/rust/pull/146627 for why we need this `use` statement. -#[cfg(any(target_os = "linux", target_os = "macos"))] -use tikv_jemalloc_sys as _; - mod log; use std::env; @@ -397,7 +392,48 @@ fn parse_range(val: &str) -> Result, &'static str> { Ok(from..to) } +#[cfg(any(target_os = "linux", target_os = "macos"))] +fn jemalloc_magic() { + // These magic runes are copied from + // . + // See there for further comments. + use std::os::raw::{c_int, c_void}; + + use tikv_jemalloc_sys as jemalloc_sys; + + #[used] + static _F1: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::calloc; + #[used] + static _F2: unsafe extern "C" fn(*mut *mut c_void, usize, usize) -> c_int = + jemalloc_sys::posix_memalign; + #[used] + static _F3: unsafe extern "C" fn(usize, usize) -> *mut c_void = jemalloc_sys::aligned_alloc; + #[used] + static _F4: unsafe extern "C" fn(usize) -> *mut c_void = jemalloc_sys::malloc; + #[used] + static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc; + #[used] + static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free; + + // On OSX, jemalloc doesn't directly override malloc/free, but instead + // registers itself with the allocator's zone APIs in a ctor. However, + // the linker doesn't seem to consider ctors as "used" when statically + // linking, so we need to explicitly depend on the function. + #[cfg(target_os = "macos")] + { + unsafe extern "C" { + fn _rjem_je_zone_register(); + } + + #[used] + static _F7: unsafe extern "C" fn() = _rjem_je_zone_register; + } +} + fn main() { + #[cfg(any(target_os = "linux", target_os = "macos"))] + jemalloc_magic(); + let early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default()); // Snapshot a copy of the environment before `rustc` starts messing with it. From 866de5fdccc4bdc7ee0a44e763901d21ff1e426e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 13 Nov 2025 15:23:14 +0100 Subject: [PATCH 107/108] Ignore `tests/ui/lto/lto-global-allocator.rs` for GCC backend --- tests/ui/lto/lto-global-allocator.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui/lto/lto-global-allocator.rs b/tests/ui/lto/lto-global-allocator.rs index 03f11709c901..6e5ed9484756 100644 --- a/tests/ui/lto/lto-global-allocator.rs +++ b/tests/ui/lto/lto-global-allocator.rs @@ -2,6 +2,7 @@ //@ build-pass //@ no-prefer-dynamic //@ needs-crate-type: cdylib +//@ ignore-backends: gcc use std::alloc::{GlobalAlloc, Layout}; From b115de9fa5b608dd7ecfd9aeacdb081ce3e64e18 Mon Sep 17 00:00:00 2001 From: The Miri Cronjob Bot Date: Fri, 14 Nov 2025 04:53:31 +0000 Subject: [PATCH 108/108] Prepare for merging from rust-lang/rust This updates the rust-version file to 7a72c5459dd58f81b0e1a0e5436d145485889375. --- src/tools/miri/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index 7dde150d1e8b..06a597064624 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -0b329f801a09004dacb19aaf09d5cb8b4c51d3f8 +7a72c5459dd58f81b0e1a0e5436d145485889375