From 09097128c39ec7834ce3dac83753e3f6231b76bc Mon Sep 17 00:00:00 2001 From: joboet Date: Thu, 25 Sep 2025 17:48:08 +0200 Subject: [PATCH 001/194] alloc: fix `Debug` implementation of `ExtractIf` --- library/alloc/src/vec/extract_if.rs | 15 ++++++++++++++- library/alloctests/tests/vec.rs | 11 +++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/library/alloc/src/vec/extract_if.rs b/library/alloc/src/vec/extract_if.rs index a456d3d9e602..c0c006017536 100644 --- a/library/alloc/src/vec/extract_if.rs +++ b/library/alloc/src/vec/extract_if.rs @@ -115,7 +115,20 @@ impl fmt::Debug for ExtractIf<'_, T, F, A> A: Allocator, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let peek = if self.idx < self.end { self.vec.get(self.idx) } else { None }; + let peek = if self.idx < self.end { + // This has to use pointer arithmetic as `self.vec[self.idx]` or + // `self.vec.get_unchecked(self.idx)` wouldn't work since we + // temporarily set the length of `self.vec` to zero. + // + // SAFETY: + // Since `self.idx` is smaller than `self.end` and `self.end` is + // smaller than `self.old_len`, `idx` is valid for indexing the + // buffer. Also, per the invariant of `self.idx`, this element + // has not been inspected/moved out yet. + Some(unsafe { &*self.vec.as_ptr().add(self.idx) }) + } else { + None + }; f.debug_struct("ExtractIf").field("peek", &peek).finish_non_exhaustive() } } diff --git a/library/alloctests/tests/vec.rs b/library/alloctests/tests/vec.rs index 33a34daccbfd..ad5e3c5ecd44 100644 --- a/library/alloctests/tests/vec.rs +++ b/library/alloctests/tests/vec.rs @@ -1635,6 +1635,17 @@ fn extract_if_unconsumed() { assert_eq!(vec, [1, 2, 3, 4]); } +#[test] +fn extract_if_debug() { + let mut vec = vec![1, 2]; + let mut drain = vec.extract_if(.., |&mut x| x % 2 != 0); + assert!(format!("{drain:?}").contains("Some(1)")); + drain.next(); + assert!(format!("{drain:?}").contains("Some(2)")); + drain.next(); + assert!(format!("{drain:?}").contains("None")); +} + #[test] fn test_reserve_exact() { // This is all the same as test_reserve From 0d6a313e6e97cbb63e7ea2111d461ac0ac1aad3d Mon Sep 17 00:00:00 2001 From: LemonJ <1632798336@qq.com> Date: Tue, 23 Sep 2025 16:42:55 +0800 Subject: [PATCH 002/194] add doc for va_list APIs --- library/core/src/ffi/va_list.rs | 7 ++++--- library/core/src/intrinsics/mod.rs | 25 ++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/library/core/src/ffi/va_list.rs b/library/core/src/ffi/va_list.rs index 0d4ccb5aeb28..3d8ce6508bf3 100644 --- a/library/core/src/ffi/va_list.rs +++ b/library/core/src/ffi/va_list.rs @@ -243,10 +243,11 @@ impl<'f> VaListImpl<'f> { /// /// # Safety /// - /// This function is only sound to call when the next variable argument: + /// This function is only sound to call when: /// - /// - has a type that is ABI-compatible with the type `T` - /// - has a value that is a properly initialized value of type `T` + /// - there is a next variable argument available. + /// - the next argument's type must be ABI-compatible with the type `T`. + /// - the next argument must have a properly initialized value of type `T`. /// /// Calling this function with an incompatible type, an invalid value, or when there /// are no more variable arguments, is unsound. diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index a174ced5a2a6..af0356be2649 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -3295,7 +3295,13 @@ pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize /// Copies the current location of arglist `src` to the arglist `dst`. /// -/// FIXME: document safety requirements +/// # Safety +/// +/// You must check the following invariants before you call this function: +/// +/// - `dest` must be non-null and point to valid, writable memory. +/// - `dest` must not alias `src`. +/// #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn va_copy<'f>(dest: *mut VaListImpl<'f>, src: &VaListImpl<'f>); @@ -3303,14 +3309,27 @@ pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize /// Loads an argument of type `T` from the `va_list` `ap` and increment the /// argument `ap` points to. /// -/// FIXME: document safety requirements +/// # Safety +/// +/// This function is only sound to call when: +/// +/// - there is a next variable argument available. +/// - the next argument's type must be ABI-compatible with the type `T`. +/// - the next argument must have a properly initialized value of type `T`. +/// +/// Calling this function with an incompatible type, an invalid value, or when there +/// are no more variable arguments, is unsound. +/// #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn va_arg(ap: &mut VaListImpl<'_>) -> T; /// Destroy the arglist `ap` after initialization with `va_start` or `va_copy`. /// -/// FIXME: document safety requirements +/// # Safety +/// +/// `ap` must not be used to access variable arguments after this call. +/// #[rustc_intrinsic] #[rustc_nounwind] pub unsafe fn va_end(ap: &mut VaListImpl<'_>); From 261d7ebdc338e9586b9d8637108493ae230a0881 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 15 Oct 2025 20:43:53 +0200 Subject: [PATCH 003/194] stabilize `asm_cfg` --- compiler/rustc_builtin_macros/messages.ftl | 2 - compiler/rustc_builtin_macros/src/asm.rs | 18 ++---- compiler/rustc_feature/src/accepted.rs | 2 + compiler/rustc_feature/src/unstable.rs | 2 - .../compiler-builtins/src/lib.rs | 1 - tests/ui/asm/cfg-parse-error.rs | 1 - tests/ui/asm/cfg-parse-error.stderr | 10 ++-- tests/ui/asm/cfg.rs | 2 +- .../ui/feature-gates/feature-gate-asm_cfg.rs | 48 ---------------- .../feature-gates/feature-gate-asm_cfg.stderr | 57 ------------------- 10 files changed, 12 insertions(+), 131 deletions(-) delete mode 100644 tests/ui/feature-gates/feature-gate-asm_cfg.rs delete mode 100644 tests/ui/feature-gates/feature-gate-asm_cfg.stderr diff --git a/compiler/rustc_builtin_macros/messages.ftl b/compiler/rustc_builtin_macros/messages.ftl index cbdd8199d7ba..335613f87697 100644 --- a/compiler/rustc_builtin_macros/messages.ftl +++ b/compiler/rustc_builtin_macros/messages.ftl @@ -3,8 +3,6 @@ builtin_macros_alloc_must_statics = allocators must be statics builtin_macros_asm_attribute_not_supported = this attribute is not supported on assembly -builtin_macros_asm_cfg = - the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable builtin_macros_asm_clobber_abi = clobber_abi builtin_macros_asm_clobber_no_reg = asm with `clobber_abi` must specify explicit registers for outputs diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index 971b68d14757..2958686f86cd 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -6,14 +6,13 @@ use rustc_index::bit_set::GrowableBitSet; use rustc_parse::parser::asm::*; use rustc_session::lint; -use rustc_session::parse::feature_err; use rustc_span::{ErrorGuaranteed, InnerSpan, Span, Symbol, sym}; use rustc_target::asm::InlineAsmArch; use smallvec::smallvec; use {rustc_ast as ast, rustc_parse_format as parse}; +use crate::errors; use crate::util::{ExprToSpannedString, expr_to_spanned_string}; -use crate::{errors, fluent_generated as fluent}; /// Validated assembly arguments, ready for macro expansion. struct ValidatedAsmArgs { @@ -64,22 +63,13 @@ fn validate_asm_args<'a>( for arg in args { for attr in arg.attributes.0.iter() { - match attr.name() { - Some(sym::cfg | sym::cfg_attr) => { - if !ecx.ecfg.features.asm_cfg() { - let span = attr.span(); - feature_err(ecx.sess, sym::asm_cfg, span, fluent::builtin_macros_asm_cfg) - .emit(); - } - } - _ => { - ecx.dcx().emit_err(errors::AsmAttributeNotSupported { span: attr.span() }); - } + if !matches!(attr.name(), Some(sym::cfg | sym::cfg_attr)) { + ecx.dcx().emit_err(errors::AsmAttributeNotSupported { span: attr.span() }); } } // Skip arguments that are configured out. - if ecx.ecfg.features.asm_cfg() && strip_unconfigured.configure(arg.attributes).is_none() { + if strip_unconfigured.configure(arg.attributes).is_none() { continue; } diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 364a1202b05c..a17ba6ca6326 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -60,6 +60,8 @@ macro_rules! declare_features { (accepted, adx_target_feature, "1.61.0", Some(44839)), /// Allows explicit discriminants on non-unit enum variants. (accepted, arbitrary_enum_discriminant, "1.66.0", Some(60553)), + /// Allows #[cfg(...)] on inline assembly templates and operands. + (accepted, asm_cfg, "CURRENT_RUSTC_VERSION", Some(140364)), /// Allows using `const` operands in inline assembly. (accepted, asm_const, "1.82.0", Some(93332)), /// Allows using `label` operands in inline assembly. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 8397cd294e0a..d0ecc0061edc 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -382,8 +382,6 @@ pub fn internal(&self, feature: Symbol) -> bool { (unstable, arbitrary_self_types, "1.23.0", Some(44874)), /// Allows inherent and trait methods with arbitrary self types that are raw pointers. (unstable, arbitrary_self_types_pointers, "1.83.0", Some(44874)), - /// Allows #[cfg(...)] on inline assembly templates and operands. - (unstable, asm_cfg, "1.89.0", Some(140364)), /// Enables experimental inline assembly support for additional architectures. (unstable, asm_experimental_arch, "1.58.0", Some(93335)), /// Enables experimental register support in inline assembly. diff --git a/library/compiler-builtins/compiler-builtins/src/lib.rs b/library/compiler-builtins/compiler-builtins/src/lib.rs index b111dc0bd18f..a9dd6e531c5d 100644 --- a/library/compiler-builtins/compiler-builtins/src/lib.rs +++ b/library/compiler-builtins/compiler-builtins/src/lib.rs @@ -7,7 +7,6 @@ #![feature(compiler_builtins)] #![feature(core_intrinsics)] #![feature(linkage)] -#![feature(asm_cfg)] #![feature(naked_functions)] #![feature(repr_simd)] #![feature(macro_metavar_expr_concat)] diff --git a/tests/ui/asm/cfg-parse-error.rs b/tests/ui/asm/cfg-parse-error.rs index 9b79d16a76dd..0c6b63872a43 100644 --- a/tests/ui/asm/cfg-parse-error.rs +++ b/tests/ui/asm/cfg-parse-error.rs @@ -1,5 +1,4 @@ //@ needs-asm-support -#![feature(asm_cfg)] use std::arch::asm; diff --git a/tests/ui/asm/cfg-parse-error.stderr b/tests/ui/asm/cfg-parse-error.stderr index 8a70d39a43dc..726dee271108 100644 --- a/tests/ui/asm/cfg-parse-error.stderr +++ b/tests/ui/asm/cfg-parse-error.stderr @@ -1,5 +1,5 @@ error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` - --> $DIR/cfg-parse-error.rs:16:13 + --> $DIR/cfg-parse-error.rs:15:13 | LL | a = out(reg) x, | - expected one of 11 possible tokens @@ -7,7 +7,7 @@ LL | "", | ^^ unexpected token error: expected one of `#`, `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `label`, `lateout`, `options`, `out`, or `sym`, found `""` - --> $DIR/cfg-parse-error.rs:26:13 + --> $DIR/cfg-parse-error.rs:25:13 | LL | }, | - expected one of 11 possible tokens @@ -15,19 +15,19 @@ LL | "", | ^^ unexpected token error: expected token: `,` - --> $DIR/cfg-parse-error.rs:41:26 + --> $DIR/cfg-parse-error.rs:40:26 | LL | a = out(reg) x, | ^ expected `,` error: this attribute is not supported on assembly - --> $DIR/cfg-parse-error.rs:47:13 + --> $DIR/cfg-parse-error.rs:46:13 | LL | #[rustfmt::skip] | ^^^^^^^^^^^^^^^^ error: an inner attribute is not permitted in this context - --> $DIR/cfg-parse-error.rs:53:13 + --> $DIR/cfg-parse-error.rs:52:13 | LL | #![rustfmt::skip] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/asm/cfg.rs b/tests/ui/asm/cfg.rs index bcf86340b9d8..90b1b3d6ee65 100644 --- a/tests/ui/asm/cfg.rs +++ b/tests/ui/asm/cfg.rs @@ -3,7 +3,7 @@ //@ revisions: reva revb //@ only-x86_64 //@ run-pass -#![feature(asm_cfg, cfg_select)] +#![feature(cfg_select)] use std::arch::{asm, naked_asm}; diff --git a/tests/ui/feature-gates/feature-gate-asm_cfg.rs b/tests/ui/feature-gates/feature-gate-asm_cfg.rs deleted file mode 100644 index ef8bf75b6929..000000000000 --- a/tests/ui/feature-gates/feature-gate-asm_cfg.rs +++ /dev/null @@ -1,48 +0,0 @@ -//@ only-x86_64 -#![crate_type = "lib"] - -use std::arch::{asm, global_asm, naked_asm}; - -global_asm!( - "nop", - #[cfg(false)] - //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - "nop" -); - -#[unsafe(naked)] -#[no_mangle] -extern "C" fn naked() { - naked_asm!( - "mov rax, 5", - #[cfg(false)] - //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - "mov rax, {a}", - "ret", - #[cfg(false)] - //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - a = const 10, - ) -} - -fn asm() { - unsafe { - asm!( - "nop", - #[cfg(false)] - //~^ ERROR the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - clobber_abi("C"), - clobber_abi("C"), //~ ERROR `C` ABI specified multiple times - ); - } -} - -fn bad_attribute() { - unsafe { - asm!( - #[inline] - //~^ ERROR this attribute is not supported on assembly - "nop" - ) - }; -} diff --git a/tests/ui/feature-gates/feature-gate-asm_cfg.stderr b/tests/ui/feature-gates/feature-gate-asm_cfg.stderr deleted file mode 100644 index e92d1e8c4874..000000000000 --- a/tests/ui/feature-gates/feature-gate-asm_cfg.stderr +++ /dev/null @@ -1,57 +0,0 @@ -error[E0658]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - --> $DIR/feature-gate-asm_cfg.rs:8:5 - | -LL | #[cfg(false)] - | ^^^^^^^^^^^^^ - | - = note: see issue #140364 for more information - = help: add `#![feature(asm_cfg)]` 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[E0658]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - --> $DIR/feature-gate-asm_cfg.rs:18:9 - | -LL | #[cfg(false)] - | ^^^^^^^^^^^^^ - | - = note: see issue #140364 for more information - = help: add `#![feature(asm_cfg)]` 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[E0658]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - --> $DIR/feature-gate-asm_cfg.rs:22:9 - | -LL | #[cfg(false)] - | ^^^^^^^^^^^^^ - | - = note: see issue #140364 for more information - = help: add `#![feature(asm_cfg)]` 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[E0658]: the `#[cfg(/* ... */)]` and `#[cfg_attr(/* ... */)]` attributes on assembly are unstable - --> $DIR/feature-gate-asm_cfg.rs:32:13 - | -LL | #[cfg(false)] - | ^^^^^^^^^^^^^ - | - = note: see issue #140364 for more information - = help: add `#![feature(asm_cfg)]` 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: this attribute is not supported on assembly - --> $DIR/feature-gate-asm_cfg.rs:43:13 - | -LL | #[inline] - | ^^^^^^^^^ - -error: `C` ABI specified multiple times - --> $DIR/feature-gate-asm_cfg.rs:35:13 - | -LL | clobber_abi("C"), - | ---------------- previously specified here -LL | clobber_abi("C"), - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0658`. From d2a2fd3c4b38356e69248b49f4a51a9400e508e1 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sun, 26 Oct 2025 16:38:46 +0100 Subject: [PATCH 004/194] forward `TEST_SAMPLE_INTRINSICS_PERCENTAGE` --- library/stdarch/ci/intrinsic-test-docker.sh | 1 + library/stdarch/ci/intrinsic-test.sh | 9 +++++++-- .../crates/intrinsic-test/src/arm/mod.rs | 8 ++++++-- .../crates/intrinsic-test/src/common/compare.rs | 6 +++++- .../crates/intrinsic-test/src/x86/mod.rs | 17 ++++++++--------- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/library/stdarch/ci/intrinsic-test-docker.sh b/library/stdarch/ci/intrinsic-test-docker.sh index 038fc4678ed2..f62d7e484f5b 100755 --- a/library/stdarch/ci/intrinsic-test-docker.sh +++ b/library/stdarch/ci/intrinsic-test-docker.sh @@ -36,6 +36,7 @@ run() { --env NORUN \ --env RUSTFLAGS \ --env CARGO_UNSTABLE_BUILD_STD \ + --env TEST_SAMPLE_INTRINSICS_PERCENTAGE \ --volume "${HOME}/.cargo":/cargo \ --volume "$(rustc --print sysroot)":/rust:ro \ --volume "$(pwd)":/checkout:ro \ diff --git a/library/stdarch/ci/intrinsic-test.sh b/library/stdarch/ci/intrinsic-test.sh index e14a824b2ae6..be309f9e42f3 100755 --- a/library/stdarch/ci/intrinsic-test.sh +++ b/library/stdarch/ci/intrinsic-test.sh @@ -51,6 +51,7 @@ case ${TARGET} in TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt TEST_CXX_COMPILER="clang++" TEST_RUNNER="${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER}" + : "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=100}" ;; aarch64_be-unknown-linux-gnu*) @@ -58,6 +59,7 @@ case ${TARGET} in TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_aarch64.txt TEST_CXX_COMPILER="clang++" TEST_RUNNER="${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER}" + : "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=100}" ;; armv7-unknown-linux-gnueabihf*) @@ -65,6 +67,7 @@ case ${TARGET} in TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_arm.txt TEST_CXX_COMPILER="clang++" TEST_RUNNER="${CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER}" + : "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=100}" ;; x86_64-unknown-linux-gnu*) @@ -72,7 +75,7 @@ case ${TARGET} in TEST_CXX_COMPILER="clang++" TEST_RUNNER="${CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER}" TEST_SKIP_INTRINSICS=crates/intrinsic-test/missing_x86.txt - TEST_SAMPLE_INTRINSICS_PERCENTAGE=5 + : "${TEST_SAMPLE_INTRINSICS_PERCENTAGE:=5}" ;; *) ;; @@ -88,7 +91,8 @@ case "${TARGET}" in --runner "${TEST_RUNNER}" \ --cppcompiler "${TEST_CXX_COMPILER}" \ --skip "${TEST_SKIP_INTRINSICS}" \ - --target "${TARGET}" + --target "${TARGET}" \ + --sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}" ;; aarch64_be-unknown-linux-gnu*) @@ -99,6 +103,7 @@ case "${TARGET}" in --cppcompiler "${TEST_CXX_COMPILER}" \ --skip "${TEST_SKIP_INTRINSICS}" \ --target "${TARGET}" \ + --sample-percentage "${TEST_SAMPLE_INTRINSICS_PERCENTAGE}" \ --linker "${CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER}" \ --cxx-toolchain-dir "${AARCH64_BE_TOOLCHAIN}" ;; diff --git a/library/stdarch/crates/intrinsic-test/src/arm/mod.rs b/library/stdarch/crates/intrinsic-test/src/arm/mod.rs index 7fa5062e8652..99c8da854c50 100644 --- a/library/stdarch/crates/intrinsic-test/src/arm/mod.rs +++ b/library/stdarch/crates/intrinsic-test/src/arm/mod.rs @@ -48,8 +48,12 @@ fn create(cli_options: ProcessedCli) -> Self { .expect("Error parsing input file"); intrinsics.sort_by(|a, b| a.name.cmp(&b.name)); + intrinsics.dedup(); - let mut intrinsics = intrinsics + let sample_percentage: usize = cli_options.sample_percentage as usize; + let sample_size = (intrinsics.len() * sample_percentage) / 100; + + let intrinsics = intrinsics .into_iter() // Not sure how we would compare intrinsic that returns void. .filter(|i| i.results.kind() != TypeKind::Void) @@ -61,8 +65,8 @@ fn create(cli_options: ProcessedCli) -> Self { .filter(|i| !i.arguments.iter().any(|a| a.ty.inner_size() == 128)) .filter(|i| !cli_options.skip.contains(&i.name)) .filter(|i| !(a32 && i.arch_tags == vec!["A64".to_string()])) + .take(sample_size) .collect::>(); - intrinsics.dedup(); Self { intrinsics, diff --git a/library/stdarch/crates/intrinsic-test/src/common/compare.rs b/library/stdarch/crates/intrinsic-test/src/common/compare.rs index 902df94283fd..c0459b743a7f 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/compare.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/compare.rs @@ -86,6 +86,10 @@ pub fn compare_outputs(intrinsic_name_list: &Vec, runner: &str, target: println!("Failed to run rust program for intrinsic {intrinsic}") } }); - println!("{} differences found", intrinsics.len()); + println!( + "{} differences found (tested {} intrinsics)", + intrinsics.len(), + intrinsic_name_list.len() + ); intrinsics.is_empty() } diff --git a/library/stdarch/crates/intrinsic-test/src/x86/mod.rs b/library/stdarch/crates/intrinsic-test/src/x86/mod.rs index 956e51836f3f..4adf85017bc1 100644 --- a/library/stdarch/crates/intrinsic-test/src/x86/mod.rs +++ b/library/stdarch/crates/intrinsic-test/src/x86/mod.rs @@ -11,7 +11,6 @@ use crate::common::intrinsic::Intrinsic; use crate::common::intrinsic_helpers::TypeKind; use intrinsic::X86IntrinsicType; -use itertools::Itertools; use xml_parser::get_xml_intrinsics; pub struct X86ArchitectureTest { @@ -44,12 +43,16 @@ fn cpp_compilation(&self) -> Option { const PLATFORM_RUST_CFGS: &str = config::PLATFORM_RUST_CFGS; fn create(cli_options: ProcessedCli) -> Self { - let intrinsics = + let mut intrinsics = get_xml_intrinsics(&cli_options.filename).expect("Error parsing input file"); - let sample_percentage: usize = cli_options.sample_percentage as usize; + intrinsics.sort_by(|a, b| a.name.cmp(&b.name)); + intrinsics.dedup(); - let mut intrinsics = intrinsics + let sample_percentage: usize = cli_options.sample_percentage as usize; + let sample_size = (intrinsics.len() * sample_percentage) / 100; + + let intrinsics = intrinsics .into_iter() // Not sure how we would compare intrinsic that returns void. .filter(|i| i.results.kind() != TypeKind::Void) @@ -61,13 +64,9 @@ fn create(cli_options: ProcessedCli) -> Self { .filter(|i| !i.arguments.iter().any(|a| a.is_ptr())) .filter(|i| !i.arguments.iter().any(|a| a.ty.inner_size() == 128)) .filter(|i| !cli_options.skip.contains(&i.name)) - .unique_by(|i| i.name.clone()) + .take(sample_size) .collect::>(); - let sample_size = (intrinsics.len() * sample_percentage) / 100; - intrinsics.truncate(sample_size); - - intrinsics.sort_by(|a, b| a.name.cmp(&b.name)); Self { intrinsics: intrinsics, cli_options: cli_options, From d6180854223f4acd5318f52ab523293e7014f40d Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sun, 26 Oct 2025 19:28:46 +0100 Subject: [PATCH 005/194] intrinsic-test: display more logs in CI --- library/stdarch/ci/intrinsic-test.sh | 6 +++--- .../stdarch/crates/intrinsic-test/src/common/mod.rs | 12 ++++++++---- library/stdarch/crates/intrinsic-test/src/main.rs | 2 +- library/stdarch/crates/intrinsic-test/src/x86/mod.rs | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/library/stdarch/ci/intrinsic-test.sh b/library/stdarch/ci/intrinsic-test.sh index be309f9e42f3..be63f0c0c617 100755 --- a/library/stdarch/ci/intrinsic-test.sh +++ b/library/stdarch/ci/intrinsic-test.sh @@ -85,7 +85,7 @@ esac # Arm specific case "${TARGET}" in aarch64-unknown-linux-gnu*|armv7-unknown-linux-gnueabihf*) - CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \ + CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=info \ cargo run "${INTRINSIC_TEST}" "${PROFILE}" \ --bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \ --runner "${TEST_RUNNER}" \ @@ -96,7 +96,7 @@ case "${TARGET}" in ;; aarch64_be-unknown-linux-gnu*) - CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=warn \ + CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" RUST_LOG=info \ cargo run "${INTRINSIC_TEST}" "${PROFILE}" \ --bin intrinsic-test -- intrinsics_data/arm_intrinsics.json \ --runner "${TEST_RUNNER}" \ @@ -114,7 +114,7 @@ case "${TARGET}" in # Hence the use of `env -u`. env -u CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER \ CPPFLAGS="${TEST_CPPFLAGS}" RUSTFLAGS="${HOST_RUSTFLAGS}" \ - RUST_LOG=warn RUST_BACKTRACE=1 \ + RUST_LOG=info RUST_BACKTRACE=1 \ cargo run "${INTRINSIC_TEST}" "${PROFILE}" \ --bin intrinsic-test -- intrinsics_data/x86-intel.xml \ --runner "${TEST_RUNNER}" \ diff --git a/library/stdarch/crates/intrinsic-test/src/common/mod.rs b/library/stdarch/crates/intrinsic-test/src/common/mod.rs index d8f06ae23885..8b6bd943a742 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/mod.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/mod.rs @@ -79,12 +79,16 @@ fn build_c_file(&self) -> bool { trace!("compiling mod_{i}.cpp"); if let Some(cpp_compiler) = cpp_compiler_wrapped.as_ref() { let compile_output = cpp_compiler - .compile_object_file(&format!("mod_{i}.cpp"), &format!("mod_{i}.o")); + .compile_object_file(&format!("mod_{i}.cpp"), &format!("mod_{i}.o")) + .map_err(|e| format!("Error compiling mod_{i}.cpp: {e:?}"))?; + + assert!( + compile_output.status.success(), + "{}", + String::from_utf8_lossy(&compile_output.stderr) + ); trace!("finished compiling mod_{i}.cpp"); - if let Err(compile_error) = compile_output { - return Err(format!("Error compiling mod_{i}.cpp: {compile_error:?}")); - } } Ok(()) }) diff --git a/library/stdarch/crates/intrinsic-test/src/main.rs b/library/stdarch/crates/intrinsic-test/src/main.rs index ed3a50067dc4..3580d80bd112 100644 --- a/library/stdarch/crates/intrinsic-test/src/main.rs +++ b/library/stdarch/crates/intrinsic-test/src/main.rs @@ -34,7 +34,7 @@ fn run(test_environment: impl SupportedArchitectureTest) { if !test_environment.build_rust_file() { std::process::exit(3); } - info!("comaparing outputs"); + info!("comparing outputs"); if !test_environment.compare_outputs() { std::process::exit(1); } diff --git a/library/stdarch/crates/intrinsic-test/src/x86/mod.rs b/library/stdarch/crates/intrinsic-test/src/x86/mod.rs index 4adf85017bc1..f2baf070714c 100644 --- a/library/stdarch/crates/intrinsic-test/src/x86/mod.rs +++ b/library/stdarch/crates/intrinsic-test/src/x86/mod.rs @@ -47,7 +47,7 @@ fn create(cli_options: ProcessedCli) -> Self { get_xml_intrinsics(&cli_options.filename).expect("Error parsing input file"); intrinsics.sort_by(|a, b| a.name.cmp(&b.name)); - intrinsics.dedup(); + intrinsics.dedup_by(|a, b| a.name == b.name); let sample_percentage: usize = cli_options.sample_percentage as usize; let sample_size = (intrinsics.len() * sample_percentage) / 100; From 24be917c03eb8e6702415266a07cb35aa8946be7 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 27 Oct 2025 14:47:37 -0700 Subject: [PATCH 006/194] rustdoc: add mergeable CCI docs to the unstable feature book --- src/doc/rustdoc/src/unstable-features.md | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 04d3c0cd630f..73986199661f 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -197,6 +197,37 @@ themselves marked as unstable. To use any of these options, pass `-Z unstable-op the flag in question to Rustdoc on the command-line. To do this from Cargo, you can either use the `RUSTDOCFLAGS` environment variable or the `cargo rustdoc` command. +### `--merge`, `--parts-out-dir`, and `--include-parts-dir` + +These options control how rustdoc handles files that combine data from multiple crates. + +By default, they act like `--merge=shared` is set, and `--parts-out-dir` and `--include-parts-dir` +are turned off. The `--merge=shared` mode causes rustdoc to load the existing data in the out-dir, +combine the new crate data into it, and write the result. This is very easy to use in scripts that +manually invoke rustdoc, but it's also slow, because it performs O(crates) work on +every crate, meaning it performs O(crates2) work. + +```console +$ rustdoc crate1.rs --out-dir=doc +$ cat doc/search.index/crateNames/* +rd_("fcrate1") +$ rustdoc crate2.rs --out-dir=doc +$ cat doc/search.index/crateNames/* +rd_("fcrate1fcrate2") +``` + +To delay shared-data merging until the end of a build, so that you only have to perform O(crates) +work, use `--merge=none` on every crate except the last one, which will use `--merge=finalize`. + +```console +$ rustdoc +nightly crate1.rs --merge=none --parts-out-dir=crate1.d -Zunstable-options +$ cat doc/search.index/crateNames/* +cat: 'doc/search.index/crateNames/*': No such file or directory +$ rustdoc +nightly crate2.rs --merge=finalize --include-parts-dir=crate1.d -Zunstable-options +$ cat doc/search.index/crateNames/* +rd_("fcrate1fcrate2") +``` + ### `--document-hidden-items`: Show items that are `#[doc(hidden)]` From a2dce774bc35a7fbafbe2d191a4eedf99023e17a Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Tue, 28 Oct 2025 00:47:29 -0700 Subject: [PATCH 007/194] Start documenting autodiff activities --- library/core/src/macros/mod.rs | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index df24dd43b82e..7d7c4147983c 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -1499,6 +1499,25 @@ macro_rules! include { /// - `INPUT_ACTIVITIES`: Specifies one valid activity for each input parameter. /// - `OUTPUT_ACTIVITY`: Must not be set if the function implicitly returns nothing /// (or explicitly returns `-> ()`). Otherwise, it must be set to one of the allowed activities. + /// + /// ACTIVITIES might either be `Dual` or `Const`, more options will be exposed later. + /// + /// `Const` should be used on non-float arguments, or float-based arguments as an optimization + /// if we are not interested in computing the derivatives with respect to this argument. + /// + /// `Dual` can be used for float scalar values or for references, raw pointers, or other + /// indirect input arguments. It can also be used on a scalar float return value. + /// If used on a return value, the generated function will return a tuple of two float scalars. + /// If used on an input argument, a new shadow argument of the same type will be created, + /// directly following the original argument. + /// + /// We might want to track how one input float affects one or more output floats. In this case, + /// the shadow of one input should be initialized to `1.0`, while the shadows of the other + /// inputs should be initialized to `0.0`. The shadow of the output(s) should be initialized to + /// `0.0`. After calling the generated function, the shadow of the input will be zeroed, + /// while the shadow(s) of the output(s) will contain the derivatives. Forward mode is generally + /// more efficient if we have more output floats marked as `Dual` than input floats. + /// Related information can also be found unter the term "Vector-Jacobian product" (VJP). #[unstable(feature = "autodiff", issue = "124509")] #[allow_internal_unstable(rustc_attrs)] #[allow_internal_unstable(core_intrinsics)] @@ -1518,6 +1537,34 @@ macro_rules! include { /// - `INPUT_ACTIVITIES`: Specifies one valid activity for each input parameter. /// - `OUTPUT_ACTIVITY`: Must not be set if the function implicitly returns nothing /// (or explicitly returns `-> ()`). Otherwise, it must be set to one of the allowed activities. + /// + /// ACTIVITIES might either be `Active`, `Duplicated` or `Const`, more options will be exposed later. + /// + /// `Active` can be used for float scalar values. + /// If used on an input, a new float will be appended to the return tuple of the generated + /// function. If the function returns a float scalar, `Active` can be used for the return as + /// well. In this case a float scalar will be appended to the argument list, it works as seed. + /// + /// `Duplicated` can be used on references, raw pointers, or other indirect input + /// arguments. It creates a new shadow argument of the same type, following the original argument. + /// A const reference or pointer argument will receive a mutable reference or pointer as shadow. + /// + /// `Const` should be used on non-float arguments, or float-based arguments as an optimization + /// if we are not interested in computing the derivatives with respect to this argument. + /// + /// We often want to track how one or more input floats affect one output float. This output can + /// be a scalar return value, or a mutable reference or pointer argument. In this case, the + /// shadow of the input should be marked as duplicated and initialized to `0.0`. The shadow of + /// the output should be marked as active or duplicated and initialized to `1.0`. After calling + /// the generated function, the shadow(s) of the input(s) will contain the derivatives. If the + /// function has more than one output float marked as active or duplicated, users might want to + /// set one of them to `1.0` and the others to `0.0` to compute partial derivatives. + /// Unlike forward-mode, a call to the generated function does not reset the shadow of the + /// inputs. + /// Reverse mode is generally more efficient if we have more active/duplicated input than + /// output floats. + /// + /// Related information can also be found unter the term "Jacobian-Vector Product" (JVP). #[unstable(feature = "autodiff", issue = "124509")] #[allow_internal_unstable(rustc_attrs)] #[allow_internal_unstable(core_intrinsics)] From 0786642d61f660e7872a4e2ce8d19b74efa13105 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 28 Oct 2025 15:51:03 -0700 Subject: [PATCH 008/194] rustdoc: clean up and further test mergeable CCI This fixes a limitation that prevented me from adding it to Cargo. The rust compiler-docs bundle is built by running multiple `cargo` commands in succession, and I want to support that, so I'm stuck putting the doc parts all in one directory, so that subsequent `cargo` runs can pick up the previous runs' data. It's less clean, but it should still be usable in hermetic build environments if you give every crate its own directory (which you needed to do before, oddly enough). --- src/librustdoc/config.rs | 17 ++++--- src/librustdoc/html/render/write_shared.rs | 32 +++++++++---- .../run-make/rustdoc-merge-directory/dep1.rs | 4 ++ .../run-make/rustdoc-merge-directory/dep2.rs | 4 ++ .../rustdoc-merge-directory/dep_missing.rs | 4 ++ .../run-make/rustdoc-merge-directory/rmake.rs | 46 +++++++++++++++++++ .../rustdoc-merge-no-input-finalize/rmake.rs | 2 +- 7 files changed, 92 insertions(+), 17 deletions(-) create mode 100644 tests/run-make/rustdoc-merge-directory/dep1.rs create mode 100644 tests/run-make/rustdoc-merge-directory/dep2.rs create mode 100644 tests/run-make/rustdoc-merge-directory/dep_missing.rs create mode 100644 tests/run-make/rustdoc-merge-directory/rmake.rs diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index cf0858810f55..521f3e638a3a 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -975,15 +975,16 @@ fn parse_extern_html_roots( Ok(externs) } -/// Path directly to crate-info file. +/// Path directly to crate-info directory. /// -/// For example, `/home/user/project/target/doc.parts//crate-info`. +/// For example, `/home/user/project/target/doc.parts`. +/// Each crate has its info stored in a file called `CRATENAME.json`. #[derive(Clone, Debug)] pub(crate) struct PathToParts(pub(crate) PathBuf); impl PathToParts { fn from_flag(path: String) -> Result { - let mut path = PathBuf::from(path); + let path = PathBuf::from(path); // check here is for diagnostics if path.exists() && !path.is_dir() { Err(format!( @@ -992,20 +993,22 @@ fn from_flag(path: String) -> Result { )) } else { // if it doesn't exist, we'll create it. worry about that in write_shared - path.push("crate-info"); Ok(PathToParts(path)) } } } -/// Reports error if --include-parts-dir / crate-info is not a file +/// Reports error if --include-parts-dir is not a directory fn parse_include_parts_dir(m: &getopts::Matches) -> Result, String> { let mut ret = Vec::new(); for p in m.opt_strs("include-parts-dir") { let p = PathToParts::from_flag(p)?; // this is just for diagnostic - if !p.0.is_file() { - return Err(format!("--include-parts-dir expected {} to be a file", p.0.display())); + if !p.0.is_dir() { + return Err(format!( + "--include-parts-dir expected {} to be a directory", + p.0.display() + )); } ret.push(p); } diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 3a1db805d01c..69282551f041 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -14,7 +14,7 @@ //! or contains "invocation-specific". use std::cell::RefCell; -use std::ffi::OsString; +use std::ffi::{OsStr, OsString}; use std::fs::File; use std::io::{self, Write as _}; use std::iter::once; @@ -83,9 +83,11 @@ pub(crate) fn write_shared( }; if let Some(parts_out_dir) = &opt.parts_out_dir { - create_parents(&parts_out_dir.0)?; + let mut parts_out_file = parts_out_dir.0.clone(); + parts_out_file.push(&format!("{crate_name}.json")); + create_parents(&parts_out_file)?; try_err!( - fs::write(&parts_out_dir.0, serde_json::to_string(&info).unwrap()), + fs::write(&parts_out_file, serde_json::to_string(&info).unwrap()), &parts_out_dir.0 ); } @@ -237,13 +239,25 @@ impl CrateInfo { pub(crate) fn read_many(parts_paths: &[PathToParts]) -> Result, Error> { parts_paths .iter() - .map(|parts_path| { - let path = &parts_path.0; - let parts = try_err!(fs::read(path), &path); - let parts: CrateInfo = try_err!(serde_json::from_slice(&parts), &path); - Ok::<_, Error>(parts) + .fold(Ok(Vec::new()), |acc, parts_path| { + let mut acc = acc?; + let dir = &parts_path.0; + acc.append(&mut try_err!(std::fs::read_dir(dir), dir.as_path()) + .filter_map(|file| { + let to_crate_info = |file: Result| -> Result, Error> { + let file = try_err!(file, dir.as_path()); + if file.path().extension() != Some(OsStr::new("json")) { + return Ok(None); + } + let parts = try_err!(fs::read(file.path()), file.path()); + let parts: CrateInfo = try_err!(serde_json::from_slice(&parts), file.path()); + Ok(Some(parts)) + }; + to_crate_info(file).transpose() + }) + .collect::, Error>>()?); + Ok(acc) }) - .collect::, Error>>() } } diff --git a/tests/run-make/rustdoc-merge-directory/dep1.rs b/tests/run-make/rustdoc-merge-directory/dep1.rs new file mode 100644 index 000000000000..5a1238adec0e --- /dev/null +++ b/tests/run-make/rustdoc-merge-directory/dep1.rs @@ -0,0 +1,4 @@ +//@ hasraw crates.js 'dep1' +//@ hasraw search.index/name/*.js 'Dep1' +//@ has dep1/index.html +pub struct Dep1; diff --git a/tests/run-make/rustdoc-merge-directory/dep2.rs b/tests/run-make/rustdoc-merge-directory/dep2.rs new file mode 100644 index 000000000000..238ff2e4f9b7 --- /dev/null +++ b/tests/run-make/rustdoc-merge-directory/dep2.rs @@ -0,0 +1,4 @@ +//@ hasraw crates.js 'dep1' +//@ hasraw search.index/name/*.js 'Dep1' +//@ has dep2/index.html +pub struct Dep2; diff --git a/tests/run-make/rustdoc-merge-directory/dep_missing.rs b/tests/run-make/rustdoc-merge-directory/dep_missing.rs new file mode 100644 index 000000000000..74236aef47ea --- /dev/null +++ b/tests/run-make/rustdoc-merge-directory/dep_missing.rs @@ -0,0 +1,4 @@ +//@ !hasraw crates.js 'dep_missing' +//@ !hasraw search.index/name/*.js 'DepMissing' +//@ has dep_missing/index.html +pub struct DepMissing; diff --git a/tests/run-make/rustdoc-merge-directory/rmake.rs b/tests/run-make/rustdoc-merge-directory/rmake.rs new file mode 100644 index 000000000000..e4695ddad0b4 --- /dev/null +++ b/tests/run-make/rustdoc-merge-directory/rmake.rs @@ -0,0 +1,46 @@ +// Running --merge=finalize without an input crate root should not trigger ICE. +// Issue: https://github.com/rust-lang/rust/issues/146646 + +//@ needs-target-std + +use run_make_support::{htmldocck, path, rustdoc}; + +fn main() { + let out_dir = path("out"); + let merged_dir = path("merged"); + let parts_out_dir = path("parts"); + + rustdoc() + .input("dep1.rs") + .out_dir(&out_dir) + .arg("-Zunstable-options") + .arg(format!("--parts-out-dir={}", parts_out_dir.display())) + .arg("--merge=none") + .run(); + assert!(parts_out_dir.join("dep1.json").exists()); + + rustdoc() + .input("dep2.rs") + .out_dir(&out_dir) + .arg("-Zunstable-options") + .arg(format!("--parts-out-dir={}", parts_out_dir.display())) + .arg("--merge=none") + .run(); + assert!(parts_out_dir.join("dep2.json").exists()); + + // dep_missing is different, because --parts-out-dir is not supplied + rustdoc().input("dep_missing.rs").out_dir(&out_dir).run(); + assert!(parts_out_dir.join("dep2.json").exists()); + + let output = rustdoc() + .arg("-Zunstable-options") + .out_dir(&out_dir) + .arg(format!("--include-parts-dir={}", parts_out_dir.display())) + .arg("--merge=finalize") + .run(); + output.assert_stderr_not_contains("error: the compiler unexpectedly panicked. this is a bug."); + + htmldocck().arg(&out_dir).arg("dep1.rs").run(); + htmldocck().arg(&out_dir).arg("dep2.rs").run(); + htmldocck().arg(out_dir).arg("dep_missing.rs").run(); +} diff --git a/tests/run-make/rustdoc-merge-no-input-finalize/rmake.rs b/tests/run-make/rustdoc-merge-no-input-finalize/rmake.rs index 0b1e1948d5fc..dadfe61235ac 100644 --- a/tests/run-make/rustdoc-merge-no-input-finalize/rmake.rs +++ b/tests/run-make/rustdoc-merge-no-input-finalize/rmake.rs @@ -16,7 +16,7 @@ fn main() { .arg(format!("--parts-out-dir={}", parts_out_dir.display())) .arg("--merge=none") .run(); - assert!(parts_out_dir.join("crate-info").exists()); + assert!(parts_out_dir.join("sierra.json").exists()); let output = rustdoc() .arg("-Zunstable-options") From 48116cf39d59782143172e8c3f86006b3a5bf12e Mon Sep 17 00:00:00 2001 From: sayantn Date: Sun, 6 Apr 2025 19:40:15 +0530 Subject: [PATCH 009/194] Add AMX intrinsics --- library/stdarch/crates/core_arch/src/lib.rs | 3 +- .../crates/core_arch/src/x86_64/amx.rs | 224 ++++++++++++++++++ 2 files changed, 226 insertions(+), 1 deletion(-) diff --git a/library/stdarch/crates/core_arch/src/lib.rs b/library/stdarch/crates/core_arch/src/lib.rs index 26a9cb589918..dcd19186a183 100644 --- a/library/stdarch/crates/core_arch/src/lib.rs +++ b/library/stdarch/crates/core_arch/src/lib.rs @@ -34,7 +34,8 @@ f16, aarch64_unstable_target_feature, bigint_helper_methods, - funnel_shifts + funnel_shifts, + avx10_target_feature )] #![cfg_attr(test, feature(test, abi_vectorcall, stdarch_internal))] #![deny(clippy::missing_inline_in_public_items)] diff --git a/library/stdarch/crates/core_arch/src/x86_64/amx.rs b/library/stdarch/crates/core_arch/src/x86_64/amx.rs index 4b33c0ab6c15..6d896c4918d1 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/amx.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/amx.rs @@ -1,3 +1,5 @@ +use crate::core_arch::{simd::*, x86::*}; + #[cfg(test)] use stdarch_test::assert_instr; @@ -242,6 +244,206 @@ pub unsafe fn _tile_cmmrlfp16ps() { tcmmrlfp16ps(DST as i8, A as i8, B as i8); } +/// Compute dot-product of BF8 (8-bit E5M2) floating-point elements in tile a and BF8 (8-bit E5M2) +/// floating-point elements in tile b, accumulating the intermediate single-precision +/// (32-bit) floating-point elements with elements in dst, and store the 32-bit result +/// back to tile dst. +#[inline] +#[rustc_legacy_const_generics(0, 1, 2)] +#[target_feature(enable = "amx-fp8")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tdpbf8ps, DST = 0, A = 1, B = 2) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_dpbf8ps() { + static_assert_uimm_bits!(DST, 3); + static_assert_uimm_bits!(A, 3); + static_assert_uimm_bits!(B, 3); + tdpbf8ps(DST as i8, A as i8, B as i8); +} + +/// Compute dot-product of BF8 (8-bit E5M2) floating-point elements in tile a and HF8 +/// (8-bit E4M3) floating-point elements in tile b, accumulating the intermediate single-precision +/// (32-bit) floating-point elements with elements in dst, and store the 32-bit result +/// back to tile dst. +#[inline] +#[rustc_legacy_const_generics(0, 1, 2)] +#[target_feature(enable = "amx-fp8")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tdpbhf8ps, DST = 0, A = 1, B = 2) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_dpbhf8ps() { + static_assert_uimm_bits!(DST, 3); + static_assert_uimm_bits!(A, 3); + static_assert_uimm_bits!(B, 3); + tdpbhf8ps(DST as i8, A as i8, B as i8); +} + +/// Compute dot-product of HF8 (8-bit E4M3) floating-point elements in tile a and BF8 +/// (8-bit E5M2) floating-point elements in tile b, accumulating the intermediate single-precision +/// (32-bit) floating-point elements with elements in dst, and store the 32-bit result +/// back to tile dst. +#[inline] +#[rustc_legacy_const_generics(0, 1, 2)] +#[target_feature(enable = "amx-fp8")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tdphbf8ps, DST = 0, A = 1, B = 2) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_dphbf8ps() { + static_assert_uimm_bits!(DST, 3); + static_assert_uimm_bits!(A, 3); + static_assert_uimm_bits!(B, 3); + tdphbf8ps(DST as i8, A as i8, B as i8); +} + +/// Compute dot-product of HF8 (8-bit E4M3) floating-point elements in tile a and HF8 (8-bit E4M3) +/// floating-point elements in tile b, accumulating the intermediate single-precision +/// (32-bit) floating-point elements with elements in dst, and store the 32-bit result +/// back to tile dst. +#[inline] +#[rustc_legacy_const_generics(0, 1, 2)] +#[target_feature(enable = "amx-fp8")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tdphf8ps, DST = 0, A = 1, B = 2) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_dphf8ps() { + static_assert_uimm_bits!(DST, 3); + static_assert_uimm_bits!(A, 3); + static_assert_uimm_bits!(B, 3); + tdphf8ps(DST as i8, A as i8, B as i8); +} + +/// Load tile rows from memory specified by base address and stride into destination tile dst +/// using the tile configuration previously configured via _tile_loadconfig. +/// Additionally, this intrinsic indicates the source memory location is likely to become +/// read-shared by multiple processors, i.e., read in the future by at least one other processor +/// before it is written, assuming it is ever written in the future. +#[inline] +#[rustc_legacy_const_generics(0)] +#[target_feature(enable = "amx-movrs")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tileloaddrs, DST = 0) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_loaddrs(base: *const u8, stride: usize) { + static_assert_uimm_bits!(DST, 3); + tileloaddrs64(DST as i8, base, stride); +} + +/// Load tile rows from memory specified by base address and stride into destination tile dst +/// using the tile configuration previously configured via _tile_loadconfig. +/// Provides a hint to the implementation that the data would be reused but does not need +/// to be resident in the nearest cache levels. +/// Additionally, this intrinsic indicates the source memory location is likely to become +/// read-shared by multiple processors, i.e., read in the future by at least one other processor +/// before it is written, assuming it is ever written in the future. +#[inline] +#[rustc_legacy_const_generics(0)] +#[target_feature(enable = "amx-movrs")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tileloaddrst1, DST = 0) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_stream_loaddrs(base: *const u8, stride: usize) { + static_assert_uimm_bits!(DST, 3); + tileloaddrst164(DST as i8, base, stride); +} + +/// Perform matrix multiplication of two tiles a and b, containing packed single precision (32-bit) +/// floating-point elements, which are converted to TF32 (tensor-float32) format, and accumulate the +/// results into a packed single precision tile. +/// For each possible combination of (row of a, column of b), it performs +/// - convert to TF32 +/// - multiply the corresponding elements of a and b +/// - accumulate the results into the corresponding row and column of dst using round-to-nearest-even +/// rounding mode. +/// Output FP32 denormals are always flushed to zero, input single precision denormals are always +/// handled and *not* treated as zero. +#[inline] +#[rustc_legacy_const_generics(0, 1, 2)] +#[target_feature(enable = "amx-tf32")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tmmultf32ps, DST = 0, A = 1, B = 2) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_mmultf32ps() { + static_assert_uimm_bits!(DST, 3); + static_assert_uimm_bits!(A, 3); + static_assert_uimm_bits!(B, 3); + tmmultf32ps(DST as i8, A as i8, B as i8); +} + +/// Moves a row from a tile register to a zmm register, converting the packed 32-bit signed integer +/// elements to packed single-precision (32-bit) floating-point elements. +#[inline] +#[rustc_legacy_const_generics(0)] +#[target_feature(enable = "amx-avx512,avx10.2")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tcvtrowd2ps, TILE = 0) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_cvtrowd2ps(row: u32) -> __m512 { + static_assert_uimm_bits!(TILE, 3); + tcvtrowd2ps(TILE as i8, row).as_m512() +} + +/// Moves a row from a tile register to a zmm register, converting the packed single-precision (32-bit) +/// floating-point elements to packed half-precision (16-bit) floating-point elements. The resulting +/// 16-bit elements are placed in the high 16-bits within each 32-bit element of the returned vector. +#[inline] +#[rustc_legacy_const_generics(0)] +#[target_feature(enable = "amx-avx512,avx10.2")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tcvtrowps2phh, TILE = 0) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_cvtrowps2phh(row: u32) -> __m512h { + static_assert_uimm_bits!(TILE, 3); + tcvtrowps2phh(TILE as i8, row).as_m512h() +} + +/// Moves a row from a tile register to a zmm register, converting the packed single-precision (32-bit) +/// floating-point elements to packed half-precision (16-bit) floating-point elements. The resulting +/// 16-bit elements are placed in the low 16-bits within each 32-bit element of the returned vector. +#[inline] +#[rustc_legacy_const_generics(0)] +#[target_feature(enable = "amx-avx512,avx10.2")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tcvtrowps2phl, TILE = 0) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_cvtrowps2phl(row: u32) -> __m512h { + static_assert_uimm_bits!(TILE, 3); + tcvtrowps2phl(TILE as i8, row).as_m512h() +} + +/// Moves one row of tile data into a zmm vector register +#[inline] +#[rustc_legacy_const_generics(0)] +#[target_feature(enable = "amx-avx512,avx10.2")] +#[cfg_attr( + all(test, any(target_os = "linux", target_env = "msvc")), + assert_instr(tilemovrow, TILE = 0) +)] +#[unstable(feature = "x86_amx_intrinsics", issue = "126622")] +pub unsafe fn _tile_movrow(row: u32) -> __m512i { + static_assert_uimm_bits!(TILE, 3); + tilemovrow(TILE as i8, row).as_m512i() +} + #[allow(improper_ctypes)] unsafe extern "C" { #[link_name = "llvm.x86.ldtilecfg"] @@ -274,6 +476,28 @@ pub unsafe fn _tile_cmmrlfp16ps() { fn tcmmimfp16ps(dst: i8, a: i8, b: i8); #[link_name = "llvm.x86.tcmmrlfp16ps"] fn tcmmrlfp16ps(dst: i8, a: i8, b: i8); + #[link_name = "llvm.x86.tdpbf8ps"] + fn tdpbf8ps(dst: i8, a: i8, b: i8); + #[link_name = "llvm.x86.tdpbhf8ps"] + fn tdpbhf8ps(dst: i8, a: i8, b: i8); + #[link_name = "llvm.x86.tdphbf8ps"] + fn tdphbf8ps(dst: i8, a: i8, b: i8); + #[link_name = "llvm.x86.tdphf8ps"] + fn tdphf8ps(dst: i8, a: i8, b: i8); + #[link_name = "llvm.x86.tileloaddrs64"] + fn tileloaddrs64(dst: i8, base: *const u8, stride: usize); + #[link_name = "llvm.x86.tileloaddrst164"] + fn tileloaddrst164(dst: i8, base: *const u8, stride: usize); + #[link_name = "llvm.x86.tmmultf32ps"] + fn tmmultf32ps(dst: i8, a: i8, b: i8); + #[link_name = "llvm.x86.tcvtrowd2ps"] + fn tcvtrowd2ps(tile: i8, row: u32) -> f32x16; + #[link_name = "llvm.x86.tcvtrowps2phh"] + fn tcvtrowps2phh(tile: i8, row: u32) -> f16x32; + #[link_name = "llvm.x86.tcvtrowps2phl"] + fn tcvtrowps2phl(tile: i8, row: u32) -> f16x32; + #[link_name = "llvm.x86.tilemovrow"] + fn tilemovrow(tile: i8, row: u32) -> i32x16; } #[cfg(test)] From 28150236808936971807310430643a50398957bb Mon Sep 17 00:00:00 2001 From: sayantn Date: Sat, 1 Nov 2025 07:51:10 +0530 Subject: [PATCH 010/194] Patch stdarch_verify to not check intel definition for new AMX intrinsics --- library/stdarch/crates/stdarch-verify/tests/x86-intel.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/stdarch/crates/stdarch-verify/tests/x86-intel.rs b/library/stdarch/crates/stdarch-verify/tests/x86-intel.rs index 5a98db980b23..4136463f197f 100644 --- a/library/stdarch/crates/stdarch-verify/tests/x86-intel.rs +++ b/library/stdarch/crates/stdarch-verify/tests/x86-intel.rs @@ -304,6 +304,14 @@ fn verify_all_signatures() { if feature.contains("sse4a") || feature.contains("tbm") { continue; } + + // FIXME: these have not been added to Intrinsics Guide yet + if ["amx-avx512", "amx-fp8", "amx-movrs", "amx-tf32"] + .iter() + .any(|f| feature.contains(f)) + { + continue; + } } let intel = match map.remove(rust.name) { From 17c3f8ab5e52e1c02779383c69fdc34d1b28ef82 Mon Sep 17 00:00:00 2001 From: sayantn Date: Sat, 1 Nov 2025 07:50:36 +0530 Subject: [PATCH 011/194] Add tests for new AMX intrinsics --- .../crates/core_arch/src/x86_64/amx.rs | 228 +++++++++++++++++- 1 file changed, 227 insertions(+), 1 deletion(-) diff --git a/library/stdarch/crates/core_arch/src/x86_64/amx.rs b/library/stdarch/crates/core_arch/src/x86_64/amx.rs index 6d896c4918d1..c87514980df6 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/amx.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/amx.rs @@ -504,7 +504,7 @@ pub unsafe fn _tile_movrow(row: u32) -> __m512i { mod tests { use crate::core_arch::x86::_mm_cvtness_sbh; use crate::core_arch::x86_64::*; - use core::mem::transmute; + use core::{array, mem::transmute}; use stdarch_test::simd_test; #[cfg(target_os = "linux")] use syscalls::{Sysno, syscall}; @@ -843,4 +843,230 @@ unsafe fn test_tile_cmmrlfp16ps() { _tile_release(); assert_eq!(res, [[0f32; 16]; 16]); } + + const BF8_ONE: u8 = 0x3c; + const BF8_TWO: u8 = 0x40; + const HF8_ONE: u8 = 0x38; + const HF8_TWO: u8 = 0x40; + + #[simd_test(enable = "amx-fp8")] + unsafe fn test_tile_dpbf8ps() { + _init_amx(); + let ones = [BF8_ONE; 1024]; + let twos = [BF8_TWO; 1024]; + let mut res = [[0.0_f32; 16]; 16]; + let mut config = __tilecfg::default(); + config.palette = 1; + (0..=2).for_each(|i| { + config.colsb[i] = 64; + config.rows[i] = 16; + }); + _tile_loadconfig(config.as_ptr()); + _tile_zero::<0>(); + _tile_loadd::<1>(&ones as *const u8, 64); + _tile_loadd::<2>(&twos as *const u8, 64); + _tile_dpbf8ps::<0, 1, 2>(); + _tile_stored::<0>(res.as_mut_ptr().cast(), 64); + _tile_release(); + assert_eq!(res, [[128.0_f32; 16]; 16]); + } + + #[simd_test(enable = "amx-fp8")] + unsafe fn test_tile_dpbhf8ps() { + _init_amx(); + let ones = [BF8_ONE; 1024]; + let twos = [HF8_TWO; 1024]; + let mut res = [[0.0_f32; 16]; 16]; + let mut config = __tilecfg::default(); + config.palette = 1; + (0..=2).for_each(|i| { + config.colsb[i] = 64; + config.rows[i] = 16; + }); + _tile_loadconfig(config.as_ptr()); + _tile_zero::<0>(); + _tile_loadd::<1>(&ones as *const u8, 64); + _tile_loadd::<2>(&twos as *const u8, 64); + _tile_dpbhf8ps::<0, 1, 2>(); + _tile_stored::<0>(res.as_mut_ptr().cast(), 64); + _tile_release(); + assert_eq!(res, [[128.0_f32; 16]; 16]); + } + + #[simd_test(enable = "amx-fp8")] + unsafe fn test_tile_dphbf8ps() { + _init_amx(); + let ones = [HF8_ONE; 1024]; + let twos = [BF8_TWO; 1024]; + let mut res = [[0.0_f32; 16]; 16]; + let mut config = __tilecfg::default(); + config.palette = 1; + (0..=2).for_each(|i| { + config.colsb[i] = 64; + config.rows[i] = 16; + }); + _tile_loadconfig(config.as_ptr()); + _tile_zero::<0>(); + _tile_loadd::<1>(&ones as *const u8, 64); + _tile_loadd::<2>(&twos as *const u8, 64); + _tile_dphbf8ps::<0, 1, 2>(); + _tile_stored::<0>(res.as_mut_ptr().cast(), 64); + _tile_release(); + assert_eq!(res, [[128.0_f32; 16]; 16]); + } + + #[simd_test(enable = "amx-fp8")] + unsafe fn test_tile_dphf8ps() { + _init_amx(); + let ones = [HF8_ONE; 1024]; + let twos = [HF8_TWO; 1024]; + let mut res = [[0.0_f32; 16]; 16]; + let mut config = __tilecfg::default(); + config.palette = 1; + (0..=2).for_each(|i| { + config.colsb[i] = 64; + config.rows[i] = 16; + }); + _tile_loadconfig(config.as_ptr()); + _tile_zero::<0>(); + _tile_loadd::<1>(&ones as *const u8, 64); + _tile_loadd::<2>(&twos as *const u8, 64); + _tile_dphf8ps::<0, 1, 2>(); + _tile_stored::<0>(res.as_mut_ptr().cast(), 64); + _tile_release(); + assert_eq!(res, [[128.0_f32; 16]; 16]); + } + + #[simd_test(enable = "amx-tile")] + unsafe fn test_tile_loaddrs() { + _init_amx(); + let mut config = __tilecfg::default(); + config.palette = 1; + config.colsb[0] = 64; + config.rows[0] = 16; + _tile_loadconfig(config.as_ptr()); + _tile_zero::<0>(); + let mat = [1_i8; 1024]; + _tile_loaddrs::<0>(&mat as *const i8 as *const u8, 64); + let mut out = [[0_i8; 64]; 16]; + _tile_stored::<0>(&mut out as *mut [i8; 64] as *mut u8, 64); + _tile_release(); + assert_eq!(out, [[1; 64]; 16]); + } + + #[simd_test(enable = "amx-tile")] + unsafe fn test_tile_stream_loaddrs() { + _init_amx(); + let mut config = __tilecfg::default(); + config.palette = 1; + config.colsb[0] = 64; + config.rows[0] = 16; + _tile_loadconfig(config.as_ptr()); + _tile_zero::<0>(); + let mat = [1_i8; 1024]; + _tile_stream_loaddrs::<0>(&mat as *const i8 as *const u8, 64); + let mut out = [[0_i8; 64]; 16]; + _tile_stored::<0>(&mut out as *mut [i8; 64] as *mut u8, 64); + _tile_release(); + assert_eq!(out, [[1; 64]; 16]); + } + + #[simd_test(enable = "amx-avx512,avx10.2")] + unsafe fn test_tile_movrow() { + _init_amx(); + let array: [[u8; 64]; 16] = array::from_fn(|i| [i as _; _]); + + let mut config = __tilecfg::default(); + config.palette = 1; + config.colsb[0] = 64; + config.rows[0] = 16; + _tile_loadconfig(config.as_ptr()); + _tile_loadd::<0>(array.as_ptr().cast(), 64); + for i in 0..16 { + let row = _tile_movrow::<0>(i); + assert_eq!(*row.as_u8x64().as_array(), [i as _; _]); + } + } + + #[simd_test(enable = "amx-avx512,avx10.2")] + unsafe fn test_tile_cvtrowd2ps() { + _init_amx(); + let array: [[u32; 16]; 16] = array::from_fn(|i| [i as _; _]); + + let mut config = __tilecfg::default(); + config.palette = 1; + config.colsb[0] = 64; + config.rows[0] = 16; + _tile_loadconfig(config.as_ptr()); + _tile_loadd::<0>(array.as_ptr().cast(), 64); + for i in 0..16 { + let row = _tile_cvtrowd2ps::<0>(i); + assert_eq!(*row.as_f32x16().as_array(), [i as _; _]); + } + } + + #[simd_test(enable = "amx-avx512,avx10.2")] + unsafe fn test_tile_cvtrowps2phh() { + _init_amx(); + let array: [[f32; 16]; 16] = array::from_fn(|i| [i as _; _]); + + let mut config = __tilecfg::default(); + config.palette = 1; + config.colsb[0] = 64; + config.rows[0] = 16; + _tile_loadconfig(config.as_ptr()); + _tile_loadd::<0>(array.as_ptr().cast(), 64); + for i in 0..16 { + let row = _tile_cvtrowps2phh::<0>(i); + assert_eq!( + *row.as_f16x32().as_array(), + array::from_fn(|j| if j & 1 == 0 { 0.0 } else { i as _ }) + ); + } + } + + #[simd_test(enable = "amx-avx512,avx10.2")] + unsafe fn test_tile_cvtrowps2phl() { + _init_amx(); + let array: [[f32; 16]; 16] = array::from_fn(|i| [i as _; _]); + + let mut config = __tilecfg::default(); + config.palette = 1; + config.colsb[0] = 64; + config.rows[0] = 16; + _tile_loadconfig(config.as_ptr()); + _tile_loadd::<0>(array.as_ptr().cast(), 64); + for i in 0..16 { + let row = _tile_cvtrowps2phl::<0>(i); + assert_eq!( + *row.as_f16x32().as_array(), + array::from_fn(|j| if j & 1 == 0 { i as _ } else { 0.0 }) + ); + } + } + + #[simd_test(enable = "amx-tf32")] + unsafe fn test_tile_mmultf32ps() { + _init_amx(); + let a: [[f32; 16]; 16] = array::from_fn(|i| [i as _; _]); + let b: [[f32; 16]; 16] = [array::from_fn(|j| j as _); _]; + let mut res = [[0.0; 16]; 16]; + + let mut config = __tilecfg::default(); + config.palette = 1; + (0..=2).for_each(|i| { + config.colsb[i] = 64; + config.rows[i] = 16; + }); + _tile_loadconfig(config.as_ptr()); + _tile_zero::<0>(); + _tile_loadd::<1>(a.as_ptr().cast(), 64); + _tile_loadd::<2>(b.as_ptr().cast(), 64); + _tile_mmultf32ps::<0, 1, 2>(); + _tile_stored::<0>(res.as_mut_ptr().cast(), 64); + _tile_release(); + + let expected = array::from_fn(|i| array::from_fn(|j| 16.0 * i as f32 * j as f32)); + assert_eq!(res, expected); + } } From f9dc790aa5e636165a2f730de94f06eec28b710a Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sun, 2 Nov 2025 20:09:54 +0100 Subject: [PATCH 012/194] improve `_mm256_permute2f128` tests --- .../stdarch/crates/core_arch/src/x86/avx.rs | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx.rs b/library/stdarch/crates/core_arch/src/x86/avx.rs index c2c2febf1829..7ea5f1f4ff41 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx.rs @@ -3928,28 +3928,43 @@ unsafe fn test_mm_permute_pd() { #[simd_test(enable = "avx")] unsafe fn test_mm256_permute2f128_ps() { - let a = _mm256_setr_ps(1., 2., 3., 4., 1., 2., 3., 4.); - let b = _mm256_setr_ps(5., 6., 7., 8., 5., 6., 7., 8.); - let r = _mm256_permute2f128_ps::<0x13>(a, b); - let e = _mm256_setr_ps(5., 6., 7., 8., 1., 2., 3., 4.); + let a = _mm256_setr_ps(11., 12., 13., 14., 15., 16., 17., 18.); + let b = _mm256_setr_ps(21., 22., 23., 24., 25., 26., 27., 28.); + let r = _mm256_permute2f128_ps::<0b0001_0011>(a, b); + let e = _mm256_setr_ps(25., 26., 27., 28., 15., 16., 17., 18.); assert_eq_m256(r, e); + + // Setting bits 3 or 7 (zero-indexed) zeroes the corresponding field. + let r = _mm256_permute2f128_ps::<0b1001_1011>(a, b); + let z = _mm256_setr_ps(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + assert_eq_m256(r, z); } #[simd_test(enable = "avx")] unsafe fn test_mm256_permute2f128_pd() { let a = _mm256_setr_pd(1., 2., 3., 4.); let b = _mm256_setr_pd(5., 6., 7., 8.); - let r = _mm256_permute2f128_pd::<0x31>(a, b); + let r = _mm256_permute2f128_pd::<0b0011_0001>(a, b); let e = _mm256_setr_pd(3., 4., 7., 8.); assert_eq_m256d(r, e); + + // Setting bits 3 or 7 (zero-indexed) zeroes the corresponding field. + let r = _mm256_permute2f128_pd::<0b1011_1001>(a, b); + let e = _mm256_setr_pd(0.0, 0.0, 0.0, 0.0); + assert_eq_m256d(r, e); } #[simd_test(enable = "avx")] unsafe fn test_mm256_permute2f128_si256() { - let a = _mm256_setr_epi32(1, 2, 3, 4, 1, 2, 3, 4); - let b = _mm256_setr_epi32(5, 6, 7, 8, 5, 6, 7, 8); - let r = _mm256_permute2f128_si256::<0x20>(a, b); - let e = _mm256_setr_epi32(1, 2, 3, 4, 5, 6, 7, 8); + let a = _mm256_setr_epi32(11, 12, 13, 14, 15, 16, 17, 18); + let b = _mm256_setr_epi32(21, 22, 23, 24, 25, 26, 27, 28); + let r = _mm256_permute2f128_si256::<0b0010_0000>(a, b); + let e = _mm256_setr_epi32(11, 12, 13, 14, 21, 22, 23, 24); + assert_eq_m256i(r, e); + + // Setting bits 3 or 7 (zero-indexed) zeroes the corresponding field. + let r = _mm256_permute2f128_si256::<0b1010_1000>(a, b); + let e = _mm256_setr_epi32(0, 0, 0, 0, 0, 0, 0, 0); assert_eq_m256i(r, e); } From 43484472eba0c60c9a1d41c07fd835111d242c80 Mon Sep 17 00:00:00 2001 From: George Tokmaji Date: Sun, 2 Nov 2025 19:35:36 +0100 Subject: [PATCH 013/194] Mangle symbols with a mangled name close to PDB limits with v0 instead of legacy mangling to avoid linker errors --- compiler/rustc_symbol_mangling/src/lib.rs | 26 ++++++++++++++++++++++- compiler/rustc_target/src/spec/mod.rs | 4 ++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index d97ee9565253..0ea20ae4dc60 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -291,7 +291,31 @@ fn compute_symbol_name<'tcx>( export::compute_hash_of_export_fn(tcx, instance) ), false => match mangling_version { - SymbolManglingVersion::Legacy => legacy::mangle(tcx, instance, instantiating_crate), + SymbolManglingVersion::Legacy => { + let mangled_name = legacy::mangle(tcx, instance, instantiating_crate); + + let mangled_name_too_long = { + // The PDB debug info format cannot store mangled symbol names for which its + // internal record exceeds u16::MAX bytes, a limit multiple Rust projects have been + // hitting due to the verbosity of legacy name manglng. Depending on the linker version + // in use, such symbol names can lead to linker crashes or incomprehensible linker error + // about a limit being hit. + // Mangle those symbols with v0 mangling instead, which gives us more room to breathe + // as v0 mangling is more compact. + // Empirical testing has shown the limit for the symbol name to be 65521 bytes; use + // 65000 bytes to leave some room for prefixes / suffixes as well as unknown scenarios + // with a different limit. + const MAX_SYMBOL_LENGTH: usize = 65000; + + tcx.sess.target.uses_pdb_debuginfo() && mangled_name.len() > MAX_SYMBOL_LENGTH + }; + + if mangled_name_too_long { + v0::mangle(tcx, instance, instantiating_crate, false) + } else { + mangled_name + } + } SymbolManglingVersion::V0 => v0::mangle(tcx, instance, instantiating_crate, false), SymbolManglingVersion::Hashed => { hashed::mangle(tcx, instance, instantiating_crate, || { diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index b49e7fc9cff6..95c0299bfeb7 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2397,6 +2397,10 @@ pub fn supports_comdat(&self) -> bool { // XCOFF and MachO don't support COMDAT. !self.is_like_aix && !self.is_like_darwin } + + pub fn uses_pdb_debuginfo(&self) -> bool { + self.debuginfo_kind == DebuginfoKind::Pdb + } } impl TargetOptions { From 21ee1cf6bbf7da1cf22475b7df6e518ba943ea47 Mon Sep 17 00:00:00 2001 From: Fulgen301 Date: Tue, 4 Nov 2025 21:04:35 +0100 Subject: [PATCH 014/194] Fix typo Co-authored-by: teor --- compiler/rustc_symbol_mangling/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index 0ea20ae4dc60..85b77ab2a5f0 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -297,7 +297,7 @@ fn compute_symbol_name<'tcx>( let mangled_name_too_long = { // The PDB debug info format cannot store mangled symbol names for which its // internal record exceeds u16::MAX bytes, a limit multiple Rust projects have been - // hitting due to the verbosity of legacy name manglng. Depending on the linker version + // hitting due to the verbosity of legacy name mangling. Depending on the linker version // in use, such symbol names can lead to linker crashes or incomprehensible linker error // about a limit being hit. // Mangle those symbols with v0 mangling instead, which gives us more room to breathe From 91261454192047560c81ab20068bdbd015b427a6 Mon Sep 17 00:00:00 2001 From: sayantn Date: Sat, 11 Oct 2025 01:34:25 +0530 Subject: [PATCH 015/194] Use generic SIMD masked load/stores for avx512 masked load/stores --- .../stdarch/crates/core_arch/src/macros.rs | 14 + .../crates/core_arch/src/x86/avx512bw.rs | 63 ++--- .../crates/core_arch/src/x86/avx512f.rs | 244 +++++++----------- 3 files changed, 134 insertions(+), 187 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/macros.rs b/library/stdarch/crates/core_arch/src/macros.rs index e00b43353679..1030d7e9740a 100644 --- a/library/stdarch/crates/core_arch/src/macros.rs +++ b/library/stdarch/crates/core_arch/src/macros.rs @@ -163,3 +163,17 @@ macro_rules! simd_extract { ($x:expr, $idx:expr $(,)?) => {{ $crate::intrinsics::simd::simd_extract($x, const { $idx }) }}; ($x:expr, $idx:expr, $ty:ty $(,)?) => {{ $crate::intrinsics::simd::simd_extract::<_, $ty>($x, const { $idx }) }}; } + +#[allow(unused)] +macro_rules! simd_masked_load { + ($align:expr, $mask:expr, $ptr:expr, $default:expr) => { + $crate::intrinsics::simd::simd_masked_load::<_, _, _, { $align }>($mask, $ptr, $default) + }; +} + +#[allow(unused)] +macro_rules! simd_masked_store { + ($align:expr, $mask:expr, $ptr:expr, $default:expr) => { + $crate::intrinsics::simd::simd_masked_store::<_, _, _, { $align }>($mask, $ptr, $default) + }; +} diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index fadc0e2cc09b..72842f454675 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -5609,7 +5609,8 @@ pub unsafe fn _mm_storeu_epi8(mem_addr: *mut i8, a: __m128i) { #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_loadu_epi16(src: __m512i, k: __mmask32, mem_addr: *const i16) -> __m512i { - transmute(loaddqu16_512(mem_addr, src.as_i16x32(), k)) + let mask = simd_select_bitmask(k, i16x32::splat(!0), i16x32::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i16x32()).as_m512i() } /// Load packed 16-bit integers from memory into dst using zeromask k @@ -5635,7 +5636,8 @@ pub unsafe fn _mm512_maskz_loadu_epi16(k: __mmask32, mem_addr: *const i16) -> __ #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_loadu_epi8(src: __m512i, k: __mmask64, mem_addr: *const i8) -> __m512i { - transmute(loaddqu8_512(mem_addr, src.as_i8x64(), k)) + let mask = simd_select_bitmask(k, i8x64::splat(!0), i8x64::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i8x64()).as_m512i() } /// Load packed 8-bit integers from memory into dst using zeromask k @@ -5661,7 +5663,8 @@ pub unsafe fn _mm512_maskz_loadu_epi8(k: __mmask64, mem_addr: *const i8) -> __m5 #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_loadu_epi16(src: __m256i, k: __mmask16, mem_addr: *const i16) -> __m256i { - transmute(loaddqu16_256(mem_addr, src.as_i16x16(), k)) + let mask = simd_select_bitmask(k, i16x16::splat(!0), i16x16::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i16x16()).as_m256i() } /// Load packed 16-bit integers from memory into dst using zeromask k @@ -5687,7 +5690,8 @@ pub unsafe fn _mm256_maskz_loadu_epi16(k: __mmask16, mem_addr: *const i16) -> __ #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_loadu_epi8(src: __m256i, k: __mmask32, mem_addr: *const i8) -> __m256i { - transmute(loaddqu8_256(mem_addr, src.as_i8x32(), k)) + let mask = simd_select_bitmask(k, i8x32::splat(!0), i8x32::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i8x32()).as_m256i() } /// Load packed 8-bit integers from memory into dst using zeromask k @@ -5713,7 +5717,8 @@ pub unsafe fn _mm256_maskz_loadu_epi8(k: __mmask32, mem_addr: *const i8) -> __m2 #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_loadu_epi16(src: __m128i, k: __mmask8, mem_addr: *const i16) -> __m128i { - transmute(loaddqu16_128(mem_addr, src.as_i16x8(), k)) + let mask = simd_select_bitmask(k, i16x8::splat(!0), i16x8::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i16x8()).as_m128i() } /// Load packed 16-bit integers from memory into dst using zeromask k @@ -5739,7 +5744,8 @@ pub unsafe fn _mm_maskz_loadu_epi16(k: __mmask8, mem_addr: *const i16) -> __m128 #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_loadu_epi8(src: __m128i, k: __mmask16, mem_addr: *const i8) -> __m128i { - transmute(loaddqu8_128(mem_addr, src.as_i8x16(), k)) + let mask = simd_select_bitmask(k, i8x16::splat(!0), i8x16::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i8x16()).as_m128i() } /// Load packed 8-bit integers from memory into dst using zeromask k @@ -5764,7 +5770,8 @@ pub unsafe fn _mm_maskz_loadu_epi8(k: __mmask16, mem_addr: *const i8) -> __m128i #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask32, a: __m512i) { - storedqu16_512(mem_addr, a.as_i16x32(), mask) + let mask = simd_select_bitmask(mask, i16x32::splat(!0), i16x32::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i16x32()); } /// Store packed 8-bit integers from a into memory using writemask k. @@ -5776,7 +5783,8 @@ pub unsafe fn _mm512_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask32, a: _ #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask64, a: __m512i) { - storedqu8_512(mem_addr, a.as_i8x64(), mask) + let mask = simd_select_bitmask(mask, i8x64::splat(!0), i8x64::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i8x64()); } /// Store packed 16-bit integers from a into memory using writemask k. @@ -5788,7 +5796,8 @@ pub unsafe fn _mm512_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask64, a: __m #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask16, a: __m256i) { - storedqu16_256(mem_addr, a.as_i16x16(), mask) + let mask = simd_select_bitmask(mask, i16x16::splat(!0), i16x16::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i16x16()); } /// Store packed 8-bit integers from a into memory using writemask k. @@ -5800,7 +5809,8 @@ pub unsafe fn _mm256_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask16, a: _ #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask32, a: __m256i) { - storedqu8_256(mem_addr, a.as_i8x32(), mask) + let mask = simd_select_bitmask(mask, i8x32::splat(!0), i8x32::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i8x32()); } /// Store packed 16-bit integers from a into memory using writemask k. @@ -5812,7 +5822,8 @@ pub unsafe fn _mm256_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask32, a: __m #[cfg_attr(test, assert_instr(vmovdqu16))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask8, a: __m128i) { - storedqu16_128(mem_addr, a.as_i16x8(), mask) + let mask = simd_select_bitmask(mask, i16x8::splat(!0), i16x8::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i16x8()); } /// Store packed 8-bit integers from a into memory using writemask k. @@ -5824,7 +5835,8 @@ pub unsafe fn _mm_mask_storeu_epi16(mem_addr: *mut i16, mask: __mmask8, a: __m12 #[cfg_attr(test, assert_instr(vmovdqu8))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_storeu_epi8(mem_addr: *mut i8, mask: __mmask16, a: __m128i) { - storedqu8_128(mem_addr, a.as_i8x16(), mask) + let mask = simd_select_bitmask(mask, i8x16::splat(!0), i8x16::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i8x16()); } /// Multiply packed signed 16-bit integers in a and b, producing intermediate signed 32-bit integers. Horizontally add adjacent pairs of intermediate 32-bit integers, and pack the results in dst. @@ -11733,33 +11745,6 @@ pub unsafe fn _mm_mask_cvtusepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask8, a: fn vpmovuswbmem256(mem_addr: *mut i8, a: i16x16, mask: u16); #[link_name = "llvm.x86.avx512.mask.pmovus.wb.mem.128"] fn vpmovuswbmem128(mem_addr: *mut i8, a: i16x8, mask: u8); - - #[link_name = "llvm.x86.avx512.mask.loadu.b.128"] - fn loaddqu8_128(mem_addr: *const i8, a: i8x16, mask: u16) -> i8x16; - #[link_name = "llvm.x86.avx512.mask.loadu.w.128"] - fn loaddqu16_128(mem_addr: *const i16, a: i16x8, mask: u8) -> i16x8; - #[link_name = "llvm.x86.avx512.mask.loadu.b.256"] - fn loaddqu8_256(mem_addr: *const i8, a: i8x32, mask: u32) -> i8x32; - #[link_name = "llvm.x86.avx512.mask.loadu.w.256"] - fn loaddqu16_256(mem_addr: *const i16, a: i16x16, mask: u16) -> i16x16; - #[link_name = "llvm.x86.avx512.mask.loadu.b.512"] - fn loaddqu8_512(mem_addr: *const i8, a: i8x64, mask: u64) -> i8x64; - #[link_name = "llvm.x86.avx512.mask.loadu.w.512"] - fn loaddqu16_512(mem_addr: *const i16, a: i16x32, mask: u32) -> i16x32; - - #[link_name = "llvm.x86.avx512.mask.storeu.b.128"] - fn storedqu8_128(mem_addr: *mut i8, a: i8x16, mask: u16); - #[link_name = "llvm.x86.avx512.mask.storeu.w.128"] - fn storedqu16_128(mem_addr: *mut i16, a: i16x8, mask: u8); - #[link_name = "llvm.x86.avx512.mask.storeu.b.256"] - fn storedqu8_256(mem_addr: *mut i8, a: i8x32, mask: u32); - #[link_name = "llvm.x86.avx512.mask.storeu.w.256"] - fn storedqu16_256(mem_addr: *mut i16, a: i16x16, mask: u16); - #[link_name = "llvm.x86.avx512.mask.storeu.b.512"] - fn storedqu8_512(mem_addr: *mut i8, a: i8x64, mask: u64); - #[link_name = "llvm.x86.avx512.mask.storeu.w.512"] - fn storedqu16_512(mem_addr: *mut i16, a: i16x32, mask: u32); - } #[cfg(test)] diff --git a/library/stdarch/crates/core_arch/src/x86/avx512f.rs b/library/stdarch/crates/core_arch/src/x86/avx512f.rs index b60df7dbc9a3..d39b741f00da 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512f.rs @@ -34715,7 +34715,8 @@ pub unsafe fn _mm512_store_pd(mem_addr: *mut f64, a: __m512d) { #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_loadu_epi32(src: __m512i, k: __mmask16, mem_addr: *const i32) -> __m512i { - transmute(loaddqu32_512(mem_addr, src.as_i32x16(), k)) + let mask = simd_select_bitmask(k, i32x16::splat(!0), i32x16::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i32x16()).as_m512i() } /// Load packed 32-bit integers from memory into dst using zeromask k @@ -34741,7 +34742,8 @@ pub unsafe fn _mm512_maskz_loadu_epi32(k: __mmask16, mem_addr: *const i32) -> __ #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_loadu_epi64(src: __m512i, k: __mmask8, mem_addr: *const i64) -> __m512i { - transmute(loaddqu64_512(mem_addr, src.as_i64x8(), k)) + let mask = simd_select_bitmask(k, i64x8::splat(!0), i64x8::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i64x8()).as_m512i() } /// Load packed 64-bit integers from memory into dst using zeromask k @@ -34767,7 +34769,8 @@ pub unsafe fn _mm512_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_loadu_ps(src: __m512, k: __mmask16, mem_addr: *const f32) -> __m512 { - transmute(loadups_512(mem_addr, src.as_f32x16(), k)) + let mask = simd_select_bitmask(k, i32x16::splat(!0), i32x16::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f32x16()).as_m512() } /// Load packed single-precision (32-bit) floating-point elements from memory into dst using zeromask k @@ -34793,7 +34796,8 @@ pub unsafe fn _mm512_maskz_loadu_ps(k: __mmask16, mem_addr: *const f32) -> __m51 #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_loadu_pd(src: __m512d, k: __mmask8, mem_addr: *const f64) -> __m512d { - transmute(loadupd_512(mem_addr, src.as_f64x8(), k)) + let mask = simd_select_bitmask(k, i64x8::splat(!0), i64x8::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f64x8()).as_m512d() } /// Load packed double-precision (64-bit) floating-point elements from memory into dst using zeromask k @@ -34819,7 +34823,8 @@ pub unsafe fn _mm512_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m512 #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_loadu_epi32(src: __m256i, k: __mmask8, mem_addr: *const i32) -> __m256i { - transmute(loaddqu32_256(mem_addr, src.as_i32x8(), k)) + let mask = simd_select_bitmask(k, i32x8::splat(!0), i32x8::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i32x8()).as_m256i() } /// Load packed 32-bit integers from memory into dst using zeromask k @@ -34845,7 +34850,8 @@ pub unsafe fn _mm256_maskz_loadu_epi32(k: __mmask8, mem_addr: *const i32) -> __m #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_loadu_epi64(src: __m256i, k: __mmask8, mem_addr: *const i64) -> __m256i { - transmute(loaddqu64_256(mem_addr, src.as_i64x4(), k)) + let mask = simd_select_bitmask(k, i64x4::splat(!0), i64x4::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i64x4()).as_m256i() } /// Load packed 64-bit integers from memory into dst using zeromask k @@ -34871,7 +34877,8 @@ pub unsafe fn _mm256_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_loadu_ps(src: __m256, k: __mmask8, mem_addr: *const f32) -> __m256 { - transmute(loadups_256(mem_addr, src.as_f32x8(), k)) + let mask = simd_select_bitmask(k, i32x8::splat(!0), i32x8::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f32x8()).as_m256() } /// Load packed single-precision (32-bit) floating-point elements from memory into dst using zeromask k @@ -34897,7 +34904,8 @@ pub unsafe fn _mm256_maskz_loadu_ps(k: __mmask8, mem_addr: *const f32) -> __m256 #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_loadu_pd(src: __m256d, k: __mmask8, mem_addr: *const f64) -> __m256d { - transmute(loadupd_256(mem_addr, src.as_f64x4(), k)) + let mask = simd_select_bitmask(k, i64x4::splat(!0), i64x4::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f64x4()).as_m256d() } /// Load packed double-precision (64-bit) floating-point elements from memory into dst using zeromask k @@ -34923,7 +34931,8 @@ pub unsafe fn _mm256_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m256 #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_loadu_epi32(src: __m128i, k: __mmask8, mem_addr: *const i32) -> __m128i { - transmute(loaddqu32_128(mem_addr, src.as_i32x4(), k)) + let mask = simd_select_bitmask(k, i32x4::splat(!0), i32x4::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i32x4()).as_m128i() } /// Load packed 32-bit integers from memory into dst using zeromask k @@ -34949,7 +34958,8 @@ pub unsafe fn _mm_maskz_loadu_epi32(k: __mmask8, mem_addr: *const i32) -> __m128 #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_loadu_epi64(src: __m128i, k: __mmask8, mem_addr: *const i64) -> __m128i { - transmute(loaddqu64_128(mem_addr, src.as_i64x2(), k)) + let mask = simd_select_bitmask(k, i64x2::splat(!0), i64x2::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_i64x2()).as_m128i() } /// Load packed 64-bit integers from memory into dst using zeromask k @@ -34975,7 +34985,8 @@ pub unsafe fn _mm_maskz_loadu_epi64(k: __mmask8, mem_addr: *const i64) -> __m128 #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_loadu_ps(src: __m128, k: __mmask8, mem_addr: *const f32) -> __m128 { - transmute(loadups_128(mem_addr, src.as_f32x4(), k)) + let mask = simd_select_bitmask(k, i32x4::splat(!0), i32x4::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f32x4()).as_m128() } /// Load packed single-precision (32-bit) floating-point elements from memory into dst using zeromask k @@ -35001,7 +35012,8 @@ pub unsafe fn _mm_maskz_loadu_ps(k: __mmask8, mem_addr: *const f32) -> __m128 { #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_loadu_pd(src: __m128d, k: __mmask8, mem_addr: *const f64) -> __m128d { - transmute(loadupd_128(mem_addr, src.as_f64x2(), k)) + let mask = simd_select_bitmask(k, i64x2::splat(!0), i64x2::ZERO); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, src.as_f64x2()).as_m128d() } /// Load packed double-precision (64-bit) floating-point elements from memory into dst using zeromask k @@ -35027,7 +35039,8 @@ pub unsafe fn _mm_maskz_loadu_pd(k: __mmask8, mem_addr: *const f64) -> __m128d { #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_load_epi32(src: __m512i, k: __mmask16, mem_addr: *const i32) -> __m512i { - transmute(loaddqa32_512(mem_addr, src.as_i32x16(), k)) + let mask = simd_select_bitmask(k, i32x16::splat(!0), i32x16::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i32x16()).as_m512i() } /// Load packed 32-bit integers from memory into dst using zeromask k @@ -35053,7 +35066,8 @@ pub unsafe fn _mm512_maskz_load_epi32(k: __mmask16, mem_addr: *const i32) -> __m #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_load_epi64(src: __m512i, k: __mmask8, mem_addr: *const i64) -> __m512i { - transmute(loaddqa64_512(mem_addr, src.as_i64x8(), k)) + let mask = simd_select_bitmask(k, i64x8::splat(!0), i64x8::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i64x8()).as_m512i() } /// Load packed 64-bit integers from memory into dst using zeromask k @@ -35079,7 +35093,8 @@ pub unsafe fn _mm512_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m5 #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_load_ps(src: __m512, k: __mmask16, mem_addr: *const f32) -> __m512 { - transmute(loadaps_512(mem_addr, src.as_f32x16(), k)) + let mask = simd_select_bitmask(k, i32x16::splat(!0), i32x16::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f32x16()).as_m512() } /// Load packed single-precision (32-bit) floating-point elements from memory into dst using zeromask k @@ -35105,7 +35120,8 @@ pub unsafe fn _mm512_maskz_load_ps(k: __mmask16, mem_addr: *const f32) -> __m512 #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_load_pd(src: __m512d, k: __mmask8, mem_addr: *const f64) -> __m512d { - transmute(loadapd_512(mem_addr, src.as_f64x8(), k)) + let mask = simd_select_bitmask(k, i64x8::splat(!0), i64x8::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f64x8()).as_m512d() } /// Load packed double-precision (64-bit) floating-point elements from memory into dst using zeromask k @@ -35131,7 +35147,8 @@ pub unsafe fn _mm512_maskz_load_pd(k: __mmask8, mem_addr: *const f64) -> __m512d #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_load_epi32(src: __m256i, k: __mmask8, mem_addr: *const i32) -> __m256i { - transmute(loaddqa32_256(mem_addr, src.as_i32x8(), k)) + let mask = simd_select_bitmask(k, i32x8::splat(!0), i32x8::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i32x8()).as_m256i() } /// Load packed 32-bit integers from memory into dst using zeromask k @@ -35157,7 +35174,8 @@ pub unsafe fn _mm256_maskz_load_epi32(k: __mmask8, mem_addr: *const i32) -> __m2 #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_load_epi64(src: __m256i, k: __mmask8, mem_addr: *const i64) -> __m256i { - transmute(loaddqa64_256(mem_addr, src.as_i64x4(), k)) + let mask = simd_select_bitmask(k, i64x4::splat(!0), i64x4::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i64x4()).as_m256i() } /// Load packed 64-bit integers from memory into dst using zeromask k @@ -35183,7 +35201,8 @@ pub unsafe fn _mm256_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m2 #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_load_ps(src: __m256, k: __mmask8, mem_addr: *const f32) -> __m256 { - transmute(loadaps_256(mem_addr, src.as_f32x8(), k)) + let mask = simd_select_bitmask(k, i32x8::splat(!0), i32x8::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f32x8()).as_m256() } /// Load packed single-precision (32-bit) floating-point elements from memory into dst using zeromask k @@ -35209,7 +35228,8 @@ pub unsafe fn _mm256_maskz_load_ps(k: __mmask8, mem_addr: *const f32) -> __m256 #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_load_pd(src: __m256d, k: __mmask8, mem_addr: *const f64) -> __m256d { - transmute(loadapd_256(mem_addr, src.as_f64x4(), k)) + let mask = simd_select_bitmask(k, i64x4::splat(!0), i64x4::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f64x4()).as_m256d() } /// Load packed double-precision (64-bit) floating-point elements from memory into dst using zeromask k @@ -35235,7 +35255,8 @@ pub unsafe fn _mm256_maskz_load_pd(k: __mmask8, mem_addr: *const f64) -> __m256d #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_load_epi32(src: __m128i, k: __mmask8, mem_addr: *const i32) -> __m128i { - transmute(loaddqa32_128(mem_addr, src.as_i32x4(), k)) + let mask = simd_select_bitmask(k, i32x4::splat(!0), i32x4::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i32x4()).as_m128i() } /// Load packed 32-bit integers from memory into dst using zeromask k @@ -35261,7 +35282,8 @@ pub unsafe fn _mm_maskz_load_epi32(k: __mmask8, mem_addr: *const i32) -> __m128i #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_load_epi64(src: __m128i, k: __mmask8, mem_addr: *const i64) -> __m128i { - transmute(loaddqa64_128(mem_addr, src.as_i64x2(), k)) + let mask = simd_select_bitmask(k, i64x2::splat(!0), i64x2::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_i64x2()).as_m128i() } /// Load packed 64-bit integers from memory into dst using zeromask k @@ -35287,7 +35309,8 @@ pub unsafe fn _mm_maskz_load_epi64(k: __mmask8, mem_addr: *const i64) -> __m128i #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_load_ps(src: __m128, k: __mmask8, mem_addr: *const f32) -> __m128 { - transmute(loadaps_128(mem_addr, src.as_f32x4(), k)) + let mask = simd_select_bitmask(k, i32x4::splat(!0), i32x4::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f32x4()).as_m128() } /// Load packed single-precision (32-bit) floating-point elements from memory into dst using zeromask k @@ -35313,7 +35336,8 @@ pub unsafe fn _mm_maskz_load_ps(k: __mmask8, mem_addr: *const f32) -> __m128 { #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_load_pd(src: __m128d, k: __mmask8, mem_addr: *const f64) -> __m128d { - transmute(loadapd_128(mem_addr, src.as_f64x2(), k)) + let mask = simd_select_bitmask(k, i64x2::splat(!0), i64x2::ZERO); + simd_masked_load!(SimdAlign::Vector, mask, mem_addr, src.as_f64x2()).as_m128d() } /// Load packed double-precision (64-bit) floating-point elements from memory into dst using zeromask k @@ -35426,7 +35450,8 @@ pub unsafe fn _mm_maskz_load_sd(k: __mmask8, mem_addr: *const f64) -> __m128d { #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask16, a: __m512i) { - storedqu32_512(mem_addr, a.as_i32x16(), mask) + let mask = simd_select_bitmask(mask, i32x16::splat(!0), i32x16::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x16()); } /// Store packed 64-bit integers from a into memory using writemask k. @@ -35438,7 +35463,8 @@ pub unsafe fn _mm512_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask16, a: _ #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m512i) { - storedqu64_512(mem_addr, a.as_i64x8(), mask) + let mask = simd_select_bitmask(mask, i64x8::splat(!0), i64x8::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x8()); } /// Store packed single-precision (32-bit) floating-point elements from a into memory using writemask k. @@ -35450,7 +35476,8 @@ pub unsafe fn _mm512_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __ #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask16, a: __m512) { - storeups_512(mem_addr, a.as_f32x16(), mask) + let mask = simd_select_bitmask(mask, i32x16::splat(!0), i32x16::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f32x16()); } /// Store packed double-precision (64-bit) floating-point elements from a into memory using writemask k. @@ -35462,7 +35489,8 @@ pub unsafe fn _mm512_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask16, a: __m5 #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m512d) { - storeupd_512(mem_addr, a.as_f64x8(), mask) + let mask = simd_select_bitmask(mask, i64x8::splat(!0), i64x8::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f64x8()); } /// Store packed 32-bit integers from a into memory using writemask k. @@ -35474,7 +35502,8 @@ pub unsafe fn _mm512_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m51 #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m256i) { - storedqu32_256(mem_addr, a.as_i32x8(), mask) + let mask = simd_select_bitmask(mask, i32x8::splat(!0), i32x8::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x8()); } /// Store packed 64-bit integers from a into memory using writemask k. @@ -35486,7 +35515,8 @@ pub unsafe fn _mm256_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask8, a: __ #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m256i) { - storedqu64_256(mem_addr, a.as_i64x4(), mask) + let mask = simd_select_bitmask(mask, i64x4::splat(!0), i64x4::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x4()); } /// Store packed single-precision (32-bit) floating-point elements from a into memory using writemask k. @@ -35498,7 +35528,8 @@ pub unsafe fn _mm256_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __ #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask8, a: __m256) { - storeups_256(mem_addr, a.as_f32x8(), mask) + let mask = simd_select_bitmask(mask, i32x8::splat(!0), i32x8::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f32x8()); } /// Store packed double-precision (64-bit) floating-point elements from a into memory using writemask k. @@ -35510,7 +35541,8 @@ pub unsafe fn _mm256_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask8, a: __m25 #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m256d) { - storeupd_256(mem_addr, a.as_f64x4(), mask) + let mask = simd_select_bitmask(mask, i64x4::splat(!0), i64x4::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f64x4()); } /// Store packed 32-bit integers from a into memory using writemask k. @@ -35522,7 +35554,8 @@ pub unsafe fn _mm256_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m25 #[cfg_attr(test, assert_instr(vmovdqu32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m128i) { - storedqu32_128(mem_addr, a.as_i32x4(), mask) + let mask = simd_select_bitmask(mask, i32x4::splat(!0), i32x4::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x4()); } /// Store packed 64-bit integers from a into memory using writemask k. @@ -35534,7 +35567,8 @@ pub unsafe fn _mm_mask_storeu_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m12 #[cfg_attr(test, assert_instr(vmovdqu64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m128i) { - storedqu64_128(mem_addr, a.as_i64x2(), mask) + let mask = simd_select_bitmask(mask, i64x2::splat(!0), i64x2::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x2()); } /// Store packed single-precision (32-bit) floating-point elements from a into memory using writemask k. @@ -35546,7 +35580,8 @@ pub unsafe fn _mm_mask_storeu_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m12 #[cfg_attr(test, assert_instr(vmovups))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask8, a: __m128) { - storeups_128(mem_addr, a.as_f32x4(), mask) + let mask = simd_select_bitmask(mask, i32x4::splat(!0), i32x4::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f32x4()); } /// Store packed double-precision (64-bit) floating-point elements from a into memory using writemask k. @@ -35558,7 +35593,8 @@ pub unsafe fn _mm_mask_storeu_ps(mem_addr: *mut f32, mask: __mmask8, a: __m128) #[cfg_attr(test, assert_instr(vmovupd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m128d) { - storeupd_128(mem_addr, a.as_f64x2(), mask) + let mask = simd_select_bitmask(mask, i64x2::splat(!0), i64x2::ZERO); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_f64x2()); } /// Store packed 32-bit integers from a into memory using writemask k. @@ -35570,7 +35606,8 @@ pub unsafe fn _mm_mask_storeu_pd(mem_addr: *mut f64, mask: __mmask8, a: __m128d) #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_store_epi32(mem_addr: *mut i32, mask: __mmask16, a: __m512i) { - storedqa32_512(mem_addr, a.as_i32x16(), mask) + let mask = simd_select_bitmask(mask, i32x16::splat(!0), i32x16::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i32x16()); } /// Store packed 64-bit integers from a into memory using writemask k. @@ -35582,7 +35619,8 @@ pub unsafe fn _mm512_mask_store_epi32(mem_addr: *mut i32, mask: __mmask16, a: __ #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m512i) { - storedqa64_512(mem_addr, a.as_i64x8(), mask) + let mask = simd_select_bitmask(mask, i64x8::splat(!0), i64x8::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i64x8()); } /// Store packed single-precision (32-bit) floating-point elements from a into memory using writemask k. @@ -35594,7 +35632,8 @@ pub unsafe fn _mm512_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_store_ps(mem_addr: *mut f32, mask: __mmask16, a: __m512) { - storeaps_512(mem_addr, a.as_f32x16(), mask) + let mask = simd_select_bitmask(mask, i32x16::splat(!0), i32x16::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f32x16()); } /// Store packed double-precision (64-bit) floating-point elements from a into memory using writemask k. @@ -35606,7 +35645,8 @@ pub unsafe fn _mm512_mask_store_ps(mem_addr: *mut f32, mask: __mmask16, a: __m51 #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm512_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m512d) { - storeapd_512(mem_addr, a.as_f64x8(), mask) + let mask = simd_select_bitmask(mask, i64x8::splat(!0), i64x8::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f64x8()); } /// Store packed 32-bit integers from a into memory using writemask k. @@ -35618,7 +35658,8 @@ pub unsafe fn _mm512_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m512 #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_store_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m256i) { - storedqa32_256(mem_addr, a.as_i32x8(), mask) + let mask = simd_select_bitmask(mask, i32x8::splat(!0), i32x8::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i32x8()); } /// Store packed 64-bit integers from a into memory using writemask k. @@ -35630,7 +35671,8 @@ pub unsafe fn _mm256_mask_store_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m256i) { - storedqa64_256(mem_addr, a.as_i64x4(), mask) + let mask = simd_select_bitmask(mask, i64x4::splat(!0), i64x4::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i64x4()); } /// Store packed single-precision (32-bit) floating-point elements from a into memory using writemask k. @@ -35642,7 +35684,8 @@ pub unsafe fn _mm256_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_store_ps(mem_addr: *mut f32, mask: __mmask8, a: __m256) { - storeaps_256(mem_addr, a.as_f32x8(), mask) + let mask = simd_select_bitmask(mask, i32x8::splat(!0), i32x8::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f32x8()); } /// Store packed double-precision (64-bit) floating-point elements from a into memory using writemask k. @@ -35654,7 +35697,8 @@ pub unsafe fn _mm256_mask_store_ps(mem_addr: *mut f32, mask: __mmask8, a: __m256 #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm256_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m256d) { - storeapd_256(mem_addr, a.as_f64x4(), mask) + let mask = simd_select_bitmask(mask, i64x4::splat(!0), i64x4::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f64x4()); } /// Store packed 32-bit integers from a into memory using writemask k. @@ -35666,7 +35710,8 @@ pub unsafe fn _mm256_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m256 #[cfg_attr(test, assert_instr(vmovdqa32))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_store_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m128i) { - storedqa32_128(mem_addr, a.as_i32x4(), mask) + let mask = simd_select_bitmask(mask, i32x4::splat(!0), i32x4::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i32x4()); } /// Store packed 64-bit integers from a into memory using writemask k. @@ -35678,7 +35723,8 @@ pub unsafe fn _mm_mask_store_epi32(mem_addr: *mut i32, mask: __mmask8, a: __m128 #[cfg_attr(test, assert_instr(vmovdqa64))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m128i) { - storedqa64_128(mem_addr, a.as_i64x2(), mask) + let mask = simd_select_bitmask(mask, i64x2::splat(!0), i64x2::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_i64x2()); } /// Store packed single-precision (32-bit) floating-point elements from a into memory using writemask k. @@ -35690,7 +35736,8 @@ pub unsafe fn _mm_mask_store_epi64(mem_addr: *mut i64, mask: __mmask8, a: __m128 #[cfg_attr(test, assert_instr(vmovaps))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_store_ps(mem_addr: *mut f32, mask: __mmask8, a: __m128) { - storeaps_128(mem_addr, a.as_f32x4(), mask) + let mask = simd_select_bitmask(mask, i32x4::splat(!0), i32x4::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f32x4()); } /// Store packed double-precision (64-bit) floating-point elements from a into memory using writemask k. @@ -35702,7 +35749,8 @@ pub unsafe fn _mm_mask_store_ps(mem_addr: *mut f32, mask: __mmask8, a: __m128) { #[cfg_attr(test, assert_instr(vmovapd))] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] pub unsafe fn _mm_mask_store_pd(mem_addr: *mut f64, mask: __mmask8, a: __m128d) { - storeapd_128(mem_addr, a.as_f64x2(), mask) + let mask = simd_select_bitmask(mask, i64x2::splat(!0), i64x2::ZERO); + simd_masked_store!(SimdAlign::Vector, mask, mem_addr, a.as_f64x2()); } /// Store a single-precision (32-bit) floating-point element from a into memory using writemask k. mem_addr @@ -43109,106 +43157,6 @@ pub fn _mm_comi_round_sd(a: __m128d, b: __m128d #[link_name = "llvm.x86.avx512.vcomi.sd"] fn vcomisd(a: f64x2, b: f64x2, imm8: i32, sae: i32) -> i32; - #[link_name = "llvm.x86.avx512.mask.loadu.d.128"] - fn loaddqu32_128(mem_addr: *const i32, a: i32x4, mask: u8) -> i32x4; - #[link_name = "llvm.x86.avx512.mask.loadu.q.128"] - fn loaddqu64_128(mem_addr: *const i64, a: i64x2, mask: u8) -> i64x2; - #[link_name = "llvm.x86.avx512.mask.loadu.ps.128"] - fn loadups_128(mem_addr: *const f32, a: f32x4, mask: u8) -> f32x4; - #[link_name = "llvm.x86.avx512.mask.loadu.pd.128"] - fn loadupd_128(mem_addr: *const f64, a: f64x2, mask: u8) -> f64x2; - #[link_name = "llvm.x86.avx512.mask.loadu.d.256"] - fn loaddqu32_256(mem_addr: *const i32, a: i32x8, mask: u8) -> i32x8; - #[link_name = "llvm.x86.avx512.mask.loadu.q.256"] - fn loaddqu64_256(mem_addr: *const i64, a: i64x4, mask: u8) -> i64x4; - #[link_name = "llvm.x86.avx512.mask.loadu.ps.256"] - fn loadups_256(mem_addr: *const f32, a: f32x8, mask: u8) -> f32x8; - #[link_name = "llvm.x86.avx512.mask.loadu.pd.256"] - fn loadupd_256(mem_addr: *const f64, a: f64x4, mask: u8) -> f64x4; - #[link_name = "llvm.x86.avx512.mask.loadu.d.512"] - fn loaddqu32_512(mem_addr: *const i32, a: i32x16, mask: u16) -> i32x16; - #[link_name = "llvm.x86.avx512.mask.loadu.q.512"] - fn loaddqu64_512(mem_addr: *const i64, a: i64x8, mask: u8) -> i64x8; - #[link_name = "llvm.x86.avx512.mask.loadu.ps.512"] - fn loadups_512(mem_addr: *const f32, a: f32x16, mask: u16) -> f32x16; - #[link_name = "llvm.x86.avx512.mask.loadu.pd.512"] - fn loadupd_512(mem_addr: *const f64, a: f64x8, mask: u8) -> f64x8; - - #[link_name = "llvm.x86.avx512.mask.load.d.128"] - fn loaddqa32_128(mem_addr: *const i32, a: i32x4, mask: u8) -> i32x4; - #[link_name = "llvm.x86.avx512.mask.load.q.128"] - fn loaddqa64_128(mem_addr: *const i64, a: i64x2, mask: u8) -> i64x2; - #[link_name = "llvm.x86.avx512.mask.load.ps.128"] - fn loadaps_128(mem_addr: *const f32, a: f32x4, mask: u8) -> f32x4; - #[link_name = "llvm.x86.avx512.mask.load.pd.128"] - fn loadapd_128(mem_addr: *const f64, a: f64x2, mask: u8) -> f64x2; - #[link_name = "llvm.x86.avx512.mask.load.d.256"] - fn loaddqa32_256(mem_addr: *const i32, a: i32x8, mask: u8) -> i32x8; - #[link_name = "llvm.x86.avx512.mask.load.q.256"] - fn loaddqa64_256(mem_addr: *const i64, a: i64x4, mask: u8) -> i64x4; - #[link_name = "llvm.x86.avx512.mask.load.ps.256"] - fn loadaps_256(mem_addr: *const f32, a: f32x8, mask: u8) -> f32x8; - #[link_name = "llvm.x86.avx512.mask.load.pd.256"] - fn loadapd_256(mem_addr: *const f64, a: f64x4, mask: u8) -> f64x4; - #[link_name = "llvm.x86.avx512.mask.load.d.512"] - fn loaddqa32_512(mem_addr: *const i32, a: i32x16, mask: u16) -> i32x16; - #[link_name = "llvm.x86.avx512.mask.load.q.512"] - fn loaddqa64_512(mem_addr: *const i64, a: i64x8, mask: u8) -> i64x8; - #[link_name = "llvm.x86.avx512.mask.load.ps.512"] - fn loadaps_512(mem_addr: *const f32, a: f32x16, mask: u16) -> f32x16; - #[link_name = "llvm.x86.avx512.mask.load.pd.512"] - fn loadapd_512(mem_addr: *const f64, a: f64x8, mask: u8) -> f64x8; - - #[link_name = "llvm.x86.avx512.mask.storeu.d.128"] - fn storedqu32_128(mem_addr: *mut i32, a: i32x4, mask: u8); - #[link_name = "llvm.x86.avx512.mask.storeu.q.128"] - fn storedqu64_128(mem_addr: *mut i64, a: i64x2, mask: u8); - #[link_name = "llvm.x86.avx512.mask.storeu.ps.128"] - fn storeups_128(mem_addr: *mut f32, a: f32x4, mask: u8); - #[link_name = "llvm.x86.avx512.mask.storeu.pd.128"] - fn storeupd_128(mem_addr: *mut f64, a: f64x2, mask: u8); - #[link_name = "llvm.x86.avx512.mask.storeu.d.256"] - fn storedqu32_256(mem_addr: *mut i32, a: i32x8, mask: u8); - #[link_name = "llvm.x86.avx512.mask.storeu.q.256"] - fn storedqu64_256(mem_addr: *mut i64, a: i64x4, mask: u8); - #[link_name = "llvm.x86.avx512.mask.storeu.ps.256"] - fn storeups_256(mem_addr: *mut f32, a: f32x8, mask: u8); - #[link_name = "llvm.x86.avx512.mask.storeu.pd.256"] - fn storeupd_256(mem_addr: *mut f64, a: f64x4, mask: u8); - #[link_name = "llvm.x86.avx512.mask.storeu.d.512"] - fn storedqu32_512(mem_addr: *mut i32, a: i32x16, mask: u16); - #[link_name = "llvm.x86.avx512.mask.storeu.q.512"] - fn storedqu64_512(mem_addr: *mut i64, a: i64x8, mask: u8); - #[link_name = "llvm.x86.avx512.mask.storeu.ps.512"] - fn storeups_512(mem_addr: *mut f32, a: f32x16, mask: u16); - #[link_name = "llvm.x86.avx512.mask.storeu.pd.512"] - fn storeupd_512(mem_addr: *mut f64, a: f64x8, mask: u8); - - #[link_name = "llvm.x86.avx512.mask.store.d.128"] - fn storedqa32_128(mem_addr: *mut i32, a: i32x4, mask: u8); - #[link_name = "llvm.x86.avx512.mask.store.q.128"] - fn storedqa64_128(mem_addr: *mut i64, a: i64x2, mask: u8); - #[link_name = "llvm.x86.avx512.mask.store.ps.128"] - fn storeaps_128(mem_addr: *mut f32, a: f32x4, mask: u8); - #[link_name = "llvm.x86.avx512.mask.store.pd.128"] - fn storeapd_128(mem_addr: *mut f64, a: f64x2, mask: u8); - #[link_name = "llvm.x86.avx512.mask.store.d.256"] - fn storedqa32_256(mem_addr: *mut i32, a: i32x8, mask: u8); - #[link_name = "llvm.x86.avx512.mask.store.q.256"] - fn storedqa64_256(mem_addr: *mut i64, a: i64x4, mask: u8); - #[link_name = "llvm.x86.avx512.mask.store.ps.256"] - fn storeaps_256(mem_addr: *mut f32, a: f32x8, mask: u8); - #[link_name = "llvm.x86.avx512.mask.store.pd.256"] - fn storeapd_256(mem_addr: *mut f64, a: f64x4, mask: u8); - #[link_name = "llvm.x86.avx512.mask.store.d.512"] - fn storedqa32_512(mem_addr: *mut i32, a: i32x16, mask: u16); - #[link_name = "llvm.x86.avx512.mask.store.q.512"] - fn storedqa64_512(mem_addr: *mut i64, a: i64x8, mask: u8); - #[link_name = "llvm.x86.avx512.mask.store.ps.512"] - fn storeaps_512(mem_addr: *mut f32, a: f32x16, mask: u16); - #[link_name = "llvm.x86.avx512.mask.store.pd.512"] - fn storeapd_512(mem_addr: *mut f64, a: f64x8, mask: u8); - #[link_name = "llvm.x86.avx512.mask.expand.load.d.128"] fn expandloadd_128(mem_addr: *const i32, a: i32x4, mask: u8) -> i32x4; #[link_name = "llvm.x86.avx512.mask.expand.load.q.128"] From 7ea8483696cbb92d7b620ce46197f6013e6b70e1 Mon Sep 17 00:00:00 2001 From: sayantn Date: Thu, 6 Nov 2025 06:26:16 +0530 Subject: [PATCH 016/194] Use generic SIMD intrinsics for AVX `maskload` and `maskstore` intrinsics --- .../stdarch/crates/core_arch/src/x86/avx.rs | 40 ++++++++----------- .../stdarch/crates/core_arch/src/x86/avx2.rs | 40 ++++++++----------- 2 files changed, 32 insertions(+), 48 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx.rs b/library/stdarch/crates/core_arch/src/x86/avx.rs index 7ea5f1f4ff41..c50c83fcaa8f 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx.rs @@ -1675,7 +1675,8 @@ pub unsafe fn _mm256_storeu_si256(mem_addr: *mut __m256i, a: __m256i) { #[cfg_attr(test, assert_instr(vmaskmovpd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm256_maskload_pd(mem_addr: *const f64, mask: __m256i) -> __m256d { - maskloadpd256(mem_addr as *const i8, mask.as_i64x4()) + let mask = simd_shr(mask.as_i64x4(), i64x4::splat(63)); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, _mm256_setzero_pd()) } /// Stores packed double-precision (64-bit) floating-point elements from `a` @@ -1687,7 +1688,8 @@ pub unsafe fn _mm256_maskload_pd(mem_addr: *const f64, mask: __m256i) -> __m256d #[cfg_attr(test, assert_instr(vmaskmovpd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm256_maskstore_pd(mem_addr: *mut f64, mask: __m256i, a: __m256d) { - maskstorepd256(mem_addr as *mut i8, mask.as_i64x4(), a); + let mask = simd_shr(mask.as_i64x4(), i64x4::splat(63)); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a) } /// Loads packed double-precision (64-bit) floating-point elements from memory @@ -1700,7 +1702,8 @@ pub unsafe fn _mm256_maskstore_pd(mem_addr: *mut f64, mask: __m256i, a: __m256d) #[cfg_attr(test, assert_instr(vmaskmovpd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_maskload_pd(mem_addr: *const f64, mask: __m128i) -> __m128d { - maskloadpd(mem_addr as *const i8, mask.as_i64x2()) + let mask = simd_shr(mask.as_i64x2(), i64x2::splat(63)); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, _mm_setzero_pd()) } /// Stores packed double-precision (64-bit) floating-point elements from `a` @@ -1712,7 +1715,8 @@ pub unsafe fn _mm_maskload_pd(mem_addr: *const f64, mask: __m128i) -> __m128d { #[cfg_attr(test, assert_instr(vmaskmovpd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_maskstore_pd(mem_addr: *mut f64, mask: __m128i, a: __m128d) { - maskstorepd(mem_addr as *mut i8, mask.as_i64x2(), a); + let mask = simd_shr(mask.as_i64x2(), i64x2::splat(63)); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a) } /// Loads packed single-precision (32-bit) floating-point elements from memory @@ -1725,7 +1729,8 @@ pub unsafe fn _mm_maskstore_pd(mem_addr: *mut f64, mask: __m128i, a: __m128d) { #[cfg_attr(test, assert_instr(vmaskmovps))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm256_maskload_ps(mem_addr: *const f32, mask: __m256i) -> __m256 { - maskloadps256(mem_addr as *const i8, mask.as_i32x8()) + let mask = simd_shr(mask.as_i32x8(), i32x8::splat(31)); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, _mm256_setzero_ps()) } /// Stores packed single-precision (32-bit) floating-point elements from `a` @@ -1737,7 +1742,8 @@ pub unsafe fn _mm256_maskload_ps(mem_addr: *const f32, mask: __m256i) -> __m256 #[cfg_attr(test, assert_instr(vmaskmovps))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm256_maskstore_ps(mem_addr: *mut f32, mask: __m256i, a: __m256) { - maskstoreps256(mem_addr as *mut i8, mask.as_i32x8(), a); + let mask = simd_shr(mask.as_i32x8(), i32x8::splat(31)); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a) } /// Loads packed single-precision (32-bit) floating-point elements from memory @@ -1750,7 +1756,8 @@ pub unsafe fn _mm256_maskstore_ps(mem_addr: *mut f32, mask: __m256i, a: __m256) #[cfg_attr(test, assert_instr(vmaskmovps))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_maskload_ps(mem_addr: *const f32, mask: __m128i) -> __m128 { - maskloadps(mem_addr as *const i8, mask.as_i32x4()) + let mask = simd_shr(mask.as_i32x4(), i32x4::splat(31)); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, _mm_setzero_ps()) } /// Stores packed single-precision (32-bit) floating-point elements from `a` @@ -1762,7 +1769,8 @@ pub unsafe fn _mm_maskload_ps(mem_addr: *const f32, mask: __m128i) -> __m128 { #[cfg_attr(test, assert_instr(vmaskmovps))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_maskstore_ps(mem_addr: *mut f32, mask: __m128i, a: __m128) { - maskstoreps(mem_addr as *mut i8, mask.as_i32x4(), a); + let mask = simd_shr(mask.as_i32x4(), i32x4::splat(31)); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a) } /// Duplicate odd-indexed single-precision (32-bit) floating-point elements @@ -3147,22 +3155,6 @@ pub fn _mm256_cvtss_f32(a: __m256) -> f32 { fn vpermilpd256(a: __m256d, b: i64x4) -> __m256d; #[link_name = "llvm.x86.avx.vpermilvar.pd"] fn vpermilpd(a: __m128d, b: i64x2) -> __m128d; - #[link_name = "llvm.x86.avx.maskload.pd.256"] - fn maskloadpd256(mem_addr: *const i8, mask: i64x4) -> __m256d; - #[link_name = "llvm.x86.avx.maskstore.pd.256"] - fn maskstorepd256(mem_addr: *mut i8, mask: i64x4, a: __m256d); - #[link_name = "llvm.x86.avx.maskload.pd"] - fn maskloadpd(mem_addr: *const i8, mask: i64x2) -> __m128d; - #[link_name = "llvm.x86.avx.maskstore.pd"] - fn maskstorepd(mem_addr: *mut i8, mask: i64x2, a: __m128d); - #[link_name = "llvm.x86.avx.maskload.ps.256"] - fn maskloadps256(mem_addr: *const i8, mask: i32x8) -> __m256; - #[link_name = "llvm.x86.avx.maskstore.ps.256"] - fn maskstoreps256(mem_addr: *mut i8, mask: i32x8, a: __m256); - #[link_name = "llvm.x86.avx.maskload.ps"] - fn maskloadps(mem_addr: *const i8, mask: i32x4) -> __m128; - #[link_name = "llvm.x86.avx.maskstore.ps"] - fn maskstoreps(mem_addr: *mut i8, mask: i32x4, a: __m128); #[link_name = "llvm.x86.avx.ldu.dq.256"] fn vlddqu(mem_addr: *const i8) -> i8x32; #[link_name = "llvm.x86.avx.rcp.ps.256"] diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index 91c10638e0bf..de27ee7b45ef 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -1786,7 +1786,8 @@ pub fn _mm256_maddubs_epi16(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpmaskmovd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_maskload_epi32(mem_addr: *const i32, mask: __m128i) -> __m128i { - transmute(maskloadd(mem_addr as *const i8, mask.as_i32x4())) + let mask = simd_shr(mask.as_i32x4(), i32x4::splat(31)); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i32x4::ZERO).as_m128i() } /// Loads packed 32-bit integers from memory pointed by `mem_addr` using `mask` @@ -1799,7 +1800,8 @@ pub unsafe fn _mm_maskload_epi32(mem_addr: *const i32, mask: __m128i) -> __m128i #[cfg_attr(test, assert_instr(vpmaskmovd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm256_maskload_epi32(mem_addr: *const i32, mask: __m256i) -> __m256i { - transmute(maskloadd256(mem_addr as *const i8, mask.as_i32x8())) + let mask = simd_shr(mask.as_i32x8(), i32x8::splat(31)); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i32x8::ZERO).as_m256i() } /// Loads packed 64-bit integers from memory pointed by `mem_addr` using `mask` @@ -1812,7 +1814,8 @@ pub unsafe fn _mm256_maskload_epi32(mem_addr: *const i32, mask: __m256i) -> __m2 #[cfg_attr(test, assert_instr(vpmaskmovq))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_maskload_epi64(mem_addr: *const i64, mask: __m128i) -> __m128i { - transmute(maskloadq(mem_addr as *const i8, mask.as_i64x2())) + let mask = simd_shr(mask.as_i64x2(), i64x2::splat(63)); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i64x2::ZERO).as_m128i() } /// Loads packed 64-bit integers from memory pointed by `mem_addr` using `mask` @@ -1825,7 +1828,8 @@ pub unsafe fn _mm_maskload_epi64(mem_addr: *const i64, mask: __m128i) -> __m128i #[cfg_attr(test, assert_instr(vpmaskmovq))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm256_maskload_epi64(mem_addr: *const i64, mask: __m256i) -> __m256i { - transmute(maskloadq256(mem_addr as *const i8, mask.as_i64x4())) + let mask = simd_shr(mask.as_i64x4(), i64x4::splat(63)); + simd_masked_load!(SimdAlign::Unaligned, mask, mem_addr, i64x4::ZERO).as_m256i() } /// Stores packed 32-bit integers from `a` into memory pointed by `mem_addr` @@ -1838,7 +1842,8 @@ pub unsafe fn _mm256_maskload_epi64(mem_addr: *const i64, mask: __m256i) -> __m2 #[cfg_attr(test, assert_instr(vpmaskmovd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_maskstore_epi32(mem_addr: *mut i32, mask: __m128i, a: __m128i) { - maskstored(mem_addr as *mut i8, mask.as_i32x4(), a.as_i32x4()) + let mask = simd_shr(mask.as_i32x4(), i32x4::splat(31)); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x4()) } /// Stores packed 32-bit integers from `a` into memory pointed by `mem_addr` @@ -1851,7 +1856,8 @@ pub unsafe fn _mm_maskstore_epi32(mem_addr: *mut i32, mask: __m128i, a: __m128i) #[cfg_attr(test, assert_instr(vpmaskmovd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm256_maskstore_epi32(mem_addr: *mut i32, mask: __m256i, a: __m256i) { - maskstored256(mem_addr as *mut i8, mask.as_i32x8(), a.as_i32x8()) + let mask = simd_shr(mask.as_i32x8(), i32x8::splat(31)); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i32x8()) } /// Stores packed 64-bit integers from `a` into memory pointed by `mem_addr` @@ -1864,7 +1870,8 @@ pub unsafe fn _mm256_maskstore_epi32(mem_addr: *mut i32, mask: __m256i, a: __m25 #[cfg_attr(test, assert_instr(vpmaskmovq))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_maskstore_epi64(mem_addr: *mut i64, mask: __m128i, a: __m128i) { - maskstoreq(mem_addr as *mut i8, mask.as_i64x2(), a.as_i64x2()) + let mask = simd_shr(mask.as_i64x2(), i64x2::splat(63)); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x2()) } /// Stores packed 64-bit integers from `a` into memory pointed by `mem_addr` @@ -1877,7 +1884,8 @@ pub unsafe fn _mm_maskstore_epi64(mem_addr: *mut i64, mask: __m128i, a: __m128i) #[cfg_attr(test, assert_instr(vpmaskmovq))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm256_maskstore_epi64(mem_addr: *mut i64, mask: __m256i, a: __m256i) { - maskstoreq256(mem_addr as *mut i8, mask.as_i64x4(), a.as_i64x4()) + let mask = simd_shr(mask.as_i64x4(), i64x4::splat(63)); + simd_masked_store!(SimdAlign::Unaligned, mask, mem_addr, a.as_i64x4()) } /// Compares packed 16-bit integers in `a` and `b`, and returns the packed @@ -3645,22 +3653,6 @@ pub fn _mm256_extract_epi16(a: __m256i) -> i32 { fn phsubsw(a: i16x16, b: i16x16) -> i16x16; #[link_name = "llvm.x86.avx2.pmadd.ub.sw"] fn pmaddubsw(a: u8x32, b: u8x32) -> i16x16; - #[link_name = "llvm.x86.avx2.maskload.d"] - fn maskloadd(mem_addr: *const i8, mask: i32x4) -> i32x4; - #[link_name = "llvm.x86.avx2.maskload.d.256"] - fn maskloadd256(mem_addr: *const i8, mask: i32x8) -> i32x8; - #[link_name = "llvm.x86.avx2.maskload.q"] - fn maskloadq(mem_addr: *const i8, mask: i64x2) -> i64x2; - #[link_name = "llvm.x86.avx2.maskload.q.256"] - fn maskloadq256(mem_addr: *const i8, mask: i64x4) -> i64x4; - #[link_name = "llvm.x86.avx2.maskstore.d"] - fn maskstored(mem_addr: *mut i8, mask: i32x4, a: i32x4); - #[link_name = "llvm.x86.avx2.maskstore.d.256"] - fn maskstored256(mem_addr: *mut i8, mask: i32x8, a: i32x8); - #[link_name = "llvm.x86.avx2.maskstore.q"] - fn maskstoreq(mem_addr: *mut i8, mask: i64x2, a: i64x2); - #[link_name = "llvm.x86.avx2.maskstore.q.256"] - fn maskstoreq256(mem_addr: *mut i8, mask: i64x4, a: i64x4); #[link_name = "llvm.x86.avx2.mpsadbw"] fn mpsadbw(a: u8x32, b: u8x32, imm8: i8) -> u16x16; #[link_name = "llvm.x86.avx2.pmul.hr.sw"] From b476969e0f893734ecddd1e7ed1e81c26af94246 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 9 Nov 2025 02:30:46 +0100 Subject: [PATCH 017/194] Allow unnormalized types in drop elaboration --- .../rustc_mir_transform/src/elaborate_drop.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_mir_transform/src/elaborate_drop.rs b/compiler/rustc_mir_transform/src/elaborate_drop.rs index de96b1f255a6..fed53eb29f62 100644 --- a/compiler/rustc_mir_transform/src/elaborate_drop.rs +++ b/compiler/rustc_mir_transform/src/elaborate_drop.rs @@ -511,19 +511,12 @@ fn move_paths_for_fields( let tcx = self.tcx(); assert_eq!(self.elaborator.typing_env().typing_mode, ty::TypingMode::PostAnalysis); - let field_ty = match tcx.try_normalize_erasing_regions( - self.elaborator.typing_env(), - field.ty(tcx, args), - ) { - Ok(t) => t, - Err(_) => Ty::new_error( - self.tcx(), - self.tcx().dcx().span_delayed_bug( - self.elaborator.body().span, - "Error normalizing in drop elaboration.", - ), - ), - }; + let field_ty = field.ty(tcx, args); + // We silently leave an unnormalized type here to support polymorphic drop + // elaboration for users of rustc internal APIs + let field_ty = tcx + .try_normalize_erasing_regions(self.elaborator.typing_env(), field_ty) + .unwrap_or(field_ty); (tcx.mk_place_field(base_place, field_idx, field_ty), subpath) }) From 83e4d8182fc372483ad1c04c8fa472044a61ba1c Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Mon, 10 Nov 2025 04:10:10 +0000 Subject: [PATCH 018/194] Prepare for merging from rust-lang/rust This updates the rust-version file to 8401398e1f14a24670ee1a3203713dc2f0f8b3a8. --- library/stdarch/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/stdarch/rust-version b/library/stdarch/rust-version index e313eada4543..04d41c96f5c0 100644 --- a/library/stdarch/rust-version +++ b/library/stdarch/rust-version @@ -1 +1 @@ -73e6c9ebd9123154a196300ef58e30ec8928e74e +8401398e1f14a24670ee1a3203713dc2f0f8b3a8 From f4efc370e67f5133aa326b37f2a4508653fece14 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Tue, 11 Nov 2025 01:14:38 +0900 Subject: [PATCH 019/194] feat: Add `bit_width` for unsigned `NonZero` --- library/core/src/num/nonzero.rs | 24 ++++++++++++++++++++++++ library/coretests/tests/nonzero.rs | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 8cd8b0850e94..baabf1d90b88 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -1777,6 +1777,30 @@ pub const fn cast_signed(self) -> NonZero<$Sint> { // SAFETY: `self.get()` can't be zero unsafe { NonZero::new_unchecked(self.get().cast_signed()) } } + + /// Returns the minimum number of bits required to represent `self`. + /// + /// # Examples + /// + /// ``` + /// #![feature(uint_bit_width)] + /// + /// # use core::num::NonZero; + /// # + /// # fn main() { test().unwrap(); } + /// # fn test() -> Option<()> { + #[doc = concat!("assert_eq!(NonZero::<", stringify!($Int), ">::new(0b111)?.bit_width(), 3);")] + #[doc = concat!("assert_eq!(NonZero::<", stringify!($Int), ">::new(0b1110)?.bit_width(), 4);")] + /// # Some(()) + /// # } + /// ``` + #[unstable(feature = "uint_bit_width", issue = "142326")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn bit_width(self) -> u32 { + Self::BITS - self.leading_zeros() + } }; // Associated items for signed nonzero types only. diff --git a/library/coretests/tests/nonzero.rs b/library/coretests/tests/nonzero.rs index 69e4ed9c36b3..4bcc61de8dca 100644 --- a/library/coretests/tests/nonzero.rs +++ b/library/coretests/tests/nonzero.rs @@ -570,3 +570,21 @@ macro_rules! nonzero_uint_impl { nonzero_int_impl!(i8, i16, i32, i64, i128, isize); nonzero_uint_impl!(u8, u16, u32, u64, u128, usize); } + +#[test] +fn test_nonzero_bit_width() { + macro_rules! nonzero_uint_impl { + ($($T:ty),+) => { + $( + { + assert_eq!(NonZero::<$T>::new(0b010_1100).unwrap().bit_width(), 6); + assert_eq!(NonZero::<$T>::new(0b111_1001).unwrap().bit_width(), 7); + assert_eq!(NonZero::<$T>::MIN.bit_width(), 1); + assert_eq!(NonZero::<$T>::MAX.bit_width(), <$T>::BITS); + } + )+ + }; + } + + nonzero_uint_impl!(u8, u16, u32, u64, u128, usize); +} From 740b8ba8ad94148854b7803e6caca4be5d5151f4 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 4 Nov 2025 03:36:14 +0530 Subject: [PATCH 020/194] Make SIMD intrinsics available in `const`-contexts --- library/core/src/intrinsics/simd.rs | 117 +++++++++--------- .../tests/pass/intrinsics/portable-simd.rs | 2 +- 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/library/core/src/intrinsics/simd.rs b/library/core/src/intrinsics/simd.rs index c56e04bfc2d9..722a765cd01e 100644 --- a/library/core/src/intrinsics/simd.rs +++ b/library/core/src/intrinsics/simd.rs @@ -64,21 +64,21 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// `T` must be a vector of integers or floats. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_add(x: T, y: T) -> T; +pub const unsafe fn simd_add(x: T, y: T) -> T; /// Subtracts `rhs` from `lhs` elementwise. /// /// `T` must be a vector of integers or floats. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_sub(lhs: T, rhs: T) -> T; +pub const unsafe fn simd_sub(lhs: T, rhs: T) -> T; /// Multiplies two simd vectors elementwise. /// /// `T` must be a vector of integers or floats. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_mul(x: T, y: T) -> T; +pub const unsafe fn simd_mul(x: T, y: T) -> T; /// Divides `lhs` by `rhs` elementwise. /// @@ -89,7 +89,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Additionally for signed integers, `::MIN / -1` is undefined behavior. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_div(lhs: T, rhs: T) -> T; +pub const unsafe fn simd_div(lhs: T, rhs: T) -> T; /// Returns remainder of two vectors elementwise. /// @@ -100,7 +100,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Additionally for signed integers, `::MIN / -1` is undefined behavior. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_rem(lhs: T, rhs: T) -> T; +pub const unsafe fn simd_rem(lhs: T, rhs: T) -> T; /// Shifts vector left elementwise, with UB on overflow. /// @@ -113,7 +113,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Each element of `rhs` must be less than `::BITS`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_shl(lhs: T, rhs: T) -> T; +pub const unsafe fn simd_shl(lhs: T, rhs: T) -> T; /// Shifts vector right elementwise, with UB on overflow. /// @@ -126,7 +126,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Each element of `rhs` must be less than `::BITS`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_shr(lhs: T, rhs: T) -> T; +pub const unsafe fn simd_shr(lhs: T, rhs: T) -> T; /// Funnel Shifts vector left elementwise, with UB on overflow. /// @@ -143,7 +143,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Each element of `shift` must be less than `::BITS`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_funnel_shl(a: T, b: T, shift: T) -> T; +pub const unsafe fn simd_funnel_shl(a: T, b: T, shift: T) -> T; /// Funnel Shifts vector right elementwise, with UB on overflow. /// @@ -160,28 +160,28 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Each element of `shift` must be less than `::BITS`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_funnel_shr(a: T, b: T, shift: T) -> T; +pub const unsafe fn simd_funnel_shr(a: T, b: T, shift: T) -> T; /// "And"s vectors elementwise. /// /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_and(x: T, y: T) -> T; +pub const unsafe fn simd_and(x: T, y: T) -> T; /// "Ors" vectors elementwise. /// /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_or(x: T, y: T) -> T; +pub const unsafe fn simd_or(x: T, y: T) -> T; /// "Exclusive ors" vectors elementwise. /// /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_xor(x: T, y: T) -> T; +pub const unsafe fn simd_xor(x: T, y: T) -> T; /// Numerically casts a vector, elementwise. /// @@ -202,7 +202,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// * Be representable in the return type, after truncating off its fractional part #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_cast(x: T) -> U; +pub const unsafe fn simd_cast(x: T) -> U; /// Numerically casts a vector, elementwise. /// @@ -216,7 +216,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Otherwise, truncates or extends the value, maintaining the sign for signed integers. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_as(x: T) -> U; +pub const unsafe fn simd_as(x: T) -> U; /// Negates a vector elementwise. /// @@ -225,14 +225,14 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Rust panics for `-::Min` due to overflow, but it is not UB with this intrinsic. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_neg(x: T) -> T; +pub const unsafe fn simd_neg(x: T) -> T; /// Returns absolute value of a vector, elementwise. /// /// `T` must be a vector of floating-point primitive types. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_fabs(x: T) -> T; +pub const unsafe fn simd_fabs(x: T) -> T; /// Returns the minimum of two vectors, elementwise. /// @@ -241,7 +241,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Follows IEEE-754 `minNum` semantics. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_fmin(x: T, y: T) -> T; +pub const unsafe fn simd_fmin(x: T, y: T) -> T; /// Returns the maximum of two vectors, elementwise. /// @@ -250,7 +250,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Follows IEEE-754 `maxNum` semantics. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_fmax(x: T, y: T) -> T; +pub const unsafe fn simd_fmax(x: T, y: T) -> T; /// Tests elementwise equality of two vectors. /// @@ -261,7 +261,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_eq(x: T, y: T) -> U; +pub const unsafe fn simd_eq(x: T, y: T) -> U; /// Tests elementwise inequality equality of two vectors. /// @@ -272,7 +272,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_ne(x: T, y: T) -> U; +pub const unsafe fn simd_ne(x: T, y: T) -> U; /// Tests if `x` is less than `y`, elementwise. /// @@ -283,7 +283,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_lt(x: T, y: T) -> U; +pub const unsafe fn simd_lt(x: T, y: T) -> U; /// Tests if `x` is less than or equal to `y`, elementwise. /// @@ -294,7 +294,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_le(x: T, y: T) -> U; +pub const unsafe fn simd_le(x: T, y: T) -> U; /// Tests if `x` is greater than `y`, elementwise. /// @@ -305,7 +305,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_gt(x: T, y: T) -> U; +pub const unsafe fn simd_gt(x: T, y: T) -> U; /// Tests if `x` is greater than or equal to `y`, elementwise. /// @@ -316,7 +316,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_ge(x: T, y: T) -> U; +pub const unsafe fn simd_ge(x: T, y: T) -> U; /// Shuffles two vectors by const indices. /// @@ -332,7 +332,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// of `xy`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_shuffle(x: T, y: T, idx: U) -> V; +pub const unsafe fn simd_shuffle(x: T, y: T, idx: U) -> V; /// Reads a vector of pointers. /// @@ -353,7 +353,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_gather(val: T, ptr: U, mask: V) -> T; +pub const unsafe fn simd_gather(val: T, ptr: U, mask: V) -> T; /// Writes to a vector of pointers. /// @@ -377,7 +377,7 @@ pub unsafe fn simd_extract_dyn(x: T, idx: u32) -> U { /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_scatter(val: T, ptr: U, mask: V); +pub const unsafe fn simd_scatter(val: T, ptr: U, mask: V); /// A type for alignment options for SIMD masked load/store intrinsics. #[derive(Debug, ConstParamTy, PartialEq, Eq)] @@ -412,7 +412,8 @@ pub enum SimdAlign { /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_masked_load(mask: V, ptr: U, val: T) -> T; +pub const unsafe fn simd_masked_load(mask: V, ptr: U, val: T) +-> T; /// Writes to a vector of pointers. /// @@ -433,14 +434,14 @@ pub enum SimdAlign { /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_masked_store(mask: V, ptr: U, val: T); +pub const unsafe fn simd_masked_store(mask: V, ptr: U, val: T); /// Adds two simd vectors elementwise, with saturation. /// /// `T` must be a vector of integer primitive types. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_saturating_add(x: T, y: T) -> T; +pub const unsafe fn simd_saturating_add(x: T, y: T) -> T; /// Subtracts two simd vectors elementwise, with saturation. /// @@ -449,7 +450,7 @@ pub enum SimdAlign { /// Subtract `rhs` from `lhs`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_saturating_sub(lhs: T, rhs: T) -> T; +pub const unsafe fn simd_saturating_sub(lhs: T, rhs: T) -> T; /// Adds elements within a vector from left to right. /// @@ -460,7 +461,7 @@ pub enum SimdAlign { /// Starting with the value `y`, add the elements of `x` and accumulate. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_reduce_add_ordered(x: T, y: U) -> U; +pub const unsafe fn simd_reduce_add_ordered(x: T, y: U) -> U; /// Adds elements within a vector in arbitrary order. May also be re-associated with /// unordered additions on the inputs/outputs. @@ -481,7 +482,7 @@ pub enum SimdAlign { /// Starting with the value `y`, multiply the elements of `x` and accumulate. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_reduce_mul_ordered(x: T, y: U) -> U; +pub const unsafe fn simd_reduce_mul_ordered(x: T, y: U) -> U; /// Multiplies elements within a vector in arbitrary order. May also be re-associated with /// unordered additions on the inputs/outputs. @@ -501,7 +502,7 @@ pub enum SimdAlign { /// `x` must contain only `0` or `!0`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_reduce_all(x: T) -> bool; +pub const unsafe fn simd_reduce_all(x: T) -> bool; /// Checks if any mask value is true. /// @@ -511,7 +512,7 @@ pub enum SimdAlign { /// `x` must contain only `0` or `!0`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_reduce_any(x: T) -> bool; +pub const unsafe fn simd_reduce_any(x: T) -> bool; /// Returns the maximum element of a vector. /// @@ -522,7 +523,7 @@ pub enum SimdAlign { /// For floating-point values, uses IEEE-754 `maxNum`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_reduce_max(x: T) -> U; +pub const unsafe fn simd_reduce_max(x: T) -> U; /// Returns the minimum element of a vector. /// @@ -533,7 +534,7 @@ pub enum SimdAlign { /// For floating-point values, uses IEEE-754 `minNum`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_reduce_min(x: T) -> U; +pub const unsafe fn simd_reduce_min(x: T) -> U; /// Logical "and"s all elements together. /// @@ -542,7 +543,7 @@ pub enum SimdAlign { /// `U` must be the element type of `T`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_reduce_and(x: T) -> U; +pub const unsafe fn simd_reduce_and(x: T) -> U; /// Logical "ors" all elements together. /// @@ -551,7 +552,7 @@ pub enum SimdAlign { /// `U` must be the element type of `T`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_reduce_or(x: T) -> U; +pub const unsafe fn simd_reduce_or(x: T) -> U; /// Logical "exclusive ors" all elements together. /// @@ -560,7 +561,7 @@ pub enum SimdAlign { /// `U` must be the element type of `T`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_reduce_xor(x: T) -> U; +pub const unsafe fn simd_reduce_xor(x: T) -> U; /// Truncates an integer vector to a bitmask. /// @@ -597,7 +598,7 @@ pub enum SimdAlign { /// `x` must contain only `0` and `!0`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_bitmask(x: T) -> U; +pub const unsafe fn simd_bitmask(x: T) -> U; /// Selects elements from a mask. /// @@ -613,7 +614,7 @@ pub enum SimdAlign { /// `mask` must only contain `0` and `!0`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_select(mask: M, if_true: T, if_false: T) -> T; +pub const unsafe fn simd_select(mask: M, if_true: T, if_false: T) -> T; /// Selects elements from a bitmask. /// @@ -629,7 +630,7 @@ pub enum SimdAlign { /// The bitmask bit order matches `simd_bitmask`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_select_bitmask(m: M, yes: T, no: T) -> T; +pub const unsafe fn simd_select_bitmask(m: M, yes: T, no: T) -> T; /// Calculates the offset from a pointer vector elementwise, potentially /// wrapping. @@ -641,14 +642,14 @@ pub enum SimdAlign { /// Operates as if by `::wrapping_offset`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_arith_offset(ptr: T, offset: U) -> T; +pub const unsafe fn simd_arith_offset(ptr: T, offset: U) -> T; /// Casts a vector of pointers. /// /// `T` and `U` must be vectors of pointers with the same number of elements. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_cast_ptr(ptr: T) -> U; +pub const unsafe fn simd_cast_ptr(ptr: T) -> U; /// Exposes a vector of pointers as a vector of addresses. /// @@ -666,56 +667,56 @@ pub enum SimdAlign { /// `U` must be a vector of pointers, with the same length as `T`. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_with_exposed_provenance(addr: T) -> U; +pub const unsafe fn simd_with_exposed_provenance(addr: T) -> U; /// Swaps bytes of each element. /// /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_bswap(x: T) -> T; +pub const unsafe fn simd_bswap(x: T) -> T; /// Reverses bits of each element. /// /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_bitreverse(x: T) -> T; +pub const unsafe fn simd_bitreverse(x: T) -> T; /// Counts the leading zeros of each element. /// /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_ctlz(x: T) -> T; +pub const unsafe fn simd_ctlz(x: T) -> T; /// Counts the number of ones in each element. /// /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_ctpop(x: T) -> T; +pub const unsafe fn simd_ctpop(x: T) -> T; /// Counts the trailing zeros of each element. /// /// `T` must be a vector of integers. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_cttz(x: T) -> T; +pub const unsafe fn simd_cttz(x: T) -> T; /// Rounds up each element to the next highest integer-valued float. /// /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_ceil(x: T) -> T; +pub const unsafe fn simd_ceil(x: T) -> T; /// Rounds down each element to the next lowest integer-valued float. /// /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_floor(x: T) -> T; +pub const unsafe fn simd_floor(x: T) -> T; /// Rounds each element to the closest integer-valued float. /// Ties are resolved by rounding away from 0. @@ -723,7 +724,7 @@ pub enum SimdAlign { /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_round(x: T) -> T; +pub const unsafe fn simd_round(x: T) -> T; /// Rounds each element to the closest integer-valued float. /// Ties are resolved by rounding to the number with an even least significant digit @@ -731,7 +732,7 @@ pub enum SimdAlign { /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_round_ties_even(x: T) -> T; +pub const unsafe fn simd_round_ties_even(x: T) -> T; /// Returns the integer part of each element as an integer-valued float. /// In other words, non-integer values are truncated towards zero. @@ -739,7 +740,7 @@ pub enum SimdAlign { /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_trunc(x: T) -> T; +pub const unsafe fn simd_trunc(x: T) -> T; /// Takes the square root of each element. /// @@ -753,7 +754,7 @@ pub enum SimdAlign { /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_fma(x: T, y: T, z: T) -> T; +pub const unsafe fn simd_fma(x: T, y: T, z: T) -> T; /// Computes `(x*y) + z` for each element, non-deterministically executing either /// a fused multiply-add or two operations with rounding of the intermediate result. @@ -768,7 +769,7 @@ pub enum SimdAlign { /// `T` must be a vector of floats. #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_relaxed_fma(x: T, y: T, z: T) -> T; +pub const unsafe fn simd_relaxed_fma(x: T, y: T, z: T) -> T; // Computes the sine of each element. /// diff --git a/src/tools/miri/tests/pass/intrinsics/portable-simd.rs b/src/tools/miri/tests/pass/intrinsics/portable-simd.rs index 961a4b82a7e9..56c000633e58 100644 --- a/src/tools/miri/tests/pass/intrinsics/portable-simd.rs +++ b/src/tools/miri/tests/pass/intrinsics/portable-simd.rs @@ -60,7 +60,7 @@ fn splat(x: T) -> Self { #[rustc_intrinsic] #[rustc_nounwind] -pub unsafe fn simd_shuffle_const_generic(x: T, y: T) -> U; +pub const unsafe fn simd_shuffle_const_generic(x: T, y: T) -> U; fn simd_ops_f16() { use intrinsics::*; From 1b3abfea9459b3696252aab32278c350527f1e26 Mon Sep 17 00:00:00 2001 From: MarcoIeni <11428655+MarcoIeni@users.noreply.github.com> Date: Tue, 11 Nov 2025 10:04:15 +0100 Subject: [PATCH 021/194] rename default branch to main --- library/stdarch/.github/workflows/rustc-pull.yml | 2 +- library/stdarch/crates/core_arch/README.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/stdarch/.github/workflows/rustc-pull.yml b/library/stdarch/.github/workflows/rustc-pull.yml index 1379bd06b0e9..ee0c498878f4 100644 --- a/library/stdarch/.github/workflows/rustc-pull.yml +++ b/library/stdarch/.github/workflows/rustc-pull.yml @@ -16,7 +16,7 @@ jobs: # https://rust-lang.zulipchat.com/#narrow/channel/208962-t-libs.2Fstdarch/topic/Subtree.20sync.20automation/with/528461782 zulip-stream-id: 208962 zulip-bot-email: "stdarch-ci-bot@rust-lang.zulipchat.com" - pr-base-branch: master + pr-base-branch: main branch-name: rustc-pull secrets: zulip-api-token: ${{ secrets.ZULIP_API_TOKEN }} diff --git a/library/stdarch/crates/core_arch/README.md b/library/stdarch/crates/core_arch/README.md index fc18a5759dbe..d341365b987a 100644 --- a/library/stdarch/crates/core_arch/README.md +++ b/library/stdarch/crates/core_arch/README.md @@ -3,7 +3,7 @@ The `core::arch` module implements architecture-dependent intrinsics (e.g. SIMD). -# Usage +# Usage `core::arch` is available as part of `libcore` and it is re-exported by `libstd`. Prefer using it via `core::arch` or `std::arch` than via this crate. @@ -17,7 +17,7 @@ are: you need to re-compile it for a non-standard target, please prefer using `xargo` and re-compiling `libcore`/`libstd` as appropriate instead of using this crate. - + * using some features that might not be available even behind unstable Rust features. We try to keep these to a minimum. If you need to use some of these features, please open an issue so that we can expose them in nightly Rust and @@ -34,7 +34,7 @@ are: * [How to get started][contrib] * [How to help implement intrinsics][help-implement] -[contrib]: https://github.com/rust-lang/stdarch/blob/master/CONTRIBUTING.md +[contrib]: https://github.com/rust-lang/stdarch/blob/HEAD/CONTRIBUTING.md [help-implement]: https://github.com/rust-lang/stdarch/issues/40 [i686]: https://rust-lang.github.io/stdarch/i686/core_arch/ [x86_64]: https://rust-lang.github.io/stdarch/x86_64/core_arch/ From 148a7509a1dee4cc0a017588d91d83b505ea526f Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Tue, 11 Nov 2025 10:55:37 +0100 Subject: [PATCH 022/194] add logic tests for ternarylogic previously the output would just always be all zeroes --- .../crates/core_arch/src/x86/avx512f.rs | 65 ++++++++++++++----- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512f.rs b/library/stdarch/crates/core_arch/src/x86/avx512f.rs index b60df7dbc9a3..81242fa6fc3f 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512f.rs @@ -46240,11 +46240,22 @@ unsafe fn test_mm_maskz_fixupimm_ps() { #[simd_test(enable = "avx512f")] unsafe fn test_mm512_ternarylogic_epi32() { - let a = _mm512_set1_epi32(1 << 2); - let b = _mm512_set1_epi32(1 << 1); - let c = _mm512_set1_epi32(1 << 0); - let r = _mm512_ternarylogic_epi32::<8>(a, b, c); - let e = _mm512_set1_epi32(0); + let a = _mm512_set4_epi32(0b100, 0b110, 0b001, 0b101); + let b = _mm512_set4_epi32(0b010, 0b011, 0b001, 0b101); + let c = _mm512_set4_epi32(0b001, 0b000, 0b001, 0b101); + + // Identity of A. + let r = _mm512_ternarylogic_epi32::<0b1111_0000>(a, b, c); + assert_eq_m512i(r, a); + + // Bitwise or. + let r = _mm512_ternarylogic_epi32::<0b1111_1110>(a, b, c); + let e = _mm512_set4_epi32(0b111, 0b111, 0b001, 0b101); + assert_eq_m512i(r, e); + + // Majority. + let r = _mm512_ternarylogic_epi32::<0b1110_1000>(a, b, c); + let e = _mm512_set4_epi32(0b000, 0b010, 0b001, 0b101); assert_eq_m512i(r, e); } @@ -46274,11 +46285,24 @@ unsafe fn test_mm512_maskz_ternarylogic_epi32() { #[simd_test(enable = "avx512f,avx512vl")] unsafe fn test_mm256_ternarylogic_epi32() { - let a = _mm256_set1_epi32(1 << 2); - let b = _mm256_set1_epi32(1 << 1); - let c = _mm256_set1_epi32(1 << 0); - let r = _mm256_ternarylogic_epi32::<8>(a, b, c); - let e = _mm256_set1_epi32(0); + let _mm256_set4_epi32 = |a, b, c, d| _mm256_setr_epi32(a, b, c, d, a, b, c, d); + + let a = _mm256_set4_epi32(0b100, 0b110, 0b001, 0b101); + let b = _mm256_set4_epi32(0b010, 0b011, 0b001, 0b101); + let c = _mm256_set4_epi32(0b001, 0b000, 0b001, 0b101); + + // Identity of A. + let r = _mm256_ternarylogic_epi32::<0b1111_0000>(a, b, c); + assert_eq_m256i(r, a); + + // Bitwise or. + let r = _mm256_ternarylogic_epi32::<0b1111_1110>(a, b, c); + let e = _mm256_set4_epi32(0b111, 0b111, 0b001, 0b101); + assert_eq_m256i(r, e); + + // Majority. + let r = _mm256_ternarylogic_epi32::<0b1110_1000>(a, b, c); + let e = _mm256_set4_epi32(0b000, 0b010, 0b001, 0b101); assert_eq_m256i(r, e); } @@ -46308,11 +46332,22 @@ unsafe fn test_mm256_maskz_ternarylogic_epi32() { #[simd_test(enable = "avx512f,avx512vl")] unsafe fn test_mm_ternarylogic_epi32() { - let a = _mm_set1_epi32(1 << 2); - let b = _mm_set1_epi32(1 << 1); - let c = _mm_set1_epi32(1 << 0); - let r = _mm_ternarylogic_epi32::<8>(a, b, c); - let e = _mm_set1_epi32(0); + let a = _mm_setr_epi32(0b100, 0b110, 0b001, 0b101); + let b = _mm_setr_epi32(0b010, 0b011, 0b001, 0b101); + let c = _mm_setr_epi32(0b001, 0b000, 0b001, 0b101); + + // Identity of A. + let r = _mm_ternarylogic_epi32::<0b1111_0000>(a, b, c); + assert_eq_m128i(r, a); + + // Bitwise or. + let r = _mm_ternarylogic_epi32::<0b1111_1110>(a, b, c); + let e = _mm_setr_epi32(0b111, 0b111, 0b001, 0b101); + assert_eq_m128i(r, e); + + // Majority. + let r = _mm_ternarylogic_epi32::<0b1110_1000>(a, b, c); + let e = _mm_setr_epi32(0b000, 0b010, 0b001, 0b101); assert_eq_m128i(r, e); } From e94ac6b638257d58052e3cde19ac62ed850348b1 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Tue, 11 Nov 2025 17:04:11 +0100 Subject: [PATCH 023/194] improve ternary logic tests --- .../crates/core_arch/src/x86/avx512f.rs | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512f.rs b/library/stdarch/crates/core_arch/src/x86/avx512f.rs index 81242fa6fc3f..b5d0daae6635 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512f.rs @@ -46240,22 +46240,25 @@ unsafe fn test_mm_maskz_fixupimm_ps() { #[simd_test(enable = "avx512f")] unsafe fn test_mm512_ternarylogic_epi32() { + use core::intrinsics::simd::simd_xor; + let a = _mm512_set4_epi32(0b100, 0b110, 0b001, 0b101); - let b = _mm512_set4_epi32(0b010, 0b011, 0b001, 0b101); - let c = _mm512_set4_epi32(0b001, 0b000, 0b001, 0b101); + let b = _mm512_set4_epi32(0b010, 0b011, 0b001, 0b110); + let c = _mm512_set4_epi32(0b001, 0b000, 0b001, 0b111); // Identity of A. let r = _mm512_ternarylogic_epi32::<0b1111_0000>(a, b, c); assert_eq_m512i(r, a); - // Bitwise or. - let r = _mm512_ternarylogic_epi32::<0b1111_1110>(a, b, c); - let e = _mm512_set4_epi32(0b111, 0b111, 0b001, 0b101); + // Bitwise xor. + let r = _mm512_ternarylogic_epi32::<0b10010110>(a, b, c); + let e = _mm512_set4_epi32(0b111, 0b101, 0b001, 0b100); assert_eq_m512i(r, e); + assert_eq_m512i(r, simd_xor(simd_xor(a, b), c)); - // Majority. + // Majority (2 or more bits set). let r = _mm512_ternarylogic_epi32::<0b1110_1000>(a, b, c); - let e = _mm512_set4_epi32(0b000, 0b010, 0b001, 0b101); + let e = _mm512_set4_epi32(0b000, 0b010, 0b001, 0b111); assert_eq_m512i(r, e); } @@ -46285,24 +46288,27 @@ unsafe fn test_mm512_maskz_ternarylogic_epi32() { #[simd_test(enable = "avx512f,avx512vl")] unsafe fn test_mm256_ternarylogic_epi32() { + use core::intrinsics::simd::simd_xor; + let _mm256_set4_epi32 = |a, b, c, d| _mm256_setr_epi32(a, b, c, d, a, b, c, d); let a = _mm256_set4_epi32(0b100, 0b110, 0b001, 0b101); - let b = _mm256_set4_epi32(0b010, 0b011, 0b001, 0b101); - let c = _mm256_set4_epi32(0b001, 0b000, 0b001, 0b101); + let b = _mm256_set4_epi32(0b010, 0b011, 0b001, 0b110); + let c = _mm256_set4_epi32(0b001, 0b000, 0b001, 0b111); // Identity of A. let r = _mm256_ternarylogic_epi32::<0b1111_0000>(a, b, c); assert_eq_m256i(r, a); - // Bitwise or. - let r = _mm256_ternarylogic_epi32::<0b1111_1110>(a, b, c); - let e = _mm256_set4_epi32(0b111, 0b111, 0b001, 0b101); + // Bitwise xor. + let r = _mm256_ternarylogic_epi32::<0b10010110>(a, b, c); + let e = _mm256_set4_epi32(0b111, 0b101, 0b001, 0b100); assert_eq_m256i(r, e); + assert_eq_m256i(r, simd_xor(simd_xor(a, b), c)); - // Majority. + // Majority (2 or more bits set). let r = _mm256_ternarylogic_epi32::<0b1110_1000>(a, b, c); - let e = _mm256_set4_epi32(0b000, 0b010, 0b001, 0b101); + let e = _mm256_set4_epi32(0b000, 0b010, 0b001, 0b111); assert_eq_m256i(r, e); } @@ -46332,22 +46338,25 @@ unsafe fn test_mm256_maskz_ternarylogic_epi32() { #[simd_test(enable = "avx512f,avx512vl")] unsafe fn test_mm_ternarylogic_epi32() { + use core::intrinsics::simd::simd_xor; + let a = _mm_setr_epi32(0b100, 0b110, 0b001, 0b101); - let b = _mm_setr_epi32(0b010, 0b011, 0b001, 0b101); - let c = _mm_setr_epi32(0b001, 0b000, 0b001, 0b101); + let b = _mm_setr_epi32(0b010, 0b011, 0b001, 0b110); + let c = _mm_setr_epi32(0b001, 0b000, 0b001, 0b111); // Identity of A. let r = _mm_ternarylogic_epi32::<0b1111_0000>(a, b, c); assert_eq_m128i(r, a); - // Bitwise or. - let r = _mm_ternarylogic_epi32::<0b1111_1110>(a, b, c); - let e = _mm_setr_epi32(0b111, 0b111, 0b001, 0b101); + // Bitwise xor. + let r = _mm_ternarylogic_epi32::<0b10010110>(a, b, c); + let e = _mm_setr_epi32(0b111, 0b101, 0b001, 0b100); assert_eq_m128i(r, e); + assert_eq_m128i(r, simd_xor(simd_xor(a, b), c)); - // Majority. + // Majority (2 or more bits set). let r = _mm_ternarylogic_epi32::<0b1110_1000>(a, b, c); - let e = _mm_setr_epi32(0b000, 0b010, 0b001, 0b101); + let e = _mm_setr_epi32(0b000, 0b010, 0b001, 0b111); assert_eq_m128i(r, e); } From 47384f79fafe696eaf8a4cda905a60d48228d3b9 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Wed, 12 Nov 2025 13:09:59 +0000 Subject: [PATCH 024/194] add check for when span is from macro expansion --- compiler/rustc_lint/src/shadowed_into_iter.rs | 12 +++++-- .../macro-expansion-empty-span-147408.rs | 24 +++++++++++++ .../macro-expansion-empty-span-147408.stderr | 35 +++++++++++++++++++ 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 tests/ui/macros/macro-expansion-empty-span-147408.rs create mode 100644 tests/ui/macros/macro-expansion-empty-span-147408.stderr diff --git a/compiler/rustc_lint/src/shadowed_into_iter.rs b/compiler/rustc_lint/src/shadowed_into_iter.rs index 45c32bfd1d5c..cfb2a7fb6186 100644 --- a/compiler/rustc_lint/src/shadowed_into_iter.rs +++ b/compiler/rustc_lint/src/shadowed_into_iter.rs @@ -124,6 +124,11 @@ fn is_ref_to_boxed_slice(ty: Ty<'_>) -> bool { return; }; + // This check needs to avoid ICE from when `receiver_arg` is from macro expansion + // Which leads to empty span in span arithmetic below + // cc: https://github.com/rust-lang/rust/issues/147408 + let span = receiver_arg.span.find_ancestor_in_same_ctxt(expr.span); + // If this expression comes from the `IntoIter::into_iter` inside of a for loop, // we should just suggest removing the `.into_iter()` or changing it to `.iter()` // to disambiguate if we want to iterate by-value or by-ref. @@ -134,14 +139,15 @@ fn is_ref_to_boxed_slice(ty: Ty<'_>) -> bool { && let hir::ExprKind::Call(path, [_]) = &arg.kind && let hir::ExprKind::Path(qpath) = path.kind && cx.tcx.qpath_is_lang_item(qpath, LangItem::IntoIterIntoIter) + && let Some(span) = span { Some(ShadowedIntoIterDiagSub::RemoveIntoIter { - span: receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()), + span: span.shrink_to_hi().to(expr.span.shrink_to_hi()), }) - } else if can_suggest_ufcs { + } else if can_suggest_ufcs && let Some(span) = span { Some(ShadowedIntoIterDiagSub::UseExplicitIntoIter { start_span: expr.span.shrink_to_lo(), - end_span: receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()), + end_span: span.shrink_to_hi().to(expr.span.shrink_to_hi()), }) } else { None diff --git a/tests/ui/macros/macro-expansion-empty-span-147408.rs b/tests/ui/macros/macro-expansion-empty-span-147408.rs new file mode 100644 index 000000000000..6df96d7b05d4 --- /dev/null +++ b/tests/ui/macros/macro-expansion-empty-span-147408.rs @@ -0,0 +1,24 @@ +//@ check-pass +//@ compile-flags: -Afor_loops_over_fallibles -Warray_into_iter + +fn main() { + macro_rules! mac { + (iter $e:expr) => { + $e.iter() + }; + (into_iter $e:expr) => { + $e.into_iter() //~ WARN this method call resolves to + //~^ WARN this changes meaning in Rust 2021 + }; + (next $e:expr) => { + $e.iter().next() + }; + } + + for _ in dbg!([1, 2]).iter() {} + for _ in dbg!([1, 2]).into_iter() {} //~ WARN this method call resolves to + //~^ WARN this changes meaning in Rust 2021 + for _ in mac!(iter [1, 2]) {} + for _ in mac!(into_iter [1, 2]) {} + for _ in mac!(next [1, 2]) {} +} diff --git a/tests/ui/macros/macro-expansion-empty-span-147408.stderr b/tests/ui/macros/macro-expansion-empty-span-147408.stderr new file mode 100644 index 000000000000..c4faaa20101d --- /dev/null +++ b/tests/ui/macros/macro-expansion-empty-span-147408.stderr @@ -0,0 +1,35 @@ +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 + --> $DIR/macro-expansion-empty-span-147408.rs:19:27 + | +LL | for _ in dbg!([1, 2]).into_iter() {} + | ^^^^^^^^^ + | + = warning: this changes meaning in Rust 2021 + = note: for more information, see + = note: requested on the command line with `-W array-into-iter` +help: use `.iter()` instead of `.into_iter()` to avoid ambiguity + | +LL - for _ in dbg!([1, 2]).into_iter() {} +LL + for _ in dbg!([1, 2]).iter() {} + | +help: or remove `.into_iter()` to iterate by value + | +LL - for _ in dbg!([1, 2]).into_iter() {} +LL + for _ in dbg!([1, 2]) {} + | + +warning: this method call resolves to `<&[T; N] as IntoIterator>::into_iter` (due to backwards compatibility), but will resolve to `<[T; N] as IntoIterator>::into_iter` in Rust 2021 + --> $DIR/macro-expansion-empty-span-147408.rs:10:16 + | +LL | $e.into_iter() + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` +... +LL | for _ in mac!(into_iter [1, 2]) {} + | ---------------------- in this macro invocation + | + = warning: this changes meaning in Rust 2021 + = note: for more information, see + = note: this warning originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: 2 warnings emitted + From d8b6752640113e0834ff7c5253cc0e840eac32be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Wed, 12 Nov 2025 16:20:02 +0100 Subject: [PATCH 025/194] describe bors try parent=sha builds --- src/doc/rustc-dev-guide/src/tests/ci.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/doc/rustc-dev-guide/src/tests/ci.md b/src/doc/rustc-dev-guide/src/tests/ci.md index 5b6accec476b..e41893a15f12 100644 --- a/src/doc/rustc-dev-guide/src/tests/ci.md +++ b/src/doc/rustc-dev-guide/src/tests/ci.md @@ -173,6 +173,11 @@ of [`jobs.yml`]: - `optional` jobs are executed only when explicitly requested via a try build. They are typically used for tier 2 and tier 3 targets. +One reason to do a try build is to do a perf run, as described above, with `@rust-timer queue`. +This perf build then compares against some commit on main. +With `@bors try parent=` you can base your try build and subsequent perf run on a specific commit on `main`, +to help make the perf comparison as fair as possible. + > **Using `try-job` PR description directives** > > 1. Identify which set of try-jobs you would like to exercise. You can From 9d1c2734f5414da22f5ce77d6b862e29497f59b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Wed, 12 Nov 2025 16:22:35 +0100 Subject: [PATCH 026/194] update some uses of `master` in the devguide --- .../src/building/how-to-build-and-run.md | 4 +- .../rustc-dev-guide/src/building/suggested.md | 8 +-- src/doc/rustc-dev-guide/src/contributing.md | 16 ++--- src/doc/rustc-dev-guide/src/external-repos.md | 4 +- src/doc/rustc-dev-guide/src/git.md | 66 +++++++++---------- src/doc/rustc-dev-guide/src/tests/adding.md | 2 +- src/doc/rustc-dev-guide/src/tests/ci.md | 18 ++--- 7 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md b/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md index efb21726e3c6..c924216b8cd3 100644 --- a/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md +++ b/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md @@ -68,7 +68,7 @@ This instructs `git` to perform a "shallow clone", cloning the repository but tr the last `N` commits. Passing `--depth 1` tells `git` to clone the repository but truncate the history to the latest -commit that is on the `master` branch, which is usually fine for browsing the source code or +commit that is on the `main` branch, which is usually fine for browsing the source code or building the compiler. ```bash @@ -172,7 +172,7 @@ You can install it with `cargo install --path src/tools/x`. To clarify that this is another global installed binary util, which is similar to the one declared in section [What is `x.py`](#what-is-xpy), but -it works as an independent process to execute the `x.py` rather than calling the +it works as an independent process to execute the `x.py` rather than calling the shell to run the platform related scripts. ## Create a `bootstrap.toml` diff --git a/src/doc/rustc-dev-guide/src/building/suggested.md b/src/doc/rustc-dev-guide/src/building/suggested.md index 6d7d340e633e..1c75de3e9042 100644 --- a/src/doc/rustc-dev-guide/src/building/suggested.md +++ b/src/doc/rustc-dev-guide/src/building/suggested.md @@ -296,7 +296,7 @@ lets you use `cargo fmt`. [the section on vscode]: suggested.md#configuring-rust-analyzer-for-rustc [the section on rustup]: how-to-build-and-run.md?highlight=rustup#creating-a-rustup-toolchain -## Faster Builds with CI-rustc +## Faster Builds with CI-rustc If you are not working on the compiler, you often don't need to build the compiler tree. For example, you can skip building the compiler and only build the `library` tree or the @@ -389,7 +389,7 @@ times, and having to update each clone individually. Fortunately, Git has a better solution called [worktrees]. This lets you create multiple "working trees", which all share the same Git database. Moreover, because all of the worktrees share the same object database, if you update a -branch (e.g. master) in any of them, you can use the new commits from any of the +branch (e.g. `main`) in any of them, you can use the new commits from any of the worktrees. One caveat, though, is that submodules do not get shared. They will still be cloned multiple times. @@ -403,10 +403,10 @@ command: git worktree add ../rust2 ``` -Creating a new worktree for a new branch based on `master` looks like: +Creating a new worktree for a new branch based on `main` looks like: ```bash -git worktree add -b my-feature ../rust2 master +git worktree add -b my-feature ../rust2 main ``` You can then use that rust2 folder as a separate workspace for modifying and diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md index e30819ebccae..1b4f04dbb5ef 100644 --- a/src/doc/rustc-dev-guide/src/contributing.md +++ b/src/doc/rustc-dev-guide/src/contributing.md @@ -55,7 +55,7 @@ Instead, we have 3 release channels: stable, beta, and nightly. - **Stable**: this is the latest stable release for general usage. - **Beta**: this is the next release (will be stable within 6 weeks). -- **Nightly**: follows the `master` branch of the repo. +- **Nightly**: follows the `main` branch of the repo. This is the only channel where unstable features are intended to be used, which happens via opt-in feature gates. @@ -97,7 +97,7 @@ before approving). This is yet another bot that will compile a collection of benchmarks on a compiler with your changes. The numbers are reported -[here][perf], and you can see a comparison of your changes against the latest master. +[here][perf], and you can see a comparison of your changes against the latest `main`. > For an introduction to the performance of Rust code in general > which would also be useful in rustc development, see [The Rust Performance Book]. @@ -153,7 +153,7 @@ We have [a chapter](git.md) on how to use Git when contributing to Rust. ### Keeping your branch up-to-date -The CI in rust-lang/rust applies your patches directly against the current master, +The CI in rust-lang/rust applies your patches directly against the current `main`, not against the commit your branch is based on. This can lead to unexpected failures if your branch is outdated, even when there are no explicit merge conflicts. @@ -164,7 +164,7 @@ During review, make incremental commits to address feedback. Prefer to squash or rebase only at the end, or when a reviewer requests it. When updating, use `git push --force-with-lease` and leave a brief comment explaining what changed. -Some repos prefer merging from `upstream/master` instead of rebasing; +Some repos prefer merging from `upstream/main` instead of rebasing; follow the project's conventions. See [keeping things up to date](git.md#keeping-things-up-to-date) for detailed instructions. @@ -264,7 +264,7 @@ It will look something like this: This tells [@bors], our lovable integration bot, that your pull request has been approved. The PR then enters the [merge queue], where [@bors] will run *all* the tests on *every* platform we support. -If it all works out, [@bors] will merge your code into `master` and close the pull request. +If it all works out, [@bors] will merge your code into `main` and close the pull request. Depending on the scale of the change, you may see a slightly different form of `r+`: @@ -288,7 +288,7 @@ You are now ready to file a pull request (PR)? Great! Here are a few points you should be aware of. -All pull requests should be filed against the `master` branch, +All pull requests should be filed against the `main` branch, unless you know for sure that you should target a different branch. Run some style checks before you submit the PR: @@ -303,7 +303,7 @@ Rust follows a _no merge-commit policy_, meaning that when you encounter merge conflicts, you are expected to always rebase instead of merging. For example, -always use rebase when bringing the latest changes from the master branch to your feature branch. +always use rebase when bringing the latest changes from the `main` branch to your feature branch. If your PR contains merge commits, it will get marked as `has-merge-commits`. Once you have removed the merge commits, e.g., through an interactive rebase, you should remove the label again: @@ -328,7 +328,7 @@ the issue in question. However, if your PR fixes a stable-to-beta or stable-to-stable regression and has been accepted for a beta and/or stable backport (i.e., it is marked `beta-accepted` and/or `stable-accepted`), please do *not* use any such keywords since we don't -want the corresponding issue to get auto-closed once the fix lands on master. +want the corresponding issue to get auto-closed once the fix lands on `main`. Please update the PR description while still mentioning the issue somewhere. For example, you could write `Fixes (after beta backport) #NNN.`. diff --git a/src/doc/rustc-dev-guide/src/external-repos.md b/src/doc/rustc-dev-guide/src/external-repos.md index fb291aa777ae..6c38b3dc5e20 100644 --- a/src/doc/rustc-dev-guide/src/external-repos.md +++ b/src/doc/rustc-dev-guide/src/external-repos.md @@ -114,7 +114,7 @@ A `subtree pull` takes all changes since the last `subtree pull` from the tool repo and adds these commits to the rustc repo along with a merge commit that moves the tool changes into the specified directory in the Rust repository. -It is recommended that you always do a push first and get that merged to the tool master branch. +It is recommended that you always do a push first and get that merged to the tool `main`/`master` branch. Then, when you do a pull, the merge works without conflicts. While it's definitely possible to resolve conflicts during a pull, you may have to redo the conflict resolution if your PR doesn't get merged fast enough and there are new conflicts. Do not try to @@ -163,7 +163,7 @@ More information may be found on the Forge [Toolstate chapter]. In practice, it is very rare for documentation to have broken toolstate. Breakage is not allowed in the beta and stable channels, and must be addressed -before the PR is merged. They are also not allowed to be broken on master in +before the PR is merged. They are also not allowed to be broken on `main` in the week leading up to the beta cut. [git submodules]: https://git-scm.com/book/en/v2/Git-Tools-Submodules diff --git a/src/doc/rustc-dev-guide/src/git.md b/src/doc/rustc-dev-guide/src/git.md index 56f1f01f26db..a01a156fa64c 100644 --- a/src/doc/rustc-dev-guide/src/git.md +++ b/src/doc/rustc-dev-guide/src/git.md @@ -57,9 +57,9 @@ useful when contributing to other repositories in the Rust project. Below is the normal procedure that you're likely to use for most minor changes and PRs: - 1. Ensure that you're making your changes on top of master: - `git checkout master`. - 2. Get the latest changes from the Rust repo: `git pull upstream master --ff-only`. + 1. Ensure that you're making your changes on top of `main`: + `git checkout main`. + 2. Get the latest changes from the Rust repo: `git pull upstream main --ff-only`. (see [No-Merge Policy][no-merge-policy] for more info about this). 3. Make a new branch for your change: `git checkout -b issue-12345-fix`. 4. Make some changes to the repo and test them. @@ -72,7 +72,7 @@ and PRs: 6. Push your changes to your fork: `git push --set-upstream origin issue-12345-fix` (After adding commits, you can use `git push` and after rebasing or pulling-and-rebasing, you can use `git push --force-with-lease`). - 7. [Open a PR][ghpullrequest] from your fork to `rust-lang/rust`'s master branch. + 7. [Open a PR][ghpullrequest] from your fork to `rust-lang/rust`'s `main` branch. [ghpullrequest]: https://guides.github.com/activities/forking/#making-a-pull-request @@ -101,7 +101,7 @@ Here are some common issues you might run into: Git has two ways to update your branch with the newest changes: merging and rebasing. Rust [uses rebasing][no-merge-policy]. If you make a merge commit, it's not too hard to fix: -`git rebase -i upstream/master`. +`git rebase -i upstream/main`. See [Rebasing](#rebasing) for more about rebasing. @@ -151,7 +151,7 @@ replace `src/tools/cargo` with the path to that submodule): - If you modified the submodule in several different commits, you will need to repeat steps 1-3 for each commit you modified. You'll know when to stop when the `git log` command shows a commit that's not authored by you. -5. Squash your changes into the existing commits: `git rebase --autosquash -i upstream/master` +5. Squash your changes into the existing commits: `git rebase --autosquash -i upstream/main` 6. [Push your changes](#standard-process). ### I see "error: cannot rebase" when I try to rebase @@ -197,7 +197,7 @@ and just want to get a clean copy of the repository back, you can use `git reset ```console # WARNING: this throws out any local changes you've made! Consider resolving the conflicts instead. -git reset --hard master +git reset --hard main ``` ### failed to push some refs @@ -222,12 +222,12 @@ rebase! Use `git push --force-with-lease` instead. If you see many commits in your rebase list, or merge commits, or commits by other people that you didn't write, it likely means you're trying to rebase over the wrong branch. For example, you may -have a `rust-lang/rust` remote `upstream`, but ran `git rebase origin/master` instead of `git rebase -upstream/master`. The fix is to abort the rebase and use the correct branch instead: +have a `rust-lang/rust` remote `upstream`, but ran `git rebase origin/main` instead of `git rebase +upstream/main`. The fix is to abort the rebase and use the correct branch instead: ```console git rebase --abort -git rebase -i upstream/master +git rebase -i upstream/main ```
Click here to see an example of rebasing over the wrong branch @@ -243,8 +243,8 @@ Git says you have modified some files that you have never edited. For example, running `git status` gives you something like (note the `new commits` mention): ```console -On branch master -Your branch is up to date with 'origin/master'. +On branch main +Your branch is up to date with 'origin/main'. Changes not staged for commit: (use "git add ..." to update what will be committed) @@ -277,11 +277,11 @@ merged. To do that, you need to rebase your work on top of rust-lang/rust. ### Rebasing -To rebase your feature branch on top of the newest version of the master branch +To rebase your feature branch on top of the newest version of the `main` branch of rust-lang/rust, checkout your branch, and then run this command: ```console -git pull --rebase https://github.com/rust-lang/rust.git master +git pull --rebase https://github.com/rust-lang/rust.git main ``` > If you are met with the following error: @@ -293,10 +293,10 @@ git pull --rebase https://github.com/rust-lang/rust.git master > case, run `git stash` before rebasing, and then `git stash pop` after you > have rebased and fixed all conflicts. -When you rebase a branch on master, all the changes on your branch are -reapplied to the most recent version of master. In other words, Git tries to -pretend that the changes you made to the old version of master were instead -made to the new version of master. During this process, you should expect to +When you rebase a branch on main, all the changes on your branch are +reapplied to the most recent version of `main`. In other words, Git tries to +pretend that the changes you made to the old version of `main` were instead +made to the new version of `main`. During this process, you should expect to encounter at least one "rebase conflict." This happens when Git's attempt to reapply the changes fails because your changes conflicted with other changes that have been made. You can tell that this happened because you'll see @@ -318,9 +318,9 @@ Your code This represents the lines in the file that Git could not figure out how to rebase. The section between `<<<<<<< HEAD` and `=======` has the code from -master, while the other side has your version of the code. You'll need to +`main`, while the other side has your version of the code. You'll need to decide how to deal with the conflict. You may want to keep your changes, -keep the changes on master, or combine the two. +keep the changes on `main`, or combine the two. Generally, resolving the conflict consists of two steps: First, fix the particular conflict. Edit the file to make the changes you want and remove the @@ -343,15 +343,15 @@ guide on rebasing work and dealing with merge conflicts. Here is some general advice about how to keep your local repo up-to-date with upstream changes: -Using `git pull upstream master` while on your local master branch regularly +Using `git pull upstream main` while on your local `main` branch regularly will keep it up-to-date. You will also want to keep your feature branches up-to-date as well. After pulling, you can checkout the feature branches and rebase them: ```console -git checkout master -git pull upstream master --ff-only # to make certain there are no merge commits -git rebase master feature_branch +git checkout main +git pull upstream main --ff-only # to make certain there are no merge commits +git rebase main feature_branch git push --force-with-lease # (set origin to be the same as local) ``` @@ -360,7 +360,7 @@ To avoid merges as per the [No-Merge Policy](#no-merge-policy), you may want to to ensure that Git doesn't create merge commits when `git pull`ing, without needing to pass `--ff-only` or `--rebase` every time. -You can also `git push --force-with-lease` from master to double-check that your +You can also `git push --force-with-lease` from main to double-check that your feature branches are in sync with their state on the Github side. ## Advanced Rebasing @@ -373,14 +373,14 @@ On the one hand, you lose track of the steps in which changes were made, but the history becomes easier to work with. If there are no conflicts and you are just squashing to clean up the history, -use `git rebase --interactive --keep-base master`. This keeps the fork point +use `git rebase --interactive --keep-base main`. This keeps the fork point of your PR the same, making it easier to review the diff of what happened across your rebases. Squashing can also be useful as part of conflict resolution. If your branch contains multiple consecutive rewrites of the same code, or if the rebase conflicts are extremely severe, you can use -`git rebase --interactive master` to gain more control over the process. This +`git rebase --interactive main` to gain more control over the process. This allows you to choose to skip commits, edit the commits that you do not skip, change the order in which they are applied, or "squash" them into each other. @@ -388,8 +388,8 @@ Alternatively, you can sacrifice the commit history like this: ```console # squash all the changes into one commit so you only have to worry about conflicts once -git rebase -i --keep-base master # and squash all changes along the way -git rebase master +git rebase -i --keep-base main # and squash all changes along the way +git rebase main # fix all merge conflicts git rebase --continue ``` @@ -402,9 +402,9 @@ because they only represent "fixups" and not real changes. For example, After completing a rebase, and before pushing up your changes, you may want to review the changes between your old branch and your new one. You can do that -with `git range-diff master @{upstream} HEAD`. +with `git range-diff main @{upstream} HEAD`. -The first argument to `range-diff`, `master` in this case, is the base revision +The first argument to `range-diff`, `main` in this case, is the base revision that you're comparing your old and new branch against. The second argument is the old version of your branch; in this case, `@upstream` means the version that you've pushed to GitHub, which is the same as what people will see in your pull @@ -413,7 +413,7 @@ your branch; in this case, it is `HEAD`, which is the commit that is currently checked-out in your local repo. Note that you can also use the equivalent, abbreviated form `git range-diff -master @{u} HEAD`. +main @{u} HEAD`. Unlike in regular Git diffs, you'll see a `-` or `+` next to another `-` or `+` in the range-diff output. The marker on the left indicates a change between the @@ -481,7 +481,7 @@ to follow and understand. ### Hiding whitespace Github has a button for disabling whitespace changes that may be useful. -You can also use `git diff -w origin/master` to view changes locally. +You can also use `git diff -w origin/main` to view changes locally. ![hide whitespace](./img/github-whitespace-changes.png) diff --git a/src/doc/rustc-dev-guide/src/tests/adding.md b/src/doc/rustc-dev-guide/src/tests/adding.md index b02d8a0f0207..ebbbb1cfc0d3 100644 --- a/src/doc/rustc-dev-guide/src/tests/adding.md +++ b/src/doc/rustc-dev-guide/src/tests/adding.md @@ -1,7 +1,7 @@ # Adding new tests **In general, we expect every PR that fixes a bug in rustc to come accompanied -by a regression test of some kind.** This test should fail in master but pass +by a regression test of some kind.** This test should fail in `main` but pass after the PR. These tests are really useful for preventing us from repeating the mistakes of the past. diff --git a/src/doc/rustc-dev-guide/src/tests/ci.md b/src/doc/rustc-dev-guide/src/tests/ci.md index e41893a15f12..a30af309a54e 100644 --- a/src/doc/rustc-dev-guide/src/tests/ci.md +++ b/src/doc/rustc-dev-guide/src/tests/ci.md @@ -1,6 +1,6 @@ # Testing with CI -The primary goal of our CI system is to ensure that the `master` branch of +The primary goal of our CI system is to ensure that the `main` branch of `rust-lang/rust` is always in a valid state by passing our test suite. From a high-level point of view, when you open a pull request at @@ -16,7 +16,7 @@ From a high-level point of view, when you open a pull request at combines multiple PRs together, to reduce CI costs and merge delays. - Once the whole test suite finishes, two things can happen. Either CI fails with an error that needs to be addressed by the developer, or CI succeeds and - the merge commit is then pushed to the `master` branch. + the merge commit is then pushed to the `main` branch. If you want to modify what gets executed on CI, see [Modifying CI jobs](#modifying-ci-jobs). @@ -93,7 +93,7 @@ directly on the PR, in the "CI checks" section at the bottom of the PR page. ### Auto builds -Before a commit can be merged into the `master` branch, it needs to pass our complete test suite. +Before a commit can be merged into the `main` branch, it needs to pass our complete test suite. We call this an `auto` build. This build runs tens of CI jobs that exercise various tests across operating systems and targets. The full test suite is quite slow; @@ -169,7 +169,7 @@ the `@bors jobs=` parameter. The job pattern needs to match one or more jobs defined in the `auto` or `optional` sections of [`jobs.yml`]: -- `auto` jobs are executed before a commit is merged into the `master` branch. +- `auto` jobs are executed before a commit is merged into the `main` branch. - `optional` jobs are executed only when explicitly requested via a try build. They are typically used for tier 2 and tier 3 targets. @@ -275,12 +275,12 @@ one or two should be sufficient in most cases. ## Merging PRs serially with bors CI services usually test the last commit of a branch merged with the last commit -in `master`, and while that’s great to check if the feature works in isolation, +in `main`, and while that’s great to check if the feature works in isolation, it doesn’t provide any guarantee the code is going to work once it’s merged. Breakages like these usually happen when another, incompatible PR is merged after the build happened. -To ensure a `master` branch that works all the time, we forbid manual merges. +To ensure a `main` branch that works all the time, we forbid manual merges. Instead, all PRs have to be approved through our bot, [bors] (the software behind it is called [homu]). All the approved PRs are put in a [merge queue] @@ -293,8 +293,8 @@ merge commit it wants to test to specific branches (like `auto` or `try`), which are configured to execute CI checks. Bors then detects the outcome of the build by listening for either Commit Statuses or Check Runs. Since the merge commit is -based on the latest `master` and only one can be tested at the same time, when -the results are green, `master` is fast-forwarded to that merge commit. +based on the latest `main` and only one can be tested at the same time, when +the results are green, `main` is fast-forwarded to that merge commit. Unfortunately, testing a single PR at a time, combined with our long CI (~2 hours for a full run), means we can’t merge a lot of PRs in a single day, and a @@ -364,7 +364,7 @@ caching], with the intermediate artifacts being stored on [ghcr.io]. We also push the built Docker images to ghcr, so that they can be reused by other tools (rustup) or by developers running the Docker build locally (to speed up their build). -Since we test multiple, diverged branches (`master`, `beta` and `stable`), we +Since we test multiple, diverged branches (`main`, `beta` and `stable`), we can’t rely on a single cache for the images, otherwise builds on a branch would override the cache for the others. Instead, we store the images under different From f6bc9d5c0592e5c31b7b2bc8b202b2e80a7ebb53 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 12 Nov 2025 19:05:33 +0200 Subject: [PATCH 027/194] some updates and improvements ... inspired from downstream default branch name change --- src/doc/rustc-dev-guide/src/contributing.md | 2 +- src/doc/rustc-dev-guide/src/conventions.md | 2 +- src/doc/rustc-dev-guide/src/external-repos.md | 2 +- src/doc/rustc-dev-guide/src/getting-started.md | 2 +- src/doc/rustc-dev-guide/src/git.md | 4 ++-- .../src/rustdoc-internals/rustdoc-gui-test-suite.md | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md index 1b4f04dbb5ef..8c764c31dbfa 100644 --- a/src/doc/rustc-dev-guide/src/contributing.md +++ b/src/doc/rustc-dev-guide/src/contributing.md @@ -153,7 +153,7 @@ We have [a chapter](git.md) on how to use Git when contributing to Rust. ### Keeping your branch up-to-date -The CI in rust-lang/rust applies your patches directly against the current `main`, +The CI in rust-lang/rust applies your patches directly against current `main`, not against the commit your branch is based on. This can lead to unexpected failures if your branch is outdated, even when there are no explicit merge conflicts. diff --git a/src/doc/rustc-dev-guide/src/conventions.md b/src/doc/rustc-dev-guide/src/conventions.md index 4356cf246f89..cce1d1850694 100644 --- a/src/doc/rustc-dev-guide/src/conventions.md +++ b/src/doc/rustc-dev-guide/src/conventions.md @@ -165,7 +165,7 @@ individually using `./x fmt`. **No merges.** We do not allow merge commits into our history, other than those by bors. If you get a merge conflict, rebase instead via a -command like `git rebase -i rust-lang/master` (presuming you use the +command like `git rebase --interactive rust-lang/main` (presuming you use the name `rust-lang` for your remote). **Individual commits do not have to build (but it's nice).** We do not diff --git a/src/doc/rustc-dev-guide/src/external-repos.md b/src/doc/rustc-dev-guide/src/external-repos.md index 6c38b3dc5e20..d2b4e791df0e 100644 --- a/src/doc/rustc-dev-guide/src/external-repos.md +++ b/src/doc/rustc-dev-guide/src/external-repos.md @@ -114,7 +114,7 @@ A `subtree pull` takes all changes since the last `subtree pull` from the tool repo and adds these commits to the rustc repo along with a merge commit that moves the tool changes into the specified directory in the Rust repository. -It is recommended that you always do a push first and get that merged to the tool `main`/`master` branch. +It is recommended that you always do a push first and get that merged to the default branch of the tool. Then, when you do a pull, the merge works without conflicts. While it's definitely possible to resolve conflicts during a pull, you may have to redo the conflict resolution if your PR doesn't get merged fast enough and there are new conflicts. Do not try to diff --git a/src/doc/rustc-dev-guide/src/getting-started.md b/src/doc/rustc-dev-guide/src/getting-started.md index 64abd94c69e2..34bc5b59dd03 100644 --- a/src/doc/rustc-dev-guide/src/getting-started.md +++ b/src/doc/rustc-dev-guide/src/getting-started.md @@ -140,7 +140,7 @@ You can find the list of such PRs [here][abandoned-prs]. If the PR has been implemented in some other way in the meantime, the `S-inactive` label should be removed from it. If not, and it seems that there is still interest in the change, -you can try to rebase the pull request on top of the latest `master` branch and send a new +you can try to rebase the pull request on top of the latest `main` branch and send a new pull request, continuing the work on the feature. [abandoned-prs]: https://github.com/rust-lang/rust/pulls?q=is%3Apr+label%3AS-inactive+is%3Aclosed diff --git a/src/doc/rustc-dev-guide/src/git.md b/src/doc/rustc-dev-guide/src/git.md index a01a156fa64c..e7e84e2ea7f5 100644 --- a/src/doc/rustc-dev-guide/src/git.md +++ b/src/doc/rustc-dev-guide/src/git.md @@ -227,7 +227,7 @@ upstream/main`. The fix is to abort the rebase and use the correct branch instea ```console git rebase --abort -git rebase -i upstream/main +git rebase --interactive upstream/main ```
Click here to see an example of rebasing over the wrong branch @@ -388,7 +388,7 @@ Alternatively, you can sacrifice the commit history like this: ```console # squash all the changes into one commit so you only have to worry about conflicts once -git rebase -i --keep-base main # and squash all changes along the way +git rebase --interactive --keep-base main # and squash all changes along the way git rebase main # fix all merge conflicts git rebase --continue diff --git a/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-gui-test-suite.md b/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-gui-test-suite.md index 419f03d020a8..d18021bf278d 100644 --- a/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-gui-test-suite.md +++ b/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-gui-test-suite.md @@ -11,4 +11,4 @@ These use a NodeJS-based tool called [`browser-UI-test`] that uses [puppeteer] t [`browser-UI-test`]: https://github.com/GuillaumeGomez/browser-UI-test/ [puppeteer]: https://pptr.dev/ [rustdoc-gui-readme]: https://github.com/rust-lang/rust/blob/HEAD/tests/rustdoc-gui/README.md -[goml-script]: https://github.com/GuillaumeGomez/browser-UI-test/blob/master/goml-script.md +[goml-script]: https://github.com/GuillaumeGomez/browser-UI-test/blob/main/goml-script.md From 7b0c21815a506e1887e7fe3637e25676b0b83c57 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 12 Nov 2025 19:29:24 +0200 Subject: [PATCH 028/194] sembr implementing_new_features.md --- .../src/implementing_new_features.md | 66 ++++++++++++++----- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/implementing_new_features.md b/src/doc/rustc-dev-guide/src/implementing_new_features.md index 00bce8599e43..b8d0520bf090 100644 --- a/src/doc/rustc-dev-guide/src/implementing_new_features.md +++ b/src/doc/rustc-dev-guide/src/implementing_new_features.md @@ -11,17 +11,25 @@ See also [the Rust Language Design Team's procedures][lang-propose] for proposin ## The @rfcbot FCP process -When the change is small, uncontroversial, non-breaking, and does not affect the stable language in any user-observable ways or add any new unstable features, then it can be done with just writing a PR and getting an r+ from someone who knows that part of the code. However, if not, more must be done. Even for compiler-internal work, it would be a bad idea to push a controversial change without consensus from the rest of the team (both in the "distributed system" sense to make sure you don't break anything you don't know about, and in the social sense to avoid PR fights). +When the change is small, uncontroversial, non-breaking, and does not affect the stable language in any user-observable ways or add any new unstable features, then it can be done with just writing a PR and getting an r+ from someone who knows that part of the code. +However, if not, more must be done. +Even for compiler-internal work, it would be a bad idea to push a controversial change without consensus from the rest of the team (both in the "distributed system" sense to make sure you don't break anything you don't know about, and in the social sense to avoid PR fights). -For changes that need the consensus of a team, we us the process of proposing a final comment period (FCP). If you're not on the relevant team (and thus don't have @rfcbot permissions), ask someone who is to start one; unless they have a concern themselves, they should. +For changes that need the consensus of a team, we us the process of proposing a final comment period (FCP). +If you're not on the relevant team (and thus don't have @rfcbot permissions), ask someone who is to start one; +unless they have a concern themselves, they should. -The FCP process is only needed if you need consensus – if no processes require consensus for your change and you don't think anyone would have a problem with it, it's OK to rely on only an r+. For example, it is OK to add or modify unstable command-line flags or attributes in the reserved compiler-internal `rustc_` namespace without an FCP for compiler development or standard library use, as long as you don't expect them to be in wide use in the nightly ecosystem. Some teams have lighter weight processes that they use in scenarios like this; for example, the compiler team recommends filing a Major Change Proposal ([MCP][mcp]) as a lightweight way to garner support and feedback without requiring full consensus. +The FCP process is only needed if you need consensus – if no processes require consensus for your change and you don't think anyone would have a problem with it, it's OK to rely on only an r+. +For example, it is OK to add or modify unstable command-line flags or attributes in the reserved compiler-internal `rustc_` namespace without an FCP for compiler development or standard library use, as long as you don't expect them to be in wide use in the nightly ecosystem. +Some teams have lighter weight processes that they use in scenarios like this; +for example, the compiler team recommends filing a Major Change Proposal ([MCP][mcp]) as a lightweight way to garner support and feedback without requiring full consensus. [mcp]: https://forge.rust-lang.org/compiler/proposals-and-stabilization.html#how-do-i-submit-an-mcp You don't need to have the implementation fully ready for r+ to propose an FCP, but it is generally a good idea to have at least a proof of concept so that people can see what you are talking about. -When an FCP is proposed, it requires all members of the team to sign off on the FCP. After they all do so, there's a 10-day-long "final comment period" (hence the name) where everybody can comment, and if no concerns are raised, the PR/issue gets FCP approval. +When an FCP is proposed, it requires all members of the team to sign off on the FCP. +After they all do so, there's a 10-day-long "final comment period" (hence the name) where everybody can comment, and if no concerns are raised, the PR/issue gets FCP approval. ## The logistics of writing features @@ -29,27 +37,36 @@ There are a few "logistical" hoops you might need to go through in order to impl ### Warning Cycles -In some cases, a feature or bugfix might break some existing programs in some edge cases. In that case, you'll want to do a crater run to assess the impact and possibly add a future-compatibility lint, similar to those used for [edition-gated lints](diagnostics.md#edition-gated-lints). +In some cases, a feature or bugfix might break some existing programs in some edge cases. +In that case, you'll want to do a crater run to assess the impact and possibly add a future-compatibility lint, similar to those used for [edition-gated lints](diagnostics.md#edition-gated-lints). ### Stability -We [value the stability of Rust]. Code that works and runs on stable should (mostly) not break. Because of that, we don't want to release a feature to the world with only team consensus and code review - we want to gain real-world experience on using that feature on nightly, and we might want to change the feature based on that experience. +We [value the stability of Rust]. +Code that works and runs on stable should (mostly) not break. +Because of that, we don't want to release a feature to the world with only team consensus and code review - we want to gain real-world experience on using that feature on nightly, and we might want to change the feature based on that experience. To allow for that, we must make sure users don't accidentally depend on that new feature - otherwise, especially if experimentation takes time or is delayed and the feature takes the trains to stable, it would end up de facto stable and we'll not be able to make changes in it without breaking people's code. -The way we do that is that we make sure all new features are feature gated - they can't be used without enabling a feature gate (`#[feature(foo)]`), which can't be done in a stable/beta compiler. See the [stability in code] section for the technical details. +The way we do that is that we make sure all new features are feature gated - they can't be used without enabling a feature gate (`#[feature(foo)]`), which can't be done in a stable/beta compiler. +See the [stability in code] section for the technical details. -Eventually, after we gain enough experience using the feature, make the necessary changes, and are satisfied, we expose it to the world using the stabilization process described [here]. Until then, the feature is not set in stone: every part of the feature can be changed, or the feature might be completely rewritten or removed. Features do not gain tenure by being unstable and unchanged for long periods of time. +Eventually, after we gain enough experience using the feature, make the necessary changes, and are satisfied, we expose it to the world using the stabilization process described [here]. +Until then, the feature is not set in stone: every part of the feature can be changed, or the feature might be completely rewritten or removed. +Features do not gain tenure by being unstable and unchanged for long periods of time. ### Tracking Issues To keep track of the status of an unstable feature, the experience we get while using it on nightly, and of the concerns that block its stabilization, every feature-gate needs a tracking -issue. When creating issues and PRs related to the feature, reference this tracking issue, and when there are updates about the feature's progress, post those to the tracking issue. +issue. +When creating issues and PRs related to the feature, reference this tracking issue, and when there are updates about the feature's progress, post those to the tracking issue. For features that are part of an accept RFC or approved lang experiment, use the tracking issue for that. -For other features, create a tracking issue for that feature. The issue title should be "Tracking issue for YOUR FEATURE". Use the ["Tracking Issue" issue template][template]. +For other features, create a tracking issue for that feature. +The issue title should be "Tracking issue for YOUR FEATURE". +Use the ["Tracking Issue" issue template][template]. [template]: https://github.com/rust-lang/rust/issues/new?template=tracking_issue.md @@ -57,7 +74,10 @@ For other features, create a tracking issue for that feature. The issue title sh To land in the compiler, features that have user-visible effects on the language (even unstable ones) must either be part of an accepted RFC or an approved [lang experiment]. -To propose a new lang experiment, open an issue in `rust-lang/rust` that describes the motivation and the intended solution. If it's accepted, this issue will become the tracking issue for the experiment, so use the tracking issue [template] while also including these other details. Nominate the issue for the lang team and CC `@rust-lang/lang` and `@rust-lang/lang-advisors`. When the experiment is approved, the tracking issue will be marked as `B-experimental`. +To propose a new lang experiment, open an issue in `rust-lang/rust` that describes the motivation and the intended solution. +If it's accepted, this issue will become the tracking issue for the experiment, so use the tracking issue [template] while also including these other details. +Nominate the issue for the lang team and CC `@rust-lang/lang` and `@rust-lang/lang-advisors`. +When the experiment is approved, the tracking issue will be marked as `B-experimental`. Feature flags related to a lang experiment must be marked as `incomplete` until an RFC is accepted for the feature. @@ -110,11 +130,15 @@ The below steps needs to be followed in order to implement a new unstable featur 1. Prevent usage of the new feature unless the feature gate is set. You can check it in most places in the compiler using the expression `tcx.features().$feature_name()`. - If the feature gate is not set, you should either maintain the pre-feature behavior or raise an error, depending on what makes sense. Errors should generally use [`rustc_session::parse::feature_err`]. For an example of adding an error, see [#81015]. + If the feature gate is not set, you should either maintain the pre-feature behavior or raise an error, depending on what makes sense. + Errors should generally use [`rustc_session::parse::feature_err`]. + For an example of adding an error, see [#81015]. - For features introducing new syntax, pre-expansion gating should be used instead. During parsing, when the new syntax is parsed, the symbol must be inserted to the current crate's [`GatedSpans`] via `self.sess.gated_span.gate(sym::my_feature, span)`. + For features introducing new syntax, pre-expansion gating should be used instead. + During parsing, when the new syntax is parsed, the symbol must be inserted to the current crate's [`GatedSpans`] via `self.sess.gated_span.gate(sym::my_feature, span)`. - After being inserted to the gated spans, the span must be checked in the [`rustc_ast_passes::feature_gate::check_crate`] function, which actually denies features. Exactly how it is gated depends on the exact type of feature, but most likely will use the `gate_all!()` macro. + After being inserted to the gated spans, the span must be checked in the [`rustc_ast_passes::feature_gate::check_crate`] function, which actually denies features. + Exactly how it is gated depends on the exact type of feature, but most likely will use the `gate_all!()` macro. 1. Add a test to ensure the feature cannot be used without a feature gate, by creating `tests/ui/feature-gates/feature-gate-$feature_name.rs`. You can generate the corresponding `.stderr` file by running `./x test tests/ui/feature-gates/ --bless`. @@ -136,7 +160,8 @@ The below steps needs to be followed in order to implement a new unstable featur ## Call for testing -Once the implementation is complete, the feature will be available to nightly users but not yet part of stable Rust. This is a good time to write a blog post on [the main Rust blog][rust-blog] and issue a "call for testing". +Once the implementation is complete, the feature will be available to nightly users but not yet part of stable Rust. +This is a good time to write a blog post on [the main Rust blog][rust-blog] and issue a "call for testing". Some earlier such blog posts include: @@ -144,7 +169,8 @@ Some earlier such blog posts include: 2. [Changes to `impl Trait` in Rust 2024](https://blog.rust-lang.org/2024/09/05/impl-trait-capture-rules.html) 3. [Async Closures MVP: Call for Testing!](https://blog.rust-lang.org/inside-rust/2024/08/09/async-closures-call-for-testing/) -Alternatively, [*This Week in Rust*][twir] has a [section][twir-cft] for this. One example of this having been used is: +Alternatively, [*This Week in Rust*][twir] has a [section][twir-cft] for this. +One example of this having been used is: - [Call for testing on boolean literals as cfg predicates](https://github.com/rust-lang/rust/issues/131204#issuecomment-2569314526) @@ -152,7 +178,9 @@ Which option to choose might depend on how significant the language change is, t ## Polishing -Giving users a polished experience means more than just implementing the feature in rustc. We need to think about all of the tools and resources that we ship. This work includes: +Giving users a polished experience means more than just implementing the feature in rustc. +We need to think about all of the tools and resources that we ship. +This work includes: - Documenting the language feature in the [Rust Reference][reference]. - Extending [`rustfmt`] to format any new syntax (if applicable). @@ -162,7 +190,9 @@ Giving users a polished experience means more than just implementing the feature ## Stabilization -The final step in the feature lifecycle is [stabilization][stab], which is when the feature becomes available to all Rust users. At this point, backward incompatible changes are generally no longer permitted (see the lang team's [defined semver policies](https://rust-lang.github.io/rfcs/1122-language-semver.html) for details). To learn more about stabilization, see the [stabilization guide][stab]. +The final step in the feature lifecycle is [stabilization][stab], which is when the feature becomes available to all Rust users. +At this point, backward incompatible changes are generally no longer permitted (see the lang team's [defined semver policies](https://rust-lang.github.io/rfcs/1122-language-semver.html) for details). +To learn more about stabilization, see the [stabilization guide][stab]. [stab]: ./stabilization_guide.md From 4a845a60e3e7c09ac8844c1d07083c02ce171551 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 12 Nov 2025 19:50:43 +0200 Subject: [PATCH 029/194] typo --- src/doc/rustc-dev-guide/src/implementing_new_features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/implementing_new_features.md b/src/doc/rustc-dev-guide/src/implementing_new_features.md index b8d0520bf090..b45440ea3da8 100644 --- a/src/doc/rustc-dev-guide/src/implementing_new_features.md +++ b/src/doc/rustc-dev-guide/src/implementing_new_features.md @@ -15,7 +15,7 @@ When the change is small, uncontroversial, non-breaking, and does not affect the However, if not, more must be done. Even for compiler-internal work, it would be a bad idea to push a controversial change without consensus from the rest of the team (both in the "distributed system" sense to make sure you don't break anything you don't know about, and in the social sense to avoid PR fights). -For changes that need the consensus of a team, we us the process of proposing a final comment period (FCP). +For changes that need the consensus of a team, we use the process of proposing a final comment period (FCP). If you're not on the relevant team (and thus don't have @rfcbot permissions), ask someone who is to start one; unless they have a concern themselves, they should. From de3b0537d622f41a871176ccc16ef625aea7aaee Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 12 Nov 2025 19:51:28 +0200 Subject: [PATCH 030/194] add date marker --- src/doc/rustc-dev-guide/src/implementing_new_features.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/doc/rustc-dev-guide/src/implementing_new_features.md b/src/doc/rustc-dev-guide/src/implementing_new_features.md index b45440ea3da8..19babcceda1f 100644 --- a/src/doc/rustc-dev-guide/src/implementing_new_features.md +++ b/src/doc/rustc-dev-guide/src/implementing_new_features.md @@ -1,3 +1,5 @@ + + # Implementing new language features When you want to implement a new significant feature in the compiler, you need to go through this process to make sure everything goes smoothly. From 41e236a0df8d27dc9f28dba370d72bde612d073a Mon Sep 17 00:00:00 2001 From: Jacob Asper <78604367+20jasper@users.noreply.github.com> Date: Wed, 12 Nov 2025 15:26:05 -0500 Subject: [PATCH 031/194] Fix typo in comment in rustc_errors It seems "CharPose" was a typo since I couldn't find any references to it anywhere else in the codebase --- compiler/rustc_errors/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 2f88e587ae9f..82e265c32bfa 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -348,7 +348,7 @@ fn push_trailing( hi_opt: Option<&Loc>, ) -> usize { let mut line_count = 0; - // Convert CharPos to Usize, as CharPose is character offset + // Convert `CharPos` to `Usize`, as `CharPos` is character offset // Extract low index and high index let (lo, hi_opt) = (lo.col.to_usize(), hi_opt.map(|hi| hi.col.to_usize())); if let Some(line) = line_opt { From 407da40e932d6ab76cbeb7fdce6ba212958c6531 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 12 Nov 2025 22:52:39 +0200 Subject: [PATCH 032/194] reduce overlong physical lines --- .../src/implementing_new_features.md | 180 +++++++++++++----- 1 file changed, 130 insertions(+), 50 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/implementing_new_features.md b/src/doc/rustc-dev-guide/src/implementing_new_features.md index 19babcceda1f..88375446afef 100644 --- a/src/doc/rustc-dev-guide/src/implementing_new_features.md +++ b/src/doc/rustc-dev-guide/src/implementing_new_features.md @@ -2,9 +2,11 @@ # Implementing new language features -When you want to implement a new significant feature in the compiler, you need to go through this process to make sure everything goes smoothly. +When you want to implement a new significant feature in the compiler, +you need to go through this process to make sure everything goes smoothly. -**NOTE: This section is for *language* features, not *library* features, which use [a different process].** +**NOTE: This section is for *language* features, not *library* features, +which use [a different process].** See also [the Rust Language Design Team's procedures][lang-propose] for proposing changes to the language. @@ -13,58 +15,95 @@ See also [the Rust Language Design Team's procedures][lang-propose] for proposin ## The @rfcbot FCP process -When the change is small, uncontroversial, non-breaking, and does not affect the stable language in any user-observable ways or add any new unstable features, then it can be done with just writing a PR and getting an r+ from someone who knows that part of the code. +When the change is small, uncontroversial, non-breaking, +and does not affect the stable language in any user-observable ways or add any new unstable features, +then it can be done with just writing a PR and getting an r+ from someone who knows that part of the code. However, if not, more must be done. -Even for compiler-internal work, it would be a bad idea to push a controversial change without consensus from the rest of the team (both in the "distributed system" sense to make sure you don't break anything you don't know about, and in the social sense to avoid PR fights). +Even for compiler-internal work, +it would be a bad idea to push a controversial change without consensus from the rest of the team +(both in the "distributed system" sense to make sure you don't break anything you don't know about, +and in the social sense to avoid PR fights). -For changes that need the consensus of a team, we use the process of proposing a final comment period (FCP). -If you're not on the relevant team (and thus don't have @rfcbot permissions), ask someone who is to start one; +For changes that need the consensus of a team, +we use the process of proposing a final comment period (FCP). +If you're not on the relevant team (and thus don't have @rfcbot permissions), +ask someone who is to start one; unless they have a concern themselves, they should. -The FCP process is only needed if you need consensus – if no processes require consensus for your change and you don't think anyone would have a problem with it, it's OK to rely on only an r+. -For example, it is OK to add or modify unstable command-line flags or attributes in the reserved compiler-internal `rustc_` namespace without an FCP for compiler development or standard library use, as long as you don't expect them to be in wide use in the nightly ecosystem. +The FCP process is only needed if you need consensus – +if no processes require consensus for your change +and you don't think anyone would have a problem with it, it's OK to rely on only an r+. +For example, +it is OK to add or modify unstable command-line flags +or attributes in the reserved compiler-internal `rustc_` namespace +without an FCP for compiler development or standard library use, +as long as you don't expect them to be in wide use in the nightly ecosystem. Some teams have lighter weight processes that they use in scenarios like this; -for example, the compiler team recommends filing a Major Change Proposal ([MCP][mcp]) as a lightweight way to garner support and feedback without requiring full consensus. +for example, +the compiler team recommends filing a Major Change Proposal ([MCP][mcp]) +as a lightweight way to garner support and feedback without requiring full consensus. [mcp]: https://forge.rust-lang.org/compiler/proposals-and-stabilization.html#how-do-i-submit-an-mcp -You don't need to have the implementation fully ready for r+ to propose an FCP, but it is generally a good idea to have at least a proof of concept so that people can see what you are talking about. +You don't need to have the implementation fully ready for r+ to propose an FCP, +but it is generally a good idea to have at least a proof of concept +so that people can see what you are talking about. When an FCP is proposed, it requires all members of the team to sign off on the FCP. -After they all do so, there's a 10-day-long "final comment period" (hence the name) where everybody can comment, and if no concerns are raised, the PR/issue gets FCP approval. +After they all do so, +there's a 10-day-long "final comment period" (hence the name) where everybody can comment, +and if no concerns are raised, the PR/issue gets FCP approval. ## The logistics of writing features -There are a few "logistical" hoops you might need to go through in order to implement a feature in a working way. +There are a few "logistical" hoops you might need to go through +in order to implement a feature in a working way. ### Warning Cycles In some cases, a feature or bugfix might break some existing programs in some edge cases. -In that case, you'll want to do a crater run to assess the impact and possibly add a future-compatibility lint, similar to those used for [edition-gated lints](diagnostics.md#edition-gated-lints). +In that case, +you'll want to do a crater run to assess the impact and possibly add a future-compatibility lint, +similar to those used for [edition-gated lints](diagnostics.md#edition-gated-lints). ### Stability We [value the stability of Rust]. Code that works and runs on stable should (mostly) not break. -Because of that, we don't want to release a feature to the world with only team consensus and code review - we want to gain real-world experience on using that feature on nightly, and we might want to change the feature based on that experience. +Because of that, +we don't want to release a feature to the world with only team consensus and code review - +we want to gain real-world experience on using that feature on nightly, +and we might want to change the feature based on that experience. -To allow for that, we must make sure users don't accidentally depend on that new feature - otherwise, especially if experimentation takes time or is delayed and the feature takes the trains to stable, it would end up de facto stable and we'll not be able to make changes in it without breaking people's code. +To allow for that, +we must make sure users don't accidentally depend on that new feature - +otherwise, +especially if experimentation takes time or is delayed and the feature takes the trains to stable, +it would end up de facto stable +and we'll not be able to make changes in it without breaking people's code. -The way we do that is that we make sure all new features are feature gated - they can't be used without enabling a feature gate (`#[feature(foo)]`), which can't be done in a stable/beta compiler. +The way we do that is that we make sure all new features are feature gated - +they can't be used without enabling a feature gate (`#[feature(foo)]`), +which can't be done in a stable/beta compiler. See the [stability in code] section for the technical details. -Eventually, after we gain enough experience using the feature, make the necessary changes, and are satisfied, we expose it to the world using the stabilization process described [here]. -Until then, the feature is not set in stone: every part of the feature can be changed, or the feature might be completely rewritten or removed. +Eventually, after we gain enough experience using the feature, make the necessary changes, +and are satisfied, we expose it to the world using the stabilization process described [here]. +Until then, the feature is not set in stone: +every part of the feature can be changed, or the feature might be completely rewritten or removed. Features do not gain tenure by being unstable and unchanged for long periods of time. ### Tracking Issues -To keep track of the status of an unstable feature, the experience we get while using it on -nightly, and of the concerns that block its stabilization, every feature-gate needs a tracking -issue. -When creating issues and PRs related to the feature, reference this tracking issue, and when there are updates about the feature's progress, post those to the tracking issue. +To keep track of the status of an unstable feature, +the experience we get while using it on nightly, +and of the concerns that block its stabilization, +every feature-gate needs a tracking issue. +When creating issues and PRs related to the feature, reference this tracking issue, +and when there are updates about the feature's progress, post those to the tracking issue. -For features that are part of an accept RFC or approved lang experiment, use the tracking issue for that. +For features that are part of an accept RFC or approved lang experiment, +use the tracking issue for that. For other features, create a tracking issue for that feature. The issue title should be "Tracking issue for YOUR FEATURE". @@ -74,14 +113,19 @@ Use the ["Tracking Issue" issue template][template]. ### Lang experiments -To land in the compiler, features that have user-visible effects on the language (even unstable ones) must either be part of an accepted RFC or an approved [lang experiment]. +To land in the compiler, +features that have user-visible effects on the language (even unstable ones) +must either be part of an accepted RFC or an approved [lang experiment]. -To propose a new lang experiment, open an issue in `rust-lang/rust` that describes the motivation and the intended solution. -If it's accepted, this issue will become the tracking issue for the experiment, so use the tracking issue [template] while also including these other details. +To propose a new lang experiment, +open an issue in `rust-lang/rust` that describes the motivation and the intended solution. +If it's accepted, this issue will become the tracking issue for the experiment, +so use the tracking issue [template] while also including these other details. Nominate the issue for the lang team and CC `@rust-lang/lang` and `@rust-lang/lang-advisors`. When the experiment is approved, the tracking issue will be marked as `B-experimental`. -Feature flags related to a lang experiment must be marked as `incomplete` until an RFC is accepted for the feature. +Feature flags related to a lang experiment must be marked as `incomplete` +until an RFC is accepted for the feature. [lang experiment]: https://lang-team.rust-lang.org/how_to/experiment.html @@ -89,9 +133,12 @@ Feature flags related to a lang experiment must be marked as `incomplete` until The below steps needs to be followed in order to implement a new unstable feature: -1. Open or identify the [tracking issue]. For features that are part of an accept RFC or approved lang experiment, use the tracking issue for that. +1. Open or identify the [tracking issue]. + For features that are part of an accept RFC or approved lang experiment, + use the tracking issue for that. - Label the tracking issue with `C-tracking-issue` and the relevant `F-feature_name` label (adding that label if needed). + Label the tracking issue with `C-tracking-issue` and the relevant `F-feature_name` label + (adding that label if needed). 1. Pick a name for the feature gate (for RFCs, use the name in the RFC). @@ -99,14 +146,17 @@ The below steps needs to be followed in order to implement a new unstable featur Note that this block must be in alphabetical order. -1. Add a feature gate declaration to `rustc_feature/src/unstable.rs` in the unstable `declare_features` block. +1. Add a feature gate declaration to `rustc_feature/src/unstable.rs` + in the unstable `declare_features` block. ```rust ignore /// description of feature (unstable, $feature_name, "CURRENT_RUSTC_VERSION", Some($tracking_issue_number)) ``` - If you haven't yet opened a tracking issue (e.g. because you want initial feedback on whether the feature is likely to be accepted), you can temporarily use `None` - but make sure to update it before the PR is merged! + If you haven't yet opened a tracking issue + (e.g. because you want initial feedback on whether the feature is likely to be accepted), + you can temporarily use `None` - but make sure to update it before the PR is merged! For example: @@ -115,7 +165,9 @@ The below steps needs to be followed in order to implement a new unstable featur (unstable, non_ascii_idents, "CURRENT_RUSTC_VERSION", Some(55467), None), ``` - Features can be marked as incomplete, and trigger the warn-by-default [`incomplete_features` lint] by setting their type to `incomplete`: + Features can be marked as incomplete, + and trigger the warn-by-default [`incomplete_features` lint] + by setting their type to `incomplete`: [`incomplete_features` lint]: https://doc.rust-lang.org/rustc/lints/listing/warn-by-default.html#incomplete-features @@ -124,29 +176,45 @@ The below steps needs to be followed in order to implement a new unstable featur (incomplete, deref_patterns, "CURRENT_RUSTC_VERSION", Some(87121), None), ``` - Feature flags related to a lang experiment must be marked as `incomplete` until an RFC is accepted for the feature. + Feature flags related to a lang experiment must be marked as `incomplete` + until an RFC is accepted for the feature. - To avoid [semantic merge conflicts], use `CURRENT_RUSTC_VERSION` instead of `1.70` or another explicit version number. + To avoid [semantic merge conflicts], + use `CURRENT_RUSTC_VERSION` instead of `1.70` or another explicit version number. [semantic merge conflicts]: https://bors.tech/essay/2017/02/02/pitch/ -1. Prevent usage of the new feature unless the feature gate is set. You can check it in most places in the compiler using the expression `tcx.features().$feature_name()`. +1. Prevent usage of the new feature unless the feature gate is set. + You can check it in most places in the compiler + using the expression `tcx.features().$feature_name()`. - If the feature gate is not set, you should either maintain the pre-feature behavior or raise an error, depending on what makes sense. + If the feature gate is not set, + you should either maintain the pre-feature behavior or raise an error, + depending on what makes sense. Errors should generally use [`rustc_session::parse::feature_err`]. For an example of adding an error, see [#81015]. For features introducing new syntax, pre-expansion gating should be used instead. - During parsing, when the new syntax is parsed, the symbol must be inserted to the current crate's [`GatedSpans`] via `self.sess.gated_span.gate(sym::my_feature, span)`. + During parsing, when the new syntax is parsed, + the symbol must be inserted to the current crate's [`GatedSpans`] + via `self.sess.gated_span.gate(sym::my_feature, span)`. - After being inserted to the gated spans, the span must be checked in the [`rustc_ast_passes::feature_gate::check_crate`] function, which actually denies features. - Exactly how it is gated depends on the exact type of feature, but most likely will use the `gate_all!()` macro. + After being inserted to the gated spans, + the span must be checked in the [`rustc_ast_passes::feature_gate::check_crate`] function, + which actually denies features. + Exactly how it is gated depends on the exact type of feature, + but most likely will use the `gate_all!()` macro. -1. Add a test to ensure the feature cannot be used without a feature gate, by creating `tests/ui/feature-gates/feature-gate-$feature_name.rs`. You can generate the corresponding `.stderr` file by running `./x test tests/ui/feature-gates/ --bless`. +1. Add a test to ensure the feature cannot be used without a feature gate, + by creating `tests/ui/feature-gates/feature-gate-$feature_name.rs`. + You can generate the corresponding `.stderr` file + by running `./x test tests/ui/feature-gates/ --bless`. -1. Add a section to the unstable book, in `src/doc/unstable-book/src/language-features/$feature_name.md`. +1. Add a section to the unstable book, + in `src/doc/unstable-book/src/language-features/$feature_name.md`. -1. Write a lot of tests for the new feature, preferably in `tests/ui/$feature_name/`. PRs without tests will not be accepted! +1. Write a lot of tests for the new feature, preferably in `tests/ui/$feature_name/`. + PRs without tests will not be accepted! 1. Get your PR reviewed and land it. You have now successfully implemented a feature in Rust! @@ -162,8 +230,10 @@ The below steps needs to be followed in order to implement a new unstable featur ## Call for testing -Once the implementation is complete, the feature will be available to nightly users but not yet part of stable Rust. -This is a good time to write a blog post on [the main Rust blog][rust-blog] and issue a "call for testing". +Once the implementation is complete, +the feature will be available to nightly users but not yet part of stable Rust. +This is a good time to write a blog post on [the main Rust blog][rust-blog] +and issue a "call for testing". Some earlier such blog posts include: @@ -176,7 +246,9 @@ One example of this having been used is: - [Call for testing on boolean literals as cfg predicates](https://github.com/rust-lang/rust/issues/131204#issuecomment-2569314526) -Which option to choose might depend on how significant the language change is, though note that the [*This Week in Rust*][twir] section might be less visible than a dedicated post on the main Rust blog. +Which option to choose might depend on how significant the language change is, +though note that the [*This Week in Rust*][twir] section might be less visible +than a dedicated post on the main Rust blog. ## Polishing @@ -186,14 +258,22 @@ This work includes: - Documenting the language feature in the [Rust Reference][reference]. - Extending [`rustfmt`] to format any new syntax (if applicable). -- Extending [`rust-analyzer`] (if applicable). The extent of this work can depend on the nature of the language feature, as some features don't need to be blocked on *full* support. - - When a language feature degrades the user experience simply by existing before support is implemented in [`rust-analyzer`], that may lead the lang team to raise a blocking concern. - - Examples of such might include new syntax that [`rust-analyzer`] can't parse or type inference changes it doesn't understand when those lead to bogus diagnostics. +- Extending [`rust-analyzer`] (if applicable). + The extent of this work can depend on the nature of the language feature, + as some features don't need to be blocked on *full* support. + - When a language feature degrades the user experience + simply by existing before support is implemented in [`rust-analyzer`], + that may lead the lang team to raise a blocking concern. + - Examples of such might include new syntax that [`rust-analyzer`] can't parse + or type inference changes it doesn't understand when those lead to bogus diagnostics. ## Stabilization -The final step in the feature lifecycle is [stabilization][stab], which is when the feature becomes available to all Rust users. -At this point, backward incompatible changes are generally no longer permitted (see the lang team's [defined semver policies](https://rust-lang.github.io/rfcs/1122-language-semver.html) for details). +The final step in the feature lifecycle is [stabilization][stab], +which is when the feature becomes available to all Rust users. +At this point, +backward incompatible changes are generally no longer permitted +(see the lang team's [defined semver policies](https://rust-lang.github.io/rfcs/1122-language-semver.html) for details). To learn more about stabilization, see the [stabilization guide][stab]. From 0f497cea9a891cd85953aa1968bf0b6f31aaf258 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 12 Nov 2025 23:06:49 +0200 Subject: [PATCH 033/194] needless repetition --- src/doc/rustc-dev-guide/src/implementing_new_features.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/implementing_new_features.md b/src/doc/rustc-dev-guide/src/implementing_new_features.md index 88375446afef..c3e8c0c06623 100644 --- a/src/doc/rustc-dev-guide/src/implementing_new_features.md +++ b/src/doc/rustc-dev-guide/src/implementing_new_features.md @@ -40,10 +40,10 @@ without an FCP for compiler development or standard library use, as long as you don't expect them to be in wide use in the nightly ecosystem. Some teams have lighter weight processes that they use in scenarios like this; for example, -the compiler team recommends filing a Major Change Proposal ([MCP][mcp]) +the compiler team recommends filing a Major Change Proposal ([MCP]) as a lightweight way to garner support and feedback without requiring full consensus. -[mcp]: https://forge.rust-lang.org/compiler/proposals-and-stabilization.html#how-do-i-submit-an-mcp +[MCP]: https://forge.rust-lang.org/compiler/proposals-and-stabilization.html#how-do-i-submit-an-mcp You don't need to have the implementation fully ready for r+ to propose an FCP, but it is generally a good idea to have at least a proof of concept From 6d42077573a8fa799c258caf745696d605be35e3 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 02:01:33 +0200 Subject: [PATCH 034/194] do not ignore lines that are list entries --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 47 +++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index b50190c78b7b..23b9fc9f67d1 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -22,13 +22,14 @@ struct Cli { show_diff: bool, } -static REGEX_IGNORE: LazyLock = - LazyLock::new(|| Regex::new(r"^\s*(\d\.|\-|\*)\s+").unwrap()); static REGEX_IGNORE_END: LazyLock = LazyLock::new(|| Regex::new(r"(\.|\?|;|!)$").unwrap()); static REGEX_IGNORE_LINK_TARGETS: LazyLock = LazyLock::new(|| Regex::new(r"^\[.+\]: ").unwrap()); static REGEX_SPLIT: LazyLock = - LazyLock::new(|| Regex::new(r"([^\.]\.|[^r]\?|;|!)\s+").unwrap()); + LazyLock::new(|| Regex::new(r"([^\.\d\-\*]\.|[^r]\?|;|!)\s").unwrap()); +// list elements, numbered (1.) or not (- and *) +static REGEX_LIST_ENTRY: LazyLock = + LazyLock::new(|| Regex::new(r"^\s*(\d\.|\-|\*)\s+").unwrap()); fn main() -> Result<()> { let cli = Cli::parse(); @@ -99,7 +100,6 @@ fn ignore(line: &str, in_code_block: bool) -> bool { || line.trim_start().starts_with('>') || line.starts_with('#') || line.trim().is_empty() - || REGEX_IGNORE.is_match(line) || REGEX_IGNORE_LINK_TARGETS.is_match(line) } @@ -120,11 +120,19 @@ fn comply(content: &str) -> String { continue; } if REGEX_SPLIT.is_match(&line) { - let indent = line.find(|ch: char| !ch.is_whitespace()).unwrap(); - let new_lines: Vec<_> = line - .split_inclusive(&*REGEX_SPLIT) - .map(|portion| format!("{:indent$}{}", "", portion.trim())) + let indent = if let Some(regex_match) = REGEX_LIST_ENTRY.find(&line) { + regex_match.len() + } else { + line.find(|ch: char| !ch.is_whitespace()).unwrap() + }; + let mut newly_split_lines = line.split_inclusive(&*REGEX_SPLIT); + let first = newly_split_lines.next().unwrap().trim_end().to_owned(); + let mut remaining: Vec<_> = newly_split_lines + .map(|portion| format!("{:indent$}{}", "", portion.trim_end())) .collect(); + let mut new_lines = Vec::new(); + new_lines.push(first); + new_lines.append(&mut remaining); new_content.splice(new_n..=new_n, new_lines.clone()); new_n += new_lines.len() - 1; } @@ -184,40 +192,45 @@ fn lengthen_lines(content: &str, limit: usize) -> String { fn test_sembr() { let original = "\ # some. heading -must! be; split? and. normalizes space -1. ignore numbered +must! be; split? +1. ignore a dot after number. but no further ignore | tables ignore e.g. and ignore i.e. and ignore E.g. too -- ignore. list -* ignore. list +- list. entry + * list. entry ``` some code. block ``` sentence with *italics* should not be ignored. truly. git log main.. compiler + foo. bar. baz "; let expected = "\ # some. heading must! be; split? -and. -normalizes space -1. ignore numbered +1. ignore a dot after number. + but no further ignore | tables ignore e.g. and ignore i.e. and ignore E.g. too -- ignore. list -* ignore. list +- list. + entry + * list. + entry ``` some code. block ``` sentence with *italics* should not be ignored. truly. git log main.. compiler + foo. + bar. + baz "; assert_eq!(expected, comply(original)); } From e4ef199039bd5e923446fe188013c8ea7df80570 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 02:03:18 +0200 Subject: [PATCH 035/194] avoid surprising string handling behavior --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index 23b9fc9f67d1..d8f20327b82d 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -190,7 +190,7 @@ fn lengthen_lines(content: &str, limit: usize) -> String { #[test] fn test_sembr() { - let original = "\ + let original = " # some. heading must! be; split? 1. ignore a dot after number. but no further @@ -207,7 +207,7 @@ fn test_sembr() { git log main.. compiler foo. bar. baz "; - let expected = "\ + let expected = " # some. heading must! be; @@ -276,13 +276,13 @@ fn test_prettify_ignore_link_targets() { #[test] fn test_sembr_then_prettify() { - let original = "\ + let original = " hi there. do not split short sentences. hi again. "; - let expected = "\ + let expected = " hi there. do not split @@ -291,7 +291,7 @@ fn test_sembr_then_prettify() { "; let processed = comply(original); assert_eq!(expected, processed); - let expected = "\ + let expected = " hi there. do not split short sentences. @@ -299,7 +299,7 @@ fn test_sembr_then_prettify() { "; let processed = lengthen_lines(&processed, 50); assert_eq!(expected, processed); - let expected = "\ + let expected = " hi there. do not split short sentences. hi again. @@ -310,12 +310,12 @@ fn test_sembr_then_prettify() { #[test] fn test_sembr_question_mark() { - let original = "\ + let original = " o? whatever r? @reviewer r? @reviewer "; - let expected = "\ + let expected = " o? whatever r? @reviewer From 5517b2c1fd7e7c83f63f9b4f98a068399ae433bd Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 02:09:12 +0200 Subject: [PATCH 036/194] sembr src/stabilization_guide.md --- .../src/stabilization_guide.md | 56 +++++++++++++------ 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/stabilization_guide.md b/src/doc/rustc-dev-guide/src/stabilization_guide.md index c4b265ba034f..c205531ad2db 100644 --- a/src/doc/rustc-dev-guide/src/stabilization_guide.md +++ b/src/doc/rustc-dev-guide/src/stabilization_guide.md @@ -1,10 +1,12 @@ # Request for stabilization -**NOTE**: This page is about stabilizing *language* features. For stabilizing *library* features, see [Stabilizing a library feature]. +**NOTE**: This page is about stabilizing *language* features. +For stabilizing *library* features, see [Stabilizing a library feature]. [Stabilizing a library feature]: ./stability.md#stabilizing-a-library-feature -Once an unstable feature has been well-tested with no outstanding concerns, anyone may push for its stabilization, though involving the people who have worked on it is prudent. Follow these steps: +Once an unstable feature has been well-tested with no outstanding concerns, anyone may push for its stabilization, though involving the people who have worked on it is prudent. +Follow these steps: ## Write an RFC, if needed @@ -16,16 +18,23 @@ If the feature was part of a [lang experiment], the lang team generally will wan -The feature might be documented in the [`Unstable Book`], located at [`src/doc/unstable-book`]. Remove the page for the feature gate if it exists. Integrate any useful parts of that documentation in other places. +The feature might be documented in the [`Unstable Book`], located at [`src/doc/unstable-book`]. +Remove the page for the feature gate if it exists. +Integrate any useful parts of that documentation in other places. Places that may need updated documentation include: - [The Reference]: This must be updated, in full detail, and a member of the lang-docs team must review and approve the PR before the stabilization can be merged. -- [The Book]: This is updated as needed. If you're not sure, please open an issue on this repository and it can be discussed. -- Standard library documentation: This is updated as needed. Language features often don't need this, but if it's a feature that changes how idiomatic examples are written, such as when `?` was added to the language, updating these in the library documentation is important. Review also the keyword documentation and ABI documentation in the standard library, as these sometimes needs updates for language changes. +- [The Book]: This is updated as needed. + If you're not sure, please open an issue on this repository and it can be discussed. +- Standard library documentation: This is updated as needed. + Language features often don't need this, but if it's a feature that changes how idiomatic examples are written, such as when `?` was added to the language, updating these in the library documentation is important. + Review also the keyword documentation and ABI documentation in the standard library, as these sometimes needs updates for language changes. - [Rust by Example]: This is updated as needed. -Prepare PRs to update documentation involving this new feature for the repositories mentioned above. Maintainers of these repositories will keep these PRs open until the whole stabilization process has completed. Meanwhile, we can proceed to the next step. +Prepare PRs to update documentation involving this new feature for the repositories mentioned above. +Maintainers of these repositories will keep these PRs open until the whole stabilization process has completed. +Meanwhile, we can proceed to the next step. ## Write a stabilization report @@ -34,7 +43,8 @@ Author a stabilization report using the [template found in this repository][srt] The stabilization reports summarizes: - The main design decisions and deviations since the RFC was accepted, including both decisions that were FCP'd or otherwise accepted by the language team as well as those being presented to the lang team for the first time. - - Often, the final stabilized language feature has significant design deviations from the original RFC. That's OK, but these deviations must be highlighted and explained carefully. + - Often, the final stabilized language feature has significant design deviations from the original RFC. + That's OK, but these deviations must be highlighted and explained carefully. - The work that has been done since the RFC was accepted, acknowledging the main contributors that helped drive the language feature forward. The [*Stabilization Template*][srt] includes a series of questions that aim to surface connections between this feature and lang's subteams (e.g. types, opsem, lang-docs, etc.) and to identify items that are commonly overlooked. @@ -51,14 +61,18 @@ Before the stabilization will be considered by the lang team, there must be a co ### Updating the feature-gate listing -There is a central listing of unstable feature-gates in [`compiler/rustc_feature/src/unstable.rs`]. Search for the `declare_features!` macro. There should be an entry for the feature you are aiming to stabilize, something like (this example is taken from [rust-lang/rust#32409]: +There is a central listing of unstable feature-gates in [`compiler/rustc_feature/src/unstable.rs`]. +Search for the `declare_features!` macro. +There should be an entry for the feature you are aiming to stabilize, something like (this example is taken from [rust-lang/rust#32409]: ```rust,ignore // pub(restricted) visibilities (RFC 1422) (unstable, pub_restricted, "CURRENT_RUSTC_VERSION", Some(32409)), ``` -The above line should be moved to [`compiler/rustc_feature/src/accepted.rs`]. Entries in the `declare_features!` call are sorted, so find the correct place. When it is done, it should look like: +The above line should be moved to [`compiler/rustc_feature/src/accepted.rs`]. +Entries in the `declare_features!` call are sorted, so find the correct place. +When it is done, it should look like: ```rust,ignore // pub(restricted) visibilities (RFC 1422) @@ -70,19 +84,24 @@ The above line should be moved to [`compiler/rustc_feature/src/accepted.rs`]. En ### Removing existing uses of the feature-gate -Next, search for the feature string (in this case, `pub_restricted`) in the codebase to find where it appears. Change uses of `#![feature(XXX)]` from the `std` and any rustc crates (this includes test folders under `library/` and `compiler/` but not the toplevel `tests/` one) to be `#![cfg_attr(bootstrap, feature(XXX))]`. This includes the feature-gate only for stage0, which is built using the current beta (this is needed because the feature is still unstable in the current beta). +Next, search for the feature string (in this case, `pub_restricted`) in the codebase to find where it appears. +Change uses of `#![feature(XXX)]` from the `std` and any rustc crates (this includes test folders under `library/` and `compiler/` but not the toplevel `tests/` one) to be `#![cfg_attr(bootstrap, feature(XXX))]`. +This includes the feature-gate only for stage0, which is built using the current beta (this is needed because the feature is still unstable in the current beta). Also, remove those strings from any tests (e.g. under `tests/`). If there are tests specifically targeting the feature-gate (i.e., testing that the feature-gate is required to use the feature, but nothing else), simply remove the test. ### Do not require the feature-gate to use the feature -Most importantly, remove the code which flags an error if the feature-gate is not present (since the feature is now considered stable). If the feature can be detected because it employs some new syntax, then a common place for that code to be is in `compiler/rustc_ast_passes/src/feature_gate.rs`. For example, you might see code like this: +Most importantly, remove the code which flags an error if the feature-gate is not present (since the feature is now considered stable). +If the feature can be detected because it employs some new syntax, then a common place for that code to be is in `compiler/rustc_ast_passes/src/feature_gate.rs`. +For example, you might see code like this: ```rust,ignore gate_all!(pub_restricted, "`pub(restricted)` syntax is experimental"); ``` -The `gate_all!` macro reports an error if the `pub_restricted` feature is not enabled. It is not needed now that `pub(restricted)` is stable. +The `gate_all!` macro reports an error if the `pub_restricted` feature is not enabled. +It is not needed now that `pub(restricted)` is stable. For more subtle features, you may find code like this: @@ -90,7 +109,9 @@ For more subtle features, you may find code like this: if self.tcx.features().async_fn_in_dyn_trait() { /* XXX */ } ``` -This `pub_restricted` field (named after the feature) would ordinarily be false if the feature flag is not present and true if it is. So transform the code to assume that the field is true. In this case, that would mean removing the `if` and leaving just the `/* XXX */`. +This `pub_restricted` field (named after the feature) would ordinarily be false if the feature flag is not present and true if it is. +So transform the code to assume that the field is true. +In this case, that would mean removing the `if` and leaving just the `/* XXX */`. ```rust,ignore if self.tcx.sess.features.borrow().pub_restricted { /* XXX */ } @@ -126,7 +147,8 @@ When opening the stabilization PR, CC the lang team and its advisors (`@rust-lan - `@rust-lang/libs-api`, for changes to the standard library API or its guarantees. - `@rust-lang/lang-docs`, for questions about how this should be documented in the Reference. -After the stabilization PR is opened with the stabilization report, wait a bit for any immediate comments. When such comments "simmer down" and you feel the PR is ready for consideration by the lang team, [nominate the PR](https://lang-team.rust-lang.org/how_to/nominate.html) to get it on the agenda for consideration in an upcoming lang meeting. +After the stabilization PR is opened with the stabilization report, wait a bit for any immediate comments. +When such comments "simmer down" and you feel the PR is ready for consideration by the lang team, [nominate the PR](https://lang-team.rust-lang.org/how_to/nominate.html) to get it on the agenda for consideration in an upcoming lang meeting. If you are not a `rust-lang` organization member, you can ask your assigned reviewer to CC the relevant teams on your behalf. @@ -138,7 +160,8 @@ After the lang team and other relevant teams review the stabilization, and after @rfcbot fcp merge ``` -Once enough team members have reviewed, the PR will move into a "final comment period" (FCP). If no new concerns are raised, this period will complete and the PR can be merged after implementation review in the usual way. +Once enough team members have reviewed, the PR will move into a "final comment period" (FCP). +If no new concerns are raised, this period will complete and the PR can be merged after implementation review in the usual way. ## Reviewing and merging stabilizations @@ -151,4 +174,5 @@ On a stabilization, before giving it the `r+`, ensure that the PR: - Has sufficient tests to convincingly demonstrate these things. - Is accompanied by a PR to the Reference than has been reviewed and approved by a member of lang-docs. -In particular, when reviewing the PR, keep an eye out for any user-visible details that the lang team failed to consider and specify. If you find one, describe it and nominate the PR for the lang team. +In particular, when reviewing the PR, keep an eye out for any user-visible details that the lang team failed to consider and specify. +If you find one, describe it and nominate the PR for the lang team. From aefdfa8b41c30c2228cdd168f899c71d3b72ef0d Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 02:18:29 +0200 Subject: [PATCH 037/194] some text improvements --- src/doc/rustc-dev-guide/src/stabilization_guide.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/stabilization_guide.md b/src/doc/rustc-dev-guide/src/stabilization_guide.md index c205531ad2db..19296b22cecf 100644 --- a/src/doc/rustc-dev-guide/src/stabilization_guide.md +++ b/src/doc/rustc-dev-guide/src/stabilization_guide.md @@ -29,7 +29,7 @@ Places that may need updated documentation include: If you're not sure, please open an issue on this repository and it can be discussed. - Standard library documentation: This is updated as needed. Language features often don't need this, but if it's a feature that changes how idiomatic examples are written, such as when `?` was added to the language, updating these in the library documentation is important. - Review also the keyword documentation and ABI documentation in the standard library, as these sometimes needs updates for language changes. + Review also the keyword documentation and ABI documentation in the standard library, as these sometimes need updates for language changes. - [Rust by Example]: This is updated as needed. Prepare PRs to update documentation involving this new feature for the repositories mentioned above. @@ -63,7 +63,8 @@ Before the stabilization will be considered by the lang team, there must be a co There is a central listing of unstable feature-gates in [`compiler/rustc_feature/src/unstable.rs`]. Search for the `declare_features!` macro. -There should be an entry for the feature you are aiming to stabilize, something like (this example is taken from [rust-lang/rust#32409]: +There should be an entry for the feature you are aiming to stabilize, +something like the following (taken from [rust-lang/rust#32409]: ```rust,ignore // pub(restricted) visibilities (RFC 1422) @@ -85,7 +86,9 @@ When it is done, it should look like: ### Removing existing uses of the feature-gate Next, search for the feature string (in this case, `pub_restricted`) in the codebase to find where it appears. -Change uses of `#![feature(XXX)]` from the `std` and any rustc crates (this includes test folders under `library/` and `compiler/` but not the toplevel `tests/` one) to be `#![cfg_attr(bootstrap, feature(XXX))]`. +Change uses of `#![feature(XXX)]` from the `std` and any rustc crates +(which includes test folders under `library/` and `compiler/` but not the toplevel `tests/` one) +to be `#![cfg_attr(bootstrap, feature(XXX))]`. This includes the feature-gate only for stage0, which is built using the current beta (this is needed because the feature is still unstable in the current beta). Also, remove those strings from any tests (e.g. under `tests/`). If there are tests specifically targeting the feature-gate (i.e., testing that the feature-gate is required to use the feature, but nothing else), simply remove the test. @@ -110,7 +113,7 @@ if self.tcx.features().async_fn_in_dyn_trait() { /* XXX */ } ``` This `pub_restricted` field (named after the feature) would ordinarily be false if the feature flag is not present and true if it is. -So transform the code to assume that the field is true. +So, transform the code to assume that the field is true. In this case, that would mean removing the `if` and leaving just the `/* XXX */`. ```rust,ignore From 74caf6dcbeef8128f13420eb5edb85d2bdd0cbd9 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 02:25:57 +0200 Subject: [PATCH 038/194] sembr implementing_new_features.md again --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 3 ++- src/doc/rustc-dev-guide/src/implementing_new_features.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index d8f20327b82d..7590fbc41c73 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -22,7 +22,8 @@ struct Cli { show_diff: bool, } -static REGEX_IGNORE_END: LazyLock = LazyLock::new(|| Regex::new(r"(\.|\?|;|!)$").unwrap()); +static REGEX_IGNORE_END: LazyLock = + LazyLock::new(|| Regex::new(r"(\.|\?|;|!|,|\-)$").unwrap()); static REGEX_IGNORE_LINK_TARGETS: LazyLock = LazyLock::new(|| Regex::new(r"^\[.+\]: ").unwrap()); static REGEX_SPLIT: LazyLock = diff --git a/src/doc/rustc-dev-guide/src/implementing_new_features.md b/src/doc/rustc-dev-guide/src/implementing_new_features.md index c3e8c0c06623..4526a7af0f46 100644 --- a/src/doc/rustc-dev-guide/src/implementing_new_features.md +++ b/src/doc/rustc-dev-guide/src/implementing_new_features.md @@ -216,7 +216,8 @@ The below steps needs to be followed in order to implement a new unstable featur 1. Write a lot of tests for the new feature, preferably in `tests/ui/$feature_name/`. PRs without tests will not be accepted! -1. Get your PR reviewed and land it. You have now successfully implemented a feature in Rust! +1. Get your PR reviewed and land it. + You have now successfully implemented a feature in Rust! [`GatedSpans`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/parse/struct.GatedSpans.html [#81015]: https://github.com/rust-lang/rust/pull/81015 From d5f14ae17e92be69f5bdfa27e85a7ddd1f9d946f Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 02:43:02 +0200 Subject: [PATCH 039/194] use latest checkout action https://github.com/actions/checkout?tab=readme-ov-file#checkout-v5 --- src/doc/rustc-dev-guide/.github/workflows/ci.yml | 2 +- src/doc/rustc-dev-guide/.github/workflows/date-check.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/.github/workflows/ci.yml b/src/doc/rustc-dev-guide/.github/workflows/ci.yml index c9c23bf9935a..a2159527e445 100644 --- a/src/doc/rustc-dev-guide/.github/workflows/ci.yml +++ b/src/doc/rustc-dev-guide/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: BASE_SHA: ${{ github.event.pull_request.base.sha }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: # linkcheck needs the base commit. fetch-depth: 0 diff --git a/src/doc/rustc-dev-guide/.github/workflows/date-check.yml b/src/doc/rustc-dev-guide/.github/workflows/date-check.yml index 356aeb4e2973..3bac68d23b74 100644 --- a/src/doc/rustc-dev-guide/.github/workflows/date-check.yml +++ b/src/doc/rustc-dev-guide/.github/workflows/date-check.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Ensure Rust is up-to-date run: | From 662facc51068d582fce8a5dd128b68a0c969a7e3 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 04:17:04 +0200 Subject: [PATCH 040/194] ci: avoid sembr getting rebuilt on every push --- src/doc/rustc-dev-guide/.github/workflows/ci.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/doc/rustc-dev-guide/.github/workflows/ci.yml b/src/doc/rustc-dev-guide/.github/workflows/ci.yml index a2159527e445..d96cb01d5256 100644 --- a/src/doc/rustc-dev-guide/.github/workflows/ci.yml +++ b/src/doc/rustc-dev-guide/.github/workflows/ci.yml @@ -83,6 +83,16 @@ jobs: git commit -m "Deploy ${GITHUB_SHA} to gh-pages" git push --quiet -f "https://x-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}" HEAD:gh-pages + - name: Cache sembr build + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ci/sembr/target/ + key: sembr-${{ hashFiles('ci/sembr/Cargo.lock') }} + - name: Check if files comply with semantic line breaks continue-on-error: true run: | From e7cd6c66a88aa82345cf15483ae1e43a9c7a5b45 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 04:17:26 +0200 Subject: [PATCH 041/194] ci: run sembr in release mode --- src/doc/rustc-dev-guide/.github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/.github/workflows/ci.yml b/src/doc/rustc-dev-guide/.github/workflows/ci.yml index d96cb01d5256..76e1d0a8f7cf 100644 --- a/src/doc/rustc-dev-guide/.github/workflows/ci.yml +++ b/src/doc/rustc-dev-guide/.github/workflows/ci.yml @@ -97,4 +97,4 @@ jobs: continue-on-error: true run: | # using split_inclusive that uses regex feature that uses an unstable feature - RUSTC_BOOTSTRAP=1 cargo run --manifest-path ci/sembr/Cargo.toml src + RUSTC_BOOTSTRAP=1 cargo run --release --manifest-path ci/sembr/Cargo.toml src From a70b5c6f7a95c5e4d3effb133dfe99d39917273f Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 04:57:08 +0200 Subject: [PATCH 042/194] sembr sanitizers.md again --- src/doc/rustc-dev-guide/src/sanitizers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/sanitizers.md b/src/doc/rustc-dev-guide/src/sanitizers.md index 7b84335e3b90..673d650e6050 100644 --- a/src/doc/rustc-dev-guide/src/sanitizers.md +++ b/src/doc/rustc-dev-guide/src/sanitizers.md @@ -2,8 +2,8 @@ The rustc compiler contains support for following sanitizers: -* [AddressSanitizer][clang-asan] a faster memory error detector. Can - detect out-of-bounds access to heap, stack, and globals, use after free, use +* [AddressSanitizer][clang-asan] a faster memory error detector. + Can detect out-of-bounds access to heap, stack, and globals, use after free, use after return, double free, invalid free, memory leaks. * [ControlFlowIntegrity][clang-cfi] LLVM Control Flow Integrity (CFI) provides forward-edge control flow protection. From fe3871f1e6fb2d82d5632a0dc7a044b969558080 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 04:25:23 +0200 Subject: [PATCH 043/194] sembr: update lockfile --- src/doc/rustc-dev-guide/ci/sembr/Cargo.lock | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock b/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock index 1e690cc7f1e7..077fa42d2e5b 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock +++ b/src/doc/rustc-dev-guide/ci/sembr/Cargo.lock @@ -4,9 +4,9 @@ version = 4 [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] @@ -69,9 +69,9 @@ checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "bstr" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4" +checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab" dependencies = [ "memchr", "serde", @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.50" +version = "4.5.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623" +checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5" dependencies = [ "clap_builder", "clap_derive", @@ -89,9 +89,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.50" +version = "4.5.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4c05b9e80c5ccd3a7ef080ad7b6ba7d6fc00a985b8b157197075677c82c7a0" +checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a" dependencies = [ "anstream", "anstyle", @@ -184,9 +184,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "ignore" -version = "0.4.24" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81776e6f9464432afcc28d03e52eb101c93b6f0566f52aef2427663e700f0403" +checksum = "d3d782a365a015e0f5c04902246139249abf769125006fbe7649e2ee88169b4a" dependencies = [ "crossbeam-deque", "globset", @@ -243,9 +243,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.41" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] @@ -336,9 +336,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.108" +version = "2.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" +checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" dependencies = [ "proc-macro2", "quote", @@ -347,9 +347,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "utf8parse" From 5d1dc38ba820a793bbe51461ae3b13eb4088985d Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Thu, 13 Nov 2025 04:56:43 +0200 Subject: [PATCH 044/194] handle another edge case --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index 7590fbc41c73..b74dbbe56bfe 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -177,7 +177,10 @@ fn lengthen_lines(content: &str, limit: usize) -> String { let Some(next_line) = content.get(n + 1) else { continue; }; - if ignore(next_line, in_code_block) || REGEX_IGNORE_END.is_match(line) { + if ignore(next_line, in_code_block) + || REGEX_LIST_ENTRY.is_match(next_line) + || REGEX_IGNORE_END.is_match(line) + { continue; } if line.len() + next_line.len() < limit { @@ -244,12 +247,28 @@ fn test_prettify() {
a bit of text inside
+preserve next line +1. one + +preserve next line +- two + +preserve next line +* three "; let expected = "\ do not split short sentences
a bit of text inside
+preserve next line +1. one + +preserve next line +- two + +preserve next line +* three "; assert_eq!(expected, lengthen_lines(original, 50)); } From 0ab7c9e3dac4c8c69267f73ea1e6deaecaacfae3 Mon Sep 17 00:00:00 2001 From: sayantn Date: Wed, 12 Nov 2025 07:36:22 +0530 Subject: [PATCH 045/194] Use SIMD intrinsics for vector shifts --- .../stdarch/crates/core_arch/src/x86/avx2.rs | 90 ++++++++++++------- .../crates/core_arch/src/x86/avx512bw.rs | 84 ++++++++++------- .../crates/core_arch/src/x86/avx512f.rs | 75 ++++++++++------ 3 files changed, 162 insertions(+), 87 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index de27ee7b45ef..2e6e010a21f0 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -2786,7 +2786,12 @@ const fn mask(shift: i32, i: u32) -> u32 { #[cfg_attr(test, assert_instr(vpsllvd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_sllv_epi32(a: __m128i, count: __m128i) -> __m128i { - unsafe { transmute(psllvd(a.as_i32x4(), count.as_i32x4())) } + unsafe { + let count = count.as_u32x4(); + let no_overflow: u32x4 = simd_lt(count, u32x4::splat(u32::BITS)); + let count = simd_select(no_overflow, count, u32x4::ZERO); + simd_select(no_overflow, simd_shl(a.as_u32x4(), count), u32x4::ZERO).as_m128i() + } } /// Shifts packed 32-bit integers in `a` left by the amount @@ -2799,7 +2804,12 @@ pub fn _mm_sllv_epi32(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(vpsllvd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_sllv_epi32(a: __m256i, count: __m256i) -> __m256i { - unsafe { transmute(psllvd256(a.as_i32x8(), count.as_i32x8())) } + unsafe { + let count = count.as_u32x8(); + let no_overflow: u32x8 = simd_lt(count, u32x8::splat(u32::BITS)); + let count = simd_select(no_overflow, count, u32x8::ZERO); + simd_select(no_overflow, simd_shl(a.as_u32x8(), count), u32x8::ZERO).as_m256i() + } } /// Shifts packed 64-bit integers in `a` left by the amount @@ -2812,7 +2822,12 @@ pub fn _mm256_sllv_epi32(a: __m256i, count: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpsllvq))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_sllv_epi64(a: __m128i, count: __m128i) -> __m128i { - unsafe { transmute(psllvq(a.as_i64x2(), count.as_i64x2())) } + unsafe { + let count = count.as_u64x2(); + let no_overflow: u64x2 = simd_lt(count, u64x2::splat(u64::BITS as u64)); + let count = simd_select(no_overflow, count, u64x2::ZERO); + simd_select(no_overflow, simd_shl(a.as_u64x2(), count), u64x2::ZERO).as_m128i() + } } /// Shifts packed 64-bit integers in `a` left by the amount @@ -2825,7 +2840,12 @@ pub fn _mm_sllv_epi64(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(vpsllvq))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_sllv_epi64(a: __m256i, count: __m256i) -> __m256i { - unsafe { transmute(psllvq256(a.as_i64x4(), count.as_i64x4())) } + unsafe { + let count = count.as_u64x4(); + let no_overflow: u64x4 = simd_lt(count, u64x4::splat(u64::BITS as u64)); + let count = simd_select(no_overflow, count, u64x4::ZERO); + simd_select(no_overflow, simd_shl(a.as_u64x4(), count), u64x4::ZERO).as_m256i() + } } /// Shifts packed 16-bit integers in `a` right by `count` while @@ -2889,7 +2909,12 @@ pub fn _mm256_srai_epi32(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpsravd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_srav_epi32(a: __m128i, count: __m128i) -> __m128i { - unsafe { transmute(psravd(a.as_i32x4(), count.as_i32x4())) } + unsafe { + let count = count.as_u32x4(); + let no_overflow: u32x4 = simd_lt(count, u32x4::splat(u32::BITS)); + let count = simd_select(no_overflow, transmute(count), i32x4::splat(31)); + simd_shr(a.as_i32x4(), count).as_m128i() + } } /// Shifts packed 32-bit integers in `a` right by the amount specified by the @@ -2901,7 +2926,12 @@ pub fn _mm_srav_epi32(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(vpsravd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_srav_epi32(a: __m256i, count: __m256i) -> __m256i { - unsafe { transmute(psravd256(a.as_i32x8(), count.as_i32x8())) } + unsafe { + let count = count.as_u32x8(); + let no_overflow: u32x8 = simd_lt(count, u32x8::splat(u32::BITS)); + let count = simd_select(no_overflow, transmute(count), i32x8::splat(31)); + simd_shr(a.as_i32x8(), count).as_m256i() + } } /// Shifts 128-bit lanes in `a` right by `imm8` bytes while shifting in zeros. @@ -3084,7 +3114,12 @@ pub fn _mm256_srli_epi64(a: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpsrlvd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_srlv_epi32(a: __m128i, count: __m128i) -> __m128i { - unsafe { transmute(psrlvd(a.as_i32x4(), count.as_i32x4())) } + unsafe { + let count = count.as_u32x4(); + let no_overflow: u32x4 = simd_lt(count, u32x4::splat(u32::BITS)); + let count = simd_select(no_overflow, count, u32x4::ZERO); + simd_select(no_overflow, simd_shr(a.as_u32x4(), count), u32x4::ZERO).as_m128i() + } } /// Shifts packed 32-bit integers in `a` right by the amount specified by @@ -3096,7 +3131,12 @@ pub fn _mm_srlv_epi32(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(vpsrlvd))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_srlv_epi32(a: __m256i, count: __m256i) -> __m256i { - unsafe { transmute(psrlvd256(a.as_i32x8(), count.as_i32x8())) } + unsafe { + let count = count.as_u32x8(); + let no_overflow: u32x8 = simd_lt(count, u32x8::splat(u32::BITS)); + let count = simd_select(no_overflow, count, u32x8::ZERO); + simd_select(no_overflow, simd_shr(a.as_u32x8(), count), u32x8::ZERO).as_m256i() + } } /// Shifts packed 64-bit integers in `a` right by the amount specified by @@ -3108,7 +3148,12 @@ pub fn _mm256_srlv_epi32(a: __m256i, count: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpsrlvq))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm_srlv_epi64(a: __m128i, count: __m128i) -> __m128i { - unsafe { transmute(psrlvq(a.as_i64x2(), count.as_i64x2())) } + unsafe { + let count = count.as_u64x2(); + let no_overflow: u64x2 = simd_lt(count, u64x2::splat(u64::BITS as u64)); + let count = simd_select(no_overflow, count, u64x2::ZERO); + simd_select(no_overflow, simd_shr(a.as_u64x2(), count), u64x2::ZERO).as_m128i() + } } /// Shifts packed 64-bit integers in `a` right by the amount specified by @@ -3120,7 +3165,12 @@ pub fn _mm_srlv_epi64(a: __m128i, count: __m128i) -> __m128i { #[cfg_attr(test, assert_instr(vpsrlvq))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_srlv_epi64(a: __m256i, count: __m256i) -> __m256i { - unsafe { transmute(psrlvq256(a.as_i64x4(), count.as_i64x4())) } + unsafe { + let count = count.as_u64x4(); + let no_overflow: u64x4 = simd_lt(count, u64x4::splat(u64::BITS as u64)); + let count = simd_select(no_overflow, count, u64x4::ZERO); + simd_select(no_overflow, simd_shr(a.as_u64x4(), count), u64x4::ZERO).as_m256i() + } } /// Load 256-bits of integer data from memory into dst using a non-temporal memory hint. mem_addr @@ -3679,36 +3729,16 @@ pub fn _mm256_extract_epi16(a: __m256i) -> i32 { fn pslld(a: i32x8, count: i32x4) -> i32x8; #[link_name = "llvm.x86.avx2.psll.q"] fn psllq(a: i64x4, count: i64x2) -> i64x4; - #[link_name = "llvm.x86.avx2.psllv.d"] - fn psllvd(a: i32x4, count: i32x4) -> i32x4; - #[link_name = "llvm.x86.avx2.psllv.d.256"] - fn psllvd256(a: i32x8, count: i32x8) -> i32x8; - #[link_name = "llvm.x86.avx2.psllv.q"] - fn psllvq(a: i64x2, count: i64x2) -> i64x2; - #[link_name = "llvm.x86.avx2.psllv.q.256"] - fn psllvq256(a: i64x4, count: i64x4) -> i64x4; #[link_name = "llvm.x86.avx2.psra.w"] fn psraw(a: i16x16, count: i16x8) -> i16x16; #[link_name = "llvm.x86.avx2.psra.d"] fn psrad(a: i32x8, count: i32x4) -> i32x8; - #[link_name = "llvm.x86.avx2.psrav.d"] - fn psravd(a: i32x4, count: i32x4) -> i32x4; - #[link_name = "llvm.x86.avx2.psrav.d.256"] - fn psravd256(a: i32x8, count: i32x8) -> i32x8; #[link_name = "llvm.x86.avx2.psrl.w"] fn psrlw(a: i16x16, count: i16x8) -> i16x16; #[link_name = "llvm.x86.avx2.psrl.d"] fn psrld(a: i32x8, count: i32x4) -> i32x8; #[link_name = "llvm.x86.avx2.psrl.q"] fn psrlq(a: i64x4, count: i64x2) -> i64x4; - #[link_name = "llvm.x86.avx2.psrlv.d"] - fn psrlvd(a: i32x4, count: i32x4) -> i32x4; - #[link_name = "llvm.x86.avx2.psrlv.d.256"] - fn psrlvd256(a: i32x8, count: i32x8) -> i32x8; - #[link_name = "llvm.x86.avx2.psrlv.q"] - fn psrlvq(a: i64x2, count: i64x2) -> i64x2; - #[link_name = "llvm.x86.avx2.psrlv.q.256"] - fn psrlvq256(a: i64x4, count: i64x4) -> i64x4; #[link_name = "llvm.x86.avx2.pshuf.b"] fn pshufb(a: u8x32, b: u8x32) -> u8x32; #[link_name = "llvm.x86.avx2.permd"] diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index 72842f454675..78f4dd53b96d 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -6864,7 +6864,12 @@ pub fn _mm_maskz_slli_epi16(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] pub fn _mm512_sllv_epi16(a: __m512i, count: __m512i) -> __m512i { - unsafe { transmute(vpsllvw(a.as_i16x32(), count.as_i16x32())) } + unsafe { + let count = count.as_u16x32(); + let no_overflow: u16x32 = simd_lt(count, u16x32::splat(u16::BITS as u16)); + let count = simd_select(no_overflow, count, u16x32::ZERO); + simd_select(no_overflow, simd_shl(a.as_u16x32(), count), u16x32::ZERO).as_m512i() + } } /// Shift packed 16-bit integers in a left by the amount specified by the corresponding element in count while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -6903,7 +6908,12 @@ pub fn _mm512_maskz_sllv_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] pub fn _mm256_sllv_epi16(a: __m256i, count: __m256i) -> __m256i { - unsafe { transmute(vpsllvw256(a.as_i16x16(), count.as_i16x16())) } + unsafe { + let count = count.as_u16x16(); + let no_overflow: u16x16 = simd_lt(count, u16x16::splat(u16::BITS as u16)); + let count = simd_select(no_overflow, count, u16x16::ZERO); + simd_select(no_overflow, simd_shl(a.as_u16x16(), count), u16x16::ZERO).as_m256i() + } } /// Shift packed 16-bit integers in a left by the amount specified by the corresponding element in count while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -6942,7 +6952,12 @@ pub fn _mm256_maskz_sllv_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvw))] pub fn _mm_sllv_epi16(a: __m128i, count: __m128i) -> __m128i { - unsafe { transmute(vpsllvw128(a.as_i16x8(), count.as_i16x8())) } + unsafe { + let count = count.as_u16x8(); + let no_overflow: u16x8 = simd_lt(count, u16x8::splat(u16::BITS as u16)); + let count = simd_select(no_overflow, count, u16x8::ZERO); + simd_select(no_overflow, simd_shl(a.as_u16x8(), count), u16x8::ZERO).as_m128i() + } } /// Shift packed 16-bit integers in a left by the amount specified by the corresponding element in count while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -7200,7 +7215,12 @@ pub fn _mm_maskz_srli_epi16(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] pub fn _mm512_srlv_epi16(a: __m512i, count: __m512i) -> __m512i { - unsafe { transmute(vpsrlvw(a.as_i16x32(), count.as_i16x32())) } + unsafe { + let count = count.as_u16x32(); + let no_overflow: u16x32 = simd_lt(count, u16x32::splat(u16::BITS as u16)); + let count = simd_select(no_overflow, count, u16x32::ZERO); + simd_select(no_overflow, simd_shr(a.as_u16x32(), count), u16x32::ZERO).as_m512i() + } } /// Shift packed 16-bit integers in a right by the amount specified by the corresponding element in count while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -7239,7 +7259,12 @@ pub fn _mm512_maskz_srlv_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] pub fn _mm256_srlv_epi16(a: __m256i, count: __m256i) -> __m256i { - unsafe { transmute(vpsrlvw256(a.as_i16x16(), count.as_i16x16())) } + unsafe { + let count = count.as_u16x16(); + let no_overflow: u16x16 = simd_lt(count, u16x16::splat(u16::BITS as u16)); + let count = simd_select(no_overflow, count, u16x16::ZERO); + simd_select(no_overflow, simd_shr(a.as_u16x16(), count), u16x16::ZERO).as_m256i() + } } /// Shift packed 16-bit integers in a right by the amount specified by the corresponding element in count while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -7278,7 +7303,12 @@ pub fn _mm256_maskz_srlv_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvw))] pub fn _mm_srlv_epi16(a: __m128i, count: __m128i) -> __m128i { - unsafe { transmute(vpsrlvw128(a.as_i16x8(), count.as_i16x8())) } + unsafe { + let count = count.as_u16x8(); + let no_overflow: u16x8 = simd_lt(count, u16x8::splat(u16::BITS as u16)); + let count = simd_select(no_overflow, count, u16x8::ZERO); + simd_select(no_overflow, simd_shr(a.as_u16x8(), count), u16x8::ZERO).as_m128i() + } } /// Shift packed 16-bit integers in a right by the amount specified by the corresponding element in count while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -7523,7 +7553,12 @@ pub fn _mm_maskz_srai_epi16(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] pub fn _mm512_srav_epi16(a: __m512i, count: __m512i) -> __m512i { - unsafe { transmute(vpsravw(a.as_i16x32(), count.as_i16x32())) } + unsafe { + let count = count.as_u16x32(); + let no_overflow: u16x32 = simd_lt(count, u16x32::splat(u16::BITS as u16)); + let count = simd_select(no_overflow, transmute(count), i16x32::splat(15)); + simd_shr(a.as_i16x32(), count).as_m512i() + } } /// Shift packed 16-bit integers in a right by the amount specified by the corresponding element in count while shifting in sign bits, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -7562,7 +7597,12 @@ pub fn _mm512_maskz_srav_epi16(k: __mmask32, a: __m512i, count: __m512i) -> __m5 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] pub fn _mm256_srav_epi16(a: __m256i, count: __m256i) -> __m256i { - unsafe { transmute(vpsravw256(a.as_i16x16(), count.as_i16x16())) } + unsafe { + let count = count.as_u16x16(); + let no_overflow: u16x16 = simd_lt(count, u16x16::splat(u16::BITS as u16)); + let count = simd_select(no_overflow, transmute(count), i16x16::splat(15)); + simd_shr(a.as_i16x16(), count).as_m256i() + } } /// Shift packed 16-bit integers in a right by the amount specified by the corresponding element in count while shifting in sign bits, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -7601,7 +7641,12 @@ pub fn _mm256_maskz_srav_epi16(k: __mmask16, a: __m256i, count: __m256i) -> __m2 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravw))] pub fn _mm_srav_epi16(a: __m128i, count: __m128i) -> __m128i { - unsafe { transmute(vpsravw128(a.as_i16x8(), count.as_i16x8())) } + unsafe { + let count = count.as_u16x8(); + let no_overflow: u16x8 = simd_lt(count, u16x8::splat(u16::BITS as u16)); + let count = simd_select(no_overflow, transmute(count), i16x8::splat(15)); + simd_shr(a.as_i16x8(), count).as_m128i() + } } /// Shift packed 16-bit integers in a right by the amount specified by the corresponding element in count while shifting in sign bits, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -11657,33 +11702,12 @@ pub unsafe fn _mm_mask_cvtusepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask8, a: #[link_name = "llvm.x86.avx512.psll.w.512"] fn vpsllw(a: i16x32, count: i16x8) -> i16x32; - #[link_name = "llvm.x86.avx512.psllv.w.512"] - fn vpsllvw(a: i16x32, b: i16x32) -> i16x32; - #[link_name = "llvm.x86.avx512.psllv.w.256"] - fn vpsllvw256(a: i16x16, b: i16x16) -> i16x16; - #[link_name = "llvm.x86.avx512.psllv.w.128"] - fn vpsllvw128(a: i16x8, b: i16x8) -> i16x8; - #[link_name = "llvm.x86.avx512.psrl.w.512"] fn vpsrlw(a: i16x32, count: i16x8) -> i16x32; - #[link_name = "llvm.x86.avx512.psrlv.w.512"] - fn vpsrlvw(a: i16x32, b: i16x32) -> i16x32; - #[link_name = "llvm.x86.avx512.psrlv.w.256"] - fn vpsrlvw256(a: i16x16, b: i16x16) -> i16x16; - #[link_name = "llvm.x86.avx512.psrlv.w.128"] - fn vpsrlvw128(a: i16x8, b: i16x8) -> i16x8; - #[link_name = "llvm.x86.avx512.psra.w.512"] fn vpsraw(a: i16x32, count: i16x8) -> i16x32; - #[link_name = "llvm.x86.avx512.psrav.w.512"] - fn vpsravw(a: i16x32, count: i16x32) -> i16x32; - #[link_name = "llvm.x86.avx512.psrav.w.256"] - fn vpsravw256(a: i16x16, count: i16x16) -> i16x16; - #[link_name = "llvm.x86.avx512.psrav.w.128"] - fn vpsravw128(a: i16x8, count: i16x8) -> i16x8; - #[link_name = "llvm.x86.avx512.vpermi2var.hi.512"] fn vpermi2w(a: i16x32, idx: i16x32, b: i16x32) -> i16x32; #[link_name = "llvm.x86.avx512.vpermi2var.hi.256"] diff --git a/library/stdarch/crates/core_arch/src/x86/avx512f.rs b/library/stdarch/crates/core_arch/src/x86/avx512f.rs index c87946846e65..0ff0e7575c50 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512f.rs @@ -20940,7 +20940,12 @@ pub fn _mm_maskz_srai_epi64(k: __mmask8, a: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravd))] pub fn _mm512_srav_epi32(a: __m512i, count: __m512i) -> __m512i { - unsafe { transmute(vpsravd(a.as_i32x16(), count.as_i32x16())) } + unsafe { + let count = count.as_u32x16(); + let no_overflow: u32x16 = simd_lt(count, u32x16::splat(u32::BITS)); + let count = simd_select(no_overflow, transmute(count), i32x16::splat(31)); + simd_shr(a.as_i32x16(), count).as_m512i() + } } /// Shift packed 32-bit integers in a right by the amount specified by the corresponding element in count while shifting in sign bits, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -21035,7 +21040,12 @@ pub fn _mm_maskz_srav_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] pub fn _mm512_srav_epi64(a: __m512i, count: __m512i) -> __m512i { - unsafe { transmute(vpsravq(a.as_i64x8(), count.as_i64x8())) } + unsafe { + let count = count.as_u64x8(); + let no_overflow: u64x8 = simd_lt(count, u64x8::splat(u64::BITS as u64)); + let count = simd_select(no_overflow, transmute(count), i64x8::splat(63)); + simd_shr(a.as_i64x8(), count).as_m512i() + } } /// Shift packed 64-bit integers in a right by the amount specified by the corresponding element in count while shifting in sign bits, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -21074,7 +21084,12 @@ pub fn _mm512_maskz_srav_epi64(k: __mmask8, a: __m512i, count: __m512i) -> __m51 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] pub fn _mm256_srav_epi64(a: __m256i, count: __m256i) -> __m256i { - unsafe { transmute(vpsravq256(a.as_i64x4(), count.as_i64x4())) } + unsafe { + let count = count.as_u64x4(); + let no_overflow: u64x4 = simd_lt(count, u64x4::splat(u64::BITS as u64)); + let count = simd_select(no_overflow, transmute(count), i64x4::splat(63)); + simd_shr(a.as_i64x4(), count).as_m256i() + } } /// Shift packed 64-bit integers in a right by the amount specified by the corresponding element in count while shifting in sign bits, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -21113,7 +21128,12 @@ pub fn _mm256_maskz_srav_epi64(k: __mmask8, a: __m256i, count: __m256i) -> __m25 #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsravq))] pub fn _mm_srav_epi64(a: __m128i, count: __m128i) -> __m128i { - unsafe { transmute(vpsravq128(a.as_i64x2(), count.as_i64x2())) } + unsafe { + let count = count.as_u64x2(); + let no_overflow: u64x2 = simd_lt(count, u64x2::splat(u64::BITS as u64)); + let count = simd_select(no_overflow, transmute(count), i64x2::splat(63)); + simd_shr(a.as_i64x2(), count).as_m128i() + } } /// Shift packed 64-bit integers in a right by the amount specified by the corresponding element in count while shifting in sign bits, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -21692,7 +21712,12 @@ pub fn _mm_maskz_rorv_epi64(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvd))] pub fn _mm512_sllv_epi32(a: __m512i, count: __m512i) -> __m512i { - unsafe { transmute(vpsllvd(a.as_i32x16(), count.as_i32x16())) } + unsafe { + let count = count.as_u32x16(); + let no_overflow: u32x16 = simd_lt(count, u32x16::splat(u32::BITS)); + let count = simd_select(no_overflow, count, u32x16::ZERO); + simd_select(no_overflow, simd_shl(a.as_u32x16(), count), u32x16::ZERO).as_m512i() + } } /// Shift packed 32-bit integers in a left by the amount specified by the corresponding element in count while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -21787,7 +21812,12 @@ pub fn _mm_maskz_sllv_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvd))] pub fn _mm512_srlv_epi32(a: __m512i, count: __m512i) -> __m512i { - unsafe { transmute(vpsrlvd(a.as_i32x16(), count.as_i32x16())) } + unsafe { + let count = count.as_u32x16(); + let no_overflow: u32x16 = simd_lt(count, u32x16::splat(u32::BITS)); + let count = simd_select(no_overflow, count, u32x16::ZERO); + simd_select(no_overflow, simd_shr(a.as_u32x16(), count), u32x16::ZERO).as_m512i() + } } /// Shift packed 32-bit integers in a right by the amount specified by the corresponding element in count while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -21882,7 +21912,12 @@ pub fn _mm_maskz_srlv_epi32(k: __mmask8, a: __m128i, count: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsllvq))] pub fn _mm512_sllv_epi64(a: __m512i, count: __m512i) -> __m512i { - unsafe { transmute(vpsllvq(a.as_i64x8(), count.as_i64x8())) } + unsafe { + let count = count.as_u64x8(); + let no_overflow: u64x8 = simd_lt(count, u64x8::splat(u64::BITS as u64)); + let count = simd_select(no_overflow, count, u64x8::ZERO); + simd_select(no_overflow, simd_shl(a.as_u64x8(), count), u64x8::ZERO).as_m512i() + } } /// Shift packed 64-bit integers in a left by the amount specified by the corresponding element in count while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -21977,7 +22012,12 @@ pub fn _mm_maskz_sllv_epi64(k: __mmask8, a: __m128i, count: __m128i) -> __m128i #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpsrlvq))] pub fn _mm512_srlv_epi64(a: __m512i, count: __m512i) -> __m512i { - unsafe { transmute(vpsrlvq(a.as_i64x8(), count.as_i64x8())) } + unsafe { + let count = count.as_u64x8(); + let no_overflow: u64x8 = simd_lt(count, u64x8::splat(u64::BITS as u64)); + let count = simd_select(no_overflow, count, u64x8::ZERO); + simd_select(no_overflow, simd_shr(a.as_u64x8(), count), u64x8::ZERO).as_m512i() + } } /// Shift packed 64-bit integers in a right by the amount specified by the corresponding element in count while shifting in zeros, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -42881,15 +42921,6 @@ pub fn _mm_comi_round_sd(a: __m128d, b: __m128d #[link_name = "llvm.x86.avx512.mask.cmp.pd.128"] fn vcmppd128(a: f64x2, b: f64x2, op: i32, m: i8) -> i8; - #[link_name = "llvm.x86.avx512.psllv.d.512"] - fn vpsllvd(a: i32x16, b: i32x16) -> i32x16; - #[link_name = "llvm.x86.avx512.psrlv.d.512"] - fn vpsrlvd(a: i32x16, b: i32x16) -> i32x16; - #[link_name = "llvm.x86.avx512.psllv.q.512"] - fn vpsllvq(a: i64x8, b: i64x8) -> i64x8; - #[link_name = "llvm.x86.avx512.psrlv.q.512"] - fn vpsrlvq(a: i64x8, b: i64x8) -> i64x8; - #[link_name = "llvm.x86.avx512.psll.d.512"] fn vpslld(a: i32x16, count: i32x4) -> i32x16; #[link_name = "llvm.x86.avx512.psrl.d.512"] @@ -42909,16 +42940,6 @@ pub fn _mm_comi_round_sd(a: __m128d, b: __m128d #[link_name = "llvm.x86.avx512.psra.q.128"] fn vpsraq128(a: i64x2, count: i64x2) -> i64x2; - #[link_name = "llvm.x86.avx512.psrav.d.512"] - fn vpsravd(a: i32x16, count: i32x16) -> i32x16; - - #[link_name = "llvm.x86.avx512.psrav.q.512"] - fn vpsravq(a: i64x8, count: i64x8) -> i64x8; - #[link_name = "llvm.x86.avx512.psrav.q.256"] - fn vpsravq256(a: i64x4, count: i64x4) -> i64x4; - #[link_name = "llvm.x86.avx512.psrav.q.128"] - fn vpsravq128(a: i64x2, count: i64x2) -> i64x2; - #[link_name = "llvm.x86.avx512.vpermilvar.ps.512"] fn vpermilps(a: f32x16, b: i32x16) -> f32x16; #[link_name = "llvm.x86.avx512.vpermilvar.pd.512"] From 3dcaf9bc41576a842a43d7901c284302f6ae9c4f Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Fri, 14 Nov 2025 13:41:07 -0500 Subject: [PATCH 046/194] add missing " and -Zoffload=Enable flag --- src/doc/rustc-dev-guide/src/offload/usage.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/offload/usage.md b/src/doc/rustc-dev-guide/src/offload/usage.md index 9d5839334b1a..7abf90aa6e0b 100644 --- a/src/doc/rustc-dev-guide/src/offload/usage.md +++ b/src/doc/rustc-dev-guide/src/offload/usage.md @@ -76,7 +76,7 @@ rustc +offload --edition 2024 src/lib.rs -g --crate-type cdylib -C opt-level=3 - Now we generate the device code. Replace the target-cpu with the right code for your gpu. ``` -RUSTFLAGS="-Ctarget-cpu=gfx90a --emit=llvm-bc,llvm-ir" cargo +offload build -Zunstable-options -r -v --target amdgcn-amd-amdhsa -Zbuild-std=core +RUSTFLAGS="-Ctarget-cpu=gfx90a --emit=llvm-bc,llvm-ir -Zoffload=Enable -Zunstable-options" cargo +offload build -Zunstable-options -r -v --target amdgcn-amd-amdhsa -Zbuild-std=core ``` Now find the `.ll` under target/amdgcn-amd-amdhsa folder and copy it to a device.ll file (or adjust the file names below). @@ -90,13 +90,13 @@ rm bare.amdgcn.gfx90a.img* ``` ``` -clang-offload-packager" "-o" "host.out" "--image=file=device.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp" +"clang-offload-packager" "-o" "host.out" "--image=file=device.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp" -clang-21" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-S" "-save-temps=cwd" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "lib.rs" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-resource-dir" "//rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21" "-ferror-limit" "19" "-fopenmp" "-fopenmp-offload-mandatory" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fembed-offload-object=host.out" "-fopenmp-targets=amdgcn-amd-amdhsa" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "host.s" "-x" "ir" "lib.bc" +"clang-21" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-S" "-save-temps=cwd" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "lib.rs" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-resource-dir" "//rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21" "-ferror-limit" "19" "-fopenmp" "-fopenmp-offload-mandatory" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fembed-offload-object=host.out" "-fopenmp-targets=amdgcn-amd-amdhsa" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "host.s" "-x" "ir" "lib.bc" -clang-21" "-cc1as" "-triple" "x86_64-unknown-linux-gnu" "-filetype" "obj" "-main-file-name" "lib.rs" "-target-cpu" "x86-64" "-mrelocation-model" "pic" "-o" "host.o" "host.s" +"clang-21" "-cc1as" "-triple" "x86_64-unknown-linux-gnu" "-filetype" "obj" "-main-file-name" "lib.rs" "-target-cpu" "x86-64" "-mrelocation-model" "pic" "-o" "host.o" "host.s" -clang-linker-wrapper" "--should-extract=gfx90a" "--device-compiler=amdgcn-amd-amdhsa=-g" "--device-compiler=amdgcn-amd-amdhsa=-save-temps=cwd" "--device-linker=amdgcn-amd-amdhsa=-lompdevice" "--host-triple=x86_64-unknown-linux-gnu" "--save-temps" "--linker-path=/ABSOlUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/lld/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-pie" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "bare" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/ABSOLUTE_PATH_TO/crtbeginS.o" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/x86_64-unknown-linux-gnu" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21/lib/x86_64-unknown-linux-gnu" "-L/lib/../lib64" "-L/usr/lib64" "-L/lib" "-L/usr/lib" "host.o" "-lstdc++" "-lm" "-lomp" "-lomptarget" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib" "-lgcc_s" "-lgcc" "-lpthread" "-lc" "-lgcc_s" "-lgcc" "/ABSOLUTE_PATH_TO/crtendS.o" "/lib/../lib64/crtn.o" +"clang-linker-wrapper" "--should-extract=gfx90a" "--device-compiler=amdgcn-amd-amdhsa=-g" "--device-compiler=amdgcn-amd-amdhsa=-save-temps=cwd" "--device-linker=amdgcn-amd-amdhsa=-lompdevice" "--host-triple=x86_64-unknown-linux-gnu" "--save-temps" "--linker-path=/ABSOlUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/lld/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-pie" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "bare" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/ABSOLUTE_PATH_TO/crtbeginS.o" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/x86_64-unknown-linux-gnu" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21/lib/x86_64-unknown-linux-gnu" "-L/lib/../lib64" "-L/usr/lib64" "-L/lib" "-L/usr/lib" "host.o" "-lstdc++" "-lm" "-lomp" "-lomptarget" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib" "-lgcc_s" "-lgcc" "-lpthread" "-lc" "-lgcc_s" "-lgcc" "/ABSOLUTE_PATH_TO/crtendS.o" "/lib/../lib64/crtn.o" ``` Especially for the last command I recommend to not fix the paths, but rather just re-generate them by copying a bare-mode openmp example and compiling it with your clang. By adding `-###` to your clang invocation, you can see the invidual steps. From 0882a6e02a61daa42bb221b33e6ca74e9fd07ce6 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Fri, 14 Nov 2025 19:25:34 +0000 Subject: [PATCH 047/194] aarch64: Remove withdrawn FEAT_TME ARM has withdrawn FEAT_TME https://developer.arm.com/documentation/102105/lb-05/ LLVM has also dropped support for enabling the feature. --- .../aarch64-unknown-linux-gnu/Dockerfile | 3 +- .../aarch64_be-unknown-linux-gnu/Dockerfile | 1 - .../crates/core_arch/src/aarch64/mod.rs | 4 - .../crates/core_arch/src/aarch64/tme.rs | 201 ------------------ .../crates/stdarch-test/src/disassembly.rs | 2 +- .../crates/stdarch-verify/tests/arm.rs | 1 - 6 files changed, 2 insertions(+), 210 deletions(-) delete mode 100644 library/stdarch/crates/core_arch/src/aarch64/tme.rs diff --git a/library/stdarch/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/library/stdarch/ci/docker/aarch64-unknown-linux-gnu/Dockerfile index 70c06509755c..2768c521ebcc 100644 --- a/library/stdarch/ci/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/library/stdarch/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -15,5 +15,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -cpu max -L /usr/aarch64-linux-gnu" \ - OBJDUMP=aarch64-linux-gnu-objdump \ - STDARCH_TEST_SKIP_FEATURE=tme + OBJDUMP=aarch64-linux-gnu-objdump diff --git a/library/stdarch/ci/docker/aarch64_be-unknown-linux-gnu/Dockerfile b/library/stdarch/ci/docker/aarch64_be-unknown-linux-gnu/Dockerfile index 56ddbd990b18..f85c6a2592e9 100644 --- a/library/stdarch/ci/docker/aarch64_be-unknown-linux-gnu/Dockerfile +++ b/library/stdarch/ci/docker/aarch64_be-unknown-linux-gnu/Dockerfile @@ -27,4 +27,3 @@ ENV AARCH64_BE_LIBC="${AARCH64_BE_TOOLCHAIN}/aarch64_be-none-linux-gnu/libc" ENV CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_LINKER="${AARCH64_BE_TOOLCHAIN}/bin/aarch64_be-none-linux-gnu-gcc" ENV CARGO_TARGET_AARCH64_BE_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64_be -cpu max -L ${AARCH64_BE_LIBC}" ENV OBJDUMP="${AARCH64_BE_TOOLCHAIN}/bin/aarch64_be-none-linux-gnu-objdump" -ENV STDARCH_TEST_SKIP_FEATURE=tme diff --git a/library/stdarch/crates/core_arch/src/aarch64/mod.rs b/library/stdarch/crates/core_arch/src/aarch64/mod.rs index f4b9b1c30251..b48bdac57e7d 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/mod.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/mod.rs @@ -21,10 +21,6 @@ #[stable(feature = "neon_intrinsics", since = "1.59.0")] pub use self::neon::*; -mod tme; -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub use self::tme::*; - mod prefetch; #[unstable(feature = "stdarch_aarch64_prefetch", issue = "117217")] pub use self::prefetch::*; diff --git a/library/stdarch/crates/core_arch/src/aarch64/tme.rs b/library/stdarch/crates/core_arch/src/aarch64/tme.rs deleted file mode 100644 index 207633c1f8d3..000000000000 --- a/library/stdarch/crates/core_arch/src/aarch64/tme.rs +++ /dev/null @@ -1,201 +0,0 @@ -//! ARM's Transactional Memory Extensions (TME). -//! -//! This CPU feature is available on Aarch64 - A architecture profile. -//! This feature is in the non-neon feature set. TME specific vendor documentation can -//! be found [TME Intrinsics Introduction][tme_intrinsics_intro]. -//! -//! The reference is [ACLE Q4 2019][acle_q4_2019_ref]. -//! -//! ACLE has a section for TME extensions and state masks for aborts and failure codes. -//! [ARM A64 Architecture Register Datasheet][a_profile_future] also describes possible failure code scenarios. -//! -//! [acle_q4_2019_ref]: https://static.docs.arm.com/101028/0010/ACLE_2019Q4_release-0010.pdf -//! [tme_intrinsics_intro]: https://developer.arm.com/docs/101028/0010/transactional-memory-extension-tme-intrinsics -//! [llvm_aarch64_int]: https://github.com/llvm/llvm-project/commit/a36d31478c182903523e04eb271bbf102bfab2cc#diff-ff24e1c35f4d54f1110ce5d90c709319R626-R646 -//! [a_profile_future]: https://static.docs.arm.com/ddi0601/a/SysReg_xml_futureA-2019-04.pdf?_ga=2.116560387.441514988.1590524918-1110153136.1588469296 - -#[cfg(test)] -use stdarch_test::assert_instr; - -unsafe extern "unadjusted" { - #[link_name = "llvm.aarch64.tstart"] - fn aarch64_tstart() -> u64; - #[link_name = "llvm.aarch64.tcommit"] - fn aarch64_tcommit(); - #[link_name = "llvm.aarch64.tcancel"] - fn aarch64_tcancel(imm0: u64); - #[link_name = "llvm.aarch64.ttest"] - fn aarch64_ttest() -> u64; -} - -/// Transaction successfully started. -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMSTART_SUCCESS: u64 = 0x00_u64; - -/// Extraction mask for failure reason -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_REASON: u64 = 0x00007FFF_u64; - -/// Transaction retry is possible. -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_RTRY: u64 = 1 << 15; - -/// Transaction executed a TCANCEL instruction -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_CNCL: u64 = 1 << 16; - -/// Transaction aborted because a conflict occurred -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_MEM: u64 = 1 << 17; - -/// Fallback error type for any other reason -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_IMP: u64 = 1 << 18; - -/// Transaction aborted because a non-permissible operation was attempted -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_ERR: u64 = 1 << 19; - -/// Transaction aborted due to read or write set limit was exceeded -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_SIZE: u64 = 1 << 20; - -/// Transaction aborted due to transactional nesting level was exceeded -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_NEST: u64 = 1 << 21; - -/// Transaction aborted due to a debug trap. -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_DBG: u64 = 1 << 22; - -/// Transaction failed from interrupt -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_INT: u64 = 1 << 23; - -/// Indicates a TRIVIAL version of TM is available -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub const _TMFAILURE_TRIVIAL: u64 = 1 << 24; - -// NOTE: Tests for these instructions are disabled on MSVC as dumpbin doesn't -// understand these instructions. - -/// Starts a new transaction. When the transaction starts successfully the return value is 0. -/// If the transaction fails, all state modifications are discarded and a cause of the failure -/// is encoded in the return value. -/// -/// [ARM TME Intrinsics](https://developer.arm.com/docs/101028/0010/transactional-memory-extension-tme-intrinsics). -#[inline] -#[target_feature(enable = "tme")] -#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(tstart))] -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub unsafe fn __tstart() -> u64 { - aarch64_tstart() -} - -/// Commits the current transaction. For a nested transaction, the only effect is that the -/// transactional nesting depth is decreased. For an outer transaction, the state modifications -/// performed transactionally are committed to the architectural state. -/// -/// [ARM TME Intrinsics](https://developer.arm.com/docs/101028/0010/transactional-memory-extension-tme-intrinsics). -#[inline] -#[target_feature(enable = "tme")] -#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(tcommit))] -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub unsafe fn __tcommit() { - aarch64_tcommit() -} - -/// Cancels the current transaction and discards all state modifications that were performed transactionally. -/// -/// [ARM TME Intrinsics](https://developer.arm.com/docs/101028/0010/transactional-memory-extension-tme-intrinsics). -#[inline] -#[target_feature(enable = "tme")] -#[cfg_attr( - all(test, not(target_env = "msvc")), - assert_instr(tcancel, IMM16 = 0x0) -)] -#[rustc_legacy_const_generics(0)] -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub unsafe fn __tcancel() { - static_assert!(IMM16 <= 65535); - aarch64_tcancel(IMM16); -} - -/// Tests if executing inside a transaction. If no transaction is currently executing, -/// the return value is 0. Otherwise, this intrinsic returns the depth of the transaction. -/// -/// [ARM TME Intrinsics](https://developer.arm.com/docs/101028/0010/transactional-memory-extension-tme-intrinsics). -#[inline] -#[target_feature(enable = "tme")] -#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(ttest))] -#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")] -pub unsafe fn __ttest() -> u64 { - aarch64_ttest() -} - -#[cfg(test)] -mod tests { - use stdarch_test::simd_test; - - use crate::core_arch::aarch64::*; - - const CANCEL_CODE: u64 = (0 | (0x123 & _TMFAILURE_REASON) as u64) as u64; - - #[simd_test(enable = "tme")] - unsafe fn test_tstart() { - let mut x = 0; - for i in 0..10 { - let code = tme::__tstart(); - if code == _TMSTART_SUCCESS { - x += 1; - assert_eq!(x, i + 1); - break; - } - assert_eq!(x, 0); - } - } - - #[simd_test(enable = "tme")] - unsafe fn test_tcommit() { - let mut x = 0; - for i in 0..10 { - let code = tme::__tstart(); - if code == _TMSTART_SUCCESS { - x += 1; - assert_eq!(x, i + 1); - tme::__tcommit(); - } - assert_eq!(x, i + 1); - } - } - - #[simd_test(enable = "tme")] - unsafe fn test_tcancel() { - let mut x = 0; - - for i in 0..10 { - let code = tme::__tstart(); - if code == _TMSTART_SUCCESS { - x += 1; - assert_eq!(x, i + 1); - tme::__tcancel::(); - break; - } - } - - assert_eq!(x, 0); - } - - #[simd_test(enable = "tme")] - unsafe fn test_ttest() { - for _ in 0..10 { - let code = tme::__tstart(); - if code == _TMSTART_SUCCESS { - if tme::__ttest() == 2 { - tme::__tcancel::(); - break; - } - } - } - } -} diff --git a/library/stdarch/crates/stdarch-test/src/disassembly.rs b/library/stdarch/crates/stdarch-test/src/disassembly.rs index 4c136cff02ae..237e8d2dc28a 100644 --- a/library/stdarch/crates/stdarch-test/src/disassembly.rs +++ b/library/stdarch/crates/stdarch-test/src/disassembly.rs @@ -78,7 +78,7 @@ pub(crate) fn disassemble_myself() -> HashSet { let objdump = env::var("OBJDUMP").unwrap_or_else(|_| "objdump".to_string()); let add_args = if cfg!(target_vendor = "apple") && cfg!(target_arch = "aarch64") { // Target features need to be enabled for LLVM objdump on Darwin ARM64 - vec!["--mattr=+v8.6a,+crypto,+tme"] + vec!["--mattr=+v8.6a,+crypto"] } else if cfg!(any(target_arch = "riscv32", target_arch = "riscv64")) { vec!["--mattr=+zk,+zks,+zbc,+zbb"] } else { diff --git a/library/stdarch/crates/stdarch-verify/tests/arm.rs b/library/stdarch/crates/stdarch-verify/tests/arm.rs index a35b8175fb22..86897908e062 100644 --- a/library/stdarch/crates/stdarch-verify/tests/arm.rs +++ b/library/stdarch/crates/stdarch-verify/tests/arm.rs @@ -444,7 +444,6 @@ fn verify_all_signatures() { && !rust.file.ends_with("v6.rs\"") && !rust.file.ends_with("v7.rs\"") && !rust.file.ends_with("v8.rs\"") - && !rust.file.ends_with("tme.rs\"") && !rust.file.ends_with("mte.rs\"") && !rust.file.ends_with("ex.rs\"") && !skip_intrinsic_verify.contains(&rust.name) From 8fe87e96235801772df7e5a41482b322c8b65db3 Mon Sep 17 00:00:00 2001 From: sayantn Date: Tue, 11 Nov 2025 04:57:42 +0530 Subject: [PATCH 048/194] correct some `#[simd_test]` attributes --- .../stdarch/crates/core_arch/src/x86/avx2.rs | 2 +- .../crates/core_arch/src/x86/avx512bw.rs | 132 +++++++++--------- .../crates/core_arch/src/x86/avx512f.rs | 14 +- .../crates/core_arch/src/x86/avx512fp16.rs | 40 +++--- .../stdarch/crates/core_arch/src/x86/rdtsc.rs | 12 +- .../stdarch/crates/core_arch/src/x86/sse.rs | 5 +- .../crates/core_arch/src/x86_64/amx.rs | 4 +- .../crates/core_arch/src/x86_64/avx512f.rs | 6 +- 8 files changed, 110 insertions(+), 105 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index 2e6e010a21f0..e8213615a22e 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -5749,7 +5749,7 @@ unsafe fn test_mm256_mask_i64gather_pd() { assert_eq_m256d(r, _mm256_setr_pd(0.0, 16.0, 64.0, 256.0)); } - #[simd_test(enable = "avx")] + #[simd_test(enable = "avx2")] unsafe fn test_mm256_extract_epi8() { #[rustfmt::skip] let a = _mm256_setr_epi8( diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index 78f4dd53b96d..aee705fb4612 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -13335,7 +13335,7 @@ unsafe fn test_mm512_max_epu16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_max_epu16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13352,7 +13352,7 @@ unsafe fn test_mm512_mask_max_epu16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_maskz_max_epu16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13369,7 +13369,7 @@ unsafe fn test_mm512_maskz_max_epu16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_max_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13380,7 +13380,7 @@ unsafe fn test_mm256_mask_max_epu16() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_maskz_max_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13391,7 +13391,7 @@ unsafe fn test_mm256_maskz_max_epu16() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_max_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); @@ -13402,7 +13402,7 @@ unsafe fn test_mm_mask_max_epu16() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_maskz_max_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); @@ -13434,7 +13434,7 @@ unsafe fn test_mm512_max_epu8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_max_epu8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13462,7 +13462,7 @@ unsafe fn test_mm512_mask_max_epu8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_maskz_max_epu8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13489,7 +13489,7 @@ unsafe fn test_mm512_maskz_max_epu8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_max_epu8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13506,7 +13506,7 @@ unsafe fn test_mm256_mask_max_epu8() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_maskz_max_epu8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13523,7 +13523,7 @@ unsafe fn test_mm256_maskz_max_epu8() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_max_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13534,7 +13534,7 @@ unsafe fn test_mm_mask_max_epu8() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_maskz_max_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13560,7 +13560,7 @@ unsafe fn test_mm512_max_epi16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_max_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13577,7 +13577,7 @@ unsafe fn test_mm512_mask_max_epi16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_maskz_max_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13594,7 +13594,7 @@ unsafe fn test_mm512_maskz_max_epi16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_max_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13605,7 +13605,7 @@ unsafe fn test_mm256_mask_max_epi16() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_maskz_max_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13616,7 +13616,7 @@ unsafe fn test_mm256_maskz_max_epi16() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_max_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); @@ -13627,7 +13627,7 @@ unsafe fn test_mm_mask_max_epi16() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_maskz_max_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); @@ -13659,7 +13659,7 @@ unsafe fn test_mm512_max_epi8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_max_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13687,7 +13687,7 @@ unsafe fn test_mm512_mask_max_epi8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_maskz_max_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13714,7 +13714,7 @@ unsafe fn test_mm512_maskz_max_epi8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_max_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13731,7 +13731,7 @@ unsafe fn test_mm256_mask_max_epi8() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_maskz_max_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13748,7 +13748,7 @@ unsafe fn test_mm256_maskz_max_epi8() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_max_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13759,7 +13759,7 @@ unsafe fn test_mm_mask_max_epi8() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_maskz_max_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13785,7 +13785,7 @@ unsafe fn test_mm512_min_epu16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_min_epu16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13802,7 +13802,7 @@ unsafe fn test_mm512_mask_min_epu16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_maskz_min_epu16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13819,7 +13819,7 @@ unsafe fn test_mm512_maskz_min_epu16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_min_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13830,7 +13830,7 @@ unsafe fn test_mm256_mask_min_epu16() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_maskz_min_epu16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13841,7 +13841,7 @@ unsafe fn test_mm256_maskz_min_epu16() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_min_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); @@ -13852,7 +13852,7 @@ unsafe fn test_mm_mask_min_epu16() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_maskz_min_epu16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); @@ -13884,7 +13884,7 @@ unsafe fn test_mm512_min_epu8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_min_epu8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13912,7 +13912,7 @@ unsafe fn test_mm512_mask_min_epu8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_maskz_min_epu8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13939,7 +13939,7 @@ unsafe fn test_mm512_maskz_min_epu8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_min_epu8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13956,7 +13956,7 @@ unsafe fn test_mm256_mask_min_epu8() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_maskz_min_epu8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -13973,7 +13973,7 @@ unsafe fn test_mm256_maskz_min_epu8() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_min_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -13984,7 +13984,7 @@ unsafe fn test_mm_mask_min_epu8() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_maskz_min_epu8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -14010,7 +14010,7 @@ unsafe fn test_mm512_min_epi16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_min_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -14027,7 +14027,7 @@ unsafe fn test_mm512_mask_min_epi16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_maskz_min_epi16() { #[rustfmt::skip] let a = _mm512_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -14044,7 +14044,7 @@ unsafe fn test_mm512_maskz_min_epi16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_min_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -14055,7 +14055,7 @@ unsafe fn test_mm256_mask_min_epi16() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_maskz_min_epi16() { let a = _mm256_set_epi16(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm256_set_epi16(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -14066,7 +14066,7 @@ unsafe fn test_mm256_maskz_min_epi16() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_min_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); @@ -14077,7 +14077,7 @@ unsafe fn test_mm_mask_min_epi16() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_maskz_min_epi16() { let a = _mm_set_epi16(0, 1, 2, 3, 4, 5, 6, 7); let b = _mm_set_epi16(7, 6, 5, 4, 3, 2, 1, 0); @@ -14109,7 +14109,7 @@ unsafe fn test_mm512_min_epi8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_min_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -14137,7 +14137,7 @@ unsafe fn test_mm512_mask_min_epi8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_maskz_min_epi8() { #[rustfmt::skip] let a = _mm512_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -14164,7 +14164,7 @@ unsafe fn test_mm512_maskz_min_epi8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_min_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -14181,7 +14181,7 @@ unsafe fn test_mm256_mask_min_epi8() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_maskz_min_epi8() { #[rustfmt::skip] let a = _mm256_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, @@ -14198,7 +14198,7 @@ unsafe fn test_mm256_maskz_min_epi8() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_min_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -14209,7 +14209,7 @@ unsafe fn test_mm_mask_min_epi8() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_maskz_min_epi8() { let a = _mm_set_epi8(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); let b = _mm_set_epi8(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); @@ -16326,7 +16326,7 @@ unsafe fn test_mm_storeu_epi8() { assert_eq_m128i(r, a); } - #[simd_test(enable = "avx512f,avx512bw")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_loadu_epi16() { let src = _mm512_set1_epi16(42); let a = &[ @@ -16344,7 +16344,7 @@ unsafe fn test_mm512_mask_loadu_epi16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512bw")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_maskz_loadu_epi16() { let a = &[ 1_i16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -16361,7 +16361,7 @@ unsafe fn test_mm512_maskz_loadu_epi16() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512bw")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_storeu_epi16() { let mut r = [42_i16; 32]; let a = &[ @@ -16379,7 +16379,7 @@ unsafe fn test_mm512_mask_storeu_epi16() { assert_eq_m512i(_mm512_loadu_epi16(r.as_ptr()), e); } - #[simd_test(enable = "avx512f,avx512bw")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_loadu_epi8() { let src = _mm512_set1_epi8(42); let a = &[ @@ -16399,7 +16399,7 @@ unsafe fn test_mm512_mask_loadu_epi8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512bw")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_maskz_loadu_epi8() { let a = &[ 1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -16418,7 +16418,7 @@ unsafe fn test_mm512_maskz_loadu_epi8() { assert_eq_m512i(r, e); } - #[simd_test(enable = "avx512f,avx512bw")] + #[simd_test(enable = "avx512bw")] unsafe fn test_mm512_mask_storeu_epi8() { let mut r = [42_i8; 64]; let a = &[ @@ -16438,7 +16438,7 @@ unsafe fn test_mm512_mask_storeu_epi8() { assert_eq_m512i(_mm512_loadu_epi8(r.as_ptr()), e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_loadu_epi16() { let src = _mm256_set1_epi16(42); let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; @@ -16452,7 +16452,7 @@ unsafe fn test_mm256_mask_loadu_epi16() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_maskz_loadu_epi16() { let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let p = a.as_ptr(); @@ -16463,7 +16463,7 @@ unsafe fn test_mm256_maskz_loadu_epi16() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_storeu_epi16() { let mut r = [42_i16; 16]; let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; @@ -16477,7 +16477,7 @@ unsafe fn test_mm256_mask_storeu_epi16() { assert_eq_m256i(_mm256_loadu_epi16(r.as_ptr()), e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_loadu_epi8() { let src = _mm256_set1_epi8(42); let a = &[ @@ -16495,7 +16495,7 @@ unsafe fn test_mm256_mask_loadu_epi8() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_maskz_loadu_epi8() { let a = &[ 1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -16512,7 +16512,7 @@ unsafe fn test_mm256_maskz_loadu_epi8() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm256_mask_storeu_epi8() { let mut r = [42_i8; 32]; let a = &[ @@ -16530,7 +16530,7 @@ unsafe fn test_mm256_mask_storeu_epi8() { assert_eq_m256i(_mm256_loadu_epi8(r.as_ptr()), e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_loadu_epi16() { let src = _mm_set1_epi16(42); let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8]; @@ -16542,7 +16542,7 @@ unsafe fn test_mm_mask_loadu_epi16() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_maskz_loadu_epi16() { let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8]; let p = a.as_ptr(); @@ -16553,7 +16553,7 @@ unsafe fn test_mm_maskz_loadu_epi16() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_storeu_epi16() { let mut r = [42_i16; 8]; let a = &[1_i16, 2, 3, 4, 5, 6, 7, 8]; @@ -16565,7 +16565,7 @@ unsafe fn test_mm_mask_storeu_epi16() { assert_eq_m128i(_mm_loadu_epi16(r.as_ptr()), e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_loadu_epi8() { let src = _mm_set1_epi8(42); let a = &[1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; @@ -16579,7 +16579,7 @@ unsafe fn test_mm_mask_loadu_epi8() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_maskz_loadu_epi8() { let a = &[1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; let p = a.as_ptr(); @@ -16590,7 +16590,7 @@ unsafe fn test_mm_maskz_loadu_epi8() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f,avx512bw,avx512vl")] + #[simd_test(enable = "avx512bw,avx512vl")] unsafe fn test_mm_mask_storeu_epi8() { let mut r = [42_i8; 16]; let a = &[1_i8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; diff --git a/library/stdarch/crates/core_arch/src/x86/avx512f.rs b/library/stdarch/crates/core_arch/src/x86/avx512f.rs index ebffb9ac9298..f7bf9178dbb9 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512f.rs @@ -56076,7 +56076,7 @@ unsafe fn test_kxnor_mask16() { assert_eq!(r, e); } - #[simd_test(enable = "avx512dq")] + #[simd_test(enable = "avx512f")] unsafe fn test_kortest_mask16_u8() { let a: __mmask16 = 0b0110100101101001; let b: __mmask16 = 0b1011011010110110; @@ -56086,7 +56086,7 @@ unsafe fn test_kortest_mask16_u8() { assert_eq!(all_ones, 1); } - #[simd_test(enable = "avx512dq")] + #[simd_test(enable = "avx512f")] unsafe fn test_kortestc_mask16_u8() { let a: __mmask16 = 0b0110100101101001; let b: __mmask16 = 0b1011011010110110; @@ -56094,7 +56094,7 @@ unsafe fn test_kortestc_mask16_u8() { assert_eq!(r, 1); } - #[simd_test(enable = "avx512dq")] + #[simd_test(enable = "avx512f")] unsafe fn test_kortestz_mask16_u8() { let a: __mmask16 = 0b0110100101101001; let b: __mmask16 = 0b1011011010110110; @@ -56102,7 +56102,7 @@ unsafe fn test_kortestz_mask16_u8() { assert_eq!(r, 0); } - #[simd_test(enable = "avx512dq")] + #[simd_test(enable = "avx512f")] unsafe fn test_kshiftli_mask16() { let a: __mmask16 = 0b1001011011000011; let r = _kshiftli_mask16::<3>(a); @@ -56122,7 +56122,7 @@ unsafe fn test_kshiftli_mask16() { assert_eq!(r, e); } - #[simd_test(enable = "avx512dq")] + #[simd_test(enable = "avx512f")] unsafe fn test_kshiftri_mask16() { let a: __mmask16 = 0b1010100100111100; let r = _kshiftri_mask16::<3>(a); @@ -57383,7 +57383,7 @@ unsafe fn test_mm256_mask_set1_epi32() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512f,avx512vl")] unsafe fn test_mm256_maskz_set1_epi32() { let a: i32 = 11; let r = _mm256_maskz_set1_epi32(0, a); @@ -57404,7 +57404,7 @@ unsafe fn test_mm_mask_set1_epi32() { assert_eq_m128i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512f,avx512vl")] unsafe fn test_mm_maskz_set1_epi32() { let a: i32 = 11; let r = _mm_maskz_set1_epi32(0, a); diff --git a/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs b/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs index 293fda3064dc..13cae45d0f81 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512fp16.rs @@ -20766,7 +20766,7 @@ unsafe fn test_mm_fmsub_round_sh() { assert_eq_m128h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm_mask_fmsub_round_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); @@ -20783,7 +20783,7 @@ unsafe fn test_mm_mask_fmsub_round_sh() { assert_eq_m128h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm_mask3_fmsub_round_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); @@ -20800,7 +20800,7 @@ unsafe fn test_mm_mask3_fmsub_round_sh() { assert_eq_m128h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm_maskz_fmsub_round_sh() { let a = _mm_setr_ph(1.0, 10., 11., 12., 13., 14., 15., 16.); let b = _mm_setr_ph(2.0, 20., 21., 22., 23., 24., 25., 26.); @@ -24529,7 +24529,7 @@ unsafe fn test_mm512_cvtepi32_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_mask_cvtepi32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let src = _mm256_set_ph( @@ -24542,7 +24542,7 @@ unsafe fn test_mm512_mask_cvtepi32_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_maskz_cvtepi32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_maskz_cvtepi32_ph(0b0101010101010101, a); @@ -24552,7 +24552,7 @@ unsafe fn test_mm512_maskz_cvtepi32_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_cvt_roundepi32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_cvt_roundepi32_ph::<{ _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC }>(a); @@ -24562,7 +24562,7 @@ unsafe fn test_mm512_cvt_roundepi32_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_mask_cvt_roundepi32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let src = _mm256_set_ph( @@ -24579,7 +24579,7 @@ unsafe fn test_mm512_mask_cvt_roundepi32_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_maskz_cvt_roundepi32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_maskz_cvt_roundepi32_ph::<{ _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC }>( @@ -24658,7 +24658,7 @@ unsafe fn test_mm256_maskz_cvtepu32_ph() { assert_eq_m128h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_cvtepu32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_cvtepu32_ph(a); @@ -24668,7 +24668,7 @@ unsafe fn test_mm512_cvtepu32_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_mask_cvtepu32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let src = _mm256_set_ph( @@ -24681,7 +24681,7 @@ unsafe fn test_mm512_mask_cvtepu32_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_maskz_cvtepu32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_maskz_cvtepu32_ph(0b0101010101010101, a); @@ -24691,7 +24691,7 @@ unsafe fn test_mm512_maskz_cvtepu32_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_cvt_roundepu32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_cvt_roundepu32_ph::<{ _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC }>(a); @@ -24701,7 +24701,7 @@ unsafe fn test_mm512_cvt_roundepu32_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_mask_cvt_roundepu32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let src = _mm256_set_ph( @@ -24719,7 +24719,7 @@ unsafe fn test_mm512_mask_cvt_roundepu32_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_maskz_cvt_roundepu32_ph() { let a = _mm512_set_epi32(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); let r = _mm512_maskz_cvt_roundepu32_ph::<{ _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC }>( @@ -25006,7 +25006,7 @@ unsafe fn test_mm256_maskz_cvtxps_ph() { assert_eq_m128h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_cvtxps_ph() { let a = _mm512_set_ps( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, @@ -25018,7 +25018,7 @@ unsafe fn test_mm512_cvtxps_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_mask_cvtxps_ph() { let a = _mm512_set_ps( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, @@ -25033,7 +25033,7 @@ unsafe fn test_mm512_mask_cvtxps_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_maskz_cvtxps_ph() { let a = _mm512_set_ps( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, @@ -25045,7 +25045,7 @@ unsafe fn test_mm512_maskz_cvtxps_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_cvtx_roundps_ph() { let a = _mm512_set_ps( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, @@ -25057,7 +25057,7 @@ unsafe fn test_mm512_cvtx_roundps_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_mask_cvtx_roundps_ph() { let a = _mm512_set_ps( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, @@ -25077,7 +25077,7 @@ unsafe fn test_mm512_mask_cvtx_roundps_ph() { assert_eq_m256h(r, e); } - #[simd_test(enable = "avx512fp16")] + #[simd_test(enable = "avx512fp16,avx512vl")] unsafe fn test_mm512_maskz_cvtx_roundps_ph() { let a = _mm512_set_ps( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, diff --git a/library/stdarch/crates/core_arch/src/x86/rdtsc.rs b/library/stdarch/crates/core_arch/src/x86/rdtsc.rs index 3b348153d602..89292d78af16 100644 --- a/library/stdarch/crates/core_arch/src/x86/rdtsc.rs +++ b/library/stdarch/crates/core_arch/src/x86/rdtsc.rs @@ -64,16 +64,16 @@ mod tests { use crate::core_arch::x86::*; use stdarch_test::simd_test; - #[simd_test(enable = "sse2")] - unsafe fn test_rdtsc() { - let r = _rdtsc(); + #[test] + fn test_rdtsc() { + let r = unsafe { _rdtsc() }; assert_ne!(r, 0); // The chances of this being 0 are infinitesimal } - #[simd_test(enable = "sse2")] - unsafe fn test_rdtscp() { + #[test] + fn test_rdtscp() { let mut aux = 0; - let r = __rdtscp(&mut aux); + let r = unsafe { __rdtscp(&mut aux) }; assert_ne!(r, 0); // The chances of this being 0 are infinitesimal } } diff --git a/library/stdarch/crates/core_arch/src/x86/sse.rs b/library/stdarch/crates/core_arch/src/x86/sse.rs index 86f743e76d88..7dd96dd1c9d7 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse.rs @@ -3052,8 +3052,9 @@ unsafe fn test_mm_setzero_ps() { assert_eq_m128(r, _mm_set1_ps(0.0)); } - #[simd_test(enable = "sse")] - unsafe fn test_MM_SHUFFLE() { + #[test] + #[allow(non_snake_case)] + fn test_MM_SHUFFLE() { assert_eq!(_MM_SHUFFLE(0, 1, 1, 3), 0b00_01_01_11); assert_eq!(_MM_SHUFFLE(3, 1, 1, 0), 0b11_01_01_00); assert_eq!(_MM_SHUFFLE(1, 2, 2, 1), 0b01_10_10_01); diff --git a/library/stdarch/crates/core_arch/src/x86_64/amx.rs b/library/stdarch/crates/core_arch/src/x86_64/amx.rs index c87514980df6..3e0ac8f47cea 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/amx.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/amx.rs @@ -937,7 +937,7 @@ unsafe fn test_tile_dphf8ps() { assert_eq!(res, [[128.0_f32; 16]; 16]); } - #[simd_test(enable = "amx-tile")] + #[simd_test(enable = "amx-movrs")] unsafe fn test_tile_loaddrs() { _init_amx(); let mut config = __tilecfg::default(); @@ -954,7 +954,7 @@ unsafe fn test_tile_loaddrs() { assert_eq!(out, [[1; 64]; 16]); } - #[simd_test(enable = "amx-tile")] + #[simd_test(enable = "amx-movrs")] unsafe fn test_tile_stream_loaddrs() { _init_amx(); let mut config = __tilecfg::default(); diff --git a/library/stdarch/crates/core_arch/src/x86_64/avx512f.rs b/library/stdarch/crates/core_arch/src/x86_64/avx512f.rs index 934c9e2812c4..a2656c853563 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/avx512f.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/avx512f.rs @@ -6453,6 +6453,7 @@ unsafe fn test_mm512_setzero_pd() { assert_eq_m512d(_mm512_setzero_pd(), _mm512_set1_pd(0.)); } + #[simd_test(enable = "avx512f")] unsafe fn test_mm512_set1_epi64() { let r = _mm512_set_epi64(2, 2, 2, 2, 2, 2, 2, 2); assert_eq_m512i(r, _mm512_set1_epi64(2)); @@ -6464,6 +6465,7 @@ unsafe fn test_mm512_set1_pd() { assert_eq_m512d(expected, _mm512_set1_pd(2.)); } + #[simd_test(enable = "avx512f")] unsafe fn test_mm512_set4_epi64() { let r = _mm512_set_epi64(4, 3, 2, 1, 4, 3, 2, 1); assert_eq_m512i(r, _mm512_set4_epi64(4, 3, 2, 1)); @@ -6475,6 +6477,7 @@ unsafe fn test_mm512_set4_pd() { assert_eq_m512d(r, _mm512_set4_pd(4., 3., 2., 1.)); } + #[simd_test(enable = "avx512f")] unsafe fn test_mm512_setr4_epi64() { let r = _mm512_set_epi64(4, 3, 2, 1, 4, 3, 2, 1); assert_eq_m512i(r, _mm512_setr4_epi64(1, 2, 3, 4)); @@ -7335,6 +7338,7 @@ unsafe fn test_mm512_setr_epi64() { assert_eq_m512i(r, _mm512_setr_epi64(7, 6, 5, 4, 3, 2, 1, 0)) } + #[simd_test(enable = "avx512f")] unsafe fn test_mm512_cmpneq_epi64_mask() { let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100); let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100); @@ -9685,7 +9689,7 @@ unsafe fn test_mm256_mask_permutex_epi64() { assert_eq_m256i(r, e); } - #[simd_test(enable = "avx512f")] + #[simd_test(enable = "avx512f,avx512vl")] unsafe fn test_mm256_maskz_permutex_epi64() { let a = _mm256_set_epi64x(3, 2, 1, 0); let r = _mm256_maskz_permutex_epi64::<0b11_11_11_11>(0, a); From ecfc64207a7e761cbebe4b7da0202f12abea63a1 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Mon, 29 Sep 2025 23:39:22 -0500 Subject: [PATCH 049/194] Add support for hexagon-unknown-qurt target --- compiler/rustc_target/src/spec/mod.rs | 2 + .../src/spec/targets/hexagon_unknown_qurt.rs | 45 +++++ src/bootstrap/src/core/sanity.rs | 1 + src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/platform-support.md | 1 + .../platform-support/hexagon-unknown-qurt.md | 180 ++++++++++++++++++ tests/assembly-llvm/targets/targets-elf.rs | 3 + tests/ui/check-cfg/cfg-crate-features.stderr | 2 +- tests/ui/check-cfg/well-known-values.stderr | 4 +- 9 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs create mode 100644 src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 62d3809c2c64..1a71e344276a 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1490,6 +1490,7 @@ fn $module() { ("mips64el-unknown-linux-muslabi64", mips64el_unknown_linux_muslabi64), ("hexagon-unknown-linux-musl", hexagon_unknown_linux_musl), ("hexagon-unknown-none-elf", hexagon_unknown_none_elf), + ("hexagon-unknown-qurt", hexagon_unknown_qurt), ("mips-unknown-linux-uclibc", mips_unknown_linux_uclibc), ("mipsel-unknown-linux-uclibc", mipsel_unknown_linux_uclibc), @@ -1958,6 +1959,7 @@ pub enum Os { OpenBsd = "openbsd", Psp = "psp", Psx = "psx", + Qurt = "qurt", Redox = "redox", Rtems = "rtems", Solaris = "solaris", diff --git a/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs b/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs new file mode 100644 index 000000000000..746e0cb11dcb --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs @@ -0,0 +1,45 @@ +use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Os, Target, TargetMetadata, TargetOptions, cvs}; + +pub(crate) fn target() -> Target { + let mut base = TargetOptions::default(); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-G0"]); + + Target { + llvm_target: "hexagon-unknown-elf".into(), + metadata: TargetMetadata { + description: Some("Hexagon QuRT".into()), + tier: Some(3), + host_tools: Some(false), + std: Some(false), + }, + pointer_width: 32, + data_layout: "\ + e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32\ + :32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32\ + :32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048\ + :2048:2048" + .into(), + arch: Arch::Hexagon, + options: TargetOptions { + os: Os::Qurt, + vendor: "unknown".into(), + cpu: "hexagonv69".into(), + linker: Some("rust-lld".into()), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + exe_suffix: ".elf".into(), + dynamic_linking: true, + executables: true, + families: cvs!["unix"], + has_thread_local: true, + has_rpath: false, + crt_static_default: false, + crt_static_respected: true, + crt_static_allows_dylibs: true, + no_default_libraries: false, + max_atomic_width: Some(32), + features: "-small-data,+hvx-length128b".into(), + c_enum_min_bits: Some(8), + ..base + }, + } +} diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 78cd7ab2539f..00aae9cce220 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -41,6 +41,7 @@ pub struct Finder { "sparc64-unknown-helenos", // just a dummy comment so the list doesn't get onelined "riscv64gc-unknown-redox", + "hexagon-unknown-qurt", ]; /// Minimum version threshold for libstdc++ required when using prebuilt LLVM diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index e4623a2a87f4..4cf95a04465a 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -87,6 +87,7 @@ - [csky-unknown-linux-gnuabiv2\*](platform-support/csky-unknown-linux-gnuabiv2.md) - [hexagon-unknown-linux-musl](platform-support/hexagon-unknown-linux-musl.md) - [hexagon-unknown-none-elf](platform-support/hexagon-unknown-none-elf.md) + - [hexagon-unknown-qurt](platform-support/hexagon-unknown-qurt.md) - [illumos](platform-support/illumos.md) - [loongarch\*-unknown-linux-\*](platform-support/loongarch-linux.md) - [loongarch\*-unknown-none\*](platform-support/loongarch-none.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 39bf9c777640..c0e9ed8aa413 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -315,6 +315,7 @@ target | std | host | notes `csky-unknown-linux-gnuabiv2hf` | ✓ | | C-SKY abiv2 Linux, hardfloat (little endian) [`hexagon-unknown-linux-musl`](platform-support/hexagon-unknown-linux-musl.md) | ✓ | | Hexagon Linux with musl 1.2.5 [`hexagon-unknown-none-elf`](platform-support/hexagon-unknown-none-elf.md)| * | | Bare Hexagon (v60+, HVX) +[`hexagon-unknown-qurt`](platform-support/hexagon-unknown-qurt.md)| * | | Hexagon QuRT [`i386-apple-ios`](platform-support/apple-ios.md) | ✓ | | 32-bit x86 iOS (Penryn) [^x86_32-floats-return-ABI] [`i586-unknown-netbsd`](platform-support/netbsd.md) | ✓ | | 32-bit x86 (original Pentium) [^x86_32-floats-x87] [`i586-unknown-redox`](platform-support/redox.md) | ✓ | | 32-bit x86 Redox OS (PentiumPro) [^x86_32-floats-x87] diff --git a/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md b/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md new file mode 100644 index 000000000000..7928804d0954 --- /dev/null +++ b/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md @@ -0,0 +1,180 @@ +# `hexagon-unknown-qurt` + +**Tier: 3** + +Rust for Hexagon QuRT (Qualcomm Real-Time OS). + +| Target | Description | +| -------------------- | ------------| +| hexagon-unknown-qurt | Hexagon 32-bit QuRT | + +## Target maintainers + +[@androm3da](https://github.com/androm3da) + +## Requirements + +This target is cross-compiled. There is support for `std`. The target uses +QuRT's standard library and runtime. + +By default, code generated with this target should run on Hexagon DSP hardware +running the QuRT real-time operating system. + +- `-Ctarget-cpu=hexagonv69` targets Hexagon V69 architecture (default) +- `-Ctarget-cpu=hexagonv73` adds support for instructions defined up to Hexagon V73 + +Functions marked `extern "C"` use the [Hexagon architecture calling convention](https://lists.llvm.org/pipermail/llvm-dev/attachments/20190916/21516a52/attachment-0001.pdf). + +This target generates position-independent ELF binaries by default, making it +suitable for both static images and dynamic shared objects. + +The [Hexagon SDK](https://softwarecenter.qualcomm.com/catalog/item/Hexagon_SDK) is +required for building programs for this target. + +## Linking + +This target selects `rust-lld` by default. Another option to use is +[eld](https://github.com/qualcomm/eld), which is also provided with +[the opensource hexagon toolchain](https://github.com/quic/toolchain_for_hexagon) +and the Hexagon SDK. + +## Building the target + +You can build Rust with support for the target by adding it to the `target` +list in `bootstrap.toml`: + +```toml +[build] +build-stage = 1 +host = [""] +target = ["", "hexagon-unknown-qurt"] + +[target.hexagon-unknown-qurt] +cc = "hexagon-clang" +cxx = "hexagon-clang++" +ranlib = "llvm-ranlib" +ar = "llvm-ar" +llvm-libunwind = 'in-tree' +``` + +Replace `` with `x86_64-unknown-linux-gnu` or whatever +else is appropriate for your host machine. + +## Building Rust programs + +Rust does not yet ship pre-compiled artifacts for this target. To compile for +this target, you will either need to build Rust with the target enabled (see +"Building the target" above), or build your own copy of `core` by using +`build-std` or similar. + +## Static Image Targeting + +For static executables that run directly on QuRT, use the default target +configuration with additional linker flags: + +```sh +# Build a static executable for QuRT +cargo rustc --target hexagon-unknown-qurt -- \ + -C link-args="-static -nostdlib" \ + -C link-args="-L/opt/Hexagon_SDK/6.3.0.0/rtos/qurt/computev69/lib" \ + -C link-args="-lqurt -lc" +``` + +This approach is suitable for: +- Standalone QuRT applications +- System-level services +- Boot-time initialization code +- Applications that need deterministic memory layout + +## User-Loadable Shared Object Targeting + +For shared libraries that can be dynamically loaded by QuRT applications: + +```sh +# Build a shared object for QuRT +cargo rustc --target hexagon-unknown-qurt \ + --crate-type=cdylib -- \ + -C link-args="-shared -fPIC" \ + -C link-args="-L/opt/Hexagon_SDK/6.3.0.0/rtos/qurt/computev69/lib" +``` + +This approach is suitable for: +- Plugin architectures +- Runtime-loadable modules +- Libraries shared between multiple applications +- Code that needs to be updated without system restart + +## Configuration Options + +The target can be customized for different use cases: + +### For Static Images +```toml +# In .cargo/config.toml +[target.hexagon-unknown-qurt] +rustflags = [ + "-C", "link-args=-static", + "-C", "link-args=-nostdlib", + "-C", "target-feature=-small-data" +] +``` + +### For Shared Objects +```toml +# In .cargo/config.toml +[target.hexagon-unknown-qurt] +rustflags = [ + "-C", "link-args=-shared", + "-C", "link-args=-fPIC", + "-C", "relocation-model=pic" +] +``` + +## Testing + +Since `hexagon-unknown-qurt` requires the QuRT runtime environment, testing requires +either: +- Hexagon hardware with QuRT +- `hexagon-sim` +- QEMU (`qemu-system-hexagon`) + +## Cross-compilation toolchains and C code + +This target requires the proprietary [Hexagon SDK toolchain for C interoperability](https://softwarecenter.qualcomm.com/catalog/item/Hexagon_SDK): + +- **Sample SDK Path**: `/opt/Hexagon_SDK/6.3.0.0/` +- **Toolchain**: Use `hexagon-clang` from the Hexagon SDK +- **Libraries**: Link against QuRT system libraries as needed + +### C Interoperability Example + +```rust +// lib.rs +#![no_std] +extern crate std; + +#[unsafe(no_mangle)] +pub extern "C" fn rust_function() -> i32 { + // Your Rust code here + 42 +} + +fn main() { + // Example usage + let result = rust_function(); + assert_eq!(result, 42); +} +``` + +```c +// wrapper.c +extern int rust_function(void); + +int main() { + return rust_function(); +} +``` + +The target supports both static linking for standalone applications and dynamic +linking for modular architectures, making it flexible for various QuRT +deployment scenarios. diff --git a/tests/assembly-llvm/targets/targets-elf.rs b/tests/assembly-llvm/targets/targets-elf.rs index 4ca46013b574..324c7fc9da4e 100644 --- a/tests/assembly-llvm/targets/targets-elf.rs +++ b/tests/assembly-llvm/targets/targets-elf.rs @@ -235,6 +235,9 @@ //@ revisions: hexagon_unknown_none_elf //@ [hexagon_unknown_none_elf] compile-flags: --target hexagon-unknown-none-elf //@ [hexagon_unknown_none_elf] needs-llvm-components: hexagon +//@ revisions: hexagon_unknown_qurt +//@ [hexagon_unknown_qurt] compile-flags: --target hexagon-unknown-qurt +//@ [hexagon_unknown_qurt] needs-llvm-components: hexagon //@ revisions: i686_pc_nto_qnx700 //@ [i686_pc_nto_qnx700] compile-flags: --target i686-pc-nto-qnx700 //@ [i686_pc_nto_qnx700] needs-llvm-components: x86 diff --git a/tests/ui/check-cfg/cfg-crate-features.stderr b/tests/ui/check-cfg/cfg-crate-features.stderr index 38301f470bf7..242883995488 100644 --- a/tests/ui/check-cfg/cfg-crate-features.stderr +++ b/tests/ui/check-cfg/cfg-crate-features.stderr @@ -24,7 +24,7 @@ warning: unexpected `cfg` condition value: `does_not_exist` LL | #![cfg(not(target(os = "does_not_exist")))] | ^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, and `teeos` and 13 more + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, and `solid_asp3` and 14 more = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index d9a9981177d2..efa0a7f4af9a 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -201,7 +201,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` @@ -274,7 +274,7 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | | | help: there is a expected value with a similar name: `"linux"` | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see for more information about checking conditional configuration warning: 28 warnings emitted From 901183b91afe29f56ac1ddd893c681fdeb57195e Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Mon, 17 Nov 2025 04:16:56 +0000 Subject: [PATCH 050/194] Prepare for merging from rust-lang/rust This updates the rust-version file to 69d4d5fc0e4db60272aac85ef27ecccef5764f3a. --- src/doc/rustc-dev-guide/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index 04d41c96f5c0..25bb5e923183 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -8401398e1f14a24670ee1a3203713dc2f0f8b3a8 +69d4d5fc0e4db60272aac85ef27ecccef5764f3a From f5892da3f253d839278f7cddfd220b029e66c803 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Tue, 11 Nov 2025 21:47:41 -0500 Subject: [PATCH 051/194] add autodiff examples --- library/core/Cargo.toml | 3 ++ library/core/src/macros/mod.rs | 68 +++++++++++++++++++++++++++++++--- library/std/Cargo.toml | 1 + library/sysroot/Cargo.toml | 1 + src/bootstrap/src/lib.rs | 4 ++ 5 files changed, 71 insertions(+), 6 deletions(-) diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml index d094172b0765..8f435dd72d7a 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -23,6 +23,7 @@ optimize_for_size = [] # Make `RefCell` store additional debugging information, which is printed out when # a borrow error occurs debug_refcell = [] +llvm_enzyme = [] [lints.rust.unexpected_cfgs] level = "warn" @@ -38,4 +39,6 @@ check-cfg = [ 'cfg(target_has_reliable_f16_math)', 'cfg(target_has_reliable_f128)', 'cfg(target_has_reliable_f128_math)', + 'cfg(llvm_enzyme)', + ] diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 7d7c4147983c..4dabf4a561ec 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -1511,13 +1511,43 @@ macro_rules! include { /// If used on an input argument, a new shadow argument of the same type will be created, /// directly following the original argument. /// + /// ### Usage examples: + /// + /// ```rust,ignore (autodiff requires a -Z flag as well as fat-lto for testing) + /// #![feature(autodiff)] + /// use std::autodiff::*; + /// #[autodiff_forward(rb_fwd1, Dual, Const, Dual)] + /// #[autodiff_forward(rb_fwd2, Const, Dual, Dual)] + /// #[autodiff_forward(rb_fwd3, Dual, Dual, Dual)] + /// fn rosenbrock(x: f64, y: f64) -> f64 { + /// (1.0 - x).powi(2) + 100.0 * (y - x.powi(2)).powi(2) + /// } + /// #[autodiff_forward(rb_inp_fwd, Dual, Dual, Dual)] + /// fn rosenbrock_inp(x: f64, y: f64, out: &mut f64) { + /// *out = (1.0 - x).powi(2) + 100.0 * (y - x.powi(2)).powi(2); + /// } + /// + /// fn main() { + /// let x0 = rosenbrock(1.0, 3.0); // 400.0 + /// let (x1, dx1) = rb_fwd1(1.0, 1.0, 3.0); // (400.0, -800.0) + /// let (x2, dy1) = rb_fwd2(1.0, 3.0, 1.0); // (400.0, 400.0) + /// // When seeding both arguments at once the tangent return is the sum of both. + /// let (x3, dxy) = rb_fwd3(1.0, 1.0, 3.0, 1.0); // (400.0, -400.0) + /// + /// let mut out = 0.0; + /// let mut dout = 0.0; + /// rb_inp_fwd(1.0, 1.0, 3.0, 1.0, &mut out, &mut dout); + /// // (out, dout) == (400.0, -400.0) + /// } + /// ``` + /// /// We might want to track how one input float affects one or more output floats. In this case, /// the shadow of one input should be initialized to `1.0`, while the shadows of the other /// inputs should be initialized to `0.0`. The shadow of the output(s) should be initialized to /// `0.0`. After calling the generated function, the shadow of the input will be zeroed, /// while the shadow(s) of the output(s) will contain the derivatives. Forward mode is generally /// more efficient if we have more output floats marked as `Dual` than input floats. - /// Related information can also be found unter the term "Vector-Jacobian product" (VJP). + /// Related information can also be found under the term "Vector-Jacobian product" (VJP). #[unstable(feature = "autodiff", issue = "124509")] #[allow_internal_unstable(rustc_attrs)] #[allow_internal_unstable(core_intrinsics)] @@ -1552,19 +1582,45 @@ macro_rules! include { /// `Const` should be used on non-float arguments, or float-based arguments as an optimization /// if we are not interested in computing the derivatives with respect to this argument. /// + /// ### Usage examples: + /// + /// ```rust,ignore (autodiff requires a -Z flag as well as fat-lto for testing) + /// #![feature(autodiff)] + /// use std::autodiff::*; + /// #[autodiff_reverse(rb_rev, Active, Active, Active)] + /// fn rosenbrock(x: f64, y: f64) -> f64 { + /// (1.0 - x).powi(2) + 100.0 * (y - x.powi(2)).powi(2) + /// } + /// #[autodiff_reverse(rb_inp_rev, Active, Active, Duplicated)] + /// fn rosenbrock_inp(x: f64, y: f64, out: &mut f64) { + /// *out = (1.0 - x).powi(2) + 100.0 * (y - x.powi(2)).powi(2); + /// } + /// + /// fn main() { + /// let (output1, dx1, dy1) = rb_rev(1.0, 3.0, 1.0); + /// dbg!(output1, dx1, dy1); // (400.0, -800.0, 400.0) + /// let mut output2 = 0.0; + /// let mut seed = 1.0; + /// let (dx2, dy2) = rb_inp_rev(1.0, 3.0, &mut output2, &mut seed); + /// // (dx2, dy2, output2, seed) == (-800.0, 400.0, 400.0, 0.0) + /// } + /// ``` + /// + /// /// We often want to track how one or more input floats affect one output float. This output can - /// be a scalar return value, or a mutable reference or pointer argument. In this case, the - /// shadow of the input should be marked as duplicated and initialized to `0.0`. The shadow of + /// be a scalar return value, or a mutable reference or pointer argument. In the latter case, the + /// mutable input should be marked as duplicated and its shadow initialized to `0.0`. The shadow of /// the output should be marked as active or duplicated and initialized to `1.0`. After calling - /// the generated function, the shadow(s) of the input(s) will contain the derivatives. If the - /// function has more than one output float marked as active or duplicated, users might want to + /// the generated function, the shadow(s) of the input(s) will contain the derivatives. The + /// shadow of the outputs ("seed") will be reset to zero. + /// If the function has more than one output float marked as active or duplicated, users might want to /// set one of them to `1.0` and the others to `0.0` to compute partial derivatives. /// Unlike forward-mode, a call to the generated function does not reset the shadow of the /// inputs. /// Reverse mode is generally more efficient if we have more active/duplicated input than /// output floats. /// - /// Related information can also be found unter the term "Jacobian-Vector Product" (JVP). + /// Related information can also be found under the term "Jacobian-Vector Product" (JVP). #[unstable(feature = "autodiff", issue = "124509")] #[allow_internal_unstable(rustc_attrs)] #[allow_internal_unstable(core_intrinsics)] diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 685c2cf162ab..1ba9f7e32d91 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -126,6 +126,7 @@ optimize_for_size = ["core/optimize_for_size", "alloc/optimize_for_size"] # a borrow error occurs debug_refcell = ["core/debug_refcell"] +llvm_enzyme = ["core/llvm_enzyme"] # Enable std_detect features: std_detect_file_io = ["std_detect/std_detect_file_io"] diff --git a/library/sysroot/Cargo.toml b/library/sysroot/Cargo.toml index ee4aec61872e..eec8c461b6db 100644 --- a/library/sysroot/Cargo.toml +++ b/library/sysroot/Cargo.toml @@ -35,3 +35,4 @@ profiler = ["dep:profiler_builtins"] std_detect_file_io = ["std/std_detect_file_io"] std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"] windows_raw_dylib = ["std/windows_raw_dylib"] +llvm_enzyme = ["std/llvm_enzyme"] diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index dd30f05b7283..fca6815a8ab5 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -846,6 +846,10 @@ fn std_features(&self, target: TargetSelection) -> String { features.insert("compiler-builtins-mem"); } + if self.config.llvm_enzyme { + features.insert("llvm_enzyme"); + } + features.into_iter().collect::>().join(" ") } From 1f7a3427f250d1fdc3fb3a059bd8e47b6aedfd1e Mon Sep 17 00:00:00 2001 From: Makai Date: Sat, 1 Nov 2025 15:51:46 +0800 Subject: [PATCH 052/194] rustc_public: fix some issues --- compiler/rustc_public/src/compiler_interface.rs | 2 ++ compiler/rustc_public/src/unstable/mod.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index b17d31f2b91a..e01ffa230904 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -835,6 +835,8 @@ pub(crate) fn associated_items(&self, def_id: DefId) -> AssocItems { // A thread local variable that stores a pointer to [`CompilerInterface`]. scoped_tls::scoped_thread_local!(static TLV: Cell<*const ()>); +// remove this cfg when we have a stable driver. +#[cfg(feature = "rustc_internal")] pub(crate) fn run<'tcx, F, T>(interface: &CompilerInterface<'tcx>, f: F) -> Result where F: FnOnce() -> T, diff --git a/compiler/rustc_public/src/unstable/mod.rs b/compiler/rustc_public/src/unstable/mod.rs index 72b14cfa072a..2b69fb5408cf 100644 --- a/compiler/rustc_public/src/unstable/mod.rs +++ b/compiler/rustc_public/src/unstable/mod.rs @@ -22,6 +22,7 @@ /// /// This trait is only for [`RustcInternal`]. Any other other access to rustc's internals /// should go through [`rustc_public_bridge::context::CompilerCtxt`]. +#[cfg_attr(not(feature = "rustc_internal"), allow(unreachable_pub))] pub trait InternalCx<'tcx>: Copy + Clone { fn tcx(self) -> TyCtxt<'tcx>; @@ -59,6 +60,7 @@ fn mk_bound_variable_kinds_from_iter(self, iter: I) -> T::Output /// between internal MIR and rustc_public's IR constructs. /// However, they should be used seldom and they have no influence in this crate semver. #[doc(hidden)] +#[cfg_attr(not(feature = "rustc_internal"), allow(unreachable_pub))] pub trait Stable<'tcx>: PointeeSized { /// The stable representation of the type implementing Stable. type T; @@ -78,6 +80,7 @@ fn stable<'cx>( /// between internal MIR and rustc_public's IR constructs. /// They should be used seldom as they have no stability guarantees. #[doc(hidden)] +#[cfg_attr(not(feature = "rustc_internal"), allow(unreachable_pub))] pub trait RustcInternal { type T<'tcx>; fn internal<'tcx>( From 6766db0eb7d72f03e44387574b600d40e47e204e Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Mon, 17 Nov 2025 13:11:54 +0000 Subject: [PATCH 053/194] Prepare for merging from rust-lang/rust This updates the rust-version file to cc328c12382f05d8ddf6ffc8139deb7985270ad8. --- src/doc/rustc-dev-guide/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index 25bb5e923183..8c841aac8eb6 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -69d4d5fc0e4db60272aac85ef27ecccef5764f3a +cc328c12382f05d8ddf6ffc8139deb7985270ad8 From 82ff614b34a5e8da38c06b9d227d146ce023a68a Mon Sep 17 00:00:00 2001 From: sayantn Date: Mon, 17 Nov 2025 02:20:07 +0530 Subject: [PATCH 054/194] Enable const-testing for the ported SIMD intrinsics --- tests/auxiliary/minisimd.rs | 114 +++++++++++---- tests/ui/simd/intrinsic/float-math-pass.rs | 85 ++++++----- tests/ui/simd/intrinsic/float-minmax-pass.rs | 10 +- .../simd/intrinsic/generic-arithmetic-pass.rs | 10 +- .../generic-arithmetic-saturating-pass.rs | 10 +- tests/ui/simd/intrinsic/generic-as.rs | 10 +- .../ui/simd/intrinsic/generic-bitmask-pass.rs | 40 +++--- tests/ui/simd/intrinsic/generic-bswap-byte.rs | 11 +- tests/ui/simd/intrinsic/generic-cast-pass.rs | 10 +- .../intrinsic/generic-cast-pointer-width.rs | 20 +-- .../simd/intrinsic/generic-comparison-pass.rs | 45 +++--- .../simd/intrinsic/generic-elements-pass.rs | 132 +++++++++--------- .../intrinsic/generic-gather-scatter-pass.rs | 100 ++++++------- .../simd/intrinsic/generic-reduction-pass.rs | 81 ++++++----- .../ui/simd/intrinsic/generic-select-pass.rs | 10 +- tests/ui/simd/masked-load-store.rs | 10 +- tests/ui/simd/simd-bitmask-notpow2.rs | 20 ++- tests/ui/simd/simd-bitmask.rs | 10 +- 18 files changed, 440 insertions(+), 288 deletions(-) diff --git a/tests/auxiliary/minisimd.rs b/tests/auxiliary/minisimd.rs index ff0c996de1c8..38e2621698db 100644 --- a/tests/auxiliary/minisimd.rs +++ b/tests/auxiliary/minisimd.rs @@ -10,6 +10,10 @@ #![allow(unused)] #![allow(non_camel_case_types)] +// FIXME: `cfg(minisimd_const)` is used to toggle use of const trait impls, which require a few +// nightly features. Remove this when `const_trait_impls`, `const_cmp` and `const_index` are +// stablilized. +#![allow(unexpected_cfgs)] // The field is currently left `pub` for convenience in porting tests, many of // which attempt to just construct it directly. That still works; it's just the @@ -24,39 +28,32 @@ fn clone(&self) -> Self { } } -impl PartialEq for Simd { - fn eq(&self, other: &Self) -> bool { - self.as_array() == other.as_array() - } -} - impl core::fmt::Debug for Simd { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { <[T; N] as core::fmt::Debug>::fmt(self.as_array(), f) } } -impl core::ops::Index for Simd { - type Output = T; - fn index(&self, i: usize) -> &T { - &self.as_array()[i] - } -} - impl Simd { pub const fn from_array(a: [T; N]) -> Self { Simd(a) } - pub fn as_array(&self) -> &[T; N] { + pub const fn as_array(&self) -> &[T; N] { let p: *const Self = self; unsafe { &*p.cast::<[T; N]>() } } - pub fn into_array(self) -> [T; N] + pub const fn into_array(self) -> [T; N] where T: Copy, { *self.as_array() } + pub const fn splat(a: T) -> Self + where + T: Copy, + { + Self([a; N]) + } } pub type u8x2 = Simd; @@ -109,6 +106,14 @@ impl Simd { pub type i128x2 = Simd; pub type i128x4 = Simd; +pub type usizex2 = Simd; +pub type usizex4 = Simd; +pub type usizex8 = Simd; + +pub type isizex2 = Simd; +pub type isizex4 = Simd; +pub type isizex8 = Simd; + pub type f32x2 = Simd; pub type f32x4 = Simd; pub type f32x8 = Simd; @@ -122,7 +127,7 @@ impl Simd { // which attempt to just construct it directly. That still works; it's just the // `.0` projection that doesn't. #[repr(simd, packed)] -#[derive(Copy)] +#[derive(Copy, Eq)] pub struct PackedSimd(pub [T; N]); impl Clone for PackedSimd { @@ -131,12 +136,6 @@ fn clone(&self) -> Self { } } -impl PartialEq for PackedSimd { - fn eq(&self, other: &Self) -> bool { - self.as_array() == other.as_array() - } -} - impl core::fmt::Debug for PackedSimd { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { <[T; N] as core::fmt::Debug>::fmt(self.as_array(), f) @@ -147,14 +146,81 @@ impl PackedSimd { pub const fn from_array(a: [T; N]) -> Self { PackedSimd(a) } - pub fn as_array(&self) -> &[T; N] { + pub const fn as_array(&self) -> &[T; N] { let p: *const Self = self; unsafe { &*p.cast::<[T; N]>() } } - pub fn into_array(self) -> [T; N] + pub const fn into_array(self) -> [T; N] where T: Copy, { *self.as_array() } + pub const fn splat(a: T) -> Self + where + T: Copy, + { + Self([a; N]) + } } + +// As `const_trait_impl` is a language feature with specialized syntax, we have to use them in a way +// such that it doesn't get parsed as Rust code unless `cfg(minisimd_const)` is on. The easiest way +// for that is a macro + +macro_rules! impl_traits { + ($($const_:ident)?) => { + impl $($const_)? PartialEq for Simd { + fn eq(&self, other: &Self) -> bool { + self.as_array() == other.as_array() + } + } + + impl $($const_)? core::ops::Index for Simd { + type Output = T; + fn index(&self, i: usize) -> &T { + &self.as_array()[i] + } + } + + impl $($const_)? PartialEq for PackedSimd + { + fn eq(&self, other: &Self) -> bool { + self.as_array() == other.as_array() + } + } + }; +} + +#[cfg(minisimd_const)] +impl_traits!(const); + +#[cfg(not(minisimd_const))] +impl_traits!(); + +/// Version of `assert_eq` that ignores fancy runtime printing in const context. +/// FIXME: Remove once is fixed. +#[cfg(minisimd_const)] +#[macro_export] +macro_rules! assert_eq { + ($left:expr, $right:expr $(,)?) => { + assert_eq!( + $left, + $right, + concat!("`", stringify!($left), "` == `", stringify!($right), "`") + ); + }; + ($left:expr, $right:expr$(, $($arg:tt)+)?) => { + { + let left = $left; + let right = $right; + // type inference works better with the concrete type on the + // left, but humans work better with the expected on the + // right + assert!(right == left, $($($arg)*),*); + } + }; +} + +#[cfg(minisimd_const)] +use assert_eq; diff --git a/tests/ui/simd/intrinsic/float-math-pass.rs b/tests/ui/simd/intrinsic/float-math-pass.rs index 743aae8d1c31..8797a8a9dca4 100644 --- a/tests/ui/simd/intrinsic/float-math-pass.rs +++ b/tests/ui/simd/intrinsic/float-math-pass.rs @@ -1,6 +1,7 @@ //@ run-pass //@ ignore-emscripten //@ ignore-android +//@ compile-flags: --cfg minisimd_const // FIXME: this test fails on arm-android because the NDK version 14 is too old. // It needs at least version 18. We disable it on all android build bots because @@ -8,7 +9,7 @@ // Test that the simd floating-point math intrinsics produce correct results. -#![feature(repr_simd, intrinsics, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #![allow(non_camel_case_types)] #[path = "../../../auxiliary/minisimd.rs"] @@ -20,7 +21,10 @@ macro_rules! assert_approx_eq_f32 { ($a:expr, $b:expr) => {{ let (a, b) = (&$a, &$b); - assert!((*a - *b).abs() < 1.0e-6, "{} is not approximately equal to {}", *a, *b); + assert!( + (*a - *b).abs() < 1.0e-6, + concat!(stringify!($a), " is not approximately equal to ", stringify!($b)) + ); }}; } macro_rules! assert_approx_eq { @@ -34,7 +38,7 @@ macro_rules! assert_approx_eq { }}; } -fn main() { +const fn simple_math() { let x = f32x4::from_array([1.0, 1.0, 1.0, 1.0]); let y = f32x4::from_array([-1.0, -1.0, -1.0, -1.0]); let z = f32x4::from_array([0.0, 0.0, 0.0, 0.0]); @@ -43,37 +47,7 @@ fn main() { unsafe { let r = simd_fabs(y); - assert_approx_eq!(x, r); - - let r = simd_fcos(z); - assert_approx_eq!(x, r); - - let r = simd_fexp(z); - assert_approx_eq!(x, r); - - let r = simd_fexp2(z); - assert_approx_eq!(x, r); - - let r = simd_fma(x, h, h); - assert_approx_eq!(x, r); - - let r = simd_relaxed_fma(x, h, h); - assert_approx_eq!(x, r); - - let r = simd_fsqrt(x); - assert_approx_eq!(x, r); - - let r = simd_flog(x); - assert_approx_eq!(z, r); - - let r = simd_flog2(x); - assert_approx_eq!(z, r); - - let r = simd_flog10(x); - assert_approx_eq!(z, r); - - let r = simd_fsin(z); - assert_approx_eq!(z, r); + assert_eq!(x, r); // rounding functions let r = simd_floor(h); @@ -90,5 +64,48 @@ fn main() { let r = simd_trunc(h); assert_eq!(z, r); + + let r = simd_fma(x, h, h); + assert_approx_eq!(x, r); + + let r = simd_relaxed_fma(x, h, h); + assert_approx_eq!(x, r); } } + +fn special_math() { + let x = f32x4::from_array([1.0, 1.0, 1.0, 1.0]); + let z = f32x4::from_array([0.0, 0.0, 0.0, 0.0]); + + unsafe { + let r = simd_fcos(z); + assert_approx_eq!(x, r); + + let r = simd_fexp(z); + assert_approx_eq!(x, r); + + let r = simd_fexp2(z); + assert_approx_eq!(x, r); + + let r = simd_fsqrt(x); + assert_approx_eq!(x, r); + + let r = simd_flog(x); + assert_approx_eq!(z, r); + + let r = simd_flog2(x); + assert_approx_eq!(z, r); + + let r = simd_flog10(x); + assert_approx_eq!(z, r); + + let r = simd_fsin(z); + assert_approx_eq!(z, r); + } +} + +fn main() { + const { simple_math() }; + simple_math(); + special_math(); +} diff --git a/tests/ui/simd/intrinsic/float-minmax-pass.rs b/tests/ui/simd/intrinsic/float-minmax-pass.rs index 12210ba0ad12..4b6a35556ed5 100644 --- a/tests/ui/simd/intrinsic/float-minmax-pass.rs +++ b/tests/ui/simd/intrinsic/float-minmax-pass.rs @@ -1,9 +1,10 @@ //@ run-pass //@ ignore-emscripten +//@ compile-flags: --cfg minisimd_const // Test that the simd_f{min,max} intrinsics produce the correct results. -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #![allow(non_camel_case_types)] #[path = "../../../auxiliary/minisimd.rs"] @@ -12,7 +13,7 @@ use std::intrinsics::simd::*; -fn main() { +const fn minmax() { let x = f32x4::from_array([1.0, 2.0, 3.0, 4.0]); let y = f32x4::from_array([2.0, 1.0, 4.0, 3.0]); @@ -47,3 +48,8 @@ fn main() { assert_eq!(maxn, y); } } + +fn main() { + const { minmax() }; + minmax(); +} diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index 09f5d41a87c1..62782db37ed4 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -1,8 +1,9 @@ //@ run-pass //@ ignore-backends: gcc +//@ compile-flags: --cfg minisimd_const #![allow(non_camel_case_types)] -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../../auxiliary/minisimd.rs"] mod minisimd; @@ -20,7 +21,7 @@ macro_rules! all_eq { use std::intrinsics::simd::*; -fn main() { +const fn arithmetic() { let x1 = i32x4::from_array([1, 2, 3, 4]); let y1 = U32::<4>::from_array([1, 2, 3, 4]); let z1 = f32x4::from_array([1.0, 2.0, 3.0, 4.0]); @@ -224,3 +225,8 @@ fn main() { all_eq!(simd_cttz(y1), U32::<4>::from_array([0, 1, 0, 2])); } } + +fn main() { + const { arithmetic() }; + arithmetic(); +} diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs index a997f1237034..f139bf322010 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs @@ -1,8 +1,9 @@ //@ run-pass //@ ignore-emscripten +//@ compile-flags: --cfg minisimd_const #![allow(non_camel_case_types)] -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../../auxiliary/minisimd.rs"] mod minisimd; @@ -12,7 +13,7 @@ type I32 = Simd; -fn main() { +const fn saturating() { // unsigned { const M: u32 = u32::MAX; @@ -84,3 +85,8 @@ fn main() { } } } + +fn main() { + const { saturating() }; + saturating(); +} diff --git a/tests/ui/simd/intrinsic/generic-as.rs b/tests/ui/simd/intrinsic/generic-as.rs index bba712e62966..b81402e9dca4 100644 --- a/tests/ui/simd/intrinsic/generic-as.rs +++ b/tests/ui/simd/intrinsic/generic-as.rs @@ -1,7 +1,8 @@ //@ run-pass //@ ignore-backends: gcc +//@ compile-flags: --cfg minisimd_const -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../../auxiliary/minisimd.rs"] mod minisimd; @@ -11,7 +12,7 @@ type V = Simd; -fn main() { +const fn as_simd() { unsafe { let u: V:: = Simd([u32::MIN, u32::MAX]); let i: V = simd_as(u); @@ -47,3 +48,8 @@ fn main() { assert_eq!(u[1], f[1] as usize); } } + +fn main() { + const { as_simd() }; + as_simd(); +} diff --git a/tests/ui/simd/intrinsic/generic-bitmask-pass.rs b/tests/ui/simd/intrinsic/generic-bitmask-pass.rs index cb3221e21d53..afe96de63bec 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask-pass.rs +++ b/tests/ui/simd/intrinsic/generic-bitmask-pass.rs @@ -1,41 +1,31 @@ //@ run-pass -#![allow(non_camel_case_types)] //@ ignore-emscripten //@ ignore-endian-big behavior of simd_bitmask is endian-specific +//@ compile-flags: --cfg minisimd_const // Test that the simd_bitmask intrinsic produces correct results. -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] + +#[path = "../../../auxiliary/minisimd.rs"] +mod minisimd; +use minisimd::*; use std::intrinsics::simd::simd_bitmask; -#[repr(simd)] -#[derive(Copy, Clone, PartialEq, Debug)] -struct u32x4(pub [u32; 4]); - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq, Debug)] -struct u8x4(pub [u8; 4]); - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq, Debug)] -struct Tx4(pub [T; 4]); - -fn main() { - let z = u32x4([0, 0, 0, 0]); +const fn bitmask() { + let z = u32x4::from_array([0, 0, 0, 0]); let ez = 0_u8; - let o = u32x4([!0, !0, !0, !0]); + let o = u32x4::from_array([!0, !0, !0, !0]); let eo = 0b_1111_u8; - let m0 = u32x4([!0, 0, !0, 0]); + let m0 = u32x4::from_array([!0, 0, !0, 0]); let e0 = 0b_0000_0101_u8; - // Check that the MSB is extracted: - let m = u8x4([0b_1000_0000, 0b_0100_0001, 0b_1100_0001, 0b_1111_1111]); let e = 0b_1101; // Check usize / isize - let msize: Tx4 = Tx4([usize::MAX, 0, usize::MAX, usize::MAX]); + let msize = usizex4::from_array([usize::MAX, 0, usize::MAX, usize::MAX]); unsafe { let r: u8 = simd_bitmask(z); @@ -47,10 +37,12 @@ fn main() { let r: u8 = simd_bitmask(m0); assert_eq!(r, e0); - let r: u8 = simd_bitmask(m); - assert_eq!(r, e); - let r: u8 = simd_bitmask(msize); assert_eq!(r, e); } } + +fn main() { + const { bitmask() }; + bitmask(); +} diff --git a/tests/ui/simd/intrinsic/generic-bswap-byte.rs b/tests/ui/simd/intrinsic/generic-bswap-byte.rs index d30a560b1c2e..52015c552aba 100644 --- a/tests/ui/simd/intrinsic/generic-bswap-byte.rs +++ b/tests/ui/simd/intrinsic/generic-bswap-byte.rs @@ -1,6 +1,6 @@ //@ run-pass -#![feature(repr_simd, core_intrinsics)] -#![allow(non_camel_case_types)] +//@ compile-flags: --cfg minisimd_const +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../../auxiliary/minisimd.rs"] mod minisimd; @@ -8,9 +8,14 @@ use std::intrinsics::simd::simd_bswap; -fn main() { +const fn bswap() { unsafe { assert_eq!(simd_bswap(i8x4::from_array([0, 1, 2, 3])).into_array(), [0, 1, 2, 3]); assert_eq!(simd_bswap(u8x4::from_array([0, 1, 2, 3])).into_array(), [0, 1, 2, 3]); } } + +fn main() { + const { bswap() }; + bswap(); +} diff --git a/tests/ui/simd/intrinsic/generic-cast-pass.rs b/tests/ui/simd/intrinsic/generic-cast-pass.rs index 0c3b00d65bf5..9aadb5d0008a 100644 --- a/tests/ui/simd/intrinsic/generic-cast-pass.rs +++ b/tests/ui/simd/intrinsic/generic-cast-pass.rs @@ -1,6 +1,7 @@ //@ run-pass +//@ compile-flags: --cfg minisimd_const -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../../auxiliary/minisimd.rs"] mod minisimd; @@ -12,7 +13,7 @@ type V = Simd; -fn main() { +const fn cast() { unsafe { let u: V:: = Simd([i16::MIN as u32, i16::MAX as u32]); let i: V = simd_cast(u); @@ -56,3 +57,8 @@ fn main() { assert_eq!(u[1], f[1] as usize); } } + +fn main() { + const { cast() }; + cast(); +} diff --git a/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs b/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs index 594d1d25d165..7e50fec56565 100644 --- a/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs +++ b/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs @@ -1,5 +1,6 @@ //@ run-pass -#![feature(repr_simd, core_intrinsics)] +//@ compile-flags: --cfg minisimd_const +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../../auxiliary/minisimd.rs"] mod minisimd; @@ -9,17 +10,16 @@ type V = Simd; -fn main() { +const fn cast_ptr_width() { let u: V:: = Simd([0, 1, 2, 3]); let uu32: V = unsafe { simd_cast(u) }; let ui64: V = unsafe { simd_cast(u) }; - for (u, (uu32, ui64)) in u - .as_array() - .iter() - .zip(uu32.as_array().iter().zip(ui64.as_array().iter())) - { - assert_eq!(*u as u32, *uu32); - assert_eq!(*u as i64, *ui64); - } + assert_eq!(uu32, V::::from_array([0, 1, 2, 3])); + assert_eq!(ui64, V::::from_array([0, 1, 2, 3])); +} + +fn main() { + const { cast_ptr_width() }; + cast_ptr_width(); } diff --git a/tests/ui/simd/intrinsic/generic-comparison-pass.rs b/tests/ui/simd/intrinsic/generic-comparison-pass.rs index 3e803e8f6032..a4d19faeeeed 100644 --- a/tests/ui/simd/intrinsic/generic-comparison-pass.rs +++ b/tests/ui/simd/intrinsic/generic-comparison-pass.rs @@ -1,7 +1,14 @@ //@ run-pass +//@ compile-flags: --cfg minisimd_const -#![feature(repr_simd, core_intrinsics, macro_metavar_expr_concat)] -#![allow(non_camel_case_types)] +#![feature( + repr_simd, + core_intrinsics, + const_trait_impl, + const_cmp, + const_index, + macro_metavar_expr_concat +)] #[path = "../../../auxiliary/minisimd.rs"] mod minisimd; @@ -25,27 +32,26 @@ macro_rules! cmp { macro_rules! tests { ($($lhs: ident, $rhs: ident;)*) => {{ $( - (|| { - cmp!(eq($lhs, $rhs)); - cmp!(ne($lhs, $rhs)); + cmp!(eq($lhs, $rhs)); + cmp!(ne($lhs, $rhs)); - // test both directions - cmp!(lt($lhs, $rhs)); - cmp!(lt($rhs, $lhs)); + // test both directions + cmp!(lt($lhs, $rhs)); + cmp!(lt($rhs, $lhs)); - cmp!(le($lhs, $rhs)); - cmp!(le($rhs, $lhs)); + cmp!(le($lhs, $rhs)); + cmp!(le($rhs, $lhs)); - cmp!(gt($lhs, $rhs)); - cmp!(gt($rhs, $lhs)); + cmp!(gt($lhs, $rhs)); + cmp!(gt($rhs, $lhs)); - cmp!(ge($lhs, $rhs)); - cmp!(ge($rhs, $lhs)); - })(); - )* + cmp!(ge($lhs, $rhs)); + cmp!(ge($rhs, $lhs)); + )* }} } -fn main() { + +const fn compare() { // 13 vs. -100 tests that we get signed vs. unsigned comparisons // correct (i32: 13 > -100, u32: 13 < -100). let i1 = i32x4(10, -11, 12, 13); let i1 = i32x4::from_array([10, -11, 12, 13]); @@ -89,3 +95,8 @@ fn main() { } } } + +fn main() { + const { compare() }; + compare(); +} diff --git a/tests/ui/simd/intrinsic/generic-elements-pass.rs b/tests/ui/simd/intrinsic/generic-elements-pass.rs index f441d992e11b..680e0dcfd7d6 100644 --- a/tests/ui/simd/intrinsic/generic-elements-pass.rs +++ b/tests/ui/simd/intrinsic/generic-elements-pass.rs @@ -1,6 +1,7 @@ //@ run-pass +//@ compile-flags: --cfg minisimd_const -#![feature(repr_simd, intrinsics, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../../auxiliary/minisimd.rs"] mod minisimd; @@ -20,11 +21,59 @@ macro_rules! all_eq { // type inference works better with the concrete type on the // left, but humans work better with the expected on the // right. - assert!(b == a, "{:?} != {:?}", a, b); + assert!(b == a, concat!(stringify!($a), "!=", stringify!($b))); }}; } -fn main() { +fn extract_insert_dyn() { + let x2 = i32x2::from_array([20, 21]); + let x4 = i32x4::from_array([40, 41, 42, 43]); + let x8 = i32x8::from_array([80, 81, 82, 83, 84, 85, 86, 87]); + + unsafe { + all_eq!(simd_insert_dyn(x2, 0, 100), i32x2::from_array([100, 21])); + all_eq!(simd_insert_dyn(x2, 1, 100), i32x2::from_array([20, 100])); + + all_eq!(simd_insert_dyn(x4, 0, 100), i32x4::from_array([100, 41, 42, 43])); + all_eq!(simd_insert_dyn(x4, 1, 100), i32x4::from_array([40, 100, 42, 43])); + all_eq!(simd_insert_dyn(x4, 2, 100), i32x4::from_array([40, 41, 100, 43])); + all_eq!(simd_insert_dyn(x4, 3, 100), i32x4::from_array([40, 41, 42, 100])); + + all_eq!(simd_insert_dyn(x8, 0, 100), i32x8::from_array([100, 81, 82, 83, 84, 85, 86, 87])); + all_eq!(simd_insert_dyn(x8, 1, 100), i32x8::from_array([80, 100, 82, 83, 84, 85, 86, 87])); + all_eq!(simd_insert_dyn(x8, 2, 100), i32x8::from_array([80, 81, 100, 83, 84, 85, 86, 87])); + all_eq!(simd_insert_dyn(x8, 3, 100), i32x8::from_array([80, 81, 82, 100, 84, 85, 86, 87])); + all_eq!(simd_insert_dyn(x8, 4, 100), i32x8::from_array([80, 81, 82, 83, 100, 85, 86, 87])); + all_eq!(simd_insert_dyn(x8, 5, 100), i32x8::from_array([80, 81, 82, 83, 84, 100, 86, 87])); + all_eq!(simd_insert_dyn(x8, 6, 100), i32x8::from_array([80, 81, 82, 83, 84, 85, 100, 87])); + all_eq!(simd_insert_dyn(x8, 7, 100), i32x8::from_array([80, 81, 82, 83, 84, 85, 86, 100])); + + all_eq!(simd_extract_dyn(x2, 0), 20); + all_eq!(simd_extract_dyn(x2, 1), 21); + + all_eq!(simd_extract_dyn(x4, 0), 40); + all_eq!(simd_extract_dyn(x4, 1), 41); + all_eq!(simd_extract_dyn(x4, 2), 42); + all_eq!(simd_extract_dyn(x4, 3), 43); + + all_eq!(simd_extract_dyn(x8, 0), 80); + all_eq!(simd_extract_dyn(x8, 1), 81); + all_eq!(simd_extract_dyn(x8, 2), 82); + all_eq!(simd_extract_dyn(x8, 3), 83); + all_eq!(simd_extract_dyn(x8, 4), 84); + all_eq!(simd_extract_dyn(x8, 5), 85); + all_eq!(simd_extract_dyn(x8, 6), 86); + all_eq!(simd_extract_dyn(x8, 7), 87); + } +} + +macro_rules! simd_shuffle { + ($a:expr, $b:expr, $swizzle:expr) => { + simd_shuffle($a, $b, const { SimdShuffleIdx($swizzle) }) + }; +} + +const fn swizzle() { let x2 = i32x2::from_array([20, 21]); let x4 = i32x4::from_array([40, 41, 42, 43]); let x8 = i32x8::from_array([80, 81, 82, 83, 84, 85, 86, 87]); @@ -63,83 +112,36 @@ fn main() { all_eq!(simd_extract(x8, 6), 86); all_eq!(simd_extract(x8, 7), 87); } - unsafe { - all_eq!(simd_insert_dyn(x2, 0, 100), i32x2::from_array([100, 21])); - all_eq!(simd_insert_dyn(x2, 1, 100), i32x2::from_array([20, 100])); - - all_eq!(simd_insert_dyn(x4, 0, 100), i32x4::from_array([100, 41, 42, 43])); - all_eq!(simd_insert_dyn(x4, 1, 100), i32x4::from_array([40, 100, 42, 43])); - all_eq!(simd_insert_dyn(x4, 2, 100), i32x4::from_array([40, 41, 100, 43])); - all_eq!(simd_insert_dyn(x4, 3, 100), i32x4::from_array([40, 41, 42, 100])); - - all_eq!(simd_insert_dyn(x8, 0, 100), i32x8::from_array([100, 81, 82, 83, 84, 85, 86, 87])); - all_eq!(simd_insert_dyn(x8, 1, 100), i32x8::from_array([80, 100, 82, 83, 84, 85, 86, 87])); - all_eq!(simd_insert_dyn(x8, 2, 100), i32x8::from_array([80, 81, 100, 83, 84, 85, 86, 87])); - all_eq!(simd_insert_dyn(x8, 3, 100), i32x8::from_array([80, 81, 82, 100, 84, 85, 86, 87])); - all_eq!(simd_insert_dyn(x8, 4, 100), i32x8::from_array([80, 81, 82, 83, 100, 85, 86, 87])); - all_eq!(simd_insert_dyn(x8, 5, 100), i32x8::from_array([80, 81, 82, 83, 84, 100, 86, 87])); - all_eq!(simd_insert_dyn(x8, 6, 100), i32x8::from_array([80, 81, 82, 83, 84, 85, 100, 87])); - all_eq!(simd_insert_dyn(x8, 7, 100), i32x8::from_array([80, 81, 82, 83, 84, 85, 86, 100])); - - all_eq!(simd_extract_dyn(x2, 0), 20); - all_eq!(simd_extract_dyn(x2, 1), 21); - - all_eq!(simd_extract_dyn(x4, 0), 40); - all_eq!(simd_extract_dyn(x4, 1), 41); - all_eq!(simd_extract_dyn(x4, 2), 42); - all_eq!(simd_extract_dyn(x4, 3), 43); - - all_eq!(simd_extract_dyn(x8, 0), 80); - all_eq!(simd_extract_dyn(x8, 1), 81); - all_eq!(simd_extract_dyn(x8, 2), 82); - all_eq!(simd_extract_dyn(x8, 3), 83); - all_eq!(simd_extract_dyn(x8, 4), 84); - all_eq!(simd_extract_dyn(x8, 5), 85); - all_eq!(simd_extract_dyn(x8, 6), 86); - all_eq!(simd_extract_dyn(x8, 7), 87); - } let y2 = i32x2::from_array([120, 121]); let y4 = i32x4::from_array([140, 141, 142, 143]); let y8 = i32x8::from_array([180, 181, 182, 183, 184, 185, 186, 187]); unsafe { + all_eq!(simd_shuffle!(x2, y2, [3u32, 0]), i32x2::from_array([121, 20])); + all_eq!(simd_shuffle!(x2, y2, [3u32, 0, 1, 2]), i32x4::from_array([121, 20, 21, 120])); all_eq!( - simd_shuffle(x2, y2, const { SimdShuffleIdx([3u32, 0]) }), - i32x2::from_array([121, 20]) - ); - all_eq!( - simd_shuffle(x2, y2, const { SimdShuffleIdx([3u32, 0, 1, 2]) }), - i32x4::from_array([121, 20, 21, 120]) - ); - all_eq!( - simd_shuffle(x2, y2, const { SimdShuffleIdx([3u32, 0, 1, 2, 1, 2, 3, 0]) }), + simd_shuffle!(x2, y2, [3u32, 0, 1, 2, 1, 2, 3, 0]), i32x8::from_array([121, 20, 21, 120, 21, 120, 121, 20]) ); + all_eq!(simd_shuffle!(x4, y4, [7u32, 2]), i32x2::from_array([143, 42])); + all_eq!(simd_shuffle!(x4, y4, [7u32, 2, 5, 0]), i32x4::from_array([143, 42, 141, 40])); all_eq!( - simd_shuffle(x4, y4, const { SimdShuffleIdx([7u32, 2]) }), - i32x2::from_array([143, 42]) - ); - all_eq!( - simd_shuffle(x4, y4, const { SimdShuffleIdx([7u32, 2, 5, 0]) }), - i32x4::from_array([143, 42, 141, 40]) - ); - all_eq!( - simd_shuffle(x4, y4, const { SimdShuffleIdx([7u32, 2, 5, 0, 3, 6, 4, 1]) }), + simd_shuffle!(x4, y4, [7u32, 2, 5, 0, 3, 6, 4, 1]), i32x8::from_array([143, 42, 141, 40, 43, 142, 140, 41]) ); + all_eq!(simd_shuffle!(x8, y8, [11u32, 5]), i32x2::from_array([183, 85])); + all_eq!(simd_shuffle!(x8, y8, [11u32, 5, 15, 0]), i32x4::from_array([183, 85, 187, 80])); all_eq!( - simd_shuffle(x8, y8, const { SimdShuffleIdx([11u32, 5]) }), - i32x2::from_array([183, 85]) - ); - all_eq!( - simd_shuffle(x8, y8, const { SimdShuffleIdx([11u32, 5, 15, 0]) }), - i32x4::from_array([183, 85, 187, 80]) - ); - all_eq!( - simd_shuffle(x8, y8, const { SimdShuffleIdx([11u32, 5, 15, 0, 3, 8, 12, 1]) }), + simd_shuffle!(x8, y8, [11u32, 5, 15, 0, 3, 8, 12, 1]), i32x8::from_array([183, 85, 187, 80, 83, 180, 184, 81]) ); } } + +fn main() { + extract_insert_dyn(); + const { swizzle() }; + swizzle(); +} diff --git a/tests/ui/simd/intrinsic/generic-gather-scatter-pass.rs b/tests/ui/simd/intrinsic/generic-gather-scatter-pass.rs index c2418c019eda..96c104012384 100644 --- a/tests/ui/simd/intrinsic/generic-gather-scatter-pass.rs +++ b/tests/ui/simd/intrinsic/generic-gather-scatter-pass.rs @@ -1,9 +1,10 @@ //@ run-pass //@ ignore-emscripten +//@ compile-flags: --cfg minisimd_const // Test that the simd_{gather,scatter} intrinsics produce the correct results. -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #![allow(non_camel_case_types)] #[path = "../../../auxiliary/minisimd.rs"] @@ -14,48 +15,11 @@ type x4 = Simd; -fn main() { - let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; - - let default = x4::from_array([-3_f32, -3., -3., -3.]); - let s_strided = x4::from_array([0_f32, 2., -3., 6.]); +fn gather_scatter_of_ptrs() { + // test modifying array of *const f32 + let x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; let mask = x4::from_array([-1_i32, -1, 0, -1]); - // reading from *const - unsafe { - let pointer = x.as_ptr(); - let pointers = - x4::from_array(std::array::from_fn(|i| pointer.add(i * 2))); - - let r_strided = simd_gather(default, pointers, mask); - - assert_eq!(r_strided, s_strided); - } - - // reading from *mut - unsafe { - let pointer = x.as_mut_ptr(); - let pointers = - x4::from_array(std::array::from_fn(|i| pointer.add(i * 2))); - - let r_strided = simd_gather(default, pointers, mask); - - assert_eq!(r_strided, s_strided); - } - - // writing to *mut - unsafe { - let pointer = x.as_mut_ptr(); - let pointers = - x4::from_array(std::array::from_fn(|i| pointer.add(i * 2))); - - let values = x4::from_array([42_f32, 43_f32, 44_f32, 45_f32]); - simd_scatter(values, pointers, mask); - - assert_eq!(x, [42., 1., 43., 3., 4., 5., 45., 7.]); - } - - // test modifying array of *const f32 let mut y = [ &x[0] as *const f32, &x[1] as *const f32, @@ -73,8 +37,7 @@ fn main() { // reading from *const unsafe { let pointer = y.as_ptr(); - let pointers = - x4::from_array(std::array::from_fn(|i| pointer.add(i * 2))); + let pointers = x4::from_array([pointer, pointer.add(2), pointer.add(4), pointer.add(6)]); let r_strided = simd_gather(default, pointers, mask); @@ -84,8 +47,7 @@ fn main() { // reading from *mut unsafe { let pointer = y.as_mut_ptr(); - let pointers = - x4::from_array(std::array::from_fn(|i| pointer.add(i * 2))); + let pointers = x4::from_array([pointer, pointer.add(2), pointer.add(4), pointer.add(6)]); let r_strided = simd_gather(default, pointers, mask); @@ -95,8 +57,7 @@ fn main() { // writing to *mut unsafe { let pointer = y.as_mut_ptr(); - let pointers = - x4::from_array(std::array::from_fn(|i| pointer.add(i * 2))); + let pointers = x4::from_array([pointer, pointer.add(2), pointer.add(4), pointer.add(6)]); let values = x4::from_array([y[7], y[6], y[5], y[1]]); simd_scatter(values, pointers, mask); @@ -114,3 +75,48 @@ fn main() { assert_eq!(y, s); } } + +const fn gather_scatter() { + let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; + + let default = x4::from_array([-3_f32, -3., -3., -3.]); + let s_strided = x4::from_array([0_f32, 2., -3., 6.]); + let mask = x4::from_array([-1_i32, -1, 0, -1]); + + // reading from *const + unsafe { + let pointer = x.as_ptr(); + let pointers = x4::from_array([pointer, pointer.add(2), pointer.add(4), pointer.add(6)]); + + let r_strided = simd_gather(default, pointers, mask); + + assert_eq!(r_strided, s_strided); + } + + // reading from *mut + unsafe { + let pointer = x.as_mut_ptr(); + let pointers = x4::from_array([pointer, pointer.add(2), pointer.add(4), pointer.add(6)]); + + let r_strided = simd_gather(default, pointers, mask); + + assert_eq!(r_strided, s_strided); + } + + // writing to *mut + unsafe { + let pointer = x.as_mut_ptr(); + let pointers = x4::from_array([pointer, pointer.add(2), pointer.add(4), pointer.add(6)]); + + let values = x4::from_array([42_f32, 43_f32, 44_f32, 45_f32]); + simd_scatter(values, pointers, mask); + + assert_eq!(x, [42., 1., 43., 3., 4., 5., 45., 7.]); + } +} + +fn main() { + const { gather_scatter() }; + gather_scatter(); + gather_scatter_of_ptrs(); +} diff --git a/tests/ui/simd/intrinsic/generic-reduction-pass.rs b/tests/ui/simd/intrinsic/generic-reduction-pass.rs index 2d5d75447b66..2c615cd729e7 100644 --- a/tests/ui/simd/intrinsic/generic-reduction-pass.rs +++ b/tests/ui/simd/intrinsic/generic-reduction-pass.rs @@ -1,35 +1,46 @@ //@ run-pass -#![allow(non_camel_case_types)] //@ ignore-emscripten +//@ compile-flags: --cfg minisimd_const // Test that the simd_reduce_{op} intrinsics produce the correct results. -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] + +#[path = "../../../auxiliary/minisimd.rs"] +mod minisimd; +use minisimd::*; use std::intrinsics::simd::*; -#[repr(simd)] -#[derive(Copy, Clone)] -struct i32x4(pub [i32; 4]); -#[repr(simd)] -#[derive(Copy, Clone)] -struct u32x4(pub [u32; 4]); - -#[repr(simd)] -#[derive(Copy, Clone)] -struct f32x4(pub [f32; 4]); - -#[repr(simd)] -#[derive(Copy, Clone)] -struct b8x4(pub [i8; 4]); - -fn main() { +fn unordered() { unsafe { - let x = i32x4([1, -2, 3, 4]); + let x = i32x4::from_array([1, -2, 3, 4]); let r: i32 = simd_reduce_add_unordered(x); assert_eq!(r, 6_i32); let r: i32 = simd_reduce_mul_unordered(x); assert_eq!(r, -24_i32); + } + + unsafe { + let x = u32x4::from_array([1, 2, 3, 4]); + let r: u32 = simd_reduce_add_unordered(x); + assert_eq!(r, 10_u32); + let r: u32 = simd_reduce_mul_unordered(x); + assert_eq!(r, 24_u32); + } + + unsafe { + let x = f32x4::from_array([1., -2., 3., 4.]); + let r: f32 = simd_reduce_add_unordered(x); + assert_eq!(r, 6_f32); + let r: f32 = simd_reduce_mul_unordered(x); + assert_eq!(r, -24_f32); + } +} + +const fn ordered() { + unsafe { + let x = i32x4::from_array([1, -2, 3, 4]); let r: i32 = simd_reduce_add_ordered(x, -1); assert_eq!(r, 5_i32); let r: i32 = simd_reduce_mul_ordered(x, -1); @@ -40,7 +51,7 @@ fn main() { let r: i32 = simd_reduce_max(x); assert_eq!(r, 4_i32); - let x = i32x4([-1, -1, -1, -1]); + let x = i32x4::from_array([-1, -1, -1, -1]); let r: i32 = simd_reduce_and(x); assert_eq!(r, -1_i32); let r: i32 = simd_reduce_or(x); @@ -48,7 +59,7 @@ fn main() { let r: i32 = simd_reduce_xor(x); assert_eq!(r, 0_i32); - let x = i32x4([-1, -1, 0, -1]); + let x = i32x4::from_array([-1, -1, 0, -1]); let r: i32 = simd_reduce_and(x); assert_eq!(r, 0_i32); let r: i32 = simd_reduce_or(x); @@ -58,11 +69,7 @@ fn main() { } unsafe { - let x = u32x4([1, 2, 3, 4]); - let r: u32 = simd_reduce_add_unordered(x); - assert_eq!(r, 10_u32); - let r: u32 = simd_reduce_mul_unordered(x); - assert_eq!(r, 24_u32); + let x = u32x4::from_array([1, 2, 3, 4]); let r: u32 = simd_reduce_add_ordered(x, 1); assert_eq!(r, 11_u32); let r: u32 = simd_reduce_mul_ordered(x, 2); @@ -74,7 +81,7 @@ fn main() { assert_eq!(r, 4_u32); let t = u32::MAX; - let x = u32x4([t, t, t, t]); + let x = u32x4::from_array([t, t, t, t]); let r: u32 = simd_reduce_and(x); assert_eq!(r, t); let r: u32 = simd_reduce_or(x); @@ -82,7 +89,7 @@ fn main() { let r: u32 = simd_reduce_xor(x); assert_eq!(r, 0_u32); - let x = u32x4([t, t, 0, t]); + let x = u32x4::from_array([t, t, 0, t]); let r: u32 = simd_reduce_and(x); assert_eq!(r, 0_u32); let r: u32 = simd_reduce_or(x); @@ -92,11 +99,7 @@ fn main() { } unsafe { - let x = f32x4([1., -2., 3., 4.]); - let r: f32 = simd_reduce_add_unordered(x); - assert_eq!(r, 6_f32); - let r: f32 = simd_reduce_mul_unordered(x); - assert_eq!(r, -24_f32); + let x = f32x4::from_array([1., -2., 3., 4.]); let r: f32 = simd_reduce_add_ordered(x, 0.); assert_eq!(r, 6_f32); let r: f32 = simd_reduce_mul_ordered(x, 1.); @@ -113,22 +116,28 @@ fn main() { } unsafe { - let x = b8x4([!0, !0, !0, !0]); + let x = i8x4::from_array([!0, !0, !0, !0]); let r: bool = simd_reduce_all(x); assert_eq!(r, true); let r: bool = simd_reduce_any(x); assert_eq!(r, true); - let x = b8x4([!0, !0, 0, !0]); + let x = i8x4::from_array([!0, !0, 0, !0]); let r: bool = simd_reduce_all(x); assert_eq!(r, false); let r: bool = simd_reduce_any(x); assert_eq!(r, true); - let x = b8x4([0, 0, 0, 0]); + let x = i8x4::from_array([0, 0, 0, 0]); let r: bool = simd_reduce_all(x); assert_eq!(r, false); let r: bool = simd_reduce_any(x); assert_eq!(r, false); } } + +fn main() { + unordered(); + const { ordered() }; + ordered(); +} diff --git a/tests/ui/simd/intrinsic/generic-select-pass.rs b/tests/ui/simd/intrinsic/generic-select-pass.rs index ff2d70d6a978..ff02955f3aca 100644 --- a/tests/ui/simd/intrinsic/generic-select-pass.rs +++ b/tests/ui/simd/intrinsic/generic-select-pass.rs @@ -2,9 +2,10 @@ #![allow(non_camel_case_types)] //@ ignore-emscripten //@ ignore-endian-big behavior of simd_select_bitmask is endian-specific +//@ compile-flags: --cfg minisimd_const // Test that the simd_select intrinsics produces correct results. -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../../auxiliary/minisimd.rs"] mod minisimd; @@ -14,7 +15,7 @@ type b8x4 = i8x4; -fn main() { +const fn select() { let m0 = b8x4::from_array([!0, !0, !0, !0]); let m1 = b8x4::from_array([0, 0, 0, 0]); let m2 = b8x4::from_array([!0, !0, 0, 0]); @@ -173,3 +174,8 @@ fn main() { assert_eq!(r, e); } } + +fn main() { + const { select() }; + select(); +} diff --git a/tests/ui/simd/masked-load-store.rs b/tests/ui/simd/masked-load-store.rs index f6682ad16725..7098a4405c7f 100644 --- a/tests/ui/simd/masked-load-store.rs +++ b/tests/ui/simd/masked-load-store.rs @@ -1,6 +1,7 @@ //@ ignore-backends: gcc +//@ compile-flags: --cfg minisimd_const //@ run-pass -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../auxiliary/minisimd.rs"] mod minisimd; @@ -8,7 +9,7 @@ use std::intrinsics::simd::{SimdAlign, simd_masked_load, simd_masked_store}; -fn main() { +const fn masked_load_store() { unsafe { let a = Simd::([0, 1, 2, 3]); let b_src = [4u8, 5, 6, 7]; @@ -37,3 +38,8 @@ fn main() { assert_eq!(&output, &[0, 1, 9, 6, u8::MAX]); } } + +fn main() { + const { masked_load_store() }; + masked_load_store(); +} diff --git a/tests/ui/simd/simd-bitmask-notpow2.rs b/tests/ui/simd/simd-bitmask-notpow2.rs index 991fe0d89337..1e805b008eab 100644 --- a/tests/ui/simd/simd-bitmask-notpow2.rs +++ b/tests/ui/simd/simd-bitmask-notpow2.rs @@ -3,8 +3,9 @@ // This should be merged into `simd-bitmask` once that's fixed. //@ ignore-endian-big //@ ignore-backends: gcc +//@ compile-flags: --cfg minisimd_const -#![feature(repr_simd, core_intrinsics)] +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../auxiliary/minisimd.rs"] mod minisimd; @@ -12,15 +13,10 @@ use std::intrinsics::simd::{simd_bitmask, simd_select_bitmask}; -fn main() { +const fn bitmask() { // Non-power-of-2 multi-byte mask. #[allow(non_camel_case_types)] type i32x10 = PackedSimd; - impl i32x10 { - fn splat(x: i32) -> Self { - Self([x; 10]) - } - } unsafe { let mask = i32x10::from_array([!0, !0, 0, !0, 0, 0, !0, 0, !0, 0]); let mask_bits = if cfg!(target_endian = "little") { 0b0101001011 } else { 0b1101001010 }; @@ -49,11 +45,6 @@ fn splat(x: i32) -> Self { // Test for a mask where the next multiple of 8 is not a power of two. #[allow(non_camel_case_types)] type i32x20 = PackedSimd; - impl i32x20 { - fn splat(x: i32) -> Self { - Self([x; 20]) - } - } unsafe { let mask = i32x20::from_array([ !0, !0, 0, !0, 0, @@ -91,3 +82,8 @@ fn splat(x: i32) -> Self { assert_eq!(selected2, mask); } } + +fn main() { + const { bitmask() }; + bitmask(); +} diff --git a/tests/ui/simd/simd-bitmask.rs b/tests/ui/simd/simd-bitmask.rs index 609dae3647b2..281a6ffb4ddd 100644 --- a/tests/ui/simd/simd-bitmask.rs +++ b/tests/ui/simd/simd-bitmask.rs @@ -1,5 +1,6 @@ //@run-pass -#![feature(repr_simd, core_intrinsics)] +//@ compile-flags: --cfg minisimd_const +#![feature(repr_simd, core_intrinsics, const_trait_impl, const_cmp, const_index)] #[path = "../../auxiliary/minisimd.rs"] mod minisimd; @@ -7,7 +8,7 @@ use std::intrinsics::simd::{simd_bitmask, simd_select_bitmask}; -fn main() { +const fn bitmask() { unsafe { let v = Simd::([-1, 0, -1, 0]); let i: u8 = simd_bitmask(v); @@ -68,3 +69,8 @@ fn main() { assert_eq!(r.into_array(), e); } } + +fn main() { + const { bitmask() }; + bitmask(); +} From ac2d97254e14e52f3e5e948405715d78e01f17a8 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Mon, 17 Nov 2025 16:01:02 +0100 Subject: [PATCH 055/194] correct signedness of pmadd arguments --- library/stdarch/crates/core_arch/src/x86/avx2.rs | 4 ++-- library/stdarch/crates/core_arch/src/x86/avx512bw.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index e8213615a22e..8be302cabc77 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -1773,7 +1773,7 @@ pub fn _mm256_madd_epi16(a: __m256i, b: __m256i) -> __m256i { #[cfg_attr(test, assert_instr(vpmaddubsw))] #[stable(feature = "simd_x86", since = "1.27.0")] pub fn _mm256_maddubs_epi16(a: __m256i, b: __m256i) -> __m256i { - unsafe { transmute(pmaddubsw(a.as_u8x32(), b.as_u8x32())) } + unsafe { transmute(pmaddubsw(a.as_u8x32(), b.as_i8x32())) } } /// Loads packed 32-bit integers from memory pointed by `mem_addr` using `mask` @@ -3702,7 +3702,7 @@ pub fn _mm256_extract_epi16(a: __m256i) -> i32 { #[link_name = "llvm.x86.avx2.phsub.sw"] fn phsubsw(a: i16x16, b: i16x16) -> i16x16; #[link_name = "llvm.x86.avx2.pmadd.ub.sw"] - fn pmaddubsw(a: u8x32, b: u8x32) -> i16x16; + fn pmaddubsw(a: u8x32, b: i8x32) -> i16x16; #[link_name = "llvm.x86.avx2.mpsadbw"] fn mpsadbw(a: u8x32, b: u8x32, imm8: i8) -> u16x16; #[link_name = "llvm.x86.avx2.pmul.hr.sw"] diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index aee705fb4612..0e2dd3ad4068 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -5955,7 +5955,7 @@ pub fn _mm_maskz_madd_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmaddubsw))] pub fn _mm512_maddubs_epi16(a: __m512i, b: __m512i) -> __m512i { - unsafe { transmute(vpmaddubsw(a.as_i8x64(), b.as_i8x64())) } + unsafe { transmute(vpmaddubsw(a.as_u8x64(), b.as_i8x64())) } } /// Multiply packed unsigned 8-bit integers in a by packed signed 8-bit integers in b, producing intermediate signed 16-bit integers. Horizontally add adjacent pairs of intermediate signed 16-bit integers, and pack the saturated results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -11688,7 +11688,7 @@ pub unsafe fn _mm_mask_cvtusepi16_storeu_epi8(mem_addr: *mut i8, k: __mmask8, a: fn vpmulhrsw(a: i16x32, b: i16x32) -> i16x32; #[link_name = "llvm.x86.avx512.pmaddubs.w.512"] - fn vpmaddubsw(a: i8x64, b: i8x64) -> i16x32; + fn vpmaddubsw(a: u8x64, b: i8x64) -> i16x32; #[link_name = "llvm.x86.avx512.packssdw.512"] fn vpackssdw(a: i32x16, b: i32x16) -> i16x32; From 754a82d87c8e1d2561b471e0664be252193644a4 Mon Sep 17 00:00:00 2001 From: Jeremy Smart Date: Mon, 29 Sep 2025 23:45:19 -0400 Subject: [PATCH 056/194] recommend using a HashMap if a HashSet's second generic parameter doesn't implement BuildHasher --- .../rustc_hir_typeck/src/method/suggest.rs | 58 ++++++++++++++++--- compiler/rustc_span/src/symbol.rs | 1 + library/core/src/hash/mod.rs | 1 + tests/ui/hashmap/hashset_generics.rs | 20 +++++++ tests/ui/hashmap/hashset_generics.stderr | 29 ++++++++++ 5 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 tests/ui/hashmap/hashset_generics.rs create mode 100644 tests/ui/hashmap/hashset_generics.stderr diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 09361f046ea8..292207573e8c 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1753,6 +1753,20 @@ fn handle_unsatisfied_predicates( err.note(note); } + if let ty::Adt(adt_def, _) = rcvr_ty.kind() { + unsatisfied_predicates.iter().find(|(pred, _parent, _cause)| { + if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) = + pred.kind().skip_binder() + { + self.suggest_hashmap_on_unsatisfied_hashset_buildhasher( + err, &pred, *adt_def, + ) + } else { + false + } + }); + } + *suggested_derive = self.suggest_derive(err, unsatisfied_predicates); *unsatisfied_bounds = true; } @@ -2989,7 +3003,7 @@ pub(crate) fn note_unmet_impls_on_type( .filter_map(|e| match e.obligation.predicate.kind().skip_binder() { ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => { match pred.self_ty().kind() { - ty::Adt(_, _) => Some(pred), + ty::Adt(_, _) => Some((e.root_obligation.predicate, pred)), _ => None, } } @@ -2999,7 +3013,7 @@ pub(crate) fn note_unmet_impls_on_type( // Note for local items and foreign items respectively. let (mut local_preds, mut foreign_preds): (Vec<_>, Vec<_>) = - preds.iter().partition(|&pred| { + preds.iter().partition(|&(_, pred)| { if let ty::Adt(def, _) = pred.self_ty().kind() { def.did().is_local() } else { @@ -3007,10 +3021,10 @@ pub(crate) fn note_unmet_impls_on_type( } }); - local_preds.sort_by_key(|pred: &&ty::TraitPredicate<'_>| pred.trait_ref.to_string()); + local_preds.sort_by_key(|(_, pred)| pred.trait_ref.to_string()); let local_def_ids = local_preds .iter() - .filter_map(|pred| match pred.self_ty().kind() { + .filter_map(|(_, pred)| match pred.self_ty().kind() { ty::Adt(def, _) => Some(def.did()), _ => None, }) @@ -3023,7 +3037,7 @@ pub(crate) fn note_unmet_impls_on_type( }) .collect::>() .into(); - for pred in &local_preds { + for (_, pred) in &local_preds { if let ty::Adt(def, _) = pred.self_ty().kind() { local_spans.push_span_label( self.tcx.def_span(def.did()), @@ -3032,7 +3046,7 @@ pub(crate) fn note_unmet_impls_on_type( } } if local_spans.primary_span().is_some() { - let msg = if let [local_pred] = local_preds.as_slice() { + let msg = if let [(_, local_pred)] = local_preds.as_slice() { format!( "an implementation of `{}` might be missing for `{}`", local_pred.trait_ref.print_trait_sugared(), @@ -3050,9 +3064,10 @@ pub(crate) fn note_unmet_impls_on_type( err.span_note(local_spans, msg); } - foreign_preds.sort_by_key(|pred: &&ty::TraitPredicate<'_>| pred.trait_ref.to_string()); + foreign_preds + .sort_by_key(|(_, pred): &(_, ty::TraitPredicate<'_>)| pred.trait_ref.to_string()); - for pred in foreign_preds { + for (_, pred) in &foreign_preds { let ty = pred.self_ty(); let ty::Adt(def, _) = ty.kind() else { continue }; let span = self.tcx.def_span(def.did()); @@ -3065,6 +3080,17 @@ pub(crate) fn note_unmet_impls_on_type( mspan, format!("`{ty}` does not implement `{}`", pred.trait_ref.print_trait_sugared()), ); + + foreign_preds.iter().find(|&(root_pred, pred)| { + if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(root_pred)) = + root_pred.kind().skip_binder() + && let Some(root_adt) = root_pred.self_ty().ty_adt_def() + { + self.suggest_hashmap_on_unsatisfied_hashset_buildhasher(err, pred, root_adt) + } else { + false + } + }); } let preds: Vec<_> = errors @@ -4355,6 +4381,22 @@ fn is_local(ty: Ty<'_>) -> bool { self.autoderef(span, rcvr_ty).silence_errors().any(|(ty, _)| is_local(ty)) } + + fn suggest_hashmap_on_unsatisfied_hashset_buildhasher( + &self, + err: &mut Diag<'_>, + pred: &ty::TraitPredicate<'_>, + adt: ty::AdtDef<'_>, + ) -> bool { + if self.tcx.is_diagnostic_item(sym::HashSet, adt.did()) + && self.tcx.is_diagnostic_item(sym::BuildHasher, pred.def_id()) + { + err.help("you might have intended to use a HashMap instead"); + true + } else { + false + } + } } #[derive(Copy, Clone, Debug)] diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index c1c9fa57f85b..b2eb716765b8 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -191,6 +191,7 @@ Borrow, BorrowMut, Break, + BuildHasher, C, CStr, C_dash_unwind: "C-unwind", diff --git a/library/core/src/hash/mod.rs b/library/core/src/hash/mod.rs index a10c85640bbb..c3f3cd729425 100644 --- a/library/core/src/hash/mod.rs +++ b/library/core/src/hash/mod.rs @@ -633,6 +633,7 @@ fn write_str(&mut self, s: &str) { /// /// [`build_hasher`]: BuildHasher::build_hasher /// [`HashMap`]: ../../std/collections/struct.HashMap.html +#[cfg_attr(not(test), rustc_diagnostic_item = "BuildHasher")] #[stable(since = "1.7.0", feature = "build_hasher")] pub trait BuildHasher { /// Type of the hasher that will be created. diff --git a/tests/ui/hashmap/hashset_generics.rs b/tests/ui/hashmap/hashset_generics.rs new file mode 100644 index 000000000000..8671066989f1 --- /dev/null +++ b/tests/ui/hashmap/hashset_generics.rs @@ -0,0 +1,20 @@ +use std::collections::HashSet; + +#[derive(PartialEq)] +//~^ NOTE in this expansion of +//~| NOTE in this expansion of +//~| NOTE in this expansion of +pub struct MyStruct { + pub parameters: HashSet, + //~^ NOTE `String` does not implement `BuildHasher` + //~| ERROR binary operation + //~| HELP use a HashMap +} + +fn main() { + let h1 = HashSet::::with_hasher(0); + h1.insert(1); + //~^ ERROR its trait bounds were not satisfied + //~| NOTE the following trait bounds + //~| HELP use a HashMap +} diff --git a/tests/ui/hashmap/hashset_generics.stderr b/tests/ui/hashmap/hashset_generics.stderr new file mode 100644 index 000000000000..a677b6671eb8 --- /dev/null +++ b/tests/ui/hashmap/hashset_generics.stderr @@ -0,0 +1,29 @@ +error[E0369]: binary operation `==` cannot be applied to type `HashSet` + --> $DIR/hashset_generics.rs:8:5 + | +LL | #[derive(PartialEq)] + | --------- in this derive macro expansion +... +LL | pub parameters: HashSet, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: `String` does not implement `BuildHasher` + --> $SRC_DIR/alloc/src/string.rs:LL:COL + | + = note: `String` is defined in another crate + = help: you might have intended to use a HashMap instead + +error[E0599]: the method `insert` exists for struct `HashSet`, but its trait bounds were not satisfied + --> $DIR/hashset_generics.rs:16:8 + | +LL | h1.insert(1); + | ^^^^^^ + | + = note: the following trait bounds were not satisfied: + `usize: BuildHasher` + = help: you might have intended to use a HashMap instead + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0369, E0599. +For more information about an error, try `rustc --explain E0369`. From 1cfd0b7c55257c65d8521707e7902e205571c7fd Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 7 Aug 2023 09:28:27 -0400 Subject: [PATCH 057/194] Match ::fmt to that of str 819247f1 changed ::fmt such that it does not escape single quotes, but neglected to apply the same choice to OsString. This commit does that. --- library/core/src/str/lossy.rs | 7 ++++++- library/core/src/wtf8.rs | 16 +++++++++++----- library/coretests/tests/str_lossy.rs | 1 + library/std/src/ffi/os_str/tests.rs | 6 ++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/library/core/src/str/lossy.rs b/library/core/src/str/lossy.rs index 8d4210c80827..d2dc650910f6 100644 --- a/library/core/src/str/lossy.rs +++ b/library/core/src/str/lossy.rs @@ -1,3 +1,4 @@ +use super::char::EscapeDebugExtArgs; use super::from_utf8_unchecked; use super::validations::utf8_char_width; use crate::fmt; @@ -121,7 +122,11 @@ fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { let valid = chunk.valid(); let mut from = 0; for (i, c) in valid.char_indices() { - let esc = c.escape_debug(); + let esc = c.escape_debug_ext(EscapeDebugExtArgs { + escape_grapheme_extended: true, + escape_single_quote: false, + escape_double_quote: true, + }); // If char needs escaping, flush backlog so far and write, else skip if esc.len() != 1 { f.write_str(&valid[from..i])?; diff --git a/library/core/src/wtf8.rs b/library/core/src/wtf8.rs index b64fccedc19c..7214918db6c3 100644 --- a/library/core/src/wtf8.rs +++ b/library/core/src/wtf8.rs @@ -19,7 +19,7 @@ // implementations, so, we'll have to add more doc(hidden)s anyway #![doc(hidden)] -use crate::char::encode_utf16_raw; +use crate::char::{EscapeDebugExtArgs, encode_utf16_raw}; use crate::clone::CloneToUninit; use crate::fmt::{self, Write}; use crate::hash::{Hash, Hasher}; @@ -144,14 +144,20 @@ fn as_ref(&self) -> &[u8] { impl fmt::Debug for Wtf8 { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fn write_str_escaped(f: &mut fmt::Formatter<'_>, s: &str) -> fmt::Result { - use crate::fmt::Write; - for c in s.chars().flat_map(|c| c.escape_debug()) { + use crate::fmt::Write as _; + for c in s.chars().flat_map(|c| { + c.escape_debug_ext(EscapeDebugExtArgs { + escape_grapheme_extended: true, + escape_single_quote: false, + escape_double_quote: true, + }) + }) { f.write_char(c)? } Ok(()) } - formatter.write_str("\"")?; + formatter.write_char('"')?; let mut pos = 0; while let Some((surrogate_pos, surrogate)) = self.next_surrogate(pos) { // SAFETY: next_surrogate provides an index for a range of valid UTF-8 bytes. @@ -164,7 +170,7 @@ fn write_str_escaped(f: &mut fmt::Formatter<'_>, s: &str) -> fmt::Result { // SAFETY: after next_surrogate returns None, the remainder is valid UTF-8. write_str_escaped(formatter, unsafe { str::from_utf8_unchecked(&self.bytes[pos..]) })?; - formatter.write_str("\"") + formatter.write_char('"') } } diff --git a/library/coretests/tests/str_lossy.rs b/library/coretests/tests/str_lossy.rs index 6e70ea3e2857..820da38dd746 100644 --- a/library/coretests/tests/str_lossy.rs +++ b/library/coretests/tests/str_lossy.rs @@ -80,4 +80,5 @@ fn debug() { b"Hello\xC0\x80 There\xE6\x83 Goodbye\xf4\x8d\x93\xaa".utf8_chunks().debug(), ), ); + assert_eq!("\"'\"", &format!("{:?}", b"'".utf8_chunks().debug())); } diff --git a/library/std/src/ffi/os_str/tests.rs b/library/std/src/ffi/os_str/tests.rs index 2572b71fd9ac..3474f0ab5068 100644 --- a/library/std/src/ffi/os_str/tests.rs +++ b/library/std/src/ffi/os_str/tests.rs @@ -303,3 +303,9 @@ fn clone_to_uninit() { unsafe { a.clone_to_uninit(ptr::from_mut::(&mut b).cast()) }; assert_eq!(a, &*b); } + +#[test] +fn debug() { + let s = "'single quotes'"; + assert_eq!(format!("{:?}", OsStr::new(s)), format!("{:?}", s)); +} From eb84efc702d55b39cfe83009f61d479351ea68c1 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Sun, 13 Aug 2023 10:04:42 -0400 Subject: [PATCH 058/194] Remove workaround --- library/std/src/env.rs | 2 +- library/std/src/sys/env/common.rs | 17 ----------------- library/std/src/sys/env/unsupported.rs | 7 ------- library/std/src/sys/env/windows.rs | 24 ------------------------ 4 files changed, 1 insertion(+), 49 deletions(-) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 6d716bd85443..fd662e8a663a 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -170,7 +170,7 @@ fn size_hint(&self) -> (usize, Option) { impl fmt::Debug for Vars { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let Self { inner: VarsOs { inner } } = self; - f.debug_struct("Vars").field("inner", &inner.str_debug()).finish() + f.debug_struct("Vars").field("inner", inner).finish() } } diff --git a/library/std/src/sys/env/common.rs b/library/std/src/sys/env/common.rs index f161ff073f3d..87e86e2947fa 100644 --- a/library/std/src/sys/env/common.rs +++ b/library/std/src/sys/env/common.rs @@ -5,27 +5,10 @@ pub struct Env { iter: vec::IntoIter<(OsString, OsString)>, } -// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when ::fmt matches ::fmt. -pub struct EnvStrDebug<'a> { - slice: &'a [(OsString, OsString)], -} - -impl fmt::Debug for EnvStrDebug<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_list() - .entries(self.slice.iter().map(|(a, b)| (a.to_str().unwrap(), b.to_str().unwrap()))) - .finish() - } -} - impl Env { pub(super) fn new(env: Vec<(OsString, OsString)>) -> Self { Env { iter: env.into_iter() } } - - pub fn str_debug(&self) -> impl fmt::Debug + '_ { - EnvStrDebug { slice: self.iter.as_slice() } - } } impl fmt::Debug for Env { diff --git a/library/std/src/sys/env/unsupported.rs b/library/std/src/sys/env/unsupported.rs index 98905e648274..a967ace95f02 100644 --- a/library/std/src/sys/env/unsupported.rs +++ b/library/std/src/sys/env/unsupported.rs @@ -3,13 +3,6 @@ pub struct Env(!); -impl Env { - // FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when ::fmt matches ::fmt. - pub fn str_debug(&self) -> impl fmt::Debug + '_ { - self.0 - } -} - impl fmt::Debug for Env { fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result { self.0 diff --git a/library/std/src/sys/env/windows.rs b/library/std/src/sys/env/windows.rs index 3c4d4a84cfd6..219fcc4fb43f 100644 --- a/library/std/src/sys/env/windows.rs +++ b/library/std/src/sys/env/windows.rs @@ -8,30 +8,6 @@ pub struct Env { iter: EnvIterator, } -// FIXME(https://github.com/rust-lang/rust/issues/114583): Remove this when ::fmt matches ::fmt. -pub struct EnvStrDebug<'a> { - iter: &'a EnvIterator, -} - -impl fmt::Debug for EnvStrDebug<'_> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let Self { iter } = self; - let iter: EnvIterator = (*iter).clone(); - let mut list = f.debug_list(); - for (a, b) in iter { - list.entry(&(a.to_str().unwrap(), b.to_str().unwrap())); - } - list.finish() - } -} - -impl Env { - pub fn str_debug(&self) -> impl fmt::Debug + '_ { - let Self { base: _, iter } = self; - EnvStrDebug { iter } - } -} - impl fmt::Debug for Env { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let Self { base: _, iter } = self; From bbf7dc0ddf6c920bb4ed1bf2fe8a7b889b9650a2 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sun, 16 Nov 2025 23:01:37 +0100 Subject: [PATCH 059/194] ignore unsized types in mips64 and sparc64 callconvs --- compiler/rustc_target/src/callconv/mips64.rs | 4 ++-- compiler/rustc_target/src/callconv/sparc64.rs | 5 ++++- tests/ui/abi/compatibility.rs | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_target/src/callconv/mips64.rs b/compiler/rustc_target/src/callconv/mips64.rs index 313ad6ddce80..a4e94ce81605 100644 --- a/compiler/rustc_target/src/callconv/mips64.rs +++ b/compiler/rustc_target/src/callconv/mips64.rs @@ -148,12 +148,12 @@ pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>) Ty: TyAbiInterface<'a, C> + Copy, C: HasDataLayout, { - if !fn_abi.ret.is_ignore() { + if !fn_abi.ret.is_ignore() && fn_abi.ret.layout.is_sized() { classify_ret(cx, &mut fn_abi.ret); } for arg in fn_abi.args.iter_mut() { - if arg.is_ignore() { + if arg.is_ignore() || !arg.layout.is_sized() { continue; } classify_arg(cx, arg); diff --git a/compiler/rustc_target/src/callconv/sparc64.rs b/compiler/rustc_target/src/callconv/sparc64.rs index 73e9a46ed5b2..fc732170dcb7 100644 --- a/compiler/rustc_target/src/callconv/sparc64.rs +++ b/compiler/rustc_target/src/callconv/sparc64.rs @@ -216,11 +216,14 @@ pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>) Ty: TyAbiInterface<'a, C> + Copy, C: HasDataLayout + HasTargetSpec, { - if !fn_abi.ret.is_ignore() { + if !fn_abi.ret.is_ignore() && fn_abi.ret.layout.is_sized() { classify_arg(cx, &mut fn_abi.ret, Size::from_bytes(32)); } for arg in fn_abi.args.iter_mut() { + if !arg.layout.is_sized() { + continue; + } if arg.is_ignore() { // sparc64-unknown-linux-{gnu,musl,uclibc} doesn't ignore ZSTs. if cx.target_spec().os == Os::Linux diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index ce662d3fe28b..84294ab34311 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -280,7 +280,8 @@ mod $name { }; } -#[cfg(not(any(target_arch = "mips64", target_arch = "sparc64")))] +// NOTE: non-rustic ABIs do not support unsized types: they are skipped during ABI generation, and +// will trigger an error if they make it to rustc_monomorphize/src/mono_checks/abi_check.rs mod unsized_ { use super::*; test_transparent_unsized!(str_, str); From 357fd66c04404dce3c87bd69d9dc4f59ca584c76 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 18 Nov 2025 09:27:51 +0000 Subject: [PATCH 060/194] Avoid encoding non-constness or non-asyncness in metadata --- compiler/rustc_hir/src/hir.rs | 2 + compiler/rustc_metadata/src/rmeta/encoder.rs | 12 +++- compiler/rustc_metadata/src/rmeta/mod.rs | 4 +- compiler/rustc_metadata/src/rmeta/table.rs | 62 ++++++++++++++++++++ compiler/rustc_middle/src/ty/mod.rs | 3 +- 5 files changed, 78 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 786280c24c11..cb5523533c0f 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -4224,8 +4224,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } #[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable, Decodable, HashStable_Generic)] +#[derive(Default)] pub enum Constness { Const, + #[default] NotConst, } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 2c256ee9b702..fc9b79021149 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1519,10 +1519,18 @@ fn encode_def_ids(&mut self) { record!(self.tables.type_of[def_id] <- self.tcx.type_of(def_id)); } if should_encode_constness(def_kind) { - self.tables.constness.set_some(def_id.index, self.tcx.constness(def_id)); + let constness = self.tcx.constness(def_id); + match constness { + hir::Constness::Const => self.tables.constness.set(def_id.index, constness), + hir::Constness::NotConst => {} + } } if let DefKind::Fn | DefKind::AssocFn = def_kind { - self.tables.asyncness.set_some(def_id.index, tcx.asyncness(def_id)); + let asyncness = tcx.asyncness(def_id); + match asyncness { + ty::Asyncness::Yes => self.tables.asyncness.set(def_id.index, asyncness), + ty::Asyncness::No => {} + } record_array!(self.tables.fn_arg_idents[def_id] <- tcx.fn_arg_idents(def_id)); } if let Some(name) = tcx.intrinsic(def_id) { diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index c20c45ae5812..672ebe3de483 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -400,6 +400,8 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { // individually instead of `DefId`s. module_children_reexports: Table>, cross_crate_inlinable: Table, + asyncness: Table, + constness: Table, - optional: attributes: Table>, @@ -433,7 +435,6 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { promoted_mir: Table>>>, thir_abstract_const: Table>>>, impl_parent: Table, - constness: Table, const_conditions: Table>>, defaultness: Table, // FIXME(eddyb) perhaps compute this on the fly if cheap enough? @@ -441,7 +442,6 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { mir_const_qualif: Table>, rendered_const: Table>, rendered_precise_capturing_args: Table>>, - asyncness: Table, fn_arg_idents: Table>>, coroutine_kind: Table, coroutine_for_closure: Table, diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index a882ee4f2b92..7118d8943420 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -25,6 +25,24 @@ fn is_default(&self) -> bool { } } +impl IsDefault for ty::Asyncness { + fn is_default(&self) -> bool { + match self { + ty::Asyncness::Yes => false, + ty::Asyncness::No => true, + } + } +} + +impl IsDefault for hir::Constness { + fn is_default(&self) -> bool { + match self { + rustc_hir::Constness::Const => false, + rustc_hir::Constness::NotConst => true, + } + } +} + impl IsDefault for u32 { fn is_default(&self) -> bool { *self == 0 @@ -293,6 +311,50 @@ impl FixedSizeEncoding for bool { } } +impl FixedSizeEncoding for ty::Asyncness { + type ByteArray = [u8; 1]; + + #[inline] + fn from_bytes(b: &[u8; 1]) -> Self { + match b[0] { + 0 => ty::Asyncness::No, + 1 => ty::Asyncness::Yes, + _ => unreachable!(), + } + } + + #[inline] + fn write_to_bytes(self, b: &mut [u8; 1]) { + debug_assert!(!self.is_default()); + b[0] = match self { + ty::Asyncness::No => 0, + ty::Asyncness::Yes => 1, + } + } +} + +impl FixedSizeEncoding for hir::Constness { + type ByteArray = [u8; 1]; + + #[inline] + fn from_bytes(b: &[u8; 1]) -> Self { + match b[0] { + 0 => hir::Constness::NotConst, + 1 => hir::Constness::Const, + _ => unreachable!(), + } + } + + #[inline] + fn write_to_bytes(self, b: &mut [u8; 1]) { + debug_assert!(!self.is_default()); + b[0] = match self { + hir::Constness::NotConst => 0, + hir::Constness::Const => 1, + } + } +} + // NOTE(eddyb) there could be an impl for `usize`, which would enable a more // generic `LazyValue` impl, but in the general case we might not need / want // to fit every `usize` in `u32`. diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 5eb8f1713a13..a8f7b22f3273 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -250,9 +250,10 @@ pub struct ImplTraitHeader<'tcx> { } #[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable, Debug)] -#[derive(TypeFoldable, TypeVisitable)] +#[derive(TypeFoldable, TypeVisitable, Default)] pub enum Asyncness { Yes, + #[default] No, } From e9ed6260907debd443d3dfbc28b88d0e332c8d55 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 17 Nov 2025 15:20:56 +0100 Subject: [PATCH 061/194] Add support for variant fields in `rustdoc::html::format::print_anchor` --- src/librustdoc/html/format.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index b7f6d84ea36c..ad8014c3ac47 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -840,16 +840,25 @@ pub(crate) fn print_anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl D if let Ok(HrefInfo { url, kind, rust_path }) = href(did, cx) { let tcx = cx.tcx(); let def_kind = tcx.def_kind(did); - let anchor = if matches!( - def_kind, - DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst | DefKind::Variant - ) { - let parent_def_id = tcx.parent(did); - let item_type = - ItemType::from_def_kind(def_kind, Some(tcx.def_kind(parent_def_id))); - format!("#{}.{}", item_type.as_str(), tcx.item_name(did)) - } else { - String::new() + let anchor = match def_kind { + DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst | DefKind::Variant => { + let parent_def_id = tcx.parent(did); + let item_type = + ItemType::from_def_kind(def_kind, Some(tcx.def_kind(parent_def_id))); + format!("#{}.{}", item_type.as_str(), tcx.item_name(did)) + } + DefKind::Field => { + let s; + let parent_id = tcx.parent(did); + let kind = if tcx.def_kind(parent_id) == DefKind::Variant { + s = format!("variant.{}.field", tcx.item_name(parent_id).as_str()); + &s + } else { + "structfield" + }; + format!("#{kind}.{}", tcx.item_name(did)) + } + _ => String::new(), }; write!( From a5f972ec4717f05d42faccc0e645c89bcd525295 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 17 Nov 2025 16:45:30 +0100 Subject: [PATCH 062/194] Remove `UrlFragment::render` method to unify `clean::types::links` and `anchor` --- src/librustdoc/clean/mod.rs | 2 +- src/librustdoc/clean/types.rs | 11 +++- src/librustdoc/clean/utils.rs | 7 +-- src/librustdoc/formats/item_type.rs | 24 ++++----- src/librustdoc/html/format.rs | 54 +++++++++---------- .../passes/collect_intra_doc_links.rs | 37 ------------- 6 files changed, 52 insertions(+), 83 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a4f754912aea..38b12405ea82 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -249,7 +249,7 @@ pub(crate) fn clean_trait_ref_with_constraints<'tcx>( trait_ref: ty::PolyTraitRef<'tcx>, constraints: ThinVec, ) -> Path { - let kind = cx.tcx.def_kind(trait_ref.def_id()).into(); + let kind = ItemType::from_def_id(trait_ref.def_id(), cx.tcx); if !matches!(kind, ItemType::Trait | ItemType::TraitAlias) { span_bug!(cx.tcx.def_span(trait_ref.def_id()), "`TraitRef` had unexpected kind {kind:?}"); } diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 6e4c65dc9127..7669a2b1a579 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -522,8 +522,15 @@ pub(crate) fn links(&self, cx: &Context<'_>) -> Vec { debug!(?id); if let Ok(HrefInfo { mut url, .. }) = href(*id, cx) { debug!(?url); - if let Some(ref fragment) = *fragment { - fragment.render(&mut url, cx.tcx()) + match fragment { + Some(UrlFragment::Item(def_id)) => { + url.push_str(&crate::html::format::fragment(*def_id, cx.tcx())) + } + Some(UrlFragment::UserWritten(raw)) => { + url.push('#'); + url.push_str(raw); + } + None => {} } Some(RenderedLink { original_text: s.clone(), diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 060abfd05e04..cb5cd6523afe 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -26,6 +26,7 @@ }; use crate::core::DocContext; use crate::display::Joined as _; +use crate::formats::item_type::ItemType; #[cfg(test)] mod tests; @@ -496,7 +497,7 @@ pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId { let (kind, did) = match res { Res::Def( - kind @ (AssocTy + AssocTy | AssocFn | AssocConst | Variant @@ -511,9 +512,9 @@ pub(crate) fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId { | Const | Static { .. } | Macro(..) - | TraitAlias), + | TraitAlias, did, - ) => (kind.into(), did), + ) => (ItemType::from_def_id(did, cx.tcx), did), _ => panic!("register_res: unexpected {res:?}"), }; diff --git a/src/librustdoc/formats/item_type.rs b/src/librustdoc/formats/item_type.rs index ab40c01cb369..d3923e3e3116 100644 --- a/src/librustdoc/formats/item_type.rs +++ b/src/librustdoc/formats/item_type.rs @@ -3,6 +3,8 @@ use std::fmt; use rustc_hir::def::{CtorOf, DefKind, MacroKinds}; +use rustc_hir::def_id::DefId; +use rustc_middle::ty::TyCtxt; use rustc_span::hygiene::MacroKind; use serde::{Deserialize, Deserializer, Serialize, Serializer, de}; @@ -147,17 +149,10 @@ fn from(item: &'a clean::Item) -> ItemType { } } -impl From for ItemType { - fn from(other: DefKind) -> Self { - Self::from_def_kind(other, None) - } -} - impl ItemType { - /// Depending on the parent kind, some variants have a different translation (like a `Method` - /// becoming a `TyMethod`). - pub(crate) fn from_def_kind(kind: DefKind, parent_kind: Option) -> Self { - match kind { + pub(crate) fn from_def_id(def_id: DefId, tcx: TyCtxt<'_>) -> Self { + let def_kind = tcx.def_kind(def_id); + match def_kind { DefKind::Enum => Self::Enum, DefKind::Fn => Self::Function, DefKind::Mod => Self::Module, @@ -176,8 +171,13 @@ pub(crate) fn from_def_kind(kind: DefKind, parent_kind: Option) -> Self DefKind::Variant => Self::Variant, DefKind::Field => Self::StructField, DefKind::AssocTy => Self::AssocType, - DefKind::AssocFn if let Some(DefKind::Trait) = parent_kind => Self::TyMethod, - DefKind::AssocFn => Self::Method, + DefKind::AssocFn => { + if tcx.associated_item(def_id).defaultness(tcx).has_value() { + Self::Method + } else { + Self::TyMethod + } + } DefKind::Ctor(CtorOf::Struct, _) => Self::Struct, DefKind::Ctor(CtorOf::Variant, _) => Self::Variant, DefKind::AssocConst => Self::AssocConst, diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index ad8014c3ac47..5892eecea35e 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -431,7 +431,6 @@ fn generate_item_def_id_path( original_def_id: DefId, cx: &Context<'_>, root_path: Option<&str>, - original_def_kind: DefKind, ) -> Result { use rustc_middle::traits::ObligationCause; use rustc_trait_selection::infer::TyCtxtInferExt; @@ -457,15 +456,14 @@ fn generate_item_def_id_path( let relative = clean::inline::item_relative_path(tcx, def_id); let fqp: Vec = once(crate_name).chain(relative).collect(); - let def_kind = tcx.def_kind(def_id); - let shortty = def_kind.into(); + let shortty = ItemType::from_def_id(def_id, tcx); let module_fqp = to_module_fqp(shortty, &fqp); let mut is_remote = false; let url_parts = url_parts(cx.cache(), def_id, module_fqp, &cx.current, &mut is_remote)?; let mut url_parts = make_href(root_path, shortty, url_parts, &fqp, is_remote); if def_id != original_def_id { - let kind = ItemType::from_def_kind(original_def_kind, Some(def_kind)); + let kind = ItemType::from_def_id(original_def_id, tcx); url_parts = format!("{url_parts}#{kind}.{}", tcx.item_name(original_def_id)) }; Ok(HrefInfo { url: url_parts, kind: shortty, rust_path: fqp }) @@ -605,7 +603,7 @@ pub(crate) fn href_with_root_path( } else if did.is_local() { return Err(HrefError::Private); } else { - return generate_item_def_id_path(did, original_did, cx, root_path, def_kind); + return generate_item_def_id_path(did, original_did, cx, root_path); } } }; @@ -835,35 +833,35 @@ fn print_higher_ranked_params_with_space( }) } +pub(crate) fn fragment(did: DefId, tcx: TyCtxt<'_>) -> String { + let def_kind = tcx.def_kind(did); + match def_kind { + DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst | DefKind::Variant => { + let item_type = ItemType::from_def_id(did, tcx); + format!("#{}.{}", item_type.as_str(), tcx.item_name(did)) + } + DefKind::Field => { + let parent_def_id = tcx.parent(did); + let s; + let kind = if tcx.def_kind(parent_def_id) == DefKind::Variant { + s = format!("variant.{}.field", tcx.item_name(parent_def_id).as_str()); + &s + } else { + "structfield" + }; + format!("#{kind}.{}", tcx.item_name(did)) + } + _ => String::new(), + } +} + pub(crate) fn print_anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl Display { fmt::from_fn(move |f| { if let Ok(HrefInfo { url, kind, rust_path }) = href(did, cx) { - let tcx = cx.tcx(); - let def_kind = tcx.def_kind(did); - let anchor = match def_kind { - DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst | DefKind::Variant => { - let parent_def_id = tcx.parent(did); - let item_type = - ItemType::from_def_kind(def_kind, Some(tcx.def_kind(parent_def_id))); - format!("#{}.{}", item_type.as_str(), tcx.item_name(did)) - } - DefKind::Field => { - let s; - let parent_id = tcx.parent(did); - let kind = if tcx.def_kind(parent_id) == DefKind::Variant { - s = format!("variant.{}.field", tcx.item_name(parent_id).as_str()); - &s - } else { - "structfield" - }; - format!("#{kind}.{}", tcx.item_name(did)) - } - _ => String::new(), - }; - write!( f, r#"{text}"#, + anchor = fragment(did, cx.tcx()), path = join_path_syms(rust_path), text = EscapeBodyText(text.as_str()), ) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index e29256bb5d1a..4e4f21bf926f 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -203,43 +203,6 @@ pub(crate) enum UrlFragment { UserWritten(String), } -impl UrlFragment { - /// Render the fragment, including the leading `#`. - pub(crate) fn render(&self, s: &mut String, tcx: TyCtxt<'_>) { - s.push('#'); - match self { - &UrlFragment::Item(def_id) => { - let kind = match tcx.def_kind(def_id) { - DefKind::AssocFn => { - if tcx.associated_item(def_id).defaultness(tcx).has_value() { - "method." - } else { - "tymethod." - } - } - DefKind::AssocConst => "associatedconstant.", - DefKind::AssocTy => "associatedtype.", - DefKind::Variant => "variant.", - DefKind::Field => { - let parent_id = tcx.parent(def_id); - if tcx.def_kind(parent_id) == DefKind::Variant { - s.push_str("variant."); - s.push_str(tcx.item_name(parent_id).as_str()); - ".field." - } else { - "structfield." - } - } - kind => bug!("unexpected associated item kind: {kind:?}"), - }; - s.push_str(kind); - s.push_str(tcx.item_name(def_id).as_str()); - } - UrlFragment::UserWritten(raw) => s.push_str(raw), - } - } -} - #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub(crate) struct ResolutionInfo { item_id: DefId, From a25950dec682c74ada1033c299071a14a8c993de Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Wed, 19 Nov 2025 03:17:38 +0900 Subject: [PATCH 063/194] feat: Change return type of `NonZero::bit_width` Return `NonZero` instead of `u32`. --- library/core/src/num/nonzero.rs | 11 +++++++---- library/coretests/tests/nonzero.rs | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index baabf1d90b88..30c3fb8b5c52 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -1789,8 +1789,9 @@ pub const fn cast_signed(self) -> NonZero<$Sint> { /// # /// # fn main() { test().unwrap(); } /// # fn test() -> Option<()> { - #[doc = concat!("assert_eq!(NonZero::<", stringify!($Int), ">::new(0b111)?.bit_width(), 3);")] - #[doc = concat!("assert_eq!(NonZero::<", stringify!($Int), ">::new(0b1110)?.bit_width(), 4);")] + #[doc = concat!("assert_eq!(NonZero::<", stringify!($Int), ">::MIN.bit_width(), NonZero::new(1)?);")] + #[doc = concat!("assert_eq!(NonZero::<", stringify!($Int), ">::new(0b111)?.bit_width(), NonZero::new(3)?);")] + #[doc = concat!("assert_eq!(NonZero::<", stringify!($Int), ">::new(0b1110)?.bit_width(), NonZero::new(4)?);")] /// # Some(()) /// # } /// ``` @@ -1798,8 +1799,10 @@ pub const fn cast_signed(self) -> NonZero<$Sint> { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - pub const fn bit_width(self) -> u32 { - Self::BITS - self.leading_zeros() + pub const fn bit_width(self) -> NonZero { + // SAFETY: Since `self.leading_zeros()` is always less than + // `Self::BITS`, this subtraction can never be zero. + unsafe { NonZero::new_unchecked(Self::BITS - self.leading_zeros()) } } }; diff --git a/library/coretests/tests/nonzero.rs b/library/coretests/tests/nonzero.rs index 4bcc61de8dca..c368a2621740 100644 --- a/library/coretests/tests/nonzero.rs +++ b/library/coretests/tests/nonzero.rs @@ -577,10 +577,10 @@ macro_rules! nonzero_uint_impl { ($($T:ty),+) => { $( { - assert_eq!(NonZero::<$T>::new(0b010_1100).unwrap().bit_width(), 6); - assert_eq!(NonZero::<$T>::new(0b111_1001).unwrap().bit_width(), 7); - assert_eq!(NonZero::<$T>::MIN.bit_width(), 1); - assert_eq!(NonZero::<$T>::MAX.bit_width(), <$T>::BITS); + assert_eq!(NonZero::<$T>::new(0b010_1100).unwrap().bit_width(), NonZero::new(6).unwrap()); + assert_eq!(NonZero::<$T>::new(0b111_1001).unwrap().bit_width(), NonZero::new(7).unwrap()); + assert_eq!(NonZero::<$T>::MIN.bit_width(), NonZero::new(1).unwrap()); + assert_eq!(NonZero::<$T>::MAX.bit_width(), NonZero::new(<$T>::BITS).unwrap()); } )+ }; From 4c6e41cb5305567ddc81fde28b2f6e601c4936a4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 17 Nov 2025 11:47:15 -0800 Subject: [PATCH 064/194] Update wasm-related dependencies in CI * Update to wasi-sdk-29 released today * Update to Wasmtime 38.0.4 which was released a week or so ago --- src/ci/docker/host-x86_64/dist-various-2/Dockerfile | 4 ++-- src/ci/docker/host-x86_64/pr-check-2/Dockerfile | 4 ++-- src/ci/docker/host-x86_64/test-various/Dockerfile | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index 33d551239362..90f46b5376e0 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -85,9 +85,9 @@ RUN /tmp/build-fuchsia-toolchain.sh COPY host-x86_64/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/ RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh -RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.tar.gz | \ +RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-29/wasi-sdk-29.0-x86_64-linux.tar.gz | \ tar -xz -ENV WASI_SDK_PATH=/tmp/wasi-sdk-27.0-x86_64-linux +ENV WASI_SDK_PATH=/tmp/wasi-sdk-29.0-x86_64-linux COPY scripts/freebsd-toolchain.sh /tmp/ RUN /tmp/freebsd-toolchain.sh i686 diff --git a/src/ci/docker/host-x86_64/pr-check-2/Dockerfile b/src/ci/docker/host-x86_64/pr-check-2/Dockerfile index c9c3e3d2a330..68162d136c3f 100644 --- a/src/ci/docker/host-x86_64/pr-check-2/Dockerfile +++ b/src/ci/docker/host-x86_64/pr-check-2/Dockerfile @@ -21,9 +21,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ mingw-w64 \ && rm -rf /var/lib/apt/lists/* -RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.tar.gz | \ +RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-29/wasi-sdk-29.0-x86_64-linux.tar.gz | \ tar -xz -ENV WASI_SDK_PATH=/wasi-sdk-27.0-x86_64-linux +ENV WASI_SDK_PATH=/wasi-sdk-29.0-x86_64-linux ENV RUST_CONFIGURE_ARGS="--set rust.validate-mir-opts=3" diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index e1c882d5b085..9b1bf6c0df99 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -41,9 +41,9 @@ WORKDIR / COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.tar.gz | \ +RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-29/wasi-sdk-29.0-x86_64-linux.tar.gz | \ tar -xz -ENV WASI_SDK_PATH=/wasi-sdk-27.0-x86_64-linux +ENV WASI_SDK_PATH=/wasi-sdk-29.0-x86_64-linux ENV RUST_CONFIGURE_ARGS \ --musl-root-x86_64=/usr/local/x86_64-linux-musl \ @@ -56,9 +56,9 @@ ENV RUST_CONFIGURE_ARGS \ ENV NO_DEBUG_ASSERTIONS=1 ENV NO_OVERFLOW_CHECKS=1 -RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v19.0.0/wasmtime-v19.0.0-x86_64-linux.tar.xz | \ +RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v38.0.4/wasmtime-v38.0.4-x86_64-linux.tar.xz | \ tar -xJ -ENV PATH "$PATH:/wasmtime-v19.0.0-x86_64-linux" +ENV PATH "$PATH:/wasmtime-v38.0.4-x86_64-linux" ENV WASM_WASIP_TARGET=wasm32-wasip1 ENV WASM_WASIP_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_WASIP_TARGET \ From 96d760c748ccfccd0bcfe1c91f4d023dfb774328 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 18 Nov 2025 19:35:43 -0500 Subject: [PATCH 065/194] Update cargo submodule --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 2d4fa139552e..5c0343317ce4 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 2d4fa139552ebdd5f091a1401ed03f7dc62cb43f +Subproject commit 5c0343317ce45d2ec17ecf41eaa473a02d73e29c From 60427ac5be3d1129fc318ef82cf7aa0228a45466 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Tue, 18 Nov 2025 11:17:09 -0700 Subject: [PATCH 066/194] feat: Enable annotate-snippets' simd feature --- Cargo.lock | 1 + compiler/rustc_errors/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 9dce64ce66ab..e186ba343b29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,6 +85,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44baf24dd94e781f74dfe67ffee75a09a57971ddf0f615a178b4f6d404b48ff" dependencies = [ "anstyle", + "memchr", "unicode-width 0.2.2", ] diff --git a/compiler/rustc_errors/Cargo.toml b/compiler/rustc_errors/Cargo.toml index b3f76732a602..a513a0345c3b 100644 --- a/compiler/rustc_errors/Cargo.toml +++ b/compiler/rustc_errors/Cargo.toml @@ -5,7 +5,7 @@ edition = "2024" [dependencies] # tidy-alphabetical-start -annotate-snippets = "0.12.9" +annotate-snippets = { version = "0.12.9", features = ["simd"] } anstream = "0.6.20" anstyle = "1.0.13" derive_setters = "0.1.6" From 1befb0bac0310b8585a244eb009e7f795c293c53 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Thu, 13 Nov 2025 03:50:17 -0700 Subject: [PATCH 067/194] fix: Only add extra padding to the first group's last file --- compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs | 2 ++ tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index 5b1fffd21d18..f26bf31a1aea 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -213,6 +213,7 @@ fn emit_messages_default( file_ann.swap(0, pos); } + let file_ann_len = file_ann.len(); for (file_idx, (file, annotations)) in file_ann.into_iter().enumerate() { if should_show_source_code(&self.ignored_directories_in_source_blocks, sm, &file) { if let Some(snippet) = self.annotated_snippet(annotations, &file.name, sm) { @@ -240,6 +241,7 @@ fn emit_messages_default( // ╰ warning: this was previously accepted if let Some(c) = children.first() && (!c.span.has_primary_spans() && !c.span.has_span_labels()) + && file_idx == file_ann_len - 1 { group = group.element(Padding); } diff --git a/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout index 1048db07ae95..65989a8ef47c 100644 --- a/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout +++ b/tests/rustdoc-ui/doctest/main-alongside-macro-calls.fail.stdout @@ -19,7 +19,6 @@ LL | println!(); error: macro expansion ignores `{` and any tokens following --> $SRC_DIR/std/src/macros.rs:LL:COL | - | ::: $DIR/main-alongside-macro-calls.rs:30:1 | LL | println!(); @@ -42,7 +41,6 @@ LL | println!(); error: macro expansion ignores `{` and any tokens following --> $SRC_DIR/std/src/macros.rs:LL:COL | - | ::: $DIR/main-alongside-macro-calls.rs:34:1 | LL | println!(); From ec17d9ea7cfbe6c69c14f40bff651d0ba8fb5671 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Thu, 13 Nov 2025 03:50:17 -0700 Subject: [PATCH 068/194] fix: Sort annotations by line number in AnnotateSnippetEmitter --- .../src/annotate_snippet_emitter_writer.rs | 8 ++++++++ tests/ui/statics/check-values-constraints.stderr | 4 ++-- tests/ui/typeck/typeck_type_placeholder_item.stderr | 12 ++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index f26bf31a1aea..f7f78d2b2852 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -742,6 +742,14 @@ fn collect_annotations( } } } + + // Sort annotations within each file by line number + for (_, ann) in output.iter_mut() { + ann.sort_by_key(|a| { + let lo = sm.lookup_char_pos(a.span.lo()); + lo.line + }); + } output } diff --git a/tests/ui/statics/check-values-constraints.stderr b/tests/ui/statics/check-values-constraints.stderr index f6fa8df45e5e..c54f4830533a 100644 --- a/tests/ui/statics/check-values-constraints.stderr +++ b/tests/ui/statics/check-values-constraints.stderr @@ -38,10 +38,10 @@ LL | field2: SafeEnum::Variant4("str".to_string()), note: method `to_string` is not const because trait `ToString` is not const --> $SRC_DIR/alloc/src/string.rs:LL:COL | - = note: this method is not const + = note: this trait is not const ::: $SRC_DIR/alloc/src/string.rs:LL:COL | - = note: this trait is not const + = note: this method is not const = note: calls in statics are limited to constant functions, tuple structs and tuple variants = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 747d032dfd4b..5820078d8329 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -686,12 +686,12 @@ LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | note: method `filter` is not const because trait `Iterator` is not const --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this trait is not const + ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | = note: this method is not const - ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL - | - = note: this trait is not const = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const method `, {closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}> as Iterator>::map::` in constants @@ -702,12 +702,12 @@ LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | note: method `map` is not const because trait `Iterator` is not const --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + | + = note: this trait is not const + ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | = note: this method is not const - ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL - | - = note: this trait is not const = note: calls in constants are limited to constant functions, tuple structs and tuple variants error: aborting due to 83 previous errors From 83485b94a03ae6cae525eaa00679b0d10cb80330 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Thu, 13 Nov 2025 03:50:17 -0700 Subject: [PATCH 069/194] fix: Only show one origin for multiline annotations with no source --- compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs | 2 +- tests/ui/typeck/typeck_type_placeholder_item.stderr | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index f7f78d2b2852..7f64dc3df23e 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -633,7 +633,7 @@ fn unannotated_messages<'a>( report.push(std::mem::replace(&mut group, Group::with_level(level.clone()))); } - if !line_tracker.contains(&lo.line) { + if !line_tracker.contains(&lo.line) && (i == 0 || hi.line <= lo.line) { line_tracker.push(lo.line); // ╭▸ $SRC_DIR/core/src/option.rs:594:0 (<- It adds *this*) // ⸬ $SRC_DIR/core/src/option.rs:602:4 diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 5820078d8329..0b70ac97fd43 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -688,7 +688,6 @@ note: method `filter` is not const because trait `Iterator` is not const --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | = note: this trait is not const - ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | = note: this method is not const @@ -704,7 +703,6 @@ note: method `map` is not const because trait `Iterator` is not const --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | = note: this trait is not const - ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL ::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | = note: this method is not const From 0dfdb6c3da4698357b9895625dc743f9f2ff8e67 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Mon, 17 Nov 2025 01:50:10 -0500 Subject: [PATCH 070/194] rlib handling --- compiler/rustc_codegen_llvm/src/intrinsic.rs | 14 ++++++++++++-- .../rustc_mir_transform/src/cross_crate_inline.rs | 8 ++++++++ .../rustc_monomorphize/src/collector/autodiff.rs | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 84fc6ebbc317..029c43e0ba82 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -15,6 +15,7 @@ use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf}; use rustc_middle::ty::{self, GenericArgsRef, Instance, SimdAlign, Ty, TyCtxt, TypingEnv}; use rustc_middle::{bug, span_bug}; +use rustc_session::config::CrateType; use rustc_span::{Span, Symbol, sym}; use rustc_symbol_mangling::{mangle_internal_symbol, symbol_name_for_instance_in_crate}; use rustc_target::callconv::PassMode; @@ -1136,8 +1137,17 @@ fn codegen_autodiff<'ll, 'tcx>( if !tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::Enable) { let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutEnable); } - if tcx.sess.lto() != rustc_session::config::Lto::Fat { - let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto); + + let ct = tcx.crate_types(); + let lto = tcx.sess.lto(); + if ct.len() == 1 && ct.contains(&CrateType::Executable) { + if lto != rustc_session::config::Lto::Fat { + let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto); + } + } else { + if lto != rustc_session::config::Lto::Fat && !tcx.sess.opts.cg.linker_plugin_lto.enabled() { + let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto); + } } let fn_args = instance.args; diff --git a/compiler/rustc_mir_transform/src/cross_crate_inline.rs b/compiler/rustc_mir_transform/src/cross_crate_inline.rs index 7fc9fb9cca2d..69248cf91f24 100644 --- a/compiler/rustc_mir_transform/src/cross_crate_inline.rs +++ b/compiler/rustc_mir_transform/src/cross_crate_inline.rs @@ -34,6 +34,14 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { return true; } + // FIXME(autodiff): replace this as per discussion in https://github.com/rust-lang/rust/pull/149033#discussion_r2535465880 + if tcx.has_attr(def_id, sym::autodiff_forward) + || tcx.has_attr(def_id, sym::autodiff_reverse) + || tcx.has_attr(def_id, sym::rustc_autodiff) + { + return true; + } + if tcx.has_attr(def_id, sym::rustc_intrinsic) { // Intrinsic fallback bodies are always cross-crate inlineable. // To ensure that the MIR inliner doesn't cluelessly try to inline fallback diff --git a/compiler/rustc_monomorphize/src/collector/autodiff.rs b/compiler/rustc_monomorphize/src/collector/autodiff.rs index 13868cca944a..e3646596e75e 100644 --- a/compiler/rustc_monomorphize/src/collector/autodiff.rs +++ b/compiler/rustc_monomorphize/src/collector/autodiff.rs @@ -7,6 +7,8 @@ // mono so this does not interfere in `autodiff` intrinsics // codegen process. If they are unused, LLVM will remove them when // compiling with O3. +// FIXME(autodiff): Remove this whole file, as per discussion in +// https://github.com/rust-lang/rust/pull/149033#discussion_r2535465880 pub(crate) fn collect_autodiff_fn<'tcx>( tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>, From 2d1fc63101b9689472568a91188034fb62345f30 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Tue, 18 Nov 2025 23:37:30 -0500 Subject: [PATCH 071/194] adding a working rlib autodiff test --- tests/run-make/autodiff/rlib/dep.rs | 7 +++ tests/run-make/autodiff/rlib/lib.rs | 13 ++++++ tests/run-make/autodiff/rlib/main.rs | 8 ++++ tests/run-make/autodiff/rlib/rmake.rs | 66 +++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 tests/run-make/autodiff/rlib/dep.rs create mode 100644 tests/run-make/autodiff/rlib/lib.rs create mode 100644 tests/run-make/autodiff/rlib/main.rs create mode 100644 tests/run-make/autodiff/rlib/rmake.rs diff --git a/tests/run-make/autodiff/rlib/dep.rs b/tests/run-make/autodiff/rlib/dep.rs new file mode 100644 index 000000000000..6fc9b2c2473f --- /dev/null +++ b/tests/run-make/autodiff/rlib/dep.rs @@ -0,0 +1,7 @@ +pub fn f(x: f64, y: f64) -> f64 { + 2.0 * x + y +} + +pub fn g(x: f64) -> f64 { + 2.0 * x +} diff --git a/tests/run-make/autodiff/rlib/lib.rs b/tests/run-make/autodiff/rlib/lib.rs new file mode 100644 index 000000000000..b459fed643a1 --- /dev/null +++ b/tests/run-make/autodiff/rlib/lib.rs @@ -0,0 +1,13 @@ +#![feature(autodiff)] +extern crate simple_dep; +use std::autodiff::*; + +#[inline(never)] +pub fn f2(x: f64) -> f64 { + x.sin() +} + +#[autodiff_forward(df1_lib, Dual, Dual)] +pub fn _f1(x: f64) -> f64 { + simple_dep::f(x, x) * f2(x) +} diff --git a/tests/run-make/autodiff/rlib/main.rs b/tests/run-make/autodiff/rlib/main.rs new file mode 100644 index 000000000000..a3e5fcde0381 --- /dev/null +++ b/tests/run-make/autodiff/rlib/main.rs @@ -0,0 +1,8 @@ +extern crate foo; + +fn main() { + //dbg!("Running main.rs"); + let enzyme_y1_lib = foo::df1_lib(1.5, 1.0); + println!("output1: {:?}", enzyme_y1_lib.0); + println!("output2: {:?}", enzyme_y1_lib.1); +} diff --git a/tests/run-make/autodiff/rlib/rmake.rs b/tests/run-make/autodiff/rlib/rmake.rs new file mode 100644 index 000000000000..59eaa836864c --- /dev/null +++ b/tests/run-make/autodiff/rlib/rmake.rs @@ -0,0 +1,66 @@ +//@ needs-enzyme +//@ ignore-cross-compile + +use run_make_support::{cwd, run, rustc}; + +fn main() { + // Build the dependency crate. + rustc() + .input("dep.rs") + .arg("-Zautodiff=Enable") + .arg("--edition=2024") + .arg("-Copt-level=3") + .arg("--crate-name=simple_dep") + .arg("-Clinker-plugin-lto") + .arg("--crate-type=lib") + .emit("dep-info,metadata,link") + .run(); + + let cwd = cwd(); + let cwd_str = cwd.to_string_lossy(); + + let mydep = format!("-Ldependency={cwd_str}"); + + let simple_dep_rlib = + format!("--extern=simple_dep={}", cwd.join("libsimple_dep.rlib").to_string_lossy()); + + // Build the main library that depends on `simple_dep`. + rustc() + .input("lib.rs") + .arg("-Zautodiff=Enable") + .arg("--edition=2024") + .arg("-Copt-level=3") + .arg("--crate-name=foo") + .arg("-Clinker-plugin-lto") + .arg("--crate-type=lib") + .emit("dep-info,metadata,link") + .arg(&mydep) + .arg(&simple_dep_rlib) + .run(); + + let foo_rlib = format!("--extern=foo={}", cwd.join("libfoo.rlib").to_string_lossy()); + + // Build the final binary linking both rlibs. + rustc() + .input("main.rs") + .arg("-Zautodiff=Enable") + .arg("--edition=2024") + .arg("-Copt-level=3") + .arg("--crate-name=foo") + .arg("-Clto=fat") + .arg("--crate-type=bin") + .emit("dep-info,link") + .arg(&mydep) + .arg(&foo_rlib) + .arg(&simple_dep_rlib) + .run(); + + // Run the binary and check its output. + let binary = run("foo"); + assert!(binary.status().success(), "binary failed to run"); + + let binary_out = binary.stdout(); + let output = String::from_utf8_lossy(&binary_out); + assert!(output.contains("output1: 4.488727439718245")); + assert!(output.contains("output2: 3.3108023673168265")); +} From 4930d3e6129b17538e687f97c3b3f3e0dcaea76f Mon Sep 17 00:00:00 2001 From: yukang Date: Wed, 19 Nov 2025 08:16:11 +0800 Subject: [PATCH 072/194] Fix the issue of unused assignment from MIR liveness checking --- compiler/rustc_mir_transform/src/liveness.rs | 25 +++++++----- tests/ui/lint/unused/unused-assign-148960.rs | 33 +++++++++++++++ .../lint/unused/unused-assign-148960.stderr | 40 +++++++++++++++++++ 3 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 tests/ui/lint/unused/unused-assign-148960.rs create mode 100644 tests/ui/lint/unused/unused-assign-148960.stderr diff --git a/compiler/rustc_mir_transform/src/liveness.rs b/compiler/rustc_mir_transform/src/liveness.rs index f7dc70356024..d0134689fec0 100644 --- a/compiler/rustc_mir_transform/src/liveness.rs +++ b/compiler/rustc_mir_transform/src/liveness.rs @@ -45,6 +45,9 @@ struct Access { /// When we encounter multiple statements at the same location, we only increase the liveness, /// in order to avoid false positives. live: bool, + /// Is this a direct access to the place itself, no projections, or to a field? + /// This helps distinguish `x = ...` from `x.field = ...` + is_direct: bool, } #[tracing::instrument(level = "debug", skip(tcx), ret)] @@ -650,15 +653,17 @@ fn find_dead_assignments( |place: Place<'tcx>, kind, source_info: SourceInfo, live: &DenseBitSet| { if let Some((index, extra_projections)) = checked_places.get(place.as_ref()) { if !is_indirect(extra_projections) { + let is_direct = extra_projections.is_empty(); match assignments[index].entry(source_info) { IndexEntry::Vacant(v) => { - let access = Access { kind, live: live.contains(index) }; + let access = Access { kind, live: live.contains(index), is_direct }; v.insert(access); } IndexEntry::Occupied(mut o) => { // There were already a sighting. Mark this statement as live if it // was, to avoid false positives. o.get_mut().live |= live.contains(index); + o.get_mut().is_direct &= is_direct; } } } @@ -742,7 +747,7 @@ fn find_dead_assignments( continue; }; let source_info = body.local_decls[place.local].source_info; - let access = Access { kind, live: live.contains(index) }; + let access = Access { kind, live: live.contains(index), is_direct: true }; assignments[index].insert(source_info, access); } } @@ -1048,26 +1053,28 @@ fn report_unused_assignments(self) { let Some((name, decl_span)) = self.checked_places.names[index] else { continue }; - // We have outstanding assignments and with non-trivial drop. - // This is probably a drop-guard, so we do not issue a warning there. - if maybe_drop_guard( + let is_maybe_drop_guard = maybe_drop_guard( tcx, self.typing_env, index, &self.ever_dropped, self.checked_places, self.body, - ) { - continue; - } + ); // We probed MIR in reverse order for dataflow. // We revert the vector to give a consistent order to the user. - for (source_info, Access { live, kind }) in statements.into_iter().rev() { + for (source_info, Access { live, kind, is_direct }) in statements.into_iter().rev() { if live { continue; } + // If this place was dropped and has non-trivial drop, + // skip reporting field assignments. + if !is_direct && is_maybe_drop_guard { + continue; + } + // Report the dead assignment. let Some(hir_id) = source_info.scope.lint_root(&self.body.source_scopes) else { continue; diff --git a/tests/ui/lint/unused/unused-assign-148960.rs b/tests/ui/lint/unused/unused-assign-148960.rs new file mode 100644 index 000000000000..5d1810ad04a6 --- /dev/null +++ b/tests/ui/lint/unused/unused-assign-148960.rs @@ -0,0 +1,33 @@ +//@ check-fail +#![deny(unused)] + +fn test_one_extra_assign() { + let mut value = b"0".to_vec(); //~ ERROR value assigned to `value` is never read + value = b"1".to_vec(); + println!("{:?}", value); +} + +fn test_two_extra_assign() { + let mut x = 1; //~ ERROR value assigned to `x` is never read + x = 2; //~ ERROR value assigned to `x` is never read + x = 3; + println!("{}", x); +} + +struct Point { + x: i32, + y: i32, +} + +fn test_indirect_assign() { + let mut p = Point { x: 1, y: 1 }; //~ ERROR value assigned to `p` is never read + p = Point { x: 2, y: 2 }; + p.x = 3; + println!("{}", p.y); +} + +fn main() { + test_one_extra_assign(); + test_two_extra_assign(); + test_indirect_assign(); +} diff --git a/tests/ui/lint/unused/unused-assign-148960.stderr b/tests/ui/lint/unused/unused-assign-148960.stderr new file mode 100644 index 000000000000..3f135264d869 --- /dev/null +++ b/tests/ui/lint/unused/unused-assign-148960.stderr @@ -0,0 +1,40 @@ +error: value assigned to `value` is never read + --> $DIR/unused-assign-148960.rs:5:21 + | +LL | let mut value = b"0".to_vec(); + | ^^^^^^^^^^^^^ + | + = help: maybe it is overwritten before being read? +note: the lint level is defined here + --> $DIR/unused-assign-148960.rs:2:9 + | +LL | #![deny(unused)] + | ^^^^^^ + = note: `#[deny(unused_assignments)]` implied by `#[deny(unused)]` + +error: value assigned to `x` is never read + --> $DIR/unused-assign-148960.rs:11:17 + | +LL | let mut x = 1; + | ^ + | + = help: maybe it is overwritten before being read? + +error: value assigned to `x` is never read + --> $DIR/unused-assign-148960.rs:12:5 + | +LL | x = 2; + | ^^^^^ + | + = help: maybe it is overwritten before being read? + +error: value assigned to `p` is never read + --> $DIR/unused-assign-148960.rs:23:17 + | +LL | let mut p = Point { x: 1, y: 1 }; + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: maybe it is overwritten before being read? + +error: aborting due to 4 previous errors + From 0b2e02f135215feb5d985903a2dd3c7a20e0bd68 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Wed, 19 Nov 2025 01:20:15 -0500 Subject: [PATCH 073/194] autodiff: update formating, improve examples for the unstable-book --- .../src/compiler-flags/autodiff.md | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/doc/unstable-book/src/compiler-flags/autodiff.md b/src/doc/unstable-book/src/compiler-flags/autodiff.md index 28d2ece1468f..8d51312466bc 100644 --- a/src/doc/unstable-book/src/compiler-flags/autodiff.md +++ b/src/doc/unstable-book/src/compiler-flags/autodiff.md @@ -6,16 +6,37 @@ The tracking issue for this feature is: [#124509](https://github.com/rust-lang/r This feature allows you to differentiate functions using automatic differentiation. Set the `-Zautodiff=` compiler flag to adjust the behaviour of the autodiff feature. -Multiple options can be separated with a comma. Valid options are: +Multiple options can be separated with a comma. -`Enable` - Required flag to enable autodiff -`PrintTA` - print Type Analysis Information -`PrintTAFn` - print Type Analysis Information for a specific function -`PrintAA` - print Activity Analysis Information -`PrintPerf` - print Performance Warnings from Enzyme -`PrintSteps` - prints all intermediate transformations -`PrintModBefore` - print the whole module, before running opts -`PrintModAfter` - print the module after Enzyme differentiated everything -`LooseTypes` - Enzyme's loose type debug helper (can cause incorrect gradients) -`Inline` - runs Enzyme specific Inlining -`RuntimeActivity` - allow specifying activity at runtime +## Syntax +```bash +rustc -Z autodiff=Enable[,options] +``` + +Where `options` can be: + +- `Enable` - Required flag to enable autodiff +- `PrintTA` - print Type Analysis Information +- `PrintTAFn=` - print Type Analysis Information for a specific function (consider combining it with `no_mangle`) +- `PrintAA` - print Activity Analysis Information +- `PrintPerf` - print Performance Warnings from Enzyme +- `PrintSteps` - prints all intermediate transformations +- `PrintModBefore` - print the whole module, before running opts +- `PrintModAfter` - print the module after Enzyme differentiated everything +- `LooseTypes` - Enzyme's loose type debug helper (can cause incorrect gradients) +- `Inline` - runs Enzyme specific Inlining +- `RuntimeActivity` - allow specifying activity at runtime + + +## Examples + +```bash +# Enable autodiff via cargo, assuming `enzyme` being a toolchain that supports autodiff +"RUSTFLAGS=-Zautodiff=Enable" cargo +enzyme build + +# Enable autodiff directly via rustc +rustc -Z autodiff=Enable + +# Print TypeAnalysis updates for the function `foo`, as well as Activity Analysis for all differentiated code. +rustc -Z autodiff=Enable,PrintTAFn=foo,PrintAA +``` From 10172d1c250c132894f49ec4fa25a8555adadf65 Mon Sep 17 00:00:00 2001 From: "Eddy (Eduard) Stefes" Date: Tue, 18 Nov 2025 11:39:00 +0100 Subject: [PATCH 074/194] disable the fragment_in_dst_padding_gets_overwritten test on s390x on s390x 128bit types have a smaller alignment then on x86[^1]. This leads to smaller structs and therefore the write_unaligned will write outside of the structs boundary. For now disable the tests on s390x. [^2] [^1]: s390x ELF ABI Table 1.1, Page 12 https://github.com/IBM/s390x-abi [^2]: https://github.com/rust-lang/rust/pull/149056#issuecomment-3547543222 Co-authored-by: Ralf Jung --- tests/ui/consts/const-eval/ptr_fragments.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui/consts/const-eval/ptr_fragments.rs b/tests/ui/consts/const-eval/ptr_fragments.rs index c251eea8add5..d27804084d73 100644 --- a/tests/ui/consts/const-eval/ptr_fragments.rs +++ b/tests/ui/consts/const-eval/ptr_fragments.rs @@ -68,6 +68,7 @@ struct Thing { }; #[allow(dead_code)] +#[cfg(not(target_arch = "s390x"))] // u128 is less aligned on s390x, removing the padding fn fragment_in_dst_padding_gets_overwritten() { #[repr(C)] struct Pair { From 9f49ac385aa0974eaa36c74c31e0f0b6b2253d99 Mon Sep 17 00:00:00 2001 From: Ximon Eighteen <3304436+ximon18@users.noreply.github.com> Date: Wed, 19 Nov 2025 11:03:00 +0100 Subject: [PATCH 075/194] Add missing trailing period to RustDoc for fn create_dir(). --- library/std/src/fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index b548eb4939d4..8b3e943b4ccd 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -2918,7 +2918,7 @@ pub fn canonicalize>(path: P) -> io::Result { fs_imp::canonicalize(path.as_ref()) } -/// Creates a new, empty directory at the provided path +/// Creates a new, empty directory at the provided path. /// /// # Platform-specific behavior /// From ff0011054366bac13a6b01e4a84c76f2a821c52e Mon Sep 17 00:00:00 2001 From: David Wood Date: Fri, 15 Oct 2021 15:20:21 +0000 Subject: [PATCH 076/194] sess: default to v0 symbol mangling Rust's current mangling scheme depends on compiler internals; loses information about generic parameters (and other things) which makes for a worse experience when using external tools that need to interact with Rust symbol names; is inconsistent; and can contain `.` characters which aren't universally supported. Therefore, Rust has defined its own symbol mangling scheme which is defined in terms of the Rust language, not the compiler implementation; encodes information about generic parameters in a reversible way; has a consistent definition; and generates symbols that only use the characters `A-Z`, `a-z`, `0-9`, and `_`. Support for the new Rust symbol mangling scheme has been added to upstream tools that will need to interact with Rust symbols (e.g. debuggers). This commit changes the default symbol mangling scheme from the legacy scheme to the new Rust mangling scheme. Signed-off-by: David Wood --- compiler/rustc_session/src/config.rs | 6 +++- src/doc/rustc/src/symbol-mangling/index.md | 2 +- .../closure-inherit-target-feature.rs | 8 ++--- tests/assembly-llvm/nvptx-safe-naming.rs | 2 +- tests/codegen-llvm/array-from_fn.rs | 4 +-- .../binary-heap-peek-mut-pop-no-panic.rs | 2 +- tests/codegen-llvm/cold-attribute.rs | 8 ++--- .../iter-max-no-unwrap-failed-129583.rs | 2 +- tests/codegen-llvm/naked-fn/generics.rs | 4 +-- .../codegen-llvm/no-alloca-inside-if-false.rs | 6 ++-- tests/codegen-llvm/precondition-checks.rs | 4 +-- ...tadata-id-itanium-cxx-abi-drop-in-place.rs | 4 +-- .../sanitizer/kcfi/fn-ptr-reify-shim.rs | 6 ++-- .../sanitizer/kcfi/naked-function.rs | 4 +-- tests/codegen-llvm/sanitizer/sanitize-off.rs | 4 +-- tests/debuginfo/basic-types-globals.rs | 34 ++++++++++--------- tests/debuginfo/no_mangle-info.rs | 2 +- ...hort-ice-remove-middle-frames-2.run.stderr | 6 ++-- .../short-ice-remove-middle-frames.run.stderr | 6 ++-- tests/ui/sanitizer/realtime-blocking.rs | 2 +- 20 files changed, 61 insertions(+), 55 deletions(-) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 1a00a72d8149..b229db1a4b16 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1530,7 +1530,11 @@ pub fn share_generics(&self) -> bool { } pub fn get_symbol_mangling_version(&self) -> SymbolManglingVersion { - self.cg.symbol_mangling_version.unwrap_or(SymbolManglingVersion::Legacy) + self.cg.symbol_mangling_version.unwrap_or(if self.unstable_features.is_nightly_build() { + SymbolManglingVersion::V0 + } else { + SymbolManglingVersion::Legacy + }) } #[inline] diff --git a/src/doc/rustc/src/symbol-mangling/index.md b/src/doc/rustc/src/symbol-mangling/index.md index be58f2b41b8d..ad565da9746c 100644 --- a/src/doc/rustc/src/symbol-mangling/index.md +++ b/src/doc/rustc/src/symbol-mangling/index.md @@ -47,6 +47,6 @@ foo::example_function ## Mangling versions `rustc` supports different mangling versions which encode the names in different ways. -The legacy version (which is currently the default) is not described here. +The legacy version (which is currently the default on beta/stable) is not described here. The "v0" mangling scheme addresses several limitations of the legacy format, and is described in the [v0 Symbol Format](v0.md) chapter. diff --git a/tests/assembly-llvm/closure-inherit-target-feature.rs b/tests/assembly-llvm/closure-inherit-target-feature.rs index 069204bbd345..c3753a534a02 100644 --- a/tests/assembly-llvm/closure-inherit-target-feature.rs +++ b/tests/assembly-llvm/closure-inherit-target-feature.rs @@ -13,7 +13,7 @@ pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128, ret: *mut __m128) { let f = { // check that _mm_blend_ps is not being inlined into the closure - // CHECK-LABEL: {{sse41_blend_nofeature.*closure.*:}} + // CHECK-LABEL: {{sse41_blend_nofeature:}} // CHECK-NOT: blendps // CHECK: {{call .*_mm_blend_ps.*}} // CHECK-NOT: blendps @@ -29,7 +29,7 @@ pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128, ret: *mut __m128) { pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 { let f = { // check that _mm_blend_ps is being inlined into the closure - // CHECK-LABEL: {{sse41_blend_noinline.*closure.*:}} + // CHECK-LABEL: {{sse41_blend_noinline:}} // CHECK-NOT: _mm_blend_ps // CHECK: blendps // CHECK-NOT: _mm_blend_ps @@ -45,10 +45,10 @@ pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 { pub fn sse41_blend_doinline(x: __m128, y: __m128) -> __m128 { // check that the closure and _mm_blend_ps are being inlined into the function // CHECK-LABEL: sse41_blend_doinline: - // CHECK-NOT: {{sse41_blend_doinline.*closure.*}} + // CHECK-NOT: {{sse41_blend_doinline:}} // CHECK-NOT: _mm_blend_ps // CHECK: blendps - // CHECK-NOT: {{sse41_blend_doinline.*closure.*}} + // CHECK-NOT: {{sse41_blend_doinline.*}} // CHECK-NOT: _mm_blend_ps // CHECK: ret let f = { diff --git a/tests/assembly-llvm/nvptx-safe-naming.rs b/tests/assembly-llvm/nvptx-safe-naming.rs index 6a6659a4e304..c70c63b7ee7c 100644 --- a/tests/assembly-llvm/nvptx-safe-naming.rs +++ b/tests/assembly-llvm/nvptx-safe-naming.rs @@ -12,7 +12,7 @@ extern crate breakpoint_panic_handler; // Verify function name doesn't contain unacceaptable characters. -// CHECK: .func (.param .b32 func_retval0) [[IMPL_FN:[a-zA-Z0-9$_]+square[a-zA-Z0-9$_]+]] +// CHECK: .func (.param .b32 func_retval0) [[IMPL_FN:[a-zA-Z0-9$_]+square]] // CHECK-LABEL: .visible .entry top_kernel( #[no_mangle] diff --git a/tests/codegen-llvm/array-from_fn.rs b/tests/codegen-llvm/array-from_fn.rs index 7202d0c67e69..0a6d5aec4b65 100644 --- a/tests/codegen-llvm/array-from_fn.rs +++ b/tests/codegen-llvm/array-from_fn.rs @@ -7,7 +7,7 @@ #[no_mangle] pub fn iota() -> [u8; 16] { - // OPT-NOT: core..array..Guard - // NORMAL: core..array..Guard + // OPT-NOT: core::array::Guard + // NORMAL: core::array::Guard std::array::from_fn(|i| i as _) } diff --git a/tests/codegen-llvm/binary-heap-peek-mut-pop-no-panic.rs b/tests/codegen-llvm/binary-heap-peek-mut-pop-no-panic.rs index 2c40327f6245..3d3a0f91c3e6 100644 --- a/tests/codegen-llvm/binary-heap-peek-mut-pop-no-panic.rs +++ b/tests/codegen-llvm/binary-heap-peek-mut-pop-no-panic.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Copt-level=3 +//@ compile-flags: -Copt-level=3 --crate-name=test //@ ignore-std-debug-assertions #![crate_type = "lib"] diff --git a/tests/codegen-llvm/cold-attribute.rs b/tests/codegen-llvm/cold-attribute.rs index 92b4280eaf27..fd8b3dbea2ae 100644 --- a/tests/codegen-llvm/cold-attribute.rs +++ b/tests/codegen-llvm/cold-attribute.rs @@ -20,7 +20,7 @@ async fn x(f: impl Future) { f.await; } x( - // CHECK-LABEL: ; cold_attribute::async_block::{{{{closure}}}}::{{{{closure}}}} + // CHECK-LABEL: ; cold_attribute::async_block::{closure#0}::{closure#0} // CHECK-NEXT: Function Attrs: cold {{.*}} #[cold] async {}, @@ -33,7 +33,7 @@ fn x(f: impl Fn()) { f() } x( - // CHECK-LABEL: ; cold_attribute::closure::{{{{closure}}}} + // CHECK-LABEL: ; cold_attribute::closure::{closure#0} // CHECK-NEXT: Function Attrs: cold {{.*}} #[cold] || {}, @@ -43,14 +43,14 @@ fn x(f: impl Fn()) { pub struct S; impl S { - // CHECK-LABEL: ; cold_attribute::S::method + // CHECK-LABEL: ; ::method // CHECK-NEXT: Function Attrs: cold {{.*}} #[cold] pub fn method(&self) {} } pub trait Trait { - // CHECK-LABEL: ; cold_attribute::Trait::trait_fn + // CHECK-LABEL: ; ::trait_fn // CHECK-NEXT: Function Attrs: cold {{.*}} #[cold] fn trait_fn(&self) {} diff --git a/tests/codegen-llvm/issues/iter-max-no-unwrap-failed-129583.rs b/tests/codegen-llvm/issues/iter-max-no-unwrap-failed-129583.rs index 4c4eebeabb5f..80bd37a63201 100644 --- a/tests/codegen-llvm/issues/iter-max-no-unwrap-failed-129583.rs +++ b/tests/codegen-llvm/issues/iter-max-no-unwrap-failed-129583.rs @@ -2,7 +2,7 @@ // The iterator may unroll for values smaller than a certain threshold so we // use a larger value to prevent unrolling. -//@ compile-flags: -Copt-level=3 +//@ compile-flags: -Copt-level=3 --crate-name=test #![crate_type = "lib"] diff --git a/tests/codegen-llvm/naked-fn/generics.rs b/tests/codegen-llvm/naked-fn/generics.rs index 865be00d91ee..b1e33ac348c6 100644 --- a/tests/codegen-llvm/naked-fn/generics.rs +++ b/tests/codegen-llvm/naked-fn/generics.rs @@ -20,11 +20,11 @@ fn test(x: u64) { } // CHECK: .balign 4 -// CHECK: add rax, 2 +// CHECK: add rax, 1 // CHECK: add rax, 42 // CHECK: .balign 4 -// CHECK: add rax, 1 +// CHECK: add rax, 2 // CHECK: add rax, 42 #[unsafe(naked)] diff --git a/tests/codegen-llvm/no-alloca-inside-if-false.rs b/tests/codegen-llvm/no-alloca-inside-if-false.rs index a231c7e808a3..d2458d0a9ab2 100644 --- a/tests/codegen-llvm/no-alloca-inside-if-false.rs +++ b/tests/codegen-llvm/no-alloca-inside-if-false.rs @@ -7,10 +7,10 @@ #[inline(never)] fn test() { - // CHECK-LABEL: no_alloca_inside_if_false::test + // CHECK-LABEL: no_alloca_inside_if_false::test::<8192> // CHECK: start: - // CHECK-NEXT: alloca [{{12|24}} x i8] - // CHECK-NOT: alloca + // CHECK-NEXT: = alloca [{{12|24}} x i8] + // CHECK-NOT: = alloca if const { SIZE < 4096 } { let arr = [0u8; SIZE]; std::hint::black_box(&arr); diff --git a/tests/codegen-llvm/precondition-checks.rs b/tests/codegen-llvm/precondition-checks.rs index 16812ca17207..df8d6ff4c2ef 100644 --- a/tests/codegen-llvm/precondition-checks.rs +++ b/tests/codegen-llvm/precondition-checks.rs @@ -13,13 +13,13 @@ use std::ptr::NonNull; -// CHECK-LABEL: ; core::ptr::non_null::NonNull::new_unchecked +// CHECK-LABEL: ; >::new_unchecked // CHECK-NOT: call // CHECK: } // CHECK-LABEL: @nonnull_new #[no_mangle] pub unsafe fn nonnull_new(ptr: *mut u8) -> NonNull { - // CHECK: ; call core::ptr::non_null::NonNull::new_unchecked + // CHECK: ; call >::new_unchecked unsafe { NonNull::new_unchecked(ptr) } } diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs index 279350d20c5f..a5ec3a9ab718 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs @@ -9,7 +9,7 @@ #![crate_type = "lib"] -// CHECK-LABEL: define{{.*}}4core3ptr47drop_in_place$LT$dyn$u20$core..marker..Send$GT$ +// CHECK-LABEL: define{{.*}}4core3ptr13drop_in_placeDNtNtB4_6marker4Send // CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} // CHECK: call i1 @llvm.type.test(ptr {{%.+}}, metadata !"_ZTSFvPu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops4drop4Dropu6regionEE") @@ -20,7 +20,7 @@ impl Drop for PresentDrop { fn drop(&mut self) {} - // CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place$LT${{.*}}PresentDrop$GT${{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place{{.*}}PresentDrop{{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} } pub fn foo() { diff --git a/tests/codegen-llvm/sanitizer/kcfi/fn-ptr-reify-shim.rs b/tests/codegen-llvm/sanitizer/kcfi/fn-ptr-reify-shim.rs index b5900852711d..676b2af8c8f1 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/fn-ptr-reify-shim.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/fn-ptr-reify-shim.rs @@ -54,11 +54,11 @@ pub fn main() { // `DynCompatible` is indeed dyn-compatible. let _: &dyn DynCompatible = &s; - // CHECK: call ::dyn_name{{.*}}reify.shim.fnptr + // CHECK: call ::dyn_name::{shim:reify_fnptr#0} let dyn_name = S::dyn_name as fn(&S) -> &str; let _unused = dyn_name(&s); - // CHECK: call fn_ptr_reify_shim::DynCompatible::dyn_name_default{{.*}}reify.shim.fnptr + // CHECK: call ::dyn_name_default::{shim:reify_fnptr#0} let dyn_name_default = S::dyn_name_default as fn(&S) -> &str; let _unused = dyn_name_default(&s); @@ -68,7 +68,7 @@ pub fn main() { let not_dyn_name = S::not_dyn_name as fn() -> &'static str; let _unused = not_dyn_name(); - // CHECK: call fn_ptr_reify_shim::NotDynCompatible::not_dyn_name_default{{$}} + // CHECK: call ::not_dyn_name_default{{$}} let not_dyn_name_default = S::not_dyn_name_default as fn() -> &'static str; let _unused = not_dyn_name_default(); } diff --git a/tests/codegen-llvm/sanitizer/kcfi/naked-function.rs b/tests/codegen-llvm/sanitizer/kcfi/naked-function.rs index 77684fea7022..830689780dce 100644 --- a/tests/codegen-llvm/sanitizer/kcfi/naked-function.rs +++ b/tests/codegen-llvm/sanitizer/kcfi/naked-function.rs @@ -29,7 +29,7 @@ impl MyTrait for Thing {} // the shim calls the real function // CHECK-LABEL: define // CHECK-SAME: my_naked_function -// CHECK-SAME: reify.shim.fnptr +// CHECK-SAME: reify_fnptr // CHECK-LABEL: main #[unsafe(no_mangle)] @@ -40,7 +40,7 @@ pub fn main() { // main calls the shim function // CHECK: call void // CHECK-SAME: my_naked_function - // CHECK-SAME: reify.shim.fnptr + // CHECK-SAME: reify_fnptr (F)(&Thing); } diff --git a/tests/codegen-llvm/sanitizer/sanitize-off.rs b/tests/codegen-llvm/sanitizer/sanitize-off.rs index 9f3f7cd9df78..ac7c49322c6d 100644 --- a/tests/codegen-llvm/sanitizer/sanitize-off.rs +++ b/tests/codegen-llvm/sanitizer/sanitize-off.rs @@ -66,7 +66,7 @@ pub trait MyTrait { fn unsanitized(&self, b: &mut u8) -> u8; fn sanitized(&self, b: &mut u8) -> u8; - // CHECK-LABEL: ; sanitize_off::MyTrait::unsanitized_default + // CHECK-LABEL: ; <() as sanitize_off::MyTrait>::unsanitized_default // CHECK-NEXT: ; Function Attrs: // CHECK-NOT: sanitize_address // CHECK: start: @@ -77,7 +77,7 @@ fn unsanitized_default(&self, b: &mut u8) -> u8 { *b } - // CHECK-LABEL: ; sanitize_off::MyTrait::sanitized_default + // CHECK-LABEL: ; <() as sanitize_off::MyTrait>::sanitized_default // CHECK-NEXT: ; Function Attrs: // CHECK: sanitize_address // CHECK: start: diff --git a/tests/debuginfo/basic-types-globals.rs b/tests/debuginfo/basic-types-globals.rs index d8997b3f75a9..6e4150873832 100644 --- a/tests/debuginfo/basic-types-globals.rs +++ b/tests/debuginfo/basic-types-globals.rs @@ -9,35 +9,35 @@ // lldb-command:run // lldb-command:v B -// lldb-check: ::B::[...] = false +// lldb-check: ::B = false // lldb-command:v I -// lldb-check: ::I::[...] = -1 +// lldb-check: ::I = -1 // lldb-command:v --format=d C -// lldb-check: ::C::[...] = 97 +// lldb-check: ::C = 97 // lldb-command:v --format=d I8 -// lldb-check: ::I8::[...] = 68 +// lldb-check: ::I8 = 68 // lldb-command:v I16 -// lldb-check: ::I16::[...] = -16 +// lldb-check: ::I16 = -16 // lldb-command:v I32 -// lldb-check: ::I32::[...] = -32 +// lldb-check: ::I32 = -32 // lldb-command:v I64 -// lldb-check: ::I64::[...] = -64 +// lldb-check: ::I64 = -64 // lldb-command:v U -// lldb-check: ::U::[...] = 1 +// lldb-check: ::U = 1 // lldb-command:v --format=d U8 -// lldb-check: ::U8::[...] = 100 +// lldb-check: ::U8 = 100 // lldb-command:v U16 -// lldb-check: ::U16::[...] = 16 +// lldb-check: ::U16 = 16 // lldb-command:v U32 -// lldb-check: ::U32::[...] = 32 +// lldb-check: ::U32 = 32 // lldb-command:v U64 -// lldb-check: ::U64::[...] = 64 +// lldb-check: ::U64 = 64 // lldb-command:v F16 -// lldb-check: ::F16::[...] = 1.5 +// lldb-check: ::F16 = 1.5 // lldb-command:v F32 -// lldb-check: ::F32::[...] = 2.5 +// lldb-check: ::F32 = 2.5 // lldb-command:v F64 -// lldb-check: ::F64::[...] = 3.5 +// lldb-check: ::F64 = 3.5 // gdb-command:run // gdb-command:print B @@ -103,4 +103,6 @@ fn main() { let b = unsafe { F16 }; } -fn _zzz() {()} +fn _zzz() { + () +} diff --git a/tests/debuginfo/no_mangle-info.rs b/tests/debuginfo/no_mangle-info.rs index d1daef669cee..ed112bc05e31 100644 --- a/tests/debuginfo/no_mangle-info.rs +++ b/tests/debuginfo/no_mangle-info.rs @@ -14,7 +14,7 @@ // lldb-command:v TEST // lldb-check:(unsigned long) TEST = 3735928559 // lldb-command:v OTHER_TEST -// lldb-check:(unsigned long) no_mangle_info::namespace::OTHER_TEST::[...] = 42 +// lldb-check:(unsigned long) no_mangle_info::namespace::OTHER_TEST = 42 // === CDB TESTS ================================================================================== // cdb-command: g diff --git a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr index 584b477f3a7c..a652eb211285 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr @@ -4,12 +4,12 @@ debug!!! stack backtrace: 0: std::panicking::begin_panic 1: short_ice_remove_middle_frames_2::eight - 2: short_ice_remove_middle_frames_2::seven::{{closure}} + 2: short_ice_remove_middle_frames_2::seven::{closure#0} [... omitted 3 frames ...] 3: short_ice_remove_middle_frames_2::fifth - 4: short_ice_remove_middle_frames_2::fourth::{{closure}} + 4: short_ice_remove_middle_frames_2::fourth::{closure#0} [... omitted 4 frames ...] 5: short_ice_remove_middle_frames_2::first 6: short_ice_remove_middle_frames_2::main - 7: core::ops::function::FnOnce::call_once + 7: >::call_once note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr index 1efcb7d53040..31fcda89a1bf 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr @@ -5,11 +5,11 @@ stack backtrace: 0: std::panicking::begin_panic 1: short_ice_remove_middle_frames::seven 2: short_ice_remove_middle_frames::sixth - 3: short_ice_remove_middle_frames::fifth::{{closure}} + 3: short_ice_remove_middle_frames::fifth::{closure#0} [... omitted 4 frames ...] 4: short_ice_remove_middle_frames::second - 5: short_ice_remove_middle_frames::first::{{closure}} + 5: short_ice_remove_middle_frames::first::{closure#0} 6: short_ice_remove_middle_frames::first 7: short_ice_remove_middle_frames::main - 8: core::ops::function::FnOnce::call_once + 8: >::call_once note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/sanitizer/realtime-blocking.rs b/tests/ui/sanitizer/realtime-blocking.rs index a27448a346f0..368f2ca571b5 100644 --- a/tests/ui/sanitizer/realtime-blocking.rs +++ b/tests/ui/sanitizer/realtime-blocking.rs @@ -6,7 +6,7 @@ // //@ run-fail //@ error-pattern: Call to blocking function -//@ error-pattern: realtime_blocking::blocking:: +//@ error-pattern: realtime_blocking::blocking //@ ignore-backends: gcc #![feature(sanitize)] From ed6a78ca868625faa50c66409037df66bff3e5bd Mon Sep 17 00:00:00 2001 From: James Barford-Evans Date: Wed, 19 Nov 2025 15:50:40 +0000 Subject: [PATCH 077/194] Fix error message for calling a non-tuple struct --- .../rustc_resolve/src/late/diagnostics.rs | 40 +++++++++++++------ ...ession-struct-called-as-function-148919.rs | 10 +++++ ...on-struct-called-as-function-148919.stderr | 9 +++++ 3 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 tests/ui/resolve/regression-struct-called-as-function-148919.rs create mode 100644 tests/ui/resolve/regression-struct-called-as-function-148919.stderr diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 0b4c52d68b6f..74afae7996b2 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -823,8 +823,10 @@ fn try_lookup_name_relaxed( } if let Some(Res::Def(DefKind::Struct, def_id)) = res { - self.update_err_for_private_tuple_struct_fields(err, &source, def_id); - err.note("constructor is not visible here due to private fields"); + if self.has_private_fields(def_id) { + self.update_err_for_private_tuple_struct_fields(err, &source, def_id); + err.note("constructor is not visible here due to private fields"); + } } else { err.span_suggestion( call_span, @@ -1642,6 +1644,17 @@ fn followed_by_brace(&self, span: Span) -> (bool, Option) { } } + fn has_tuple_fields(&mut self, def_id: DefId) -> bool { + // As we cannot name a field "0", this is an indictation + // that we are looking at a tuple struct + if let Some(fields) = self.r.field_idents(def_id) { + if let Some(first_field) = fields.get(0) { + return first_field.name.as_str() == "0"; + } + } + false + } + fn update_err_for_private_tuple_struct_fields( &mut self, err: &mut Diag<'_>, @@ -1664,17 +1677,18 @@ fn update_err_for_private_tuple_struct_fields( span: call_span, .. })) => { - err.primary_message( - "cannot initialize a tuple struct which contains private fields", - ); - self.suggest_alternative_construction_methods( - def_id, - err, - path.span, - *call_span, - &args[..], - ); - // Use spans of the tuple struct definition. + if self.has_tuple_fields(def_id) { + err.primary_message( + "cannot initialize a tuple struct which contains private fields", + ); + self.suggest_alternative_construction_methods( + def_id, + err, + path.span, + *call_span, + &args[..], + ); + } self.r .field_idents(def_id) .map(|fields| fields.iter().map(|f| f.span).collect::>()) diff --git a/tests/ui/resolve/regression-struct-called-as-function-148919.rs b/tests/ui/resolve/regression-struct-called-as-function-148919.rs new file mode 100644 index 000000000000..7358e1716c11 --- /dev/null +++ b/tests/ui/resolve/regression-struct-called-as-function-148919.rs @@ -0,0 +1,10 @@ +struct Bar {} + +impl Bar { + fn into_self(self) -> Bar { + Bar(self) + //~^ ERROR expected function, tuple struct or tuple variant, found struct `Bar` [E0423] + } +} + +fn main() {} diff --git a/tests/ui/resolve/regression-struct-called-as-function-148919.stderr b/tests/ui/resolve/regression-struct-called-as-function-148919.stderr new file mode 100644 index 000000000000..d3e62b3a5a98 --- /dev/null +++ b/tests/ui/resolve/regression-struct-called-as-function-148919.stderr @@ -0,0 +1,9 @@ +error[E0423]: expected function, tuple struct or tuple variant, found struct `Bar` + --> $DIR/regression-struct-called-as-function-148919.rs:5:9 + | +LL | Bar(self) + | ^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0423`. From cdd88963c8234c31db67b5e79fe0da1f7966bfdf Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Tue, 18 Nov 2025 19:07:34 -0500 Subject: [PATCH 078/194] Add test scaffolding for the `remote-test-client` --- Cargo.lock | 66 +++++++++++++++++++ src/bootstrap/src/core/build_steps/test.rs | 37 +++++++++++ .../builder/cli_paths/snapshots/x_test.snap | 4 ++ .../snapshots/x_test_skip_coverage.snap | 4 ++ .../snapshots/x_test_skip_tests.snap | 4 ++ .../snapshots/x_test_skip_tests_etc.snap | 4 ++ src/bootstrap/src/core/builder/mod.rs | 1 + src/tools/remote-test-client/Cargo.toml | 1 + src/tools/remote-test-client/tests/lib.rs | 10 +++ 9 files changed, 131 insertions(+) create mode 100644 src/tools/remote-test-client/tests/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 9dce64ce66ab..cf16428f11b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -229,6 +229,21 @@ dependencies = [ "winnow 0.7.13", ] +[[package]] +name = "assert_cmd" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcbb6924530aa9e0432442af08bbcafdad182db80d2e560da42a6d442535bf85" +dependencies = [ + "anstyle", + "bstr", + "libc", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + [[package]] name = "autocfg" version = "1.5.0" @@ -1151,6 +1166,12 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + [[package]] name = "digest" version = "0.10.7" @@ -2982,6 +3003,33 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "predicates" +version = "3.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" +dependencies = [ + "anstyle", + "difflib", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" + +[[package]] +name = "predicates-tree" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "prettydiff" version = "0.7.0" @@ -3262,6 +3310,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "remote-test-client" version = "0.1.0" +dependencies = [ + "assert_cmd", +] [[package]] name = "remote-test-server" @@ -5458,6 +5509,12 @@ dependencies = [ "windows-sys 0.60.2", ] +[[package]] +name = "termtree" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" + [[package]] name = "test-float-parse" version = "0.1.0" @@ -6076,6 +6133,15 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "wait-timeout" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" +dependencies = [ + "libc", +] + [[package]] name = "walkdir" version = "2.5.0" diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 2332256c1fbd..4fc938d33c6c 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -4003,3 +4003,40 @@ fn run(self, builder: &Builder<'_>) -> Self::Output { dest } } + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct RemoteTestClientTests { + host: TargetSelection, +} + +impl Step for RemoteTestClientTests { + type Output = (); + const IS_HOST: bool = true; + const DEFAULT: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/tools/remote-test-client") + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(Self { host: run.target }); + } + + fn run(self, builder: &Builder<'_>) { + let bootstrap_host = builder.config.host_target; + let compiler = builder.compiler(0, bootstrap_host); + + let cargo = tool::prepare_tool_cargo( + builder, + compiler, + Mode::ToolBootstrap, + bootstrap_host, + Kind::Test, + "src/tools/remote-test-client", + SourceType::InTree, + &[], + ); + + run_cargo_test(cargo, &[], &[], "remote-test-client", bootstrap_host, builder); + } +} 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 index b9cb897a7569..fd18b59a9c6d 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -1,5 +1,6 @@ --- source: src/bootstrap/src/core/builder/cli_paths/tests.rs +assertion_line: 68 expression: test --- [Test] test::Tidy @@ -158,6 +159,9 @@ expression: test - Set({test::src/tools/jsondoclint}) - Set({test::src/tools/replace-version-placeholder}) - Set({test::tidyselftest}) +[Test] test::RemoteTestClientTests + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/remote-test-client}) [Test] test::Linkcheck targets: [x86_64-unknown-linux-gnu] - Set({test::src/tools/linkchecker}) 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 index 04253bba5ef7..171680515476 100644 --- 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 @@ -1,5 +1,6 @@ --- source: src/bootstrap/src/core/builder/cli_paths/tests.rs +assertion_line: 68 expression: test --skip=coverage --- [Test] test::Tidy @@ -157,6 +158,9 @@ expression: test --skip=coverage - Set({test::src/tools/jsondoclint}) - Set({test::src/tools/replace-version-placeholder}) - Set({test::tidyselftest}) +[Test] test::RemoteTestClientTests + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/remote-test-client}) [Test] test::Linkcheck targets: [x86_64-unknown-linux-gnu] - Set({test::src/tools/linkchecker}) 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 index f10589548f66..1468964c7818 100644 --- 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 @@ -1,5 +1,6 @@ --- source: src/bootstrap/src/core/builder/cli_paths/tests.rs +assertion_line: 68 expression: test --skip=tests --- [Test] test::Tidy @@ -121,6 +122,9 @@ expression: test --skip=tests - Set({test::src/tools/jsondoclint}) - Set({test::src/tools/replace-version-placeholder}) - Set({test::tidyselftest}) +[Test] test::RemoteTestClientTests + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/remote-test-client}) [Test] test::Linkcheck targets: [x86_64-unknown-linux-gnu] - Set({test::src/tools/linkchecker}) 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 index 65e05dfaef2d..7ff6a201e77a 100644 --- 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 @@ -1,5 +1,6 @@ --- source: src/bootstrap/src/core/builder/cli_paths/tests.rs +assertion_line: 68 expression: test --skip=tests --skip=coverage-map --skip=coverage-run --skip=library --skip=tidyselftest --- [Test] test::Tidy @@ -100,6 +101,9 @@ expression: test --skip=tests --skip=coverage-map --skip=coverage-run --skip=lib - Set({test::src/tools/coverage-dump}) - Set({test::src/tools/jsondoclint}) - Set({test::src/tools/replace-version-placeholder}) +[Test] test::RemoteTestClientTests + targets: [x86_64-unknown-linux-gnu] + - Set({test::src/tools/remote-test-client}) [Test] test::Linkcheck targets: [x86_64-unknown-linux-gnu] - Set({test::src/tools/linkchecker}) diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 9124442e7f37..c326fe27d2c8 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -904,6 +904,7 @@ macro_rules! describe { test::CrateRustdoc, test::CrateRustdocJsonTypes, test::CrateBootstrap, + test::RemoteTestClientTests, test::Linkcheck, test::TierCheck, test::Cargotest, diff --git a/src/tools/remote-test-client/Cargo.toml b/src/tools/remote-test-client/Cargo.toml index d59cd6b3d8e2..6fe690ba2038 100644 --- a/src/tools/remote-test-client/Cargo.toml +++ b/src/tools/remote-test-client/Cargo.toml @@ -4,3 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] +assert_cmd = "2" diff --git a/src/tools/remote-test-client/tests/lib.rs b/src/tools/remote-test-client/tests/lib.rs new file mode 100644 index 000000000000..663afbfb6c7d --- /dev/null +++ b/src/tools/remote-test-client/tests/lib.rs @@ -0,0 +1,10 @@ +#[test] +fn test_help() { + let mut cmd = assert_cmd::cargo::cargo_bin_cmd!(); + cmd.arg("help"); + + let output = cmd.unwrap(); + + let stdout = String::from_utf8(output.stdout.clone()).unwrap(); + assert!(stdout.trim().starts_with("Usage:")); +} From 9e497b6071efce3cf22296576f71b7296b0817cc Mon Sep 17 00:00:00 2001 From: Zachary S Date: Fri, 15 Nov 2024 00:47:22 -0600 Subject: [PATCH 079/194] Add Box::(try_)clone_from_ref(_in) --- library/alloc/src/boxed.rs | 123 +++++++++++++++++- library/std/src/lib.rs | 1 + tests/ui/privacy/suggest-box-new.stderr | 6 +- .../suggestions/multi-suggestion.ascii.stderr | 4 +- .../multi-suggestion.unicode.stderr | 4 +- 5 files changed, 130 insertions(+), 8 deletions(-) diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 2b767ffe02be..f714a87c1868 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -184,7 +184,6 @@ #![stable(feature = "rust1", since = "1.0.0")] use core::borrow::{Borrow, BorrowMut}; -#[cfg(not(no_global_oom_handling))] use core::clone::CloneToUninit; use core::cmp::Ordering; use core::error::{self, Error}; @@ -733,6 +732,128 @@ pub fn take(boxed: Self) -> (T, Box, A>) { } } +impl Box { + /// Allocates memory on the heap then clones `src` into it. + /// + /// This doesn't actually allocate if `src` is zero-sized. + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// + /// let hello: Box = Box::clone_from_ref("hello"); + /// ``` + #[cfg(not(no_global_oom_handling))] + #[unstable(feature = "clone_from_ref", issue = "149075")] + #[must_use] + #[inline] + pub fn clone_from_ref(src: &T) -> Box { + Box::clone_from_ref_in(src, Global) + } + + /// Allocates memory on the heap then clones `src` into it, returning an error if allocation fails. + /// + /// This doesn't actually allocate if `src` is zero-sized. + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// #![feature(allocator_api)] + /// + /// let hello: Box = Box::try_clone_from_ref("hello")?; + /// # Ok::<(), std::alloc::AllocError>(()) + /// ``` + #[unstable(feature = "clone_from_ref", issue = "149075")] + //#[unstable(feature = "allocator_api", issue = "32838")] + #[must_use] + #[inline] + pub fn try_clone_from_ref(src: &T) -> Result, AllocError> { + Box::try_clone_from_ref_in(src, Global) + } +} + +impl Box { + /// Allocates memory in the given allocator then clones `src` into it. + /// + /// This doesn't actually allocate if `src` is zero-sized. + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// #![feature(allocator_api)] + /// + /// use std::alloc::System; + /// + /// let hello: Box = Box::clone_from_ref_in("hello", System); + /// ``` + #[cfg(not(no_global_oom_handling))] + #[unstable(feature = "clone_from_ref", issue = "149075")] + //#[unstable(feature = "allocator_api", issue = "32838")] + #[must_use] + #[inline] + pub fn clone_from_ref_in(src: &T, alloc: A) -> Box { + let layout = Layout::for_value::(src); + match Box::try_clone_from_ref_in(src, alloc) { + Ok(bx) => bx, + Err(_) => handle_alloc_error(layout), + } + } + + /// Allocates memory in the given allocator then clones `src` into it, returning an error if allocation fails. + /// + /// This doesn't actually allocate if `src` is zero-sized. + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// #![feature(allocator_api)] + /// + /// use std::alloc::System; + /// + /// let hello: Box = Box::try_clone_from_ref_in("hello", System)?; + /// # Ok::<(), std::alloc::AllocError>(()) + /// ``` + #[unstable(feature = "clone_from_ref", issue = "149075")] + //#[unstable(feature = "allocator_api", issue = "32838")] + #[must_use] + #[inline] + pub fn try_clone_from_ref_in(src: &T, alloc: A) -> Result, AllocError> { + struct DeallocDropGuard<'a, A: Allocator>(Layout, &'a A, NonNull); + impl<'a, A: Allocator> Drop for DeallocDropGuard<'a, A> { + fn drop(&mut self) { + let &mut DeallocDropGuard(layout, alloc, ptr) = self; + // Safety: `ptr` was allocated by `*alloc` with layout `layout` + unsafe { + alloc.deallocate(ptr, layout); + } + } + } + let layout = Layout::for_value::(src); + let (ptr, guard) = if layout.size() == 0 { + (layout.dangling(), None) + } else { + // Safety: layout is non-zero-sized + let ptr = alloc.allocate(layout)?.cast(); + (ptr, Some(DeallocDropGuard(layout, &alloc, ptr))) + }; + let ptr = ptr.as_ptr(); + // Safety: `*ptr` is newly allocated, correctly aligned to `align_of_val(src)`, + // and is valid for writes for `size_of_val(src)`. + // If this panics, then `guard` will deallocate for us (if allocation occuured) + unsafe { + ::clone_to_uninit(src, ptr); + } + // Defuse the deallocate guard + core::mem::forget(guard); + // Safety: We just initialized `*ptr` as a clone of `src` + Ok(unsafe { Box::from_raw_in(ptr.with_metadata_of(src), alloc) }) + } +} + impl Box<[T]> { /// Constructs a new boxed slice with uninitialized contents. /// diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 07618550a9cb..32f166e112e9 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -374,6 +374,7 @@ // tidy-alphabetical-start #![feature(alloc_layout_extra)] #![feature(allocator_api)] +#![feature(clone_from_ref)] #![feature(get_mut_unchecked)] #![feature(map_try_insert)] #![feature(slice_concat_trait)] diff --git a/tests/ui/privacy/suggest-box-new.stderr b/tests/ui/privacy/suggest-box-new.stderr index 7df293e1e1d9..566f31fc305e 100644 --- a/tests/ui/privacy/suggest-box-new.stderr +++ b/tests/ui/privacy/suggest-box-new.stderr @@ -63,7 +63,7 @@ LL - x: (), LL - })), LL + wtf: Some(Box::new_in(_, _)), | - = and 13 other candidates + = and 15 other candidates help: consider using the `Default` trait | LL - wtf: Some(Box(U { @@ -118,7 +118,7 @@ LL + let _ = Box::new_zeroed(); LL - let _ = Box {}; LL + let _ = Box::new_in(_, _); | - = and 14 other candidates + = and 16 other candidates help: consider using the `Default` trait | LL - let _ = Box {}; @@ -146,7 +146,7 @@ LL + let _ = Box::::map(_, _); LL - let _ = Box:: {}; LL + let _ = Box::::into_inner(_); | - = and 5 other candidates + = and 7 other candidates help: consider using the `Default` trait | LL - let _ = Box:: {}; diff --git a/tests/ui/suggestions/multi-suggestion.ascii.stderr b/tests/ui/suggestions/multi-suggestion.ascii.stderr index 4bd6c19e0829..bb14eb2fb572 100644 --- a/tests/ui/suggestions/multi-suggestion.ascii.stderr +++ b/tests/ui/suggestions/multi-suggestion.ascii.stderr @@ -63,7 +63,7 @@ LL - x: (), LL - })), LL + wtf: Some(Box::new_in(_, _)), | - = and 13 other candidates + = and 15 other candidates help: consider using the `Default` trait | LL - wtf: Some(Box(U { @@ -118,7 +118,7 @@ LL + let _ = Box::new_zeroed(); LL - let _ = Box {}; LL + let _ = Box::new_in(_, _); | - = and 14 other candidates + = and 16 other candidates help: consider using the `Default` trait | LL - let _ = Box {}; diff --git a/tests/ui/suggestions/multi-suggestion.unicode.stderr b/tests/ui/suggestions/multi-suggestion.unicode.stderr index b11570f34161..e7f9e7153d19 100644 --- a/tests/ui/suggestions/multi-suggestion.unicode.stderr +++ b/tests/ui/suggestions/multi-suggestion.unicode.stderr @@ -63,7 +63,7 @@ LL - x: (), LL - })), LL + wtf: Some(Box::new_in(_, _)), │ - ╰ and 13 other candidates + ╰ and 15 other candidates help: consider using the `Default` trait ╭╴ LL - wtf: Some(Box(U { @@ -118,7 +118,7 @@ LL + let _ = Box::new_zeroed(); LL - let _ = Box {}; LL + let _ = Box::new_in(_, _); │ - ╰ and 14 other candidates + ╰ and 16 other candidates help: consider using the `Default` trait ╭╴ LL - let _ = Box {}; From 316d54a5bde8b72c663c630f1c343de27232cd18 Mon Sep 17 00:00:00 2001 From: Zachary S Date: Fri, 15 Nov 2024 02:01:01 -0600 Subject: [PATCH 080/194] Implement some conversions using Box::clone_from_ref --- library/alloc/src/boxed/convert.rs | 43 +++-------------------------- library/alloc/src/ffi/c_str.rs | 3 +- library/std/src/ffi/os_str.rs | 3 +- library/std/src/path.rs | 4 +-- library/std/src/sys/os_str/bytes.rs | 6 ---- library/std/src/sys/os_str/wtf8.rs | 5 ---- 6 files changed, 7 insertions(+), 57 deletions(-) diff --git a/library/alloc/src/boxed/convert.rs b/library/alloc/src/boxed/convert.rs index 73940db5d2f5..d6a8e78991b8 100644 --- a/library/alloc/src/boxed/convert.rs +++ b/library/alloc/src/boxed/convert.rs @@ -1,21 +1,15 @@ use core::any::Any; -#[cfg(not(no_global_oom_handling))] -use core::clone::TrivialClone; use core::error::Error; +#[cfg(not(no_global_oom_handling))] +use core::fmt; use core::mem; use core::pin::Pin; -#[cfg(not(no_global_oom_handling))] -use core::{fmt, ptr}; use crate::alloc::Allocator; #[cfg(not(no_global_oom_handling))] use crate::borrow::Cow; use crate::boxed::Box; #[cfg(not(no_global_oom_handling))] -use crate::raw_vec::RawVec; -#[cfg(not(no_global_oom_handling))] -use crate::str::from_boxed_utf8_unchecked; -#[cfg(not(no_global_oom_handling))] use crate::string::String; #[cfg(not(no_global_oom_handling))] use crate::vec::Vec; @@ -62,35 +56,6 @@ fn from(boxed: Box) -> Self { } } -/// Specialization trait used for `From<&[T]>`. -#[cfg(not(no_global_oom_handling))] -trait BoxFromSlice { - fn from_slice(slice: &[T]) -> Self; -} - -#[cfg(not(no_global_oom_handling))] -impl BoxFromSlice for Box<[T]> { - #[inline] - default fn from_slice(slice: &[T]) -> Self { - slice.to_vec().into_boxed_slice() - } -} - -#[cfg(not(no_global_oom_handling))] -impl BoxFromSlice for Box<[T]> { - #[inline] - fn from_slice(slice: &[T]) -> Self { - let len = slice.len(); - let buf = RawVec::with_capacity(len); - // SAFETY: since `T` implements `TrivialClone`, this is sound and - // equivalent to the above. - unsafe { - ptr::copy_nonoverlapping(slice.as_ptr(), buf.ptr(), len); - buf.into_box(slice.len()).assume_init() - } - } -} - #[cfg(not(no_global_oom_handling))] #[stable(feature = "box_from_slice", since = "1.17.0")] impl From<&[T]> for Box<[T]> { @@ -109,7 +74,7 @@ impl From<&[T]> for Box<[T]> { /// ``` #[inline] fn from(slice: &[T]) -> Box<[T]> { - >::from_slice(slice) + Box::clone_from_ref(slice) } } @@ -170,7 +135,7 @@ impl From<&str> for Box { /// ``` #[inline] fn from(s: &str) -> Box { - unsafe { from_boxed_utf8_unchecked(Box::from(s.as_bytes())) } + Box::clone_from_ref(s) } } diff --git a/library/alloc/src/ffi/c_str.rs b/library/alloc/src/ffi/c_str.rs index 3e78d680ea68..59f5857b97aa 100644 --- a/library/alloc/src/ffi/c_str.rs +++ b/library/alloc/src/ffi/c_str.rs @@ -766,8 +766,7 @@ impl From<&CStr> for Box { /// Converts a `&CStr` into a `Box`, /// by copying the contents into a newly allocated [`Box`]. fn from(s: &CStr) -> Box { - let boxed: Box<[u8]> = Box::from(s.to_bytes_with_nul()); - unsafe { Box::from_raw(Box::into_raw(boxed) as *mut CStr) } + Box::clone_from_ref(s) } } diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 09bd911aa769..a1dd8e5f86f4 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -1285,8 +1285,7 @@ impl From<&OsStr> for Box { /// Copies the string into a newly allocated [Box]<[OsStr]>. #[inline] fn from(s: &OsStr) -> Box { - let rw = Box::into_raw(s.inner.into_box()) as *mut OsStr; - unsafe { Box::from_raw(rw) } + Box::clone_from_ref(s) } } diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 114fcc796c52..2a57a1ed5960 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1877,9 +1877,7 @@ impl From<&Path> for Box { /// /// This will allocate and clone `path` to it. fn from(path: &Path) -> Box { - let boxed: Box = path.inner.into(); - let rw = Box::into_raw(boxed) as *mut Path; - unsafe { Box::from_raw(rw) } + Box::clone_from_ref(path) } } diff --git a/library/std/src/sys/os_str/bytes.rs b/library/std/src/sys/os_str/bytes.rs index 9373982c455f..258279bd4a60 100644 --- a/library/std/src/sys/os_str/bytes.rs +++ b/library/std/src/sys/os_str/bytes.rs @@ -321,12 +321,6 @@ pub fn clone_into(&self, buf: &mut Buf) { self.inner.clone_into(&mut buf.inner) } - #[inline] - pub fn into_box(&self) -> Box { - let boxed: Box<[u8]> = self.inner.into(); - unsafe { mem::transmute(boxed) } - } - #[inline] pub fn empty_box() -> Box { let boxed: Box<[u8]> = Default::default(); diff --git a/library/std/src/sys/os_str/wtf8.rs b/library/std/src/sys/os_str/wtf8.rs index 208755cd5b9c..5050fd279433 100644 --- a/library/std/src/sys/os_str/wtf8.rs +++ b/library/std/src/sys/os_str/wtf8.rs @@ -271,11 +271,6 @@ pub fn clone_into(&self, buf: &mut Buf) { self.inner.clone_into(&mut buf.inner) } - #[inline] - pub fn into_box(&self) -> Box { - unsafe { mem::transmute(self.inner.into_box()) } - } - #[inline] pub fn empty_box() -> Box { unsafe { mem::transmute(Wtf8::empty_box()) } From 8c569c141615351d1d9f3dfb33258e7e31610579 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Wed, 19 Nov 2025 19:28:15 +0000 Subject: [PATCH 081/194] run-make-support: re-export rustdoc_json_types This is useful for allowing writing run-make tests that test rustdoc-json. --- Cargo.lock | 1 + src/tools/run-make-support/Cargo.toml | 2 ++ src/tools/run-make-support/src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 9dce64ce66ab..35d1cea30d22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3285,6 +3285,7 @@ dependencies = [ "libc", "object 0.37.3", "regex", + "rustdoc-json-types", "serde_json", "similar", "wasmparser 0.236.1", diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml index 250e0f65a9f4..9d9cd656f570 100644 --- a/src/tools/run-make-support/Cargo.toml +++ b/src/tools/run-make-support/Cargo.toml @@ -22,6 +22,8 @@ wasmparser = { version = "0.236", default-features = false, features = ["std", " # Shared with bootstrap and compiletest build_helper = { path = "../../build_helper" } +# Shared with rustdoc +rustdoc-json-types = { path = "../../rustdoc-json-types" } [lib] crate-type = ["lib", "dylib"] diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index fef75401d945..5253dc04a93e 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -34,7 +34,7 @@ pub mod rfs { } // Re-exports of third-party library crates. -pub use {bstr, gimli, libc, object, regex, serde_json, similar, wasmparser}; +pub use {bstr, gimli, libc, object, regex, rustdoc_json_types, serde_json, similar, wasmparser}; // Helpers for building names of output artifacts that are potentially target-specific. pub use crate::artifact_names::{ From cfb859eb4a69ca13e017bba4afbd91835993aba6 Mon Sep 17 00:00:00 2001 From: Zachary S Date: Fri, 15 Nov 2024 02:01:22 -0600 Subject: [PATCH 082/194] Add Rc::(try_)clone_from_ref(_in) --- library/alloc/src/rc.rs | 120 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 5 deletions(-) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 0ab019a68ea0..c0517afec64b 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -243,9 +243,9 @@ use core::any::Any; use core::cell::{Cell, CloneFromCell}; -use core::clone::UseCloned; #[cfg(not(no_global_oom_handling))] -use core::clone::{CloneToUninit, TrivialClone}; +use core::clone::TrivialClone; +use core::clone::{CloneToUninit, UseCloned}; use core::cmp::Ordering; use core::hash::{Hash, Hasher}; use core::intrinsics::abort; @@ -1290,6 +1290,104 @@ pub unsafe fn assume_init(self) -> Rc { } } +impl Rc { + /// Constructs a new `Rc` with a clone of `value`. + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// use std::rc::Rc; + /// + /// let hello: Rc = Rc::clone_from_ref("hello"); + /// ``` + #[cfg(not(no_global_oom_handling))] + #[unstable(feature = "clone_from_ref", issue = "149075")] + pub fn clone_from_ref(value: &T) -> Rc { + Rc::clone_from_ref_in(value, Global) + } + + /// Constructs a new `Rc` with a clone of `value`, returning an error if allocation fails + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// #![feature(allocator_api)] + /// use std::rc::Rc; + /// + /// let hello: Rc = Rc::try_clone_from_ref("hello")?; + /// # Ok::<(), std::alloc::AllocError>(()) + /// ``` + #[unstable(feature = "clone_from_ref", issue = "149075")] + //#[unstable(feature = "allocator_api", issue = "32838")] + pub fn try_clone_from_ref(value: &T) -> Result, AllocError> { + Rc::try_clone_from_ref_in(value, Global) + } +} + +impl Rc { + /// Constructs a new `Rc` with a clone of `value` in the provided allocator. + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// #![feature(allocator_api)] + /// use std::rc::Rc; + /// use std::alloc::System; + /// + /// let hello: Rc = Rc::clone_from_ref_in("hello", System); + /// ``` + #[cfg(not(no_global_oom_handling))] + #[unstable(feature = "clone_from_ref", issue = "149075")] + //#[unstable(feature = "allocator_api", issue = "32838")] + pub fn clone_from_ref_in(value: &T, alloc: A) -> Rc { + // `in_progress` drops the allocation if we panic before finishing initializing it. + let mut in_progress: UniqueRcUninit = UniqueRcUninit::new(value, alloc); + + // Initialize with clone of value. + let initialized_clone = unsafe { + // Clone. If the clone panics, `in_progress` will be dropped and clean up. + value.clone_to_uninit(in_progress.data_ptr().cast()); + // Cast type of pointer, now that it is initialized. + in_progress.into_rc() + }; + + initialized_clone + } + + /// Constructs a new `Rc` with a clone of `value` in the provided allocator, returning an error if allocation fails + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// #![feature(allocator_api)] + /// use std::rc::Rc; + /// use std::alloc::System; + /// + /// let hello: Rc = Rc::try_clone_from_ref_in("hello", System)?; + /// # Ok::<(), std::alloc::AllocError>(()) + /// ``` + #[unstable(feature = "clone_from_ref", issue = "149075")] + //#[unstable(feature = "allocator_api", issue = "32838")] + pub fn try_clone_from_ref_in(value: &T, alloc: A) -> Result, AllocError> { + // `in_progress` drops the allocation if we panic before finishing initializing it. + let mut in_progress: UniqueRcUninit = UniqueRcUninit::try_new(value, alloc)?; + + // Initialize with clone of value. + let initialized_clone = unsafe { + // Clone. If the clone panics, `in_progress` will be dropped and clean up. + value.clone_to_uninit(in_progress.data_ptr().cast()); + // Cast type of pointer, now that it is initialized. + in_progress.into_rc() + }; + + Ok(initialized_clone) + } +} + impl Rc<[mem::MaybeUninit], A> { /// Converts to `Rc<[T]>`. /// @@ -4358,16 +4456,15 @@ fn drop(&mut self) { /// This is a helper for [`Rc::make_mut()`] to ensure correct cleanup on panic. /// It is nearly a duplicate of `UniqueRc, A>` except that it allows `T: !Sized`, /// which `MaybeUninit` does not. -#[cfg(not(no_global_oom_handling))] struct UniqueRcUninit { ptr: NonNull>, layout_for_value: Layout, alloc: Option, } -#[cfg(not(no_global_oom_handling))] impl UniqueRcUninit { /// Allocates a RcInner with layout suitable to contain `for_value` or a clone of it. + #[cfg(not(no_global_oom_handling))] fn new(for_value: &T, alloc: A) -> UniqueRcUninit { let layout = Layout::for_value(for_value); let ptr = unsafe { @@ -4380,6 +4477,20 @@ fn new(for_value: &T, alloc: A) -> UniqueRcUninit { Self { ptr: NonNull::new(ptr).unwrap(), layout_for_value: layout, alloc: Some(alloc) } } + /// Allocates a RcInner with layout suitable to contain `for_value` or a clone of it, + /// returning an error if allocation fails. + fn try_new(for_value: &T, alloc: A) -> Result, AllocError> { + let layout = Layout::for_value(for_value); + let ptr = unsafe { + Rc::try_allocate_for_layout( + layout, + |layout_for_rc_inner| alloc.allocate(layout_for_rc_inner), + |mem| mem.with_metadata_of(ptr::from_ref(for_value) as *const RcInner), + )? + }; + Ok(Self { ptr: NonNull::new(ptr).unwrap(), layout_for_value: layout, alloc: Some(alloc) }) + } + /// Returns the pointer to be written into to initialize the [`Rc`]. fn data_ptr(&mut self) -> *mut T { let offset = data_offset_align(self.layout_for_value.align()); @@ -4402,7 +4513,6 @@ unsafe fn into_rc(self) -> Rc { } } -#[cfg(not(no_global_oom_handling))] impl Drop for UniqueRcUninit { fn drop(&mut self) { // SAFETY: From 7a7142c93b5e27114319b67160b3b42914a149fb Mon Sep 17 00:00:00 2001 From: Zachary S Date: Tue, 18 Nov 2025 19:54:23 -0600 Subject: [PATCH 083/194] Implelement the clone part of Rc::make_mut using Rc::clone_from_ref_in --- library/alloc/src/rc.rs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index c0517afec64b..a3ebbbbaae05 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -2067,22 +2067,7 @@ pub fn make_mut(this: &mut Self) -> &mut T { if Rc::strong_count(this) != 1 { // Gotta clone the data, there are other Rcs. - - let this_data_ref: &T = &**this; - // `in_progress` drops the allocation if we panic before finishing initializing it. - let mut in_progress: UniqueRcUninit = - UniqueRcUninit::new(this_data_ref, this.alloc.clone()); - - // Initialize with clone of this. - let initialized_clone = unsafe { - // Clone. If the clone panics, `in_progress` will be dropped and clean up. - this_data_ref.clone_to_uninit(in_progress.data_ptr().cast()); - // Cast type of pointer, now that it is initialized. - in_progress.into_rc() - }; - - // Replace `this` with newly constructed Rc. - *this = initialized_clone; + *this = Rc::clone_from_ref_in(&**this, this.alloc.clone()); } else if Rc::weak_count(this) != 0 { // Can just steal the data, all that's left is Weaks From e7b84604cbebc3c5228fb444087015fe0ed66a68 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Wed, 29 Oct 2025 17:07:54 +0000 Subject: [PATCH 084/194] rustc_public: Make Id types !Send / !Sync These types are Id's to a table stored in TLS, so using them from another tread will either panic, or give wrong results. Therefor, I've added a `ThreadLocalIndex` marker type, which ensures types arn't `Send`/`Sync`. This is a breaking change for users of the `rustc_public` crate. Zulip Discussion: https://rust-lang.zulipchat.com/#narrow/channel/320896-project-stable-mir/topic/WDYM.20.22should.20not.20.20be.20shared.20across.20threads.22/with/547374171 --- Cargo.lock | 1 + compiler/rustc_public/Cargo.toml | 7 ++- compiler/rustc_public/src/abi.rs | 18 ++---- .../rustc_public/src/compiler_interface.rs | 4 +- compiler/rustc_public/src/crate_def.rs | 11 ++-- compiler/rustc_public/src/lib.rs | 44 +++++++++---- compiler/rustc_public/src/mir/alloc.rs | 18 ++---- compiler/rustc_public/src/mir/mono.rs | 18 ++---- .../rustc_public/src/rustc_internal/mod.rs | 2 +- compiler/rustc_public/src/tests.rs | 63 +++++++++++++++++++ compiler/rustc_public/src/ty.rs | 39 ++++++++---- .../src/unstable/convert/internal.rs | 2 +- 12 files changed, 153 insertions(+), 74 deletions(-) create mode 100644 compiler/rustc_public/src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index 5e9ba9b43279..6f43b9b798eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4440,6 +4440,7 @@ dependencies = [ "rustc_target", "scoped-tls", "serde", + "serde_json", "tracing", ] diff --git a/compiler/rustc_public/Cargo.toml b/compiler/rustc_public/Cargo.toml index 70af30c1a5f4..c2b00b515adc 100644 --- a/compiler/rustc_public/Cargo.toml +++ b/compiler/rustc_public/Cargo.toml @@ -13,10 +13,15 @@ rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } scoped-tls = "1.0" -serde = { version = "1.0.125", features = [ "derive" ] } +serde = { version = "1.0.125", features = ["derive"] } tracing = "0.1" # tidy-alphabetical-end +[dev-dependencies] +# tidy-alphabetical-start +serde_json = "1.0.142" +# tidy-alphabetical-end + [features] # tidy-alphabetical-start # Provides access to APIs that expose internals of the rust compiler. diff --git a/compiler/rustc_public/src/abi.rs b/compiler/rustc_public/src/abi.rs index 7b0882caf1b3..820c41acf5b2 100644 --- a/compiler/rustc_public/src/abi.rs +++ b/compiler/rustc_public/src/abi.rs @@ -7,8 +7,8 @@ use crate::compiler_interface::with; use crate::mir::FieldIdx; use crate::target::{MachineInfo, MachineSize as Size}; -use crate::ty::{Align, Ty, VariantIdx}; -use crate::{Error, Opaque, error}; +use crate::ty::{Align, Ty, VariantIdx, index_impl}; +use crate::{Error, Opaque, ThreadLocalIndex, error}; /// A function ABI definition. #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)] @@ -109,8 +109,9 @@ pub fn is_1zst(&self) -> bool { } } -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize)] -pub struct Layout(usize); +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +pub struct Layout(usize, ThreadLocalIndex); +index_impl!(Layout); impl Layout { pub fn shape(self) -> LayoutShape { @@ -118,15 +119,6 @@ pub fn shape(self) -> LayoutShape { } } -impl crate::IndexedVal for Layout { - fn to_val(index: usize) -> Self { - Layout(index) - } - fn to_index(&self) -> usize { - self.0 - } -} - /// Describes how the fields of a type are shaped in memory. #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)] pub enum FieldsShape { diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index 5a09c3b24f0f..2af66fcaa5a4 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -25,7 +25,7 @@ use crate::unstable::{RustcInternal, Stable, new_item_kind}; use crate::{ AssocItems, Crate, CrateDef, CrateItem, CrateItems, CrateNum, DefId, Error, Filename, - ImplTraitDecls, ItemKind, Symbol, TraitDecls, alloc, mir, + ImplTraitDecls, ItemKind, Symbol, ThreadLocalIndex, TraitDecls, alloc, mir, }; pub struct BridgeTys; @@ -1093,7 +1093,7 @@ fn smir_crate<'tcx>( ) -> Crate { let name = cx.crate_name(crate_num); let is_local = cx.crate_is_local(crate_num); - let id = cx.crate_num_id(crate_num); + let id = CrateNum(cx.crate_num_id(crate_num), ThreadLocalIndex); debug!(?name, ?crate_num, "smir_crate"); Crate { id, name, is_local } } diff --git a/compiler/rustc_public/src/crate_def.rs b/compiler/rustc_public/src/crate_def.rs index 75228135e4cb..95a7908b19bd 100644 --- a/compiler/rustc_public/src/crate_def.rs +++ b/compiler/rustc_public/src/crate_def.rs @@ -1,14 +1,13 @@ //! Module that define a common trait for things that represent a crate definition, //! such as, a function, a trait, an enum, and any other definitions. -use serde::Serialize; - -use crate::ty::{GenericArgs, Span, Ty}; -use crate::{AssocItems, Crate, Symbol, with}; +use crate::ty::{GenericArgs, Span, Ty, index_impl}; +use crate::{AssocItems, Crate, Symbol, ThreadLocalIndex, with}; /// A unique identification number for each item accessible for the current compilation unit. -#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize)] -pub struct DefId(pub(crate) usize); +#[derive(Clone, Copy, PartialEq, Eq, Hash)] +pub struct DefId(pub(crate) usize, ThreadLocalIndex); +index_impl!(DefId); impl DefId { /// Return fully qualified name of this definition diff --git a/compiler/rustc_public/src/lib.rs b/compiler/rustc_public/src/lib.rs index 958b3b264788..9d64553b7a66 100644 --- a/compiler/rustc_public/src/lib.rs +++ b/compiler/rustc_public/src/lib.rs @@ -20,6 +20,7 @@ //! [crates.io](https://crates.io). use std::fmt::Debug; +use std::marker::PhantomData; use std::{fmt, io}; pub(crate) use rustc_public_bridge::IndexedVal; @@ -36,7 +37,10 @@ pub use crate::error::*; use crate::mir::mono::StaticDef; use crate::mir::{Body, Mutability}; -use crate::ty::{AssocItem, FnDef, ForeignModuleDef, ImplDef, ProvenanceMap, Span, TraitDef, Ty}; +use crate::ty::{ + AssocItem, FnDef, ForeignModuleDef, ImplDef, ProvenanceMap, Span, TraitDef, Ty, + serialize_index_impl, +}; use crate::unstable::Stable; pub mod abi; @@ -49,6 +53,8 @@ pub mod error; pub mod mir; pub mod target; +#[cfg(test)] +mod tests; pub mod ty; pub mod visitor; @@ -56,7 +62,9 @@ pub type Symbol = String; /// The number that identifies a crate. -pub type CrateNum = usize; +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct CrateNum(pub(crate) usize, ThreadLocalIndex); +serialize_index_impl!(CrateNum); impl Debug for DefId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -64,16 +72,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { } } -impl IndexedVal for DefId { - fn to_val(index: usize) -> Self { - DefId(index) - } - - fn to_index(&self) -> usize { - self.0 - } -} - /// A list of crate items. pub type CrateItems = Vec; @@ -300,3 +298,25 @@ fn new<'tcx>( } } } + +#[derive(Clone, Copy, Hash, PartialEq, Eq, Default)] +/// Marker type for indexes into thread local structures. +/// +/// Makes things `!Send`/`!Sync`, so users don't move `rustc_public` types to +/// thread with no (or worse, different) `rustc_public` pointer. +/// +/// Note. This doesn't make it impossible to confuse TLS. You could return a +/// `DefId` from one `run!` invocation, and then use it inside a different +/// `run!` invocation with different tables. +pub(crate) struct ThreadLocalIndex { + _phantom: PhantomData<*const ()>, +} +#[expect(non_upper_case_globals)] +/// Emulating unit struct `struct ThreadLocalIndex`; +pub(crate) const ThreadLocalIndex: ThreadLocalIndex = ThreadLocalIndex { _phantom: PhantomData }; + +impl fmt::Debug for ThreadLocalIndex { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("ThreadLocalIndex").finish() + } +} diff --git a/compiler/rustc_public/src/mir/alloc.rs b/compiler/rustc_public/src/mir/alloc.rs index 07a979f3811e..b267e3612d80 100644 --- a/compiler/rustc_public/src/mir/alloc.rs +++ b/compiler/rustc_public/src/mir/alloc.rs @@ -6,8 +6,8 @@ use crate::mir::mono::{Instance, StaticDef}; use crate::target::{Endian, MachineInfo}; -use crate::ty::{Allocation, Binder, ExistentialTraitRef, Ty}; -use crate::{Error, IndexedVal, with}; +use crate::ty::{Allocation, Binder, ExistentialTraitRef, Ty, index_impl}; +use crate::{Error, ThreadLocalIndex, with}; /// An allocation in the rustc_public's IR global memory can be either a function pointer, /// a static, or a "real" allocation with some data in it. @@ -47,17 +47,9 @@ pub fn vtable_allocation(&self) -> Option { } /// A unique identification number for each provenance -#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Serialize)] -pub struct AllocId(usize); - -impl IndexedVal for AllocId { - fn to_val(index: usize) -> Self { - AllocId(index) - } - fn to_index(&self) -> usize { - self.0 - } -} +#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] +pub struct AllocId(usize, ThreadLocalIndex); +index_impl!(AllocId); /// Utility function used to read an allocation data into a unassigned integer. pub(crate) fn read_target_uint(mut bytes: &[u8]) -> Result { diff --git a/compiler/rustc_public/src/mir/mono.rs b/compiler/rustc_public/src/mir/mono.rs index d488f5a25c7d..ab939a553514 100644 --- a/compiler/rustc_public/src/mir/mono.rs +++ b/compiler/rustc_public/src/mir/mono.rs @@ -7,8 +7,8 @@ use crate::abi::FnAbi; use crate::crate_def::CrateDef; use crate::mir::Body; -use crate::ty::{Allocation, ClosureDef, ClosureKind, FnDef, GenericArgs, Ty}; -use crate::{CrateItem, DefId, Error, IndexedVal, ItemKind, Opaque, Symbol, with}; +use crate::ty::{Allocation, ClosureDef, ClosureKind, FnDef, GenericArgs, Ty, index_impl}; +use crate::{CrateItem, DefId, Error, ItemKind, Opaque, Symbol, ThreadLocalIndex, with}; #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)] pub enum MonoItem { @@ -241,8 +241,9 @@ fn from(value: StaticDef) -> Self { } } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize)] -pub struct InstanceDef(usize); +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub struct InstanceDef(usize, ThreadLocalIndex); +index_impl!(InstanceDef); impl CrateDef for InstanceDef { fn def_id(&self) -> DefId { @@ -294,12 +295,3 @@ pub fn eval_initializer(&self) -> Result { with(|cx| cx.eval_static_initializer(*self)) } } - -impl IndexedVal for InstanceDef { - fn to_val(index: usize) -> Self { - InstanceDef(index) - } - fn to_index(&self) -> usize { - self.0 - } -} diff --git a/compiler/rustc_public/src/rustc_internal/mod.rs b/compiler/rustc_public/src/rustc_internal/mod.rs index 225c811ab3a5..dc8afb89d949 100644 --- a/compiler/rustc_public/src/rustc_internal/mod.rs +++ b/compiler/rustc_public/src/rustc_internal/mod.rs @@ -53,7 +53,7 @@ pub fn internal<'tcx, S>(tcx: TyCtxt<'tcx>, item: S) -> S::T<'tcx> } pub fn crate_num(item: &crate::Crate) -> CrateNum { - item.id.into() + item.id.0.into() } // A thread local variable that stores a pointer to the tables mapping between TyCtxt diff --git a/compiler/rustc_public/src/tests.rs b/compiler/rustc_public/src/tests.rs new file mode 100644 index 000000000000..9c3f956c37df --- /dev/null +++ b/compiler/rustc_public/src/tests.rs @@ -0,0 +1,63 @@ +use rustc_public_bridge::IndexedVal; + +use crate::abi::Layout; +use crate::mir::alloc::AllocId; +use crate::mir::mono::InstanceDef; +use crate::ty::{MirConstId, TyConstId, VariantIdx}; +use crate::{CrateNum, DefId, Span, ThreadLocalIndex, Ty}; + +#[track_caller] +fn check_serialize(value: T, expected_json: &str) { + let got_json = serde_json::to_string(&value).unwrap(); + assert_eq!(got_json, expected_json, "didn't get expected json for serializing"); +} + +#[test] +fn serialize_cratenum() { + check_serialize(CrateNum(1, ThreadLocalIndex), "1"); +} + +#[test] +fn serialize_defid() { + check_serialize(DefId::to_val(2), "2"); +} + +#[test] +fn serialize_layout() { + check_serialize(Layout::to_val(3), "3"); +} + +#[test] +fn serialize_allocid() { + check_serialize(AllocId::to_val(4), "4"); +} + +#[test] +fn serialize_ty() { + check_serialize(Ty::to_val(5), "5"); +} + +#[test] +fn serialize_tyconstid() { + check_serialize(TyConstId::to_val(6), "6"); +} + +#[test] +fn serialize_mirconstid() { + check_serialize(MirConstId::to_val(7), "7"); +} + +#[test] +fn serialize_span() { + check_serialize(Span::to_val(8), "8"); +} + +#[test] +fn serialize_variantidx() { + check_serialize(VariantIdx::to_val(9), "9"); +} + +#[test] +fn serialize_instancedef() { + check_serialize(InstanceDef::to_val(10), "10"); +} diff --git a/compiler/rustc_public/src/ty.rs b/compiler/rustc_public/src/ty.rs index 0afb94c18d7b..f24d98f7e552 100644 --- a/compiler/rustc_public/src/ty.rs +++ b/compiler/rustc_public/src/ty.rs @@ -11,10 +11,10 @@ use crate::mir::alloc::{AllocId, read_target_int, read_target_uint}; use crate::mir::mono::StaticDef; use crate::target::MachineInfo; -use crate::{Filename, IndexedVal, Opaque}; +use crate::{Filename, IndexedVal, Opaque, ThreadLocalIndex}; -#[derive(Copy, Clone, Eq, PartialEq, Hash, Serialize)] -pub struct Ty(usize); +#[derive(Copy, Clone, Eq, PartialEq, Hash)] +pub struct Ty(usize, ThreadLocalIndex); impl Debug for Ty { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { @@ -151,8 +151,8 @@ pub enum TyConstKind { ZSTValue(Ty), } -#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Serialize)] -pub struct TyConstId(usize); +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] +pub struct TyConstId(usize, ThreadLocalIndex); /// Represents a constant in MIR #[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize)] @@ -212,8 +212,8 @@ pub fn try_from_uint(value: u128, uint_ty: UintTy) -> Result { } } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize)] -pub struct MirConstId(usize); +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub struct MirConstId(usize, ThreadLocalIndex); type Ident = Opaque; @@ -255,8 +255,8 @@ pub struct Placeholder { pub bound: T, } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize)] -pub struct Span(usize); +#[derive(Clone, Copy, PartialEq, Eq, Hash)] +pub struct Span(usize, ThreadLocalIndex); impl Debug for Span { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { @@ -1560,14 +1560,29 @@ macro_rules! index_impl { ($name:ident) => { impl crate::IndexedVal for $name { fn to_val(index: usize) -> Self { - $name(index) + $name(index, $crate::ThreadLocalIndex) } fn to_index(&self) -> usize { self.0 } } + $crate::ty::serialize_index_impl!($name); }; } +macro_rules! serialize_index_impl { + ($name:ident) => { + impl ::serde::Serialize for $name { + fn serialize(&self, serializer: S) -> Result + where + S: ::serde::Serializer, + { + let n: usize = self.0; // Make sure we're serializing an int. + ::serde::Serialize::serialize(&n, serializer) + } + } + }; +} +pub(crate) use {index_impl, serialize_index_impl}; index_impl!(TyConstId); index_impl!(MirConstId); @@ -1587,8 +1602,8 @@ fn to_index(&self) -> usize { /// `a` is in the variant with the `VariantIdx` of `0`, /// `c` is in the variant with the `VariantIdx` of `1`, and /// `g` is in the variant with the `VariantIdx` of `0`. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize)] -pub struct VariantIdx(usize); +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub struct VariantIdx(usize, ThreadLocalIndex); index_impl!(VariantIdx); diff --git a/compiler/rustc_public/src/unstable/convert/internal.rs b/compiler/rustc_public/src/unstable/convert/internal.rs index 064fb6c6803a..d9f314a8e29c 100644 --- a/compiler/rustc_public/src/unstable/convert/internal.rs +++ b/compiler/rustc_public/src/unstable/convert/internal.rs @@ -40,7 +40,7 @@ fn internal<'tcx>( _tables: &mut Tables<'_, BridgeTys>, _tcx: impl InternalCx<'tcx>, ) -> Self::T<'tcx> { - rustc_span::def_id::CrateNum::from_usize(*self) + rustc_span::def_id::CrateNum::from_usize(self.0) } } From b565635e045f87e4fab979aa2b6cb500a93e01ee Mon Sep 17 00:00:00 2001 From: Zachary S Date: Tue, 18 Nov 2025 20:00:22 -0600 Subject: [PATCH 085/194] Add Arc::(try_)clone_from_ref(_in) --- library/alloc/src/sync.rs | 119 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 5 deletions(-) diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index c302f35e5ed6..f584a9a6d4d6 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -11,10 +11,8 @@ use core::any::Any; use core::cell::CloneFromCell; #[cfg(not(no_global_oom_handling))] -use core::clone::CloneToUninit; -#[cfg(not(no_global_oom_handling))] use core::clone::TrivialClone; -use core::clone::UseCloned; +use core::clone::{CloneToUninit, UseCloned}; use core::cmp::Ordering; use core::hash::{Hash, Hasher}; use core::intrinsics::abort; @@ -1442,6 +1440,104 @@ pub unsafe fn assume_init(self) -> Arc { } } +impl Arc { + /// Constructs a new `Arc` with a clone of `value`. + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// use std::sync::Arc; + /// + /// let hello: Arc = Arc::clone_from_ref("hello"); + /// ``` + #[cfg(not(no_global_oom_handling))] + #[unstable(feature = "clone_from_ref", issue = "149075")] + pub fn clone_from_ref(value: &T) -> Arc { + Arc::clone_from_ref_in(value, Global) + } + + /// Constructs a new `Arc` with a clone of `value`, returning an error if allocation fails + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// #![feature(allocator_api)] + /// use std::sync::Arc; + /// + /// let hello: Arc = Arc::try_clone_from_ref("hello")?; + /// # Ok::<(), std::alloc::AllocError>(()) + /// ``` + #[unstable(feature = "clone_from_ref", issue = "149075")] + //#[unstable(feature = "allocator_api", issue = "32838")] + pub fn try_clone_from_ref(value: &T) -> Result, AllocError> { + Arc::try_clone_from_ref_in(value, Global) + } +} + +impl Arc { + /// Constructs a new `Arc` with a clone of `value` in the provided allocator. + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// #![feature(allocator_api)] + /// use std::sync::Arc; + /// use std::alloc::System; + /// + /// let hello: Arc = Arc::clone_from_ref_in("hello", System); + /// ``` + #[cfg(not(no_global_oom_handling))] + #[unstable(feature = "clone_from_ref", issue = "149075")] + //#[unstable(feature = "allocator_api", issue = "32838")] + pub fn clone_from_ref_in(value: &T, alloc: A) -> Arc { + // `in_progress` drops the allocation if we panic before finishing initializing it. + let mut in_progress: UniqueArcUninit = UniqueArcUninit::new(value, alloc); + + // Initialize with clone of value. + let initialized_clone = unsafe { + // Clone. If the clone panics, `in_progress` will be dropped and clean up. + value.clone_to_uninit(in_progress.data_ptr().cast()); + // Cast type of pointer, now that it is initialized. + in_progress.into_arc() + }; + + initialized_clone + } + + /// Constructs a new `Arc` with a clone of `value` in the provided allocator, returning an error if allocation fails + /// + /// # Examples + /// + /// ``` + /// #![feature(clone_from_ref)] + /// #![feature(allocator_api)] + /// use std::sync::Arc; + /// use std::alloc::System; + /// + /// let hello: Arc = Arc::try_clone_from_ref_in("hello", System)?; + /// # Ok::<(), std::alloc::AllocError>(()) + /// ``` + #[unstable(feature = "clone_from_ref", issue = "149075")] + //#[unstable(feature = "allocator_api", issue = "32838")] + pub fn try_clone_from_ref_in(value: &T, alloc: A) -> Result, AllocError> { + // `in_progress` drops the allocation if we panic before finishing initializing it. + let mut in_progress: UniqueArcUninit = UniqueArcUninit::try_new(value, alloc)?; + + // Initialize with clone of value. + let initialized_clone = unsafe { + // Clone. If the clone panics, `in_progress` will be dropped and clean up. + value.clone_to_uninit(in_progress.data_ptr().cast()); + // Cast type of pointer, now that it is initialized. + in_progress.into_arc() + }; + + Ok(initialized_clone) + } +} + impl Arc<[mem::MaybeUninit], A> { /// Converts to `Arc<[T]>`. /// @@ -4137,16 +4233,15 @@ fn data_offset_align(align: usize) -> usize { /// but will deallocate it (without dropping the value) when dropped. /// /// This is a helper for [`Arc::make_mut()`] to ensure correct cleanup on panic. -#[cfg(not(no_global_oom_handling))] struct UniqueArcUninit { ptr: NonNull>, layout_for_value: Layout, alloc: Option, } -#[cfg(not(no_global_oom_handling))] impl UniqueArcUninit { /// Allocates an ArcInner with layout suitable to contain `for_value` or a clone of it. + #[cfg(not(no_global_oom_handling))] fn new(for_value: &T, alloc: A) -> UniqueArcUninit { let layout = Layout::for_value(for_value); let ptr = unsafe { @@ -4159,6 +4254,20 @@ fn new(for_value: &T, alloc: A) -> UniqueArcUninit { Self { ptr: NonNull::new(ptr).unwrap(), layout_for_value: layout, alloc: Some(alloc) } } + /// Allocates an ArcInner with layout suitable to contain `for_value` or a clone of it, + /// returning an error if allocation fails. + fn try_new(for_value: &T, alloc: A) -> Result, AllocError> { + let layout = Layout::for_value(for_value); + let ptr = unsafe { + Arc::try_allocate_for_layout( + layout, + |layout_for_arcinner| alloc.allocate(layout_for_arcinner), + |mem| mem.with_metadata_of(ptr::from_ref(for_value) as *const ArcInner), + )? + }; + Ok(Self { ptr: NonNull::new(ptr).unwrap(), layout_for_value: layout, alloc: Some(alloc) }) + } + /// Returns the pointer to be written into to initialize the [`Arc`]. fn data_ptr(&mut self) -> *mut T { let offset = data_offset_align(self.layout_for_value.align()); From 2eac4db0b179605d24c1af50bf6f82a4f3e580f9 Mon Sep 17 00:00:00 2001 From: Zachary S Date: Tue, 18 Nov 2025 20:01:48 -0600 Subject: [PATCH 086/194] Implement the clone part of Arc::make_mut using Arc::clone_from_ref_in --- library/alloc/src/sync.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index f584a9a6d4d6..6a49017a8276 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -2502,19 +2502,7 @@ pub fn make_mut(this: &mut Self) -> &mut T { // deallocated. if this.inner().strong.compare_exchange(1, 0, Acquire, Relaxed).is_err() { // Another strong pointer exists, so we must clone. - - let this_data_ref: &T = &**this; - // `in_progress` drops the allocation if we panic before finishing initializing it. - let mut in_progress: UniqueArcUninit = - UniqueArcUninit::new(this_data_ref, this.alloc.clone()); - - let initialized_clone = unsafe { - // Clone. If the clone panics, `in_progress` will be dropped and clean up. - this_data_ref.clone_to_uninit(in_progress.data_ptr().cast()); - // Cast type of pointer, now that it is initialized. - in_progress.into_arc() - }; - *this = initialized_clone; + *this = Arc::clone_from_ref_in(&**this, this.alloc.clone()); } else if this.inner().weak.load(Relaxed) != 1 { // Relaxed suffices in the above because this is fundamentally an // optimization: we are always racing with weak pointers being From a74d572b741322cb1e51fa7632b5066aa29dd48e Mon Sep 17 00:00:00 2001 From: David Tenty Date: Wed, 19 Nov 2025 15:09:32 -0500 Subject: [PATCH 087/194] [AIX][ppc64le-linux-gnu] Add Amy Kwan to target maintainers --- src/doc/rustc/src/platform-support/aix.md | 1 + .../rustc/src/platform-support/powerpc64le-unknown-linux-gnu.md | 1 + 2 files changed, 2 insertions(+) diff --git a/src/doc/rustc/src/platform-support/aix.md b/src/doc/rustc/src/platform-support/aix.md index 3002a5c4b2cd..c06092eb123c 100644 --- a/src/doc/rustc/src/platform-support/aix.md +++ b/src/doc/rustc/src/platform-support/aix.md @@ -8,6 +8,7 @@ Rust for AIX operating system, currently only 64-bit PowerPC is supported. [@daltenty](https://github.com/daltenty) [@gilamn5tr](https://github.com/gilamn5tr) +[@amy-kwan](https://github.com/amy-kwan) ## Requirements diff --git a/src/doc/rustc/src/platform-support/powerpc64le-unknown-linux-gnu.md b/src/doc/rustc/src/platform-support/powerpc64le-unknown-linux-gnu.md index 78c3e680fc3c..c093a7d4ddba 100644 --- a/src/doc/rustc/src/platform-support/powerpc64le-unknown-linux-gnu.md +++ b/src/doc/rustc/src/platform-support/powerpc64le-unknown-linux-gnu.md @@ -8,6 +8,7 @@ Target for 64-bit little endian PowerPC Linux programs [@daltenty](https://github.com/daltenty) [@gilamn5tr](https://github.com/gilamn5tr) +[@amy-kwan](https://github.com/amy-kwan) ## Requirements From 8c4e3ff0a6f056345196dffc81795927e947b3f9 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 19 Nov 2025 14:20:00 -0600 Subject: [PATCH 088/194] fs: Update skipped file lock tests to match flock support The list of platforms for which file locks are tested is smaller than the list of platforms that support it. Synchronize these here. Link: https://github.com/rust-lang/rust/blob/07bdbaedc63094281483c40a88a1a8f2f8ffadc5/library/std/src/sys/fs/unix.rs#L1291-L1308 --- library/std/src/fs/tests.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 9fd87e119906..294de60f7d43 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -224,11 +224,15 @@ fn file_test_io_seek_and_write() { #[test] #[cfg(any( windows, + target_os = "aix", + target_os = "cygwin", target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_os = "solaris", - target_os = "illumos", target_vendor = "apple", ))] fn file_lock_multiple_shared() { @@ -249,11 +253,15 @@ fn file_lock_multiple_shared() { #[test] #[cfg(any( windows, + target_os = "aix", + target_os = "cygwin", target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_os = "solaris", - target_os = "illumos", target_vendor = "apple", ))] fn file_lock_blocking() { @@ -275,11 +283,15 @@ fn file_lock_blocking() { #[test] #[cfg(any( windows, + target_os = "aix", + target_os = "cygwin", target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_os = "solaris", - target_os = "illumos", target_vendor = "apple", ))] fn file_lock_drop() { @@ -298,11 +310,15 @@ fn file_lock_drop() { #[test] #[cfg(any( windows, + target_os = "aix", + target_os = "cygwin", target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", target_os = "linux", target_os = "netbsd", + target_os = "openbsd", target_os = "solaris", - target_os = "illumos", target_vendor = "apple", ))] fn file_lock_dup() { From 30f4a2ae160610af3d79bf7c2361b2f1438f540b Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Wed, 19 Nov 2025 12:11:32 -0800 Subject: [PATCH 089/194] See if this is the time we can remove `layout::size_align` This was a bad idea before, but now that `size_of` and `align_of` work completely differently than when removing it was first tried in 2020, maybe it makes sense now. (Or maybe I'll just add another attempt to the list in the comments...) --- library/core/src/alloc/layout.rs | 16 +--------------- library/core/src/mem/mod.rs | 7 ++++++- tests/ui/thir-print/offset_of.stdout | 18 +++++++++--------- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs index 1f37c978fecf..73d929fbc7f4 100644 --- a/library/core/src/alloc/layout.rs +++ b/library/core/src/alloc/layout.rs @@ -10,16 +10,6 @@ use crate::ptr::{Alignment, NonNull}; use crate::{assert_unsafe_precondition, fmt, mem}; -// While this function is used in one place and its implementation -// could be inlined, the previous attempts to do so made rustc -// slower: -// -// * https://github.com/rust-lang/rust/pull/72189 -// * https://github.com/rust-lang/rust/pull/79827 -const fn size_align() -> (usize, usize) { - (size_of::(), align_of::()) -} - /// Layout of a block of memory. /// /// An instance of `Layout` describes a particular layout of memory. @@ -168,11 +158,7 @@ pub const fn align(&self) -> usize { #[must_use] #[inline] pub const fn new() -> Self { - let (size, align) = size_align::(); - // SAFETY: if the type is instantiated, rustc already ensures that its - // layout is valid. Use the unchecked constructor to avoid inserting a - // panicking codepath that needs to be optimized out. - unsafe { Layout::from_size_align_unchecked(size, align) } + ::LAYOUT } /// Produces layout describing a record that could be used to diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 7d9d7f3f586c..f4fcc9b1f366 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -1283,7 +1283,12 @@ pub trait SizedTypeProperties: Sized { #[doc(hidden)] #[unstable(feature = "sized_type_properties", issue = "none")] - const LAYOUT: Layout = Layout::new::(); + const LAYOUT: Layout = { + // SAFETY: if the type is instantiated, rustc already ensures that its + // layout is valid. Use the unchecked constructor to avoid inserting a + // panicking codepath that needs to be optimized out. + unsafe { Layout::from_size_align_unchecked(Self::SIZE, Self::ALIGN) } + }; /// The largest safe length for a `[Self]`. /// diff --git a/tests/ui/thir-print/offset_of.stdout b/tests/ui/thir-print/offset_of.stdout index 74f7fbd10099..e1b6ea9349b4 100644 --- a/tests/ui/thir-print/offset_of.stdout +++ b/tests/ui/thir-print/offset_of.stdout @@ -68,7 +68,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::concrete).10)) - span: $DIR/offset_of.rs:37:5: 1430:57 (#0) + span: $DIR/offset_of.rs:37:5: 1435:57 (#0) } } Stmt { @@ -117,7 +117,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::concrete).20)) - span: $DIR/offset_of.rs:38:5: 1430:57 (#0) + span: $DIR/offset_of.rs:38:5: 1435:57 (#0) } } Stmt { @@ -166,7 +166,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::concrete).30)) - span: $DIR/offset_of.rs:39:5: 1430:57 (#0) + span: $DIR/offset_of.rs:39:5: 1435:57 (#0) } } Stmt { @@ -215,7 +215,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::concrete).40)) - span: $DIR/offset_of.rs:40:5: 1430:57 (#0) + span: $DIR/offset_of.rs:40:5: 1435:57 (#0) } } Stmt { @@ -264,7 +264,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::concrete).50)) - span: $DIR/offset_of.rs:41:5: 1430:57 (#0) + span: $DIR/offset_of.rs:41:5: 1435:57 (#0) } } ] @@ -864,7 +864,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::generic).12)) - span: $DIR/offset_of.rs:45:5: 1430:57 (#0) + span: $DIR/offset_of.rs:45:5: 1435:57 (#0) } } Stmt { @@ -913,7 +913,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::generic).24)) - span: $DIR/offset_of.rs:46:5: 1430:57 (#0) + span: $DIR/offset_of.rs:46:5: 1435:57 (#0) } } Stmt { @@ -962,7 +962,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::generic).36)) - span: $DIR/offset_of.rs:47:5: 1430:57 (#0) + span: $DIR/offset_of.rs:47:5: 1435:57 (#0) } } Stmt { @@ -1011,7 +1011,7 @@ body: ) else_block: None lint_level: Explicit(HirId(DefId(offset_of::generic).48)) - span: $DIR/offset_of.rs:48:5: 1430:57 (#0) + span: $DIR/offset_of.rs:48:5: 1435:57 (#0) } } ] From 4bf24d2b54c23dd00c7eb48dd6b9a82bead687ec Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 19 Nov 2025 14:20:00 -0600 Subject: [PATCH 090/194] fs: Expect a test failure if file locks aren't supported Rather than skipping the tests, make sure that they fail. This ensures that if file locking support is added for more platforms in the future, the tests don't wind up quietly skipped. --- library/std/src/fs/tests.rs | 135 +++++++++++++++++------------------- 1 file changed, 65 insertions(+), 70 deletions(-) diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 294de60f7d43..a9195f09425c 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -1,24 +1,7 @@ use rand::RngCore; -#[cfg(any( - windows, - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "illumos", - target_vendor = "apple", -))] use crate::assert_matches::assert_matches; -#[cfg(any( - windows, - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", - target_os = "illumos", - target_vendor = "apple", -))] -use crate::fs::TryLockError; -use crate::fs::{self, File, FileTimes, OpenOptions}; +use crate::fs::{self, File, FileTimes, OpenOptions, TryLockError}; use crate::io::prelude::*; use crate::io::{BorrowedBuf, ErrorKind, SeekFrom}; use crate::mem::MaybeUninit; @@ -222,19 +205,22 @@ fn file_test_io_seek_and_write() { } #[test] -#[cfg(any( - windows, - target_os = "aix", - target_os = "cygwin", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "illumos", - target_os = "linux", - target_os = "netbsd", - target_os = "openbsd", - target_os = "solaris", - target_vendor = "apple", -))] +#[cfg_attr( + not(any( + windows, + target_os = "aix", + target_os = "cygwin", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris", + target_vendor = "apple", + )), + should_panic +)] fn file_lock_multiple_shared() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_lock_multiple_shared_test.txt"); @@ -251,19 +237,22 @@ fn file_lock_multiple_shared() { } #[test] -#[cfg(any( - windows, - target_os = "aix", - target_os = "cygwin", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "illumos", - target_os = "linux", - target_os = "netbsd", - target_os = "openbsd", - target_os = "solaris", - target_vendor = "apple", -))] +#[cfg_attr( + not(any( + windows, + target_os = "aix", + target_os = "cygwin", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris", + target_vendor = "apple", + )), + should_panic +)] fn file_lock_blocking() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_lock_blocking_test.txt"); @@ -281,19 +270,22 @@ fn file_lock_blocking() { } #[test] -#[cfg(any( - windows, - target_os = "aix", - target_os = "cygwin", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "illumos", - target_os = "linux", - target_os = "netbsd", - target_os = "openbsd", - target_os = "solaris", - target_vendor = "apple", -))] +#[cfg_attr( + not(any( + windows, + target_os = "aix", + target_os = "cygwin", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris", + target_vendor = "apple", + )), + should_panic +)] fn file_lock_drop() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_lock_dup_test.txt"); @@ -308,19 +300,22 @@ fn file_lock_drop() { } #[test] -#[cfg(any( - windows, - target_os = "aix", - target_os = "cygwin", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "illumos", - target_os = "linux", - target_os = "netbsd", - target_os = "openbsd", - target_os = "solaris", - target_vendor = "apple", -))] +#[cfg_attr( + not(any( + windows, + target_os = "aix", + target_os = "cygwin", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris", + target_vendor = "apple", + )), + should_panic +)] fn file_lock_dup() { let tmpdir = tmpdir(); let filename = &tmpdir.join("file_lock_dup_test.txt"); From cea9dd8dc8cddd9ecbdf1308418b63dfa047aca4 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 19 Nov 2025 14:20:00 -0600 Subject: [PATCH 091/194] test: Use an ignore message for fs Android skips --- library/std/src/fs/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index a9195f09425c..0a5d1153d860 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -1263,7 +1263,7 @@ fn readlink_not_symlink() { } #[test] -#[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating hardlinks +#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")] fn links_work() { let tmpdir = tmpdir(); let input = tmpdir.join("in.txt"); @@ -1759,7 +1759,7 @@ fn metadata_access_times() { /// Test creating hard links to symlinks. #[test] -#[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating hardlinks +#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")] fn symlink_hard_link() { let tmpdir = tmpdir(); if !got_symlink_permission(&tmpdir) { From ae682a3862aed2878c1c5bbc8d5dfba52aa72d70 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Thu, 20 Nov 2025 00:27:56 +0100 Subject: [PATCH 092/194] enable `avx10_target_feature` in core (used by stdarch) --- library/core/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 2dd48ef18369..ef85e3690086 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -195,6 +195,7 @@ // tidy-alphabetical-start #![feature(aarch64_unstable_target_feature)] #![feature(arm_target_feature)] +#![feature(avx10_target_feature)] #![feature(hexagon_target_feature)] #![feature(loongarch_target_feature)] #![feature(mips_target_feature)] From ea3fe53ac0eb96c7efc367b9acc2907c4b041853 Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Thu, 20 Nov 2025 10:13:11 +0530 Subject: [PATCH 093/194] std: sys: fs: uefi: Fix FileAttr size - The underlying file size is represented by file_size field. The size field is just the size of structure since it is a C DST. Signed-off-by: Ayush Singh --- library/std/src/sys/fs/uefi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/fs/uefi.rs b/library/std/src/sys/fs/uefi.rs index 18c1501a655f..7625409007a4 100644 --- a/library/std/src/sys/fs/uefi.rs +++ b/library/std/src/sys/fs/uefi.rs @@ -81,7 +81,7 @@ fn from_uefi(info: helpers::UefiBox) -> Self { unsafe { Self { attr: (*info.as_ptr()).attribute, - size: (*info.as_ptr()).size, + size: (*info.as_ptr()).file_size, modified: uefi_fs::uefi_to_systemtime((*info.as_ptr()).modification_time), accessed: uefi_fs::uefi_to_systemtime((*info.as_ptr()).last_access_time), created: uefi_fs::uefi_to_systemtime((*info.as_ptr()).create_time), From 7ad3c5c4f8498f0683e1addc1b514c8e95ec7a48 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 19 Nov 2025 22:14:46 +0100 Subject: [PATCH 094/194] sgx: avoid unnecessarily creating a slice --- library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs b/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs index a60b83213fd9..fb410c285160 100644 --- a/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs +++ b/library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs @@ -143,12 +143,6 @@ fn align_of() -> usize { align_of::() } - /// # Safety - /// Behavior is undefined if any of these conditions are violated: - /// * `ptr` must be [valid] for writes of `size` many bytes, and it must be - /// properly aligned. - /// - /// [valid]: core::ptr#safety /// # Panics /// /// This function panics if: @@ -158,8 +152,7 @@ unsafe fn from_raw_sized_unchecked(ptr: *mut u8, size: usize) -> *mut Self { let elem_size = size_of::(); assert_eq!(size % elem_size, 0); let len = size / elem_size; - // SAFETY: The caller must uphold the safety contract for `from_raw_sized_unchecked` - unsafe { slice::from_raw_parts_mut(ptr as _, len) } + ptr::slice_from_raw_parts_mut(ptr as _, len) } } From 68abe69f13be3d3864f6fa3136a5a19a776549ea Mon Sep 17 00:00:00 2001 From: bendn Date: Thu, 20 Nov 2025 15:21:27 +0700 Subject: [PATCH 095/194] iter::ArrayChunks::into_remainder ought not return option --- library/core/src/iter/adapters/array_chunks.rs | 6 +++--- library/core/src/iter/traits/iterator.rs | 2 +- library/coretests/tests/iter/adapters/array_chunks.rs | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/library/core/src/iter/adapters/array_chunks.rs b/library/core/src/iter/adapters/array_chunks.rs index 8f1744fc5fbb..967136288865 100644 --- a/library/core/src/iter/adapters/array_chunks.rs +++ b/library/core/src/iter/adapters/array_chunks.rs @@ -40,17 +40,17 @@ pub(in crate::iter) fn new(iter: I) -> Self { /// # // Also serves as a regression test for https://github.com/rust-lang/rust/issues/123333 /// # #![feature(iter_array_chunks)] /// let x = [1,2,3,4,5].into_iter().array_chunks::<2>(); - /// let mut rem = x.into_remainder().unwrap(); + /// let mut rem = x.into_remainder(); /// assert_eq!(rem.next(), Some(5)); /// assert_eq!(rem.next(), None); /// ``` #[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")] #[inline] - pub fn into_remainder(mut self) -> Option> { + pub fn into_remainder(mut self) -> array::IntoIter { if self.remainder.is_none() { while let Some(_) = self.next() {} } - self.remainder + self.remainder.unwrap_or_default() } } diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 695f8d1e195e..29230b166538 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -3523,7 +3523,7 @@ fn cycle(self) -> Cycle /// assert_eq!(iter.next(), Some(['l', 'o'])); /// assert_eq!(iter.next(), Some(['r', 'e'])); /// assert_eq!(iter.next(), None); - /// assert_eq!(iter.into_remainder().unwrap().as_slice(), &['m']); + /// assert_eq!(iter.into_remainder().as_slice(), &['m']); /// ``` /// /// ``` diff --git a/library/coretests/tests/iter/adapters/array_chunks.rs b/library/coretests/tests/iter/adapters/array_chunks.rs index fb19a519f63b..e6e279b14e62 100644 --- a/library/coretests/tests/iter/adapters/array_chunks.rs +++ b/library/coretests/tests/iter/adapters/array_chunks.rs @@ -18,10 +18,10 @@ fn test_iterator_array_chunks_clone_and_drop() { assert_eq!(count.get(), 3); let mut it2 = it.clone(); assert_eq!(count.get(), 3); - assert_eq!(it.into_remainder().unwrap().len(), 2); + assert_eq!(it.into_remainder().len(), 2); assert_eq!(count.get(), 5); assert!(it2.next().is_none()); - assert_eq!(it2.into_remainder().unwrap().len(), 2); + assert_eq!(it2.into_remainder().len(), 2); assert_eq!(count.get(), 7); } @@ -31,7 +31,7 @@ fn test_iterator_array_chunks_remainder() { assert_eq!(it.next(), Some([0, 1, 2, 3])); assert_eq!(it.next(), Some([4, 5, 6, 7])); assert_eq!(it.next(), None); - assert_eq!(it.into_remainder().unwrap().as_slice(), &[8, 9, 10]); + assert_eq!(it.into_remainder().as_slice(), &[8, 9, 10]); } #[test] @@ -89,7 +89,7 @@ fn test_iterator_array_chunks_next_and_next_back() { assert_eq!(it.next(), None); assert_eq!(it.next_back(), None); assert_eq!(it.next(), None); - assert_eq!(it.into_remainder().unwrap().as_slice(), &[9, 10]); + assert_eq!(it.into_remainder().as_slice(), &[9, 10]); } #[test] @@ -102,7 +102,7 @@ fn test_iterator_array_chunks_rev_remainder() { assert_eq!(it.next(), None); assert_eq!(it.next(), None); } - assert_eq!(it.into_remainder().unwrap().as_slice(), &[8, 9, 10]); + assert_eq!(it.into_remainder().as_slice(), &[8, 9, 10]); } #[test] From c8ba2a59f897f01357149fc4ce14c029683e6b26 Mon Sep 17 00:00:00 2001 From: Fluid Date: Thu, 20 Nov 2025 12:09:44 +0200 Subject: [PATCH 096/194] remove an unused variable Deleted lines are duplicates of the lines 38 & 39. --- src/tools/compiletest/src/runtest/rustdoc_json.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/tools/compiletest/src/runtest/rustdoc_json.rs b/src/tools/compiletest/src/runtest/rustdoc_json.rs index 6cb0c2a04053..89e9f3168837 100644 --- a/src/tools/compiletest/src/runtest/rustdoc_json.rs +++ b/src/tools/compiletest/src/runtest/rustdoc_json.rs @@ -18,8 +18,6 @@ pub(super) fn run_rustdoc_json_test(&self) { self.fatal_proc_rec("rustdoc failed!", &proc_res); } - let mut json_out = out_dir.join(self.testpaths.file.file_stem().unwrap()); - json_out.set_extension("json"); let res = self.run_command_to_procres( Command::new(self.config.jsondocck_path.as_ref().unwrap()) .arg("--doc-dir") From 3f08502242399d10f879a5573c7f6ee1568462c4 Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Thu, 20 Nov 2025 15:50:19 +0530 Subject: [PATCH 097/194] std: sys: net: uefi: Implement read_vectored - Basically a copy of write_vectored [0] - Tested on QEMU ovmf. [0]: https://github.com/rust-lang/rust/pull/146301 Signed-off-by: Ayush Singh --- .../std/src/sys/net/connection/uefi/mod.rs | 5 +- .../std/src/sys/net/connection/uefi/tcp.rs | 12 +++- .../std/src/sys/net/connection/uefi/tcp4.rs | 68 +++++++++++++++---- 3 files changed, 69 insertions(+), 16 deletions(-) diff --git a/library/std/src/sys/net/connection/uefi/mod.rs b/library/std/src/sys/net/connection/uefi/mod.rs index d76e3e576f33..db2d18646d02 100644 --- a/library/std/src/sys/net/connection/uefi/mod.rs +++ b/library/std/src/sys/net/connection/uefi/mod.rs @@ -69,12 +69,11 @@ pub fn read_buf(&self, cursor: BorrowedCursor<'_>) -> io::Result<()> { } pub fn read_vectored(&self, buf: &mut [IoSliceMut<'_>]) -> io::Result { - // FIXME: UEFI does support vectored read, so implement that. - crate::io::default_read_vectored(|b| self.read(b), buf) + self.inner.read_vectored(buf, self.read_timeout()?) } pub fn is_read_vectored(&self) -> bool { - false + true } pub fn write(&self, buf: &[u8]) -> io::Result { diff --git a/library/std/src/sys/net/connection/uefi/tcp.rs b/library/std/src/sys/net/connection/uefi/tcp.rs index 16283e64fb35..1e7e829c85f3 100644 --- a/library/std/src/sys/net/connection/uefi/tcp.rs +++ b/library/std/src/sys/net/connection/uefi/tcp.rs @@ -1,5 +1,5 @@ use super::tcp4; -use crate::io::{self, IoSlice}; +use crate::io::{self, IoSlice, IoSliceMut}; use crate::net::SocketAddr; use crate::ptr::NonNull; use crate::sys::{helpers, unsupported}; @@ -44,6 +44,16 @@ pub(crate) fn read(&self, buf: &mut [u8], timeout: Option) -> io::Resu } } + pub(crate) fn read_vectored( + &self, + buf: &mut [IoSliceMut<'_>], + timeout: Option, + ) -> io::Result { + match self { + Self::V4(client) => client.read_vectored(buf, timeout), + } + } + pub(crate) fn ttl(&self) -> io::Result { match self { Self::V4(client) => client.get_mode_data().map(|x| x.time_to_live.into()), diff --git a/library/std/src/sys/net/connection/uefi/tcp4.rs b/library/std/src/sys/net/connection/uefi/tcp4.rs index ba0424454d73..0409997f0272 100644 --- a/library/std/src/sys/net/connection/uefi/tcp4.rs +++ b/library/std/src/sys/net/connection/uefi/tcp4.rs @@ -1,7 +1,7 @@ use r_efi::efi::{self, Status}; use r_efi::protocols::tcp4; -use crate::io::{self, IoSlice}; +use crate::io::{self, IoSlice, IoSliceMut}; use crate::net::SocketAddrV4; use crate::ptr::NonNull; use crate::sync::atomic::{AtomicBool, Ordering}; @@ -193,30 +193,74 @@ fn write_inner( } pub(crate) fn read(&self, buf: &mut [u8], timeout: Option) -> io::Result { - let evt = unsafe { self.create_evt() }?; - let completion_token = - tcp4::CompletionToken { event: evt.as_ptr(), status: Status::SUCCESS }; let data_len = u32::try_from(buf.len()).unwrap_or(u32::MAX); let fragment = tcp4::FragmentData { fragment_length: data_len, fragment_buffer: buf.as_mut_ptr().cast::(), }; - let mut tx_data = tcp4::ReceiveData { + let mut rx_data = tcp4::ReceiveData { urgent_flag: r_efi::efi::Boolean::FALSE, data_length: data_len, fragment_count: 1, fragment_table: [fragment], }; - let protocol = self.protocol.as_ptr(); - let mut token = tcp4::IoToken { - completion_token, - packet: tcp4::IoTokenPacket { - rx_data: (&raw mut tx_data).cast::>(), - }, + self.read_inner((&raw mut rx_data).cast(), timeout).map(|_| data_len as usize) + } + + pub(crate) fn read_vectored( + &self, + buf: &[IoSliceMut<'_>], + timeout: Option, + ) -> io::Result { + let mut data_length = 0u32; + let mut fragment_count = 0u32; + + // Calculate how many IoSlice in buf can be transmitted. + for i in buf { + // IoSlice length is always <= u32::MAX in UEFI. + match data_length.checked_add(u32::try_from(i.len()).expect("value is stored as a u32")) + { + Some(x) => data_length = x, + None => break, + } + fragment_count += 1; + } + + let rx_data_size = size_of::>() + + size_of::() * (fragment_count as usize); + let mut rx_data = helpers::UefiBox::::new(rx_data_size)?; + rx_data.write(tcp4::ReceiveData { + urgent_flag: r_efi::efi::Boolean::FALSE, + data_length, + fragment_count, + fragment_table: [], + }); + unsafe { + // SAFETY: IoSlice and FragmentData are guaranteed to have same layout. + crate::ptr::copy_nonoverlapping( + buf.as_ptr().cast(), + (*rx_data.as_mut_ptr()).fragment_table.as_mut_ptr(), + fragment_count as usize, + ); }; + self.read_inner(rx_data.as_mut_ptr(), timeout).map(|_| data_length as usize) + } + + pub(crate) fn read_inner( + &self, + rx_data: *mut tcp4::ReceiveData, + timeout: Option, + ) -> io::Result<()> { + let evt = unsafe { self.create_evt() }?; + let completion_token = + tcp4::CompletionToken { event: evt.as_ptr(), status: Status::SUCCESS }; + + let protocol = self.protocol.as_ptr(); + let mut token = tcp4::IoToken { completion_token, packet: tcp4::IoTokenPacket { rx_data } }; + let r = unsafe { ((*protocol).receive)(protocol, &mut token) }; if r.is_error() { return Err(io::Error::from_raw_os_error(r.as_usize())); @@ -227,7 +271,7 @@ pub(crate) fn read(&self, buf: &mut [u8], timeout: Option) -> io::Resu if completion_token.status.is_error() { Err(io::Error::from_raw_os_error(completion_token.status.as_usize())) } else { - Ok(data_len as usize) + Ok(()) } } From 5590d7db51265a3fabbc47a25a679ba8d32a5959 Mon Sep 17 00:00:00 2001 From: nxsaken Date: Thu, 20 Nov 2025 14:33:01 +0400 Subject: [PATCH 098/194] Constify `residual_into_try_type` --- library/core/src/ops/try_trait.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/core/src/ops/try_trait.rs b/library/core/src/ops/try_trait.rs index f68782c804cd..204291886589 100644 --- a/library/core/src/ops/try_trait.rs +++ b/library/core/src/ops/try_trait.rs @@ -371,11 +371,14 @@ pub const trait Residual: Sized { /// but importantly not on the contextual type the way it would be if /// we called `<_ as FromResidual>::from_residual(r)` directly. #[unstable(feature = "try_trait_v2_residual", issue = "91285")] +#[rustc_const_unstable(feature = "const_try_residual", issue = "91285")] // needs to be `pub` to avoid `private type` errors #[expect(unreachable_pub)] #[inline] // FIXME: force would be nice, but fails -- see #148915 #[lang = "into_try_type"] -pub fn residual_into_try_type, O>(r: R) -> >::TryType { +pub const fn residual_into_try_type, O>( + r: R, +) -> >::TryType { FromResidual::from_residual(r) } From 1e14a5dc737cb608a7a35f816266edb2362992f6 Mon Sep 17 00:00:00 2001 From: 12101111 Date: Thu, 20 Nov 2025 19:22:01 +0800 Subject: [PATCH 099/194] Enable host tools for aarch64-unknown-linux-ohos --- .../rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs index 5f1ab6069ef0..eb0d328b51b7 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target { metadata: TargetMetadata { description: Some("ARM64 OpenHarmony".into()), tier: Some(2), - host_tools: Some(false), + host_tools: Some(true), std: Some(true), }, pointer_width: 64, From 3d3394200adbb6749b58cfe5238ea9a853a5fb68 Mon Sep 17 00:00:00 2001 From: James Barford-Evans Date: Thu, 20 Nov 2025 11:27:18 +0000 Subject: [PATCH 100/194] Use less brittle way for updating error message --- .../rustc_resolve/src/late/diagnostics.rs | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 74afae7996b2..da58c923695d 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -823,8 +823,14 @@ fn try_lookup_name_relaxed( } if let Some(Res::Def(DefKind::Struct, def_id)) = res { - if self.has_private_fields(def_id) { + let private_fields = self.has_private_fields(def_id); + let adjust_error_message = + private_fields && self.is_struct_with_fn_ctor(def_id); + if adjust_error_message { self.update_err_for_private_tuple_struct_fields(err, &source, def_id); + } + + if private_fields { err.note("constructor is not visible here due to private fields"); } } else { @@ -1644,15 +1650,17 @@ fn followed_by_brace(&self, span: Span) -> (bool, Option) { } } - fn has_tuple_fields(&mut self, def_id: DefId) -> bool { - // As we cannot name a field "0", this is an indictation - // that we are looking at a tuple struct - if let Some(fields) = self.r.field_idents(def_id) { - if let Some(first_field) = fields.get(0) { - return first_field.name.as_str() == "0"; - } - } - false + fn is_struct_with_fn_ctor(&mut self, def_id: DefId) -> bool { + def_id + .as_local() + .and_then(|local_id| self.r.struct_constructors.get(&local_id)) + .map(|struct_ctor| { + matches!( + struct_ctor.0, + def::Res::Def(DefKind::Ctor(CtorOf::Struct, CtorKind::Fn), _) + ) + }) + .unwrap_or(false) } fn update_err_for_private_tuple_struct_fields( @@ -1677,18 +1685,17 @@ fn update_err_for_private_tuple_struct_fields( span: call_span, .. })) => { - if self.has_tuple_fields(def_id) { - err.primary_message( - "cannot initialize a tuple struct which contains private fields", - ); - self.suggest_alternative_construction_methods( - def_id, - err, - path.span, - *call_span, - &args[..], - ); - } + err.primary_message( + "cannot initialize a tuple struct which contains private fields", + ); + self.suggest_alternative_construction_methods( + def_id, + err, + path.span, + *call_span, + &args[..], + ); + self.r .field_idents(def_id) .map(|fields| fields.iter().map(|f| f.span).collect::>()) From 00f3155794f40030249a36b4abb09906b6e8fa5d Mon Sep 17 00:00:00 2001 From: yukang Date: Thu, 20 Nov 2025 19:47:21 +0800 Subject: [PATCH 101/194] fix unused assigment issue for variable with drop, issue 148418 --- compiler/rustc_mir_transform/src/liveness.rs | 6 ++- tests/ui/drop/or-pattern-drop-order.rs | 22 ++++++---- tests/ui/drop/or-pattern-drop-order.stderr | 43 +++++++++++++++++++ tests/ui/lint/unused/unused-assign-148960.rs | 17 ++++++-- .../lint/unused/unused-assign-148960.stderr | 32 +++++++++++--- tests/ui/liveness/liveness-unused.rs | 4 +- tests/ui/liveness/liveness-unused.stderr | 18 +++++++- 7 files changed, 120 insertions(+), 22 deletions(-) create mode 100644 tests/ui/drop/or-pattern-drop-order.stderr diff --git a/compiler/rustc_mir_transform/src/liveness.rs b/compiler/rustc_mir_transform/src/liveness.rs index d0134689fec0..e66fb9d2d2a3 100644 --- a/compiler/rustc_mir_transform/src/liveness.rs +++ b/compiler/rustc_mir_transform/src/liveness.rs @@ -981,8 +981,10 @@ fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, _: Location) { self.checked_places, self.body, ) { - statements.clear(); - continue; + statements.retain(|_, access| access.is_direct); + if statements.is_empty() { + continue; + } } let typo = maybe_suggest_typo(); diff --git a/tests/ui/drop/or-pattern-drop-order.rs b/tests/ui/drop/or-pattern-drop-order.rs index 88355a4937e4..c7913be032ea 100644 --- a/tests/ui/drop/or-pattern-drop-order.rs +++ b/tests/ui/drop/or-pattern-drop-order.rs @@ -33,15 +33,15 @@ fn main() { // Drops are right-to-left: `z`, `y`, `x`. let (x, Ok(y) | Err(y), z); // Assignment order doesn't matter. - z = LogDrop(o, 1); - y = LogDrop(o, 2); - x = LogDrop(o, 3); + z = LogDrop(o, 1); //~ WARN value assigned to `z` is never read + y = LogDrop(o, 2); //~ WARN value assigned to `y` is never read + x = LogDrop(o, 3); //~ WARN value assigned to `x` is never read }); assert_drop_order(1..=2, |o| { // The first or-pattern alternative determines the bindings' drop order: `y`, `x`. let ((true, x, y) | (false, y, x)); - x = LogDrop(o, 2); - y = LogDrop(o, 1); + x = LogDrop(o, 2); //~ WARN value assigned to `x` is never read + y = LogDrop(o, 1); //~ WARN value assigned to `y` is never read }); // `let pat = expr;` should have the same drop order. @@ -61,15 +61,21 @@ fn main() { // `match` should have the same drop order. assert_drop_order(1..=3, |o| { // Drops are right-to-left: `z`, `y` `x`. - match (LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)) { (x, Ok(y) | Err(y), z) => {} } + match (LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)) { + (x, Ok(y) | Err(y), z) => {} + } }); assert_drop_order(1..=2, |o| { // The first or-pattern alternative determines the bindings' drop order: `y`, `x`. - match (true, LogDrop(o, 2), LogDrop(o, 1)) { (true, x, y) | (false, y, x) => {} } + match (true, LogDrop(o, 2), LogDrop(o, 1)) { + (true, x, y) | (false, y, x) => {} + } }); assert_drop_order(1..=2, |o| { // That drop order is used regardless of which or-pattern alternative matches: `y`, `x`. - match (false, LogDrop(o, 1), LogDrop(o, 2)) { (true, x, y) | (false, y, x) => {} } + match (false, LogDrop(o, 1), LogDrop(o, 2)) { + (true, x, y) | (false, y, x) => {} + } }); // Function params are visited one-by-one, and the order of bindings within a param's pattern is diff --git a/tests/ui/drop/or-pattern-drop-order.stderr b/tests/ui/drop/or-pattern-drop-order.stderr new file mode 100644 index 000000000000..3d1aa69fb91a --- /dev/null +++ b/tests/ui/drop/or-pattern-drop-order.stderr @@ -0,0 +1,43 @@ +warning: value assigned to `x` is never read + --> $DIR/or-pattern-drop-order.rs:43:9 + | +LL | x = LogDrop(o, 2); + | ^ + | + = help: maybe it is overwritten before being read? + = note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default + +warning: value assigned to `y` is never read + --> $DIR/or-pattern-drop-order.rs:44:9 + | +LL | y = LogDrop(o, 1); + | ^ + | + = help: maybe it is overwritten before being read? + +warning: value assigned to `x` is never read + --> $DIR/or-pattern-drop-order.rs:38:9 + | +LL | x = LogDrop(o, 3); + | ^ + | + = help: maybe it is overwritten before being read? + +warning: value assigned to `y` is never read + --> $DIR/or-pattern-drop-order.rs:37:9 + | +LL | y = LogDrop(o, 2); + | ^ + | + = help: maybe it is overwritten before being read? + +warning: value assigned to `z` is never read + --> $DIR/or-pattern-drop-order.rs:36:9 + | +LL | z = LogDrop(o, 1); + | ^ + | + = help: maybe it is overwritten before being read? + +warning: 5 warnings emitted + diff --git a/tests/ui/lint/unused/unused-assign-148960.rs b/tests/ui/lint/unused/unused-assign-148960.rs index 5d1810ad04a6..2e51c01398a3 100644 --- a/tests/ui/lint/unused/unused-assign-148960.rs +++ b/tests/ui/lint/unused/unused-assign-148960.rs @@ -1,5 +1,6 @@ //@ check-fail #![deny(unused)] +#![allow(dead_code)] fn test_one_extra_assign() { let mut value = b"0".to_vec(); //~ ERROR value assigned to `value` is never read @@ -26,8 +27,16 @@ fn test_indirect_assign() { println!("{}", p.y); } -fn main() { - test_one_extra_assign(); - test_two_extra_assign(); - test_indirect_assign(); +struct Foo; + +impl Drop for Foo { + fn drop(&mut self) {} } + +// testcase for issue #148418 +fn test_unused_variable() { + let mut foo = Foo; //~ ERROR variable `foo` is assigned to, but never used + foo = Foo; //~ ERROR value assigned to `foo` is never read +} + +fn main() {} diff --git a/tests/ui/lint/unused/unused-assign-148960.stderr b/tests/ui/lint/unused/unused-assign-148960.stderr index 3f135264d869..0e23fabd5f56 100644 --- a/tests/ui/lint/unused/unused-assign-148960.stderr +++ b/tests/ui/lint/unused/unused-assign-148960.stderr @@ -1,5 +1,5 @@ error: value assigned to `value` is never read - --> $DIR/unused-assign-148960.rs:5:21 + --> $DIR/unused-assign-148960.rs:6:21 | LL | let mut value = b"0".to_vec(); | ^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | #![deny(unused)] = note: `#[deny(unused_assignments)]` implied by `#[deny(unused)]` error: value assigned to `x` is never read - --> $DIR/unused-assign-148960.rs:11:17 + --> $DIR/unused-assign-148960.rs:12:17 | LL | let mut x = 1; | ^ @@ -21,7 +21,7 @@ LL | let mut x = 1; = help: maybe it is overwritten before being read? error: value assigned to `x` is never read - --> $DIR/unused-assign-148960.rs:12:5 + --> $DIR/unused-assign-148960.rs:13:5 | LL | x = 2; | ^^^^^ @@ -29,12 +29,34 @@ LL | x = 2; = help: maybe it is overwritten before being read? error: value assigned to `p` is never read - --> $DIR/unused-assign-148960.rs:23:17 + --> $DIR/unused-assign-148960.rs:24:17 | LL | let mut p = Point { x: 1, y: 1 }; | ^^^^^^^^^^^^^^^^^^^^ | = help: maybe it is overwritten before being read? -error: aborting due to 4 previous errors +error: variable `foo` is assigned to, but never used + --> $DIR/unused-assign-148960.rs:38:9 + | +LL | let mut foo = Foo; + | ^^^^^^^ + | + = note: consider using `_foo` instead + = note: `#[deny(unused_variables)]` implied by `#[deny(unused)]` +help: you might have meant to pattern match on the similarly named struct `Foo` + | +LL - let mut foo = Foo; +LL + let Foo = Foo; + | + +error: value assigned to `foo` is never read + --> $DIR/unused-assign-148960.rs:39:5 + | +LL | foo = Foo; + | ^^^ + | + = help: maybe it is overwritten before being read? + +error: aborting due to 6 previous errors diff --git a/tests/ui/liveness/liveness-unused.rs b/tests/ui/liveness/liveness-unused.rs index 639d7c2776de..a291d2489695 100644 --- a/tests/ui/liveness/liveness-unused.rs +++ b/tests/ui/liveness/liveness-unused.rs @@ -244,8 +244,8 @@ fn f10(mut a: T, b: T) { //~^ ERROR value assigned to `a` is never read } -fn f10b(mut a: Box, b: Box) { - a = b; +fn f10b(mut a: Box, b: Box) { //~ ERROR variable `a` is assigned to, but never used + a = b; //~ ERROR value assigned to `a` is never read } // unused params warnings are not needed for intrinsic functions without bodies diff --git a/tests/ui/liveness/liveness-unused.stderr b/tests/ui/liveness/liveness-unused.stderr index 23a26841be2f..f56ca7823e16 100644 --- a/tests/ui/liveness/liveness-unused.stderr +++ b/tests/ui/liveness/liveness-unused.stderr @@ -283,5 +283,21 @@ LL | a = b; | = help: maybe it is overwritten before being read? -error: aborting due to 34 previous errors; 1 warning emitted +error: variable `a` is assigned to, but never used + --> $DIR/liveness-unused.rs:247:12 + | +LL | fn f10b(mut a: Box, b: Box) { + | ^^^^^ + | + = note: consider using `_a` instead + +error: value assigned to `a` is never read + --> $DIR/liveness-unused.rs:248:5 + | +LL | a = b; + | ^ + | + = help: maybe it is overwritten before being read? + +error: aborting due to 36 previous errors; 1 warning emitted From 697419163ad37315fd69bb8179480966a5c3ba6b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 19 Nov 2025 15:28:19 +0000 Subject: [PATCH 102/194] Remove some now-unnecessary impls --- compiler/rustc_metadata/src/rmeta/table.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index fca413cdad8c..4069ce2c98b8 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -196,13 +196,6 @@ macro_rules! const_macro_kinds { } } -fixed_size_enum! { - hir::Constness { - ( NotConst ) - ( Const ) - } -} - fixed_size_enum! { hir::Defaultness { ( Final ) @@ -218,13 +211,6 @@ macro_rules! const_macro_kinds { } } -fixed_size_enum! { - ty::Asyncness { - ( Yes ) - ( No ) - } -} - fixed_size_enum! { hir::CoroutineKind { ( Coroutine(hir::Movability::Movable) ) From a3062aac128b0fb83ab5b178288a6a3963e6d39b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 19 Nov 2025 15:31:45 +0000 Subject: [PATCH 103/194] Only encode `hir::Safety::Safe` in metadata. While `Unsafe` is much less common, a failure to encode it would make downstream crates default to `Safe` and think a thing marked as unsafe is actually safe --- compiler/rustc_hir/src/hir.rs | 7 +++- compiler/rustc_metadata/src/rmeta/decoder.rs | 2 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 2 +- compiler/rustc_metadata/src/rmeta/mod.rs | 2 +- compiler/rustc_metadata/src/rmeta/table.rs | 42 +++++++++++++++----- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index db88de828aaf..ea2f9e6d920f 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -4186,8 +4186,13 @@ pub fn is_struct_or_union(&self) -> bool { } #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] -#[derive(Encodable, Decodable, HashStable_Generic)] +#[derive(Encodable, Decodable, HashStable_Generic, Default)] pub enum Safety { + /// This is the default variant, because the compiler messing up + /// metadata encoding and failing to encode a `Safe` flag, means + /// downstream crates think a thing is `Unsafe` instead of silently + /// treating an unsafe thing as safe. + #[default] Unsafe, Safe, } diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 6c796b3a9c8c..5c7de5f3ff84 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1187,7 +1187,7 @@ fn get_visibility(self, id: DefIndex) -> Visibility { } fn get_safety(self, id: DefIndex) -> Safety { - self.root.tables.safety.get(self, id).unwrap_or_else(|| self.missing("safety", id)) + self.root.tables.safety.get(self, id) } fn get_default_field(self, id: DefIndex) -> Option { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index dca9ed2ef74f..82dc4b0e89da 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1697,7 +1697,7 @@ fn encode_info_for_adt(&mut self, local_def_id: LocalDefId) { })); for field in &variant.fields { - self.tables.safety.set_some(field.did.index, field.safety); + self.tables.safety.set(field.did.index, field.safety); } if let Some((CtorKind::Fn, ctor_def_id)) = variant.ctor { diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 672ebe3de483..8c5737cb9eb6 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -402,6 +402,7 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { cross_crate_inlinable: Table, asyncness: Table, constness: Table, + safety: Table, - optional: attributes: Table>, @@ -411,7 +412,6 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { associated_item_or_field_def_ids: Table>, def_kind: Table, visibility: Table>>, - safety: Table, def_span: Table>, def_ident_span: Table>, lookup_stability: Table>, diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 4069ce2c98b8..7a8190fcf2f7 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -37,8 +37,17 @@ fn is_default(&self) -> bool { impl IsDefault for hir::Constness { fn is_default(&self) -> bool { match self { - rustc_hir::Constness::Const => false, - rustc_hir::Constness::NotConst => true, + hir::Constness::Const => false, + hir::Constness::NotConst => true, + } + } +} + +impl IsDefault for hir::Safety { + fn is_default(&self) -> bool { + match self { + hir::Safety::Safe => false, + hir::Safety::Unsafe => true, } } } @@ -204,13 +213,6 @@ macro_rules! const_macro_kinds { } } -fixed_size_enum! { - hir::Safety { - ( Unsafe ) - ( Safe ) - } -} - fixed_size_enum! { hir::CoroutineKind { ( Coroutine(hir::Movability::Movable) ) @@ -343,6 +345,28 @@ impl FixedSizeEncoding for hir::Constness { } } +impl FixedSizeEncoding for hir::Safety { + type ByteArray = [u8; 1]; + + #[inline] + fn from_bytes(b: &[u8; 1]) -> Self { + match b[0] { + 0 => hir::Safety::Unsafe, + 1 => hir::Safety::Safe, + _ => unreachable!(), + } + } + + #[inline] + fn write_to_bytes(self, b: &mut [u8; 1]) { + debug_assert!(!self.is_default()); + b[0] = match self { + hir::Safety::Unsafe => 0, + hir::Safety::Safe => 1, + } + } +} + // NOTE(eddyb) there could be an impl for `usize`, which would enable a more // generic `LazyValue` impl, but in the general case we might not need / want // to fit every `usize` in `u32`. From c489b92845235c66253d964e714ac8dec32bed4b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 19 Nov 2025 16:01:09 +0000 Subject: [PATCH 104/194] Not encoding the default is already handled by `set` --- compiler/rustc_metadata/src/rmeta/encoder.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 82dc4b0e89da..ca4cf260dffb 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1524,17 +1524,11 @@ fn encode_def_ids(&mut self) { } if should_encode_constness(def_kind) { let constness = self.tcx.constness(def_id); - match constness { - hir::Constness::Const => self.tables.constness.set(def_id.index, constness), - hir::Constness::NotConst => {} - } + self.tables.constness.set(def_id.index, constness); } if let DefKind::Fn | DefKind::AssocFn = def_kind { let asyncness = tcx.asyncness(def_id); - match asyncness { - ty::Asyncness::Yes => self.tables.asyncness.set(def_id.index, asyncness), - ty::Asyncness::No => {} - } + self.tables.asyncness.set(def_id.index, asyncness); record_array!(self.tables.fn_arg_idents[def_id] <- tcx.fn_arg_idents(def_id)); } if let Some(name) = tcx.intrinsic(def_id) { From c108451faf1fe034a09c02e8d5b217beafeddea6 Mon Sep 17 00:00:00 2001 From: lapla Date: Thu, 20 Nov 2025 21:25:54 +0900 Subject: [PATCH 105/194] Reject `async fn` in `const impl` during AST validation --- compiler/rustc_ast_passes/messages.ftl | 7 ++++--- compiler/rustc_ast_passes/src/ast_validation.rs | 11 +++++++++-- compiler/rustc_ast_passes/src/errors.rs | 2 +- .../const-traits/ice-149083-async-in-const-impl.rs | 9 +++++++++ .../ice-149083-async-in-const-impl.stderr | 10 ++++++++++ 5 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 tests/ui/traits/const-traits/ice-149083-async-in-const-impl.rs create mode 100644 tests/ui/traits/const-traits/ice-149083-async-in-const-impl.stderr diff --git a/compiler/rustc_ast_passes/messages.ftl b/compiler/rustc_ast_passes/messages.ftl index 3858bc80d431..9bdbcf6ab907 100644 --- a/compiler/rustc_ast_passes/messages.ftl +++ b/compiler/rustc_ast_passes/messages.ftl @@ -37,9 +37,10 @@ ast_passes_assoc_type_without_body = .suggestion = provide a definition for the type ast_passes_async_fn_in_const_trait_or_trait_impl = - async functions are not allowed in `const` {$in_impl -> - [true] trait impls - *[false] traits + async functions are not allowed in `const` {$context -> + [trait_impl] trait impls + [impl] impls + *[trait] traits } .label = associated functions of `const` cannot be declared `async` diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 425ba407fd61..163dbc3350ba 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -312,9 +312,15 @@ fn check_async_fn_in_const_trait_or_impl(&self, sig: &FnSig, parent: &TraitOrImp return; }; + let context = match parent { + TraitOrImpl::Trait { .. } => "trait", + TraitOrImpl::TraitImpl { .. } => "trait_impl", + TraitOrImpl::Impl { .. } => "impl", + }; + self.dcx().emit_err(errors::AsyncFnInConstTraitOrTraitImpl { async_keyword, - in_impl: matches!(parent, TraitOrImpl::TraitImpl { .. }), + context, const_keyword, }); } @@ -1714,9 +1720,10 @@ fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) { self.check_async_fn_in_const_trait_or_impl(sig, parent); } } - Some(TraitOrImpl::Impl { constness }) => { + Some(parent @ TraitOrImpl::Impl { constness }) => { if let AssocItemKind::Fn(box Fn { sig, .. }) = &item.kind { self.check_impl_fn_not_const(sig.header.constness, *constness); + self.check_async_fn_in_const_trait_or_impl(sig, parent); } } None => {} diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index 48fd6a7cdd5d..02e6ecfbaee7 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -76,7 +76,7 @@ pub(crate) struct TraitFnConst { pub(crate) struct AsyncFnInConstTraitOrTraitImpl { #[primary_span] pub async_keyword: Span, - pub in_impl: bool, + pub context: &'static str, #[label] pub const_keyword: Span, } diff --git a/tests/ui/traits/const-traits/ice-149083-async-in-const-impl.rs b/tests/ui/traits/const-traits/ice-149083-async-in-const-impl.rs new file mode 100644 index 000000000000..0880ae509111 --- /dev/null +++ b/tests/ui/traits/const-traits/ice-149083-async-in-const-impl.rs @@ -0,0 +1,9 @@ +//@ edition:2024 + +#![feature(const_trait_impl)] +struct Foo; +const impl Foo { + async fn e() {} + //~^ ERROR async functions are not allowed in `const` impls +} +fn main() {} diff --git a/tests/ui/traits/const-traits/ice-149083-async-in-const-impl.stderr b/tests/ui/traits/const-traits/ice-149083-async-in-const-impl.stderr new file mode 100644 index 000000000000..447222ea4abb --- /dev/null +++ b/tests/ui/traits/const-traits/ice-149083-async-in-const-impl.stderr @@ -0,0 +1,10 @@ +error: async functions are not allowed in `const` impls + --> $DIR/ice-149083-async-in-const-impl.rs:6:5 + | +LL | const impl Foo { + | ----- associated functions of `const` cannot be declared `async` +LL | async fn e() {} + | ^^^^^ + +error: aborting due to 1 previous error + From b9460471e264a580fa8e4721084fa07c4a6b5858 Mon Sep 17 00:00:00 2001 From: apiraino Date: Thu, 20 Nov 2025 18:00:43 +0100 Subject: [PATCH 106/194] Fix platform supports docs typo --- src/doc/rustc/src/platform-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 39bf9c777640..a04f27df9d74 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -182,7 +182,7 @@ target | std | notes [`riscv32imac-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMAC ISA) [`riscv32imafc-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMAFC ISA) [`riscv32imc-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMC ISA) -[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | RISC-V Linux (kernel 4.20+, musl 1.2.5) +[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | ✓ |RISC-V Linux (kernel 4.20+, musl 1.2.5) `riscv64gc-unknown-none-elf` | * | Bare RISC-V (RV64IMAFDC ISA) `riscv64imac-unknown-none-elf` | * | Bare RISC-V (RV64IMAC ISA) `sparc64-unknown-linux-gnu` | ✓ | SPARC Linux (kernel 4.4+, glibc 2.23) From e8a00a7621606f8c4a34b679cefaaa6aecf2442e Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Wed, 12 Nov 2025 09:45:35 +0100 Subject: [PATCH 107/194] Add sub-fn for method call annotation in FnCtxt::report_no_match_method_error Currently this method is quiet long and complex, this commit refactors it and improves its readability by adding sub-fn --- .../rustc_hir_typeck/src/method/suggest.rs | 83 +++++++++++-------- 1 file changed, 49 insertions(+), 34 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index a0d9e9a72386..56f4a2a70a9b 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -666,6 +666,52 @@ fn visit_pat(&mut self, p: &'v hir::Pat<'v>) -> Self::Result { } } + fn suggest_method_call_annotation( + &self, + err: &mut Diag<'_>, + span: Span, + rcvr_ty: Ty<'tcx>, + item_ident: Ident, + mode: Mode, + source: SelfSource<'tcx>, + expected: Expectation<'tcx>, + ) { + if let Mode::MethodCall = mode + && let SelfSource::MethodCall(cal) = source + { + self.suggest_await_before_method( + err, + item_ident, + rcvr_ty, + cal, + span, + expected.only_has_type(self), + ); + } + + self.suggest_on_pointer_type(err, source, rcvr_ty, item_ident); + + if let SelfSource::MethodCall(rcvr_expr) = source { + self.suggest_fn_call(err, rcvr_expr, rcvr_ty, |output_ty| { + let call_expr = self.tcx.hir_expect_expr(self.tcx.parent_hir_id(rcvr_expr.hir_id)); + let probe = self.lookup_probe_for_diagnostic( + item_ident, + output_ty, + call_expr, + ProbeScope::AllTraits, + expected.only_has_type(self), + ); + probe.is_ok() + }); + self.note_internal_mutation_in_method( + err, + rcvr_expr, + expected.to_option(self), + rcvr_ty, + ); + } + } + fn report_no_match_method_error( &self, mut span: Span, @@ -754,40 +800,9 @@ fn report_no_match_method_error( args, ); - if let Mode::MethodCall = mode - && let SelfSource::MethodCall(cal) = source - { - self.suggest_await_before_method( - &mut err, - item_ident, - rcvr_ty, - cal, - span, - expected.only_has_type(self), - ); - } - - self.suggest_on_pointer_type(&mut err, source, rcvr_ty, item_ident); - - if let SelfSource::MethodCall(rcvr_expr) = source { - self.suggest_fn_call(&mut err, rcvr_expr, rcvr_ty, |output_ty| { - let call_expr = self.tcx.hir_expect_expr(self.tcx.parent_hir_id(rcvr_expr.hir_id)); - let probe = self.lookup_probe_for_diagnostic( - item_ident, - output_ty, - call_expr, - ProbeScope::AllTraits, - expected.only_has_type(self), - ); - probe.is_ok() - }); - self.note_internal_mutation_in_method( - &mut err, - rcvr_expr, - expected.to_option(self), - rcvr_ty, - ); - } + self.suggest_method_call_annotation( + &mut err, span, rcvr_ty, item_ident, mode, source, expected, + ); let mut custom_span_label = false; let mut static_candidates = no_match_data.static_candidates.clone(); From 117d6765db66155c166b0406fe41c9d163fa283f Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Wed, 12 Nov 2025 09:57:22 +0100 Subject: [PATCH 108/194] Add sub-fn for static method candidates in FnCtxt::report_no_match_method_error Currently this method is quiet long and complex, this commit refactors it and improves its readability by adding sub-fn --- .../rustc_hir_typeck/src/method/suggest.rs | 119 +++++++++++------- 1 file changed, 71 insertions(+), 48 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 56f4a2a70a9b..bc7e3ca4805c 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -712,6 +712,66 @@ fn suggest_method_call_annotation( } } + fn suggest_static_method_candidates( + &self, + err: &mut Diag<'_>, + span: Span, + rcvr_ty: Ty<'tcx>, + item_ident: Ident, + source: SelfSource<'tcx>, + args: Option<&'tcx [hir::Expr<'tcx>]>, + sugg_span: Span, + no_match_data: &NoMatchData<'tcx>, + ) -> Vec { + let mut static_candidates = no_match_data.static_candidates.clone(); + + // `static_candidates` may have same candidates appended by + // inherent and extension, which may result in incorrect + // diagnostic. + static_candidates.dedup(); + + if !static_candidates.is_empty() { + err.note( + "found the following associated functions; to be used as methods, \ + functions must have a `self` parameter", + ); + err.span_label(span, "this is an associated function, not a method"); + } + if static_candidates.len() == 1 { + self.suggest_associated_call_syntax( + err, + &static_candidates, + rcvr_ty, + source, + item_ident, + args, + sugg_span, + ); + self.note_candidates_on_method_error( + rcvr_ty, + item_ident, + source, + args, + span, + err, + &mut static_candidates, + None, + ); + } else if static_candidates.len() > 1 { + self.note_candidates_on_method_error( + rcvr_ty, + item_ident, + source, + args, + span, + err, + &mut static_candidates, + Some(sugg_span), + ); + } + static_candidates + } + fn report_no_match_method_error( &self, mut span: Span, @@ -804,54 +864,17 @@ fn report_no_match_method_error( &mut err, span, rcvr_ty, item_ident, mode, source, expected, ); - let mut custom_span_label = false; - let mut static_candidates = no_match_data.static_candidates.clone(); - - // `static_candidates` may have same candidates appended by - // inherent and extension, which may result in incorrect - // diagnostic. - static_candidates.dedup(); - - if !static_candidates.is_empty() { - err.note( - "found the following associated functions; to be used as methods, \ - functions must have a `self` parameter", - ); - err.span_label(span, "this is an associated function, not a method"); - custom_span_label = true; - } - if static_candidates.len() == 1 { - self.suggest_associated_call_syntax( - &mut err, - &static_candidates, - rcvr_ty, - source, - item_ident, - args, - sugg_span, - ); - self.note_candidates_on_method_error( - rcvr_ty, - item_ident, - source, - args, - span, - &mut err, - &mut static_candidates, - None, - ); - } else if static_candidates.len() > 1 { - self.note_candidates_on_method_error( - rcvr_ty, - item_ident, - source, - args, - span, - &mut err, - &mut static_candidates, - Some(sugg_span), - ); - } + let static_candidates = self.suggest_static_method_candidates( + &mut err, + span, + rcvr_ty, + item_ident, + source, + args, + sugg_span, + &no_match_data, + ); + let mut custom_span_label = !static_candidates.is_empty(); let mut bound_spans: SortedMap> = Default::default(); let mut restrict_type_params = false; From 6bd1a031ab0431163e890f7285d396f677296bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Sat, 18 Oct 2025 14:52:23 +0200 Subject: [PATCH 109/194] Turn moves into copies after copy propagation Previously copy propagation presumed that there is further unspecified distinction between move operands and copy operands in assignments and propagated moves from assignments into terminators. This is inconsistent with current operational semantics. Turn moves into copies after copy propagation to preserve existing behavior. Fixes https://github.com/rust-lang/rust/issues/137936. Fixes https://github.com/rust-lang/rust/issues/146423. --- compiler/rustc_mir_transform/src/copy_prop.rs | 63 +++---------------- tests/codegen-llvm/align-byval.rs | 2 +- .../move_arg.f.CopyProp.panic-abort.diff | 37 ----------- .../move_arg.f.CopyProp.panic-unwind.diff | 37 ----------- tests/mir-opt/copy-prop/move_arg.rs | 54 +++++++++++----- .../reborrow.remut.CopyProp.panic-abort.diff | 2 +- .../reborrow.remut.CopyProp.panic-unwind.diff | 2 +- .../reborrow.reraw.CopyProp.panic-abort.diff | 2 +- .../reborrow.reraw.CopyProp.panic-unwind.diff | 2 +- tests/ui/lint/large_assignments/inline_mir.rs | 2 +- .../lint/large_assignments/inline_mir.stderr | 10 ++- .../ui/lint/large_assignments/move_into_fn.rs | 2 +- .../large_assignments/move_into_fn.stderr | 10 ++- 13 files changed, 75 insertions(+), 150 deletions(-) delete mode 100644 tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-abort.diff delete mode 100644 tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff diff --git a/compiler/rustc_mir_transform/src/copy_prop.rs b/compiler/rustc_mir_transform/src/copy_prop.rs index 2e9c3a5bf3ee..89ee96317ac9 100644 --- a/compiler/rustc_mir_transform/src/copy_prop.rs +++ b/compiler/rustc_mir_transform/src/copy_prop.rs @@ -16,7 +16,7 @@ /// _d = move? _c /// where each of the locals is only assigned once. /// -/// We want to replace all those locals by `_a`, either copied or moved. +/// We want to replace all those locals by `copy _a`. pub(super) struct CopyProp; impl<'tcx> crate::MirPass<'tcx> for CopyProp { @@ -34,11 +34,13 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { debug!(copy_classes = ?ssa.copy_classes()); let mut any_replacement = false; - let mut storage_to_remove = DenseBitSet::new_empty(body.local_decls.len()); + // Locals that participate in copy propagation either as a source or a destination. + let mut unified = DenseBitSet::new_empty(body.local_decls.len()); for (local, &head) in ssa.copy_classes().iter_enumerated() { if local != head { any_replacement = true; - storage_to_remove.insert(head); + unified.insert(head); + unified.insert(local); } } @@ -46,11 +48,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { return; } - let fully_moved = fully_moved_locals(&ssa, body); - debug!(?fully_moved); - - Replacer { tcx, copy_classes: ssa.copy_classes(), fully_moved, storage_to_remove } - .visit_body_preserves_cfg(body); + Replacer { tcx, copy_classes: ssa.copy_classes(), unified }.visit_body_preserves_cfg(body); crate::simplify::remove_unused_definitions(body); } @@ -60,44 +58,10 @@ fn is_required(&self) -> bool { } } -/// `SsaLocals` computed equivalence classes between locals considering copy/move assignments. -/// -/// This function also returns whether all the `move?` in the pattern are `move` and not copies. -/// A local which is in the bitset can be replaced by `move _a`. Otherwise, it must be -/// replaced by `copy _a`, as we cannot move multiple times from `_a`. -/// -/// If an operand copies `_c`, it must happen before the assignment `_d = _c`, otherwise it is UB. -/// This means that replacing it by a copy of `_a` if ok, since this copy happens before `_c` is -/// moved, and therefore that `_d` is moved. -#[instrument(level = "trace", skip(ssa, body))] -fn fully_moved_locals(ssa: &SsaLocals, body: &Body<'_>) -> DenseBitSet { - let mut fully_moved = DenseBitSet::new_filled(body.local_decls.len()); - - for (_, rvalue, _) in ssa.assignments(body) { - let Rvalue::Use(Operand::Copy(place) | Operand::Move(place)) = rvalue else { - continue; - }; - - let Some(rhs) = place.as_local() else { continue }; - if !ssa.is_ssa(rhs) { - continue; - } - - if let Rvalue::Use(Operand::Copy(_)) = rvalue { - fully_moved.remove(rhs); - } - } - - ssa.meet_copy_equivalence(&mut fully_moved); - - fully_moved -} - /// Utility to help performing substitution of `*pattern` by `target`. struct Replacer<'a, 'tcx> { tcx: TyCtxt<'tcx>, - fully_moved: DenseBitSet, - storage_to_remove: DenseBitSet, + unified: DenseBitSet, copy_classes: &'a IndexSlice, } @@ -108,13 +72,7 @@ fn tcx(&self) -> TyCtxt<'tcx> { #[tracing::instrument(level = "trace", skip(self))] fn visit_local(&mut self, local: &mut Local, ctxt: PlaceContext, _: Location) { - let new_local = self.copy_classes[*local]; - match ctxt { - // Do not modify the local in storage statements. - PlaceContext::NonUse(NonUseContext::StorageLive | NonUseContext::StorageDead) => {} - // We access the value. - _ => *local = new_local, - } + *local = self.copy_classes[*local]; } #[tracing::instrument(level = "trace", skip(self))] @@ -123,7 +81,7 @@ fn visit_operand(&mut self, operand: &mut Operand<'tcx>, loc: Location) { // A move out of a projection of a copy is equivalent to a copy of the original // projection. && !place.is_indirect_first_projection() - && !self.fully_moved.contains(place.local) + && self.unified.contains(place.local) { *operand = Operand::Copy(place); } @@ -134,10 +92,9 @@ fn visit_operand(&mut self, operand: &mut Operand<'tcx>, loc: Location) { fn visit_statement(&mut self, stmt: &mut Statement<'tcx>, loc: Location) { // When removing storage statements, we need to remove both (#107511). if let StatementKind::StorageLive(l) | StatementKind::StorageDead(l) = stmt.kind - && self.storage_to_remove.contains(l) + && self.unified.contains(l) { stmt.make_nop(true); - return; } self.super_statement(stmt, loc); diff --git a/tests/codegen-llvm/align-byval.rs b/tests/codegen-llvm/align-byval.rs index 2d6fc0d1e78d..fd238534a335 100644 --- a/tests/codegen-llvm/align-byval.rs +++ b/tests/codegen-llvm/align-byval.rs @@ -1,7 +1,7 @@ // ignore-tidy-linelength //@ add-minicore //@ revisions:m68k x86_64-linux x86_64-windows i686-linux i686-windows - +//@ compile-flags: -Copt-level=1 -Cno-prepopulate-passes //@[m68k] compile-flags: --target m68k-unknown-linux-gnu //@[m68k] needs-llvm-components: m68k //@[x86_64-linux] compile-flags: --target x86_64-unknown-linux-gnu diff --git a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-abort.diff deleted file mode 100644 index da9904bfa01f..000000000000 --- a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-abort.diff +++ /dev/null @@ -1,37 +0,0 @@ -- // MIR for `f` before CopyProp -+ // MIR for `f` after CopyProp - - fn f(_1: T) -> () { - debug a => _1; - let mut _0: (); - let _2: T; - let _3: (); - let mut _4: T; - let mut _5: T; - scope 1 { -- debug b => _2; -+ debug b => _1; - } - - bb0: { -- StorageLive(_2); -- _2 = copy _1; - StorageLive(_3); -- StorageLive(_4); -- _4 = copy _1; -- StorageLive(_5); -- _5 = copy _2; -- _3 = g::(move _4, move _5) -> [return: bb1, unwind unreachable]; -+ _3 = g::(copy _1, copy _1) -> [return: bb1, unwind unreachable]; - } - - bb1: { -- StorageDead(_5); -- StorageDead(_4); - StorageDead(_3); - _0 = const (); -- StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff deleted file mode 100644 index 9b0de655bd26..000000000000 --- a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff +++ /dev/null @@ -1,37 +0,0 @@ -- // MIR for `f` before CopyProp -+ // MIR for `f` after CopyProp - - fn f(_1: T) -> () { - debug a => _1; - let mut _0: (); - let _2: T; - let _3: (); - let mut _4: T; - let mut _5: T; - scope 1 { -- debug b => _2; -+ debug b => _1; - } - - bb0: { -- StorageLive(_2); -- _2 = copy _1; - StorageLive(_3); -- StorageLive(_4); -- _4 = copy _1; -- StorageLive(_5); -- _5 = copy _2; -- _3 = g::(move _4, move _5) -> [return: bb1, unwind continue]; -+ _3 = g::(copy _1, copy _1) -> [return: bb1, unwind continue]; - } - - bb1: { -- StorageDead(_5); -- StorageDead(_4); - StorageDead(_3); - _0 = const (); -- StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/copy-prop/move_arg.rs b/tests/mir-opt/copy-prop/move_arg.rs index b7adae333196..23e20021f588 100644 --- a/tests/mir-opt/copy-prop/move_arg.rs +++ b/tests/mir-opt/copy-prop/move_arg.rs @@ -1,20 +1,46 @@ -// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Test that we do not move multiple times from the same local. //@ test-mir-pass: CopyProp +//@ compile-flags: --crate-type=lib -Cpanic=abort +#![feature(custom_mir, core_intrinsics)] +use core::intrinsics::mir::*; +use core::mem::MaybeUninit; +extern crate core; -// EMIT_MIR move_arg.f.CopyProp.diff -pub fn f(a: T) { - // CHECK-LABEL: fn f( - // CHECK: debug a => [[a:_.*]]; - // CHECK: debug b => [[a]]; - // CHECK: g::(copy [[a]], copy [[a]]) - let b = a; - g(a, b); +#[custom_mir(dialect = "runtime", phase = "initial")] +pub fn moved_and_copied(_1: T) { + // CHECK-LABEL: fn moved_and_copied( + // CHECK: _0 = f::(copy _1, copy _1) + mir! { + { + let _2 = _1; + Call(RET = f(Move(_1), Move(_2)), ReturnTo(bb1), UnwindUnreachable()) + } + bb1 = { + Return() + } + } +} + +#[custom_mir(dialect = "runtime", phase = "initial")] +pub fn moved_twice(_1: MaybeUninit) { + // In a future we would like to propagate moves instead of copies here. The resulting program + // would have an undefined behavior due to overlap in a call terminator, so we need to change + // operational semantics to explain why the original program has undefined behavior. + // https://github.com/rust-lang/unsafe-code-guidelines/issues/556 + // + // CHECK-LABEL: fn moved_twice( + // CHECK: _0 = f::>(copy _1, copy _1) + mir! { + { + let _2 = Move(_1); + let _3 = Move(_1); + Call(RET = f(Move(_2), Move(_3)), ReturnTo(bb1), UnwindUnreachable()) + } + bb1 = { + Return() + } + } } #[inline(never)] -pub fn g(_: T, _: T) {} - -fn main() { - f(5) -} +pub fn f(_: T, _: T) {} diff --git a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff index 2026c1982f29..8ef61b5667dd 100644 --- a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-abort.diff @@ -31,7 +31,7 @@ - StorageLive(_6); - _6 = move _4; - _5 = opaque::<&mut u8>(move _6) -> [return: bb1, unwind unreachable]; -+ _5 = opaque::<&mut u8>(move _2) -> [return: bb1, unwind unreachable]; ++ _5 = opaque::<&mut u8>(copy _2) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff index 67763fdce667..2a7182af984d 100644 --- a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff @@ -31,7 +31,7 @@ - StorageLive(_6); - _6 = move _4; - _5 = opaque::<&mut u8>(move _6) -> [return: bb1, unwind continue]; -+ _5 = opaque::<&mut u8>(move _2) -> [return: bb1, unwind continue]; ++ _5 = opaque::<&mut u8>(copy _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff index dfc8dd097563..8a2cdd8e5728 100644 --- a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-abort.diff @@ -31,7 +31,7 @@ - StorageLive(_6); - _6 = move _4; - _5 = opaque::<&mut u8>(move _6) -> [return: bb1, unwind unreachable]; -+ _5 = opaque::<&mut u8>(move _2) -> [return: bb1, unwind unreachable]; ++ _5 = opaque::<&mut u8>(copy _2) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff index becc42563210..614d23cf6245 100644 --- a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff @@ -31,7 +31,7 @@ - StorageLive(_6); - _6 = move _4; - _5 = opaque::<&mut u8>(move _6) -> [return: bb1, unwind continue]; -+ _5 = opaque::<&mut u8>(move _2) -> [return: bb1, unwind continue]; ++ _5 = opaque::<&mut u8>(copy _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/ui/lint/large_assignments/inline_mir.rs b/tests/ui/lint/large_assignments/inline_mir.rs index fc27b8ff244d..d16aae6ab145 100644 --- a/tests/ui/lint/large_assignments/inline_mir.rs +++ b/tests/ui/lint/large_assignments/inline_mir.rs @@ -20,5 +20,5 @@ pub fn main() { let data = [10u8; 9999]; let cell = std::cell::UnsafeCell::new(data); //~ ERROR large_assignments - std::hint::black_box(cell); + std::hint::black_box(cell); //~ ERROR large_assignments } diff --git a/tests/ui/lint/large_assignments/inline_mir.stderr b/tests/ui/lint/large_assignments/inline_mir.stderr index d9010e24d03b..1a5fcb6c8fc1 100644 --- a/tests/ui/lint/large_assignments/inline_mir.stderr +++ b/tests/ui/lint/large_assignments/inline_mir.stderr @@ -11,5 +11,13 @@ note: the lint level is defined here LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: moving 9999 bytes + --> $DIR/inline_mir.rs:23:5 + | +LL | std::hint::black_box(cell); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: aborting due to 2 previous errors diff --git a/tests/ui/lint/large_assignments/move_into_fn.rs b/tests/ui/lint/large_assignments/move_into_fn.rs index 73ec08fa23a7..b3b2160ca36e 100644 --- a/tests/ui/lint/large_assignments/move_into_fn.rs +++ b/tests/ui/lint/large_assignments/move_into_fn.rs @@ -16,7 +16,7 @@ fn main() { // Looking at llvm-ir output, we can see that there is no memcpy involved in // this function call. Instead, just a pointer is passed to the function. So // the lint shall not trigger here. - take_data(data); + take_data(data); //~ ERROR large_assignments } fn take_data(data: Data) {} diff --git a/tests/ui/lint/large_assignments/move_into_fn.stderr b/tests/ui/lint/large_assignments/move_into_fn.stderr index 92a0489e472f..19ec6a51d2e7 100644 --- a/tests/ui/lint/large_assignments/move_into_fn.stderr +++ b/tests/ui/lint/large_assignments/move_into_fn.stderr @@ -11,5 +11,13 @@ note: the lint level is defined here LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: moving 9999 bytes + --> $DIR/move_into_fn.rs:19:15 + | +LL | take_data(data); + | ^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: aborting due to 2 previous errors From 3a56d492decfcb38a1e93a13f5c428aa2550e3a7 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 20 Nov 2025 11:12:31 -0800 Subject: [PATCH 110/194] library: upgrade to hashbrown v0.16.1 --- library/Cargo.lock | 11 +++++++++-- library/std/Cargo.toml | 2 +- library/std/src/collections/hash/map.rs | 4 ++-- src/tools/tidy/src/deps.rs | 2 ++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/library/Cargo.lock b/library/Cargo.lock index b062b505cb24..8f60cea459c7 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -88,6 +88,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "fortanix-sgx-abi" version = "0.6.1" @@ -119,10 +125,11 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ + "foldhash", "rustc-std-workspace-alloc", "rustc-std-workspace-core", ] diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 1ba9f7e32d91..3a673cf23b83 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -20,7 +20,7 @@ panic_unwind = { path = "../panic_unwind", optional = true } panic_abort = { path = "../panic_abort" } core = { path = "../core", public = true } unwind = { path = "../unwind" } -hashbrown = { version = "0.15", default-features = false, features = [ +hashbrown = { version = "0.16.1", default-features = false, features = [ 'rustc-dep-of-std', ] } std_detect = { path = "../std_detect", public = true } diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index ab21e3b927e2..251d62bd2033 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -1051,7 +1051,7 @@ pub fn get_disjoint_mut( K: Borrow, Q: Hash + Eq, { - self.base.get_many_mut(ks) + self.base.get_disjoint_mut(ks) } /// Attempts to get mutable references to `N` values in the map at once, without validating that @@ -1118,7 +1118,7 @@ pub unsafe fn get_disjoint_unchecked_mut( K: Borrow, Q: Hash + Eq, { - unsafe { self.base.get_many_unchecked_mut(ks) } + unsafe { self.base.get_disjoint_unchecked_mut(ks) } } /// Returns `true` if the map contains a value for the specified key. diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 93d38d929c6d..9b586e158ad6 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -42,6 +42,7 @@ "MIT/Apache-2.0", "Unlicense OR MIT", "Unlicense/MIT", + "Zlib", // foldhash (FIXME: see PERMITTED_STDLIB_DEPENDENCIES) // tidy-alphabetical-end ]; @@ -509,6 +510,7 @@ macro_rules! location { "cfg-if", "compiler_builtins", "dlmalloc", + "foldhash", // FIXME: only appears in Cargo.lock due to https://github.com/rust-lang/cargo/issues/10801 "fortanix-sgx-abi", "getopts", "gimli", From ebf1c38aa67f113c3a638fe467c75b0b154c903c Mon Sep 17 00:00:00 2001 From: Max Dexheimer Date: Thu, 20 Nov 2025 21:25:19 +0100 Subject: [PATCH 111/194] Check for intrinsic to fn ptr casts in unified coercions Ensures that when coercing multiple expressions to a unified type, the same "intrinsic to fn ptr" check is applied as for other coercions. --- compiler/rustc_hir_typeck/src/coercion.rs | 16 +++++++++-- .../intrinsic-in-unifying-coercion-149143.rs | 25 +++++++++++++++++ ...trinsic-in-unifying-coercion-149143.stderr | 27 +++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 tests/ui/coercion/intrinsic-in-unifying-coercion-149143.rs create mode 100644 tests/ui/coercion/intrinsic-in-unifying-coercion-149143.stderr diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 857e4f66489a..009caad51eac 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1291,14 +1291,26 @@ fn try_find_coercion_lub( ty::Closure(..) => { Adjust::Pointer(PointerCoercion::ClosureFnPointer(a_sig.safety())) } - ty::FnDef(..) => Adjust::Pointer(PointerCoercion::ReifyFnPointer), + ty::FnDef(def_id, ..) => { + // Intrinsics are not coercible to function pointers + if self.tcx.intrinsic(def_id).is_some() { + return Err(TypeError::IntrinsicCast); + } + Adjust::Pointer(PointerCoercion::ReifyFnPointer) + } _ => span_bug!(cause.span, "should not try to coerce a {prev_ty} to a fn pointer"), }; let next_adjustment = match new_ty.kind() { ty::Closure(..) => { Adjust::Pointer(PointerCoercion::ClosureFnPointer(b_sig.safety())) } - ty::FnDef(..) => Adjust::Pointer(PointerCoercion::ReifyFnPointer), + ty::FnDef(def_id, ..) => { + // Intrinsics are not coercible to function pointers + if self.tcx.intrinsic(def_id).is_some() { + return Err(TypeError::IntrinsicCast); + } + Adjust::Pointer(PointerCoercion::ReifyFnPointer) + } _ => span_bug!(new.span, "should not try to coerce a {new_ty} to a fn pointer"), }; for expr in exprs.iter().map(|e| e.as_coercion_site()) { diff --git a/tests/ui/coercion/intrinsic-in-unifying-coercion-149143.rs b/tests/ui/coercion/intrinsic-in-unifying-coercion-149143.rs new file mode 100644 index 000000000000..f20a491916f6 --- /dev/null +++ b/tests/ui/coercion/intrinsic-in-unifying-coercion-149143.rs @@ -0,0 +1,25 @@ +// Regression test for #149143. +// The compiler did not check for a coercion from intrinsics +// to fn ptrs in all possible code paths that could lead to such a coercion. +// This caused an ICE during a later sanity check. + +use std::mem::transmute; + +fn main() { + unsafe { + let f = if true { transmute } else { safe_transmute }; + //~^ ERROR `if` and `else` have incompatible type + + let _: i64 = f(5i64); + } + unsafe { + let f = if true { safe_transmute } else { transmute }; + //~^ ERROR `if` and `else` have incompatible type + + let _: i64 = f(5i64); + } +} + +unsafe fn safe_transmute(x: A) -> B { + panic!() +} diff --git a/tests/ui/coercion/intrinsic-in-unifying-coercion-149143.stderr b/tests/ui/coercion/intrinsic-in-unifying-coercion-149143.stderr new file mode 100644 index 000000000000..43fc194deea2 --- /dev/null +++ b/tests/ui/coercion/intrinsic-in-unifying-coercion-149143.stderr @@ -0,0 +1,27 @@ +error[E0308]: `if` and `else` have incompatible types + --> $DIR/intrinsic-in-unifying-coercion-149143.rs:10:46 + | +LL | let f = if true { transmute } else { safe_transmute }; + | --------- ^^^^^^^^^^^^^^ cannot coerce intrinsics to function pointers + | | + | expected because of this + | + = note: expected fn item `unsafe fn(_) -> _ {std::intrinsics::transmute::<_, _>}` + found fn item `unsafe fn(_) -> _ {safe_transmute::<_, _>}` + = note: different fn items have unique types, even if their signatures are the same + +error[E0308]: `if` and `else` have incompatible types + --> $DIR/intrinsic-in-unifying-coercion-149143.rs:16:51 + | +LL | let f = if true { safe_transmute } else { transmute }; + | -------------- ^^^^^^^^^ cannot coerce intrinsics to function pointers + | | + | expected because of this + | + = note: expected fn item `unsafe fn(_) -> _ {safe_transmute::<_, _>}` + found fn item `unsafe fn(_) -> _ {std::intrinsics::transmute::<_, _>}` + = note: different fn items have unique types, even if their signatures are the same + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. From c81d22d5066d3e04861bdd6b44c9c6facacc2e93 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 11 Nov 2025 17:44:29 +1100 Subject: [PATCH 112/194] Extract module `rustc_session::config::print_request` --- compiler/rustc_session/src/config.rs | 181 +---------------- .../rustc_session/src/config/print_request.rs | 185 ++++++++++++++++++ 2 files changed, 189 insertions(+), 177 deletions(-) create mode 100644 compiler/rustc_session/src/config/print_request.rs diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index b229db1a4b16..f97a29e064b6 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -36,6 +36,7 @@ pub use crate::config::cfg::{Cfg, CheckCfg, ExpectedValues}; use crate::config::native_libs::parse_native_libs; +pub use crate::config::print_request::{PrintKind, PrintRequest}; use crate::errors::FileWriteFail; pub use crate::options::*; use crate::search_paths::SearchPath; @@ -45,37 +46,9 @@ mod cfg; mod externs; mod native_libs; +mod print_request; pub mod sigpipe; -pub const PRINT_KINDS: &[(&str, PrintKind)] = &[ - // tidy-alphabetical-start - ("all-target-specs-json", PrintKind::AllTargetSpecsJson), - ("calling-conventions", PrintKind::CallingConventions), - ("cfg", PrintKind::Cfg), - ("check-cfg", PrintKind::CheckCfg), - ("code-models", PrintKind::CodeModels), - ("crate-name", PrintKind::CrateName), - ("crate-root-lint-levels", PrintKind::CrateRootLintLevels), - ("deployment-target", PrintKind::DeploymentTarget), - ("file-names", PrintKind::FileNames), - ("host-tuple", PrintKind::HostTuple), - ("link-args", PrintKind::LinkArgs), - ("native-static-libs", PrintKind::NativeStaticLibs), - ("relocation-models", PrintKind::RelocationModels), - ("split-debuginfo", PrintKind::SplitDebuginfo), - ("stack-protector-strategies", PrintKind::StackProtectorStrategies), - ("supported-crate-types", PrintKind::SupportedCrateTypes), - ("sysroot", PrintKind::Sysroot), - ("target-cpus", PrintKind::TargetCPUs), - ("target-features", PrintKind::TargetFeatures), - ("target-libdir", PrintKind::TargetLibdir), - ("target-list", PrintKind::TargetList), - ("target-spec-json", PrintKind::TargetSpecJson), - ("target-spec-json-schema", PrintKind::TargetSpecJsonSchema), - ("tls-models", PrintKind::TlsModels), - // tidy-alphabetical-end -]; - /// The different settings that the `-C strip` flag can have. #[derive(Clone, Copy, PartialEq, Hash, Debug)] pub enum Strip { @@ -1015,42 +988,6 @@ pub fn files(&self) -> Option> { } } -#[derive(Clone, PartialEq, Debug)] -pub struct PrintRequest { - pub kind: PrintKind, - pub out: OutFileName, -} - -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -pub enum PrintKind { - // tidy-alphabetical-start - AllTargetSpecsJson, - CallingConventions, - Cfg, - CheckCfg, - CodeModels, - CrateName, - CrateRootLintLevels, - DeploymentTarget, - FileNames, - HostTuple, - LinkArgs, - NativeStaticLibs, - RelocationModels, - SplitDebuginfo, - StackProtectorStrategies, - SupportedCrateTypes, - Sysroot, - TargetCPUs, - TargetFeatures, - TargetLibdir, - TargetList, - TargetSpecJson, - TargetSpecJsonSchema, - TlsModels, - // tidy-alphabetical-end -} - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Default)] pub struct NextSolverConfig { /// Whether the new trait solver should be enabled in coherence. @@ -1798,14 +1735,6 @@ pub fn make_opt( ) }); -static PRINT_HELP: LazyLock = LazyLock::new(|| { - format!( - "Compiler information to print on stdout (or to a file)\n\ - INFO may be one of <{}>.", - PRINT_KINDS.iter().map(|(name, _)| format!("{name}")).collect::>().join("|") - ) -}); - static EMIT_HELP: LazyLock = LazyLock::new(|| { let mut result = String::from("Comma separated list of types of output for the compiler to emit.\n"); @@ -1872,7 +1801,7 @@ pub fn rustc_optgroups() -> Vec { opt(Stable, Opt, "", "crate-name", "Specify the name of the crate being built", ""), opt(Stable, Opt, "", "edition", &EDITION_STRING, EDITION_NAME_LIST), opt(Stable, Multi, "", "emit", &EMIT_HELP, "[=]"), - opt(Stable, Multi, "", "print", &PRINT_HELP, "[=]"), + opt(Stable, Multi, "", "print", &print_request::PRINT_HELP, "[=]"), opt(Stable, FlagMulti, "g", "", "Equivalent to -C debuginfo=2", ""), opt(Stable, FlagMulti, "O", "", "Equivalent to -C opt-level=3", ""), opt(Stable, Opt, "o", "", "Write output to FILENAME", ""), @@ -2320,108 +2249,6 @@ fn should_override_cgus_and_disable_thinlto( (disable_local_thinlto, codegen_units) } -fn collect_print_requests( - early_dcx: &EarlyDiagCtxt, - cg: &mut CodegenOptions, - unstable_opts: &UnstableOptions, - matches: &getopts::Matches, -) -> Vec { - let mut prints = Vec::::new(); - if cg.target_cpu.as_deref() == Some("help") { - prints.push(PrintRequest { kind: PrintKind::TargetCPUs, out: OutFileName::Stdout }); - cg.target_cpu = None; - }; - if cg.target_feature == "help" { - prints.push(PrintRequest { kind: PrintKind::TargetFeatures, out: OutFileName::Stdout }); - cg.target_feature = String::new(); - } - - // We disallow reusing the same path in multiple prints, such as `--print - // cfg=output.txt --print link-args=output.txt`, because outputs are printed - // by disparate pieces of the compiler, and keeping track of which files - // need to be overwritten vs appended to is annoying. - let mut printed_paths = FxHashSet::default(); - - prints.extend(matches.opt_strs("print").into_iter().map(|req| { - let (req, out) = split_out_file_name(&req); - - let kind = if let Some((print_name, print_kind)) = - PRINT_KINDS.iter().find(|&&(name, _)| name == req) - { - check_print_request_stability(early_dcx, unstable_opts, (print_name, *print_kind)); - *print_kind - } else { - let is_nightly = nightly_options::match_is_nightly_build(matches); - emit_unknown_print_request_help(early_dcx, req, is_nightly) - }; - - let out = out.unwrap_or(OutFileName::Stdout); - if let OutFileName::Real(path) = &out { - if !printed_paths.insert(path.clone()) { - early_dcx.early_fatal(format!( - "cannot print multiple outputs to the same path: {}", - path.display(), - )); - } - } - - PrintRequest { kind, out } - })); - - prints -} - -fn check_print_request_stability( - early_dcx: &EarlyDiagCtxt, - unstable_opts: &UnstableOptions, - (print_name, print_kind): (&str, PrintKind), -) { - if !is_print_request_stable(print_kind) && !unstable_opts.unstable_options { - early_dcx.early_fatal(format!( - "the `-Z unstable-options` flag must also be passed to enable the `{print_name}` \ - print option" - )); - } -} - -fn is_print_request_stable(print_kind: PrintKind) -> bool { - match print_kind { - PrintKind::AllTargetSpecsJson - | PrintKind::CheckCfg - | PrintKind::CrateRootLintLevels - | PrintKind::SupportedCrateTypes - | PrintKind::TargetSpecJson - | PrintKind::TargetSpecJsonSchema => false, - _ => true, - } -} - -fn emit_unknown_print_request_help(early_dcx: &EarlyDiagCtxt, req: &str, is_nightly: bool) -> ! { - let prints = PRINT_KINDS - .iter() - .filter_map(|(name, kind)| { - // If we're not on nightly, we don't want to print unstable options - if !is_nightly && !is_print_request_stable(*kind) { - None - } else { - Some(format!("`{name}`")) - } - }) - .collect::>(); - let prints = prints.join(", "); - - let mut diag = early_dcx.early_struct_fatal(format!("unknown print request: `{req}`")); - #[allow(rustc::diagnostic_outside_of_impl)] - diag.help(format!("valid print requests are: {prints}")); - - if req == "lints" { - diag.help(format!("use `-Whelp` to print a list of lints")); - } - - diag.help(format!("for more information, see the rustc book: https://doc.rust-lang.org/rustc/command-line-arguments.html#--print-print-compiler-information")); - diag.emit() -} - pub fn parse_target_triple(early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches) -> TargetTuple { match matches.opt_str("target") { Some(target) if target.ends_with(".json") => { @@ -2846,7 +2673,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M )); } - let prints = collect_print_requests(early_dcx, &mut cg, &unstable_opts, matches); + let prints = print_request::collect_print_requests(early_dcx, &mut cg, &unstable_opts, matches); // -Zretpoline-external-thunk also requires -Zretpoline if unstable_opts.retpoline_external_thunk { diff --git a/compiler/rustc_session/src/config/print_request.rs b/compiler/rustc_session/src/config/print_request.rs new file mode 100644 index 000000000000..6226a8aee7d3 --- /dev/null +++ b/compiler/rustc_session/src/config/print_request.rs @@ -0,0 +1,185 @@ +//! Code for dealing with `--print` requests. + +use std::sync::LazyLock; + +use rustc_data_structures::fx::FxHashSet; + +use crate::EarlyDiagCtxt; +use crate::config::{ + CodegenOptions, OutFileName, UnstableOptions, nightly_options, split_out_file_name, +}; + +const PRINT_KINDS: &[(&str, PrintKind)] = &[ + // tidy-alphabetical-start + ("all-target-specs-json", PrintKind::AllTargetSpecsJson), + ("calling-conventions", PrintKind::CallingConventions), + ("cfg", PrintKind::Cfg), + ("check-cfg", PrintKind::CheckCfg), + ("code-models", PrintKind::CodeModels), + ("crate-name", PrintKind::CrateName), + ("crate-root-lint-levels", PrintKind::CrateRootLintLevels), + ("deployment-target", PrintKind::DeploymentTarget), + ("file-names", PrintKind::FileNames), + ("host-tuple", PrintKind::HostTuple), + ("link-args", PrintKind::LinkArgs), + ("native-static-libs", PrintKind::NativeStaticLibs), + ("relocation-models", PrintKind::RelocationModels), + ("split-debuginfo", PrintKind::SplitDebuginfo), + ("stack-protector-strategies", PrintKind::StackProtectorStrategies), + ("supported-crate-types", PrintKind::SupportedCrateTypes), + ("sysroot", PrintKind::Sysroot), + ("target-cpus", PrintKind::TargetCPUs), + ("target-features", PrintKind::TargetFeatures), + ("target-libdir", PrintKind::TargetLibdir), + ("target-list", PrintKind::TargetList), + ("target-spec-json", PrintKind::TargetSpecJson), + ("target-spec-json-schema", PrintKind::TargetSpecJsonSchema), + ("tls-models", PrintKind::TlsModels), + // tidy-alphabetical-end +]; + +#[derive(Clone, PartialEq, Debug)] +pub struct PrintRequest { + pub kind: PrintKind, + pub out: OutFileName, +} + +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub enum PrintKind { + // tidy-alphabetical-start + AllTargetSpecsJson, + CallingConventions, + Cfg, + CheckCfg, + CodeModels, + CrateName, + CrateRootLintLevels, + DeploymentTarget, + FileNames, + HostTuple, + LinkArgs, + NativeStaticLibs, + RelocationModels, + SplitDebuginfo, + StackProtectorStrategies, + SupportedCrateTypes, + Sysroot, + TargetCPUs, + TargetFeatures, + TargetLibdir, + TargetList, + TargetSpecJson, + TargetSpecJsonSchema, + TlsModels, + // tidy-alphabetical-end +} + +pub(crate) static PRINT_HELP: LazyLock = LazyLock::new(|| { + format!( + "Compiler information to print on stdout (or to a file)\n\ + INFO may be one of <{}>.", + PRINT_KINDS.iter().map(|(name, _)| format!("{name}")).collect::>().join("|") + ) +}); + +pub(crate) fn collect_print_requests( + early_dcx: &EarlyDiagCtxt, + cg: &mut CodegenOptions, + unstable_opts: &UnstableOptions, + matches: &getopts::Matches, +) -> Vec { + let mut prints = Vec::::new(); + if cg.target_cpu.as_deref() == Some("help") { + prints.push(PrintRequest { kind: PrintKind::TargetCPUs, out: OutFileName::Stdout }); + cg.target_cpu = None; + }; + if cg.target_feature == "help" { + prints.push(PrintRequest { kind: PrintKind::TargetFeatures, out: OutFileName::Stdout }); + cg.target_feature = String::new(); + } + + // We disallow reusing the same path in multiple prints, such as `--print + // cfg=output.txt --print link-args=output.txt`, because outputs are printed + // by disparate pieces of the compiler, and keeping track of which files + // need to be overwritten vs appended to is annoying. + let mut printed_paths = FxHashSet::default(); + + prints.extend(matches.opt_strs("print").into_iter().map(|req| { + let (req, out) = split_out_file_name(&req); + + let kind = if let Some((print_name, print_kind)) = + PRINT_KINDS.iter().find(|&&(name, _)| name == req) + { + check_print_request_stability(early_dcx, unstable_opts, (print_name, *print_kind)); + *print_kind + } else { + let is_nightly = nightly_options::match_is_nightly_build(matches); + emit_unknown_print_request_help(early_dcx, req, is_nightly) + }; + + let out = out.unwrap_or(OutFileName::Stdout); + if let OutFileName::Real(path) = &out { + if !printed_paths.insert(path.clone()) { + early_dcx.early_fatal(format!( + "cannot print multiple outputs to the same path: {}", + path.display(), + )); + } + } + + PrintRequest { kind, out } + })); + + prints +} + +fn check_print_request_stability( + early_dcx: &EarlyDiagCtxt, + unstable_opts: &UnstableOptions, + (print_name, print_kind): (&str, PrintKind), +) { + if !is_print_request_stable(print_kind) && !unstable_opts.unstable_options { + early_dcx.early_fatal(format!( + "the `-Z unstable-options` flag must also be passed to enable the `{print_name}` \ + print option" + )); + } +} + +fn is_print_request_stable(print_kind: PrintKind) -> bool { + match print_kind { + PrintKind::AllTargetSpecsJson + | PrintKind::CheckCfg + | PrintKind::CrateRootLintLevels + | PrintKind::SupportedCrateTypes + | PrintKind::TargetSpecJson + | PrintKind::TargetSpecJsonSchema => false, + _ => true, + } +} + +fn emit_unknown_print_request_help(early_dcx: &EarlyDiagCtxt, req: &str, is_nightly: bool) -> ! { + let prints = PRINT_KINDS + .iter() + .filter_map(|(name, kind)| { + // If we're not on nightly, we don't want to print unstable options + if !is_nightly && !is_print_request_stable(*kind) { + None + } else { + Some(format!("`{name}`")) + } + }) + .collect::>(); + let prints = prints.join(", "); + + let mut diag = early_dcx.early_struct_fatal(format!("unknown print request: `{req}`")); + #[allow(rustc::diagnostic_outside_of_impl)] + diag.help(format!("valid print requests are: {prints}")); + + if req == "lints" { + diag.help(format!("use `-Whelp` to print a list of lints")); + } + + diag.help(format!("for more information, see the rustc book: https://doc.rust-lang.org/rustc/command-line-arguments.html#--print-print-compiler-information")); + diag.emit() +} From 9c7e7ccd25ec8f89dfe5f64417ce466d2ace2dc4 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 11 Nov 2025 21:20:46 +1100 Subject: [PATCH 113/194] Exhaustively specify names and stability of `--print` values --- .../rustc_session/src/config/print_request.rs | 163 +++++++++++------- compiler/rustc_session/src/lib.rs | 2 + compiler/rustc_session/src/macros.rs | 27 +++ 3 files changed, 129 insertions(+), 63 deletions(-) create mode 100644 compiler/rustc_session/src/macros.rs diff --git a/compiler/rustc_session/src/config/print_request.rs b/compiler/rustc_session/src/config/print_request.rs index 6226a8aee7d3..b8111fbc17f8 100644 --- a/compiler/rustc_session/src/config/print_request.rs +++ b/compiler/rustc_session/src/config/print_request.rs @@ -1,5 +1,6 @@ //! Code for dealing with `--print` requests. +use std::fmt; use std::sync::LazyLock; use rustc_data_structures::fx::FxHashSet; @@ -8,35 +9,7 @@ use crate::config::{ CodegenOptions, OutFileName, UnstableOptions, nightly_options, split_out_file_name, }; - -const PRINT_KINDS: &[(&str, PrintKind)] = &[ - // tidy-alphabetical-start - ("all-target-specs-json", PrintKind::AllTargetSpecsJson), - ("calling-conventions", PrintKind::CallingConventions), - ("cfg", PrintKind::Cfg), - ("check-cfg", PrintKind::CheckCfg), - ("code-models", PrintKind::CodeModels), - ("crate-name", PrintKind::CrateName), - ("crate-root-lint-levels", PrintKind::CrateRootLintLevels), - ("deployment-target", PrintKind::DeploymentTarget), - ("file-names", PrintKind::FileNames), - ("host-tuple", PrintKind::HostTuple), - ("link-args", PrintKind::LinkArgs), - ("native-static-libs", PrintKind::NativeStaticLibs), - ("relocation-models", PrintKind::RelocationModels), - ("split-debuginfo", PrintKind::SplitDebuginfo), - ("stack-protector-strategies", PrintKind::StackProtectorStrategies), - ("supported-crate-types", PrintKind::SupportedCrateTypes), - ("sysroot", PrintKind::Sysroot), - ("target-cpus", PrintKind::TargetCPUs), - ("target-features", PrintKind::TargetFeatures), - ("target-libdir", PrintKind::TargetLibdir), - ("target-list", PrintKind::TargetList), - ("target-spec-json", PrintKind::TargetSpecJson), - ("target-spec-json-schema", PrintKind::TargetSpecJsonSchema), - ("tls-models", PrintKind::TlsModels), - // tidy-alphabetical-end -]; +use crate::macros::AllVariants; #[derive(Clone, PartialEq, Debug)] pub struct PrintRequest { @@ -45,6 +18,7 @@ pub struct PrintRequest { } #[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[derive(AllVariants)] pub enum PrintKind { // tidy-alphabetical-start AllTargetSpecsJson, @@ -74,11 +48,94 @@ pub enum PrintKind { // tidy-alphabetical-end } +impl PrintKind { + /// FIXME: rust-analyzer doesn't support `#![feature(macro_derive)]` yet + /// (), which breaks autocomplete. + /// Work around that by aliasing the trait constant to a regular constant. + const ALL_VARIANTS: &[Self] = ::ALL_VARIANTS; + + fn name(self) -> &'static str { + use PrintKind::*; + match self { + // tidy-alphabetical-start + AllTargetSpecsJson => "all-target-specs-json", + CallingConventions => "calling-conventions", + Cfg => "cfg", + CheckCfg => "check-cfg", + CodeModels => "code-models", + CrateName => "crate-name", + CrateRootLintLevels => "crate-root-lint-levels", + DeploymentTarget => "deployment-target", + FileNames => "file-names", + HostTuple => "host-tuple", + LinkArgs => "link-args", + NativeStaticLibs => "native-static-libs", + RelocationModels => "relocation-models", + SplitDebuginfo => "split-debuginfo", + StackProtectorStrategies => "stack-protector-strategies", + SupportedCrateTypes => "supported-crate-types", + Sysroot => "sysroot", + TargetCPUs => "target-cpus", + TargetFeatures => "target-features", + TargetLibdir => "target-libdir", + TargetList => "target-list", + TargetSpecJson => "target-spec-json", + TargetSpecJsonSchema => "target-spec-json-schema", + TlsModels => "tls-models", + // tidy-alphabetical-end + } + } + + fn is_stable(self) -> bool { + use PrintKind::*; + match self { + // Stable values: + CallingConventions + | Cfg + | CodeModels + | CrateName + | DeploymentTarget + | FileNames + | HostTuple + | LinkArgs + | NativeStaticLibs + | RelocationModels + | SplitDebuginfo + | StackProtectorStrategies + | Sysroot + | TargetCPUs + | TargetFeatures + | TargetLibdir + | TargetList + | TlsModels => true, + + // Unstable values: + AllTargetSpecsJson => false, + CheckCfg => false, + CrateRootLintLevels => false, + SupportedCrateTypes => false, + TargetSpecJson => false, + TargetSpecJsonSchema => false, + } + } + + fn from_str(s: &str) -> Option { + Self::ALL_VARIANTS.iter().find(|kind| kind.name() == s).copied() + } +} + +impl fmt::Display for PrintKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.name().fmt(f) + } +} + pub(crate) static PRINT_HELP: LazyLock = LazyLock::new(|| { + let print_kinds = + PrintKind::ALL_VARIANTS.iter().map(|kind| kind.name()).collect::>().join("|"); format!( "Compiler information to print on stdout (or to a file)\n\ - INFO may be one of <{}>.", - PRINT_KINDS.iter().map(|(name, _)| format!("{name}")).collect::>().join("|") + INFO may be one of <{print_kinds}>.", ) }); @@ -107,11 +164,9 @@ pub(crate) fn collect_print_requests( prints.extend(matches.opt_strs("print").into_iter().map(|req| { let (req, out) = split_out_file_name(&req); - let kind = if let Some((print_name, print_kind)) = - PRINT_KINDS.iter().find(|&&(name, _)| name == req) - { - check_print_request_stability(early_dcx, unstable_opts, (print_name, *print_kind)); - *print_kind + let kind = if let Some(print_kind) = PrintKind::from_str(req) { + check_print_request_stability(early_dcx, unstable_opts, print_kind); + print_kind } else { let is_nightly = nightly_options::match_is_nightly_build(matches); emit_unknown_print_request_help(early_dcx, req, is_nightly) @@ -136,41 +191,23 @@ pub(crate) fn collect_print_requests( fn check_print_request_stability( early_dcx: &EarlyDiagCtxt, unstable_opts: &UnstableOptions, - (print_name, print_kind): (&str, PrintKind), + print_kind: PrintKind, ) { - if !is_print_request_stable(print_kind) && !unstable_opts.unstable_options { + if !print_kind.is_stable() && !unstable_opts.unstable_options { early_dcx.early_fatal(format!( - "the `-Z unstable-options` flag must also be passed to enable the `{print_name}` \ - print option" + "the `-Z unstable-options` flag must also be passed to enable the `{print_kind}` print option" )); } } -fn is_print_request_stable(print_kind: PrintKind) -> bool { - match print_kind { - PrintKind::AllTargetSpecsJson - | PrintKind::CheckCfg - | PrintKind::CrateRootLintLevels - | PrintKind::SupportedCrateTypes - | PrintKind::TargetSpecJson - | PrintKind::TargetSpecJsonSchema => false, - _ => true, - } -} - fn emit_unknown_print_request_help(early_dcx: &EarlyDiagCtxt, req: &str, is_nightly: bool) -> ! { - let prints = PRINT_KINDS + let prints = PrintKind::ALL_VARIANTS .iter() - .filter_map(|(name, kind)| { - // If we're not on nightly, we don't want to print unstable options - if !is_nightly && !is_print_request_stable(*kind) { - None - } else { - Some(format!("`{name}`")) - } - }) - .collect::>(); - let prints = prints.join(", "); + // If we're not on nightly, we don't want to print unstable options + .filter(|kind| is_nightly || kind.is_stable()) + .map(|kind| format!("`{kind}`")) + .collect::>() + .join(", "); let mut diag = early_dcx.early_struct_fatal(format!("unknown print request: `{req}`")); #[allow(rustc::diagnostic_outside_of_impl)] diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs index 5e5872ee0681..90108e911044 100644 --- a/compiler/rustc_session/src/lib.rs +++ b/compiler/rustc_session/src/lib.rs @@ -2,6 +2,7 @@ #![allow(internal_features)] #![feature(default_field_values)] #![feature(iter_intersperse)] +#![feature(macro_derive)] #![feature(rustc_attrs)] // To generate CodegenOptionsTargetModifiers and UnstableOptionsTargetModifiers enums // with macro_rules, it is necessary to use recursive mechanic ("Incremental TT Munchers"). @@ -20,6 +21,7 @@ pub mod config; pub mod cstore; pub mod filesearch; +mod macros; mod options; pub mod search_paths; diff --git a/compiler/rustc_session/src/macros.rs b/compiler/rustc_session/src/macros.rs new file mode 100644 index 000000000000..8f9a12d00cc7 --- /dev/null +++ b/compiler/rustc_session/src/macros.rs @@ -0,0 +1,27 @@ +/// Derivable trait for enums with no fields (i.e. C-style enums) that want to +/// allow iteration over a list of all variant values. +pub(crate) trait AllVariants: Copy + 'static { + const ALL_VARIANTS: &[Self]; +} + +macro_rules! AllVariantsDerive { + derive() ( + $(#[$meta:meta])* + $vis:vis enum $Type:ident { + $( + $(#[$varmeta:meta])* + $Variant:ident $( = $value:literal )? + ), *$(,)? + } + ) => { + impl $crate::macros::AllVariants for $Type { + const ALL_VARIANTS: &[$Type] = &[ + $( $Type::$Variant, )* + ]; + } + }; +} + +// For some reason the compiler won't allow `pub(crate) use AllVariants` due +// to a conflict with the trait of the same name, but will allow this form. +pub(crate) use AllVariantsDerive as AllVariants; From 2c6b1d3430f52ba5ed614e92a38677354f562a68 Mon Sep 17 00:00:00 2001 From: yukang Date: Wed, 19 Nov 2025 21:53:26 +0800 Subject: [PATCH 114/194] Skip unused variables warning for unreachable code --- compiler/rustc_mir_transform/src/liveness.rs | 31 +++++++++++++ .../unused/unused-var-in-unreachable-code.rs | 46 +++++++++++++++++++ .../unused-var-in-unreachable-code.stderr | 14 ++++++ ...arly-return-with-unreachable-code-24353.rs | 1 - ...-return-with-unreachable-code-24353.stderr | 10 ---- 5 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 tests/ui/lint/unused/unused-var-in-unreachable-code.rs create mode 100644 tests/ui/lint/unused/unused-var-in-unreachable-code.stderr delete mode 100644 tests/ui/return/early-return-with-unreachable-code-24353.stderr diff --git a/compiler/rustc_mir_transform/src/liveness.rs b/compiler/rustc_mir_transform/src/liveness.rs index f7dc70356024..e047580d5bad 100644 --- a/compiler/rustc_mir_transform/src/liveness.rs +++ b/compiler/rustc_mir_transform/src/liveness.rs @@ -836,6 +836,33 @@ fn compute_dead_captures(&self, num_captures: usize) -> DenseBitSet { dead_captures } + /// Check if a local is referenced in any reachable basic block. + /// Variables in unreachable code (e.g., after `todo!()`) should not trigger unused warnings. + fn is_local_in_reachable_code(&self, local: Local) -> bool { + struct LocalVisitor { + target_local: Local, + found: bool, + } + + impl<'tcx> Visitor<'tcx> for LocalVisitor { + fn visit_local(&mut self, local: Local, _context: PlaceContext, _location: Location) { + if local == self.target_local { + self.found = true; + } + } + } + + let mut visitor = LocalVisitor { target_local: local, found: false }; + for (bb, bb_data) in traversal::postorder(self.body) { + visitor.visit_basic_block_data(bb, bb_data); + if visitor.found { + return true; + } + } + + false + } + /// Report fully unused locals, and forget the corresponding assignments. fn report_fully_unused(&mut self) { let tcx = self.tcx; @@ -927,6 +954,10 @@ fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, _: Location) { let statements = &mut self.assignments[index]; if statements.is_empty() { + if !self.is_local_in_reachable_code(local) { + continue; + } + let sugg = if from_macro { errors::UnusedVariableSugg::NoSugg { span: def_span, name } } else { diff --git a/tests/ui/lint/unused/unused-var-in-unreachable-code.rs b/tests/ui/lint/unused/unused-var-in-unreachable-code.rs new file mode 100644 index 000000000000..39c5e0315d9c --- /dev/null +++ b/tests/ui/lint/unused/unused-var-in-unreachable-code.rs @@ -0,0 +1,46 @@ +//@ check-pass + +#![allow(unreachable_code)] +#![allow(dead_code)] +#![warn(unused_variables)] + +fn after_todo() { + todo!("not implemented"); + + // This should not warn - the code is unreachable + let a = 1; + if a < 2 { + eprintln!("a: {}", a); + } +} + +fn after_panic() { + panic!("oops"); + + // This should not warn - the code is unreachable + let b = 2; + println!("{}", b); +} + +fn after_unimplemented() { + unimplemented!(); + + // This should not warn - the code is unreachable + let c = 3; + println!("{}", c); +} + +fn after_unreachable() { + unsafe { std::hint::unreachable_unchecked() } + + // This should not warn - the code is unreachable + let d = 4; + println!("{}", d); +} + +fn reachable_unused() { + // This SHOULD warn - the code is reachable + let e = 5; //~ WARN unused variable: `e` +} + +fn main() {} diff --git a/tests/ui/lint/unused/unused-var-in-unreachable-code.stderr b/tests/ui/lint/unused/unused-var-in-unreachable-code.stderr new file mode 100644 index 000000000000..dfc2f9c8fc56 --- /dev/null +++ b/tests/ui/lint/unused/unused-var-in-unreachable-code.stderr @@ -0,0 +1,14 @@ +warning: unused variable: `e` + --> $DIR/unused-var-in-unreachable-code.rs:43:9 + | +LL | let e = 5; + | ^ help: if this is intentional, prefix it with an underscore: `_e` + | +note: the lint level is defined here + --> $DIR/unused-var-in-unreachable-code.rs:5:9 + | +LL | #![warn(unused_variables)] + | ^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/return/early-return-with-unreachable-code-24353.rs b/tests/ui/return/early-return-with-unreachable-code-24353.rs index 41d77fea49ac..13add4652d99 100644 --- a/tests/ui/return/early-return-with-unreachable-code-24353.rs +++ b/tests/ui/return/early-return-with-unreachable-code-24353.rs @@ -4,7 +4,6 @@ fn main() { return (); let x = (); - //~^ WARN unused variable: `x` x } diff --git a/tests/ui/return/early-return-with-unreachable-code-24353.stderr b/tests/ui/return/early-return-with-unreachable-code-24353.stderr deleted file mode 100644 index 92526faef33b..000000000000 --- a/tests/ui/return/early-return-with-unreachable-code-24353.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: unused variable: `x` - --> $DIR/early-return-with-unreachable-code-24353.rs:6:9 - | -LL | let x = (); - | ^ help: if this is intentional, prefix it with an underscore: `_x` - | - = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default - -warning: 1 warning emitted - From 361af821ab169a98e9fc1db5d3a57978504ed379 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Mon, 17 Nov 2025 23:10:00 +0000 Subject: [PATCH 115/194] rustdoc-json: add rlib path to ExternalCrate to enable robust crate resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Historically, it's not been possible to robustly resolve a cross-crate item in rustdoc-json. If you had a `Id` that wasn't in `Crate::index` (because it was defined in a different crate), you could only look it up it `Crate::paths`. But there, you don't get the full information, only an `ItemSummary`. This tells you the `path` and the `crate_id`. But knowing the `crate_id` isn't enough to be able to build/find the rustdoc-json output with this item. It's only use is to get a `ExternalCrate` (via `Crate::external_crates`). But that only tells you the `name` (as a string). This isn't enough to uniquely identify a crate, as there could be multiple versions/features [1] [2]. This was originally proposed to be solved via LukeMathWalker's `--orchestrator-id` proposal (https://www.github.com/rust-lang/compiler-team/issues/635). But that requires invasive changes to cargo/rustc. This PR instead implements Urgau's proposal to re-use the path to a crate's rmeta/rlib as a unique identifer. Callers can use that to determine which package it corresponds to in the language of the build-system above rustc. E.g. for cargo, `cargo rustdoc --message-format=json --output-format=json -Zunstable-options`). (Once you've found the right external crate's rustdoc-json output, you still need to resolve the path->id in that crate. But that's """just""" a matter of walking the module tree. We should probably still make that nicer (by, for example, allowing sharing `Id`s between rustdoc-json document), but that's a future concern) For some notes from RustWeek 2025, where this was designed, see https://hackmd.io/0jkdguobTnW7nXoGKAxfEQ [1]: https://www.github.com/rust-lang/compiler-team/issues/635#issue-1714254865 § Problem [2]: https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/Identifying.20external.20crates.20in.20Rustdoc.20JSON/with/352701211 --- src/librustdoc/json/mod.rs | 14 ++- src/rustdoc-json-types/lib.rs | 10 ++- .../rustdoc-json-external-crate-path/dep.rs | 5 ++ .../rustdoc-json-external-crate-path/entry.rs | 4 + .../rustdoc-json-external-crate-path/rmake.rs | 89 +++++++++++++++++++ .../trans_dep.rs | 3 + 6 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 tests/run-make/rustdoc-json-external-crate-path/dep.rs create mode 100644 tests/run-make/rustdoc-json-external-crate-path/entry.rs create mode 100644 tests/run-make/rustdoc-json-external-crate-path/rmake.rs create mode 100644 tests/run-make/rustdoc-json-external-crate-path/trans_dep.rs diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index b020e3d924a4..37d456ae796b 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -302,6 +302,13 @@ fn after_krate(mut self) -> Result<(), Error> { ExternalLocation::Remote(s) => Some(s.clone()), _ => None, }, + path: self + .tcx + .used_crate_source(*crate_num) + .paths() + .next() + .expect("crate should have at least 1 path") + .clone(), }, ) }) @@ -339,15 +346,12 @@ mod size_asserts { // tidy-alphabetical-start static_assert_size!(AssocItemConstraint, 112); static_assert_size!(Crate, 184); - static_assert_size!(ExternalCrate, 48); static_assert_size!(FunctionPointer, 168); static_assert_size!(GenericArg, 80); static_assert_size!(GenericArgs, 104); static_assert_size!(GenericBound, 72); static_assert_size!(GenericParamDef, 136); static_assert_size!(Impl, 304); - // `Item` contains a `PathBuf`, which is different sizes on different OSes. - static_assert_size!(Item, 528 + size_of::()); static_assert_size!(ItemSummary, 32); static_assert_size!(PolyTrait, 64); static_assert_size!(PreciseCapturingArg, 32); @@ -355,4 +359,8 @@ mod size_asserts { static_assert_size!(Type, 80); static_assert_size!(WherePredicate, 160); // tidy-alphabetical-end + + // These contains a `PathBuf`, which is different sizes on different OSes. + static_assert_size!(Item, 528 + size_of::()); + static_assert_size!(ExternalCrate, 48 + size_of::()); } diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index 658d3791d257..9a59de4f844a 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -37,8 +37,8 @@ // will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line // are deliberately not in a doc comment, because they need not be in public docs.) // -// Latest feature: Add `ItemKind::Attribute`. -pub const FORMAT_VERSION: u32 = 56; +// Latest feature: Add `ExternCrate::path`. +pub const FORMAT_VERSION: u32 = 57; /// The root of the emitted JSON blob. /// @@ -135,6 +135,12 @@ pub struct ExternalCrate { pub name: String, /// The root URL at which the crate's documentation lives. pub html_root_url: Option, + + /// A path from where this crate was loaded. + /// + /// This will typically be a `.rlib` or `.rmeta`. It can be used to determine which crate + /// this was in terms of whatever build-system invoked rustc. + pub path: PathBuf, } /// Information about an external (not defined in the local crate) [`Item`]. diff --git a/tests/run-make/rustdoc-json-external-crate-path/dep.rs b/tests/run-make/rustdoc-json-external-crate-path/dep.rs new file mode 100644 index 000000000000..25c5dcac9f75 --- /dev/null +++ b/tests/run-make/rustdoc-json-external-crate-path/dep.rs @@ -0,0 +1,5 @@ +#![no_std] + +pub struct S; + +pub use trans_dep::S as TransDep; diff --git a/tests/run-make/rustdoc-json-external-crate-path/entry.rs b/tests/run-make/rustdoc-json-external-crate-path/entry.rs new file mode 100644 index 000000000000..5e0d8610e7ad --- /dev/null +++ b/tests/run-make/rustdoc-json-external-crate-path/entry.rs @@ -0,0 +1,4 @@ +#![no_std] + +pub type FromDep = dep::S; +pub type FromTransDep = dep::TransDep; diff --git a/tests/run-make/rustdoc-json-external-crate-path/rmake.rs b/tests/run-make/rustdoc-json-external-crate-path/rmake.rs new file mode 100644 index 000000000000..40790e56cab5 --- /dev/null +++ b/tests/run-make/rustdoc-json-external-crate-path/rmake.rs @@ -0,0 +1,89 @@ +use std::path; + +use run_make_support::rustdoc_json_types::{Crate, ItemEnum, Path, Type, TypeAlias}; +use run_make_support::{cwd, rfs, rust_lib_name, rustc, rustdoc, serde_json}; + +#[track_caller] +fn canonicalize(p: &path::Path) -> path::PathBuf { + std::fs::canonicalize(p).expect("path should be canonicalizeable") +} + +fn main() { + rustc().input("trans_dep.rs").edition("2024").crate_type("lib").run(); + + rustc() + .input("dep.rs") + .edition("2024") + .crate_type("lib") + .extern_("trans_dep", rust_lib_name("trans_dep")) + .run(); + + rustdoc() + .input("entry.rs") + .edition("2024") + .output_format("json") + .library_search_path(cwd()) + .extern_("dep", rust_lib_name("dep")) + .arg("-Zunstable-options") + .run(); + + let bytes = rfs::read("doc/entry.json"); + + let krate: Crate = serde_json::from_slice(&bytes).expect("output should be valid json"); + + let root_item = &krate.index[&krate.root]; + let ItemEnum::Module(root_mod) = &root_item.inner else { panic!("expected ItemEnum::Module") }; + + assert_eq!(root_mod.items.len(), 2); + + let items = root_mod.items.iter().map(|id| &krate.index[id]).collect::>(); + + let from_dep = items + .iter() + .filter(|item| item.name.as_deref() == Some("FromDep")) + .next() + .expect("there should be en item called FromDep"); + + let from_trans_dep = items + .iter() + .filter(|item| item.name.as_deref() == Some("FromTransDep")) + .next() + .expect("there should be en item called FromDep"); + + let ItemEnum::TypeAlias(TypeAlias { + type_: Type::ResolvedPath(Path { id: from_dep_id, .. }), + .. + }) = &from_dep.inner + else { + panic!("Expected FromDep to be a TypeAlias"); + }; + + let ItemEnum::TypeAlias(TypeAlias { + type_: Type::ResolvedPath(Path { id: from_trans_dep_id, .. }), + .. + }) = &from_trans_dep.inner + else { + panic!("Expected FromDep to be a TypeAlias"); + }; + + assert_eq!(krate.index.get(from_dep_id), None); + assert_eq!(krate.index.get(from_trans_dep_id), None); + + let from_dep_externalinfo = &krate.paths[from_dep_id]; + let from_trans_dep_externalinfo = &krate.paths[from_trans_dep_id]; + + let dep_crate_id = from_dep_externalinfo.crate_id; + let trans_dep_crate_id = from_trans_dep_externalinfo.crate_id; + + let dep = &krate.external_crates[&dep_crate_id]; + let trans_dep = &krate.external_crates[&trans_dep_crate_id]; + + assert_eq!(dep.name, "dep"); + assert_eq!(trans_dep.name, "trans_dep"); + + assert_eq!(canonicalize(&dep.path), canonicalize(&cwd().join(rust_lib_name("dep")))); + assert_eq!( + canonicalize(&trans_dep.path), + canonicalize(&cwd().join(rust_lib_name("trans_dep"))) + ); +} diff --git a/tests/run-make/rustdoc-json-external-crate-path/trans_dep.rs b/tests/run-make/rustdoc-json-external-crate-path/trans_dep.rs new file mode 100644 index 000000000000..8f185393a7c3 --- /dev/null +++ b/tests/run-make/rustdoc-json-external-crate-path/trans_dep.rs @@ -0,0 +1,3 @@ +#![no_std] + +pub struct S; From 89d50591c06f084b80a5ce527781e07f8dc32be6 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Fri, 21 Nov 2025 00:14:03 -0800 Subject: [PATCH 116/194] Replace the first of 4 binary invocations for offload --- compiler/rustc_codegen_llvm/src/back/write.rs | 7 +++ compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 3 ++ .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 47 +++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index fde7dd6ef7a8..78b11c458d5a 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -765,6 +765,13 @@ fn handle_offload<'ll>(cx: &'ll SimpleCx<'_>, old_fn: &llvm::Value) { llvm_plugins.len(), ) }; + + if cgcx.target_is_like_gpu && config.offload.contains(&config::Offload::Enable) { + unsafe { + llvm::LLVMRustBundleImages(module.module_llvm.llmod(), module.module_llvm.tm.raw()); + } + } + result.into_result().unwrap_or_else(|()| llvm_err(dcx, LlvmError::RunLlvmPasses)) } diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index ca64d96c2a33..34f0e4b95338 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1641,6 +1641,9 @@ pub(crate) fn LLVMBuildFence<'a>( Name: *const c_char, ) -> &'a Value; + /// Processes the module and writes it in an offload compatible way into a "host.out" file. + pub(crate) fn LLVMRustBundleImages<'a>(M: &'a Module, TM: &'a TargetMachine) -> bool; + /// Writes a module to the specified path. Returns 0 on success. pub(crate) fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int; diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 8823c8392282..ba17aef92d0d 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -25,6 +25,7 @@ #include "llvm/IR/Module.h" #include "llvm/IR/Value.h" #include "llvm/Object/COFFImportFile.h" +#include "llvm/Object/OffloadBinary.h" #include "llvm/Remarks/RemarkFormat.h" #include "llvm/Remarks/RemarkSerializer.h" #include "llvm/Remarks/RemarkStreamer.h" @@ -35,6 +36,7 @@ #include "llvm/Support/Signals.h" #include "llvm/Support/Timer.h" #include "llvm/Support/ToolOutputFile.h" +#include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/ValueMapper.h" #include @@ -144,6 +146,51 @@ extern "C" void LLVMRustPrintStatistics(RustStringRef OutBuf) { llvm::PrintStatistics(OS); } +static Error writeFile(StringRef Filename, StringRef Data) { + Expected> OutputOrErr = + FileOutputBuffer::create(Filename, Data.size()); + if (!OutputOrErr) + return OutputOrErr.takeError(); + std::unique_ptr Output = std::move(*OutputOrErr); + llvm::copy(Data, Output->getBufferStart()); + if (Error E = Output->commit()) + return E; + return Error::success(); +} + +// This is the first of many steps in creating a binary using llvm offload, +// to run code on the gpu. Concrete, it replaces the following binary use: +// clang-offload-packager -o host.out +// --image=file=device.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp +// The input module is the rust code compiled for a gpu target like amdgpu. +// Based on clang/tools/clang-offload-packager/ClangOffloadPackager.cpp +extern "C" bool LLVMRustBundleImages(LLVMModuleRef M, TargetMachine &TM) { + std::string Storage; + llvm::raw_string_ostream OS1(Storage); + llvm::WriteBitcodeToFile(*unwrap(M), OS1); + OS1.flush(); + auto MB = llvm::MemoryBuffer::getMemBufferCopy(Storage, "module.bc"); + + SmallVector BinaryData; + raw_svector_ostream OS2(BinaryData); + + OffloadBinary::OffloadingImage ImageBinary{}; + ImageBinary.TheImageKind = object::IMG_Bitcode; + ImageBinary.Image = std::move(MB); + ImageBinary.TheOffloadKind = object::OFK_OpenMP; + ImageBinary.StringData["triple"] = TM.getTargetTriple().str(); + ImageBinary.StringData["arch"] = TM.getTargetCPU(); + llvm::SmallString<0> Buffer = OffloadBinary::write(ImageBinary); + if (Buffer.size() % OffloadBinary::getAlignment() != 0) + // Offload binary has invalid size alignment + return false; + OS2 << Buffer; + if (Error E = writeFile("host.out", + StringRef(BinaryData.begin(), BinaryData.size()))) + return false; + return true; +} + extern "C" void LLVMRustOffloadMapper(LLVMValueRef OldFn, LLVMValueRef NewFn) { llvm::Function *oldFn = llvm::unwrap(OldFn); llvm::Function *newFn = llvm::unwrap(NewFn); From fc822f8c85989b318511a7a8b8e7a0491ef8abdf Mon Sep 17 00:00:00 2001 From: mu001999 Date: Fri, 17 Oct 2025 00:42:21 +0800 Subject: [PATCH 117/194] Emit error when using path-segment keyword as cfg pred --- .../rustc_attr_parsing/src/attributes/cfg.rs | 5 +- .../src/attributes/cfg_old.rs | 5 +- compiler/rustc_errors/src/emitter.rs | 22 +- compiler/rustc_interface/src/interface.rs | 70 ++- compiler/rustc_parse/src/parser/mod.rs | 2 +- compiler/rustc_session/src/parse.rs | 12 +- ...e.32bit.stderr => cast_size.r32bit.stderr} | 0 ...e.64bit.stderr => cast_size.r64bit.stderr} | 0 src/tools/clippy/tests/ui/cast_size.rs | 8 +- ...tderr => fn_to_numeric_cast.r32bit.stderr} | 0 ...tderr => fn_to_numeric_cast.r64bit.stderr} | 0 .../clippy/tests/ui/fn_to_numeric_cast.rs | 26 +- ...tderr => large_enum_variant.r32bit.stderr} | 0 ...tderr => large_enum_variant.r64bit.stderr} | 0 .../clippy/tests/ui/large_enum_variant.rs | 10 +- tests/codegen-llvm/cf-protection.rs | 10 +- tests/ui/cfg/cmdline-false.rs | 2 +- ...th-kw-as-cfg-pred-cli-cfg.cfg_crate.stderr | 2 + ...ath-kw-as-cfg-pred-cli-cfg.cfg_priv.stderr | 2 + ...w-as-cfg-pred-cli-cfg.cfg_raw_crate.stderr | 6 + ...cfg-pred-cli-cfg.cfg_raw_self_lower.stderr | 6 + ...cfg-pred-cli-cfg.cfg_raw_self_upper.stderr | 6 + ...w-as-cfg-pred-cli-cfg.cfg_raw_super.stderr | 6 + ...cfg-pred-cli-cfg.cfg_raw_underscore.stderr | 6 + ...-as-cfg-pred-cli-cfg.cfg_self_lower.stderr | 2 + ...-as-cfg-pred-cli-cfg.cfg_self_upper.stderr | 2 + ...h-kw-as-cfg-pred-cli-cfg.cfg_struct.stderr | 2 + ...th-kw-as-cfg-pred-cli-cfg.cfg_super.stderr | 2 + ...-as-cfg-pred-cli-cfg.cfg_underscore.stderr | 2 + tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.rs | 24 + ...-pred-cli-check-cfg.check_cfg_crate.stderr | 5 + ...g-pred-cli-check-cfg.check_cfg_priv.stderr | 5 + ...d-cli-check-cfg.check_cfg_raw_crate.stderr | 9 + ...-check-cfg.check_cfg_raw_self_lower.stderr | 9 + ...-check-cfg.check_cfg_raw_self_upper.stderr | 9 + ...d-cli-check-cfg.check_cfg_raw_super.stderr | 9 + ...-check-cfg.check_cfg_raw_underscore.stderr | 9 + ...-cli-check-cfg.check_cfg_self_lower.stderr | 5 + ...-cli-check-cfg.check_cfg_self_upper.stderr | 5 + ...pred-cli-check-cfg.check_cfg_struct.stderr | 5 + ...-pred-cli-check-cfg.check_cfg_super.stderr | 5 + ...-cli-check-cfg.check_cfg_underscore.stderr | 5 + .../cfg/path-kw-as-cfg-pred-cli-check-cfg.rs | 25 + .../cfg/path-kw-as-cfg-pred-cli-raw-allow.rs | 6 + tests/ui/cfg/path-kw-as-cfg-pred.rs | 129 ++++ tests/ui/cfg/path-kw-as-cfg-pred.stderr | 573 ++++++++++++++++++ tests/ui/cfg/raw-true-false.rs | 6 +- tests/ui/check-cfg/raw-keywords.rs | 2 +- .../cfg-arg-invalid-7.rs | 2 +- .../cfg-arg-invalid-7.stderr | 2 +- ...tderr => ctfe-id-unlimited.return_.stderr} | 12 +- .../explicit-tail-calls/ctfe-id-unlimited.rs | 10 +- 52 files changed, 988 insertions(+), 99 deletions(-) rename src/tools/clippy/tests/ui/{cast_size.32bit.stderr => cast_size.r32bit.stderr} (100%) rename src/tools/clippy/tests/ui/{cast_size.64bit.stderr => cast_size.r64bit.stderr} (100%) rename src/tools/clippy/tests/ui/{fn_to_numeric_cast.32bit.stderr => fn_to_numeric_cast.r32bit.stderr} (100%) rename src/tools/clippy/tests/ui/{fn_to_numeric_cast.64bit.stderr => fn_to_numeric_cast.r64bit.stderr} (100%) rename src/tools/clippy/tests/ui/{large_enum_variant.32bit.stderr => large_enum_variant.r32bit.stderr} (100%) rename src/tools/clippy/tests/ui/{large_enum_variant.64bit.stderr => large_enum_variant.r64bit.stderr} (100%) create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_crate.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_priv.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_crate.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_lower.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_upper.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_super.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_underscore.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_lower.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_upper.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_struct.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_super.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_underscore.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.rs create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_crate.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_priv.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_crate.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_lower.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_upper.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_super.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_underscore.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_lower.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_upper.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_struct.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_super.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_underscore.stderr create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.rs create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred-cli-raw-allow.rs create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred.rs create mode 100644 tests/ui/cfg/path-kw-as-cfg-pred.stderr rename tests/ui/explicit-tail-calls/{ctfe-id-unlimited.return.stderr => ctfe-id-unlimited.return_.stderr} (59%) diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg.rs b/compiler/rustc_attr_parsing/src/attributes/cfg.rs index 53f8fd5af6b4..a8aa63bd05ee 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg.rs @@ -82,7 +82,8 @@ pub fn parse_cfg_entry( } }, a @ (ArgParser::NoArgs | ArgParser::NameValue(_)) => { - let Some(name) = meta.path().word_sym() else { + let Some(name) = meta.path().word_sym().filter(|s| !s.is_path_segment_keyword()) + else { return Err(cx.expected_identifier(meta.path().span())); }; parse_name_value(name, meta.path().span(), a.name_value(), meta.span(), cx)? @@ -158,7 +159,7 @@ fn parse_cfg_entry_target( }; // Then, parse it as a name-value item - let Some(name) = sub_item.path().word_sym() else { + let Some(name) = sub_item.path().word_sym().filter(|s| !s.is_path_segment_keyword()) else { return Err(cx.expected_identifier(sub_item.path().span())); }; let name = Symbol::intern(&format!("target_{name}")); diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg_old.rs b/compiler/rustc_attr_parsing/src/attributes/cfg_old.rs index 3257d898eccb..70228d1e1510 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg_old.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg_old.rs @@ -220,7 +220,10 @@ pub fn eval_condition( } } } - MetaItemKind::Word | MetaItemKind::NameValue(..) if cfg.path.segments.len() != 1 => { + MetaItemKind::Word | MetaItemKind::NameValue(..) + if cfg.path.segments.len() != 1 + || cfg.path.segments[0].ident.is_path_segment_keyword() => + { dcx.emit_err(session_diagnostics::CfgPredicateIdentifier { span: cfg.path.span }); true } diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 4cab7e407eec..d9132ca12349 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -532,30 +532,24 @@ fn translator(&self) -> &Translator { } } -/// An emitter that does nothing when emitting a non-fatal diagnostic. -/// Fatal diagnostics are forwarded to `fatal_emitter` to avoid silent -/// failures of rustc, as witnessed e.g. in issue #89358. -pub struct FatalOnlyEmitter { - pub fatal_emitter: Box, - pub fatal_note: Option, +/// An emitter that adds a note to each diagnostic. +pub struct EmitterWithNote { + pub emitter: Box, + pub note: String, } -impl Emitter for FatalOnlyEmitter { +impl Emitter for EmitterWithNote { fn source_map(&self) -> Option<&SourceMap> { None } fn emit_diagnostic(&mut self, mut diag: DiagInner, registry: &Registry) { - if diag.level == Level::Fatal { - if let Some(fatal_note) = &self.fatal_note { - diag.sub(Level::Note, fatal_note.clone(), MultiSpan::new()); - } - self.fatal_emitter.emit_diagnostic(diag, registry); - } + diag.sub(Level::Note, self.note.clone(), MultiSpan::new()); + self.emitter.emit_diagnostic(diag, registry); } fn translator(&self) -> &Translator { - self.fatal_emitter.translator() + self.emitter.translator() } } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index bc4e4127c8ed..af1c35774a67 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -15,6 +15,7 @@ use rustc_middle::util::Providers; use rustc_parse::lexer::StripTokens; use rustc_parse::new_parser_from_source_str; +use rustc_parse::parser::Recovery; use rustc_parse::parser::attr::AllowLeadingUnsafe; use rustc_query_impl::QueryCtxt; use rustc_query_system::query::print_query_stack; @@ -52,9 +53,9 @@ pub struct Compiler { pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec) -> Cfg { cfgs.into_iter() .map(|s| { - let psess = ParseSess::with_fatal_emitter( + let psess = ParseSess::emitter_with_note( vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE], - format!("this error occurred on the command line: `--cfg={s}`"), + format!("this occurred on the command line: `--cfg={s}`"), ); let filename = FileName::cfg_spec_source_code(&s); @@ -62,36 +63,46 @@ macro_rules! error { ($reason: expr) => { #[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::diagnostic_outside_of_impl)] - dcx.fatal(format!( - concat!("invalid `--cfg` argument: `{}` (", $reason, ")"), - s - )); + dcx.fatal(format!("invalid `--cfg` argument: `{s}` ({})", $reason)); }; } match new_parser_from_source_str(&psess, filename, s.to_string(), StripTokens::Nothing) { - Ok(mut parser) => match parser.parse_meta_item(AllowLeadingUnsafe::No) { - Ok(meta_item) if parser.token == token::Eof => { - if meta_item.path.segments.len() != 1 { - error!("argument key must be an identifier"); - } - match &meta_item.kind { - MetaItemKind::List(..) => {} - MetaItemKind::NameValue(lit) if !lit.kind.is_str() => { - error!("argument value must be a string"); + Ok(mut parser) => { + parser = parser.recovery(Recovery::Forbidden); + match parser.parse_meta_item(AllowLeadingUnsafe::No) { + Ok(meta_item) + if parser.token == token::Eof + && parser.dcx().has_errors().is_none() => + { + if meta_item.path.segments.len() != 1 { + error!("argument key must be an identifier"); } - MetaItemKind::NameValue(..) | MetaItemKind::Word => { - let ident = meta_item.ident().expect("multi-segment cfg key"); - return (ident.name, meta_item.value_str()); + match &meta_item.kind { + MetaItemKind::List(..) => {} + MetaItemKind::NameValue(lit) if !lit.kind.is_str() => { + error!("argument value must be a string"); + } + MetaItemKind::NameValue(..) | MetaItemKind::Word => { + let ident = meta_item.ident().expect("multi-segment cfg key"); + + if ident.is_path_segment_keyword() { + error!( + "malformed `cfg` input, expected a valid identifier" + ); + } + + return (ident.name, meta_item.value_str()); + } } } + Ok(..) => {} + Err(err) => err.cancel(), } - Ok(..) => {} - Err(err) => err.cancel(), - }, + } Err(errs) => errs.into_iter().for_each(|err| err.cancel()), - } + }; // If the user tried to use a key="value" flag, but is missing the quotes, provide // a hint about how to resolve this. @@ -116,9 +127,9 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec) -> Ch let mut check_cfg = CheckCfg { exhaustive_names, exhaustive_values, ..CheckCfg::default() }; for s in specs { - let psess = ParseSess::with_fatal_emitter( + let psess = ParseSess::emitter_with_note( vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE], - format!("this error occurred on the command line: `--check-cfg={s}`"), + format!("this occurred on the command line: `--check-cfg={s}`"), ); let filename = FileName::cfg_spec_source_code(&s); @@ -171,7 +182,7 @@ macro_rules! error { let mut parser = match new_parser_from_source_str(&psess, filename, s.to_string(), StripTokens::Nothing) { - Ok(parser) => parser, + Ok(parser) => parser.recovery(Recovery::Forbidden), Err(errs) => { errs.into_iter().for_each(|err| err.cancel()); expected_error(); @@ -179,7 +190,9 @@ macro_rules! error { }; let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::No) { - Ok(meta_item) if parser.token == token::Eof => meta_item, + Ok(meta_item) if parser.token == token::Eof && parser.dcx().has_errors().is_none() => { + meta_item + } Ok(..) => expected_error(), Err(err) => { err.cancel(); @@ -209,6 +222,11 @@ macro_rules! error { if values_specified { error!("`cfg()` names cannot be after values"); } + + if ident.is_path_segment_keyword() { + error!("malformed `cfg` input, expected a valid identifier"); + } + names.push(ident); } else if let Some(boolean) = arg.boolean_literal() { if values_specified { diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 203a93b52012..14a738fb9d24 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -466,7 +466,7 @@ fn expect_one_of( // Public for rustfmt usage. pub fn parse_ident(&mut self) -> PResult<'a, Ident> { - self.parse_ident_common(true) + self.parse_ident_common(self.may_recover()) } fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, Ident> { diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 9048c51d5b42..8c70e18fb66d 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -8,7 +8,7 @@ use rustc_ast::node_id::NodeId; use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::sync::{AppendOnlyVec, Lock}; -use rustc_errors::emitter::{FatalOnlyEmitter, HumanEmitter, stderr_destination}; +use rustc_errors::emitter::{EmitterWithNote, HumanEmitter, stderr_destination}; use rustc_errors::translation::Translator; use rustc_errors::{ BufferedEarlyLint, ColorConfig, DecorateDiagCompat, Diag, DiagCtxt, DiagCtxtHandle, @@ -315,16 +315,12 @@ pub fn with_dcx(dcx: DiagCtxt, source_map: Arc) -> Self { } } - pub fn with_fatal_emitter(locale_resources: Vec<&'static str>, fatal_note: String) -> Self { + pub fn emitter_with_note(locale_resources: Vec<&'static str>, note: String) -> Self { let translator = Translator::with_fallback_bundle(locale_resources, false); let sm = Arc::new(SourceMap::new(FilePathMapping::empty())); - let fatal_emitter = + let emitter = Box::new(HumanEmitter::new(stderr_destination(ColorConfig::Auto), translator)); - let dcx = DiagCtxt::new(Box::new(FatalOnlyEmitter { - fatal_emitter, - fatal_note: Some(fatal_note), - })) - .disable_warnings(); + let dcx = DiagCtxt::new(Box::new(EmitterWithNote { emitter, note })); ParseSess::with_dcx(dcx, sm) } diff --git a/src/tools/clippy/tests/ui/cast_size.32bit.stderr b/src/tools/clippy/tests/ui/cast_size.r32bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/cast_size.32bit.stderr rename to src/tools/clippy/tests/ui/cast_size.r32bit.stderr diff --git a/src/tools/clippy/tests/ui/cast_size.64bit.stderr b/src/tools/clippy/tests/ui/cast_size.r64bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/cast_size.64bit.stderr rename to src/tools/clippy/tests/ui/cast_size.r64bit.stderr diff --git a/src/tools/clippy/tests/ui/cast_size.rs b/src/tools/clippy/tests/ui/cast_size.rs index ecc586694191..cefab253bbee 100644 --- a/src/tools/clippy/tests/ui/cast_size.rs +++ b/src/tools/clippy/tests/ui/cast_size.rs @@ -1,6 +1,6 @@ -//@revisions: 32bit 64bit -//@[32bit]ignore-bitwidth: 64 -//@[64bit]ignore-bitwidth: 32 +//@revisions: r32bit r64bit +//@[r32bit]ignore-bitwidth: 64 +//@[r64bit]ignore-bitwidth: 32 //@no-rustfix: only some diagnostics have suggestions #![warn( @@ -62,7 +62,7 @@ fn main() { //~^ cast_precision_loss 9_999_999_999_999_999usize as f64; //~^ cast_precision_loss - //~[32bit]^^ ERROR: literal out of range for `usize` + //~[r32bit]^^ ERROR: literal out of range for `usize` // 999_999_999_999_999_999_999_999_999_999u128 as f128; } diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast.32bit.stderr b/src/tools/clippy/tests/ui/fn_to_numeric_cast.r32bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/fn_to_numeric_cast.32bit.stderr rename to src/tools/clippy/tests/ui/fn_to_numeric_cast.r32bit.stderr diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast.64bit.stderr b/src/tools/clippy/tests/ui/fn_to_numeric_cast.r64bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/fn_to_numeric_cast.64bit.stderr rename to src/tools/clippy/tests/ui/fn_to_numeric_cast.r64bit.stderr diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast.rs b/src/tools/clippy/tests/ui/fn_to_numeric_cast.rs index 0a07aeff366e..3659ca24278f 100644 --- a/src/tools/clippy/tests/ui/fn_to_numeric_cast.rs +++ b/src/tools/clippy/tests/ui/fn_to_numeric_cast.rs @@ -1,6 +1,6 @@ -//@revisions: 32bit 64bit -//@[32bit]ignore-bitwidth: 64 -//@[64bit]ignore-bitwidth: 32 +//@revisions: r32bit r64bit +//@[r32bit]ignore-bitwidth: 64 +//@[r64bit]ignore-bitwidth: 32 //@no-rustfix #![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] #![allow(function_casts_as_integer)] @@ -15,8 +15,8 @@ fn test_function_to_numeric_cast() { let _ = foo as i16; //~^ fn_to_numeric_cast_with_truncation let _ = foo as i32; - //~[64bit]^ fn_to_numeric_cast_with_truncation - //~[32bit]^^ fn_to_numeric_cast + //~[r64bit]^ fn_to_numeric_cast_with_truncation + //~[r32bit]^^ fn_to_numeric_cast let _ = foo as i64; //~^ fn_to_numeric_cast let _ = foo as i128; @@ -29,8 +29,8 @@ fn test_function_to_numeric_cast() { let _ = foo as u16; //~^ fn_to_numeric_cast_with_truncation let _ = foo as u32; - //~[64bit]^ fn_to_numeric_cast_with_truncation - //~[32bit]^^ fn_to_numeric_cast + //~[r64bit]^ fn_to_numeric_cast_with_truncation + //~[r32bit]^^ fn_to_numeric_cast let _ = foo as u64; //~^ fn_to_numeric_cast let _ = foo as u128; @@ -52,8 +52,8 @@ fn test_function_var_to_numeric_cast() { let _ = abc as i16; //~^ fn_to_numeric_cast_with_truncation let _ = abc as i32; - //~[64bit]^ fn_to_numeric_cast_with_truncation - //~[32bit]^^ fn_to_numeric_cast + //~[r64bit]^ fn_to_numeric_cast_with_truncation + //~[r32bit]^^ fn_to_numeric_cast let _ = abc as i64; //~^ fn_to_numeric_cast let _ = abc as i128; @@ -66,8 +66,8 @@ fn test_function_var_to_numeric_cast() { let _ = abc as u16; //~^ fn_to_numeric_cast_with_truncation let _ = abc as u32; - //~[64bit]^ fn_to_numeric_cast_with_truncation - //~[32bit]^^ fn_to_numeric_cast + //~[r64bit]^ fn_to_numeric_cast_with_truncation + //~[r32bit]^^ fn_to_numeric_cast let _ = abc as u64; //~^ fn_to_numeric_cast let _ = abc as u128; @@ -79,8 +79,8 @@ fn test_function_var_to_numeric_cast() { fn fn_with_fn_args(f: fn(i32) -> i32) -> i32 { f as i32 - //~[64bit]^ fn_to_numeric_cast_with_truncation - //~[32bit]^^ fn_to_numeric_cast + //~[r64bit]^ fn_to_numeric_cast_with_truncation + //~[r32bit]^^ fn_to_numeric_cast } fn main() {} diff --git a/src/tools/clippy/tests/ui/large_enum_variant.32bit.stderr b/src/tools/clippy/tests/ui/large_enum_variant.r32bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/large_enum_variant.32bit.stderr rename to src/tools/clippy/tests/ui/large_enum_variant.r32bit.stderr diff --git a/src/tools/clippy/tests/ui/large_enum_variant.64bit.stderr b/src/tools/clippy/tests/ui/large_enum_variant.r64bit.stderr similarity index 100% rename from src/tools/clippy/tests/ui/large_enum_variant.64bit.stderr rename to src/tools/clippy/tests/ui/large_enum_variant.r64bit.stderr diff --git a/src/tools/clippy/tests/ui/large_enum_variant.rs b/src/tools/clippy/tests/ui/large_enum_variant.rs index 9cf6318ca342..43c19d648626 100644 --- a/src/tools/clippy/tests/ui/large_enum_variant.rs +++ b/src/tools/clippy/tests/ui/large_enum_variant.rs @@ -1,8 +1,8 @@ -//@revisions: 32bit 64bit +//@revisions: r32bit r64bit //@aux-build:proc_macros.rs //@no-rustfix -//@[32bit]ignore-bitwidth: 64 -//@[64bit]ignore-bitwidth: 32 +//@[r32bit]ignore-bitwidth: 64 +//@[r64bit]ignore-bitwidth: 32 #![allow(dead_code)] #![allow(unused_variables)] #![warn(clippy::large_enum_variant)] @@ -221,13 +221,13 @@ pub(crate) struct Vtable { } enum NoWarnings { - //~[64bit]^ large_enum_variant + //~[r64bit]^ large_enum_variant BigBoi(PublishWithBytes), _SmallBoi(u8), } enum MakesClippyAngry { - //~[64bit]^ large_enum_variant + //~[r64bit]^ large_enum_variant BigBoi(PublishWithVec), _SmallBoi(u8), } diff --git a/tests/codegen-llvm/cf-protection.rs b/tests/codegen-llvm/cf-protection.rs index c9e9d3433f1f..a1c902755afb 100644 --- a/tests/codegen-llvm/cf-protection.rs +++ b/tests/codegen-llvm/cf-protection.rs @@ -1,12 +1,12 @@ // Test that the correct module flags are emitted with different control-flow protection flags. //@ add-minicore -//@ revisions: undefined none branch return full +//@ revisions: undefined none branch return_ full //@ needs-llvm-components: x86 // [undefined] no extra compile-flags //@ [none] compile-flags: -Z cf-protection=none //@ [branch] compile-flags: -Z cf-protection=branch -//@ [return] compile-flags: -Z cf-protection=return +//@ [return_] compile-flags: -Z cf-protection=return //@ [full] compile-flags: -Z cf-protection=full //@ compile-flags: --target x86_64-unknown-linux-gnu @@ -30,9 +30,9 @@ pub fn test() {} // branch: !"cf-protection-branch", i32 1 // branch-NOT: !"cf-protection-return" -// return-NOT: !"cf-protection-branch" -// return: !"cf-protection-return", i32 1 -// return-NOT: !"cf-protection-branch" +// return_-NOT: !"cf-protection-branch" +// return_: !"cf-protection-return", i32 1 +// return_-NOT: !"cf-protection-branch" // full: !"cf-protection-branch", i32 1 // full: !"cf-protection-return", i32 1 diff --git a/tests/ui/cfg/cmdline-false.rs b/tests/ui/cfg/cmdline-false.rs index d4b7d3bbfdca..917679e2e424 100644 --- a/tests/ui/cfg/cmdline-false.rs +++ b/tests/ui/cfg/cmdline-false.rs @@ -1,5 +1,5 @@ /// Test that `--cfg false` doesn't cause `cfg(false)` to evaluate to `true` -//@ compile-flags: --cfg false +//@ compile-flags: --cfg r#false #[cfg(false)] fn foo() {} diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_crate.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_crate.stderr new file mode 100644 index 000000000000..daaddd307416 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_crate.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `crate` (malformed `cfg` input, expected a valid identifier) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_priv.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_priv.stderr new file mode 100644 index 000000000000..5fd341485cd9 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_priv.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `priv` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_crate.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_crate.stderr new file mode 100644 index 000000000000..a5f8b25fe427 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_crate.stderr @@ -0,0 +1,6 @@ +error: `crate` cannot be a raw identifier + | + = note: this occurred on the command line: `--cfg=r#crate` + +error: invalid `--cfg` argument: `r#crate` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_lower.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_lower.stderr new file mode 100644 index 000000000000..25dbaa36dbec --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_lower.stderr @@ -0,0 +1,6 @@ +error: `self` cannot be a raw identifier + | + = note: this occurred on the command line: `--cfg=r#self` + +error: invalid `--cfg` argument: `r#self` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_upper.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_upper.stderr new file mode 100644 index 000000000000..04341926143a --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_self_upper.stderr @@ -0,0 +1,6 @@ +error: `Self` cannot be a raw identifier + | + = note: this occurred on the command line: `--cfg=r#Self` + +error: invalid `--cfg` argument: `r#Self` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_super.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_super.stderr new file mode 100644 index 000000000000..9c70442394ca --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_super.stderr @@ -0,0 +1,6 @@ +error: `super` cannot be a raw identifier + | + = note: this occurred on the command line: `--cfg=r#super` + +error: invalid `--cfg` argument: `r#super` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_underscore.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_underscore.stderr new file mode 100644 index 000000000000..144f6a134989 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_raw_underscore.stderr @@ -0,0 +1,6 @@ +error: `_` cannot be a raw identifier + | + = note: this occurred on the command line: `--cfg=r#_` + +error: invalid `--cfg` argument: `r#_` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_lower.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_lower.stderr new file mode 100644 index 000000000000..9d7897c48ef4 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_lower.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `self` (malformed `cfg` input, expected a valid identifier) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_upper.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_upper.stderr new file mode 100644 index 000000000000..16c91198eea7 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_self_upper.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `Self` (malformed `cfg` input, expected a valid identifier) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_struct.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_struct.stderr new file mode 100644 index 000000000000..5ee3f35ae0cf --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_struct.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `struct` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_super.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_super.stderr new file mode 100644 index 000000000000..08513ac466cb --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_super.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `super` (malformed `cfg` input, expected a valid identifier) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_underscore.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_underscore.stderr new file mode 100644 index 000000000000..4dfb3f827646 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.cfg_underscore.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `_` (expected `key` or `key="value"`) + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.rs b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.rs new file mode 100644 index 000000000000..b50b8216ca47 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-cfg.rs @@ -0,0 +1,24 @@ +//@ edition: 2024 + +//@ revisions: cfg_crate cfg_super cfg_self_lower cfg_self_upper +//@ revisions: cfg_raw_crate cfg_raw_super cfg_raw_self_lower cfg_raw_self_upper +//@ revisions: cfg_struct cfg_priv cfg_underscore cfg_raw_underscore + +//@ [cfg_crate]compile-flags: --cfg crate +//@ [cfg_super]compile-flags: --cfg super +//@ [cfg_self_lower]compile-flags: --cfg self +//@ [cfg_self_upper]compile-flags: --cfg Self + +//@ [cfg_raw_crate]compile-flags: --cfg r#crate +//@ [cfg_raw_super]compile-flags: --cfg r#super +//@ [cfg_raw_self_lower]compile-flags: --cfg r#self +//@ [cfg_raw_self_upper]compile-flags: --cfg r#Self + +//@ [cfg_struct]compile-flags: --cfg struct +//@ [cfg_priv]compile-flags: --cfg priv +//@ [cfg_underscore]compile-flags: --cfg _ +//@ [cfg_raw_underscore]compile-flags: --cfg r#_ + +fn main() {} + +//~? ERROR invalid `--cfg` argument diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_crate.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_crate.stderr new file mode 100644 index 000000000000..69f06cf5e216 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_crate.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(crate)` + | + = note: malformed `cfg` input, expected a valid identifier + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_priv.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_priv.stderr new file mode 100644 index 000000000000..2165d37500a9 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_priv.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(priv)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_crate.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_crate.stderr new file mode 100644 index 000000000000..f440c07779da --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_crate.stderr @@ -0,0 +1,9 @@ +error: `crate` cannot be a raw identifier + | + = note: this occurred on the command line: `--check-cfg=cfg(r#crate)` + +error: invalid `--check-cfg` argument: `cfg(r#crate)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_lower.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_lower.stderr new file mode 100644 index 000000000000..bccc694084e3 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_lower.stderr @@ -0,0 +1,9 @@ +error: `self` cannot be a raw identifier + | + = note: this occurred on the command line: `--check-cfg=cfg(r#self)` + +error: invalid `--check-cfg` argument: `cfg(r#self)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_upper.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_upper.stderr new file mode 100644 index 000000000000..68c149a01fb5 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_self_upper.stderr @@ -0,0 +1,9 @@ +error: `Self` cannot be a raw identifier + | + = note: this occurred on the command line: `--check-cfg=cfg(r#Self)` + +error: invalid `--check-cfg` argument: `cfg(r#Self)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_super.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_super.stderr new file mode 100644 index 000000000000..b3ef74422620 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_super.stderr @@ -0,0 +1,9 @@ +error: `super` cannot be a raw identifier + | + = note: this occurred on the command line: `--check-cfg=cfg(r#super)` + +error: invalid `--check-cfg` argument: `cfg(r#super)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_underscore.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_underscore.stderr new file mode 100644 index 000000000000..c05536b4185e --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_raw_underscore.stderr @@ -0,0 +1,9 @@ +error: `_` cannot be a raw identifier + | + = note: this occurred on the command line: `--check-cfg=cfg(r#_)` + +error: invalid `--check-cfg` argument: `cfg(r#_)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_lower.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_lower.stderr new file mode 100644 index 000000000000..b109650d116d --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_lower.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(self)` + | + = note: malformed `cfg` input, expected a valid identifier + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_upper.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_upper.stderr new file mode 100644 index 000000000000..649cde33e159 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_self_upper.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(Self)` + | + = note: malformed `cfg` input, expected a valid identifier + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_struct.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_struct.stderr new file mode 100644 index 000000000000..40942a955bf9 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_struct.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(struct)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_super.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_super.stderr new file mode 100644 index 000000000000..488d2982e7b8 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_super.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(super)` + | + = note: malformed `cfg` input, expected a valid identifier + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_underscore.stderr b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_underscore.stderr new file mode 100644 index 000000000000..98a645f039a5 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.check_cfg_underscore.stderr @@ -0,0 +1,5 @@ +error: invalid `--check-cfg` argument: `cfg(_)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit for more details + diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.rs b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.rs new file mode 100644 index 000000000000..57ec3f3d54bd --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-check-cfg.rs @@ -0,0 +1,25 @@ +//@ edition: 2021 + +//@ revisions: check_cfg_crate check_cfg_super check_cfg_self_lower check_cfg_self_upper +//@ revisions: check_cfg_raw_crate check_cfg_raw_super check_cfg_raw_self_lower +//@ revisions: check_cfg_raw_self_upper +//@ revisions: check_cfg_struct check_cfg_priv check_cfg_underscore check_cfg_raw_underscore + +//@ [check_cfg_crate]compile-flags: --check-cfg 'cfg(crate)' +//@ [check_cfg_super]compile-flags: --check-cfg 'cfg(super)' +//@ [check_cfg_self_lower]compile-flags: --check-cfg 'cfg(self)' +//@ [check_cfg_self_upper]compile-flags: --check-cfg 'cfg(Self)' + +//@ [check_cfg_raw_crate]compile-flags: --check-cfg 'cfg(r#crate)' +//@ [check_cfg_raw_super]compile-flags: --check-cfg 'cfg(r#super)' +//@ [check_cfg_raw_self_lower]compile-flags: --check-cfg 'cfg(r#self)' +//@ [check_cfg_raw_self_upper]compile-flags: --check-cfg 'cfg(r#Self)' + +//@ [check_cfg_struct]compile-flags: --check-cfg 'cfg(struct)' +//@ [check_cfg_priv]compile-flags: --check-cfg 'cfg(priv)' +//@ [check_cfg_underscore]compile-flags: --check-cfg 'cfg(_)' +//@ [check_cfg_raw_underscore]compile-flags: --check-cfg 'cfg(r#_)' + +fn main() {} + +//~? ERROR invalid `--check-cfg` argument diff --git a/tests/ui/cfg/path-kw-as-cfg-pred-cli-raw-allow.rs b/tests/ui/cfg/path-kw-as-cfg-pred-cli-raw-allow.rs new file mode 100644 index 000000000000..2f603baf28bd --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred-cli-raw-allow.rs @@ -0,0 +1,6 @@ +//@ edition: 2024 +//@ check-pass +//@ compile-flags: --cfg r#struct --cfg r#priv +//@ compile-flags: --check-cfg 'cfg(r#struct)' --check-cfg 'cfg(r#priv)' + +fn main() {} diff --git a/tests/ui/cfg/path-kw-as-cfg-pred.rs b/tests/ui/cfg/path-kw-as-cfg-pred.rs new file mode 100644 index 000000000000..d3b419175163 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred.rs @@ -0,0 +1,129 @@ +//@ edition: 2024 + +#![allow(unexpected_cfgs)] + +macro_rules! foo { + () => { + #[cfg($crate)] //~ ERROR malformed `cfg` attribute input + mod _cfg_dollar_crate {} + #[cfg_attr($crate, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input + mod _cfg_attr_dollar_crate {} + #[cfg_attr(true, cfg($crate))] //~ ERROR malformed `cfg` attribute input + mod _cfg_attr_true_cfg_crate {} + + cfg!($crate); //~ ERROR malformed `cfg` macro input + }; +} + +#[cfg(crate)] //~ ERROR malformed `cfg` attribute input +mod _cfg_crate {} +#[cfg(super)] //~ ERROR malformed `cfg` attribute input +mod _cfg_super {} +#[cfg(self)] //~ ERROR malformed `cfg` attribute input +mod _cfg_self_lower {} +#[cfg(Self)] //~ ERROR malformed `cfg` attribute input +mod _cfg_self_upper {} +#[cfg_attr(crate, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input +mod _cfg_attr_crate {} +#[cfg_attr(super, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input +mod _cfg_attr_super {} +#[cfg_attr(self, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input +mod _cfg_attr_self_lower {} +#[cfg_attr(Self, path = "foo")] //~ ERROR malformed `cfg_attr` attribute input +mod _cfg_attr_self_upper {} +#[cfg_attr(true, cfg(crate))] //~ ERROR malformed `cfg` attribute input +mod _cfg_attr_true_cfg_crate {} +#[cfg_attr(true, cfg(super))] //~ ERROR malformed `cfg` attribute input +mod _cfg_attr_true_cfg_super {} +#[cfg_attr(true, cfg(self))] //~ ERROR malformed `cfg` attribute input +mod _cfg_attr_true_cfg_self_lower {} +#[cfg_attr(true, cfg(Self))] //~ ERROR malformed `cfg` attribute input +mod _cfg_attr_true_cfg_self_upper {} + +#[cfg(struct)] //~ ERROR expected identifier, found keyword +mod _cfg_struct {} +#[cfg(priv)] //~ ERROR expected identifier, found reserved keyword `priv` +mod _cfg_priv {} +#[cfg(_)] //~ ERROR expected identifier, found reserved identifier `_` +mod _cfg_underscore {} +#[cfg_attr(struct, path = "foo")] //~ ERROR expected identifier, found keyword +mod _cfg_attr_struct {} +#[cfg_attr(priv, path = "foo")] //~ ERROR expected identifier, found reserved keyword `priv` +mod _cfg_attr_priv {} +#[cfg_attr(_, path = "foo")] //~ ERROR expected identifier, found reserved identifier `_` +mod _cfg_attr_underscore {} +#[cfg_attr(true, cfg(struct))] //~ ERROR expected identifier, found keyword +mod _cfg_attr_true_cfg_struct {} +#[cfg_attr(true, cfg(priv))] //~ ERROR expected identifier, found reserved keyword `priv` +mod _cfg_attr_true_cfg_priv {} +#[cfg_attr(true, cfg(_))] //~ ERROR expected identifier, found reserved identifier `_` +mod _cfg_attr_true_cfg_underscore {} + +fn main() { + foo!(); + + cfg!(crate); //~ ERROR malformed `cfg` macro input + cfg!(super); //~ ERROR malformed `cfg` macro input + cfg!(self); //~ ERROR malformed `cfg` macro input + cfg!(Self); //~ ERROR malformed `cfg` macro input + + cfg!(r#crate); //~ ERROR `crate` cannot be a raw identifier + //~^ ERROR malformed `cfg` macro input + cfg!(r#super); //~ ERROR `super` cannot be a raw identifier + //~^ ERROR malformed `cfg` macro input + cfg!(r#self); //~ ERROR `self` cannot be a raw identifier + //~^ ERROR malformed `cfg` macro input + cfg!(r#Self); //~ ERROR `Self` cannot be a raw identifier + //~^ ERROR malformed `cfg` macro input + + cfg!(struct); //~ ERROR expected identifier, found keyword + cfg!(priv); //~ ERROR expected identifier, found reserved keyword `priv` + cfg!(_); //~ ERROR expected identifier, found reserved identifier `_` + + cfg!(r#struct); // Ok + cfg!(r#priv); // Ok + cfg!(r#_); //~ ERROR `_` cannot be a raw identifier +} + +#[cfg(r#crate)] //~ ERROR malformed `cfg` attribute input +//~^ ERROR `crate` cannot be a raw identifier +mod _cfg_r_crate {} +#[cfg(r#super)] //~ ERROR malformed `cfg` attribute input +//~^ ERROR `super` cannot be a raw identifier +mod _cfg_r_super {} +#[cfg(r#self)] //~ ERROR malformed `cfg` attribute input +//~^ ERROR `self` cannot be a raw identifier +mod _cfg_r_self_lower {} +#[cfg(r#Self)] //~ ERROR malformed `cfg` attribute input +//~^ ERROR `Self` cannot be a raw identifier +mod _cfg_r_self_upper {} +#[cfg_attr(r#crate, cfg(r#crate))] //~ ERROR malformed `cfg_attr` attribute input +//~^ ERROR `crate` cannot be a raw identifier +//~^^ ERROR `crate` cannot be a raw identifier +mod _cfg_attr_r_crate {} +#[cfg_attr(r#super, cfg(r#super))] //~ ERROR malformed `cfg_attr` attribute input +//~^ ERROR `super` cannot be a raw identifier +//~^^ ERROR `super` cannot be a raw identifier +mod _cfg_attr_r_super {} +#[cfg_attr(r#self, cfg(r#self))] //~ ERROR malformed `cfg_attr` attribute input +//~^ ERROR `self` cannot be a raw identifier +//~^^ ERROR `self` cannot be a raw identifier +mod _cfg_attr_r_self_lower {} +#[cfg_attr(r#Self, cfg(r#Self))] //~ ERROR malformed `cfg_attr` attribute input +//~^ ERROR `Self` cannot be a raw identifier +//~^^ ERROR `Self` cannot be a raw identifier +mod _cfg_attr_r_self_upper {} + +#[cfg(r#struct)] // Ok +mod _cfg_r_struct {} +#[cfg(r#priv)] // Ok +mod _cfg_r_priv {} +#[cfg(r#_)] //~ ERROR `_` cannot be a raw identifier +mod _cfg_r_underscore {} +#[cfg_attr(r#struct, cfg(r#struct))] // Ok +mod _cfg_attr_r_struct {} +#[cfg_attr(r#priv, cfg(r#priv))] // Ok +mod _cfg_attr_r_priv {} +#[cfg_attr(r#_, cfg(r#_))] //~ ERROR `_` cannot be a raw identifier +//~^ ERROR `_` cannot be a raw identifier +mod _cfg_attr_r_underscore {} diff --git a/tests/ui/cfg/path-kw-as-cfg-pred.stderr b/tests/ui/cfg/path-kw-as-cfg-pred.stderr new file mode 100644 index 000000000000..f0bc0b67b933 --- /dev/null +++ b/tests/ui/cfg/path-kw-as-cfg-pred.stderr @@ -0,0 +1,573 @@ +error: `crate` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:70:10 + | +LL | cfg!(r#crate); + | ^^^^^^^ + +error: `super` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:72:10 + | +LL | cfg!(r#super); + | ^^^^^^^ + +error: `self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:74:10 + | +LL | cfg!(r#self); + | ^^^^^^ + +error: `Self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:76:10 + | +LL | cfg!(r#Self); + | ^^^^^^ + +error: `_` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:85:10 + | +LL | cfg!(r#_); + | ^^^ + +error: `crate` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:88:7 + | +LL | #[cfg(r#crate)] + | ^^^^^^^ + +error: `super` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:91:7 + | +LL | #[cfg(r#super)] + | ^^^^^^^ + +error: `self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:94:7 + | +LL | #[cfg(r#self)] + | ^^^^^^ + +error: `Self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:97:7 + | +LL | #[cfg(r#Self)] + | ^^^^^^ + +error: `crate` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:100:12 + | +LL | #[cfg_attr(r#crate, cfg(r#crate))] + | ^^^^^^^ + +error: `crate` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:100:25 + | +LL | #[cfg_attr(r#crate, cfg(r#crate))] + | ^^^^^^^ + +error: `super` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:104:12 + | +LL | #[cfg_attr(r#super, cfg(r#super))] + | ^^^^^^^ + +error: `super` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:104:25 + | +LL | #[cfg_attr(r#super, cfg(r#super))] + | ^^^^^^^ + +error: `self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:108:12 + | +LL | #[cfg_attr(r#self, cfg(r#self))] + | ^^^^^^ + +error: `self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:108:24 + | +LL | #[cfg_attr(r#self, cfg(r#self))] + | ^^^^^^ + +error: `Self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:112:12 + | +LL | #[cfg_attr(r#Self, cfg(r#Self))] + | ^^^^^^ + +error: `Self` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:112:24 + | +LL | #[cfg_attr(r#Self, cfg(r#Self))] + | ^^^^^^ + +error: `_` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:121:7 + | +LL | #[cfg(r#_)] + | ^^^ + +error: `_` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:127:12 + | +LL | #[cfg_attr(r#_, cfg(r#_))] + | ^^^ + +error: `_` cannot be a raw identifier + --> $DIR/path-kw-as-cfg-pred.rs:127:21 + | +LL | #[cfg_attr(r#_, cfg(r#_))] + | ^^^ + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:18:1 + | +LL | #[cfg(crate)] + | ^^^^^^-----^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:20:1 + | +LL | #[cfg(super)] + | ^^^^^^-----^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:22:1 + | +LL | #[cfg(self)] + | ^^^^^^----^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:24:1 + | +LL | #[cfg(Self)] + | ^^^^^^----^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:26:1 + | +LL | #[cfg_attr(crate, path = "foo")] + | ^^^^^^^^^^^-----^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:28:1 + | +LL | #[cfg_attr(super, path = "foo")] + | ^^^^^^^^^^^-----^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:30:1 + | +LL | #[cfg_attr(self, path = "foo")] + | ^^^^^^^^^^^----^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:32:1 + | +LL | #[cfg_attr(Self, path = "foo")] + | ^^^^^^^^^^^----^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:34:18 + | +LL | #[cfg_attr(true, cfg(crate))] + | ^^^^-----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:36:18 + | +LL | #[cfg_attr(true, cfg(super))] + | ^^^^-----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:38:18 + | +LL | #[cfg_attr(true, cfg(self))] + | ^^^^----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:40:18 + | +LL | #[cfg_attr(true, cfg(Self))] + | ^^^^----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg(predicate)` + | + = note: for more information, visit + +error: expected identifier, found keyword `struct` + --> $DIR/path-kw-as-cfg-pred.rs:43:7 + | +LL | #[cfg(struct)] + | ^^^^^^ expected identifier, found keyword + +error: expected identifier, found reserved keyword `priv` + --> $DIR/path-kw-as-cfg-pred.rs:45:7 + | +LL | #[cfg(priv)] + | ^^^^ expected identifier, found reserved keyword + +error: expected identifier, found reserved identifier `_` + --> $DIR/path-kw-as-cfg-pred.rs:47:7 + | +LL | #[cfg(_)] + | ^ expected identifier, found reserved identifier + +error: expected identifier, found keyword `struct` + --> $DIR/path-kw-as-cfg-pred.rs:49:12 + | +LL | #[cfg_attr(struct, path = "foo")] + | ^^^^^^ expected identifier, found keyword + | +help: escape `struct` to use it as an identifier + | +LL | #[cfg_attr(r#struct, path = "foo")] + | ++ + +error: expected identifier, found reserved keyword `priv` + --> $DIR/path-kw-as-cfg-pred.rs:51:12 + | +LL | #[cfg_attr(priv, path = "foo")] + | ^^^^ expected identifier, found reserved keyword + | +help: escape `priv` to use it as an identifier + | +LL | #[cfg_attr(r#priv, path = "foo")] + | ++ + +error: expected identifier, found reserved identifier `_` + --> $DIR/path-kw-as-cfg-pred.rs:53:12 + | +LL | #[cfg_attr(_, path = "foo")] + | ^ expected identifier, found reserved identifier + +error: expected identifier, found keyword `struct` + --> $DIR/path-kw-as-cfg-pred.rs:55:22 + | +LL | #[cfg_attr(true, cfg(struct))] + | ^^^^^^ expected identifier, found keyword + +error: expected identifier, found reserved keyword `priv` + --> $DIR/path-kw-as-cfg-pred.rs:57:22 + | +LL | #[cfg_attr(true, cfg(priv))] + | ^^^^ expected identifier, found reserved keyword + +error: expected identifier, found reserved identifier `_` + --> $DIR/path-kw-as-cfg-pred.rs:59:22 + | +LL | #[cfg_attr(true, cfg(_))] + | ^ expected identifier, found reserved identifier + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:88:1 + | +LL | #[cfg(r#crate)] + | ^^^^^^-------^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:91:1 + | +LL | #[cfg(r#super)] + | ^^^^^^-------^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:94:1 + | +LL | #[cfg(r#self)] + | ^^^^^^------^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:97:1 + | +LL | #[cfg(r#Self)] + | ^^^^^^------^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:100:1 + | +LL | #[cfg_attr(r#crate, cfg(r#crate))] + | ^^^^^^^^^^^-------^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:104:1 + | +LL | #[cfg_attr(r#super, cfg(r#super))] + | ^^^^^^^^^^^-------^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:108:1 + | +LL | #[cfg_attr(r#self, cfg(r#self))] + | ^^^^^^^^^^^------^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:112:1 + | +LL | #[cfg_attr(r#Self, cfg(r#Self))] + | ^^^^^^^^^^^------^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:7:9 + | +LL | #[cfg($crate)] + | ^^^^^^------^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg(predicate)]` +... +LL | foo!(); + | ------ in this macro invocation + | + = note: for more information, visit + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0539]: malformed `cfg_attr` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:9:9 + | +LL | #[cfg_attr($crate, path = "foo")] + | ^^^^^^^^^^^------^^^^^^^^^^^^^^^^ + | | | + | | expected a valid identifier here + | help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]` +... +LL | foo!(); + | ------ in this macro invocation + | + = note: for more information, visit + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0539]: malformed `cfg` attribute input + --> $DIR/path-kw-as-cfg-pred.rs:11:26 + | +LL | #[cfg_attr(true, cfg($crate))] + | ^^^^------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg(predicate)` +... +LL | foo!(); + | ------ in this macro invocation + | + = note: for more information, visit + = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:14:9 + | +LL | cfg!($crate); + | ^^^^^------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` +... +LL | foo!(); + | ------ in this macro invocation + | + = note: for more information, visit + = note: this error originates in the macro `cfg` which comes from the expansion of the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:65:5 + | +LL | cfg!(crate); + | ^^^^^-----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:66:5 + | +LL | cfg!(super); + | ^^^^^-----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:67:5 + | +LL | cfg!(self); + | ^^^^^----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:68:5 + | +LL | cfg!(Self); + | ^^^^^----^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:70:5 + | +LL | cfg!(r#crate); + | ^^^^^-------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:72:5 + | +LL | cfg!(r#super); + | ^^^^^-------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:74:5 + | +LL | cfg!(r#self); + | ^^^^^------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error[E0539]: malformed `cfg` macro input + --> $DIR/path-kw-as-cfg-pred.rs:76:5 + | +LL | cfg!(r#Self); + | ^^^^^------^ + | | | + | | expected a valid identifier here + | help: must be of the form: `cfg!(predicate)` + | + = note: for more information, visit + +error: expected identifier, found keyword `struct` + --> $DIR/path-kw-as-cfg-pred.rs:79:10 + | +LL | cfg!(struct); + | ^^^^^^ expected identifier, found keyword + +error: expected identifier, found reserved keyword `priv` + --> $DIR/path-kw-as-cfg-pred.rs:80:10 + | +LL | cfg!(priv); + | ^^^^ expected identifier, found reserved keyword + +error: expected identifier, found reserved identifier `_` + --> $DIR/path-kw-as-cfg-pred.rs:81:10 + | +LL | cfg!(_); + | ^ expected identifier, found reserved identifier + +error: aborting due to 64 previous errors + +For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/cfg/raw-true-false.rs b/tests/ui/cfg/raw-true-false.rs index c92672fc144e..9f4c6c1fcd42 100644 --- a/tests/ui/cfg/raw-true-false.rs +++ b/tests/ui/cfg/raw-true-false.rs @@ -1,9 +1,5 @@ //@ check-pass -//@ revisions: r0x0 r0x1 r1x0 r1x1 -//@[r0x0] compile-flags: --cfg false --check-cfg=cfg(false) -//@[r0x1] compile-flags: --cfg false --check-cfg=cfg(r#false) -//@[r1x0] compile-flags: --cfg r#false --check-cfg=cfg(false) -//@[r1x1] compile-flags: --cfg r#false --check-cfg=cfg(r#false) +//@ compile-flags: --cfg r#false --check-cfg=cfg(r#false) #![deny(unexpected_cfgs)] fn main() { #[cfg(not(r#false))] diff --git a/tests/ui/check-cfg/raw-keywords.rs b/tests/ui/check-cfg/raw-keywords.rs index b82eb5a64e9a..07daf564f6d8 100644 --- a/tests/ui/check-cfg/raw-keywords.rs +++ b/tests/ui/check-cfg/raw-keywords.rs @@ -3,7 +3,7 @@ // //@ check-pass //@ no-auto-check-cfg -//@ compile-flags: --cfg=true --cfg=async --check-cfg=cfg(r#true,r#async,edition2015,edition2021) +//@ compile-flags: --cfg=r#true --cfg=r#async --check-cfg=cfg(r#true,r#async,edition2015,edition2021) // //@ revisions: edition2015 edition2021 //@ [edition2015] edition: 2015 diff --git a/tests/ui/conditional-compilation/cfg-arg-invalid-7.rs b/tests/ui/conditional-compilation/cfg-arg-invalid-7.rs index f05adc7bf7aa..d90075da3e63 100644 --- a/tests/ui/conditional-compilation/cfg-arg-invalid-7.rs +++ b/tests/ui/conditional-compilation/cfg-arg-invalid-7.rs @@ -3,4 +3,4 @@ //@ compile-flags: --cfg a" //~? RAW unterminated double quote string -//~? RAW this error occurred on the command line +//~? RAW this occurred on the command line diff --git a/tests/ui/conditional-compilation/cfg-arg-invalid-7.stderr b/tests/ui/conditional-compilation/cfg-arg-invalid-7.stderr index 919709c84701..833d24a907dc 100644 --- a/tests/ui/conditional-compilation/cfg-arg-invalid-7.stderr +++ b/tests/ui/conditional-compilation/cfg-arg-invalid-7.stderr @@ -1,4 +1,4 @@ error[E0765]: unterminated double quote string | - = note: this error occurred on the command line: `--cfg=a"` + = note: this occurred on the command line: `--cfg=a"` diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr similarity index 59% rename from tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr rename to tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr index 25e30397c832..5102f278f027 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return_.stderr @@ -10,15 +10,15 @@ note: inside `rec_id` LL | inner(0, n) | ^^^^^^^^^^^ note: [... 125 additional calls inside `inner` ...] - --> $DIR/ctfe-id-unlimited.rs:17:42 + --> $DIR/ctfe-id-unlimited.rs:17:41 | -LL | #[cfg(r#return)] _ => return inner(acc + 1, n - 1), - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[cfg(return_)] _ => return inner(acc + 1, n - 1), + | ^^^^^^^^^^^^^^^^^^^^^ note: inside `inner` - --> $DIR/ctfe-id-unlimited.rs:17:42 + --> $DIR/ctfe-id-unlimited.rs:17:41 | -LL | #[cfg(r#return)] _ => return inner(acc + 1, n - 1), - | ^^^^^^^^^^^^^^^^^^^^^ the failure occurred here +LL | #[cfg(return_)] _ => return inner(acc + 1, n - 1), + | ^^^^^^^^^^^^^^^^^^^^^ the failure occurred here error: aborting due to 1 previous error diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs index 53cccb38e2b8..0efd8967f8bd 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.rs @@ -1,5 +1,5 @@ -//@ revisions: become return -//@ [become] run-pass +//@ revisions: become_ return_ +//@ [become_] run-pass #![expect(incomplete_features)] #![feature(explicit_tail_calls)] @@ -13,8 +13,8 @@ const fn rec_id(n: u32) -> u32 { const fn inner(acc: u32, n: u32) -> u32 { match n { 0 => acc, - #[cfg(r#become)] _ => become inner(acc + 1, n - 1), - #[cfg(r#return)] _ => return inner(acc + 1, n - 1), + #[cfg(become_)] _ => become inner(acc + 1, n - 1), + #[cfg(return_)] _ => return inner(acc + 1, n - 1), } } @@ -25,7 +25,7 @@ const fn inner(acc: u32, n: u32) -> u32 { const ORIGINAL: u32 = 12345; // Original number, but with identity function applied // (this is the same, but requires execution of the recursion) -const ID_ED: u32 = rec_id(ORIGINAL); //[return]~ ERROR: reached the configured maximum number of stack frames +const ID_ED: u32 = rec_id(ORIGINAL); //[return_]~ ERROR: reached the configured maximum number of stack frames // Assert to make absolutely sure the computation actually happens const ASSERT: () = assert!(ORIGINAL == ID_ED); From 640990f64c3aaae1a454bcac28f21caf164d1101 Mon Sep 17 00:00:00 2001 From: mu001999 Date: Thu, 20 Nov 2025 23:48:17 +0800 Subject: [PATCH 118/194] Add test for importing path-segment keyword --- tests/ui/use/use-path-segment-kw.rs | 250 +++++ tests/ui/use/use-path-segment-kw.stderr | 1245 +++++++++++++++++++++++ 2 files changed, 1495 insertions(+) create mode 100644 tests/ui/use/use-path-segment-kw.rs create mode 100644 tests/ui/use/use-path-segment-kw.stderr diff --git a/tests/ui/use/use-path-segment-kw.rs b/tests/ui/use/use-path-segment-kw.rs new file mode 100644 index 000000000000..137a9e18aef3 --- /dev/null +++ b/tests/ui/use/use-path-segment-kw.rs @@ -0,0 +1,250 @@ +//@ edition: 2021 + +macro_rules! macro_dollar_crate { + () => { + use $crate::*; + use $crate::{}; + + type A1 = $crate; //~ ERROR expected type, found module `$crate` + use $crate; //~ ERROR `$crate` may not be imported + pub use $crate as _dollar_crate; //~ ERROR `$crate` may not be imported + + type A2 = ::$crate; //~ ERROR failed to resolve: global paths cannot start with `$crate` + use ::$crate; //~ ERROR unresolved import `$crate` + use ::$crate as _dollar_crate2; //~ ERROR unresolved import `$crate` + use ::{$crate}; //~ ERROR unresolved import `$crate` + use ::{$crate as _nested_dollar_crate2}; //~ ERROR unresolved import `$crate` + + type A3 = foobar::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position + use foobar::$crate; //~ ERROR unresolved import `foobar::$crate` + use foobar::$crate as _dollar_crate3; //~ ERROR unresolved import `foobar::$crate` + use foobar::{$crate}; //~ ERROR unresolved import `foobar::$crate` + use foobar::{$crate as _nested_dollar_crate3}; //~ ERROR unresolved import `foobar::$crate` + + type A4 = crate::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position + use crate::$crate; //~ ERROR unresolved import `crate::$crate` + use crate::$crate as _dollar_crate4; //~ ERROR unresolved import `crate::$crate` + use crate::{$crate}; //~ ERROR unresolved import `crate::$crate` + use crate::{$crate as _nested_dollar_crate4}; //~ ERROR unresolved import `crate::$crate` + + type A5 = super::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position + use super::$crate; //~ ERROR unresolved import `super::$crate` + use super::$crate as _dollar_crate5; //~ ERROR unresolved import `super::$crate` + use super::{$crate}; //~ ERROR unresolved import `super::$crate` + use super::{$crate as _nested_dollar_crate5}; //~ ERROR unresolved import `super::$crate` + + type A6 = self::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position + use self::$crate; + use self::$crate as _dollar_crate6; + use self::{$crate}; + use self::{$crate as _nested_dollar_crate6}; + + type A7 = $crate::$crate; //~ ERROR failed to resolve: `$crate` in paths can only be used in start position + use $crate::$crate; //~ ERROR unresolved import `$crate::$crate` + use $crate::$crate as _dollar_crate7; //~ ERROR unresolved import `$crate::$crate` + use $crate::{$crate}; //~ ERROR unresolved import `$crate::$crate` + use $crate::{$crate as _nested_dollar_crate7}; //~ ERROR unresolved import `$crate::$crate` + + type A8 = $crate::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position + use $crate::crate; //~ ERROR unresolved import `$crate::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use $crate::crate as _m_crate8; //~ ERROR unresolved import `$crate::crate` + use $crate::{crate}; //~ ERROR unresolved import `$crate::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use $crate::{crate as _m_nested_crate8}; //~ ERROR unresolved import `$crate::crate` + + type A9 = $crate::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position + use $crate::super; //~ ERROR unresolved import `$crate::super` + use $crate::super as _m_super8; //~ ERROR unresolved import `$crate::super` + use $crate::{super}; //~ ERROR unresolved import `$crate::super` + use $crate::{super as _m_nested_super8}; //~ ERROR unresolved import `$crate::super` + + type A10 = $crate::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position + use $crate::self; //~ ERROR `$crate` may not be imported + //~^ ERROR `self` imports are only allowed within a { } list + //~^^ ERROR the name `` is defined multiple times + pub use $crate::self as _m_self8; //~ ERROR `self` imports are only allowed within a { } list + //~^ ERROR `$crate` may not be imported + use $crate::{self}; + //~^ ERROR the name `$crate` is defined multiple times + pub use $crate::{self as _m_nested_self8}; // Good + } +} + +fn outer() {} + +mod foo { + pub mod bar { + pub mod foobar { + pub mod qux { + pub use super::inner; + } + + pub mod baz { + pub use super::inner; + } + + pub fn inner() {} + } + + // --- $crate --- + macro_dollar_crate!(); + + // --- crate --- + use crate::*; + use crate::{}; + + type B1 = crate; //~ ERROR expected type, found module `crate` + use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + pub use crate as _crate; // Good + + type B2 = ::crate; //~ ERROR failed to resolve: global paths cannot start with `crate` + use ::crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR unresolved import `crate` + use ::crate as _crate2; //~ ERROR unresolved import `crate` + use ::{crate}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR unresolved import `crate` + use ::{crate as _nested_crate2}; //~ ERROR unresolved import `crate` + + type B3 = foobar::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position + use foobar::crate; //~ ERROR unresolved import `foobar::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use foobar::crate as _crate3; //~ ERROR unresolved import `foobar::crate` + use foobar::{crate}; //~ ERROR unresolved import `foobar::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use foobar::{crate as _nested_crate3}; //~ ERROR unresolved import `foobar::crate` + + type B4 = crate::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position + use crate::crate; //~ ERROR unresolved import `crate::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use crate::crate as _crate4; //~ ERROR unresolved import `crate::crate` + use crate::{crate}; //~ ERROR unresolved import `crate::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use crate::{crate as _nested_crate4}; //~ ERROR unresolved import `crate::crate` + + type B5 = super::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position + use super::crate; //~ ERROR unresolved import `super::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use super::crate as _crate5; //~ ERROR unresolved import `super::crate` + use super::{crate}; //~ ERROR unresolved import `super::crate` + //~^ ERROR crate root imports need to be explicitly named: `use crate as name;` + use super::{crate as _nested_crate5}; //~ ERROR unresolved import `super::crate` + + type B6 = self::crate; //~ ERROR failed to resolve: `crate` in paths can only be used in start position + use self::crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR the name `crate` is defined multiple times + use self::crate as _crate6; + use self::{crate}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR the name `crate` is defined multiple times + use self::{crate as _nested_crate6}; + + // --- super --- + use super::*; + use super::{}; //~ ERROR unresolved import `super` + + type C1 = super; //~ ERROR expected type, found module `super` + use super; //~ ERROR unresolved import `super` + pub use super as _super; //~ ERROR unresolved import `super` + + type C2 = ::super; //~ ERROR failed to resolve: global paths cannot start with `super` + use ::super; //~ ERROR unresolved import `super` + use ::super as _super2; //~ ERROR unresolved import `super` + use ::{super}; //~ ERROR unresolved import `super` + use ::{super as _nested_super2}; //~ ERROR unresolved import `super` + + type C3 = foobar::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position + use foobar::super; //~ ERROR unresolved import `foobar::super` + use foobar::super as _super3; //~ ERROR unresolved import `foobar::super` + use foobar::{super}; //~ ERROR unresolved import `foobar::super` + use foobar::{super as _nested_super3}; //~ ERROR unresolved import `foobar::super` + + type C4 = crate::super; //~ ERROR failed to resolve: `super` in paths can only be used in start position + use crate::super; //~ ERROR unresolved import `crate::super` + use crate::super as _super4; //~ ERROR unresolved import `crate::super` + use crate::{super}; //~ ERROR unresolved import `crate::super` + use crate::{super as _nested_super4}; //~ ERROR unresolved import `crate::super` + + type C5 = super::super; //~ ERROR expected type, found module `super::super` + use super::super; //~ ERROR unresolved import `super::super` + pub use super::super as _super5; //~ ERROR unresolved import `super::super` + use super::{super}; //~ ERROR unresolved import `super::super` + pub use super::{super as _nested_super5}; //~ ERROR unresolved import `super::super` + + type C6 = self::super; //~ ERROR expected type, found module `self::super` + use self::super; + use self::super as _super6; + use self::{super}; + use self::{super as _nested_super6}; + + // --- self --- + // use self::*; // Suppress other errors + use self::{}; //~ ERROR unresolved import `self` + + type D1 = self; //~ ERROR expected type, found module `self` + use self; //~ ERROR `self` imports are only allowed within a { } list + pub use self as _self; //~ ERROR `self` imports are only allowed within a { } list + + type D2 = ::self; //~ ERROR failed to resolve: global paths cannot start with `self` + use ::self; //~ ERROR `self` imports are only allowed within a { } list + //~^ ERROR unresolved import `{{root}}` + use ::self as _self2; //~ ERROR `self` imports are only allowed within a { } list + //~^ ERROR unresolved import `{{root}}` + use ::{self}; //~ ERROR `self` import can only appear in an import list with a non-empty prefix + use ::{self as _nested_self2}; //~ ERROR `self` import can only appear in an import list with a non-empty prefix + + type D3 = foobar::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position + pub use foobar::qux::self; //~ ERROR `self` imports are only allowed within a { } list + pub use foobar::self as _self3; //~ ERROR `self` imports are only allowed within a { } list + pub use foobar::baz::{self}; // Good + pub use foobar::{self as _nested_self3}; // Good + + type D4 = crate::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position + use crate::self; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR `self` imports are only allowed within a { } list + //~^^ ERROR the name `crate` is defined multiple times + pub use crate::self as _self4; //~ ERROR `self` imports are only allowed within a { } list + use crate::{self}; //~ ERROR crate root imports need to be explicitly named: `use crate as name;` + //~^ ERROR the name `crate` is defined multiple times + pub use crate::{self as _nested_self4}; // Good + + type D5 = super::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position + use super::self; //~ ERROR unresolved import `super` + //~^ ERROR `self` imports are only allowed within a { } list + pub use super::self as _self5; //~ ERROR `self` imports are only allowed within a { } list + //~^ ERROR unresolved import `super` + use super::{self}; //~ ERROR unresolved import `super` + pub use super::{self as _nested_self5}; //~ ERROR unresolved import `super` + + type D6 = self::self; //~ ERROR failed to resolve: `self` in paths can only be used in start position + use self::self; //~ ERROR `self` imports are only allowed within a { } list + pub use self::self as _self6; //~ ERROR `self` imports are only allowed within a { } list + use self::{self}; //~ ERROR unresolved import `self` + pub use self::{self as _nested_self6}; //~ ERROR unresolved import `self` + } +} + +fn main() { + foo::bar::_dollar_crate::outer(); + foo::bar::_m_self8::outer(); + foo::bar::_dollar_crate::foo::bar::foobar::inner(); + foo::bar::_m_self8::foo::bar::foobar::inner(); + + foo::bar::_crate::outer(); + foo::bar::_crate::foo::bar::foobar::inner(); + + foo::bar::_super::bar::foobar::inner(); + foo::bar::_super5::outer(); + foo::bar::_nested_super5::outer(); + + foo::bar::_self::foobar::inner(); + foo::bar::qux::inner(); // Works after recovery + foo::bar::baz::inner(); + foo::bar::_self3::inner(); // Works after recovery + foo::bar::_nested_self3::inner(); + foo::bar::_self4::outer(); // Works after recovery + foo::bar::_nested_self4::outer(); + foo::bar::_self5::bar::foobar::inner(); // Works after recovery + foo::bar::_nested_self5::bar::foobar::inner(); + foo::bar::_self6::foobar::inner(); // Works after recovery + foo::bar::_nested_self6::foobar::inner(); +} diff --git a/tests/ui/use/use-path-segment-kw.stderr b/tests/ui/use/use-path-segment-kw.stderr new file mode 100644 index 000000000000..407e99059b2a --- /dev/null +++ b/tests/ui/use/use-path-segment-kw.stderr @@ -0,0 +1,1245 @@ +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:98:13 + | +LL | use crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:102:15 + | +LL | use ::crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:105:16 + | +LL | use ::{crate}; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:110:21 + | +LL | use foobar::crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:113:22 + | +LL | use foobar::{crate}; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:118:20 + | +LL | use crate::crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:121:21 + | +LL | use crate::{crate}; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:126:20 + | +LL | use super::crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:129:21 + | +LL | use super::{crate}; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:134:19 + | +LL | use self::crate; + | ^^^^^ + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:137:20 + | +LL | use self::{crate}; + | ^^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:184:13 + | +LL | use self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:185:17 + | +LL | pub use self as _self; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:188:13 + | +LL | use ::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use ::self; +LL + use ; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use ::{self}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:190:13 + | +LL | use ::self as _self2; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use ::self as _self2; +LL + use as _self2; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use ::{self as _self2}; + | + + + +error[E0431]: `self` import can only appear in an import list with a non-empty prefix + --> $DIR/use-path-segment-kw.rs:192:16 + | +LL | use ::{self}; + | ^^^^ can only appear in an import list with a non-empty prefix + +error[E0431]: `self` import can only appear in an import list with a non-empty prefix + --> $DIR/use-path-segment-kw.rs:193:16 + | +LL | use ::{self as _nested_self2}; + | ^^^^^^^^^^^^^^^^^^^^^ can only appear in an import list with a non-empty prefix + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:196:28 + | +LL | pub use foobar::qux::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use foobar::qux::self; +LL + pub use foobar::qux; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use foobar::qux::{self}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:197:23 + | +LL | pub use foobar::self as _self3; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use foobar::self as _self3; +LL + pub use foobar as _self3; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use foobar::{self as _self3}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:202:18 + | +LL | use crate::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use crate::self; +LL + use crate; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use crate::{self}; + | + + + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:202:13 + | +LL | use crate::self; + | ^^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:205:22 + | +LL | pub use crate::self as _self4; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use crate::self as _self4; +LL + pub use crate as _self4; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use crate::{self as _self4}; + | + + + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:206:21 + | +LL | use crate::{self}; + | ^^^^ + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:211:18 + | +LL | use super::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use super::self; +LL + use super; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use super::{self}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:213:22 + | +LL | pub use super::self as _self5; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use super::self as _self5; +LL + pub use super as _self5; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use super::{self as _self5}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:219:17 + | +LL | use self::self; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - use self::self; +LL + use self; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use self::{self}; + | + + + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:220:21 + | +LL | pub use self::self as _self6; + | ^^^^^^ + | +help: consider importing the module directly + | +LL - pub use self::self as _self6; +LL + pub use self as _self6; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use self::{self as _self6}; + | + + + +error[E0252]: the name `crate` is defined multiple times + --> $DIR/use-path-segment-kw.rs:134:13 + | +LL | use crate; + | ----- previous import of the module `crate` here +... +LL | use self::crate; + | ^^^^^^^^^^^ `crate` reimported here + | + = note: `crate` must be defined only once in the type namespace of this module + +error[E0252]: the name `crate` is defined multiple times + --> $DIR/use-path-segment-kw.rs:137:20 + | +LL | use crate; + | ----- previous import of the module `crate` here +... +LL | use self::{crate}; + | -----------^^^^^-- + | | | + | | `crate` reimported here + | help: remove unnecessary import + | + = note: `crate` must be defined only once in the type namespace of this module + +error[E0252]: the name `crate` is defined multiple times + --> $DIR/use-path-segment-kw.rs:202:13 + | +LL | use crate; + | ----- previous import of the module `crate` here +... +LL | use crate::self; + | ^^^^^^^^^^^ `crate` reimported here + | + = note: `crate` must be defined only once in the type namespace of this module + +error[E0252]: the name `crate` is defined multiple times + --> $DIR/use-path-segment-kw.rs:206:21 + | +LL | use crate; + | ----- previous import of the module `crate` here +... +LL | use crate::{self}; + | ------------^^^^-- + | | | + | | `crate` reimported here + | help: remove unnecessary import + | + = note: `crate` must be defined only once in the type namespace of this module + +error: `$crate` may not be imported + --> $DIR/use-path-segment-kw.rs:9:9 + | +LL | use $crate; + | ^^^^^^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `$crate` may not be imported + --> $DIR/use-path-segment-kw.rs:10:9 + | +LL | pub use $crate as _dollar_crate; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:49:21 + | +LL | use $crate::crate; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: crate root imports need to be explicitly named: `use crate as name;` + --> $DIR/use-path-segment-kw.rs:52:22 + | +LL | use $crate::{crate}; + | ^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:63:19 + | +LL | use $crate::self; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing the module directly + | +LL - use $crate::self; +LL + use $crate; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | use $crate::{self}; + | + + + +error: `$crate` may not be imported + --> $DIR/use-path-segment-kw.rs:63:9 + | +LL | use $crate::self; + | ^^^^^^^^^^^^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/use-path-segment-kw.rs:66:23 + | +LL | pub use $crate::self as _m_self8; + | ^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider importing the module directly + | +LL - pub use $crate::self as _m_self8; +LL + pub use $crate as _m_self8; + | +help: alternatively, use the multi-path `use` syntax to import `self` + | +LL | pub use $crate::{self as _m_self8}; + | + + + +error: `$crate` may not be imported + --> $DIR/use-path-segment-kw.rs:66:9 + | +LL | pub use $crate::self as _m_self8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0252]: the name `` is defined multiple times + --> $DIR/use-path-segment-kw.rs:63:13 + | +LL | use $crate; + | ------ previous import of the module `` here +... +LL | use $crate::self; + | ^^^^^^^^^^^^ `` reimported here +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: `` must be defined only once in the type namespace of this module + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0252]: the name `$crate` is defined multiple times + --> $DIR/use-path-segment-kw.rs:68:22 + | +LL | use self::$crate; + | ------------ previous import of the module `$crate` here +... +LL | use $crate::{self}; + | -------------^^^^-- + | | | + | | `$crate` reimported here + | help: remove unnecessary import +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: `$crate` must be defined only once in the type namespace of this module + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `crate` + --> $DIR/use-path-segment-kw.rs:102:13 + | +LL | use ::crate; + | ^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate` + --> $DIR/use-path-segment-kw.rs:104:13 + | +LL | use ::crate as _crate2; + | ^^^^^^^^^^^^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate` + --> $DIR/use-path-segment-kw.rs:105:16 + | +LL | use ::{crate}; + | ^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate` + --> $DIR/use-path-segment-kw.rs:107:16 + | +LL | use ::{crate as _nested_crate2}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `foobar::crate` + --> $DIR/use-path-segment-kw.rs:110:13 + | +LL | use foobar::crate; + | ^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::crate` + --> $DIR/use-path-segment-kw.rs:112:13 + | +LL | use foobar::crate as _crate3; + | ^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::crate` + --> $DIR/use-path-segment-kw.rs:113:22 + | +LL | use foobar::{crate}; + | ^^^^^ no `crate` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::crate` + --> $DIR/use-path-segment-kw.rs:115:22 + | +LL | use foobar::{crate as _nested_crate3}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo::bar::foobar` + +error[E0432]: unresolved import `crate::crate` + --> $DIR/use-path-segment-kw.rs:118:13 + | +LL | use crate::crate; + | ^^^^^^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate::crate` + --> $DIR/use-path-segment-kw.rs:120:13 + | +LL | use crate::crate as _crate4; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate::crate` + --> $DIR/use-path-segment-kw.rs:121:21 + | +LL | use crate::{crate}; + | ^^^^^ no `crate` in the root + +error[E0432]: unresolved import `crate::crate` + --> $DIR/use-path-segment-kw.rs:123:21 + | +LL | use crate::{crate as _nested_crate4}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root + +error[E0432]: unresolved import `super::crate` + --> $DIR/use-path-segment-kw.rs:126:13 + | +LL | use super::crate; + | ^^^^^^^^^^^^ no `crate` in `foo` + +error[E0432]: unresolved import `super::crate` + --> $DIR/use-path-segment-kw.rs:128:13 + | +LL | use super::crate as _crate5; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo` + +error[E0432]: unresolved import `super::crate` + --> $DIR/use-path-segment-kw.rs:129:21 + | +LL | use super::{crate}; + | ^^^^^ no `crate` in `foo` + +error[E0432]: unresolved import `super::crate` + --> $DIR/use-path-segment-kw.rs:131:21 + | +LL | use super::{crate as _nested_crate5}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in `foo` + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:143:13 + | +LL | use super::{}; + | ^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:146:13 + | +LL | use super; + | ^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:147:17 + | +LL | pub use super as _super; + | ^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:150:13 + | +LL | use ::super; + | ^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:151:13 + | +LL | use ::super as _super2; + | ^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:152:16 + | +LL | use ::{super}; + | ^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:153:16 + | +LL | use ::{super as _nested_super2}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `foobar::super` + --> $DIR/use-path-segment-kw.rs:156:13 + | +LL | use foobar::super; + | ^^^^^^^^^^^^^ no `super` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::super` + --> $DIR/use-path-segment-kw.rs:157:13 + | +LL | use foobar::super as _super3; + | ^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::super` + --> $DIR/use-path-segment-kw.rs:158:22 + | +LL | use foobar::{super}; + | ^^^^^ no `super` in `foo::bar::foobar` + +error[E0432]: unresolved import `foobar::super` + --> $DIR/use-path-segment-kw.rs:159:22 + | +LL | use foobar::{super as _nested_super3}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo::bar::foobar` + +error[E0432]: unresolved import `crate::super` + --> $DIR/use-path-segment-kw.rs:162:13 + | +LL | use crate::super; + | ^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `crate::super` + --> $DIR/use-path-segment-kw.rs:163:13 + | +LL | use crate::super as _super4; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `crate::super` + --> $DIR/use-path-segment-kw.rs:164:21 + | +LL | use crate::{super}; + | ^^^^^ no `super` in the root + +error[E0432]: unresolved import `crate::super` + --> $DIR/use-path-segment-kw.rs:165:21 + | +LL | use crate::{super as _nested_super4}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super::super` + --> $DIR/use-path-segment-kw.rs:168:13 + | +LL | use super::super; + | ^^^^^^^^^^^^ no `super` in `foo` + +error[E0432]: unresolved import `super::super` + --> $DIR/use-path-segment-kw.rs:169:17 + | +LL | pub use super::super as _super5; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo` + +error[E0432]: unresolved import `super::super` + --> $DIR/use-path-segment-kw.rs:170:21 + | +LL | use super::{super}; + | ^^^^^ no `super` in `foo` + +error[E0432]: unresolved import `super::super` + --> $DIR/use-path-segment-kw.rs:171:25 + | +LL | pub use super::{super as _nested_super5}; + | ^^^^^^^^^^^^^^^^^^^^^^^ no `super` in `foo` + +error[E0432]: unresolved import `self` + --> $DIR/use-path-segment-kw.rs:181:13 + | +LL | use self::{}; + | ^^^^^^^^ no `self` in the root + +error[E0432]: unresolved import `{{root}}` + --> $DIR/use-path-segment-kw.rs:188:13 + | +LL | use ::self; + | ^^^^^^ no `{{root}}` in the root + +error[E0432]: unresolved import `{{root}}` + --> $DIR/use-path-segment-kw.rs:190:13 + | +LL | use ::self as _self2; + | ^^^^^^^^^^^^^^^^ no `{{root}}` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:211:13 + | +LL | use super::self; + | ^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:213:17 + | +LL | pub use super::self as _self5; + | ^^^^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:215:21 + | +LL | use super::{self}; + | ^^^^ no `super` in the root + +error[E0432]: unresolved import `super` + --> $DIR/use-path-segment-kw.rs:216:25 + | +LL | pub use super::{self as _nested_self5}; + | ^^^^^^^^^^^^^^^^^^^^^ no `super` in the root + +error[E0432]: unresolved import `self` + --> $DIR/use-path-segment-kw.rs:221:20 + | +LL | use self::{self}; + | ^^^^ no `self` in the root + +error[E0432]: unresolved import `self` + --> $DIR/use-path-segment-kw.rs:222:24 + | +LL | pub use self::{self as _nested_self6}; + | ^^^^^^^^^^^^^^^^^^^^^ no `self` in the root + +error[E0432]: unresolved import `$crate` + --> $DIR/use-path-segment-kw.rs:13:13 + | +LL | use ::$crate; + | ^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate` + --> $DIR/use-path-segment-kw.rs:14:13 + | +LL | use ::$crate as _dollar_crate2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate` + --> $DIR/use-path-segment-kw.rs:15:16 + | +LL | use ::{$crate}; + | ^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate` + --> $DIR/use-path-segment-kw.rs:16:16 + | +LL | use ::{$crate as _nested_dollar_crate2}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `foobar::$crate` + --> $DIR/use-path-segment-kw.rs:19:13 + | +LL | use foobar::$crate; + | ^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `foobar::$crate` + --> $DIR/use-path-segment-kw.rs:20:13 + | +LL | use foobar::$crate as _dollar_crate3; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `foobar::$crate` + --> $DIR/use-path-segment-kw.rs:21:22 + | +LL | use foobar::{$crate}; + | ^^^^^^ no `$crate` in `foo::bar::foobar` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `foobar::$crate` + --> $DIR/use-path-segment-kw.rs:22:22 + | +LL | use foobar::{$crate as _nested_dollar_crate3}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo::bar::foobar` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `crate::$crate` + --> $DIR/use-path-segment-kw.rs:25:13 + | +LL | use crate::$crate; + | ^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `crate::$crate` + --> $DIR/use-path-segment-kw.rs:26:13 + | +LL | use crate::$crate as _dollar_crate4; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `crate::$crate` + --> $DIR/use-path-segment-kw.rs:27:21 + | +LL | use crate::{$crate}; + | ^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `crate::$crate` + --> $DIR/use-path-segment-kw.rs:28:21 + | +LL | use crate::{$crate as _nested_dollar_crate4}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `super::$crate` + --> $DIR/use-path-segment-kw.rs:31:13 + | +LL | use super::$crate; + | ^^^^^^^^^^^^^ no `$crate` in `foo` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `super::$crate` + --> $DIR/use-path-segment-kw.rs:32:13 + | +LL | use super::$crate as _dollar_crate5; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `super::$crate` + --> $DIR/use-path-segment-kw.rs:33:21 + | +LL | use super::{$crate}; + | ^^^^^^ no `$crate` in `foo` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `super::$crate` + --> $DIR/use-path-segment-kw.rs:34:21 + | +LL | use super::{$crate as _nested_dollar_crate5}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in `foo` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::$crate` + --> $DIR/use-path-segment-kw.rs:43:13 + | +LL | use $crate::$crate; + | ^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::$crate` + --> $DIR/use-path-segment-kw.rs:44:13 + | +LL | use $crate::$crate as _dollar_crate7; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::$crate` + --> $DIR/use-path-segment-kw.rs:45:22 + | +LL | use $crate::{$crate}; + | ^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::$crate` + --> $DIR/use-path-segment-kw.rs:46:22 + | +LL | use $crate::{$crate as _nested_dollar_crate7}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `$crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::crate` + --> $DIR/use-path-segment-kw.rs:49:13 + | +LL | use $crate::crate; + | ^^^^^^^^^^^^^ no `crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::crate` + --> $DIR/use-path-segment-kw.rs:51:13 + | +LL | use $crate::crate as _m_crate8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::crate` + --> $DIR/use-path-segment-kw.rs:52:22 + | +LL | use $crate::{crate}; + | ^^^^^ no `crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::crate` + --> $DIR/use-path-segment-kw.rs:54:22 + | +LL | use $crate::{crate as _m_nested_crate8}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ no `crate` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::super` + --> $DIR/use-path-segment-kw.rs:57:13 + | +LL | use $crate::super; + | ^^^^^^^^^^^^^ no `super` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::super` + --> $DIR/use-path-segment-kw.rs:58:13 + | +LL | use $crate::super as _m_super8; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::super` + --> $DIR/use-path-segment-kw.rs:59:22 + | +LL | use $crate::{super}; + | ^^^^^ no `super` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0432]: unresolved import `$crate::super` + --> $DIR/use-path-segment-kw.rs:60:22 + | +LL | use $crate::{super as _m_nested_super8}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ no `super` in the root +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0573]: expected type, found module `$crate` + --> $DIR/use-path-segment-kw.rs:8:19 + | +LL | type A1 = $crate; + | ^^^^^^ not a type +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0573]: expected type, found module `crate` + --> $DIR/use-path-segment-kw.rs:97:19 + | +LL | type B1 = crate; + | ^^^^^ not a type + +error[E0573]: expected type, found module `super` + --> $DIR/use-path-segment-kw.rs:145:19 + | +LL | type C1 = super; + | ^^^^^ not a type + +error[E0573]: expected type, found module `super::super` + --> $DIR/use-path-segment-kw.rs:167:19 + | +LL | type C5 = super::super; + | ^^^^^^^^^^^^ not a type + +error[E0573]: expected type, found module `self::super` + --> $DIR/use-path-segment-kw.rs:173:19 + | +LL | type C6 = self::super; + | ^^^^^^^^^^^ not a type + +error[E0573]: expected type, found module `self` + --> $DIR/use-path-segment-kw.rs:183:19 + | +LL | type D1 = self; + | ^^^^ not a type + +error[E0433]: failed to resolve: global paths cannot start with `$crate` + --> $DIR/use-path-segment-kw.rs:12:21 + | +LL | type A2 = ::$crate; + | ^^^^^^ global paths cannot start with `$crate` +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:18:27 + | +LL | type A3 = foobar::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:24:26 + | +LL | type A4 = crate::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:30:26 + | +LL | type A5 = super::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:36:25 + | +LL | type A6 = self::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:42:27 + | +LL | type A7 = $crate::$crate; + | ^^^^^^ `$crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:48:27 + | +LL | type A8 = $crate::crate; + | ^^^^^ `crate` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:56:27 + | +LL | type A9 = $crate::super; + | ^^^^^ `super` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:62:28 + | +LL | type A10 = $crate::self; + | ^^^^ `self` in paths can only be used in start position +... +LL | macro_dollar_crate!(); + | --------------------- in this macro invocation + | + = note: this error originates in the macro `macro_dollar_crate` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0433]: failed to resolve: global paths cannot start with `crate` + --> $DIR/use-path-segment-kw.rs:101:21 + | +LL | type B2 = ::crate; + | ^^^^^ global paths cannot start with `crate` + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:109:27 + | +LL | type B3 = foobar::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:117:26 + | +LL | type B4 = crate::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:125:26 + | +LL | type B5 = super::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: `crate` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:133:25 + | +LL | type B6 = self::crate; + | ^^^^^ `crate` in paths can only be used in start position + +error[E0433]: failed to resolve: global paths cannot start with `super` + --> $DIR/use-path-segment-kw.rs:149:21 + | +LL | type C2 = ::super; + | ^^^^^ global paths cannot start with `super` + +error[E0433]: failed to resolve: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:155:27 + | +LL | type C3 = foobar::super; + | ^^^^^ `super` in paths can only be used in start position + +error[E0433]: failed to resolve: `super` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:161:26 + | +LL | type C4 = crate::super; + | ^^^^^ `super` in paths can only be used in start position + +error[E0433]: failed to resolve: global paths cannot start with `self` + --> $DIR/use-path-segment-kw.rs:187:21 + | +LL | type D2 = ::self; + | ^^^^ global paths cannot start with `self` + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:195:27 + | +LL | type D3 = foobar::self; + | ^^^^ `self` in paths can only be used in start position + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:201:26 + | +LL | type D4 = crate::self; + | ^^^^ `self` in paths can only be used in start position + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:210:26 + | +LL | type D5 = super::self; + | ^^^^ `self` in paths can only be used in start position + +error[E0433]: failed to resolve: `self` in paths can only be used in start position + --> $DIR/use-path-segment-kw.rs:218:25 + | +LL | type D6 = self::self; + | ^^^^ `self` in paths can only be used in start position + +error: aborting due to 141 previous errors + +Some errors have detailed explanations: E0252, E0429, E0431, E0432, E0433, E0573. +For more information about an error, try `rustc --explain E0252`. From d340ea520b8981f088c7930821dc2b4a80c202f3 Mon Sep 17 00:00:00 2001 From: lapla-cogito Date: Fri, 21 Nov 2025 14:04:06 +0900 Subject: [PATCH 119/194] Fix ICE when collecting opaques from trait method declarations --- compiler/rustc_ty_utils/src/opaque_types.rs | 5 ++- .../ice-148622-opaque-as-const-generics.rs | 12 +++++++ ...ice-148622-opaque-as-const-generics.stderr | 31 +++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/ui/impl-trait/ice-148622-opaque-as-const-generics.rs create mode 100644 tests/ui/impl-trait/ice-148622-opaque-as-const-generics.stderr diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs index 4dd45a09a4df..445021801bef 100644 --- a/compiler/rustc_ty_utils/src/opaque_types.rs +++ b/compiler/rustc_ty_utils/src/opaque_types.rs @@ -64,7 +64,10 @@ fn visit_spanned(&mut self, span: Span, value: impl TypeVisitable>) #[instrument(level = "trace", skip(self))] fn collect_taits_declared_in_body(&mut self) { - let body = self.tcx.hir_body_owned_by(self.item).value; + let Some(body) = self.tcx.hir_maybe_body_owned_by(self.item) else { + return; + }; + let body = body.value; struct TaitInBodyFinder<'a, 'tcx> { collector: &'a mut OpaqueTypeCollector<'tcx>, } diff --git a/tests/ui/impl-trait/ice-148622-opaque-as-const-generics.rs b/tests/ui/impl-trait/ice-148622-opaque-as-const-generics.rs new file mode 100644 index 000000000000..03741dca3297 --- /dev/null +++ b/tests/ui/impl-trait/ice-148622-opaque-as-const-generics.rs @@ -0,0 +1,12 @@ +#![feature(type_alias_impl_trait)] + +pub type Opaque = impl std::future::Future; +//~^ ERROR: unconstrained opaque type + +trait Foo { + //~^ ERROR: `Opaque` is forbidden as the type of a const generic parameter + fn bar(&self) -> [u8; N]; + //~^ ERROR: the constant `N` is not of type `usize` +} + +fn main() {} diff --git a/tests/ui/impl-trait/ice-148622-opaque-as-const-generics.stderr b/tests/ui/impl-trait/ice-148622-opaque-as-const-generics.stderr new file mode 100644 index 000000000000..bc76c6fe85e7 --- /dev/null +++ b/tests/ui/impl-trait/ice-148622-opaque-as-const-generics.stderr @@ -0,0 +1,31 @@ +error: `Opaque` is forbidden as the type of a const generic parameter + --> $DIR/ice-148622-opaque-as-const-generics.rs:6:20 + | +LL | trait Foo { + | ^^^^^^ + | + = note: the only supported types are integers, `bool`, and `char` + +error: the constant `N` is not of type `usize` + --> $DIR/ice-148622-opaque-as-const-generics.rs:8:22 + | +LL | fn bar(&self) -> [u8; N]; + | ^^^^^^^ expected `usize`, found future + | +note: this item must have a `#[define_opaque(Opaque)]` attribute to be able to define hidden types + --> $DIR/ice-148622-opaque-as-const-generics.rs:8:8 + | +LL | fn bar(&self) -> [u8; N]; + | ^^^ + = note: the length of array `[u8; N]` must be type `usize` + +error: unconstrained opaque type + --> $DIR/ice-148622-opaque-as-const-generics.rs:3:19 + | +LL | pub type Opaque = impl std::future::Future; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `Opaque` must be used in combination with a concrete type within the same crate + +error: aborting due to 3 previous errors + From a4ee7f896486006e3bf6e9ddbf59670c6ead10ee Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Fri, 21 Nov 2025 23:03:39 +0900 Subject: [PATCH 120/194] Add regression test for 128705 --- .../dyn-compatibility/no-duplicate-e0038.rs | 17 ++++++++++++++++ .../no-duplicate-e0038.stderr | 20 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/ui/dyn-compatibility/no-duplicate-e0038.rs create mode 100644 tests/ui/dyn-compatibility/no-duplicate-e0038.stderr diff --git a/tests/ui/dyn-compatibility/no-duplicate-e0038.rs b/tests/ui/dyn-compatibility/no-duplicate-e0038.rs new file mode 100644 index 000000000000..283164596d06 --- /dev/null +++ b/tests/ui/dyn-compatibility/no-duplicate-e0038.rs @@ -0,0 +1,17 @@ +// Test that E0038 is not emitted twice for the same trait object coercion +// regression test for issue + +#![allow(dead_code)] + +trait Tr { + const N: usize; +} + +impl Tr for u8 { + const N: usize = 1; +} + +fn main() { + let x: &dyn Tr = &0_u8; + //~^ ERROR E0038 +} diff --git a/tests/ui/dyn-compatibility/no-duplicate-e0038.stderr b/tests/ui/dyn-compatibility/no-duplicate-e0038.stderr new file mode 100644 index 000000000000..94037387c3e1 --- /dev/null +++ b/tests/ui/dyn-compatibility/no-duplicate-e0038.stderr @@ -0,0 +1,20 @@ +error[E0038]: the trait `Tr` is not dyn compatible + --> $DIR/no-duplicate-e0038.rs:15:17 + | +LL | let x: &dyn Tr = &0_u8; + | ^^ `Tr` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit + --> $DIR/no-duplicate-e0038.rs:7:11 + | +LL | trait Tr { + | -- this trait is not dyn compatible... +LL | const N: usize; + | ^ ...because it contains this associated `const` + = help: consider moving `N` to another trait + = help: only type `u8` implements `Tr`; consider using it directly instead. + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0038`. From 7f7b3488c0258e1059426611267b5bd4ec068ac0 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 11 Nov 2025 15:51:24 +0000 Subject: [PATCH 121/194] Introduce InlineAsmError type --- compiler/rustc_codegen_llvm/src/back/write.rs | 16 +++++++--- compiler/rustc_codegen_ssa/src/back/write.rs | 31 ++++++++++--------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index fde7dd6ef7a8..95539059653b 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -9,8 +9,8 @@ use rustc_codegen_ssa::back::link::ensure_removed; use rustc_codegen_ssa::back::versioned_llvm_target; use rustc_codegen_ssa::back::write::{ - BitcodeSection, CodegenContext, EmitObj, ModuleConfig, TargetMachineFactoryConfig, - TargetMachineFactoryFn, + BitcodeSection, CodegenContext, EmitObj, InlineAsmError, ModuleConfig, + TargetMachineFactoryConfig, TargetMachineFactoryFn, }; use rustc_codegen_ssa::base::wants_wasm_eh; use rustc_codegen_ssa::traits::*; @@ -434,7 +434,7 @@ fn report_inline_asm( level: llvm::DiagnosticLevel, cookie: u64, source: Option<(String, Vec)>, -) { +) -> InlineAsmError { // In LTO build we may get srcloc values from other crates which are invalid // since they use a different source map. To be safe we just suppress these // in LTO builds. @@ -454,7 +454,7 @@ fn report_inline_asm( llvm::DiagnosticLevel::Note | llvm::DiagnosticLevel::Remark => Level::Note, }; let msg = msg.trim_prefix("error: ").to_string(); - cgcx.diag_emitter.inline_asm_error(span, msg, level, source); + InlineAsmError { span, msg, level, source } } unsafe extern "C" fn diagnostic_handler(info: &DiagnosticInfo, user: *mut c_void) { @@ -466,7 +466,13 @@ fn report_inline_asm( match unsafe { llvm::diagnostic::Diagnostic::unpack(info) } { llvm::diagnostic::InlineAsm(inline) => { - report_inline_asm(cgcx, inline.message, inline.level, inline.cookie, inline.source); + cgcx.diag_emitter.inline_asm_error(report_inline_asm( + cgcx, + inline.message, + inline.level, + inline.cookie, + inline.source, + )); } llvm::diagnostic::Optimization(opt) => { diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index fc1edec8de84..3073b1641ac7 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1897,10 +1897,17 @@ fn spawn_thin_lto_work<'a, B: ExtraBackendMethods>( enum SharedEmitterMessage { Diagnostic(Diagnostic), - InlineAsmError(SpanData, String, Level, Option<(String, Vec)>), + InlineAsmError(InlineAsmError), Fatal(String), } +pub struct InlineAsmError { + pub span: SpanData, + pub msg: String, + pub level: Level, + pub source: Option<(String, Vec)>, +} + #[derive(Clone)] pub struct SharedEmitter { sender: Sender, @@ -1917,14 +1924,8 @@ fn new() -> (SharedEmitter, SharedEmitterMain) { (SharedEmitter { sender }, SharedEmitterMain { receiver }) } - pub fn inline_asm_error( - &self, - span: SpanData, - msg: String, - level: Level, - source: Option<(String, Vec)>, - ) { - drop(self.sender.send(SharedEmitterMessage::InlineAsmError(span, msg, level, source))); + pub fn inline_asm_error(&self, err: InlineAsmError) { + drop(self.sender.send(SharedEmitterMessage::InlineAsmError(err))); } fn fatal(&self, msg: &str) { @@ -2007,15 +2008,15 @@ fn check(&self, sess: &Session, blocking: bool) { dcx.emit_diagnostic(d); sess.dcx().abort_if_errors(); } - Ok(SharedEmitterMessage::InlineAsmError(span, msg, level, source)) => { - assert_matches!(level, Level::Error | Level::Warning | Level::Note); - let mut err = Diag::<()>::new(sess.dcx(), level, msg); - if !span.is_dummy() { - err.span(span.span()); + Ok(SharedEmitterMessage::InlineAsmError(inner)) => { + assert_matches!(inner.level, Level::Error | Level::Warning | Level::Note); + let mut err = Diag::<()>::new(sess.dcx(), inner.level, inner.msg); + if !inner.span.is_dummy() { + err.span(inner.span.span()); } // Point to the generated assembly if it is available. - if let Some((buffer, spans)) = source { + if let Some((buffer, spans)) = inner.source { let source = sess .source_map() .new_source_file(FileName::inline_asm_source_code(&buffer), buffer); From bba5f7f72b6d1aacd12442d538419fac480b6393 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 21 Nov 2025 13:46:19 +0000 Subject: [PATCH 122/194] Remove unused pop_span_label method --- compiler/rustc_error_messages/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index 64dcf3c1f72d..085403c8ef36 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -455,10 +455,6 @@ pub fn replace(&mut self, before: Span, after: Span) -> bool { replacements_occurred } - pub fn pop_span_label(&mut self) -> Option<(Span, DiagMessage)> { - self.span_labels.pop() - } - /// Returns the strings to highlight. We always ensure that there /// is an entry for each of the primary spans -- for each primary /// span `P`, if there is at least one label with span `P`, we return From 2a280130db7b6fa5a52ee42f68e130d101e73607 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 21 Nov 2025 13:46:51 +0000 Subject: [PATCH 123/194] Allow passing primary spans to SharedEmitter --- compiler/rustc_codegen_ssa/src/back/write.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 3073b1641ac7..3e36bd8552b1 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1208,6 +1208,7 @@ pub(crate) enum ThinLtoMessage { // - `is_lint`: lints aren't relevant during codegen. // - `emitted_at`: not used for codegen diagnostics. struct Diagnostic { + span: Vec, level: Level, messages: Vec<(DiagMessage, Style)>, code: Option, @@ -1218,7 +1219,7 @@ struct Diagnostic { // A cut-down version of `rustc_errors::Subdiag` that impls `Send`. It's // missing the following fields from `rustc_errors::Subdiag`. // - `span`: it doesn't impl `Send`. -pub(crate) struct Subdiagnostic { +struct Subdiagnostic { level: Level, messages: Vec<(DiagMessage, Style)>, } @@ -1941,7 +1942,7 @@ fn emit_diagnostic( ) { // Check that we aren't missing anything interesting when converting to // the cut-down local `DiagInner`. - assert_eq!(diag.span, MultiSpan::new()); + assert!(!diag.span.has_span_labels()); assert_eq!(diag.suggestions, Suggestions::Enabled(vec![])); assert_eq!(diag.sort_span, rustc_span::DUMMY_SP); assert_eq!(diag.is_lint, None); @@ -1950,6 +1951,7 @@ fn emit_diagnostic( let args = mem::replace(&mut diag.args, DiagArgMap::default()); drop( self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic { + span: diag.span.primary_spans().iter().map(|span| span.data()).collect::>(), level: diag.level(), messages: diag.messages, code: diag.code, @@ -1994,6 +1996,9 @@ fn check(&self, sess: &Session, blocking: bool) { let dcx = sess.dcx(); let mut d = rustc_errors::DiagInner::new_with_messages(diag.level, diag.messages); + d.span = MultiSpan::from_spans( + diag.span.into_iter().map(|span| span.span()).collect(), + ); d.code = diag.code; // may be `None`, that's ok d.children = diag .children From 3ad82500ba53c5ad03695e5c57f3a77b3098bfeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Wed, 1 Oct 2025 14:54:21 +0200 Subject: [PATCH 124/194] Add `rust-mingw` component for `*-windows-gnullvm` hosts --- .../src/spec/base/windows_gnullvm.rs | 16 ++++--- .../targets/aarch64_pc_windows_gnullvm.rs | 3 +- .../spec/targets/x86_64_pc_windows_gnullvm.rs | 1 + src/bootstrap/src/core/build_steps/compile.rs | 2 +- src/bootstrap/src/core/build_steps/dist.rs | 48 ++++++++++++++++++- .../src/core/config/target_selection.rs | 4 ++ src/tools/build-manifest/src/main.rs | 2 +- 7 files changed, 65 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_target/src/spec/base/windows_gnullvm.rs b/compiler/rustc_target/src/spec/base/windows_gnullvm.rs index 58aff198a660..3bd8ebd0ed3d 100644 --- a/compiler/rustc_target/src/spec/base/windows_gnullvm.rs +++ b/compiler/rustc_target/src/spec/base/windows_gnullvm.rs @@ -1,8 +1,9 @@ use std::borrow::Cow; +use crate::spec::crt_objects::pre_mingw_self_contained; use crate::spec::{ - Abi, BinaryFormat, Cc, DebuginfoKind, Env, LinkerFlavor, Lld, Os, SplitDebuginfo, - TargetOptions, cvs, + Abi, BinaryFormat, Cc, DebuginfoKind, Env, LinkSelfContainedDefault, LinkerFlavor, Lld, Os, + SplitDebuginfo, TargetOptions, add_link_args, cvs, }; pub(crate) fn opts() -> TargetOptions { @@ -15,10 +16,11 @@ pub(crate) fn opts() -> TargetOptions { &["-nolibc", "--unwindlib=none"], ); // Order of `late_link_args*` does not matter with LLD. - let late_link_args = TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-lmingw32", "-lmingwex", "-lmsvcrt", "-lkernel32", "-luser32"], - ); + let mingw_libs = &["-lmingw32", "-lmingwex", "-lmsvcrt", "-lkernel32", "-luser32"]; + + let mut late_link_args = + TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs); + add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs); TargetOptions { os: Os::Windows, @@ -36,6 +38,8 @@ pub(crate) fn opts() -> TargetOptions { binary_format: BinaryFormat::Coff, allows_weak_linkage: false, pre_link_args, + pre_link_objects_self_contained: pre_mingw_self_contained(), + link_self_contained: LinkSelfContainedDefault::InferredForMingw, late_link_args, abi_return_struct_as_int: true, emit_debug_gdb_scripts: false, diff --git a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs index 9b7db11e2f29..b6f82e5ccbf4 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs @@ -1,10 +1,11 @@ -use crate::spec::{Arch, FramePointer, Target, TargetMetadata, base}; +use crate::spec::{Arch, Cc, FramePointer, LinkerFlavor, Lld, Target, TargetMetadata, base}; pub(crate) fn target() -> Target { let mut base = base::windows_gnullvm::opts(); base.max_atomic_width = Some(128); base.features = "+v8a,+neon,+fp-armv8".into(); base.linker = Some("aarch64-w64-mingw32-clang".into()); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-m", "arm64pe"]); // Microsoft recommends enabling frame pointers on Arm64 Windows. // From https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs index 28c9e6251255..938f1e49f1ef 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs @@ -6,6 +6,7 @@ pub(crate) fn target() -> Target { base.features = "+cx16,+sse3,+sahf".into(); base.plt_by_default = false; base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); + base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-m", "i386pep"]); base.max_atomic_width = Some(128); base.linker = Some("x86_64-w64-mingw32-clang".into()); diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 6857a40ada81..a6704a5675a1 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -448,7 +448,7 @@ fn copy_self_contained_objects( DependencyType::TargetSelfContained, ); } - } else if target.is_windows_gnu() { + } else if target.is_windows_gnu() || target.is_windows_gnullvm() { for obj in ["crt2.o", "dllcrt2.o"].iter() { let src = compiler_file(builder, &builder.cc(target), target, CLang::C, obj); let dst = libdir_self_contained.join(obj); diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 411d42962644..8bdabb45f0b6 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -295,6 +295,44 @@ fn make_win_dist(plat_root: &Path, target: TargetSelection, builder: &Builder<'_ } } +fn make_win_llvm_dist(plat_root: &Path, target: TargetSelection, builder: &Builder<'_>) { + if builder.config.dry_run() { + return; + } + + let (_, lib_path) = get_cc_search_dirs(target, builder); + + // Libraries necessary to link the windows-gnullvm toolchains. + // System libraries will be preferred if they are available (see #67429). + let target_libs = [ + // MinGW libs + "libunwind.a", + "libunwind.dll.a", + "libmingw32.a", + "libmingwex.a", + "libmsvcrt.a", + // Windows import libs, remove them once std transitions to raw-dylib + "libkernel32.a", + "libuser32.a", + "libntdll.a", + "libuserenv.a", + "libws2_32.a", + "libdbghelp.a", + ]; + + //Find mingw artifacts we want to bundle + let target_libs = find_files(&target_libs, &lib_path); + + //Copy platform libs to platform-specific lib directory + let plat_target_lib_self_contained_dir = + plat_root.join("lib/rustlib").join(target).join("lib/self-contained"); + fs::create_dir_all(&plat_target_lib_self_contained_dir) + .expect("creating plat_target_lib_self_contained_dir failed"); + for src in target_libs { + builder.copy_link_to_folder(&src, &plat_target_lib_self_contained_dir); + } +} + fn runtime_dll_dist(rust_root: &Path, target: TargetSelection, builder: &Builder<'_>) { if builder.config.dry_run() { return; @@ -394,14 +432,20 @@ fn make_run(run: RunConfig<'_>) { fn run(self, builder: &Builder<'_>) -> Option { let target = self.target; - if !target.ends_with("pc-windows-gnu") || !builder.config.dist_include_mingw_linker { + if !target.contains("pc-windows-gnu") || !builder.config.dist_include_mingw_linker { return None; } let mut tarball = Tarball::new(builder, "rust-mingw", &target.triple); tarball.set_product_name("Rust MinGW"); - make_win_dist(tarball.image_dir(), target, builder); + if target.ends_with("pc-windows-gnu") { + make_win_dist(tarball.image_dir(), target, builder); + } else if target.ends_with("pc-windows-gnullvm") { + make_win_llvm_dist(tarball.image_dir(), target, builder); + } else { + unreachable!(); + } Some(tarball.generate()) } diff --git a/src/bootstrap/src/core/config/target_selection.rs b/src/bootstrap/src/core/config/target_selection.rs index 40b63a7f9c75..47f6d6f386df 100644 --- a/src/bootstrap/src/core/config/target_selection.rs +++ b/src/bootstrap/src/core/config/target_selection.rs @@ -86,6 +86,10 @@ pub fn is_windows_gnu(&self) -> bool { self.ends_with("windows-gnu") } + pub fn is_windows_gnullvm(&self) -> bool { + self.ends_with("windows-gnullvm") + } + pub fn is_cygwin(&self) -> bool { self.is_windows() && // ref. https://cygwin.com/pipermail/cygwin/2022-February/250802.html diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 9bae8b241a94..4ffd17ae5218 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -476,7 +476,7 @@ fn target_host_combination(&mut self, host: &str, manifest: &Manifest) -> Option } // so is rust-mingw if it's available for the target PkgType::RustMingw => { - if host.ends_with("pc-windows-gnu") { + if host.contains("pc-windows-gnu") { components.push(host_component(pkg)); } } From 6e63c3946726549f0b191e934764e74f9d57d1ee Mon Sep 17 00:00:00 2001 From: Karol Zwolak Date: Mon, 10 Nov 2025 13:16:24 +0100 Subject: [PATCH 125/194] feat: add rust.rustflags and per target rustflags options to bootstrap.toml This makes easy to persistently pass any flag to the compiler when building rustc. For example you can use a different linker by putting the following in `bootstrap.toml`: ```toml [rust] rustflags = ["-Clinker=clang", "-Clink-arg=--ld-path=wild"] ``` --- bootstrap.example.toml | 12 ++++++++++++ src/bootstrap/src/core/builder/cargo.rs | 16 ++++++++++++++++ src/bootstrap/src/core/config/config.rs | 5 +++++ src/bootstrap/src/core/config/toml/rust.rs | 2 ++ src/bootstrap/src/core/config/toml/target.rs | 2 ++ src/bootstrap/src/utils/change_tracker.rs | 5 +++++ 6 files changed, 42 insertions(+) diff --git a/bootstrap.example.toml b/bootstrap.example.toml index 08e96fda0714..6a8da0305464 100644 --- a/bootstrap.example.toml +++ b/bootstrap.example.toml @@ -708,6 +708,12 @@ # desired in distributions, for example. #rust.rpath = true +# Additional flags to pass to `rustc`. +# Takes precedence over bootstrap's own flags but not over per target rustflags nor env. vars. like RUSTFLAGS. +# Applies to all stages and targets. +# +#rust.rustflags = [] + # Indicates whether symbols should be stripped using `-Cstrip=symbols`. #rust.strip = false @@ -1013,6 +1019,12 @@ # and will override the same option under [rust] section. It only works on Unix platforms #rpath = rust.rpath (bool) +# Additional flags to pass to `rustc`. +# Takes precedence over bootstrap's own flags and `rust.rustflags` but not over env. vars. like RUSTFLAGS. +# Applies to all stages. +# +#rustflags = rust.rustflags + # Force static or dynamic linkage of the standard library for this target. If # this target is a host for rustc, this will also affect the linkage of the # compiler itself. This is useful for building rustc on targets that normally diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index c38e14089854..a685a0f2d822 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -105,6 +105,7 @@ pub struct Cargo { allow_features: String, release_build: bool, build_compiler_stage: u32, + extra_rustflags: Vec, } impl Cargo { @@ -403,6 +404,11 @@ fn from(mut cargo: Cargo) -> BootstrapCommand { cargo.args.insert(0, "--release".into()); } + for arg in &cargo.extra_rustflags { + cargo.rustflags.arg(arg); + cargo.rustdocflags.arg(arg); + } + // Propagate the envs here at the very end to make sure they override any previously set flags. cargo.rustflags.propagate_rustflag_envs(cargo.build_compiler_stage); cargo.rustdocflags.propagate_rustflag_envs(cargo.build_compiler_stage); @@ -1379,6 +1385,15 @@ fn cargo( rustflags.arg("-Zmir_strip_debuginfo=locals-in-tiny-functions"); } + // take target-specific extra rustflags if any otherwise take `rust.rustflags` + let extra_rustflags = self + .config + .target_config + .get(&target) + .map(|t| &t.rustflags) + .unwrap_or(&self.config.rust_rustflags) + .clone(); + let release_build = self.config.rust_optimize.is_release() && // cargo bench/install do not accept `--release` and miri doesn't want it !matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest); @@ -1394,6 +1409,7 @@ fn cargo( allow_features, release_build, build_compiler_stage, + extra_rustflags, } } } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 9ad22e9de565..2f493658ec0e 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -225,6 +225,7 @@ pub struct Config { pub rust_std_features: BTreeSet, pub rust_break_on_ice: bool, pub rust_parallel_frontend_threads: Option, + pub rust_rustflags: Vec, pub llvm_profile_use: Option, pub llvm_profile_generate: bool, @@ -575,6 +576,7 @@ pub(crate) fn parse_inner( bootstrap_override_lld_legacy: rust_bootstrap_override_lld_legacy, std_features: rust_std_features, break_on_ice: rust_break_on_ice, + rustflags: rust_rustflags, } = toml.rust.unwrap_or_default(); let Llvm { @@ -864,6 +866,7 @@ pub(crate) fn parse_inner( sanitizers: target_sanitizers, profiler: target_profiler, rpath: target_rpath, + rustflags: target_rustflags, crt_static: target_crt_static, musl_root: target_musl_root, musl_libdir: target_musl_libdir, @@ -947,6 +950,7 @@ pub(crate) fn parse_inner( target.sanitizers = target_sanitizers; target.profiler = target_profiler; target.rpath = target_rpath; + target.rustflags = target_rustflags.unwrap_or_default(); target.optimized_compiler_builtins = target_optimized_compiler_builtins; target.jemalloc = target_jemalloc; if let Some(backends) = target_codegen_backends { @@ -1441,6 +1445,7 @@ pub(crate) fn parse_inner( rust_randomize_layout: rust_randomize_layout.unwrap_or(false), rust_remap_debuginfo: rust_remap_debuginfo.unwrap_or(false), rust_rpath: rust_rpath.unwrap_or(true), + rust_rustflags: rust_rustflags.unwrap_or_default(), rust_stack_protector, rust_std_features: rust_std_features .unwrap_or(BTreeSet::from([String::from("panic-unwind")])), diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index a9089ba499a4..48042ba56bb6 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -33,6 +33,7 @@ struct Rust { channel: Option = "channel", musl_root: Option = "musl-root", rpath: Option = "rpath", + rustflags: Option> = "rustflags", strip: Option = "strip", frame_pointers: Option = "frame-pointers", stack_protector: Option = "stack-protector", @@ -375,6 +376,7 @@ macro_rules! warn { parallel_frontend_threads: _, bootstrap_override_lld: _, bootstrap_override_lld_legacy: _, + rustflags: _, } = ci_rust_config; // There are two kinds of checks for CI rustc incompatible options: diff --git a/src/bootstrap/src/core/config/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs index 4c7afa50b965..847b75e696b4 100644 --- a/src/bootstrap/src/core/config/toml/target.rs +++ b/src/bootstrap/src/core/config/toml/target.rs @@ -37,6 +37,7 @@ struct TomlTarget { sanitizers: Option = "sanitizers", profiler: Option = "profiler", rpath: Option = "rpath", + rustflags: Option> = "rustflags", crt_static: Option = "crt-static", musl_root: Option = "musl-root", musl_libdir: Option = "musl-libdir", @@ -70,6 +71,7 @@ pub struct Target { pub sanitizers: Option, pub profiler: Option, pub rpath: Option, + pub rustflags: Vec, pub crt_static: Option, pub musl_root: Option, pub musl_libdir: Option, diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index 5f66d8a7d4c6..ed280addb3b8 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -596,4 +596,9 @@ pub fn human_readable_changes(changes: &[ChangeInfo]) -> String { severity: ChangeSeverity::Info, summary: "The `-Zannotate-moves` option is now always enabled when building rustc, sysroot and tools.", }, + ChangeInfo { + change_id: 148795, + severity: ChangeSeverity::Info, + summary: "New options `rust.rustflags` for all targets and `rustflags` par target that will pass specified flags to rustc for all stages. Target specific flags override global `rust.rustflags` ones.", + }, ]; From 98141e0beb94c3c96a225614a2e63b08c2dba5ac Mon Sep 17 00:00:00 2001 From: Jamie Hill-Daniel Date: Tue, 18 Nov 2025 17:39:37 +0000 Subject: [PATCH 126/194] Reduce confusing `unreachable_code` lints --- compiler/rustc_mir_build/src/builder/mod.rs | 46 ++++++++++++++++----- tests/ui/uninhabited/unreachable.rs | 34 +++++++++++++++ tests/ui/uninhabited/void-branch.rs | 6 ++- tests/ui/uninhabited/void-branch.stderr | 29 ++++++------- 4 files changed, 87 insertions(+), 28 deletions(-) create mode 100644 tests/ui/uninhabited/unreachable.rs diff --git a/compiler/rustc_mir_build/src/builder/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs index 092c34da2ba4..206eb9126f54 100644 --- a/compiler/rustc_mir_build/src/builder/mod.rs +++ b/compiler/rustc_mir_build/src/builder/mod.rs @@ -861,20 +861,46 @@ fn lint_and_remove_uninhabited(&mut self) { } } + /// Starting at a target unreachable block, find some user code to lint as unreachable + fn find_unreachable_code_from( + bb: BasicBlock, + bbs: &IndexVec>, + ) -> Option<(SourceInfo, &'static str)> { + let bb = &bbs[bb]; + for stmt in &bb.statements { + match &stmt.kind { + // Ignore the implicit `()` return place assignment for unit functions/blocks + StatementKind::Assign(box (_, Rvalue::Use(Operand::Constant(const_)))) + if const_.ty().is_unit() => + { + continue; + } + StatementKind::StorageLive(_) | StatementKind::StorageDead(_) => { + continue; + } + StatementKind::FakeRead(..) => return Some((stmt.source_info, "definition")), + _ => return Some((stmt.source_info, "expression")), + } + } + + let term = bb.terminator(); + match term.kind { + // No user code in this bb, and our goto target may be reachable via other paths + TerminatorKind::Goto { .. } | TerminatorKind::Return => None, + _ => Some((term.source_info, "expression")), + } + } + for (target_bb, orig_ty, orig_span) in lints { if orig_span.in_external_macro(self.tcx.sess.source_map()) { continue; } - let target_bb = &self.cfg.basic_blocks[target_bb]; - let (target_loc, descr) = target_bb - .statements - .iter() - .find_map(|stmt| match stmt.kind { - StatementKind::StorageLive(_) | StatementKind::StorageDead(_) => None, - StatementKind::FakeRead(..) => Some((stmt.source_info, "definition")), - _ => Some((stmt.source_info, "expression")), - }) - .unwrap_or_else(|| (target_bb.terminator().source_info, "expression")); + + let Some((target_loc, descr)) = + find_unreachable_code_from(target_bb, &self.cfg.basic_blocks) + else { + continue; + }; let lint_root = self.source_scopes[target_loc.scope] .local_data .as_ref() diff --git a/tests/ui/uninhabited/unreachable.rs b/tests/ui/uninhabited/unreachable.rs new file mode 100644 index 000000000000..e4a5ba406a72 --- /dev/null +++ b/tests/ui/uninhabited/unreachable.rs @@ -0,0 +1,34 @@ +//! Test that a diverging function as the final expression in a block does not +//! raise an 'unreachable code' lint. + +//@ check-pass +#![deny(unreachable_code)] + +enum Never {} + +fn make_never() -> Never { + loop {} +} + +fn func() { + make_never(); +} + +fn block() { + { + make_never(); + } +} + +fn branchy() { + if false { + make_never(); + } else { + make_never(); + } +} + +fn main() { + func(); + block(); +} diff --git a/tests/ui/uninhabited/void-branch.rs b/tests/ui/uninhabited/void-branch.rs index e000f946dc15..b9e1d7038291 100644 --- a/tests/ui/uninhabited/void-branch.rs +++ b/tests/ui/uninhabited/void-branch.rs @@ -6,8 +6,9 @@ enum Void {} fn with_void() { if false { unsafe { - //~^ ERROR unreachable expression std::mem::uninitialized::(); + println!(); + //~^ ERROR unreachable expression } } @@ -20,8 +21,9 @@ fn infallible() -> std::convert::Infallible { fn with_infallible() { if false { - //~^ ERROR unreachable expression infallible(); + println!() + //~^ ERROR unreachable expression } println!() diff --git a/tests/ui/uninhabited/void-branch.stderr b/tests/ui/uninhabited/void-branch.stderr index 7bbcb763ddf7..ee5efb94ed21 100644 --- a/tests/ui/uninhabited/void-branch.stderr +++ b/tests/ui/uninhabited/void-branch.stderr @@ -1,15 +1,13 @@ error: unreachable expression - --> $DIR/void-branch.rs:8:9 + --> $DIR/void-branch.rs:10:13 | -LL | / unsafe { -LL | | -LL | | std::mem::uninitialized::(); - | | --------------------------------- any code following this expression is unreachable -LL | | } - | |_________^ unreachable expression +LL | std::mem::uninitialized::(); + | --------------------------------- any code following this expression is unreachable +LL | println!(); + | ^^^^^^^^^^ unreachable expression | note: this expression has type `Void`, which is uninhabited - --> $DIR/void-branch.rs:10:13 + --> $DIR/void-branch.rs:9:13 | LL | std::mem::uninitialized::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,23 +16,22 @@ note: the lint level is defined here | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: unreachable expression - --> $DIR/void-branch.rs:22:14 + --> $DIR/void-branch.rs:25:9 | -LL | if false { - | ______________^ -LL | | -LL | | infallible(); - | | ------------ any code following this expression is unreachable -LL | | } - | |_____^ unreachable expression +LL | infallible(); + | ------------ any code following this expression is unreachable +LL | println!() + | ^^^^^^^^^^ unreachable expression | note: this expression has type `Infallible`, which is uninhabited --> $DIR/void-branch.rs:24:9 | LL | infallible(); | ^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors From 36bdffea595fd3ea1c9f445e10d29c4d2d07a829 Mon Sep 17 00:00:00 2001 From: Jamie Hill-Daniel Date: Sun, 16 Nov 2025 19:57:04 +0000 Subject: [PATCH 127/194] Bump compiler dependencies --- Cargo.lock | 1058 +++++++++----------- compiler/rustc/Cargo.toml | 7 + src/bootstrap/src/utils/proc_macro_deps.rs | 4 - src/tools/tidy/src/deps.rs | 11 +- 4 files changed, 514 insertions(+), 566 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9dce64ce66ab..8cd67fa3a17e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] @@ -43,12 +43,6 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - [[package]] name = "android_system_properties" version = "0.1.5" @@ -90,9 +84,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" dependencies = [ "anstyle", "anstyle-parse", @@ -129,11 +123,11 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" dependencies = [ - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -151,20 +145,20 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.10" +version = "3.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] name = "anyhow" -version = "1.0.99" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "ar_archive_writer" @@ -214,7 +208,7 @@ dependencies = [ "rustc-hash 2.1.1", "serde", "serde_derive", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -276,9 +270,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.9.3" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34efbcccd345379ca2868b2b2c9d3782e9cc58ba87bc7d79d5b53d9c9ae6f25d" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "blake3" @@ -303,13 +297,22 @@ dependencies = [ ] [[package]] -name = "bstr" -version = "1.12.0" +name = "block2" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2", +] + +[[package]] +name = "bstr" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63044e1ae8e69f3b5a92c736ca6269b8d12fa7efe39bf34ddb06d102cf0e2cab" dependencies = [ "memchr", - "regex-automata 0.4.9", + "regex-automata", "serde", ] @@ -365,11 +368,11 @@ checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e" [[package]] name = "camino" -version = "1.1.11" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d07aa9a93b00c76f71bc35d598bed923f6d4f3a9ca5c24b7737ae1a292841c0" +checksum = "276a59bf2b2c967788139340c9f0c5b12d7fd6630315c15c217e559de85d2609" dependencies = [ - "serde", + "serde_core", ] [[package]] @@ -442,7 +445,7 @@ dependencies = [ "serde", "serde-untagged", "serde-value", - "thiserror 2.0.15", + "thiserror 2.0.17", "toml 0.8.23", "unicode-xid", "url", @@ -474,7 +477,7 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror 2.0.15", + "thiserror 2.0.17", ] [[package]] @@ -488,7 +491,7 @@ dependencies = [ "semver", "serde", "serde_json", - "thiserror 2.0.15", + "thiserror 2.0.17", ] [[package]] @@ -508,9 +511,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" @@ -520,15 +523,14 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chrono" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" dependencies = [ - "android-tzdata", "iana-time-zone", "num-traits", "serde", - "windows-link 0.1.3", + "windows-link 0.2.1", ] [[package]] @@ -553,9 +555,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.45" +version = "4.5.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc0e74a703892159f5ae7d3aac52c8e6c392f5ae5f359c70b5881d60aaac318" +checksum = "4c26d721170e0295f191a69bd9a1f93efcdb0aff38684b61ab5750468972e5f5" dependencies = [ "clap_builder", "clap_derive", @@ -573,9 +575,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.44" +version = "4.5.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e7f4214277f3c7aa526a59dd3fbe306a370daee1f8b7b8c987069cd8e888a8" +checksum = "75835f0c7bf681bfd05abe44e965760fea999a5286c6eb2d59883634fd02011a" dependencies = [ "anstream", "anstyle", @@ -585,21 +587,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.45" +version = "4.5.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14cb31bb0a7d536caef2639baa7fad459e15c3144efefa6dbd1c84562c4739f6" +checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "clap_lex" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" +checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "clippy" @@ -623,7 +625,7 @@ dependencies = [ "serde_json", "tempfile", "termize", - "toml 0.9.7", + "toml 0.9.8", "ui_test", "walkdir", ] @@ -662,10 +664,10 @@ dependencies = [ "declare_clippy_lint", "itertools", "quine-mc_cluskey", - "regex-syntax 0.8.5", + "regex-syntax", "semver", "serde", - "toml 0.9.7", + "toml 0.9.8", "unicode-normalization", "unicode-script", "url", @@ -704,9 +706,9 @@ dependencies = [ [[package]] name = "codespan-reporting" -version = "0.12.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" dependencies = [ "serde", "termcolor", @@ -735,7 +737,7 @@ dependencies = [ "eyre", "indenter", "once_cell", - "owo-colors 4.2.2", + "owo-colors", "tracing-error", ] @@ -757,7 +759,7 @@ dependencies = [ "nom", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -767,7 +769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8b88ea9df13354b55bc7234ebcce36e6ef896aca2e42a15de9e10edce01b427" dependencies = [ "once_cell", - "owo-colors 4.2.2", + "owo-colors", "tracing-core", "tracing-error", ] @@ -829,7 +831,7 @@ dependencies = [ "tracing-subscriber", "unified-diff", "walkdir", - "windows 0.61.3", + "windows", ] [[package]] @@ -924,9 +926,9 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crypto-common" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", "typenum", @@ -934,12 +936,13 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.7" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f93780a459b7d656ef7f071fe699c4d3d2cb201c4b24d085b6ddc505276e73" +checksum = "73736a89c4aff73035ba2ed2e565061954da00d4970fc9ac25dcc85a2a20d790" dependencies = [ + "dispatch2", "nix", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -959,9 +962,9 @@ dependencies = [ [[package]] name = "curl-sys" -version = "0.4.83+curl-8.15.0" +version = "0.4.84+curl-8.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5830daf304027db10c82632a464879d46a3f7c4ba17a31592657ad16c719b483" +checksum = "abc4294dc41b882eaff37973c2ec3ae203d0091341ee68fbadd1d06e0c18a73b" dependencies = [ "cc", "libc", @@ -974,9 +977,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f81de88da10862f22b5b3a60f18f6f42bbe7cb8faa24845dd7b1e4e22190e77" +checksum = "47ac4eaf7ebe29e92f1b091ceefec7710a53a6f6154b2460afda626c113b65b9" dependencies = [ "cc", "cxx-build", @@ -989,9 +992,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5edd58bf75c3fdfc80d79806403af626570662f7b6cc782a7fabe156166bd6d6" +checksum = "2abd4c3021eefbac5149f994c117b426852bca3a0aad227698527bca6d4ea657" dependencies = [ "cc", "codespan-reporting", @@ -999,40 +1002,39 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "cxxbridge-cmd" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd46bf2b541a4e0c2d5abba76607379ee05d68e714868e3cb406dc8d591ce2d2" +checksum = "6f12fbc5888b2311f23e52a601e11ad7790d8f0dbb903ec26e2513bf5373ed70" dependencies = [ "clap", "codespan-reporting", "indexmap", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "cxxbridge-flags" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c79b68f6a3a8f809d39b38ae8af61305a6113819b19b262643b9c21353b92d9" +checksum = "83d3dd7870af06e283f3f8ce0418019c96171c9ce122cfb9c8879de3d84388fd" [[package]] name = "cxxbridge-macro" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862b7fdb048ff9ef0779a0d0a03affd09746c4c875543746b640756be9cff2af" +checksum = "a26f0d82da663316786791c3d0e9f9edc7d1ee1f04bdad3d2643086a69d6256c" dependencies = [ "indexmap", "proc-macro2", "quote", - "rustversion", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -1056,7 +1058,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -1067,7 +1069,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -1078,13 +1080,13 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69" [[package]] name = "dbus" -version = "0.9.7" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bb21987b9fb1613058ba3843121dd18b163b254d8a6e797e144cbac14d96d1b" +checksum = "190b6255e8ab55a7b568df5a883e9497edc3e4821c06396612048b430e5ad1e9" dependencies = [ "libc", "libdbus-sys", - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -1099,7 +1101,7 @@ checksum = "ef941ded77d15ca19b40374869ac6000af1c9f2a4c0f3d4c70926287e6364a8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -1120,7 +1122,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -1130,7 +1132,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -1142,7 +1144,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -1212,6 +1214,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "dispatch2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89a09f22a6c6069a18470eb92d2298acf25463f14256d24778e1230d789a2aec" +dependencies = [ + "bitflags", + "block2", + "libc", + "objc2", +] + [[package]] name = "displaydoc" version = "0.2.5" @@ -1220,7 +1234,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -1231,9 +1245,9 @@ checksum = "8975ffdaa0ef3661bfe02dbdcc06c9f829dfafe6a3c474de366a8d5e44276921" [[package]] name = "dyn-clone" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c7a8fb8a9fbf66c1f703fe16184d10ca0ee9d23be5b4436400408ba54a95005" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "either" @@ -1267,9 +1281,9 @@ checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "env_filter" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" +checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" dependencies = [ "log", "regex", @@ -1296,22 +1310,23 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "erased-serde" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7" +checksum = "89e8918065695684b2b0702da20382d5ae6065cf3327bc2d6436bd49a71ce9f3" dependencies = [ "serde", + "serde_core", "typeid", ] [[package]] name = "errno" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -1359,27 +1374,27 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.25" +version = "0.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +checksum = "bc0505cd1b6fa6580283f6bdf70a73fcf4aba1184038c90902b92b3dd0df63ed" dependencies = [ "cfg-if", "libc", "libredox", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] name = "find-msvc-tools" -version = "0.1.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959" +checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" [[package]] name = "flate2" -version = "1.1.2" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb" dependencies = [ "crc32fast", "miniz_oxide", @@ -1403,9 +1418,9 @@ dependencies = [ [[package]] name = "fluent-langneg" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c4ad0989667548f06ccd0e306ed56b61bd4d35458d54df5ec7587c0e8ed5e94" +checksum = "7eebbe59450baee8282d71676f3bfed5689aeab00b27545e83e5f14b1195e8b0" dependencies = [ "unic-langid", ] @@ -1417,7 +1432,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54f0d287c53ffd184d04d8677f590f4ac5379785529e5e08b1c8083acdd5c198" dependencies = [ "memchr", - "thiserror 2.0.15", + "thiserror 2.0.17", ] [[package]] @@ -1440,9 +1455,9 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "form_urlencoded" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" dependencies = [ "percent-encoding", ] @@ -1557,9 +1572,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.32.0" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93563d740bc9ef04104f9ed6f86f1e3275c2cdafb95664e26584b9ca807a8ffe" +checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" dependencies = [ "fallible-iterator", "indexmap", @@ -1589,15 +1604,15 @@ checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" [[package]] name = "globset" -version = "0.4.16" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a1028dfc5f5df5da8a56a73e6c153c9a9708ec57232470703592a3f18e49f5" +checksum = "52dfc19153a48bde0cbd630453615c8151bce3a5adfac7a0aebfbf0a1e1f57e3" dependencies = [ "aho-corasick", "bstr", "log", - "regex-automata 0.4.9", - "regex-syntax 0.8.5", + "regex-automata", + "regex-syntax", ] [[package]] @@ -1621,6 +1636,12 @@ dependencies = [ "serde", ] +[[package]] +name = "hashbrown" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" + [[package]] name = "heck" version = "0.4.1" @@ -1647,11 +1668,11 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "home" -version = "0.5.11" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -1694,15 +1715,15 @@ dependencies = [ [[package]] name = "humantime" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" +checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424" [[package]] name = "iana-time-zone" -version = "0.1.63" +version = "0.1.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1710,7 +1731,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core 0.61.2", + "windows-core 0.62.2", ] [[package]] @@ -1724,9 +1745,9 @@ dependencies = [ [[package]] name = "icu_collections" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" dependencies = [ "displaydoc", "potential_utf", @@ -1737,13 +1758,12 @@ dependencies = [ [[package]] name = "icu_list" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e26f94ec776bb8b28cedc7dcf91033b822c5cb4c1783cf7a3f796fc168aa0c8b" +checksum = "d3a0b7b126e2fc42777d3c348611553d540bd3683caa39b387c5dd1036bb21a8" dependencies = [ - "displaydoc", "icu_provider", - "regex-automata 0.4.9", + "regex-automata", "serde", "writeable", "zerovec", @@ -1751,11 +1771,10 @@ dependencies = [ [[package]] name = "icu_locale" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ae5921528335e91da1b6c695dbf1ec37df5ac13faa3f91e5640be93aa2fbefd" +checksum = "532b11722e350ab6bf916ba6eb0efe3ee54b932666afec989465f9243fe6dd60" dependencies = [ - "displaydoc", "icu_collections", "icu_locale_core", "icu_locale_data", @@ -1767,12 +1786,13 @@ dependencies = [ [[package]] name = "icu_locale_core" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" dependencies = [ "displaydoc", "litemap", + "serde", "tinystr", "writeable", "zerovec", @@ -1780,17 +1800,16 @@ dependencies = [ [[package]] name = "icu_locale_data" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fdef0c124749d06a743c69e938350816554eb63ac979166590e2b4ee4252765" +checksum = "f03e2fcaefecdf05619f3d6f91740e79ab969b4dd54f77cbf546b1d0d28e3147" [[package]] name = "icu_normalizer" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" dependencies = [ - "displaydoc", "icu_collections", "icu_normalizer_data", "icu_properties", @@ -1801,42 +1820,40 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" [[package]] name = "icu_properties" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" dependencies = [ - "displaydoc", "icu_collections", "icu_locale_core", "icu_properties_data", "icu_provider", - "potential_utf", "zerotrie", "zerovec", ] [[package]] name = "icu_properties_data" -version = "2.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" +checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" [[package]] name = "icu_provider" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" dependencies = [ "displaydoc", "icu_locale_core", + "serde", "stable_deref_trait", - "tinystr", "writeable", "yoke", "zerofrom", @@ -1858,9 +1875,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" dependencies = [ "idna_adapter", "smallvec", @@ -1879,15 +1896,15 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.23" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" +checksum = "d3d782a365a015e0f5c04902246139249abf769125006fbe7649e2ee88169b4a" dependencies = [ "crossbeam-deque", "globset", "log", "memchr", - "regex-automata 0.4.9", + "regex-automata", "same-file", "walkdir", "winapi-util", @@ -1901,12 +1918,12 @@ checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" [[package]] name = "indexmap" -version = "2.11.4" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.16.0", "serde", "serde_core", ] @@ -1973,9 +1990,9 @@ dependencies = [ [[package]] name = "ipc-channel" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1700f6b8b9f00cdd675f32fbb3a5be882213140dfe045805273221ca266c43f8" +checksum = "f93600b5616c2d075f8af8dbd23c1d69278c5d24e4913d220cbc60b14c95c180" dependencies = [ "bincode", "crossbeam-channel", @@ -1986,14 +2003,14 @@ dependencies = [ "serde", "tempfile", "uuid", - "windows 0.58.0", + "windows", ] [[package]] name = "is_terminal_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "itertools" @@ -2012,33 +2029,33 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jiff" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be1f93b8b1eb69c77f24bbb0afdf66f54b632ee39af40ca21c4365a1d7347e49" +checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35" dependencies = [ "jiff-static", "log", "portable-atomic", "portable-atomic-util", - "serde", + "serde_core", ] [[package]] name = "jiff-static" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4" +checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "jobserver" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" dependencies = [ "getrandom 0.3.3", "libc", @@ -2046,9 +2063,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" dependencies = [ "once_cell", "wasm-bindgen", @@ -2089,7 +2106,7 @@ dependencies = [ "pest_derive", "regex", "serde_json", - "thiserror 2.0.15", + "thiserror 2.0.17", ] [[package]] @@ -2130,9 +2147,9 @@ checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libdbus-sys" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72" +checksum = "5cbe856efeb50e4681f010e9aaa2bf0a644e10139e54cde10fc83a307c23bd9f" dependencies = [ "cc", "pkg-config", @@ -2172,12 +2189,12 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" dependencies = [ "cfg-if", - "windows-targets 0.53.3", + "windows-link 0.2.1", ] [[package]] @@ -2198,9 +2215,9 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" [[package]] name = "libredox" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3" +checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ "bitflags", "libc", @@ -2209,9 +2226,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.22" +version = "1.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d" +checksum = "15d118bbf3771060e7311cc7bb0545b01d08a8b4a7de949198dec1fa0ca1c0f7" dependencies = [ "cc", "libc", @@ -2255,9 +2272,9 @@ checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] name = "litemap" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" [[package]] name = "lld-wrapper" @@ -2276,19 +2293,18 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] [[package]] name = "log" -version = "0.4.27" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "lzma-sys" @@ -2329,16 +2345,16 @@ checksum = "88a9689d8d44bf9964484516275f5cd4c9b59457a6940c1d5d0ecbb94510a36b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "matchers" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" dependencies = [ - "regex-automata 0.1.10", + "regex-automata", ] [[package]] @@ -2399,17 +2415,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", + "simd-adler32", ] [[package]] name = "mio" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" dependencies = [ "libc", "wasi 0.11.1+wasi-snapshot-preview1", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -2485,30 +2502,20 @@ dependencies = [ [[package]] name = "normpath" -version = "1.3.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8911957c4b1549ac0dc74e30db9c8b0e66ddcd6d7acc33098f4c63a64a6d7ed" +checksum = "bf23ab2b905654b4cb177e30b629937b3868311d4e1cba859f899c041046e69b" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] name = "nu-ansi-term" -version = "0.46.0" +version = "0.50.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "nu-ansi-term" -version = "0.50.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" -dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2601,19 +2608,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] -name = "objc2-core-foundation" -version = "0.3.1" +name = "objc2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c10c2894a6fed806ade6027bcd50662746363a9589d3ec9d9bef30a4e4bc166" +checksum = "b7c2599ce0ec54857b29ce62166b0ed9b4f6f1a70ccc9a71165b6154caca8c05" +dependencies = [ + "objc2-encode", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ "bitflags", ] [[package]] -name = "objc2-io-kit" -version = "0.3.1" +name = "objc2-encode" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71c1c64d6120e51cd86033f67176b1cb66780c2efe34dec55176f77befd93c0a" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-io-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" dependencies = [ "libc", "objc2-core-foundation", @@ -2627,7 +2649,7 @@ checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "crc32fast", "flate2", - "hashbrown", + "hashbrown 0.15.5", "indexmap", "memchr", "ruzstd 0.7.3", @@ -2641,10 +2663,10 @@ checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" dependencies = [ "crc32fast", "flate2", - "hashbrown", + "hashbrown 0.15.5", "indexmap", "memchr", - "ruzstd 0.8.1", + "ruzstd 0.8.2", "wasmparser 0.236.1", ] @@ -2665,9 +2687,9 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "once_cell_polyfill" -version = "1.70.1" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "opener" @@ -2689,9 +2711,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.109" +version = "0.9.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" dependencies = [ "cc", "libc", @@ -2737,32 +2759,11 @@ dependencies = [ "num-traits", ] -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "owo-colors" -version = "3.5.0" +version = "4.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" - -[[package]] -name = "owo-colors" -version = "4.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e" - -[[package]] -name = "pad" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ad9b889f1b12e0b9ee24db044b5129150d5eada288edc800f789928dc8c0e3" -dependencies = [ - "unicode-width 0.1.14", -] +checksum = "9c6901729fa79e91a0913333229e9ca5dc725089d1c363b2f4b4760709dc4a52" [[package]] name = "papergrid" @@ -2777,9 +2778,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", "parking_lot_core", @@ -2787,15 +2788,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.6", + "windows-link 0.2.1", ] [[package]] @@ -2806,9 +2807,9 @@ checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" [[package]] name = "percent-encoding" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "perf-event-open-sys" @@ -2821,20 +2822,19 @@ dependencies = [ [[package]] name = "pest" -version = "2.8.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" +checksum = "989e7521a040efde50c3ab6bbadafbe15ab6dc042686926be59ac35d74607df4" dependencies = [ "memchr", - "thiserror 2.0.15", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.8.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc" +checksum = "187da9a3030dbafabbbfb20cb323b976dc7b7ce91fcd84f2f74d6e31d378e2de" dependencies = [ "pest", "pest_generator", @@ -2842,22 +2842,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966" +checksum = "49b401d98f5757ebe97a26085998d6c0eecec4995cad6ab7fc30ffdf4b052843" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "pest_meta" -version = "2.8.1" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5" +checksum = "72f27a2cfee9f9039c4d86faa5af122a0ac3851441a34865b8a043b46be0065a" dependencies = [ "pest", "sha2", @@ -2959,11 +2959,12 @@ dependencies = [ [[package]] name = "potential_utf" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" dependencies = [ - "serde", + "serde_core", + "writeable", "zerovec", ] @@ -2984,12 +2985,11 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "prettydiff" -version = "0.7.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abec3fb083c10660b3854367697da94c674e9e82aa7511014dc958beeb7215e9" +checksum = "ac17546d82912e64874e3d5b40681ce32eac4e5834344f51efcf689ff1550a65" dependencies = [ - "owo-colors 3.5.0", - "pad", + "owo-colors", ] [[package]] @@ -3000,9 +3000,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] @@ -3048,9 +3048,9 @@ checksum = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45" [[package]] name = "quote" -version = "1.0.40" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] @@ -3160,9 +3160,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ "bitflags", ] @@ -3186,78 +3186,63 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" dependencies = [ "getrandom 0.2.16", "libredox", - "thiserror 2.0.15", + "thiserror 2.0.17", ] [[package]] name = "ref-cast" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "regex" -version = "1.11.1" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.9", - "regex-syntax 0.8.5", + "regex-automata", + "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.1.10" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.5", + "regex-syntax", ] [[package]] name = "regex-lite" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" +checksum = "8d942b98df5e658f56f20d592c7f868833fe38115e65c33003d8cd224b0155da" [[package]] name = "regex-syntax" -version = "0.6.29" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "remote-test-client" @@ -3281,7 +3266,7 @@ version = "0.0.0" dependencies = [ "bstr", "build_helper", - "gimli 0.32.0", + "gimli 0.32.3", "libc", "object 0.37.3", "regex", @@ -3331,6 +3316,7 @@ checksum = "e4ee29da77c5a54f42697493cd4c9b9f31b74df666a6c04dfc4fde77abe0438b" name = "rustc-main" version = "0.0.0" dependencies = [ + "getrandom 0.3.3", "rustc_codegen_ssa", "rustc_driver", "rustc_driver_impl", @@ -3338,6 +3324,7 @@ dependencies = [ "rustc_public_bridge", "rustc_windows_rc", "tikv-jemalloc-sys", + "wasi 0.14.2+wasi-0.2.4", ] [[package]] @@ -3646,7 +3633,7 @@ dependencies = [ "thorin-dwp", "tracing", "wasm-encoder 0.219.2", - "windows 0.61.3", + "windows", ] [[package]] @@ -3682,7 +3669,7 @@ dependencies = [ "either", "elsa", "ena", - "hashbrown", + "hashbrown 0.15.5", "indexmap", "jobserver", "libc", @@ -3704,7 +3691,7 @@ dependencies = [ "tempfile", "thin-vec", "tracing", - "windows 0.61.3", + "windows", ] [[package]] @@ -3768,7 +3755,7 @@ dependencies = [ "serde_json", "shlex", "tracing", - "windows 0.61.3", + "windows", ] [[package]] @@ -3820,7 +3807,7 @@ dependencies = [ "serde_json", "termize", "tracing", - "windows 0.61.3", + "windows", ] [[package]] @@ -3869,7 +3856,7 @@ dependencies = [ "fluent-syntax", "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", "unic-langid", ] @@ -4029,7 +4016,7 @@ version = "0.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -4175,7 +4162,7 @@ version = "0.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", "synstructure", ] @@ -4185,7 +4172,7 @@ version = "0.0.0" dependencies = [ "bitflags", "libc", - "libloading 0.8.8", + "libloading 0.8.9", "odht", "rustc_abi", "rustc_ast", @@ -4298,7 +4285,7 @@ name = "rustc_mir_transform" version = "0.0.0" dependencies = [ "either", - "hashbrown", + "hashbrown 0.15.5", "itertools", "rustc_abi", "rustc_arena", @@ -4509,7 +4496,7 @@ dependencies = [ name = "rustc_query_system" version = "0.0.0" dependencies = [ - "hashbrown", + "hashbrown 0.15.5", "parking_lot", "rustc_abi", "rustc_ast", @@ -4611,7 +4598,7 @@ dependencies = [ "rustc_target", "termize", "tracing", - "windows 0.61.3", + "windows", ] [[package]] @@ -4798,7 +4785,7 @@ version = "0.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", "synstructure", ] @@ -4896,7 +4883,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -4958,11 +4945,11 @@ dependencies = [ [[package]] name = "ruzstd" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3640bec8aad418d7d03c72ea2de10d5c646a598f9883c7babc160d91e3c1b26c" +checksum = "e5ff0cc5e135c8870a775d3320910cd9b564ec036b4dc0b8741629020be63f01" dependencies = [ - "twox-hash 2.1.1", + "twox-hash 2.1.2", ] [[package]] @@ -4982,18 +4969,18 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] name = "schemars" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +checksum = "9558e172d4e8533736ba97870c4b2cd63f84b382a3d6eb063da41b91cce17289" dependencies = [ "dyn-clone", "ref-cast", @@ -5004,14 +4991,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "1.0.4" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80" +checksum = "301858a4023d78debd2353c7426dc486001bddc91ae31a76fb1f55132f7e2633" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -5034,17 +5021,18 @@ checksum = "d68f2ec51b097e4c1a75b681a8bec621909b5e91f15bb7b840c4f2f7b01148b2" [[package]] name = "self_cell" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f7d95a54511e0c7be3f51e8867aa8cf35148d7b9445d44de2f943e2b206e749" +checksum = "16c2f82143577edb4921b71ede051dac62ca3c16084e918bf7b40c96ae10eb33" [[package]] name = "semver" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" dependencies = [ "serde", + "serde_core", ] [[package]] @@ -5059,12 +5047,13 @@ dependencies = [ [[package]] name = "serde-untagged" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34836a629bcbc6f1afdf0907a744870039b1e14c0561cb26094fa683b158eff3" +checksum = "f9faf48a4a2d2693be24c6289dbe26552776eb7737074e6722891fadbe6c5058" dependencies = [ "erased-serde", "serde", + "serde_core", "typeid", ] @@ -5095,7 +5084,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -5106,29 +5095,31 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "serde_json" -version = "1.0.142" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] [[package]] name = "serde_path_to_error" -version = "0.1.17" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fab13f937fa393d08645bf3a84bdfe86e296747b506ada67bb15f10f218b2a" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" dependencies = [ "itoa", "serde", + "serde_core", ] [[package]] @@ -5142,9 +5133,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5417783452c2be558477e104686f7de5dae53dba813c28435e0e70f82d9b04ee" +checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" dependencies = [ "serde_core", ] @@ -5186,6 +5177,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "similar" version = "2.7.0" @@ -5206,12 +5203,12 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "socket2" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -5256,9 +5253,9 @@ dependencies = [ [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "stacker" @@ -5351,9 +5348,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.106" +version = "2.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" dependencies = [ "proc-macro2", "quote", @@ -5368,19 +5365,19 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "sysinfo" -version = "0.37.0" +version = "0.37.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cec4dc2d2e357ca1e610cfb07de2fa7a10fc3e9fe89f72545f3d244ea87753" +checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f" dependencies = [ "libc", "objc2-core-foundation", "objc2-io-kit", - "windows 0.61.3", + "windows", ] [[package]] @@ -5406,15 +5403,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.20.0" +version = "3.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" dependencies = [ "fastrand", "getrandom 0.3.3", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -5450,12 +5447,12 @@ dependencies = [ [[package]] name = "termize" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8da106d1a19c5b9c53c03311936568a0439926a7607815bd3461139cbab1cc" +checksum = "61946f539e9ff67cbc8df5b2e9823d84e0d58d74e342707c2dfb85405995827b" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -5486,11 +5483,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.15" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d76d3f064b981389ecb4b6b7f45a0bf9fdac1d5b9204c7bd6714fecc302850" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl 2.0.15", + "thiserror-impl 2.0.17", ] [[package]] @@ -5501,18 +5498,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "thiserror-impl" -version = "2.0.15" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d29feb33e986b6ea906bd9c3559a856983f92371b3eaa5e83782a351623de0" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -5522,7 +5519,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e9c1e705f82a260173f3eec93f2ff6d7807f23ad5a8cc2e7316a891733ea7a1" dependencies = [ "gimli 0.31.1", - "hashbrown", + "hashbrown 0.15.5", "object 0.36.7", "tracing", ] @@ -5570,9 +5567,9 @@ version = "0.1.0" [[package]] name = "tikv-jemalloc-sys" -version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" +version = "0.6.1+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd3c60906412afa9c2b5b5a48ca6a5abe5736aec9eb48ad05037a677e52e4e2d" +checksum = "cd8aa5b2ab86a2cefa406d889139c162cbb230092f7d1d7cbc1716405d852a3b" dependencies = [ "cc", "libc", @@ -5580,19 +5577,20 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" dependencies = [ "displaydoc", + "serde_core", "zerovec", ] [[package]] name = "tinyvec" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" dependencies = [ "tinyvec_macros", ] @@ -5630,14 +5628,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e5e5d9bf2475ac9d4f0d9edab68cc573dc2fd644b0dba36b0c30a92dd9eaa0" +checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" dependencies = [ "indexmap", "serde_core", - "serde_spanned 1.0.2", - "toml_datetime 0.7.2", + "serde_spanned 1.0.3", + "toml_datetime 0.7.3", "toml_parser", "toml_writer", "winnow 0.7.13", @@ -5654,9 +5652,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" dependencies = [ "serde_core", ] @@ -5690,9 +5688,9 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627" +checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" dependencies = [ "winnow 0.7.13", ] @@ -5705,9 +5703,9 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] name = "toml_writer" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d163a63c116ce562a22cda521fcc4d79152e7aba014456fb5eb442f6d6a10109" +checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" [[package]] name = "tracing" @@ -5728,7 +5726,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -5764,15 +5762,15 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" dependencies = [ "matchers", - "nu-ansi-term 0.46.0", + "nu-ansi-term", "once_cell", "parking_lot", - "regex", + "regex-automata", "sharded-slab", "smallvec", "thread_local", @@ -5787,7 +5785,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b56c62d2c80033cb36fae448730a2f2ef99410fe3ecbffc916681a32f6807dbe" dependencies = [ - "nu-ansi-term 0.50.1", + "nu-ansi-term", "tracing-core", "tracing-log", "tracing-subscriber", @@ -5806,9 +5804,9 @@ dependencies = [ [[package]] name = "twox-hash" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b907da542cbced5261bd3256de1b3a1bf340a3d37f93425a07362a1d687de56" +checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c" [[package]] name = "type-map" @@ -5827,9 +5825,9 @@ checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" [[package]] name = "typenum" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" [[package]] name = "ucd-parse" @@ -5848,9 +5846,9 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "ui_test" -version = "0.30.2" +version = "0.30.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b56a6897cc4bb6f8daf1939b0b39cd9645856997f46f4d0b3e3cb7122dfe9251" +checksum = "44eb652e1a8799d4e47f20851370e86247cbc5270ce677ab1e9409a6d45a9649" dependencies = [ "annotate-snippets 0.11.5", "anyhow", @@ -5858,7 +5856,7 @@ dependencies = [ "cargo-platform 0.1.9", "cargo_metadata 0.18.1", "color-eyre", - "colored 2.2.0", + "colored 3.0.0", "comma", "crossbeam-channel", "indicatif", @@ -5911,7 +5909,7 @@ checksum = "a1249a628de3ad34b821ecb1001355bca3940bcb2f88558f1a8bd82e977f75b5" dependencies = [ "proc-macro-hack", "quote", - "syn 2.0.106", + "syn 2.0.110", "unic-langid-impl", ] @@ -6008,13 +6006,14 @@ dependencies = [ [[package]] name = "url" -version = "2.5.4" +version = "2.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] [[package]] @@ -6049,9 +6048,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.18.0" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f33196643e165781c20a5ead5582283a7dacbb87855d867fbc2df3f81eddc1be" +checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" dependencies = [ "getrandom 0.3.3", "js-sys", @@ -6109,35 +6108,22 @@ checksum = "7ec3ef3783e18f2457796ed91b1e6c2adc46f2905f740d1527ab3053fe8e5682" [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" dependencies = [ "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn 2.0.106", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -6145,22 +6131,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" dependencies = [ + "bumpalo", "proc-macro2", "quote", - "syn 2.0.106", - "wasm-bindgen-backend", + "syn 2.0.110", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" dependencies = [ "unicode-ident", ] @@ -6251,7 +6237,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46d90019b1afd4b808c263e428de644f3003691f243387d30d673211ee0cb8e8" dependencies = [ "bitflags", - "hashbrown", + "hashbrown 0.15.5", "indexmap", "semver", "serde", @@ -6307,11 +6293,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.61.2", ] [[package]] @@ -6320,16 +6306,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" -dependencies = [ - "windows-core 0.58.0", - "windows-targets 0.52.6", -] - [[package]] name = "windows" version = "0.61.3" @@ -6363,32 +6339,32 @@ dependencies = [ "windows-core 0.61.2", ] -[[package]] -name = "windows-core" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" -dependencies = [ - "windows-implement 0.58.0", - "windows-interface 0.58.0", - "windows-result 0.2.0", - "windows-strings 0.1.0", - "windows-targets 0.52.6", -] - [[package]] name = "windows-core" version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "windows-implement 0.60.0", - "windows-interface 0.59.1", + "windows-implement", + "windows-interface", "windows-link 0.1.3", "windows-result 0.3.4", "windows-strings 0.4.2", ] +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", +] + [[package]] name = "windows-future" version = "0.2.1" @@ -6402,46 +6378,24 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.58.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", -] - -[[package]] -name = "windows-implement" -version = "0.60.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] name = "windows-interface" -version = "0.58.0" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", -] - -[[package]] -name = "windows-interface" -version = "0.59.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -6466,15 +6420,6 @@ dependencies = [ "windows-link 0.1.3", ] -[[package]] -name = "windows-result" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-result" version = "0.3.4" @@ -6485,13 +6430,12 @@ dependencies = [ ] [[package]] -name = "windows-strings" -version = "0.1.0" +name = "windows-result" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ - "windows-result 0.2.0", - "windows-targets 0.52.6", + "windows-link 0.2.1", ] [[package]] @@ -6504,12 +6448,12 @@ dependencies = [ ] [[package]] -name = "windows-sys" -version = "0.52.0" +name = "windows-strings" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-targets 0.52.6", + "windows-link 0.2.1", ] [[package]] @@ -6527,7 +6471,7 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.3", + "windows-targets 0.53.5", ] [[package]] @@ -6557,19 +6501,19 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.3" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ - "windows-link 0.1.3", - "windows_aarch64_gnullvm 0.53.0", - "windows_aarch64_msvc 0.53.0", - "windows_i686_gnu 0.53.0", - "windows_i686_gnullvm 0.53.0", - "windows_i686_msvc 0.53.0", - "windows_x86_64_gnu 0.53.0", - "windows_x86_64_gnullvm 0.53.0", - "windows_x86_64_msvc 0.53.0", + "windows-link 0.2.1", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] @@ -6589,9 +6533,9 @@ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" @@ -6601,9 +6545,9 @@ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" [[package]] name = "windows_i686_gnu" @@ -6613,9 +6557,9 @@ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" [[package]] name = "windows_i686_gnullvm" @@ -6625,9 +6569,9 @@ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" [[package]] name = "windows_i686_msvc" @@ -6637,9 +6581,9 @@ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" @@ -6649,9 +6593,9 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" [[package]] name = "windows_x86_64_gnullvm" @@ -6661,9 +6605,9 @@ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" @@ -6673,9 +6617,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winnow" @@ -6749,9 +6693,9 @@ dependencies = [ [[package]] name = "writeable" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" [[package]] name = "x" @@ -6759,9 +6703,9 @@ version = "0.1.1" [[package]] name = "xattr" -version = "1.5.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af3a19837351dc82ba89f8a125e22a3c475f05aba604acc023d62b2739ae2909" +checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156" dependencies = [ "libc", "rustix", @@ -6787,11 +6731,10 @@ dependencies = [ [[package]] name = "yoke" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" dependencies = [ - "serde", "stable_deref_trait", "yoke-derive", "zerofrom", @@ -6799,34 +6742,34 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.26" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.26" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] [[package]] @@ -6846,15 +6789,15 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", "synstructure", ] [[package]] name = "zerotrie" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" dependencies = [ "displaydoc", "yoke", @@ -6863,10 +6806,11 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" dependencies = [ + "serde", "yoke", "zerofrom", "zerovec-derive", @@ -6874,11 +6818,11 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.106", + "syn 2.0.110", ] diff --git a/compiler/rustc/Cargo.toml b/compiler/rustc/Cargo.toml index 9ef8fa75062a..ea38e2806da5 100644 --- a/compiler/rustc/Cargo.toml +++ b/compiler/rustc/Cargo.toml @@ -20,6 +20,13 @@ rustc_public = { path = "../rustc_public" } rustc_public_bridge = { path = "../rustc_public_bridge" } # tidy-alphabetical-end +# Pin these to avoid pulling in a package with a binary blob +# +[target.'cfg(target_os = "wasi")'.dependencies] +getrandom = "=0.3.3" +wasi = "=0.14.2" + + [dependencies.tikv-jemalloc-sys] version = "0.6.0" optional = true diff --git a/src/bootstrap/src/utils/proc_macro_deps.rs b/src/bootstrap/src/utils/proc_macro_deps.rs index 83e5580eaa91..3873e0c928a5 100644 --- a/src/bootstrap/src/utils/proc_macro_deps.rs +++ b/src/bootstrap/src/utils/proc_macro_deps.rs @@ -3,7 +3,6 @@ /// See pub static CRATES: &[&str] = &[ // tidy-alphabetical-start - "allocator-api2", "annotate-snippets", "anstyle", "askama_parser", @@ -22,7 +21,6 @@ "fluent-langneg", "fluent-syntax", "fnv", - "foldhash", "generic-array", "hashbrown", "heck", @@ -31,7 +29,6 @@ "intl-memoizer", "intl_pluralrules", "libc", - "log", "memchr", "minimal-lexical", "nom", @@ -62,7 +59,6 @@ "unicode-ident", "unicode-width", "version_check", - "wasm-bindgen-backend", "wasm-bindgen-macro-support", "wasm-bindgen-shared", "winnow", diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 93d38d929c6d..b60b709c8eda 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -55,6 +55,7 @@ "0BSD", "Apache-2.0 AND ISC", "Apache-2.0 OR BSL-1.0", // BSL is not acceptable, but we use it under Apache-2.0 + "Apache-2.0 OR GPL-2.0-only", "Apache-2.0 WITH LLVM-exception", "Apache-2.0", "BSD-2-Clause", @@ -279,10 +280,10 @@ macro_rules! location { "ar_archive_writer", "arrayref", "arrayvec", - "autocfg", "bitflags", "blake3", "block-buffer", + "block2", "bstr", "cc", "cfg-if", @@ -303,6 +304,7 @@ macro_rules! location { "derive-where", "derive_setters", "digest", + "dispatch2", "displaydoc", "dissimilar", "dyn-clone", @@ -359,11 +361,12 @@ macro_rules! location { "miniz_oxide", "nix", "nu-ansi-term", + "objc2", + "objc2-encode", "object", "odht", "once_cell", "once_cell_polyfill", - "overload", "parking_lot", "parking_lot_core", "pathdiff", @@ -416,6 +419,7 @@ macro_rules! location { "sha2", "sharded-slab", "shlex", + "simd-adler32", "smallvec", "stable_deref_trait", "stacker", @@ -461,9 +465,6 @@ macro_rules! location { "wasi", "wasm-encoder", "wasmparser", - "winapi", - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", "windows", "windows-collections", "windows-core", From f580357863c1689ea1903b9570092a53f85a5c44 Mon Sep 17 00:00:00 2001 From: Jules Bertholet Date: Fri, 21 Nov 2025 11:43:53 -0500 Subject: [PATCH 128/194] Handle cycles when checking impl candidates for `doc(hidden)` Fixes https://github.com/rust-lang/rust/issues/149092 --- .../traits/fulfillment_errors.rs | 13 +++++++--- compiler/rustc_trait_selection/src/lib.rs | 1 + .../ui/suggestions/auxiliary/hidden-struct.rs | 3 +++ .../dont-suggest-foreign-doc-hidden.rs | 5 ++++ .../dont-suggest-foreign-doc-hidden.stderr | 26 +++++++++++++++++-- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index d2f2c92dda08..0f5607dd7fec 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -1,12 +1,13 @@ // ignore-tidy-filelength use core::ops::ControlFlow; use std::borrow::Cow; +use std::collections::hash_set; use std::path::PathBuf; use rustc_abi::ExternAbi; use rustc_ast::ast::LitKind; use rustc_ast::{LitIntType, TraitObjectSyntax}; -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::unord::UnordSet; use rustc_errors::codes::*; use rustc_errors::{ @@ -1956,11 +1957,17 @@ pub(super) fn report_similar_impl_candidates( if self.tcx.visibility(did).is_accessible_from(body_def_id, self.tcx) { // don't suggest foreign `#[doc(hidden)]` types if !did.is_local() { - while let Some(parent) = parent_map.get(&did) { + let mut previously_seen_dids: FxHashSet = Default::default(); + previously_seen_dids.insert(did); + while let Some(&parent) = parent_map.get(&did) + && let hash_set::Entry::Vacant(v) = + previously_seen_dids.entry(parent) + { if self.tcx.is_doc_hidden(did) { return false; } - did = *parent; + v.insert(); + did = parent; } } true diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index c5dfaa2a60d8..0184b2ccde78 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -17,6 +17,7 @@ #![feature(associated_type_defaults)] #![feature(box_patterns)] #![feature(default_field_values)] +#![feature(hash_set_entry)] #![feature(if_let_guard)] #![feature(iter_intersperse)] #![feature(iterator_try_reduce)] diff --git a/tests/ui/suggestions/auxiliary/hidden-struct.rs b/tests/ui/suggestions/auxiliary/hidden-struct.rs index 1f495a9f2224..ee24389bebd7 100644 --- a/tests/ui/suggestions/auxiliary/hidden-struct.rs +++ b/tests/ui/suggestions/auxiliary/hidden-struct.rs @@ -33,3 +33,6 @@ impl Marker for hidden::Foo {} impl Marker for hidden1::Bar {} impl Marker for Baz {} impl Marker for Quux {} + + +pub use crate as library; diff --git a/tests/ui/suggestions/dont-suggest-foreign-doc-hidden.rs b/tests/ui/suggestions/dont-suggest-foreign-doc-hidden.rs index a83e496f2703..0716e4e2e143 100644 --- a/tests/ui/suggestions/dont-suggest-foreign-doc-hidden.rs +++ b/tests/ui/suggestions/dont-suggest-foreign-doc-hidden.rs @@ -21,7 +21,12 @@ pub fn test4(_: Quux) {} fn test5() {} +fn test6() {} + fn main() { test5::(); //~^ ERROR [E0277] + + test6::(); + //~^ ERROR [E0277] } diff --git a/tests/ui/suggestions/dont-suggest-foreign-doc-hidden.stderr b/tests/ui/suggestions/dont-suggest-foreign-doc-hidden.stderr index e0444c93eeec..a111d0e5aa95 100644 --- a/tests/ui/suggestions/dont-suggest-foreign-doc-hidden.stderr +++ b/tests/ui/suggestions/dont-suggest-foreign-doc-hidden.stderr @@ -38,7 +38,7 @@ LL + use hidden_struct::Quux; | error[E0277]: the trait bound `i32: Marker` is not satisfied - --> $DIR/dont-suggest-foreign-doc-hidden.rs:25:13 + --> $DIR/dont-suggest-foreign-doc-hidden.rs:27:13 | LL | test5::(); | ^^^ the trait `Marker` is not implemented for `i32` @@ -59,7 +59,29 @@ note: required by a bound in `test5` LL | fn test5() {} | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test5` -error: aborting due to 5 previous errors +error[E0277]: the trait bound `i32: Marker` is not satisfied + --> $DIR/dont-suggest-foreign-doc-hidden.rs:30:13 + | +LL | test6::(); + | ^^^ the trait `Marker` is not implemented for `i32` + | +help: the following other types implement trait `Marker` + --> $DIR/auxiliary/hidden-struct.rs:31:1 + | +LL | impl Marker for Option {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Option` +... +LL | impl Marker for Baz {} + | ^^^^^^^^^^^^^^^^^^^ `Baz` +LL | impl Marker for Quux {} + | ^^^^^^^^^^^^^^^^^^^^ `Quux` +note: required by a bound in `test6` + --> $DIR/dont-suggest-foreign-doc-hidden.rs:24:13 + | +LL | fn test6() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test6` + +error: aborting due to 6 previous errors Some errors have detailed explanations: E0277, E0412. For more information about an error, try `rustc --explain E0277`. From 8f76773041cf730410ad5287c07d64a797d3b8e3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 Nov 2025 20:49:31 +0100 Subject: [PATCH 129/194] Return `impl Display` instead of `String` in `fragment` --- src/librustdoc/clean/types.rs | 4 +++- src/librustdoc/html/format.rs | 39 ++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 7669a2b1a579..f1b0f4a68bea 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1,3 +1,4 @@ +use std::fmt::Write; use std::hash::Hash; use std::path::PathBuf; use std::sync::{Arc, OnceLock as OnceCell}; @@ -524,7 +525,8 @@ pub(crate) fn links(&self, cx: &Context<'_>) -> Vec { debug!(?url); match fragment { Some(UrlFragment::Item(def_id)) => { - url.push_str(&crate::html::format::fragment(*def_id, cx.tcx())) + write!(url, "{}", crate::html::format::fragment(*def_id, cx.tcx())) + .unwrap(); } Some(UrlFragment::UserWritten(raw)) => { url.push('#'); diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 5892eecea35e..dd91cec531f5 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -833,26 +833,27 @@ fn print_higher_ranked_params_with_space( }) } -pub(crate) fn fragment(did: DefId, tcx: TyCtxt<'_>) -> String { - let def_kind = tcx.def_kind(did); - match def_kind { - DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst | DefKind::Variant => { - let item_type = ItemType::from_def_id(did, tcx); - format!("#{}.{}", item_type.as_str(), tcx.item_name(did)) +pub(crate) fn fragment(did: DefId, tcx: TyCtxt<'_>) -> impl Display { + fmt::from_fn(move |f| { + let def_kind = tcx.def_kind(did); + match def_kind { + DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst | DefKind::Variant => { + let item_type = ItemType::from_def_id(did, tcx); + write!(f, "#{}.{}", item_type.as_str(), tcx.item_name(did)) + } + DefKind::Field => { + let parent_def_id = tcx.parent(did); + f.write_char('#')?; + if tcx.def_kind(parent_def_id) == DefKind::Variant { + write!(f, "variant.{}.field", tcx.item_name(parent_def_id).as_str())?; + } else { + f.write_str("structfield")?; + }; + write!(f, ".{}", tcx.item_name(did)) + } + _ => Ok(()), } - DefKind::Field => { - let parent_def_id = tcx.parent(did); - let s; - let kind = if tcx.def_kind(parent_def_id) == DefKind::Variant { - s = format!("variant.{}.field", tcx.item_name(parent_def_id).as_str()); - &s - } else { - "structfield" - }; - format!("#{kind}.{}", tcx.item_name(did)) - } - _ => String::new(), - } + }) } pub(crate) fn print_anchor(did: DefId, text: Symbol, cx: &Context<'_>) -> impl Display { From 3386da8f6fd77206acfa135c99727395a427bd2e Mon Sep 17 00:00:00 2001 From: chiri Date: Fri, 21 Nov 2025 22:52:19 +0300 Subject: [PATCH 130/194] Move safe computation out of unsafe block --- library/alloc/src/collections/vec_deque/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs index 52e079d3ae8e..ea9d5b128ebe 100644 --- a/library/alloc/src/collections/vec_deque/mod.rs +++ b/library/alloc/src/collections/vec_deque/mod.rs @@ -2479,11 +2479,11 @@ pub fn split_off(&mut self, at: usize) -> Self let other_len = len - at; let mut other = VecDeque::with_capacity_in(other_len, self.allocator().clone()); - unsafe { - let (first_half, second_half) = self.as_slices(); + let (first_half, second_half) = self.as_slices(); + let first_len = first_half.len(); + let second_len = second_half.len(); - let first_len = first_half.len(); - let second_len = second_half.len(); + unsafe { if at < first_len { // `at` lies in the first half. let amount_in_first = first_len - at; From e9440fb24e43789a32ca70b693b8c76e314c727e Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Fri, 21 Nov 2025 17:40:55 -0500 Subject: [PATCH 131/194] Update cargo submodule --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 5c0343317ce4..9fa462fe3a81 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 5c0343317ce45d2ec17ecf41eaa473a02d73e29c +Subproject commit 9fa462fe3a81e07e0bfdcc75c29d312c55113ebb From 8094934b9a7e882e40ea1de03a73d8c1053bed28 Mon Sep 17 00:00:00 2001 From: winningMove Date: Sat, 22 Nov 2025 10:37:31 +0100 Subject: [PATCH 132/194] Fix typo in HashMap performance comment --- library/std/src/collections/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/collections/mod.rs b/library/std/src/collections/mod.rs index 6104a02c739b..460deb490ef0 100644 --- a/library/std/src/collections/mod.rs +++ b/library/std/src/collections/mod.rs @@ -104,7 +104,7 @@ //! unlikely, for [`HashMap`] to experience significantly worse performance than //! the expected cost. This is due to the probabilistic nature of hashing - i.e. //! it is possible to generate a duplicate hash given some input key that will -//! requires extra computation to correct. +//! require extra computation to correct. //! //! ## Cost of Collection Operations //! From e2a69cea60d58ced09c1aaee15669c75a2f64aae Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 2 Nov 2025 12:46:59 +0100 Subject: [PATCH 133/194] Add `#[rustc_should_not_be_called_on_const_items]` attribute --- .../rustc_attr_parsing/src/attributes/lint_helpers.rs | 11 +++++++++++ compiler/rustc_attr_parsing/src/context.rs | 2 ++ compiler/rustc_feature/src/builtin_attrs.rs | 5 +++++ compiler/rustc_hir/src/attrs/data_structures.rs | 3 +++ compiler/rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_passes/src/check_attr.rs | 1 + compiler/rustc_span/src/symbol.rs | 1 + 7 files changed, 24 insertions(+) diff --git a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs index 63b0809d0d8c..8ca5f0f7228e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs +++ b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs @@ -38,6 +38,17 @@ impl NoArgsAttributeParser for PassByValueParser { const CREATE: fn(Span) -> AttributeKind = AttributeKind::PassByValue; } +pub(crate) struct RustcShouldNotBeCalledOnConstItems; +impl NoArgsAttributeParser for RustcShouldNotBeCalledOnConstItems { + const PATH: &[Symbol] = &[sym::rustc_should_not_be_called_on_const_items]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[ + Allow(Target::Method(MethodKind::Inherent)), + Allow(Target::Method(MethodKind::TraitImpl)), + ]); + const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcShouldNotBeCalledOnConstItems; +} + pub(crate) struct AutomaticallyDerivedParser; impl NoArgsAttributeParser for AutomaticallyDerivedParser { const PATH: &[Symbol] = &[sym::automatically_derived]; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index d1777991731c..99e6c748dbe9 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -39,6 +39,7 @@ }; use crate::attributes::lint_helpers::{ AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser, + RustcShouldNotBeCalledOnConstItems, }; use crate::attributes::loop_match::{ConstContinueParser, LoopMatchParser}; use crate::attributes::macro_attrs::{ @@ -244,6 +245,7 @@ mod late { Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index ce7dd16cd19c..c1e947720452 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -1267,6 +1267,11 @@ pub struct BuiltinAttribute { EncodeCrossCrate::Yes, "`#[rustc_as_ptr]` is used to mark functions returning pointers to their inner allocations." ), + rustc_attr!( + rustc_should_not_be_called_on_const_items, Normal, template!(Word), ErrorFollowing, + EncodeCrossCrate::Yes, + "`#[rustc_should_not_be_called_on_const_items]` is used to mark methods that don't make sense to be called on interior mutable consts." + ), rustc_attr!( rustc_pass_by_value, Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::Yes, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 4ba64b240ac0..708210ac6c6e 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -701,6 +701,9 @@ pub enum AttributeKind { /// Represents `#[rustc_pass_indirectly_in_non_rustic_abis]` RustcPassIndirectlyInNonRusticAbis(Span), + /// Represents `#[rustc_should_not_be_called_on_const_items]` + RustcShouldNotBeCalledOnConstItems(Span), + /// Represents `#[rustc_simd_monomorphize_lane_limit = "N"]`. RustcSimdMonomorphizeLaneLimit(Limit), diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index 2ccfdc2ad983..74fc6c6af009 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -91,6 +91,7 @@ pub fn encode_cross_crate(&self) -> EncodeCrossCrate { RustcMain => No, RustcObjectLifetimeDefault => No, RustcPassIndirectlyInNonRusticAbis(..) => No, + RustcShouldNotBeCalledOnConstItems(..) => Yes, RustcSimdMonomorphizeLaneLimit(..) => Yes, // Affects layout computation, which needs to work cross-crate Sanitize { .. } => No, ShouldPanic { .. } => No, diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 347e103af937..30bb7d657f7a 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -254,6 +254,7 @@ fn check_attributes( | AttributeKind::RustcLayoutScalarValidRangeStart(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) | AttributeKind::RustcSimdMonomorphizeLaneLimit(..) + | AttributeKind::RustcShouldNotBeCalledOnConstItems(..) | AttributeKind::ExportStable | AttributeKind::FfiConst(..) | AttributeKind::UnstableFeatureBound(..) diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index eca4259efa7d..cd730ede4ba1 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1986,6 +1986,7 @@ rustc_regions, rustc_reservation_impl, rustc_serialize, + rustc_should_not_be_called_on_const_items, rustc_simd_monomorphize_lane_limit, rustc_skip_during_method_dispatch, rustc_specialization_trait, From 0e8d1e1f8ec2c8feb0b573371e688f97485b6a06 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 2 Nov 2025 13:38:30 +0100 Subject: [PATCH 134/194] Add `#[rustc_should_not_be_called_on_const_items]` to std methods --- library/core/src/cell.rs | 17 ++++++++++ library/core/src/cell/lazy.rs | 1 + library/core/src/cell/once.rs | 4 +++ library/core/src/sync/atomic.rs | 45 ++++++++++++++++++++++++++ library/std/src/sync/lazy_lock.rs | 2 ++ library/std/src/sync/once.rs | 4 +++ library/std/src/sync/once_lock.rs | 6 ++++ library/std/src/sync/poison/condvar.rs | 7 ++++ library/std/src/sync/poison/mutex.rs | 5 +++ library/std/src/sync/poison/rwlock.rs | 6 ++++ 10 files changed, 97 insertions(+) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 988c50795e29..c8340c328be1 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -430,6 +430,7 @@ pub const fn new(value: T) -> Cell { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_cell_traits", issue = "147787")] + #[rustc_should_not_be_called_on_const_items] pub const fn set(&self, val: T) where T: [const] Destruct, @@ -461,6 +462,7 @@ pub const fn set(&self, val: T) /// ``` #[inline] #[stable(feature = "move_cell", since = "1.17.0")] + #[rustc_should_not_be_called_on_const_items] pub fn swap(&self, other: &Self) { // This function documents that it *will* panic, and intrinsics::is_nonoverlapping doesn't // do the check in const, so trying to use it here would be inviting unnecessary fragility. @@ -505,6 +507,7 @@ fn is_nonoverlapping(src: *const T, dst: *const T) -> bool { #[stable(feature = "move_cell", since = "1.17.0")] #[rustc_const_stable(feature = "const_cell", since = "1.88.0")] #[rustc_confusables("swap")] + #[rustc_should_not_be_called_on_const_items] pub const fn replace(&self, val: T) -> T { // SAFETY: This can cause data races if called from a separate thread, // but `Cell` is `!Sync` so this won't happen. @@ -546,6 +549,7 @@ impl Cell { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_cell", since = "1.88.0")] + #[rustc_should_not_be_called_on_const_items] pub const fn get(&self) -> T { // SAFETY: This can cause data races if called from a separate thread, // but `Cell` is `!Sync` so this won't happen. @@ -566,6 +570,7 @@ pub const fn get(&self) -> T { #[inline] #[stable(feature = "cell_update", since = "1.88.0")] #[rustc_const_unstable(feature = "const_cell_traits", issue = "147787")] + #[rustc_should_not_be_called_on_const_items] pub const fn update(&self, f: impl [const] FnOnce(T) -> T) where // FIXME(const-hack): `Copy` should imply `const Destruct` @@ -994,6 +999,7 @@ pub const fn into_inner(self) -> T { #[track_caller] #[rustc_confusables("swap")] #[rustc_const_unstable(feature = "const_ref_cell", issue = "137844")] + #[rustc_should_not_be_called_on_const_items] pub const fn replace(&self, t: T) -> T { mem::replace(&mut self.borrow_mut(), t) } @@ -1017,6 +1023,7 @@ pub const fn replace(&self, t: T) -> T { #[inline] #[stable(feature = "refcell_replace_swap", since = "1.35.0")] #[track_caller] + #[rustc_should_not_be_called_on_const_items] pub fn replace_with T>(&self, f: F) -> T { let mut_borrow = &mut *self.borrow_mut(); let replacement = f(mut_borrow); @@ -1046,6 +1053,7 @@ pub fn replace_with T>(&self, f: F) -> T { #[inline] #[stable(feature = "refcell_swap", since = "1.24.0")] #[rustc_const_unstable(feature = "const_ref_cell", issue = "137844")] + #[rustc_should_not_be_called_on_const_items] pub const fn swap(&self, other: &Self) { mem::swap(&mut *self.borrow_mut(), &mut *other.borrow_mut()) } @@ -1087,6 +1095,7 @@ impl RefCell { #[inline] #[track_caller] #[rustc_const_unstable(feature = "const_ref_cell", issue = "137844")] + #[rustc_should_not_be_called_on_const_items] pub const fn borrow(&self) -> Ref<'_, T> { match self.try_borrow() { Ok(b) => b, @@ -1123,6 +1132,7 @@ pub const fn borrow(&self) -> Ref<'_, T> { #[inline] #[cfg_attr(feature = "debug_refcell", track_caller)] #[rustc_const_unstable(feature = "const_ref_cell", issue = "137844")] + #[rustc_should_not_be_called_on_const_items] pub const fn try_borrow(&self) -> Result, BorrowError> { match BorrowRef::new(&self.borrow) { Some(b) => { @@ -1185,6 +1195,7 @@ pub const fn try_borrow(&self) -> Result, BorrowError> { #[inline] #[track_caller] #[rustc_const_unstable(feature = "const_ref_cell", issue = "137844")] + #[rustc_should_not_be_called_on_const_items] pub const fn borrow_mut(&self) -> RefMut<'_, T> { match self.try_borrow_mut() { Ok(b) => b, @@ -1218,6 +1229,7 @@ pub const fn borrow_mut(&self) -> RefMut<'_, T> { #[inline] #[cfg_attr(feature = "debug_refcell", track_caller)] #[rustc_const_unstable(feature = "const_ref_cell", issue = "137844")] + #[rustc_should_not_be_called_on_const_items] pub const fn try_borrow_mut(&self) -> Result, BorrowMutError> { match BorrowRefMut::new(&self.borrow) { Some(b) => { @@ -2356,6 +2368,7 @@ pub const fn into_inner(self) -> T { /// ``` #[inline] #[unstable(feature = "unsafe_cell_access", issue = "136327")] + #[rustc_should_not_be_called_on_const_items] pub const unsafe fn replace(&self, value: T) -> T { // SAFETY: pointer comes from `&self` so naturally satisfies invariants. unsafe { ptr::replace(self.get(), value) } @@ -2404,6 +2417,7 @@ pub const fn from_mut(value: &mut T) -> &mut UnsafeCell { #[rustc_const_stable(feature = "const_unsafecell_get", since = "1.32.0")] #[rustc_as_ptr] #[rustc_never_returns_null_ptr] + #[rustc_should_not_be_called_on_const_items] pub const fn get(&self) -> *mut T { // We can just cast the pointer from `UnsafeCell` to `T` because of // #[repr(transparent)]. This exploits std's special status, there is @@ -2493,6 +2507,7 @@ pub const fn raw_get(this: *const Self) -> *mut T { /// ``` #[inline] #[unstable(feature = "unsafe_cell_access", issue = "136327")] + #[rustc_should_not_be_called_on_const_items] pub const unsafe fn as_ref_unchecked(&self) -> &T { // SAFETY: pointer comes from `&self` so naturally satisfies ptr-to-ref invariants. unsafe { self.get().as_ref_unchecked() } @@ -2521,6 +2536,7 @@ pub const fn raw_get(this: *const Self) -> *mut T { #[inline] #[unstable(feature = "unsafe_cell_access", issue = "136327")] #[allow(clippy::mut_from_ref)] + #[rustc_should_not_be_called_on_const_items] pub const unsafe fn as_mut_unchecked(&self) -> &mut T { // SAFETY: pointer comes from `&self` so naturally satisfies ptr-to-ref invariants. unsafe { self.get().as_mut_unchecked() } @@ -2608,6 +2624,7 @@ impl SyncUnsafeCell { #[inline] #[rustc_as_ptr] #[rustc_never_returns_null_ptr] + #[rustc_should_not_be_called_on_const_items] pub const fn get(&self) -> *mut T { self.value.get() } diff --git a/library/core/src/cell/lazy.rs b/library/core/src/cell/lazy.rs index a1bd4c857170..3dae6c64200c 100644 --- a/library/core/src/cell/lazy.rs +++ b/library/core/src/cell/lazy.rs @@ -134,6 +134,7 @@ pub const fn into_inner(this: Self) -> Result { /// ``` #[inline] #[stable(feature = "lazy_cell", since = "1.80.0")] + #[rustc_should_not_be_called_on_const_items] pub fn force(this: &LazyCell) -> &T { // SAFETY: // This invalidates any mutable references to the data. The resulting diff --git a/library/core/src/cell/once.rs b/library/core/src/cell/once.rs index 833be059d75f..1e211ae66e79 100644 --- a/library/core/src/cell/once.rs +++ b/library/core/src/cell/once.rs @@ -88,6 +88,7 @@ pub fn get_mut(&mut self) -> Option<&mut T> { /// ``` #[inline] #[stable(feature = "once_cell", since = "1.70.0")] + #[rustc_should_not_be_called_on_const_items] pub fn set(&self, value: T) -> Result<(), T> { match self.try_insert(value) { Ok(_) => Ok(()), @@ -120,6 +121,7 @@ pub fn set(&self, value: T) -> Result<(), T> { /// ``` #[inline] #[unstable(feature = "once_cell_try_insert", issue = "116693")] + #[rustc_should_not_be_called_on_const_items] pub fn try_insert(&self, value: T) -> Result<&T, (&T, T)> { if let Some(old) = self.get() { return Err((old, value)); @@ -157,6 +159,7 @@ pub fn try_insert(&self, value: T) -> Result<&T, (&T, T)> { /// ``` #[inline] #[stable(feature = "once_cell", since = "1.70.0")] + #[rustc_should_not_be_called_on_const_items] pub fn get_or_init(&self, f: F) -> &T where F: FnOnce() -> T, @@ -231,6 +234,7 @@ pub fn get_mut_or_init(&mut self, f: F) -> &mut T /// assert_eq!(cell.get(), Some(&92)) /// ``` #[unstable(feature = "once_cell_try", issue = "109737")] + #[rustc_should_not_be_called_on_const_items] pub fn get_or_try_init(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result, diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index d7eaaf35b53a..0c5552a0b81c 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -749,6 +749,7 @@ pub fn load(&self, order: Ordering) -> bool { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn store(&self, val: bool, order: Ordering) { // SAFETY: any data races are prevented by atomic intrinsics and the raw // pointer passed in is valid because we got it from a reference. @@ -781,6 +782,7 @@ pub fn store(&self, val: bool, order: Ordering) { #[stable(feature = "rust1", since = "1.0.0")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn swap(&self, val: bool, order: Ordering) -> bool { if EMULATE_ATOMIC_BOOL { if val { self.fetch_or(true, order) } else { self.fetch_and(false, order) } @@ -848,6 +850,7 @@ pub fn swap(&self, val: bool, order: Ordering) -> bool { )] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn compare_and_swap(&self, current: bool, new: bool, order: Ordering) -> bool { match self.compare_exchange(current, new, order, strongest_failure_ordering(order)) { Ok(x) => x, @@ -909,6 +912,7 @@ pub fn compare_and_swap(&self, current: bool, new: bool, order: Ordering) -> boo #[doc(alias = "compare_and_swap")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn compare_exchange( &self, current: bool, @@ -1004,6 +1008,7 @@ pub fn compare_exchange( #[doc(alias = "compare_and_swap")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn compare_exchange_weak( &self, current: bool, @@ -1060,6 +1065,7 @@ pub fn compare_exchange_weak( #[stable(feature = "rust1", since = "1.0.0")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_and(&self, val: bool, order: Ordering) -> bool { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_and(self.v.get(), val as u8, order) != 0 } @@ -1102,6 +1108,7 @@ pub fn fetch_and(&self, val: bool, order: Ordering) -> bool { #[stable(feature = "rust1", since = "1.0.0")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_nand(&self, val: bool, order: Ordering) -> bool { // We can't use atomic_nand here because it can result in a bool with // an invalid value. This happens because the atomic operation is done @@ -1154,6 +1161,7 @@ pub fn fetch_nand(&self, val: bool, order: Ordering) -> bool { #[stable(feature = "rust1", since = "1.0.0")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_or(&self, val: bool, order: Ordering) -> bool { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_or(self.v.get(), val as u8, order) != 0 } @@ -1195,6 +1203,7 @@ pub fn fetch_or(&self, val: bool, order: Ordering) -> bool { #[stable(feature = "rust1", since = "1.0.0")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_xor(&self, val: bool, order: Ordering) -> bool { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_xor(self.v.get(), val as u8, order) != 0 } @@ -1232,6 +1241,7 @@ pub fn fetch_xor(&self, val: bool, order: Ordering) -> bool { #[stable(feature = "atomic_bool_fetch_not", since = "1.81.0")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_not(&self, order: Ordering) -> bool { self.fetch_xor(true, order) } @@ -1270,6 +1280,7 @@ pub fn fetch_not(&self, order: Ordering) -> bool { #[stable(feature = "atomic_as_ptr", since = "1.70.0")] #[rustc_const_stable(feature = "atomic_as_ptr", since = "1.70.0")] #[rustc_never_returns_null_ptr] + #[rustc_should_not_be_called_on_const_items] pub const fn as_ptr(&self) -> *mut bool { self.v.get().cast() } @@ -1323,6 +1334,7 @@ pub const fn as_ptr(&self) -> *mut bool { #[stable(feature = "atomic_fetch_update", since = "1.53.0")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_update( &self, set_order: Ordering, @@ -1394,6 +1406,7 @@ pub fn fetch_update( #[unstable(feature = "atomic_try_update", issue = "135894")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn try_update( &self, set_order: Ordering, @@ -1452,6 +1465,7 @@ pub fn try_update( #[unstable(feature = "atomic_try_update", issue = "135894")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn update( &self, set_order: Ordering, @@ -1735,6 +1749,7 @@ pub fn load(&self, order: Ordering) -> *mut T { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn store(&self, ptr: *mut T, order: Ordering) { // SAFETY: data races are prevented by atomic intrinsics. unsafe { @@ -1768,6 +1783,7 @@ pub fn store(&self, ptr: *mut T, order: Ordering) { #[stable(feature = "rust1", since = "1.0.0")] #[cfg(target_has_atomic = "ptr")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn swap(&self, ptr: *mut T, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_swap(self.p.get(), ptr, order) } @@ -1830,6 +1846,7 @@ pub fn swap(&self, ptr: *mut T, order: Ordering) -> *mut T { )] #[cfg(target_has_atomic = "ptr")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn compare_and_swap(&self, current: *mut T, new: *mut T, order: Ordering) -> *mut T { match self.compare_exchange(current, new, order, strongest_failure_ordering(order)) { Ok(x) => x, @@ -1884,6 +1901,7 @@ pub fn compare_and_swap(&self, current: *mut T, new: *mut T, order: Ordering) -> #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] #[cfg(target_has_atomic = "ptr")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn compare_exchange( &self, current: *mut T, @@ -1947,6 +1965,7 @@ pub fn compare_exchange( #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] #[cfg(target_has_atomic = "ptr")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn compare_exchange_weak( &self, current: *mut T, @@ -2020,6 +2039,7 @@ pub fn compare_exchange_weak( #[stable(feature = "atomic_fetch_update", since = "1.53.0")] #[cfg(target_has_atomic = "ptr")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_update( &self, set_order: Ordering, @@ -2100,6 +2120,7 @@ pub fn fetch_update( #[unstable(feature = "atomic_try_update", issue = "135894")] #[cfg(target_has_atomic = "ptr")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn try_update( &self, set_order: Ordering, @@ -2163,6 +2184,7 @@ pub fn try_update( #[unstable(feature = "atomic_try_update", issue = "135894")] #[cfg(target_has_atomic = "8")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn update( &self, set_order: Ordering, @@ -2214,6 +2236,7 @@ pub fn update( #[cfg(target_has_atomic = "ptr")] #[stable(feature = "strict_provenance_atomic_ptr", since = "1.91.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_ptr_add(&self, val: usize, order: Ordering) -> *mut T { self.fetch_byte_add(val.wrapping_mul(size_of::()), order) } @@ -2258,6 +2281,7 @@ pub fn fetch_ptr_add(&self, val: usize, order: Ordering) -> *mut T { #[cfg(target_has_atomic = "ptr")] #[stable(feature = "strict_provenance_atomic_ptr", since = "1.91.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_ptr_sub(&self, val: usize, order: Ordering) -> *mut T { self.fetch_byte_sub(val.wrapping_mul(size_of::()), order) } @@ -2292,6 +2316,7 @@ pub fn fetch_ptr_sub(&self, val: usize, order: Ordering) -> *mut T { #[cfg(target_has_atomic = "ptr")] #[stable(feature = "strict_provenance_atomic_ptr", since = "1.91.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_byte_add(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_add(self.p.get(), val, order).cast() } @@ -2327,6 +2352,7 @@ pub fn fetch_byte_add(&self, val: usize, order: Ordering) -> *mut T { #[cfg(target_has_atomic = "ptr")] #[stable(feature = "strict_provenance_atomic_ptr", since = "1.91.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_byte_sub(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_sub(self.p.get(), val, order).cast() } @@ -2377,6 +2403,7 @@ pub fn fetch_byte_sub(&self, val: usize, order: Ordering) -> *mut T { #[cfg(target_has_atomic = "ptr")] #[stable(feature = "strict_provenance_atomic_ptr", since = "1.91.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_or(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_or(self.p.get(), val, order).cast() } @@ -2426,6 +2453,7 @@ pub fn fetch_or(&self, val: usize, order: Ordering) -> *mut T { #[cfg(target_has_atomic = "ptr")] #[stable(feature = "strict_provenance_atomic_ptr", since = "1.91.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_and(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_and(self.p.get(), val, order).cast() } @@ -2473,6 +2501,7 @@ pub fn fetch_and(&self, val: usize, order: Ordering) -> *mut T { #[cfg(target_has_atomic = "ptr")] #[stable(feature = "strict_provenance_atomic_ptr", since = "1.91.0")] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_xor(&self, val: usize, order: Ordering) -> *mut T { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_xor(self.p.get(), val, order).cast() } @@ -2913,6 +2942,7 @@ pub fn load(&self, order: Ordering) -> $int_type { #[inline] #[$stable] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn store(&self, val: $int_type, order: Ordering) { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_store(self.v.get(), val, order); } @@ -2941,6 +2971,7 @@ pub fn store(&self, val: $int_type, order: Ordering) { #[$stable] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn swap(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_swap(self.v.get(), val, order) } @@ -3005,6 +3036,7 @@ pub fn swap(&self, val: $int_type, order: Ordering) -> $int_type { ] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn compare_and_swap(&self, current: $int_type, new: $int_type, @@ -3073,6 +3105,7 @@ pub fn compare_and_swap(&self, #[$stable_cxchg] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn compare_exchange(&self, current: $int_type, new: $int_type, @@ -3136,6 +3169,7 @@ pub fn compare_exchange(&self, #[$stable_cxchg] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn compare_exchange_weak(&self, current: $int_type, new: $int_type, @@ -3172,6 +3206,7 @@ pub fn compare_exchange_weak(&self, #[$stable] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_add(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_add(self.v.get(), val, order) } @@ -3202,6 +3237,7 @@ pub fn fetch_add(&self, val: $int_type, order: Ordering) -> $int_type { #[$stable] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_sub(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_sub(self.v.get(), val, order) } @@ -3235,6 +3271,7 @@ pub fn fetch_sub(&self, val: $int_type, order: Ordering) -> $int_type { #[$stable] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_and(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_and(self.v.get(), val, order) } @@ -3268,6 +3305,7 @@ pub fn fetch_and(&self, val: $int_type, order: Ordering) -> $int_type { #[$stable_nand] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_nand(self.v.get(), val, order) } @@ -3301,6 +3339,7 @@ pub fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type { #[$stable] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_or(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_or(self.v.get(), val, order) } @@ -3334,6 +3373,7 @@ pub fn fetch_or(&self, val: $int_type, order: Ordering) -> $int_type { #[$stable] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_xor(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. unsafe { atomic_xor(self.v.get(), val, order) } @@ -3388,6 +3428,7 @@ pub fn fetch_xor(&self, val: $int_type, order: Ordering) -> $int_type { #[stable(feature = "no_more_cas", since = "1.45.0")] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_update(&self, set_order: Ordering, fetch_order: Ordering, @@ -3455,6 +3496,7 @@ pub fn fetch_update(&self, #[unstable(feature = "atomic_try_update", issue = "135894")] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn try_update( &self, set_order: Ordering, @@ -3516,6 +3558,7 @@ pub fn try_update( #[unstable(feature = "atomic_try_update", issue = "135894")] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn update( &self, set_order: Ordering, @@ -3570,6 +3613,7 @@ pub fn update( #[stable(feature = "atomic_min_max", since = "1.45.0")] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_max(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. unsafe { $max_fn(self.v.get(), val, order) } @@ -3616,6 +3660,7 @@ pub fn fetch_max(&self, val: $int_type, order: Ordering) -> $int_type { #[stable(feature = "atomic_min_max", since = "1.45.0")] #[$cfg_cas] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces + #[rustc_should_not_be_called_on_const_items] pub fn fetch_min(&self, val: $int_type, order: Ordering) -> $int_type { // SAFETY: data races are prevented by atomic intrinsics. unsafe { $min_fn(self.v.get(), val, order) } diff --git a/library/std/src/sync/lazy_lock.rs b/library/std/src/sync/lazy_lock.rs index f1cae4b207c9..ef58b64d4967 100644 --- a/library/std/src/sync/lazy_lock.rs +++ b/library/std/src/sync/lazy_lock.rs @@ -247,6 +247,7 @@ fn drop(&mut self) { /// ``` #[inline] #[stable(feature = "lazy_cell", since = "1.80.0")] + #[rustc_should_not_be_called_on_const_items] pub fn force(this: &LazyLock) -> &T { this.once.call_once_force(|state| { if state.is_poisoned() { @@ -320,6 +321,7 @@ pub fn get_mut(this: &mut LazyLock) -> Option<&mut T> { /// ``` #[inline] #[unstable(feature = "lazy_get", issue = "129333")] + #[rustc_should_not_be_called_on_const_items] pub fn get(this: &LazyLock) -> Option<&T> { if this.once.is_completed() { // SAFETY: diff --git a/library/std/src/sync/once.rs b/library/std/src/sync/once.rs index 12cc32f381d1..bcfc9f581fd2 100644 --- a/library/std/src/sync/once.rs +++ b/library/std/src/sync/once.rs @@ -145,6 +145,7 @@ pub const fn new() -> Once { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[track_caller] + #[rustc_should_not_be_called_on_const_items] pub fn call_once(&self, f: F) where F: FnOnce(), @@ -204,6 +205,7 @@ pub fn call_once(&self, f: F) /// ``` #[inline] #[stable(feature = "once_poison", since = "1.51.0")] + #[rustc_should_not_be_called_on_const_items] pub fn call_once_force(&self, f: F) where F: FnOnce(&OnceState), @@ -288,6 +290,7 @@ pub fn is_completed(&self) -> bool { /// panicked, this method will also panic. Use [`wait_force`](Self::wait_force) /// if this behavior is not desired. #[stable(feature = "once_wait", since = "1.86.0")] + #[rustc_should_not_be_called_on_const_items] pub fn wait(&self) { if !self.inner.is_completed() { self.inner.wait(false); @@ -300,6 +303,7 @@ pub fn wait(&self) { /// If this [`Once`] has been poisoned, this function blocks until it /// becomes completed, unlike [`Once::wait()`], which panics in this case. #[stable(feature = "once_wait", since = "1.86.0")] + #[rustc_should_not_be_called_on_const_items] pub fn wait_force(&self) { if !self.inner.is_completed() { self.inner.wait(true); diff --git a/library/std/src/sync/once_lock.rs b/library/std/src/sync/once_lock.rs index b224044cbe09..d1bbe0ff843c 100644 --- a/library/std/src/sync/once_lock.rs +++ b/library/std/src/sync/once_lock.rs @@ -150,6 +150,7 @@ pub const fn new() -> OnceLock { /// This method never blocks. #[inline] #[stable(feature = "once_cell", since = "1.70.0")] + #[rustc_should_not_be_called_on_const_items] pub fn get(&self) -> Option<&T> { if self.is_initialized() { // Safe b/c checked is_initialized @@ -197,6 +198,7 @@ pub fn get_mut(&mut self) -> Option<&mut T> { /// ``` #[inline] #[stable(feature = "once_wait", since = "1.86.0")] + #[rustc_should_not_be_called_on_const_items] pub fn wait(&self) -> &T { self.once.wait_force(); @@ -231,6 +233,7 @@ pub fn wait(&self) -> &T { /// ``` #[inline] #[stable(feature = "once_cell", since = "1.70.0")] + #[rustc_should_not_be_called_on_const_items] pub fn set(&self, value: T) -> Result<(), T> { match self.try_insert(value) { Ok(_) => Ok(()), @@ -270,6 +273,7 @@ pub fn set(&self, value: T) -> Result<(), T> { /// ``` #[inline] #[unstable(feature = "once_cell_try_insert", issue = "116693")] + #[rustc_should_not_be_called_on_const_items] pub fn try_insert(&self, value: T) -> Result<&T, (&T, T)> { let mut value = Some(value); let res = self.get_or_init(|| value.take().unwrap()); @@ -308,6 +312,7 @@ pub fn try_insert(&self, value: T) -> Result<&T, (&T, T)> { /// ``` #[inline] #[stable(feature = "once_cell", since = "1.70.0")] + #[rustc_should_not_be_called_on_const_items] pub fn get_or_init(&self, f: F) -> &T where F: FnOnce() -> T, @@ -388,6 +393,7 @@ pub fn get_mut_or_init(&mut self, f: F) -> &mut T /// ``` #[inline] #[unstable(feature = "once_cell_try", issue = "109737")] + #[rustc_should_not_be_called_on_const_items] pub fn get_or_try_init(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result, diff --git a/library/std/src/sync/poison/condvar.rs b/library/std/src/sync/poison/condvar.rs index de625a6cc5f6..fa9e1caada59 100644 --- a/library/std/src/sync/poison/condvar.rs +++ b/library/std/src/sync/poison/condvar.rs @@ -121,6 +121,7 @@ pub const fn new() -> Condvar { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_should_not_be_called_on_const_items] pub fn wait<'a, T>(&self, guard: MutexGuard<'a, T>) -> LockResult> { let poisoned = unsafe { let lock = mutex::guard_lock(&guard); @@ -177,6 +178,7 @@ pub fn wait<'a, T>(&self, guard: MutexGuard<'a, T>) -> LockResult( &self, mut guard: MutexGuard<'a, T>, @@ -245,6 +247,7 @@ pub fn wait_while<'a, T, F>( /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_should_not_be_called_on_const_items] #[deprecated(since = "1.6.0", note = "replaced by `std::sync::Condvar::wait_timeout`")] pub fn wait_timeout_ms<'a, T>( &self, @@ -316,6 +319,7 @@ pub fn wait_timeout_ms<'a, T>( /// } /// ``` #[stable(feature = "wait_timeout", since = "1.5.0")] + #[rustc_should_not_be_called_on_const_items] pub fn wait_timeout<'a, T>( &self, guard: MutexGuard<'a, T>, @@ -382,6 +386,7 @@ pub fn wait_timeout<'a, T>( /// // access the locked mutex via result.0 /// ``` #[stable(feature = "wait_timeout_until", since = "1.42.0")] + #[rustc_should_not_be_called_on_const_items] pub fn wait_timeout_while<'a, T, F>( &self, mut guard: MutexGuard<'a, T>, @@ -442,6 +447,7 @@ pub fn wait_timeout_while<'a, T, F>( /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_should_not_be_called_on_const_items] pub fn notify_one(&self) { self.inner.notify_one() } @@ -482,6 +488,7 @@ pub fn notify_one(&self) { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_should_not_be_called_on_const_items] pub fn notify_all(&self) { self.inner.notify_all() } diff --git a/library/std/src/sync/poison/mutex.rs b/library/std/src/sync/poison/mutex.rs index 6fdb4f6799ee..7f9e5fe62516 100644 --- a/library/std/src/sync/poison/mutex.rs +++ b/library/std/src/sync/poison/mutex.rs @@ -401,6 +401,7 @@ pub fn get_cloned(&self) -> Result> /// assert_eq!(mutex.get_cloned().unwrap(), 11); /// ``` #[unstable(feature = "lock_value_accessors", issue = "133407")] + #[rustc_should_not_be_called_on_const_items] pub fn set(&self, value: T) -> Result<(), PoisonError> { if mem::needs_drop::() { // If the contained value has non-trivial destructor, we @@ -438,6 +439,7 @@ pub fn set(&self, value: T) -> Result<(), PoisonError> { /// assert_eq!(mutex.get_cloned().unwrap(), 11); /// ``` #[unstable(feature = "lock_value_accessors", issue = "133407")] + #[rustc_should_not_be_called_on_const_items] pub fn replace(&self, value: T) -> LockResult { match self.lock() { Ok(mut guard) => Ok(mem::replace(&mut *guard, value)), @@ -484,6 +486,7 @@ impl Mutex { /// assert_eq!(*mutex.lock().unwrap(), 10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_should_not_be_called_on_const_items] pub fn lock(&self) -> LockResult> { unsafe { self.inner.lock(); @@ -532,6 +535,7 @@ pub fn lock(&self) -> LockResult> { /// assert_eq!(*mutex.lock().unwrap(), 10); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_should_not_be_called_on_const_items] pub fn try_lock(&self) -> TryLockResult> { unsafe { if self.inner.try_lock() { @@ -602,6 +606,7 @@ pub fn is_poisoned(&self) -> bool { /// ``` #[inline] #[stable(feature = "mutex_unpoison", since = "1.77.0")] + #[rustc_should_not_be_called_on_const_items] pub fn clear_poison(&self) { self.poison.clear(); } diff --git a/library/std/src/sync/poison/rwlock.rs b/library/std/src/sync/poison/rwlock.rs index 10e45bc8c11a..acfeb96900cc 100644 --- a/library/std/src/sync/poison/rwlock.rs +++ b/library/std/src/sync/poison/rwlock.rs @@ -299,6 +299,7 @@ pub fn get_cloned(&self) -> Result> /// assert_eq!(lock.get_cloned().unwrap(), 11); /// ``` #[unstable(feature = "lock_value_accessors", issue = "133407")] + #[rustc_should_not_be_called_on_const_items] pub fn set(&self, value: T) -> Result<(), PoisonError> { if mem::needs_drop::() { // If the contained value has non-trivial destructor, we @@ -337,6 +338,7 @@ pub fn set(&self, value: T) -> Result<(), PoisonError> { /// assert_eq!(lock.get_cloned().unwrap(), 11); /// ``` #[unstable(feature = "lock_value_accessors", issue = "133407")] + #[rustc_should_not_be_called_on_const_items] pub fn replace(&self, value: T) -> LockResult { match self.write() { Ok(mut guard) => Ok(mem::replace(&mut *guard, value)), @@ -389,6 +391,7 @@ impl RwLock { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_should_not_be_called_on_const_items] pub fn read(&self) -> LockResult> { unsafe { self.inner.read(); @@ -435,6 +438,7 @@ pub fn read(&self) -> LockResult> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_should_not_be_called_on_const_items] pub fn try_read(&self) -> TryLockResult> { unsafe { if self.inner.try_read() { @@ -479,6 +483,7 @@ pub fn try_read(&self) -> TryLockResult> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_should_not_be_called_on_const_items] pub fn write(&self) -> LockResult> { unsafe { self.inner.write(); @@ -526,6 +531,7 @@ pub fn write(&self) -> LockResult> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_should_not_be_called_on_const_items] pub fn try_write(&self) -> TryLockResult> { unsafe { if self.inner.try_write() { From dc2a61eccd6702e297db6a4bfd1443064cabc0a4 Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 2 Nov 2025 15:19:33 +0100 Subject: [PATCH 135/194] Add `const_item_interior_mutations` lint --- compiler/rustc_lint/messages.ftl | 8 + .../rustc_lint/src/interior_mutable_consts.rs | 122 +++ compiler/rustc_lint/src/lib.rs | 3 + compiler/rustc_lint/src/lints.rs | 33 + ...tem-interior-mutations-const-atomics.fixed | 164 ++++ ...t-item-interior-mutations-const-atomics.rs | 164 ++++ ...em-interior-mutations-const-atomics.stderr | 765 ++++++++++++++++++ ...onst-item-interior-mutations-const-cell.rs | 105 +++ ...-item-interior-mutations-const-cell.stderr | 377 +++++++++ .../const-item-interior-mutations-const.fixed | 139 ++++ .../const-item-interior-mutations-const.rs | 139 ++++ ...const-item-interior-mutations-const.stderr | 513 ++++++++++++ 12 files changed, 2532 insertions(+) create mode 100644 compiler/rustc_lint/src/interior_mutable_consts.rs create mode 100644 tests/ui/lint/const-item-interior-mutations-const-atomics.fixed create mode 100644 tests/ui/lint/const-item-interior-mutations-const-atomics.rs create mode 100644 tests/ui/lint/const-item-interior-mutations-const-atomics.stderr create mode 100644 tests/ui/lint/const-item-interior-mutations-const-cell.rs create mode 100644 tests/ui/lint/const-item-interior-mutations-const-cell.stderr create mode 100644 tests/ui/lint/const-item-interior-mutations-const.fixed create mode 100644 tests/ui/lint/const-item-interior-mutations-const.rs create mode 100644 tests/ui/lint/const-item-interior-mutations-const.stderr diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index c996181354b9..df04d135600a 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -193,6 +193,14 @@ lint_confusable_identifier_pair = found both `{$existing_sym}` and `{$sym}` as i .current_use = this identifier can be confused with `{$existing_sym}` .other_use = other identifier used here +lint_const_item_interior_mutations = + mutation of an interior mutable `const` item with call to `{$method_name}` + .label = `{$const_name}` is a interior mutable `const` item of type `{$const_ty}` + .temporary = each usage of a `const` item creates a new temporary + .never_original = only the temporaries and never the original `const {$const_name}` will be modified + .suggestion_static = for a shared instance of `{$const_name}`, consider making it a `static` item instead + .help = for more details on interior mutability see + lint_dangling_pointers_from_locals = {$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}` .ret_ty = return type is `{$ret_ty}` .local_var = local variable `{$local_var_name}` is dropped at the end of the {$fn_kind} diff --git a/compiler/rustc_lint/src/interior_mutable_consts.rs b/compiler/rustc_lint/src/interior_mutable_consts.rs new file mode 100644 index 000000000000..8576698dec33 --- /dev/null +++ b/compiler/rustc_lint/src/interior_mutable_consts.rs @@ -0,0 +1,122 @@ +use rustc_hir::attrs::AttributeKind; +use rustc_hir::def::{DefKind, Res}; +use rustc_hir::{Expr, ExprKind, ItemKind, Node, find_attr}; +use rustc_session::{declare_lint, declare_lint_pass}; + +use crate::lints::{ConstItemInteriorMutationsDiag, ConstItemInteriorMutationsSuggestionStatic}; +use crate::{LateContext, LateLintPass, LintContext}; + +declare_lint! { + /// The `const_item_interior_mutations` lint checks for calls which + /// mutates an interior mutable const-item. + /// + /// ### Example + /// + /// ```rust + /// use std::sync::Once; + /// + /// const INIT: Once = Once::new(); // using `INIT` will always create a temporary and + /// // never modify it-self on use, should be a `static` + /// // instead for shared use + /// + /// fn init() { + /// INIT.call_once(|| { + /// println!("Once::call_once first call"); + /// }); + /// INIT.call_once(|| { // this second will also print + /// println!("Once::call_once second call"); // as each call to `INIT` creates + /// }); // new temporary + /// } + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Calling a method which mutates an interior mutable type has no effect as const-item + /// are essentially inlined wherever they are used, meaning that they are copied + /// directly into the relevant context when used rendering modification through + /// interior mutability ineffective across usage of that const-item. + /// + /// The current implementation of this lint only warns on significant `std` and + /// `core` interior mutable types, like `Once`, `AtomicI32`, ... this is done out + /// of prudence to avoid false-positive and may be extended in the future. + pub CONST_ITEM_INTERIOR_MUTATIONS, + Warn, + "checks for calls which mutates a interior mutable const-item" +} + +declare_lint_pass!(InteriorMutableConsts => [CONST_ITEM_INTERIOR_MUTATIONS]); + +impl<'tcx> LateLintPass<'tcx> for InteriorMutableConsts { + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { + let typeck = cx.typeck_results(); + + let (method_did, receiver) = match expr.kind { + // matching on `.method(..)` + ExprKind::MethodCall(_, receiver, _, _) => { + (typeck.type_dependent_def_id(expr.hir_id), receiver) + } + // matching on `function(&, ...)` + ExprKind::Call(path, [receiver, ..]) => match receiver.kind { + ExprKind::AddrOf(_, _, receiver) => match path.kind { + ExprKind::Path(ref qpath) => { + (cx.qpath_res(qpath, path.hir_id).opt_def_id(), receiver) + } + _ => return, + }, + _ => return, + }, + _ => return, + }; + + let Some(method_did) = method_did else { + return; + }; + + if let ExprKind::Path(qpath) = &receiver.kind + && let Res::Def(DefKind::Const | DefKind::AssocConst, const_did) = + typeck.qpath_res(qpath, receiver.hir_id) + // Let's do the attribute check after the other checks for perf reasons + && find_attr!( + cx.tcx.get_all_attrs(method_did), + AttributeKind::RustcShouldNotBeCalledOnConstItems(_) + ) + && let Some(method_name) = cx.tcx.opt_item_ident(method_did) + && let Some(const_name) = cx.tcx.opt_item_ident(const_did) + && let Some(const_ty) = typeck.node_type_opt(receiver.hir_id) + { + // Find the local `const`-item and create the suggestion to use `static` instead + let sugg_static = if let Some(Node::Item(const_item)) = + cx.tcx.hir_get_if_local(const_did) + && let ItemKind::Const(ident, _generics, _ty, _body_id) = const_item.kind + { + if let Some(vis_span) = const_item.vis_span.find_ancestor_inside(const_item.span) + && const_item.span.can_be_used_for_suggestions() + && vis_span.can_be_used_for_suggestions() + { + Some(ConstItemInteriorMutationsSuggestionStatic::Spanful { + const_: const_item.vis_span.between(ident.span), + before: if !vis_span.is_empty() { " " } else { "" }, + }) + } else { + Some(ConstItemInteriorMutationsSuggestionStatic::Spanless) + } + } else { + None + }; + + cx.emit_span_lint( + CONST_ITEM_INTERIOR_MUTATIONS, + expr.span, + ConstItemInteriorMutationsDiag { + method_name, + const_name, + const_ty, + receiver_span: receiver.span, + sugg_static, + }, + ); + } + } +} diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 7c3a81e89130..78b76e083d41 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -48,6 +48,7 @@ mod function_cast_as_integer; mod if_let_rescope; mod impl_trait_overcaptures; +mod interior_mutable_consts; mod internal; mod invalid_from_utf8; mod late; @@ -93,6 +94,7 @@ use function_cast_as_integer::*; use if_let_rescope::IfLetRescope; use impl_trait_overcaptures::ImplTraitOvercaptures; +use interior_mutable_consts::*; use internal::*; use invalid_from_utf8::*; use let_underscore::*; @@ -239,6 +241,7 @@ fn lint_mod(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) { AsyncClosureUsage: AsyncClosureUsage, AsyncFnInTrait: AsyncFnInTrait, NonLocalDefinitions: NonLocalDefinitions::default(), + InteriorMutableConsts: InteriorMutableConsts, ImplTraitOvercaptures: ImplTraitOvercaptures, IfLetRescope: IfLetRescope::default(), StaticMutRefs: StaticMutRefs, diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index dc50f61f741d..096299c16e0f 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -784,6 +784,39 @@ pub(crate) enum InvalidFromUtf8Diag { }, } +// interior_mutable_consts.rs +#[derive(LintDiagnostic)] +#[diag(lint_const_item_interior_mutations)] +#[note(lint_temporary)] +#[note(lint_never_original)] +#[help] +pub(crate) struct ConstItemInteriorMutationsDiag<'tcx> { + pub method_name: Ident, + pub const_name: Ident, + pub const_ty: Ty<'tcx>, + #[label] + pub receiver_span: Span, + #[subdiagnostic] + pub sugg_static: Option, +} + +#[derive(Subdiagnostic)] +pub(crate) enum ConstItemInteriorMutationsSuggestionStatic { + #[suggestion( + lint_suggestion_static, + code = "{before}static ", + style = "verbose", + applicability = "maybe-incorrect" + )] + Spanful { + #[primary_span] + const_: Span, + before: &'static str, + }, + #[help(lint_suggestion_static)] + Spanless, +} + // reference_casting.rs #[derive(LintDiagnostic)] pub(crate) enum InvalidReferenceCastingDiag<'tcx> { diff --git a/tests/ui/lint/const-item-interior-mutations-const-atomics.fixed b/tests/ui/lint/const-item-interior-mutations-const-atomics.fixed new file mode 100644 index 000000000000..17737e5cb8b9 --- /dev/null +++ b/tests/ui/lint/const-item-interior-mutations-const-atomics.fixed @@ -0,0 +1,164 @@ +//@ check-pass +//@ run-rustfix + +#![allow(deprecated)] +#![allow(dead_code)] +#![feature(atomic_try_update)] + +use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicU32, Ordering}; + +fn atomic_bool() { + static A: AtomicBool = AtomicBool::new(false); + + let _a = A.store(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `store` + + let _a = A.swap(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `swap` + + let _a = A.compare_and_swap(false, true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap` + + let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange` + + let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak` + + let _a = A.fetch_and(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_and` + + let _a = A.fetch_nand(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_nand` + + let _a = A.fetch_or(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_or` + + let _a = A.fetch_xor(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor` + + let _a = A.fetch_not(Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_not` + + let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true)); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_update` + + let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false)); + //~^ WARN mutation of an interior mutable `const` item with call to `try_update` + + let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true); + //~^ WARN mutation of an interior mutable `const` item with call to `update` +} + +fn atomic_ptr() { + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + + let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `store` + + let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `swap` + + let _a = A.compare_and_swap(std::ptr::null_mut(), std::ptr::null_mut(), Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap` + + let _a = A.compare_exchange( + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange` + std::ptr::null_mut(), + std::ptr::null_mut(), + Ordering::SeqCst, + Ordering::Relaxed, + ); + + let _a = A.compare_exchange_weak( + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak` + std::ptr::null_mut(), + std::ptr::null_mut(), + Ordering::SeqCst, + Ordering::Relaxed, + ); + + let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_update` + + let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); + //~^ WARN mutation of an interior mutable `const` item with call to `try_update` + + let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut()); + //~^ WARN mutation of an interior mutable `const` item with call to `update` + + let _a = A.fetch_ptr_add(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_ptr_add` + + let _a = A.fetch_ptr_sub(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_ptr_sub` + + let _a = A.fetch_byte_add(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_byte_add` + + let _a = A.fetch_byte_sub(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_byte_sub` + + let _a = A.fetch_and(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_and` + + let _a = A.fetch_or(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_or` + + let _a = A.fetch_xor(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor` +} + +fn atomic_u32() { + static A: AtomicU32 = AtomicU32::new(0); + + let _a = A.store(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `store` + + let _a = A.swap(2, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `swap` + + let _a = A.compare_and_swap(2, 3, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap` + + let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange` + + let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak` + + let _a = A.fetch_add(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_add` + + let _a = A.fetch_sub(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_sub` + + let _a = A.fetch_add(2, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_add` + + let _a = A.fetch_nand(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_nand` + + let _a = A.fetch_or(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_or` + + let _a = A.fetch_xor(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor` + + let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10)); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_update` + + let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11)); + //~^ WARN mutation of an interior mutable `const` item with call to `try_update` + + let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12); + //~^ WARN mutation of an interior mutable `const` item with call to `update` + + let _a = A.fetch_max(20, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_max` + + let _a = A.fetch_min(5, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_min` +} + +fn main() {} diff --git a/tests/ui/lint/const-item-interior-mutations-const-atomics.rs b/tests/ui/lint/const-item-interior-mutations-const-atomics.rs new file mode 100644 index 000000000000..4180b2340df6 --- /dev/null +++ b/tests/ui/lint/const-item-interior-mutations-const-atomics.rs @@ -0,0 +1,164 @@ +//@ check-pass +//@ run-rustfix + +#![allow(deprecated)] +#![allow(dead_code)] +#![feature(atomic_try_update)] + +use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicU32, Ordering}; + +fn atomic_bool() { + const A: AtomicBool = AtomicBool::new(false); + + let _a = A.store(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `store` + + let _a = A.swap(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `swap` + + let _a = A.compare_and_swap(false, true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap` + + let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange` + + let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak` + + let _a = A.fetch_and(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_and` + + let _a = A.fetch_nand(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_nand` + + let _a = A.fetch_or(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_or` + + let _a = A.fetch_xor(true, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor` + + let _a = A.fetch_not(Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_not` + + let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true)); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_update` + + let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false)); + //~^ WARN mutation of an interior mutable `const` item with call to `try_update` + + let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true); + //~^ WARN mutation of an interior mutable `const` item with call to `update` +} + +fn atomic_ptr() { + const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + + let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `store` + + let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `swap` + + let _a = A.compare_and_swap(std::ptr::null_mut(), std::ptr::null_mut(), Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap` + + let _a = A.compare_exchange( + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange` + std::ptr::null_mut(), + std::ptr::null_mut(), + Ordering::SeqCst, + Ordering::Relaxed, + ); + + let _a = A.compare_exchange_weak( + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak` + std::ptr::null_mut(), + std::ptr::null_mut(), + Ordering::SeqCst, + Ordering::Relaxed, + ); + + let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_update` + + let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); + //~^ WARN mutation of an interior mutable `const` item with call to `try_update` + + let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut()); + //~^ WARN mutation of an interior mutable `const` item with call to `update` + + let _a = A.fetch_ptr_add(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_ptr_add` + + let _a = A.fetch_ptr_sub(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_ptr_sub` + + let _a = A.fetch_byte_add(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_byte_add` + + let _a = A.fetch_byte_sub(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_byte_sub` + + let _a = A.fetch_and(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_and` + + let _a = A.fetch_or(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_or` + + let _a = A.fetch_xor(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor` +} + +fn atomic_u32() { + const A: AtomicU32 = AtomicU32::new(0); + + let _a = A.store(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `store` + + let _a = A.swap(2, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `swap` + + let _a = A.compare_and_swap(2, 3, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_and_swap` + + let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange` + + let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed); + //~^ WARN mutation of an interior mutable `const` item with call to `compare_exchange_weak` + + let _a = A.fetch_add(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_add` + + let _a = A.fetch_sub(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_sub` + + let _a = A.fetch_add(2, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_add` + + let _a = A.fetch_nand(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_nand` + + let _a = A.fetch_or(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_or` + + let _a = A.fetch_xor(1, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_xor` + + let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10)); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_update` + + let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11)); + //~^ WARN mutation of an interior mutable `const` item with call to `try_update` + + let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12); + //~^ WARN mutation of an interior mutable `const` item with call to `update` + + let _a = A.fetch_max(20, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_max` + + let _a = A.fetch_min(5, Ordering::SeqCst); + //~^ WARN mutation of an interior mutable `const` item with call to `fetch_min` +} + +fn main() {} diff --git a/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr new file mode 100644 index 000000000000..17823366d406 --- /dev/null +++ b/tests/ui/lint/const-item-interior-mutations-const-atomics.stderr @@ -0,0 +1,765 @@ +warning: mutation of an interior mutable `const` item with call to `store` + --> $DIR/const-item-interior-mutations-const-atomics.rs:13:14 + | +LL | let _a = A.store(true, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see + = note: `#[warn(const_item_interior_mutations)]` on by default +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `swap` + --> $DIR/const-item-interior-mutations-const-atomics.rs:16:14 + | +LL | let _a = A.swap(true, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `compare_and_swap` + --> $DIR/const-item-interior-mutations-const-atomics.rs:19:14 + | +LL | let _a = A.compare_and_swap(false, true, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `compare_exchange` + --> $DIR/const-item-interior-mutations-const-atomics.rs:22:14 + | +LL | let _a = A.compare_exchange(false, true, Ordering::SeqCst, Ordering::Relaxed); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `compare_exchange_weak` + --> $DIR/const-item-interior-mutations-const-atomics.rs:25:14 + | +LL | let _a = A.compare_exchange_weak(false, true, Ordering::SeqCst, Ordering::Relaxed); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_and` + --> $DIR/const-item-interior-mutations-const-atomics.rs:28:14 + | +LL | let _a = A.fetch_and(true, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_nand` + --> $DIR/const-item-interior-mutations-const-atomics.rs:31:14 + | +LL | let _a = A.fetch_nand(true, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_or` + --> $DIR/const-item-interior-mutations-const-atomics.rs:34:14 + | +LL | let _a = A.fetch_or(true, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_xor` + --> $DIR/const-item-interior-mutations-const-atomics.rs:37:14 + | +LL | let _a = A.fetch_xor(true, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_not` + --> $DIR/const-item-interior-mutations-const-atomics.rs:40:14 + | +LL | let _a = A.fetch_not(Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_update` + --> $DIR/const-item-interior-mutations-const-atomics.rs:43:14 + | +LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(true)); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `try_update` + --> $DIR/const-item-interior-mutations-const-atomics.rs:46:14 + | +LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(false)); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `update` + --> $DIR/const-item-interior-mutations-const-atomics.rs:49:14 + | +LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| true); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicBool` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicBool = AtomicBool::new(false); +LL + static A: AtomicBool = AtomicBool::new(false); + | + +warning: mutation of an interior mutable `const` item with call to `store` + --> $DIR/const-item-interior-mutations-const-atomics.rs:56:14 + | +LL | let _a = A.store(std::ptr::null_mut(), Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `swap` + --> $DIR/const-item-interior-mutations-const-atomics.rs:59:14 + | +LL | let _a = A.swap(std::ptr::null_mut(), Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `compare_and_swap` + --> $DIR/const-item-interior-mutations-const-atomics.rs:62:14 + | +LL | let _a = A.compare_and_swap(std::ptr::null_mut(), std::ptr::null_mut(), Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `compare_exchange` + --> $DIR/const-item-interior-mutations-const-atomics.rs:65:14 + | +LL | let _a = A.compare_exchange( + | ^ `A` is a interior mutable `const` item of type `AtomicPtr` + | ______________| + | | +LL | | +LL | | std::ptr::null_mut(), +LL | | std::ptr::null_mut(), +LL | | Ordering::SeqCst, +LL | | Ordering::Relaxed, +LL | | ); + | |_____^ + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `compare_exchange_weak` + --> $DIR/const-item-interior-mutations-const-atomics.rs:73:14 + | +LL | let _a = A.compare_exchange_weak( + | ^ `A` is a interior mutable `const` item of type `AtomicPtr` + | ______________| + | | +LL | | +LL | | std::ptr::null_mut(), +LL | | std::ptr::null_mut(), +LL | | Ordering::SeqCst, +LL | | Ordering::Relaxed, +LL | | ); + | |_____^ + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_update` + --> $DIR/const-item-interior-mutations-const-atomics.rs:81:14 + | +LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `try_update` + --> $DIR/const-item-interior-mutations-const-atomics.rs:84:14 + | +LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(std::ptr::null_mut())); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `update` + --> $DIR/const-item-interior-mutations-const-atomics.rs:87:14 + | +LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| std::ptr::null_mut()); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_ptr_add` + --> $DIR/const-item-interior-mutations-const-atomics.rs:90:14 + | +LL | let _a = A.fetch_ptr_add(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_ptr_sub` + --> $DIR/const-item-interior-mutations-const-atomics.rs:93:14 + | +LL | let _a = A.fetch_ptr_sub(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_byte_add` + --> $DIR/const-item-interior-mutations-const-atomics.rs:96:14 + | +LL | let _a = A.fetch_byte_add(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_byte_sub` + --> $DIR/const-item-interior-mutations-const-atomics.rs:99:14 + | +LL | let _a = A.fetch_byte_sub(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_and` + --> $DIR/const-item-interior-mutations-const-atomics.rs:102:14 + | +LL | let _a = A.fetch_and(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_or` + --> $DIR/const-item-interior-mutations-const-atomics.rs:105:14 + | +LL | let _a = A.fetch_or(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_xor` + --> $DIR/const-item-interior-mutations-const-atomics.rs:108:14 + | +LL | let _a = A.fetch_xor(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicPtr` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); +LL + static A: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + | + +warning: mutation of an interior mutable `const` item with call to `store` + --> $DIR/const-item-interior-mutations-const-atomics.rs:115:14 + | +LL | let _a = A.store(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `swap` + --> $DIR/const-item-interior-mutations-const-atomics.rs:118:14 + | +LL | let _a = A.swap(2, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `compare_and_swap` + --> $DIR/const-item-interior-mutations-const-atomics.rs:121:14 + | +LL | let _a = A.compare_and_swap(2, 3, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `compare_exchange` + --> $DIR/const-item-interior-mutations-const-atomics.rs:124:14 + | +LL | let _a = A.compare_exchange(3, 4, Ordering::SeqCst, Ordering::Relaxed); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `compare_exchange_weak` + --> $DIR/const-item-interior-mutations-const-atomics.rs:127:14 + | +LL | let _a = A.compare_exchange_weak(4, 5, Ordering::SeqCst, Ordering::Relaxed); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_add` + --> $DIR/const-item-interior-mutations-const-atomics.rs:130:14 + | +LL | let _a = A.fetch_add(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_sub` + --> $DIR/const-item-interior-mutations-const-atomics.rs:133:14 + | +LL | let _a = A.fetch_sub(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_add` + --> $DIR/const-item-interior-mutations-const-atomics.rs:136:14 + | +LL | let _a = A.fetch_add(2, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_nand` + --> $DIR/const-item-interior-mutations-const-atomics.rs:139:14 + | +LL | let _a = A.fetch_nand(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_or` + --> $DIR/const-item-interior-mutations-const-atomics.rs:142:14 + | +LL | let _a = A.fetch_or(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_xor` + --> $DIR/const-item-interior-mutations-const-atomics.rs:145:14 + | +LL | let _a = A.fetch_xor(1, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_update` + --> $DIR/const-item-interior-mutations-const-atomics.rs:148:14 + | +LL | let _a = A.fetch_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(10)); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `try_update` + --> $DIR/const-item-interior-mutations-const-atomics.rs:151:14 + | +LL | let _a = A.try_update(Ordering::SeqCst, Ordering::Relaxed, |_| Some(11)); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `update` + --> $DIR/const-item-interior-mutations-const-atomics.rs:154:14 + | +LL | let _a = A.update(Ordering::SeqCst, Ordering::Relaxed, |_| 12); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_max` + --> $DIR/const-item-interior-mutations-const-atomics.rs:157:14 + | +LL | let _a = A.fetch_max(20, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `fetch_min` + --> $DIR/const-item-interior-mutations-const-atomics.rs:160:14 + | +LL | let _a = A.fetch_min(5, Ordering::SeqCst); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `AtomicU32` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: AtomicU32 = AtomicU32::new(0); +LL + static A: AtomicU32 = AtomicU32::new(0); + | + +warning: 44 warnings emitted + diff --git a/tests/ui/lint/const-item-interior-mutations-const-cell.rs b/tests/ui/lint/const-item-interior-mutations-const-cell.rs new file mode 100644 index 000000000000..b4a7f54c8e7a --- /dev/null +++ b/tests/ui/lint/const-item-interior-mutations-const-cell.rs @@ -0,0 +1,105 @@ +//@ check-pass + +#![feature(unsafe_cell_access)] +#![feature(sync_unsafe_cell)] +#![feature(once_cell_try_insert)] +#![feature(once_cell_try)] +#![feature(lazy_get)] + +use std::cell::{Cell, RefCell, SyncUnsafeCell, UnsafeCell}; +use std::cell::{LazyCell, OnceCell}; +use std::ops::Deref; + +fn lazy_cell() { + const A: LazyCell = LazyCell::new(|| 0); + + let _ = LazyCell::force(&A); + //~^ WARN mutation of an interior mutable `const` item with call to `force` +} + +fn once_cell() { + const A: OnceCell = OnceCell::new(); + + let _ = A.set(10); + //~^ WARN mutation of an interior mutable `const` item with call to `set` + + let _ = A.try_insert(20); + //~^ WARN mutation of an interior mutable `const` item with call to `try_insert` + + let _ = A.get_or_init(|| 30); + //~^ WARN mutation of an interior mutable `const` item with call to `get_or_init` + + let _ = A.get_or_try_init(|| Ok::<_, ()>(40)); + //~^ WARN mutation of an interior mutable `const` item with call to `get_or_try_init` +} + +fn cell() { + const A: Cell = Cell::new(0); + + let _ = A.set(1); + //~^ WARN mutation of an interior mutable `const` item with call to `set` + + let _ = A.swap(&A); + //~^ WARN mutation of an interior mutable `const` item with call to `swap` + + let _ = A.replace(2); + //~^ WARN mutation of an interior mutable `const` item with call to `replace` + + let _ = A.get(); + //~^ WARN mutation of an interior mutable `const` item with call to `get` + + let _ = A.update(|x| x + 1); + //~^ WARN mutation of an interior mutable `const` item with call to `update` +} + +fn ref_cell() { + const A: RefCell = RefCell::new(0); + + let _ = A.replace(1); + //~^ WARN mutation of an interior mutable `const` item with call to `replace` + + let _ = A.replace_with(|x| *x + 2); + //~^ WARN mutation of an interior mutable `const` item with call to `replace_with` + + let _ = A.swap(&A); + //~^ WARN mutation of an interior mutable `const` item with call to `swap` + + let _ = A.borrow(); + //~^ WARN mutation of an interior mutable `const` item with call to `borrow` + + let _ = A.try_borrow(); + //~^ WARN mutation of an interior mutable `const` item with call to `try_borrow` + + let _ = A.borrow_mut(); + //~^ WARN mutation of an interior mutable `const` item with call to `borrow_mut` + + let _ = A.try_borrow_mut(); + //~^ WARN mutation of an interior mutable `const` item with call to `try_borrow_mut` +} + +fn unsafe_cell() { + const A: UnsafeCell = UnsafeCell::new(0); + + let _ = unsafe { A.replace(1) }; + //~^ WARN mutation of an interior mutable `const` item with call to `replace` + + let _ = A.get(); + //~^ WARN mutation of an interior mutable `const` item with call to `get` + + unsafe { + let _ = A.as_ref_unchecked(); + //~^ WARN mutation of an interior mutable `const` item with call to `as_ref_unchecked` + + let _ = A.as_mut_unchecked(); + //~^ WARN mutation of an interior mutable `const` item with call to `as_mut_unchecked` + } +} + +fn sync_unsafe_cell() { + const A: SyncUnsafeCell = SyncUnsafeCell::new(0); + + let _ = A.get(); + //~^ WARN mutation of an interior mutable `const` item with call to `get` +} + +fn main() {} diff --git a/tests/ui/lint/const-item-interior-mutations-const-cell.stderr b/tests/ui/lint/const-item-interior-mutations-const-cell.stderr new file mode 100644 index 000000000000..d9f19c61fa77 --- /dev/null +++ b/tests/ui/lint/const-item-interior-mutations-const-cell.stderr @@ -0,0 +1,377 @@ +warning: mutation of an interior mutable `const` item with call to `force` + --> $DIR/const-item-interior-mutations-const-cell.rs:16:13 + | +LL | let _ = LazyCell::force(&A); + | ^^^^^^^^^^^^^^^^^-^ + | | + | `A` is a interior mutable `const` item of type `LazyCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see + = note: `#[warn(const_item_interior_mutations)]` on by default +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: LazyCell = LazyCell::new(|| 0); +LL + static A: LazyCell = LazyCell::new(|| 0); + | + +warning: mutation of an interior mutable `const` item with call to `set` + --> $DIR/const-item-interior-mutations-const-cell.rs:23:13 + | +LL | let _ = A.set(10); + | -^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `OnceCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: OnceCell = OnceCell::new(); +LL + static A: OnceCell = OnceCell::new(); + | + +warning: mutation of an interior mutable `const` item with call to `try_insert` + --> $DIR/const-item-interior-mutations-const-cell.rs:26:13 + | +LL | let _ = A.try_insert(20); + | -^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `OnceCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: OnceCell = OnceCell::new(); +LL + static A: OnceCell = OnceCell::new(); + | + +warning: mutation of an interior mutable `const` item with call to `get_or_init` + --> $DIR/const-item-interior-mutations-const-cell.rs:29:13 + | +LL | let _ = A.get_or_init(|| 30); + | -^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `OnceCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: OnceCell = OnceCell::new(); +LL + static A: OnceCell = OnceCell::new(); + | + +warning: mutation of an interior mutable `const` item with call to `get_or_try_init` + --> $DIR/const-item-interior-mutations-const-cell.rs:32:13 + | +LL | let _ = A.get_or_try_init(|| Ok::<_, ()>(40)); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `OnceCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: OnceCell = OnceCell::new(); +LL + static A: OnceCell = OnceCell::new(); + | + +warning: mutation of an interior mutable `const` item with call to `set` + --> $DIR/const-item-interior-mutations-const-cell.rs:39:13 + | +LL | let _ = A.set(1); + | -^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `Cell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Cell = Cell::new(0); +LL + static A: Cell = Cell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `swap` + --> $DIR/const-item-interior-mutations-const-cell.rs:42:13 + | +LL | let _ = A.swap(&A); + | -^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `Cell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Cell = Cell::new(0); +LL + static A: Cell = Cell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `replace` + --> $DIR/const-item-interior-mutations-const-cell.rs:45:13 + | +LL | let _ = A.replace(2); + | -^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `Cell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Cell = Cell::new(0); +LL + static A: Cell = Cell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `get` + --> $DIR/const-item-interior-mutations-const-cell.rs:48:13 + | +LL | let _ = A.get(); + | -^^^^^^ + | | + | `A` is a interior mutable `const` item of type `Cell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Cell = Cell::new(0); +LL + static A: Cell = Cell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `update` + --> $DIR/const-item-interior-mutations-const-cell.rs:51:13 + | +LL | let _ = A.update(|x| x + 1); + | -^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `Cell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Cell = Cell::new(0); +LL + static A: Cell = Cell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `replace` + --> $DIR/const-item-interior-mutations-const-cell.rs:58:13 + | +LL | let _ = A.replace(1); + | -^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `RefCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RefCell = RefCell::new(0); +LL + static A: RefCell = RefCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `replace_with` + --> $DIR/const-item-interior-mutations-const-cell.rs:61:13 + | +LL | let _ = A.replace_with(|x| *x + 2); + | -^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `RefCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RefCell = RefCell::new(0); +LL + static A: RefCell = RefCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `swap` + --> $DIR/const-item-interior-mutations-const-cell.rs:64:13 + | +LL | let _ = A.swap(&A); + | -^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `RefCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RefCell = RefCell::new(0); +LL + static A: RefCell = RefCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `borrow` + --> $DIR/const-item-interior-mutations-const-cell.rs:67:13 + | +LL | let _ = A.borrow(); + | -^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `RefCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RefCell = RefCell::new(0); +LL + static A: RefCell = RefCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `try_borrow` + --> $DIR/const-item-interior-mutations-const-cell.rs:70:13 + | +LL | let _ = A.try_borrow(); + | -^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `RefCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RefCell = RefCell::new(0); +LL + static A: RefCell = RefCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `borrow_mut` + --> $DIR/const-item-interior-mutations-const-cell.rs:73:13 + | +LL | let _ = A.borrow_mut(); + | -^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `RefCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RefCell = RefCell::new(0); +LL + static A: RefCell = RefCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `try_borrow_mut` + --> $DIR/const-item-interior-mutations-const-cell.rs:76:13 + | +LL | let _ = A.try_borrow_mut(); + | -^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `RefCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RefCell = RefCell::new(0); +LL + static A: RefCell = RefCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `replace` + --> $DIR/const-item-interior-mutations-const-cell.rs:83:22 + | +LL | let _ = unsafe { A.replace(1) }; + | -^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `UnsafeCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: UnsafeCell = UnsafeCell::new(0); +LL + static A: UnsafeCell = UnsafeCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `get` + --> $DIR/const-item-interior-mutations-const-cell.rs:86:13 + | +LL | let _ = A.get(); + | -^^^^^^ + | | + | `A` is a interior mutable `const` item of type `UnsafeCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: UnsafeCell = UnsafeCell::new(0); +LL + static A: UnsafeCell = UnsafeCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `as_ref_unchecked` + --> $DIR/const-item-interior-mutations-const-cell.rs:90:17 + | +LL | let _ = A.as_ref_unchecked(); + | -^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `UnsafeCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: UnsafeCell = UnsafeCell::new(0); +LL + static A: UnsafeCell = UnsafeCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `as_mut_unchecked` + --> $DIR/const-item-interior-mutations-const-cell.rs:93:17 + | +LL | let _ = A.as_mut_unchecked(); + | -^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `UnsafeCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: UnsafeCell = UnsafeCell::new(0); +LL + static A: UnsafeCell = UnsafeCell::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `get` + --> $DIR/const-item-interior-mutations-const-cell.rs:101:13 + | +LL | let _ = A.get(); + | -^^^^^^ + | | + | `A` is a interior mutable `const` item of type `SyncUnsafeCell` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: SyncUnsafeCell = SyncUnsafeCell::new(0); +LL + static A: SyncUnsafeCell = SyncUnsafeCell::new(0); + | + +warning: 22 warnings emitted + diff --git a/tests/ui/lint/const-item-interior-mutations-const.fixed b/tests/ui/lint/const-item-interior-mutations-const.fixed new file mode 100644 index 000000000000..82f3fdac43a3 --- /dev/null +++ b/tests/ui/lint/const-item-interior-mutations-const.fixed @@ -0,0 +1,139 @@ +//@ check-pass +//@ run-rustfix + +#![allow(deprecated)] +#![allow(dead_code)] +#![feature(lock_value_accessors)] +#![feature(once_cell_try_insert)] +#![feature(once_cell_try)] +#![feature(lazy_get)] + +use std::sync::{Condvar, LazyLock, Mutex, Once, OnceLock, RwLock}; +use std::time::Duration; + +fn mutex() { + static A: Mutex = Mutex::new(0); + + let _a = A.set(1); + //~^ WARN mutation of an interior mutable `const` item with call to `set` + + let _a = A.replace(2); + //~^ WARN mutation of an interior mutable `const` item with call to `replace` + + drop(A.lock()); + //~^ WARN mutation of an interior mutable `const` item with call to `lock` + + drop(A.try_lock()); + //~^ WARN mutation of an interior mutable `const` item with call to `try_lock` + + let _a = A.clear_poison(); + //~^ WARN mutation of an interior mutable `const` item with call to `clear_poison` +} + +fn once() { + static A: Once = Once::new(); + + let _a = A.call_once(|| {}); + //~^ WARN mutation of an interior mutable `const` item with call to `call_once` + + let _a = A.call_once_force(|_| {}); + //~^ WARN mutation of an interior mutable `const` item with call to `call_once_force` + + let _a = A.wait(); + //~^ WARN mutation of an interior mutable `const` item with call to `wait` + + let _a = A.wait_force(); + //~^ WARN mutation of an interior mutable `const` item with call to `wait_force` +} + +fn rwlock() { + static A: RwLock = RwLock::new(0); + + let _a = A.set(1); + //~^ WARN mutation of an interior mutable `const` item with call to `set` + + let _a = A.replace(2); + //~^ WARN mutation of an interior mutable `const` item with call to `replace` + + drop(A.read()); + //~^ WARN mutation of an interior mutable `const` item with call to `read` + + drop(A.try_read()); + //~^ WARN mutation of an interior mutable `const` item with call to `try_read` + + drop(A.write()); + //~^ WARN mutation of an interior mutable `const` item with call to `write` + + drop(A.try_write()); + //~^ WARN mutation of an interior mutable `const` item with call to `try_write` +} + +fn lazy_lock() { + static A: LazyLock = LazyLock::new(|| 0); + + let _a = LazyLock::force(&A); + //~^ WARN mutation of an interior mutable `const` item with call to `force` + + let _a = LazyLock::get(&A); + //~^ WARN mutation of an interior mutable `const` item with call to `get` +} + +fn once_lock() { + static A: OnceLock = OnceLock::new(); + + let _a = A.get(); + //~^ WARN mutation of an interior mutable `const` item with call to `get` + + let _a = A.wait(); + //~^ WARN mutation of an interior mutable `const` item with call to `wait` + + let _a = A.set(10); + //~^ WARN mutation of an interior mutable `const` item with call to `set` + + let _a = A.try_insert(20); + //~^ WARN mutation of an interior mutable `const` item with call to `try_insert` + + let _a = A.get_or_init(|| 30); + //~^ WARN mutation of an interior mutable `const` item with call to `get_or_init` + + let _a = A.get_or_try_init(|| Ok::<_, ()>(40)); + //~^ WARN mutation of an interior mutable `const` item with call to `get_or_try_init` +} + +fn condvar() { + static A: Condvar = Condvar::new(); + + let mutex = Mutex::new(0); + let guard = mutex.lock().unwrap(); + + let _a = A.wait(guard); + //~^ WARN mutation of an interior mutable `const` item with call to `wait` + + let mutex = Mutex::new(0); + let guard = mutex.lock().unwrap(); + let _a = A.wait_while(guard, |x| *x == 0); + //~^ WARN mutation of an interior mutable `const` item with call to `wait_while` + + let mutex = Mutex::new(0); + let guard = mutex.lock().unwrap(); + let _a = A.wait_timeout_ms(guard, 10); + //~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout_ms` + + let mutex = Mutex::new(0); + let guard = mutex.lock().unwrap(); + let _a = A.wait_timeout(guard, Duration::from_millis(10)); + //~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout` + + let mutex = Mutex::new(0); + let guard = mutex.lock().unwrap(); + let _a = A.wait_timeout_while(guard, Duration::from_millis(10), |x| *x == 0); + //~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout_while` + + let _a = A.notify_one(); + //~^ WARN mutation of an interior mutable `const` item with call to `notify_one` + + let _a = A.notify_all(); + //~^ WARN mutation of an interior mutable `const` item with call to `notify_all` +} + +fn main() {} diff --git a/tests/ui/lint/const-item-interior-mutations-const.rs b/tests/ui/lint/const-item-interior-mutations-const.rs new file mode 100644 index 000000000000..5dbbfd8ca32f --- /dev/null +++ b/tests/ui/lint/const-item-interior-mutations-const.rs @@ -0,0 +1,139 @@ +//@ check-pass +//@ run-rustfix + +#![allow(deprecated)] +#![allow(dead_code)] +#![feature(lock_value_accessors)] +#![feature(once_cell_try_insert)] +#![feature(once_cell_try)] +#![feature(lazy_get)] + +use std::sync::{Condvar, LazyLock, Mutex, Once, OnceLock, RwLock}; +use std::time::Duration; + +fn mutex() { + const A: Mutex = Mutex::new(0); + + let _a = A.set(1); + //~^ WARN mutation of an interior mutable `const` item with call to `set` + + let _a = A.replace(2); + //~^ WARN mutation of an interior mutable `const` item with call to `replace` + + drop(A.lock()); + //~^ WARN mutation of an interior mutable `const` item with call to `lock` + + drop(A.try_lock()); + //~^ WARN mutation of an interior mutable `const` item with call to `try_lock` + + let _a = A.clear_poison(); + //~^ WARN mutation of an interior mutable `const` item with call to `clear_poison` +} + +fn once() { + const A: Once = Once::new(); + + let _a = A.call_once(|| {}); + //~^ WARN mutation of an interior mutable `const` item with call to `call_once` + + let _a = A.call_once_force(|_| {}); + //~^ WARN mutation of an interior mutable `const` item with call to `call_once_force` + + let _a = A.wait(); + //~^ WARN mutation of an interior mutable `const` item with call to `wait` + + let _a = A.wait_force(); + //~^ WARN mutation of an interior mutable `const` item with call to `wait_force` +} + +fn rwlock() { + const A: RwLock = RwLock::new(0); + + let _a = A.set(1); + //~^ WARN mutation of an interior mutable `const` item with call to `set` + + let _a = A.replace(2); + //~^ WARN mutation of an interior mutable `const` item with call to `replace` + + drop(A.read()); + //~^ WARN mutation of an interior mutable `const` item with call to `read` + + drop(A.try_read()); + //~^ WARN mutation of an interior mutable `const` item with call to `try_read` + + drop(A.write()); + //~^ WARN mutation of an interior mutable `const` item with call to `write` + + drop(A.try_write()); + //~^ WARN mutation of an interior mutable `const` item with call to `try_write` +} + +fn lazy_lock() { + const A: LazyLock = LazyLock::new(|| 0); + + let _a = LazyLock::force(&A); + //~^ WARN mutation of an interior mutable `const` item with call to `force` + + let _a = LazyLock::get(&A); + //~^ WARN mutation of an interior mutable `const` item with call to `get` +} + +fn once_lock() { + const A: OnceLock = OnceLock::new(); + + let _a = A.get(); + //~^ WARN mutation of an interior mutable `const` item with call to `get` + + let _a = A.wait(); + //~^ WARN mutation of an interior mutable `const` item with call to `wait` + + let _a = A.set(10); + //~^ WARN mutation of an interior mutable `const` item with call to `set` + + let _a = A.try_insert(20); + //~^ WARN mutation of an interior mutable `const` item with call to `try_insert` + + let _a = A.get_or_init(|| 30); + //~^ WARN mutation of an interior mutable `const` item with call to `get_or_init` + + let _a = A.get_or_try_init(|| Ok::<_, ()>(40)); + //~^ WARN mutation of an interior mutable `const` item with call to `get_or_try_init` +} + +fn condvar() { + const A: Condvar = Condvar::new(); + + let mutex = Mutex::new(0); + let guard = mutex.lock().unwrap(); + + let _a = A.wait(guard); + //~^ WARN mutation of an interior mutable `const` item with call to `wait` + + let mutex = Mutex::new(0); + let guard = mutex.lock().unwrap(); + let _a = A.wait_while(guard, |x| *x == 0); + //~^ WARN mutation of an interior mutable `const` item with call to `wait_while` + + let mutex = Mutex::new(0); + let guard = mutex.lock().unwrap(); + let _a = A.wait_timeout_ms(guard, 10); + //~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout_ms` + + let mutex = Mutex::new(0); + let guard = mutex.lock().unwrap(); + let _a = A.wait_timeout(guard, Duration::from_millis(10)); + //~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout` + + let mutex = Mutex::new(0); + let guard = mutex.lock().unwrap(); + let _a = A.wait_timeout_while(guard, Duration::from_millis(10), |x| *x == 0); + //~^ WARN mutation of an interior mutable `const` item with call to `wait_timeout_while` + + let _a = A.notify_one(); + //~^ WARN mutation of an interior mutable `const` item with call to `notify_one` + + let _a = A.notify_all(); + //~^ WARN mutation of an interior mutable `const` item with call to `notify_all` +} + +fn main() {} diff --git a/tests/ui/lint/const-item-interior-mutations-const.stderr b/tests/ui/lint/const-item-interior-mutations-const.stderr new file mode 100644 index 000000000000..7d3e7bee7fbb --- /dev/null +++ b/tests/ui/lint/const-item-interior-mutations-const.stderr @@ -0,0 +1,513 @@ +warning: mutation of an interior mutable `const` item with call to `set` + --> $DIR/const-item-interior-mutations-const.rs:17:14 + | +LL | let _a = A.set(1); + | -^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see + = note: `#[warn(const_item_interior_mutations)]` on by default +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Mutex = Mutex::new(0); +LL + static A: Mutex = Mutex::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `replace` + --> $DIR/const-item-interior-mutations-const.rs:20:14 + | +LL | let _a = A.replace(2); + | -^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Mutex = Mutex::new(0); +LL + static A: Mutex = Mutex::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `lock` + --> $DIR/const-item-interior-mutations-const.rs:23:10 + | +LL | drop(A.lock()); + | -^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Mutex = Mutex::new(0); +LL + static A: Mutex = Mutex::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `try_lock` + --> $DIR/const-item-interior-mutations-const.rs:26:10 + | +LL | drop(A.try_lock()); + | -^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Mutex = Mutex::new(0); +LL + static A: Mutex = Mutex::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `clear_poison` + --> $DIR/const-item-interior-mutations-const.rs:29:14 + | +LL | let _a = A.clear_poison(); + | -^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Mutex` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Mutex = Mutex::new(0); +LL + static A: Mutex = Mutex::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `call_once` + --> $DIR/const-item-interior-mutations-const.rs:36:14 + | +LL | let _a = A.call_once(|| {}); + | -^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Once` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Once = Once::new(); +LL + static A: Once = Once::new(); + | + +warning: mutation of an interior mutable `const` item with call to `call_once_force` + --> $DIR/const-item-interior-mutations-const.rs:39:14 + | +LL | let _a = A.call_once_force(|_| {}); + | -^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Once` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Once = Once::new(); +LL + static A: Once = Once::new(); + | + +warning: mutation of an interior mutable `const` item with call to `wait` + --> $DIR/const-item-interior-mutations-const.rs:42:14 + | +LL | let _a = A.wait(); + | -^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Once` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Once = Once::new(); +LL + static A: Once = Once::new(); + | + +warning: mutation of an interior mutable `const` item with call to `wait_force` + --> $DIR/const-item-interior-mutations-const.rs:45:14 + | +LL | let _a = A.wait_force(); + | -^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Once` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Once = Once::new(); +LL + static A: Once = Once::new(); + | + +warning: mutation of an interior mutable `const` item with call to `set` + --> $DIR/const-item-interior-mutations-const.rs:52:14 + | +LL | let _a = A.set(1); + | -^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RwLock = RwLock::new(0); +LL + static A: RwLock = RwLock::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `replace` + --> $DIR/const-item-interior-mutations-const.rs:55:14 + | +LL | let _a = A.replace(2); + | -^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RwLock = RwLock::new(0); +LL + static A: RwLock = RwLock::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `read` + --> $DIR/const-item-interior-mutations-const.rs:58:10 + | +LL | drop(A.read()); + | -^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RwLock = RwLock::new(0); +LL + static A: RwLock = RwLock::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `try_read` + --> $DIR/const-item-interior-mutations-const.rs:61:10 + | +LL | drop(A.try_read()); + | -^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RwLock = RwLock::new(0); +LL + static A: RwLock = RwLock::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `write` + --> $DIR/const-item-interior-mutations-const.rs:64:10 + | +LL | drop(A.write()); + | -^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RwLock = RwLock::new(0); +LL + static A: RwLock = RwLock::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `try_write` + --> $DIR/const-item-interior-mutations-const.rs:67:10 + | +LL | drop(A.try_write()); + | -^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::RwLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: RwLock = RwLock::new(0); +LL + static A: RwLock = RwLock::new(0); + | + +warning: mutation of an interior mutable `const` item with call to `force` + --> $DIR/const-item-interior-mutations-const.rs:74:14 + | +LL | let _a = LazyLock::force(&A); + | ^^^^^^^^^^^^^^^^^-^ + | | + | `A` is a interior mutable `const` item of type `LazyLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: LazyLock = LazyLock::new(|| 0); +LL + static A: LazyLock = LazyLock::new(|| 0); + | + +warning: mutation of an interior mutable `const` item with call to `get` + --> $DIR/const-item-interior-mutations-const.rs:77:14 + | +LL | let _a = LazyLock::get(&A); + | ^^^^^^^^^^^^^^^-^ + | | + | `A` is a interior mutable `const` item of type `LazyLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: LazyLock = LazyLock::new(|| 0); +LL + static A: LazyLock = LazyLock::new(|| 0); + | + +warning: mutation of an interior mutable `const` item with call to `get` + --> $DIR/const-item-interior-mutations-const.rs:84:14 + | +LL | let _a = A.get(); + | -^^^^^^ + | | + | `A` is a interior mutable `const` item of type `OnceLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: OnceLock = OnceLock::new(); +LL + static A: OnceLock = OnceLock::new(); + | + +warning: mutation of an interior mutable `const` item with call to `wait` + --> $DIR/const-item-interior-mutations-const.rs:87:14 + | +LL | let _a = A.wait(); + | -^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `OnceLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: OnceLock = OnceLock::new(); +LL + static A: OnceLock = OnceLock::new(); + | + +warning: mutation of an interior mutable `const` item with call to `set` + --> $DIR/const-item-interior-mutations-const.rs:90:14 + | +LL | let _a = A.set(10); + | -^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `OnceLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: OnceLock = OnceLock::new(); +LL + static A: OnceLock = OnceLock::new(); + | + +warning: mutation of an interior mutable `const` item with call to `try_insert` + --> $DIR/const-item-interior-mutations-const.rs:93:14 + | +LL | let _a = A.try_insert(20); + | -^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `OnceLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: OnceLock = OnceLock::new(); +LL + static A: OnceLock = OnceLock::new(); + | + +warning: mutation of an interior mutable `const` item with call to `get_or_init` + --> $DIR/const-item-interior-mutations-const.rs:96:14 + | +LL | let _a = A.get_or_init(|| 30); + | -^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `OnceLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: OnceLock = OnceLock::new(); +LL + static A: OnceLock = OnceLock::new(); + | + +warning: mutation of an interior mutable `const` item with call to `get_or_try_init` + --> $DIR/const-item-interior-mutations-const.rs:99:14 + | +LL | let _a = A.get_or_try_init(|| Ok::<_, ()>(40)); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `OnceLock` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: OnceLock = OnceLock::new(); +LL + static A: OnceLock = OnceLock::new(); + | + +warning: mutation of an interior mutable `const` item with call to `wait` + --> $DIR/const-item-interior-mutations-const.rs:109:14 + | +LL | let _a = A.wait(guard); + | -^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Condvar = Condvar::new(); +LL + static A: Condvar = Condvar::new(); + | + +warning: mutation of an interior mutable `const` item with call to `wait_while` + --> $DIR/const-item-interior-mutations-const.rs:114:14 + | +LL | let _a = A.wait_while(guard, |x| *x == 0); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Condvar = Condvar::new(); +LL + static A: Condvar = Condvar::new(); + | + +warning: mutation of an interior mutable `const` item with call to `wait_timeout_ms` + --> $DIR/const-item-interior-mutations-const.rs:119:14 + | +LL | let _a = A.wait_timeout_ms(guard, 10); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Condvar = Condvar::new(); +LL + static A: Condvar = Condvar::new(); + | + +warning: mutation of an interior mutable `const` item with call to `wait_timeout` + --> $DIR/const-item-interior-mutations-const.rs:124:14 + | +LL | let _a = A.wait_timeout(guard, Duration::from_millis(10)); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Condvar = Condvar::new(); +LL + static A: Condvar = Condvar::new(); + | + +warning: mutation of an interior mutable `const` item with call to `wait_timeout_while` + --> $DIR/const-item-interior-mutations-const.rs:129:14 + | +LL | let _a = A.wait_timeout_while(guard, Duration::from_millis(10), |x| *x == 0); + | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Condvar = Condvar::new(); +LL + static A: Condvar = Condvar::new(); + | + +warning: mutation of an interior mutable `const` item with call to `notify_one` + --> $DIR/const-item-interior-mutations-const.rs:132:14 + | +LL | let _a = A.notify_one(); + | -^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Condvar = Condvar::new(); +LL + static A: Condvar = Condvar::new(); + | + +warning: mutation of an interior mutable `const` item with call to `notify_all` + --> $DIR/const-item-interior-mutations-const.rs:135:14 + | +LL | let _a = A.notify_all(); + | -^^^^^^^^^^^^^ + | | + | `A` is a interior mutable `const` item of type `std::sync::Condvar` + | + = note: each usage of a `const` item creates a new temporary + = note: only the temporaries and never the original `const A` will be modified + = help: for more details on interior mutability see +help: for a shared instance of `A`, consider making it a `static` item instead + | +LL - const A: Condvar = Condvar::new(); +LL + static A: Condvar = Condvar::new(); + | + +warning: 30 warnings emitted + From ddabb1c13973b85a6a8475f9b98394d12e9211dc Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 2 Nov 2025 16:57:29 +0100 Subject: [PATCH 136/194] Allow `const_item_interior_mutations` in Clippy tests --- .../tests/ui/borrow_interior_mutable_const.rs | 1 + .../ui/borrow_interior_mutable_const.stderr | 58 +++++++++---------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/tools/clippy/tests/ui/borrow_interior_mutable_const.rs b/src/tools/clippy/tests/ui/borrow_interior_mutable_const.rs index 674450a73ad2..39d6e76d5d00 100644 --- a/src/tools/clippy/tests/ui/borrow_interior_mutable_const.rs +++ b/src/tools/clippy/tests/ui/borrow_interior_mutable_const.rs @@ -4,6 +4,7 @@ #![allow( clippy::declare_interior_mutable_const, clippy::out_of_bounds_indexing, + const_item_interior_mutations, const_item_mutation, unconditional_panic )] diff --git a/src/tools/clippy/tests/ui/borrow_interior_mutable_const.stderr b/src/tools/clippy/tests/ui/borrow_interior_mutable_const.stderr index e7c3f879b05b..b3b1eb858e47 100644 --- a/src/tools/clippy/tests/ui/borrow_interior_mutable_const.stderr +++ b/src/tools/clippy/tests/ui/borrow_interior_mutable_const.stderr @@ -1,5 +1,5 @@ error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:35:17 + --> tests/ui/borrow_interior_mutable_const.rs:36:17 | LL | let _ = &C; | ^^ @@ -12,7 +12,7 @@ LL | #![deny(clippy::borrow_interior_mutable_const)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:37:17 + --> tests/ui/borrow_interior_mutable_const.rs:38:17 | LL | let _ = C.get(); | ^ @@ -21,7 +21,7 @@ LL | let _ = C.get(); = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:42:17 + --> tests/ui/borrow_interior_mutable_const.rs:43:17 | LL | let _ = &C; | ^^ @@ -29,7 +29,7 @@ LL | let _ = &C; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:43:17 + --> tests/ui/borrow_interior_mutable_const.rs:44:17 | LL | let _ = &mut C; | ^^^^^^ @@ -37,7 +37,7 @@ LL | let _ = &mut C; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:47:9 + --> tests/ui/borrow_interior_mutable_const.rs:48:9 | LL | C.swap(&local) | ^ @@ -46,7 +46,7 @@ LL | C.swap(&local) = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:52:17 + --> tests/ui/borrow_interior_mutable_const.rs:53:17 | LL | let _ = &C; | ^^ @@ -54,7 +54,7 @@ LL | let _ = &C; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:53:17 + --> tests/ui/borrow_interior_mutable_const.rs:54:17 | LL | let _ = &C[0]; | ^^^^^ @@ -62,7 +62,7 @@ LL | let _ = &C[0]; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:54:17 + --> tests/ui/borrow_interior_mutable_const.rs:55:17 | LL | let _ = &C[0].0; | ^^^^^^^ @@ -70,7 +70,7 @@ LL | let _ = &C[0].0; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:55:9 + --> tests/ui/borrow_interior_mutable_const.rs:56:9 | LL | C[0].0.set(1); | ^^^^^^ @@ -79,7 +79,7 @@ LL | C[0].0.set(1); = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:70:17 + --> tests/ui/borrow_interior_mutable_const.rs:71:17 | LL | let _ = &S::C; | ^^^^^ @@ -87,7 +87,7 @@ LL | let _ = &S::C; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:71:17 + --> tests/ui/borrow_interior_mutable_const.rs:72:17 | LL | let _ = &S::C.0; | ^^^^^^^ @@ -95,7 +95,7 @@ LL | let _ = &S::C.0; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:72:9 + --> tests/ui/borrow_interior_mutable_const.rs:73:9 | LL | S::C.set(1); | ^^^^ @@ -104,7 +104,7 @@ LL | S::C.set(1); = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:73:18 + --> tests/ui/borrow_interior_mutable_const.rs:74:18 | LL | let _ = &*S::C; | ^^^^^ @@ -113,7 +113,7 @@ LL | let _ = &*S::C; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:74:9 + --> tests/ui/borrow_interior_mutable_const.rs:75:9 | LL | (*S::C).set(1); | ^^^^^^^ @@ -122,7 +122,7 @@ LL | (*S::C).set(1); = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:85:17 + --> tests/ui/borrow_interior_mutable_const.rs:86:17 | LL | let _ = &CELL; | ^^^^^ @@ -130,7 +130,7 @@ LL | let _ = &CELL; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:109:25 + --> tests/ui/borrow_interior_mutable_const.rs:110:25 | LL | let _ = &Self::C; | ^^^^^^^^ @@ -138,7 +138,7 @@ LL | let _ = &Self::C; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:112:25 + --> tests/ui/borrow_interior_mutable_const.rs:113:25 | LL | let _ = &Self::C.cell; | ^^^^^^^^^^^^^ @@ -146,7 +146,7 @@ LL | let _ = &Self::C.cell; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:113:25 + --> tests/ui/borrow_interior_mutable_const.rs:114:25 | LL | let _ = &Self::C.cell.0; | ^^^^^^^^^^^^^^^ @@ -154,7 +154,7 @@ LL | let _ = &Self::C.cell.0; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:114:17 + --> tests/ui/borrow_interior_mutable_const.rs:115:17 | LL | Self::C.cell.0.set(T::DEFAULT); | ^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ LL | Self::C.cell.0.set(T::DEFAULT); = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:128:17 + --> tests/ui/borrow_interior_mutable_const.rs:129:17 | LL | let _ = &u32::VALUE; | ^^^^^^^^^^^ @@ -171,7 +171,7 @@ LL | let _ = &u32::VALUE; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:145:21 + --> tests/ui/borrow_interior_mutable_const.rs:146:21 | LL | let _ = &>::VALUE; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -179,7 +179,7 @@ LL | let _ = &>::VALUE; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:172:17 + --> tests/ui/borrow_interior_mutable_const.rs:173:17 | LL | let _ = &C; | ^^ @@ -187,7 +187,7 @@ LL | let _ = &C; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:173:18 + --> tests/ui/borrow_interior_mutable_const.rs:174:18 | LL | let _ = &C[0]; | ^^^^ @@ -196,7 +196,7 @@ LL | let _ = &C[0]; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:174:17 + --> tests/ui/borrow_interior_mutable_const.rs:175:17 | LL | let _ = &C.0[0]; | ^^^^^^^ @@ -204,7 +204,7 @@ LL | let _ = &C.0[0]; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:190:17 + --> tests/ui/borrow_interior_mutable_const.rs:191:17 | LL | let _ = &C[1]; | ^^^^^ @@ -212,7 +212,7 @@ LL | let _ = &C[1]; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:194:21 + --> tests/ui/borrow_interior_mutable_const.rs:195:21 | LL | let _ = &C[i]; | ^^^^^ @@ -220,7 +220,7 @@ LL | let _ = &C[i]; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:198:17 + --> tests/ui/borrow_interior_mutable_const.rs:199:17 | LL | let _ = &interior_mutable_const::WRAPPED_PRIVATE_UNFROZEN_VARIANT; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -228,7 +228,7 @@ LL | let _ = &interior_mutable_const::WRAPPED_PRIVATE_UNFROZEN_VARIANT; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:216:17 + --> tests/ui/borrow_interior_mutable_const.rs:217:17 | LL | let _ = &S::VALUE; | ^^^^^^^^^ @@ -236,7 +236,7 @@ LL | let _ = &S::VALUE; = help: this lint can be silenced by assigning the value to a local variable before borrowing error: borrow of a named constant with interior mutability - --> tests/ui/borrow_interior_mutable_const.rs:218:17 + --> tests/ui/borrow_interior_mutable_const.rs:219:17 | LL | let _ = &S::VALUE.1; | ^^^^^^^^^^^ From c48dce11871a5cfe2c0475ea35c5086436d5f32e Mon Sep 17 00:00:00 2001 From: Urgau Date: Sun, 2 Nov 2025 18:13:14 +0100 Subject: [PATCH 137/194] Allow `const_item_interior_mutations` in tests --- tests/ui/consts/issue-17718.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/ui/consts/issue-17718.rs b/tests/ui/consts/issue-17718.rs index b6c676886c10..33e2d791840e 100644 --- a/tests/ui/consts/issue-17718.rs +++ b/tests/ui/consts/issue-17718.rs @@ -1,7 +1,9 @@ //@ run-pass -#![allow(dead_code)] //@ aux-build:issue-17718-aux.rs +#![allow(dead_code)] +#![allow(const_item_interior_mutations)] + extern crate issue_17718_aux as other; use std::sync::atomic::{AtomicUsize, Ordering}; From f23675f7f3e7b61aadef33c2c35af9c17cb3bc18 Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Wed, 12 Nov 2025 10:14:59 +0100 Subject: [PATCH 138/194] Add sub-fn for unsatisfied ty or trait in FnCtxt::report_no_match_method_error Currently this method is quiet long and complex, this commit refactors it and improves its readability by adding sub-fn --- .../rustc_hir_typeck/src/method/suggest.rs | 222 +++++++++++------- 1 file changed, 132 insertions(+), 90 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index bc7e3ca4805c..1364e07ef03c 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -772,6 +772,120 @@ fn suggest_static_method_candidates( static_candidates } + fn suggest_unsatisfied_ty_or_trait( + &self, + err: &mut Diag<'_>, + span: Span, + rcvr_ty: Ty<'tcx>, + item_ident: Ident, + item_kind: &str, + source: SelfSource<'tcx>, + unsatisfied_predicates: &UnsatisfiedPredicates<'tcx>, + static_candidates: &[CandidateSource], + ) -> Result<(bool, bool, bool, bool, SortedMap>), ()> { + let mut restrict_type_params = false; + let mut suggested_derive = false; + let mut unsatisfied_bounds = false; + let mut custom_span_label = !static_candidates.is_empty(); + let mut bound_spans: SortedMap> = Default::default(); + let tcx = self.tcx; + + if item_ident.name == sym::count && self.is_slice_ty(rcvr_ty, span) { + let msg = "consider using `len` instead"; + if let SelfSource::MethodCall(_expr) = source { + err.span_suggestion_short(span, msg, "len", Applicability::MachineApplicable); + } else { + err.span_label(span, msg); + } + if let Some(iterator_trait) = self.tcx.get_diagnostic_item(sym::Iterator) { + let iterator_trait = self.tcx.def_path_str(iterator_trait); + err.note(format!( + "`count` is defined on `{iterator_trait}`, which `{rcvr_ty}` does not implement" + )); + } + } else if self.impl_into_iterator_should_be_iterator(rcvr_ty, span, unsatisfied_predicates) + { + err.span_label(span, format!("`{rcvr_ty}` is not an iterator")); + if !span.in_external_macro(self.tcx.sess.source_map()) { + err.multipart_suggestion_verbose( + "call `.into_iter()` first", + vec![(span.shrink_to_lo(), format!("into_iter()."))], + Applicability::MaybeIncorrect, + ); + } + // Report to emit the diagnostic + return Err(()); + } else if !unsatisfied_predicates.is_empty() { + if matches!(rcvr_ty.kind(), ty::Param(_)) { + // We special case the situation where we are looking for `_` in + // `::method` because otherwise the machinery will look for blanket + // implementations that have unsatisfied trait bounds to suggest, leading us to claim + // things like "we're looking for a trait with method `cmp`, both `Iterator` and `Ord` + // have one, in order to implement `Ord` you need to restrict `TypeParam: FnPtr` so + // that `impl Ord for T` can apply", which is not what we want. We have a type + // parameter, we want to directly say "`Ord::cmp` and `Iterator::cmp` exist, restrict + // `TypeParam: Ord` or `TypeParam: Iterator`"". That is done further down when calling + // `self.suggest_traits_to_import`, so we ignore the `unsatisfied_predicates` + // suggestions. + } else { + self.handle_unsatisfied_predicates( + err, + rcvr_ty, + item_ident, + item_kind, + span, + unsatisfied_predicates, + &mut restrict_type_params, + &mut suggested_derive, + &mut unsatisfied_bounds, + &mut custom_span_label, + &mut bound_spans, + ); + } + } else if let ty::Adt(def, targs) = rcvr_ty.kind() + && let SelfSource::MethodCall(rcvr_expr) = source + { + // This is useful for methods on arbitrary self types that might have a simple + // mutability difference, like calling a method on `Pin<&mut Self>` that is on + // `Pin<&Self>`. + if targs.len() == 1 { + let mut item_segment = hir::PathSegment::invalid(); + item_segment.ident = item_ident; + for t in [Ty::new_mut_ref, Ty::new_imm_ref, |_, _, t| t] { + let new_args = + tcx.mk_args_from_iter(targs.iter().map(|arg| match arg.as_type() { + Some(ty) => ty::GenericArg::from(t( + tcx, + tcx.lifetimes.re_erased, + ty.peel_refs(), + )), + _ => arg, + })); + let rcvr_ty = Ty::new_adt(tcx, *def, new_args); + if let Ok(method) = self.lookup_method_for_diagnostic( + rcvr_ty, + &item_segment, + span, + tcx.parent_hir_node(rcvr_expr.hir_id).expect_expr(), + rcvr_expr, + ) { + err.span_note( + tcx.def_span(method.def_id), + format!("{item_kind} is available for `{rcvr_ty}`"), + ); + } + } + } + } + Ok(( + restrict_type_params, + suggested_derive, + unsatisfied_bounds, + custom_span_label, + bound_spans, + )) + } + fn report_no_match_method_error( &self, mut span: Span, @@ -874,12 +988,7 @@ fn report_no_match_method_error( sugg_span, &no_match_data, ); - let mut custom_span_label = !static_candidates.is_empty(); - let mut bound_spans: SortedMap> = Default::default(); - let mut restrict_type_params = false; - let mut suggested_derive = false; - let mut unsatisfied_bounds = false; let mut ty_span = match rcvr_ty.kind() { ty::Param(param_type) => { Some(param_type.span_from_generics(self.tcx, self.body_id.to_def_id())) @@ -888,92 +997,25 @@ fn report_no_match_method_error( _ => None, }; - if item_ident.name == sym::count && self.is_slice_ty(rcvr_ty, span) { - let msg = "consider using `len` instead"; - if let SelfSource::MethodCall(_expr) = source { - err.span_suggestion_short(span, msg, "len", Applicability::MachineApplicable); - } else { - err.span_label(span, msg); - } - if let Some(iterator_trait) = self.tcx.get_diagnostic_item(sym::Iterator) { - let iterator_trait = self.tcx.def_path_str(iterator_trait); - err.note(format!( - "`count` is defined on `{iterator_trait}`, which `{rcvr_ty}` does not implement" - )); - } - } else if self.impl_into_iterator_should_be_iterator(rcvr_ty, span, unsatisfied_predicates) - { - err.span_label(span, format!("`{rcvr_ty}` is not an iterator")); - if !span.in_external_macro(self.tcx.sess.source_map()) { - err.multipart_suggestion_verbose( - "call `.into_iter()` first", - vec![(span.shrink_to_lo(), format!("into_iter()."))], - Applicability::MaybeIncorrect, - ); - } + let Ok(( + restrict_type_params, + suggested_derive, + unsatisfied_bounds, + custom_span_label, + bound_spans, + )) = self.suggest_unsatisfied_ty_or_trait( + &mut err, + span, + rcvr_ty, + item_ident, + item_kind, + source, + unsatisfied_predicates, + &static_candidates, + ) + else { return err.emit(); - } else if !unsatisfied_predicates.is_empty() { - if matches!(rcvr_ty.kind(), ty::Param(_)) { - // We special case the situation where we are looking for `_` in - // `::method` because otherwise the machinery will look for blanket - // implementations that have unsatisfied trait bounds to suggest, leading us to claim - // things like "we're looking for a trait with method `cmp`, both `Iterator` and `Ord` - // have one, in order to implement `Ord` you need to restrict `TypeParam: FnPtr` so - // that `impl Ord for T` can apply", which is not what we want. We have a type - // parameter, we want to directly say "`Ord::cmp` and `Iterator::cmp` exist, restrict - // `TypeParam: Ord` or `TypeParam: Iterator`"". That is done further down when calling - // `self.suggest_traits_to_import`, so we ignore the `unsatisfied_predicates` - // suggestions. - } else { - self.handle_unsatisfied_predicates( - &mut err, - rcvr_ty, - item_ident, - item_kind, - span, - unsatisfied_predicates, - &mut restrict_type_params, - &mut suggested_derive, - &mut unsatisfied_bounds, - &mut custom_span_label, - &mut bound_spans, - ); - } - } else if let ty::Adt(def, targs) = rcvr_ty.kind() - && let SelfSource::MethodCall(rcvr_expr) = source - { - // This is useful for methods on arbitrary self types that might have a simple - // mutability difference, like calling a method on `Pin<&mut Self>` that is on - // `Pin<&Self>`. - if targs.len() == 1 { - let mut item_segment = hir::PathSegment::invalid(); - item_segment.ident = item_ident; - for t in [Ty::new_mut_ref, Ty::new_imm_ref, |_, _, t| t] { - let new_args = - tcx.mk_args_from_iter(targs.iter().map(|arg| match arg.as_type() { - Some(ty) => ty::GenericArg::from(t( - tcx, - tcx.lifetimes.re_erased, - ty.peel_refs(), - )), - _ => arg, - })); - let rcvr_ty = Ty::new_adt(tcx, *def, new_args); - if let Ok(method) = self.lookup_method_for_diagnostic( - rcvr_ty, - &item_segment, - span, - tcx.parent_hir_node(rcvr_expr.hir_id).expect_expr(), - rcvr_expr, - ) { - err.span_note( - tcx.def_span(method.def_id), - format!("{item_kind} is available for `{rcvr_ty}`"), - ); - } - } - } - } + }; let mut find_candidate_for_method = false; let should_label_not_found = match source { From 56ce33f57a3e3d3012e1a3efc5c027319c134007 Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Wed, 12 Nov 2025 14:03:08 +0100 Subject: [PATCH 139/194] Add sub-fn for surround method calls in FnCtxt::report_no_match_method_error Currently this method is quiet long and complex, this commit refactors it and improves its readability by adding sub-fn --- .../rustc_hir_typeck/src/method/suggest.rs | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 1364e07ef03c..8fa951dbc480 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -886,6 +886,26 @@ fn suggest_unsatisfied_ty_or_trait( )) } + fn suggest_surround_method_call( + &self, + err: &mut Diag<'_>, + span: Span, + rcvr_ty: Ty<'tcx>, + item_ident: Ident, + source: SelfSource<'tcx>, + similar_candidate: &Option, + ) -> bool { + match source { + // If the method name is the name of a field with a function or closure type, + // give a helping note that it has to be called as `(x.f)(...)`. + SelfSource::MethodCall(expr) => { + !self.suggest_calling_field_as_fn(span, rcvr_ty, expr, item_ident, err) + && similar_candidate.is_none() + } + _ => true, + } + } + fn report_no_match_method_error( &self, mut span: Span, @@ -1018,15 +1038,14 @@ fn report_no_match_method_error( }; let mut find_candidate_for_method = false; - let should_label_not_found = match source { - // If the method name is the name of a field with a function or closure type, - // give a helping note that it has to be called as `(x.f)(...)`. - SelfSource::MethodCall(expr) => { - !self.suggest_calling_field_as_fn(span, rcvr_ty, expr, item_ident, &mut err) - && similar_candidate.is_none() - } - _ => true, - }; + let should_label_not_found = self.suggest_surround_method_call( + &mut err, + span, + rcvr_ty, + item_ident, + source, + &similar_candidate, + ); if should_label_not_found && !custom_span_label { self.set_not_found_span_label( From d7a8f6bc08a204959eb98272defb68f773eb935a Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Wed, 12 Nov 2025 14:21:16 +0100 Subject: [PATCH 140/194] Add sub-fn to find possible candidates for method in FnCtxt::report_no_match_method_error Currently this method is quiet long and complex, this commit refactors it and improves its readability by adding sub-fn --- .../rustc_hir_typeck/src/method/suggest.rs | 103 ++++++++++++------ 1 file changed, 67 insertions(+), 36 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 8fa951dbc480..6f7eaa73907d 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -906,6 +906,60 @@ fn suggest_surround_method_call( } } + fn find_possible_candidates_for_method( + &self, + err: &mut Diag<'_>, + span: Span, + rcvr_ty: Ty<'tcx>, + item_ident: Ident, + item_kind: &str, + mode: Mode, + source: SelfSource<'tcx>, + no_match_data: &NoMatchData<'tcx>, + expected: Expectation<'tcx>, + should_label_not_found: bool, + custom_span_label: bool, + ) { + let mut find_candidate_for_method = false; + let unsatisfied_predicates = &no_match_data.unsatisfied_predicates; + + if should_label_not_found && !custom_span_label { + self.set_not_found_span_label( + err, + rcvr_ty, + item_ident, + item_kind, + mode, + source, + span, + unsatisfied_predicates, + &mut find_candidate_for_method, + ); + } + if !find_candidate_for_method { + self.lookup_segments_chain_for_no_match_method( + err, + item_ident, + item_kind, + source, + no_match_data, + ); + } + + // Don't suggest (for example) `expr.field.clone()` if `expr.clone()` + // can't be called due to `typeof(expr): Clone` not holding. + if unsatisfied_predicates.is_empty() { + self.suggest_calling_method_on_field( + err, + source, + span, + rcvr_ty, + item_ident, + expected.only_has_type(self), + ); + } + } + fn report_no_match_method_error( &self, mut span: Span, @@ -1037,7 +1091,6 @@ fn report_no_match_method_error( return err.emit(); }; - let mut find_candidate_for_method = false; let should_label_not_found = self.suggest_surround_method_call( &mut err, span, @@ -1047,41 +1100,19 @@ fn report_no_match_method_error( &similar_candidate, ); - if should_label_not_found && !custom_span_label { - self.set_not_found_span_label( - &mut err, - rcvr_ty, - item_ident, - item_kind, - mode, - source, - span, - unsatisfied_predicates, - &mut find_candidate_for_method, - ); - } - if !find_candidate_for_method { - self.lookup_segments_chain_for_no_match_method( - &mut err, - item_ident, - item_kind, - source, - no_match_data, - ); - } - - // Don't suggest (for example) `expr.field.clone()` if `expr.clone()` - // can't be called due to `typeof(expr): Clone` not holding. - if unsatisfied_predicates.is_empty() { - self.suggest_calling_method_on_field( - &mut err, - source, - span, - rcvr_ty, - item_ident, - expected.only_has_type(self), - ); - } + self.find_possible_candidates_for_method( + &mut err, + span, + rcvr_ty, + item_ident, + item_kind, + mode, + source, + no_match_data, + expected, + should_label_not_found, + custom_span_label, + ); self.suggest_unwrapping_inner_self(&mut err, source, rcvr_ty, item_ident); From a33555b6f52582b1fe68488ef6f71192e098fb64 Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Wed, 12 Nov 2025 14:34:10 +0100 Subject: [PATCH 141/194] Add sub-fn for confusable or similarly named methods in FnCtxt::report_no_match_method_error Currently this method is quiet long and complex, this commit refactors it and improves its readability by adding sub-fn --- .../rustc_hir_typeck/src/method/suggest.rs | 70 ++++++++++++------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 6f7eaa73907d..88cd5a320da3 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -960,6 +960,43 @@ fn find_possible_candidates_for_method( } } + fn suggest_confusable_or_similarly_named_method( + &self, + err: &mut Diag<'_>, + span: Span, + rcvr_ty: Ty<'tcx>, + item_ident: Ident, + mode: Mode, + args: Option<&'tcx [hir::Expr<'tcx>]>, + unsatisfied_predicates: &UnsatisfiedPredicates<'tcx>, + similar_candidate: Option, + ) { + let confusable_suggested = self.confusable_method_name( + err, + rcvr_ty, + item_ident, + args.map(|args| { + args.iter() + .map(|expr| { + self.node_ty_opt(expr.hir_id).unwrap_or_else(|| self.next_ty_var(expr.span)) + }) + .collect() + }), + ); + if let Some(similar_candidate) = similar_candidate { + // Don't emit a suggestion if we found an actual method + // that had unsatisfied trait bounds + if unsatisfied_predicates.is_empty() + // ...or if we already suggested that name because of `rustc_confusable` annotation + && Some(similar_candidate.name()) != confusable_suggested + // and if we aren't in an expansion. + && !span.from_expansion() + { + self.find_likely_intended_associated_item(err, similar_candidate, span, args, mode); + } + } + } + fn report_no_match_method_error( &self, mut span: Span, @@ -1142,36 +1179,17 @@ fn report_no_match_method_error( source, unsatisfied_predicates, ); - let confusable_suggested = self.confusable_method_name( + + self.suggest_confusable_or_similarly_named_method( &mut err, + span, rcvr_ty, item_ident, - args.map(|args| { - args.iter() - .map(|expr| { - self.node_ty_opt(expr.hir_id).unwrap_or_else(|| self.next_ty_var(expr.span)) - }) - .collect() - }), + mode, + args, + unsatisfied_predicates, + similar_candidate, ); - if let Some(similar_candidate) = similar_candidate { - // Don't emit a suggestion if we found an actual method - // that had unsatisfied trait bounds - if unsatisfied_predicates.is_empty() - // ...or if we already suggested that name because of `rustc_confusable` annotation - && Some(similar_candidate.name()) != confusable_suggested - // and if we aren't in an expansion. - && !span.from_expansion() - { - self.find_likely_intended_associated_item( - &mut err, - similar_candidate, - span, - args, - mode, - ); - } - } for (span, mut bounds) in bound_spans { if !tcx.sess.source_map().is_span_accessible(span) { From ae2c070a356091bf96adbc55cf110d6c3c500c7e Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Wed, 12 Nov 2025 14:41:07 +0100 Subject: [PATCH 142/194] Add sub-fn for not found methods with unsatisfied bounds in FnCtxt::report_no_match_method_error Currently this method is quiet long and complex, this commit refactors it and improves its readability by adding sub-fn --- .../rustc_hir_typeck/src/method/suggest.rs | 100 ++++++++++-------- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 88cd5a320da3..72644e0c4c22 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -997,6 +997,57 @@ fn suggest_confusable_or_similarly_named_method( } } + fn suggest_method_not_found_because_of_unsatisfied_bounds( + &self, + err: &mut Diag<'_>, + rcvr_ty: Ty<'tcx>, + item_ident: Ident, + item_kind: &str, + bound_spans: SortedMap>, + ) { + let mut ty_span = match rcvr_ty.kind() { + ty::Param(param_type) => { + Some(param_type.span_from_generics(self.tcx, self.body_id.to_def_id())) + } + ty::Adt(def, _) if def.did().is_local() => Some(self.tcx.def_span(def.did())), + _ => None, + }; + for (span, mut bounds) in bound_spans { + if !self.tcx.sess.source_map().is_span_accessible(span) { + continue; + } + bounds.sort(); + bounds.dedup(); + let pre = if Some(span) == ty_span { + ty_span.take(); + format!( + "{item_kind} `{item_ident}` not found for this {} because it ", + rcvr_ty.prefix_string(self.tcx) + ) + } else { + String::new() + }; + let msg = match &bounds[..] { + [bound] => format!("{pre}doesn't satisfy {bound}"), + bounds if bounds.len() > 4 => format!("doesn't satisfy {} bounds", bounds.len()), + [bounds @ .., last] => { + format!("{pre}doesn't satisfy {} or {last}", bounds.join(", ")) + } + [] => unreachable!(), + }; + err.span_label(span, msg); + } + if let Some(span) = ty_span { + err.span_label( + span, + format!( + "{item_kind} `{item_ident}` not found for this {}", + rcvr_ty.prefix_string(self.tcx) + ), + ); + } + } + fn report_no_match_method_error( &self, mut span: Span, @@ -1100,14 +1151,6 @@ fn report_no_match_method_error( &no_match_data, ); - let mut ty_span = match rcvr_ty.kind() { - ty::Param(param_type) => { - Some(param_type.span_from_generics(self.tcx, self.body_id.to_def_id())) - } - ty::Adt(def, _) if def.did().is_local() => Some(tcx.def_span(def.did())), - _ => None, - }; - let Ok(( restrict_type_params, suggested_derive, @@ -1191,40 +1234,13 @@ fn report_no_match_method_error( similar_candidate, ); - for (span, mut bounds) in bound_spans { - if !tcx.sess.source_map().is_span_accessible(span) { - continue; - } - bounds.sort(); - bounds.dedup(); - let pre = if Some(span) == ty_span { - ty_span.take(); - format!( - "{item_kind} `{item_ident}` not found for this {} because it ", - rcvr_ty.prefix_string(self.tcx) - ) - } else { - String::new() - }; - let msg = match &bounds[..] { - [bound] => format!("{pre}doesn't satisfy {bound}"), - bounds if bounds.len() > 4 => format!("doesn't satisfy {} bounds", bounds.len()), - [bounds @ .., last] => { - format!("{pre}doesn't satisfy {} or {last}", bounds.join(", ")) - } - [] => unreachable!(), - }; - err.span_label(span, msg); - } - if let Some(span) = ty_span { - err.span_label( - span, - format!( - "{item_kind} `{item_ident}` not found for this {}", - rcvr_ty.prefix_string(self.tcx) - ), - ); - } + self.suggest_method_not_found_because_of_unsatisfied_bounds( + &mut err, + rcvr_ty, + item_ident, + item_kind, + bound_spans, + ); self.note_derefed_ty_has_method(&mut err, source, rcvr_ty, item_ident, expected); self.suggest_bounds_for_range_to_method(&mut err, source, item_ident); From 4c952ebcd602f8317fed987e33b088d773309375 Mon Sep 17 00:00:00 2001 From: Romain Perier Date: Wed, 12 Nov 2025 15:11:07 +0100 Subject: [PATCH 143/194] Refactor and cleanup FnCtxt::report_no_match_method_error Currently this method is quiet long and complex, this commit improves its readability, refactor and cleanup few things --- .../rustc_hir_typeck/src/method/suggest.rs | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 72644e0c4c22..9a657ab15903 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1050,7 +1050,7 @@ fn suggest_method_not_found_because_of_unsatisfied_bounds( fn report_no_match_method_error( &self, - mut span: Span, + span: Span, rcvr_ty: Ty<'tcx>, item_ident: Ident, expr_id: hir::HirId, @@ -1062,13 +1062,24 @@ fn report_no_match_method_error( trait_missing_method: bool, within_macro_span: Option, ) -> ErrorGuaranteed { - let mode = no_match_data.mode; let tcx = self.tcx; let rcvr_ty = self.resolve_vars_if_possible(rcvr_ty); + + if let Err(guar) = rcvr_ty.error_reported() { + return guar; + } + + // We could pass the file for long types into these two, but it isn't strictly necessary + // given how targeted they are. + if let Err(guar) = + self.report_failed_method_call_on_range_end(tcx, rcvr_ty, source, span, item_ident) + { + return guar; + } + let mut ty_file = None; + let mode = no_match_data.mode; let is_method = mode == Mode::MethodCall; - let unsatisfied_predicates = &no_match_data.unsatisfied_predicates; - let similar_candidate = no_match_data.similar_candidate; let item_kind = if is_method { "method" } else if rcvr_ty.is_enum() { @@ -1082,13 +1093,6 @@ fn report_no_match_method_error( } }; - // We could pass the file for long types into these two, but it isn't strictly necessary - // given how targeted they are. - if let Err(guar) = - self.report_failed_method_call_on_range_end(tcx, rcvr_ty, source, span, item_ident) - { - return guar; - } if let Err(guar) = self.report_failed_method_call_on_numerical_infer_var( tcx, rcvr_ty, @@ -1100,8 +1104,8 @@ fn report_no_match_method_error( ) { return guar; } - span = item_ident.span; + let unsatisfied_predicates = &no_match_data.unsatisfied_predicates; let is_write = sugg_span.ctxt().outer_expn_data().macro_def_id.is_some_and(|def_id| { tcx.is_diagnostic_item(sym::write_macro, def_id) || tcx.is_diagnostic_item(sym::writeln_macro, def_id) @@ -1120,9 +1124,6 @@ fn report_no_match_method_error( unsatisfied_predicates, ) }; - if rcvr_ty.references_error() { - err.downgrade_to_delayed_bug(); - } self.set_label_for_method_error( &mut err, @@ -1130,19 +1131,25 @@ fn report_no_match_method_error( rcvr_ty, item_ident, expr_id, - span, + item_ident.span, sugg_span, within_macro_span, args, ); self.suggest_method_call_annotation( - &mut err, span, rcvr_ty, item_ident, mode, source, expected, + &mut err, + item_ident.span, + rcvr_ty, + item_ident, + mode, + source, + expected, ); let static_candidates = self.suggest_static_method_candidates( &mut err, - span, + item_ident.span, rcvr_ty, item_ident, source, @@ -1159,7 +1166,7 @@ fn report_no_match_method_error( bound_spans, )) = self.suggest_unsatisfied_ty_or_trait( &mut err, - span, + item_ident.span, rcvr_ty, item_ident, item_kind, @@ -1171,9 +1178,10 @@ fn report_no_match_method_error( return err.emit(); }; + let similar_candidate = no_match_data.similar_candidate; let should_label_not_found = self.suggest_surround_method_call( &mut err, - span, + item_ident.span, rcvr_ty, item_ident, source, @@ -1182,7 +1190,7 @@ fn report_no_match_method_error( self.find_possible_candidates_for_method( &mut err, - span, + item_ident.span, rcvr_ty, item_ident, item_kind, @@ -1201,7 +1209,7 @@ fn report_no_match_method_error( } else { self.suggest_traits_to_import( &mut err, - span, + item_ident.span, rcvr_ty, item_ident, args.map(|args| args.len() + 1), @@ -1218,14 +1226,14 @@ fn report_no_match_method_error( &mut err, rcvr_ty, item_ident, - span, + item_ident.span, source, unsatisfied_predicates, ); self.suggest_confusable_or_similarly_named_method( &mut err, - span, + item_ident.span, rcvr_ty, item_ident, mode, From 548b5d2406cb0a79d67e745dc3bf45e7eddbb607 Mon Sep 17 00:00:00 2001 From: Jacob Asper <78604367+20jasper@users.noreply.github.com> Date: Sat, 22 Nov 2025 22:25:51 -0500 Subject: [PATCH 144/194] lowercase usize Co-authored-by: Kivooeo <75776246+Kivooeo@users.noreply.github.com> --- compiler/rustc_errors/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 82e265c32bfa..1e70e54cf10c 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -348,7 +348,7 @@ fn push_trailing( hi_opt: Option<&Loc>, ) -> usize { let mut line_count = 0; - // Convert `CharPos` to `Usize`, as `CharPos` is character offset + // Convert `CharPos` to `usize`, as `CharPos` is character offset // Extract low index and high index let (lo, hi_opt) = (lo.col.to_usize(), hi_opt.map(|hi| hi.col.to_usize())); if let Some(line) = line_opt { From 1111730c5794cffc92ac26c0bd7e4cbe950144de Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sun, 23 Nov 2025 05:58:15 +0100 Subject: [PATCH 145/194] Add doc aliases list and vector to Vec --- library/alloc/src/vec/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 13d38d3c9609..6f587df6e33c 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -433,6 +433,8 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "Vec"] #[rustc_insignificant_dtor] +#[doc(alias = "list")] +#[doc(alias = "vector")] pub struct Vec { buf: RawVec, len: usize, From 5fbe5dae4264816c04f34711c9f53a6775d75505 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Sat, 22 Nov 2025 22:15:26 -0800 Subject: [PATCH 146/194] Only try to link against offload functions if llvm.enzyme is enabled --- compiler/rustc/Cargo.toml | 1 + compiler/rustc_codegen_llvm/Cargo.toml | 1 + compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 35 ++++++++++++++++--- compiler/rustc_driver_impl/Cargo.toml | 1 + compiler/rustc_interface/Cargo.toml | 1 + compiler/rustc_llvm/build.rs | 4 +++ .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 15 ++++++-- src/bootstrap/src/core/build_steps/compile.rs | 3 ++ src/bootstrap/src/lib.rs | 3 ++ 9 files changed, 58 insertions(+), 6 deletions(-) diff --git a/compiler/rustc/Cargo.toml b/compiler/rustc/Cargo.toml index 9ef8fa75062a..d68c1c9249f8 100644 --- a/compiler/rustc/Cargo.toml +++ b/compiler/rustc/Cargo.toml @@ -31,6 +31,7 @@ check_only = ['rustc_driver_impl/check_only'] jemalloc = ['dep:tikv-jemalloc-sys'] llvm = ['rustc_driver_impl/llvm'] llvm_enzyme = ['rustc_driver_impl/llvm_enzyme'] +llvm_offload = ['rustc_driver_impl/llvm_offload'] max_level_info = ['rustc_driver_impl/max_level_info'] rustc_randomized_layouts = ['rustc_driver_impl/rustc_randomized_layouts'] # tidy-alphabetical-end diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index 67bd1e59bb0c..0544a94fd59f 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -47,5 +47,6 @@ tracing = "0.1" # tidy-alphabetical-start check_only = ["rustc_llvm/check_only"] llvm_enzyme = [] +llvm_offload = [] # tidy-alphabetical-end diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 34f0e4b95338..09978dc6f873 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1641,9 +1641,6 @@ pub(crate) fn LLVMBuildFence<'a>( Name: *const c_char, ) -> &'a Value; - /// Processes the module and writes it in an offload compatible way into a "host.out" file. - pub(crate) fn LLVMRustBundleImages<'a>(M: &'a Module, TM: &'a TargetMachine) -> bool; - /// Writes a module to the specified path. Returns 0 on success. pub(crate) fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int; @@ -1721,6 +1718,37 @@ pub(crate) fn LLVMBuildCallBr<'a>( ) -> &'a Value; } +#[cfg(feature = "llvm_offload")] +pub(crate) use self::Offload::*; + +#[cfg(feature = "llvm_offload")] +mod Offload { + use super::*; + unsafe extern "C" { + /// Processes the module and writes it in an offload compatible way into a "host.out" file. + pub(crate) fn LLVMRustBundleImages<'a>(M: &'a Module, TM: &'a TargetMachine) -> bool; + pub(crate) fn LLVMRustOffloadMapper<'a>(OldFn: &'a Value, NewFn: &'a Value); + } +} + +#[cfg(not(feature = "llvm_offload"))] +pub(crate) use self::Offload_fallback::*; + +#[cfg(not(feature = "llvm_offload"))] +mod Offload_fallback { + use super::*; + /// Processes the module and writes it in an offload compatible way into a "host.out" file. + /// Marked as unsafe to match the real offload wrapper which is unsafe due to FFI. + #[allow(unused_unsafe)] + pub(crate) unsafe fn LLVMRustBundleImages<'a>(_M: &'a Module, _TM: &'a TargetMachine) -> bool { + unimplemented!("This rustc version was not built with LLVM Offload support!"); + } + #[allow(unused_unsafe)] + pub(crate) unsafe fn LLVMRustOffloadMapper<'a>(_OldFn: &'a Value, _NewFn: &'a Value) { + unimplemented!("This rustc version was not built with LLVM Offload support!"); + } +} + // FFI bindings for `DIBuilder` functions in the LLVM-C API. // Try to keep these in the same order as in `llvm/include/llvm-c/DebugInfo.h`. // @@ -2028,7 +2056,6 @@ pub(crate) fn LLVMRustCreateRangeAttribute( ) -> &Attribute; // Operations on functions - pub(crate) fn LLVMRustOffloadMapper<'a>(Fn: &'a Value, Fn: &'a Value); pub(crate) fn LLVMRustGetOrInsertFunction<'a>( M: &'a Module, Name: *const c_char, diff --git a/compiler/rustc_driver_impl/Cargo.toml b/compiler/rustc_driver_impl/Cargo.toml index 46efa50cff36..531b9e0c8ff7 100644 --- a/compiler/rustc_driver_impl/Cargo.toml +++ b/compiler/rustc_driver_impl/Cargo.toml @@ -75,6 +75,7 @@ ctrlc = "3.4.4" check_only = ['rustc_interface/check_only'] llvm = ['rustc_interface/llvm'] llvm_enzyme = ['rustc_interface/llvm_enzyme'] +llvm_offload = ['rustc_interface/llvm_offload'] max_level_info = ['rustc_log/max_level_info'] rustc_randomized_layouts = [ 'rustc_index/rustc_randomized_layouts', diff --git a/compiler/rustc_interface/Cargo.toml b/compiler/rustc_interface/Cargo.toml index f0836c47740a..d785030b5f2c 100644 --- a/compiler/rustc_interface/Cargo.toml +++ b/compiler/rustc_interface/Cargo.toml @@ -59,4 +59,5 @@ rustc_abi = { path = "../rustc_abi" } check_only = ['rustc_codegen_llvm?/check_only'] llvm = ['dep:rustc_codegen_llvm'] llvm_enzyme = ['rustc_builtin_macros/llvm_enzyme', 'rustc_codegen_llvm/llvm_enzyme'] +llvm_offload = ['rustc_codegen_llvm/llvm_offload'] # tidy-alphabetical-end diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index d5c43c4fa066..c58dd64cca5f 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -214,6 +214,10 @@ fn main() { cfg.define("ENZYME", None); } + if tracked_env_var_os("LLVM_OFFLOAD").is_some() { + cfg.define("OFFLOAD", None); + } + if tracked_env_var_os("LLVM_RUSTLLVM").is_some() { cfg.define("LLVM_RUSTLLVM", None); } diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index ba17aef92d0d..8d95b7f3aa40 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -25,7 +25,6 @@ #include "llvm/IR/Module.h" #include "llvm/IR/Value.h" #include "llvm/Object/COFFImportFile.h" -#include "llvm/Object/OffloadBinary.h" #include "llvm/Remarks/RemarkFormat.h" #include "llvm/Remarks/RemarkSerializer.h" #include "llvm/Remarks/RemarkStreamer.h" @@ -36,11 +35,18 @@ #include "llvm/Support/Signals.h" #include "llvm/Support/Timer.h" #include "llvm/Support/ToolOutputFile.h" -#include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/ValueMapper.h" #include +// Some of the functions below rely on LLVM modules that may not always be +// available. As such, we only try to build it in the first place, if +// llvm.offload is enabled. +#ifdef OFFLOAD +#include "llvm/Object/OffloadBinary.h" +#include "llvm/Target/TargetMachine.h" +#endif + // for raw `write` in the bad-alloc handler #ifdef _MSC_VER #include @@ -146,6 +152,10 @@ extern "C" void LLVMRustPrintStatistics(RustStringRef OutBuf) { llvm::PrintStatistics(OS); } +// Some of the functions here rely on LLVM modules that may not always be +// available. As such, we only try to build it in the first place, if +// llvm.offload is enabled. +#ifdef OFFLOAD static Error writeFile(StringRef Filename, StringRef Data) { Expected> OutputOrErr = FileOutputBuffer::create(Filename, Data.size()); @@ -210,6 +220,7 @@ extern "C" void LLVMRustOffloadMapper(LLVMValueRef OldFn, LLVMValueRef NewFn) { llvm::CloneFunctionChangeType::LocalChangesOnly, returns); } +#endif extern "C" LLVMValueRef LLVMRustGetNamedValue(LLVMModuleRef M, const char *Name, size_t NameLen) { diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 6857a40ada81..d0ba6c5e896c 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1436,6 +1436,9 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect if builder.config.llvm_enzyme { cargo.env("LLVM_ENZYME", "1"); } + if builder.config.llvm_offload { + cargo.env("LLVM_OFFLOAD", "1"); + } let llvm::LlvmResult { host_llvm_config, .. } = builder.ensure(llvm::Llvm { target }); cargo.env("LLVM_CONFIG", &host_llvm_config); diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index f4f467e01325..a31eb0c1c801 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -873,6 +873,9 @@ fn rustc_features(&self, kind: Kind, target: TargetSelection, crates: &[String]) if self.config.llvm_enzyme { features.push("llvm_enzyme"); } + if self.config.llvm_offload { + features.push("llvm_offload"); + } // keep in sync with `bootstrap/compile.rs:rustc_cargo_env` if self.config.rust_randomize_layout && check("rustc_randomized_layouts") { features.push("rustc_randomized_layouts"); From b31005e381492763ad994661bef864a39ef58e01 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Fri, 21 Nov 2025 01:47:47 -0800 Subject: [PATCH 147/194] update dev guide --- src/doc/rustc-dev-guide/src/offload/usage.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/offload/usage.md b/src/doc/rustc-dev-guide/src/offload/usage.md index 7abf90aa6e0b..8350fb5777fb 100644 --- a/src/doc/rustc-dev-guide/src/offload/usage.md +++ b/src/doc/rustc-dev-guide/src/offload/usage.md @@ -79,19 +79,8 @@ Now we generate the device code. Replace the target-cpu with the right code for RUSTFLAGS="-Ctarget-cpu=gfx90a --emit=llvm-bc,llvm-ir -Zoffload=Enable -Zunstable-options" cargo +offload build -Zunstable-options -r -v --target amdgcn-amd-amdhsa -Zbuild-std=core ``` -Now find the `.ll` under target/amdgcn-amd-amdhsa folder and copy it to a device.ll file (or adjust the file names below). -If you work on an NVIDIA or Intel gpu, please adjust the names acordingly and open an issue to share your results (either if you succeed or fail). -First we compile our .ll files (good for manual inspections) to .bc files and clean up leftover artifacts. The cleanup is important, otherwise caching might interfere on following runs. -``` -opt lib.ll -o lib.bc -opt device.ll -o device.bc -rm *.o -rm bare.amdgcn.gfx90a.img* -``` ``` -"clang-offload-packager" "-o" "host.out" "--image=file=device.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp" - "clang-21" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-S" "-save-temps=cwd" "-disable-free" "-clear-ast-before-backend" "-main-file-name" "lib.rs" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=all" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-resource-dir" "//rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21" "-ferror-limit" "19" "-fopenmp" "-fopenmp-offload-mandatory" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fembed-offload-object=host.out" "-fopenmp-targets=amdgcn-amd-amdhsa" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "host.s" "-x" "ir" "lib.bc" "clang-21" "-cc1as" "-triple" "x86_64-unknown-linux-gnu" "-filetype" "obj" "-main-file-name" "lib.rs" "-target-cpu" "x86-64" "-mrelocation-model" "pic" "-o" "host.o" "host.s" @@ -99,7 +88,8 @@ rm bare.amdgcn.gfx90a.img* "clang-linker-wrapper" "--should-extract=gfx90a" "--device-compiler=amdgcn-amd-amdhsa=-g" "--device-compiler=amdgcn-amd-amdhsa=-save-temps=cwd" "--device-linker=amdgcn-amd-amdhsa=-lompdevice" "--host-triple=x86_64-unknown-linux-gnu" "--save-temps" "--linker-path=/ABSOlUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/lld/bin/ld.lld" "--hash-style=gnu" "--eh-frame-hdr" "-m" "elf_x86_64" "-pie" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-o" "bare" "/lib/../lib64/Scrt1.o" "/lib/../lib64/crti.o" "/ABSOLUTE_PATH_TO/crtbeginS.o" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/x86_64-unknown-linux-gnu" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib/clang/21/lib/x86_64-unknown-linux-gnu" "-L/lib/../lib64" "-L/usr/lib64" "-L/lib" "-L/usr/lib" "host.o" "-lstdc++" "-lm" "-lomp" "-lomptarget" "-L/ABSOLUTE_PATH_TO/rust/build/x86_64-unknown-linux-gnu/llvm/lib" "-lgcc_s" "-lgcc" "-lpthread" "-lc" "-lgcc_s" "-lgcc" "/ABSOLUTE_PATH_TO/crtendS.o" "/lib/../lib64/crtn.o" ``` -Especially for the last command I recommend to not fix the paths, but rather just re-generate them by copying a bare-mode openmp example and compiling it with your clang. By adding `-###` to your clang invocation, you can see the invidual steps. +Especially for the last three commands I recommend to not fix the paths, but rather just re-generate them by copying a bare-mode openmp example and compiling it with your clang. By adding `-###` to your clang invocation, you can see the invidual steps. +You can ignore other steps, e.g. the invocation of a "clang-offload-packager". ``` myclang++ -fuse-ld=lld -O3 -fopenmp -fopenmp-offload-mandatory --offload-arch=gfx90a omp_bare.cpp -o main -### ``` From 73cecf3a39bfb5a57982311de238147dd1c34a1f Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 11 Nov 2025 20:16:15 +0100 Subject: [PATCH 148/194] Simplify jemalloc setup Using the new `override_allocator_on_supported_platforms` feature in `tikv-jemalloc-sys v0.6.1` we can avoid the manual statics. --- compiler/rustc/Cargo.toml | 4 +-- compiler/rustc/src/main.rs | 63 ++++++++-------------------------- src/librustdoc/lib.rs | 41 ++++------------------ src/tools/clippy/src/driver.rs | 40 ++++----------------- src/tools/miri/Cargo.toml | 4 +-- src/tools/miri/src/bin/miri.rs | 46 +++---------------------- 6 files changed, 37 insertions(+), 161 deletions(-) diff --git a/compiler/rustc/Cargo.toml b/compiler/rustc/Cargo.toml index ea38e2806da5..8c71ae1d6ad8 100644 --- a/compiler/rustc/Cargo.toml +++ b/compiler/rustc/Cargo.toml @@ -28,9 +28,9 @@ wasi = "=0.14.2" [dependencies.tikv-jemalloc-sys] -version = "0.6.0" +version = "0.6.1" optional = true -features = ['unprefixed_malloc_on_supported_platforms'] +features = ['override_allocator_on_supported_platforms'] [features] # tidy-alphabetical-start diff --git a/compiler/rustc/src/main.rs b/compiler/rustc/src/main.rs index ca1bb59e59d6..89c61cdf00a5 100644 --- a/compiler/rustc/src/main.rs +++ b/compiler/rustc/src/main.rs @@ -7,26 +7,25 @@ // 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 must 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'd like to use a +// consistent allocator across the rustc <-> llvm boundary, and +// `#[global_allocator]` wouldn't provide that. // -// 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. +// 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. // // 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. // -// 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: 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]`. // // 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: @@ -36,43 +35,9 @@ // 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/lib.rs b/src/librustdoc/lib.rs index e88180c3033b..e4601bfb20d7 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -61,10 +61,14 @@ 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. +/// 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. +/// +/// FIXME(madsmtm): This is loaded from the sysroot that was built with the other `rustc` crates +/// above, instead of via Cargo as you'd normally do. This is currently needed for LTO due to +/// https://github.com/rust-lang/cc-rs/issues/1613. #[cfg(feature = "jemalloc")] -extern crate tikv_jemalloc_sys as jemalloc_sys; +extern crate tikv_jemalloc_sys as _; use std::env::{self, VarError}; use std::io::{self, IsTerminal}; @@ -124,37 +128,6 @@ macro_rules! map { 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/src/driver.rs b/src/tools/clippy/src/driver.rs index abc706b7772f..2fc4abe48fe4 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -13,10 +13,14 @@ extern crate rustc_session; extern crate rustc_span; -// See docs in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc/src/main.rs -// about jemalloc. +/// 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. +/// +/// FIXME(madsmtm): This is loaded from the sysroot that was built with the other `rustc` crates +/// above, instead of via Cargo as you'd normally do. This is currently needed for LTO due to +/// https://github.com/rust-lang/cc-rs/issues/1613. #[cfg(feature = "jemalloc")] -extern crate tikv_jemalloc_sys as jemalloc_sys; +extern crate tikv_jemalloc_sys as _; use clippy_utils::sym; use declare_clippy_lint::LintListBuilder; @@ -189,36 +193,6 @@ fn display_help() { #[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 99a48e5d4bc1..611e549930a9 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.0" -features = ['unprefixed_malloc_on_supported_platforms'] +version = "0.6.1" +features = ['override_allocator_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 ecb8abc463bb..d7c5cb68e4f0 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -20,6 +20,11 @@ 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; @@ -395,48 +400,7 @@ 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 1a4852c5fe69219e145acc87ac35a8d21202101a Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Thu, 16 Oct 2025 23:28:24 -0400 Subject: [PATCH 149/194] Fix MaybeUninit codegen using GVN --- compiler/rustc_codegen_ssa/src/mir/rvalue.rs | 6 ++++ .../rustc_const_eval/src/interpret/operand.rs | 4 +++ compiler/rustc_middle/src/mir/pretty.rs | 7 +++++ compiler/rustc_mir_transform/src/gvn.rs | 28 +++++++++++++++---- tests/codegen-llvm/maybeuninit-array.rs | 15 ++++++++++ tests/codegen-llvm/uninit-consts.rs | 12 ++++---- tests/mir-opt/const_prop/maybe_uninit.rs | 10 +++++++ .../const_prop/maybe_uninit.u8_array.GVN.diff | 28 +++++++++++++++++++ tests/mir-opt/const_prop/transmute.rs | 3 +- ...mute.undef_union_as_integer.GVN.32bit.diff | 8 ++++-- ...mute.undef_union_as_integer.GVN.64bit.diff | 8 ++++-- 11 files changed, 112 insertions(+), 17 deletions(-) create mode 100644 tests/codegen-llvm/maybeuninit-array.rs create mode 100644 tests/mir-opt/const_prop/maybe_uninit.rs create mode 100644 tests/mir-opt/const_prop/maybe_uninit.u8_array.GVN.diff diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs index 827dc6e167af..221513eb2464 100644 --- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs +++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs @@ -24,6 +24,12 @@ pub(crate) fn codegen_rvalue( ) { match *rvalue { mir::Rvalue::Use(ref operand) => { + if let mir::Operand::Constant(const_op) = operand { + let val = self.eval_mir_constant(&const_op); + if val.all_bytes_uninit(self.cx.tcx()) { + return; + } + } let cg_operand = self.codegen_operand(bx, operand); // Crucially, we do *not* use `OperandValue::Ref` for types with // `BackendRepr::Scalar | BackendRepr::ScalarPair`. This ensures we match the MIR diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 560b0e1ae4e6..d3d119c8fc9c 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -522,6 +522,10 @@ impl<'tcx, Prov: Provenance> OpTy<'tcx, Prov> { pub(super) fn op(&self) -> &Operand { &self.op } + + pub fn is_immediate_uninit(&self) -> bool { + matches!(self.op, Operand::Immediate(Immediate::Uninit)) + } } impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for OpTy<'tcx, Prov> { diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index e31b110ab265..57dcdb236355 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -1872,6 +1872,13 @@ fn pretty_print_const_value_tcx<'tcx>( return Ok(()); } + // Printing [MaybeUninit::uninit(); N] or any other aggregate where all fields are uninit + // becomes very verbose. This special case makes the dump terse and clear. + if ct.all_bytes_uninit(tcx) { + fmt.write_str("")?; + return Ok(()); + } + let u8_type = tcx.types.u8; match (ct, ty.kind()) { // Byte/string slices, printed as (byte) string literals. diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index a20e04371b98..fc8dfcfe1220 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -570,9 +570,19 @@ fn eval_to_const_inner(&mut self, value: VnIndex) -> Option> { _ if ty.is_zst() => ImmTy::uninit(ty).into(), Opaque(_) => return None, - // Do not bother evaluating repeat expressions. This would uselessly consume memory. - Repeat(..) => return None, + // In general, evaluating repeat expressions just consumes a lot of memory. + // But in the special case that the element is just Immediate::Uninit, we can evaluate + // it without extra memory! If we don't propagate uninit values like this, LLVM can get + // very confused: https://github.com/rust-lang/rust/issues/139355 + Repeat(value, _count) => { + let value = self.eval_to_const(value)?; + if value.is_immediate_uninit() { + ImmTy::uninit(ty).into() + } else { + return None; + } + } Constant { ref value, disambiguator: _ } => { self.ecx.eval_mir_constant(value, DUMMY_SP, None).discard_err()? } @@ -608,8 +618,12 @@ fn eval_to_const_inner(&mut self, value: VnIndex) -> Option> { } Union(active_field, field) => { let field = self.eval_to_const(field)?; - if matches!(ty.backend_repr, BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..)) - { + if field.layout.layout.is_zst() { + ImmTy::from_immediate(Immediate::Uninit, ty).into() + } else if matches!( + ty.backend_repr, + BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..) + ) { let dest = self.ecx.allocate(ty, MemoryKind::Stack).discard_err()?; let field_dest = self.ecx.project_field(&dest, active_field).discard_err()?; self.ecx.copy_op(field, &field_dest).discard_err()?; @@ -1705,7 +1719,11 @@ fn op_to_prop_const<'tcx>( // Do not synthetize too large constants. Codegen will just memcpy them, which we'd like to // avoid. - if !matches!(op.layout.backend_repr, BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..)) { + // But we *do* want to synthesize any size constant if it is entirely uninit because that + // benefits codegen, which has special handling for them. + if !op.is_immediate_uninit() + && !matches!(op.layout.backend_repr, BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..)) + { return None; } diff --git a/tests/codegen-llvm/maybeuninit-array.rs b/tests/codegen-llvm/maybeuninit-array.rs new file mode 100644 index 000000000000..e96db2836e1b --- /dev/null +++ b/tests/codegen-llvm/maybeuninit-array.rs @@ -0,0 +1,15 @@ +// This is a regression test for https://github.com/rust-lang/rust/issues/139355 + +//@ compile-flags: -Copt-level=3 + +#![crate_type = "lib"] + +use std::mem::MaybeUninit; + +#[no_mangle] +pub fn create_uninit_array() -> [[MaybeUninit; 4]; 200] { + // CHECK-LABEL: create_uninit_array + // CHECK-NEXT: start: + // CHECK-NEXT: ret void + [[MaybeUninit::::uninit(); 4]; 200] +} diff --git a/tests/codegen-llvm/uninit-consts.rs b/tests/codegen-llvm/uninit-consts.rs index bde71a35c47d..6724c0631713 100644 --- a/tests/codegen-llvm/uninit-consts.rs +++ b/tests/codegen-llvm/uninit-consts.rs @@ -11,21 +11,19 @@ pub struct PartiallyUninit { y: MaybeUninit<[u8; 10]>, } -// CHECK: [[FULLY_UNINIT:@.*]] = private unnamed_addr constant [10 x i8] undef - // CHECK: [[PARTIALLY_UNINIT:@.*]] = private unnamed_addr constant <{ [4 x i8], [12 x i8] }> <{ [4 x i8] c"{{\\EF\\BE\\AD\\DE|\\DE\\AD\\BE\\EF}}", [12 x i8] undef }>, align 4 // This shouldn't contain undef, since it contains more chunks // than the default value of uninit_const_chunk_threshold. // CHECK: [[UNINIT_PADDING_HUGE:@.*]] = private unnamed_addr constant [32768 x i8] c"{{.+}}", align 4 -// CHECK: [[FULLY_UNINIT_HUGE:@.*]] = private unnamed_addr constant [16384 x i8] undef - // CHECK-LABEL: @fully_uninit #[no_mangle] pub const fn fully_uninit() -> MaybeUninit<[u8; 10]> { const M: MaybeUninit<[u8; 10]> = MaybeUninit::uninit(); - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 1 %_0, ptr align 1 {{.*}}[[FULLY_UNINIT]]{{.*}}, i{{(32|64)}} 10, i1 false) + // returning uninit doesn't need to do anything to the return place at all + // CHECK-NEXT: start: + // CHECK-NEXT: ret void M } @@ -49,6 +47,8 @@ pub const fn partially_uninit() -> PartiallyUninit { #[no_mangle] pub const fn fully_uninit_huge() -> MaybeUninit<[u32; 4096]> { const F: MaybeUninit<[u32; 4096]> = MaybeUninit::uninit(); - // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 4 %_0, ptr align 4 {{.*}}[[FULLY_UNINIT_HUGE]]{{.*}}, i{{(32|64)}} 16384, i1 false) + // returning uninit doesn't need to do anything to the return place at all + // CHECK-NEXT: start: + // CHECK-NEXT: ret void F } diff --git a/tests/mir-opt/const_prop/maybe_uninit.rs b/tests/mir-opt/const_prop/maybe_uninit.rs new file mode 100644 index 000000000000..649fea625221 --- /dev/null +++ b/tests/mir-opt/const_prop/maybe_uninit.rs @@ -0,0 +1,10 @@ +//@ compile-flags: -O + +use std::mem::MaybeUninit; + +// EMIT_MIR maybe_uninit.u8_array.GVN.diff +pub fn u8_array() -> [MaybeUninit; 8] { + // CHECK: fn u8_array( + // CHECK: _0 = const ; + [MaybeUninit::uninit(); 8] +} diff --git a/tests/mir-opt/const_prop/maybe_uninit.u8_array.GVN.diff b/tests/mir-opt/const_prop/maybe_uninit.u8_array.GVN.diff new file mode 100644 index 000000000000..50191488ad9a --- /dev/null +++ b/tests/mir-opt/const_prop/maybe_uninit.u8_array.GVN.diff @@ -0,0 +1,28 @@ +- // MIR for `u8_array` before GVN ++ // MIR for `u8_array` after GVN + + fn u8_array() -> [MaybeUninit; 8] { + let mut _0: [std::mem::MaybeUninit; 8]; + let mut _1: std::mem::MaybeUninit; + scope 1 (inlined MaybeUninit::::uninit) { + } + + bb0: { + StorageLive(_1); +- _1 = MaybeUninit:: { uninit: const () }; +- _0 = [move _1; 8]; ++ _1 = const ; ++ _0 = const ; + StorageDead(_1); + return; + } ++ } ++ ++ ALLOC0 (size: 8, align: 1) { ++ __ __ __ __ __ __ __ __ │ ░░░░░░░░ ++ } ++ ++ ALLOC1 (size: 1, align: 1) { ++ __ │ ░ + } + diff --git a/tests/mir-opt/const_prop/transmute.rs b/tests/mir-opt/const_prop/transmute.rs index ece6331ade27..ad971a64370e 100644 --- a/tests/mir-opt/const_prop/transmute.rs +++ b/tests/mir-opt/const_prop/transmute.rs @@ -43,8 +43,7 @@ pub unsafe fn invalid_bool() -> bool { // EMIT_MIR transmute.undef_union_as_integer.GVN.diff pub unsafe fn undef_union_as_integer() -> u32 { // CHECK-LABEL: fn undef_union_as_integer( - // CHECK: _1 = const Union32 - // CHECK: _0 = const {{.*}}: u32; + // CHECK: _0 = const ; union Union32 { value: u32, unit: (), diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.32bit.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.32bit.diff index be0450114b1c..f36f7df51ba4 100644 --- a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.32bit.diff @@ -12,16 +12,20 @@ - _2 = (); - _1 = Union32 { value: move _2 }; + _2 = const (); -+ _1 = const Union32 {{ value: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: u32, unit: () }}; ++ _1 = const ; StorageDead(_2); - _0 = move _1 as u32 (Transmute); -+ _0 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: u32; ++ _0 = const ; StorageDead(_1); return; } + } + + ALLOC0 (size: 4, align: 4) { ++ __ __ __ __ │ ░░░░ ++ } ++ ++ ALLOC1 (size: 4, align: 4) { + __ __ __ __ │ ░░░░ } diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.64bit.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.64bit.diff index be0450114b1c..f36f7df51ba4 100644 --- a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.64bit.diff @@ -12,16 +12,20 @@ - _2 = (); - _1 = Union32 { value: move _2 }; + _2 = const (); -+ _1 = const Union32 {{ value: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: u32, unit: () }}; ++ _1 = const ; StorageDead(_2); - _0 = move _1 as u32 (Transmute); -+ _0 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: u32; ++ _0 = const ; StorageDead(_1); return; } + } + + ALLOC0 (size: 4, align: 4) { ++ __ __ __ __ │ ░░░░ ++ } ++ ++ ALLOC1 (size: 4, align: 4) { + __ __ __ __ │ ░░░░ } From 2ee6196078f76ff78279414fc336dfee0093331e Mon Sep 17 00:00:00 2001 From: binarycat Date: Fri, 21 Nov 2025 14:42:02 -0600 Subject: [PATCH 150/194] validate usage of crate-level doc attributes --- compiler/rustc_passes/messages.ftl | 8 +++ compiler/rustc_passes/src/check_attr.rs | 31 +++++++++++- compiler/rustc_passes/src/errors.rs | 12 +++++ tests/rustdoc-ui/bad-render-options.rs | 11 ++++ tests/rustdoc-ui/bad-render-options.stderr | 58 ++++++++++++++++++++++ 5 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 tests/rustdoc-ui/bad-render-options.rs create mode 100644 tests/rustdoc-ui/bad-render-options.stderr diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl index b33ccbae0e69..44177d4ae468 100644 --- a/compiler/rustc_passes/messages.ftl +++ b/compiler/rustc_passes/messages.ftl @@ -126,6 +126,14 @@ passes_doc_alias_not_string_literal = passes_doc_alias_start_end = {$attr_str} cannot start or end with ' ' +passes_doc_attr_expects_no_value = + `doc({$attr_name})` does not accept a value + .suggestion = use `doc({$attr_name})` + +passes_doc_attr_expects_string = + `doc({$attr_name})` expects a string value + .suggestion = use `doc({$attr_name} = "...")` + passes_doc_attr_not_crate_level = `#![doc({$attr_name} = "...")]` isn't allowed as a crate-level attribute diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 347e103af937..94bdb1e571bc 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -1122,6 +1122,28 @@ fn check_attr_crate_level( true } + fn check_doc_attr_string_value(&self, meta: &MetaItemInner, hir_id: HirId) { + if meta.value_str().is_none() { + self.tcx.emit_node_span_lint( + INVALID_DOC_ATTRIBUTES, + hir_id, + meta.span(), + errors::DocAttrExpectsString { attr_name: meta.name().unwrap() }, + ); + } + } + + fn check_doc_attr_no_value(&self, meta: &MetaItemInner, hir_id: HirId) { + if !meta.is_word() { + self.tcx.emit_node_span_lint( + INVALID_DOC_ATTRIBUTES, + hir_id, + meta.span(), + errors::DocAttrExpectsNoValue { attr_name: meta.name().unwrap() }, + ); + } + } + /// Checks that `doc(test(...))` attribute contains only valid attributes and are at the right place. fn check_test_attr( &self, @@ -1292,10 +1314,15 @@ fn check_doc_attrs( | sym::html_logo_url | sym::html_playground_url | sym::issue_tracker_base_url - | sym::html_root_url - | sym::html_no_source, + | sym::html_root_url, ) => { self.check_attr_crate_level(attr_span, style, meta, hir_id); + self.check_doc_attr_string_value(meta, hir_id); + } + + Some(sym::html_no_source) => { + self.check_attr_crate_level(attr_span, style, meta, hir_id); + self.check_doc_attr_no_value(meta, hir_id); } Some(sym::auto_cfg) => { diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index ed4cf77d294f..e4826cccd32f 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -24,6 +24,18 @@ #[diag(passes_incorrect_do_not_recommend_args)] pub(crate) struct DoNotRecommendDoesNotExpectArgs; +#[derive(LintDiagnostic)] +#[diag(passes_doc_attr_expects_string)] +pub(crate) struct DocAttrExpectsString { + pub(crate) attr_name: Symbol, +} + +#[derive(LintDiagnostic)] +#[diag(passes_doc_attr_expects_no_value)] +pub(crate) struct DocAttrExpectsNoValue { + pub(crate) attr_name: Symbol, +} + #[derive(Diagnostic)] #[diag(passes_autodiff_attr)] pub(crate) struct AutoDiffAttr { diff --git a/tests/rustdoc-ui/bad-render-options.rs b/tests/rustdoc-ui/bad-render-options.rs new file mode 100644 index 000000000000..f2cfd4b76fa8 --- /dev/null +++ b/tests/rustdoc-ui/bad-render-options.rs @@ -0,0 +1,11 @@ +// regression test for https://github.com/rust-lang/rust/issues/149187 + +#![doc(html_favicon_url)] //~ ERROR: `doc(html_favicon_url)` expects a string value [invalid_doc_attributes] +#![doc(html_logo_url)] //~ ERROR: `doc(html_logo_url)` expects a string value [invalid_doc_attributes] +#![doc(html_playground_url)] //~ ERROR: `doc(html_playground_url)` expects a string value [invalid_doc_attributes] +#![doc(issue_tracker_base_url)] //~ ERROR expects a string value +#![doc(html_favicon_url = 1)] //~ ERROR expects a string value +#![doc(html_logo_url = 2)] //~ ERROR expects a string value +#![doc(html_playground_url = 3)] //~ ERROR expects a string value +#![doc(issue_tracker_base_url = 4)] //~ ERROR expects a string value +#![doc(html_no_source = "asdf")] //~ ERROR `doc(html_no_source)` does not accept a value [invalid_doc_attributes] diff --git a/tests/rustdoc-ui/bad-render-options.stderr b/tests/rustdoc-ui/bad-render-options.stderr new file mode 100644 index 000000000000..9d503363c0bd --- /dev/null +++ b/tests/rustdoc-ui/bad-render-options.stderr @@ -0,0 +1,58 @@ +error: `doc(html_favicon_url)` expects a string value + --> $DIR/bad-render-options.rs:3:8 + | +LL | #![doc(html_favicon_url)] + | ^^^^^^^^^^^^^^^^ + | + = note: `#[deny(invalid_doc_attributes)]` on by default + +error: `doc(html_logo_url)` expects a string value + --> $DIR/bad-render-options.rs:4:8 + | +LL | #![doc(html_logo_url)] + | ^^^^^^^^^^^^^ + +error: `doc(html_playground_url)` expects a string value + --> $DIR/bad-render-options.rs:5:8 + | +LL | #![doc(html_playground_url)] + | ^^^^^^^^^^^^^^^^^^^ + +error: `doc(issue_tracker_base_url)` expects a string value + --> $DIR/bad-render-options.rs:6:8 + | +LL | #![doc(issue_tracker_base_url)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: `doc(html_favicon_url)` expects a string value + --> $DIR/bad-render-options.rs:7:8 + | +LL | #![doc(html_favicon_url = 1)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: `doc(html_logo_url)` expects a string value + --> $DIR/bad-render-options.rs:8:8 + | +LL | #![doc(html_logo_url = 2)] + | ^^^^^^^^^^^^^^^^^ + +error: `doc(html_playground_url)` expects a string value + --> $DIR/bad-render-options.rs:9:8 + | +LL | #![doc(html_playground_url = 3)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: `doc(issue_tracker_base_url)` expects a string value + --> $DIR/bad-render-options.rs:10:8 + | +LL | #![doc(issue_tracker_base_url = 4)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `doc(html_no_source)` does not accept a value + --> $DIR/bad-render-options.rs:11:8 + | +LL | #![doc(html_no_source = "asdf")] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 9 previous errors + From ab169ed983cb773dd861d5e3b96d24566c1ea699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sun, 9 Nov 2025 16:01:59 +0100 Subject: [PATCH 151/194] Build gnullvm toolchains on Windows natively --- src/bootstrap/src/core/build_steps/dist.rs | 28 +++------ .../dist-aarch64-windows-gnullvm/Dockerfile | 35 ----------- .../dist-x86_64-windows-gnullvm/Dockerfile | 37 ------------ .../install-llvm-mingw.sh | 13 ---- src/ci/github-actions/jobs.yml | 28 +++++++-- src/ci/scripts/install-mingw.sh | 59 +++++++++++++++---- src/etc/installer/msi/rust.wxs | 20 +++++++ 7 files changed, 97 insertions(+), 123 deletions(-) delete mode 100644 src/ci/docker/host-x86_64/dist-aarch64-windows-gnullvm/Dockerfile delete mode 100644 src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/Dockerfile delete mode 100755 src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 4fdcdb2051f5..074ebe8c1317 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -338,7 +338,7 @@ fn runtime_dll_dist(rust_root: &Path, target: TargetSelection, builder: &Builder return; } - let (bin_path, libs_path) = get_cc_search_dirs(target, builder); + let (bin_path, _) = get_cc_search_dirs(target, builder); let mut rustc_dlls = vec![]; // windows-gnu and windows-gnullvm require different runtime libs @@ -354,15 +354,6 @@ fn runtime_dll_dist(rust_root: &Path, target: TargetSelection, builder: &Builder } else { panic!("Vendoring of runtime DLLs for `{target}` is not supported`"); } - // FIXME(#144656): Remove this whole `let ...` - let bin_path = if target.ends_with("windows-gnullvm") && builder.host_target != target { - bin_path - .into_iter() - .chain(libs_path.iter().map(|path| path.with_file_name("bin"))) - .collect() - } else { - bin_path - }; let rustc_dlls = find_files(&rustc_dlls, &bin_path); // Copy runtime dlls next to rustc.exe @@ -1721,7 +1712,7 @@ macro_rules! add_component { tarballs.push(builder.ensure(Rustc { target_compiler })); tarballs.push(builder.ensure(Std { build_compiler, target }).expect("missing std")); - if target.is_windows_gnu() { + if target.is_windows_gnu() || target.is_windows_gnullvm() { tarballs.push(builder.ensure(Mingw { target }).expect("missing mingw")); } @@ -1868,8 +1859,7 @@ fn filter(contents: &str, marker: &str) -> String { cmd.run(builder); } - // FIXME(mati865): `gnullvm` here is temporary, remove it once it can host itself - if target.is_windows() && !target.contains("gnullvm") { + if target.is_windows() { let exe = tmp.join("exe"); let _ = fs::remove_dir_all(&exe); @@ -1907,7 +1897,7 @@ fn filter(contents: &str, marker: &str) -> String { prepare(tool); } } - if target.is_windows_gnu() { + if target.is_windows_gnu() || target.is_windows_gnullvm() { prepare("rust-mingw"); } @@ -2072,7 +2062,7 @@ fn filter(contents: &str, marker: &str) -> String { .arg("-t") .arg(etc.join("msi/remove-duplicates.xsl")) .run(builder); - if target.is_windows_gnu() { + if target.is_windows_gnu() || target.is_windows_gnullvm() { command(&heat) .current_dir(&exe) .arg("dir") @@ -2121,7 +2111,7 @@ fn filter(contents: &str, marker: &str) -> String { if built_tools.contains("miri") { cmd.arg("-dMiriDir=miri"); } - if target.is_windows_gnu() { + if target.is_windows_gnu() || target.is_windows_gnullvm() { cmd.arg("-dGccDir=rust-mingw"); } cmd.run(builder); @@ -2149,7 +2139,7 @@ fn filter(contents: &str, marker: &str) -> String { } candle("AnalysisGroup.wxs".as_ref()); - if target.is_windows_gnu() { + if target.is_windows_gnu() || target.is_windows_gnullvm() { candle("GccGroup.wxs".as_ref()); } @@ -2192,7 +2182,7 @@ fn filter(contents: &str, marker: &str) -> String { cmd.arg("DocsGroup.wixobj"); } - if target.is_windows_gnu() { + if target.is_windows_gnu() || target.is_windows_gnullvm() { cmd.arg("GccGroup.wixobj"); } // ICE57 wrongly complains about the shortcuts @@ -2231,7 +2221,7 @@ fn add_env( .env("CFG_BUILD", target.triple) .env("CFG_CHANNEL", &builder.config.channel); - if target.contains("windows-gnullvm") { + if target.is_windows_gnullvm() { cmd.env("CFG_MINGW", "1").env("CFG_ABI", "LLVM"); } else if target.is_windows_gnu() { cmd.env("CFG_MINGW", "1").env("CFG_ABI", "GNU"); diff --git a/src/ci/docker/host-x86_64/dist-aarch64-windows-gnullvm/Dockerfile b/src/ci/docker/host-x86_64/dist-aarch64-windows-gnullvm/Dockerfile deleted file mode 100644 index 0bb51af817ab..000000000000 --- a/src/ci/docker/host-x86_64/dist-aarch64-windows-gnullvm/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -FROM ubuntu:24.04 - -WORKDIR /build - -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - g++ \ - git \ - make \ - ninja-build \ - python3 \ - xz-utils - -ENV ARCH=aarch64 -COPY host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh /build -RUN ./install-llvm-mingw.sh - -COPY scripts/sccache.sh /scripts/ -RUN sh /scripts/sccache.sh - -ENV CC_aarch64_pc_windows_gnullvm=aarch64-w64-mingw32-clang \ - CXX_aarch64_pc_windows_gnullvm=aarch64-w64-mingw32-clang++ - -ENV HOST=aarch64-pc-windows-gnullvm - -ENV RUST_CONFIGURE_ARGS \ - --enable-full-tools \ - --enable-profiler \ - --enable-sanitizers \ - --disable-docs - -ENV SCRIPT python3 ../x.py dist --host $HOST --target $HOST diff --git a/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/Dockerfile deleted file mode 100644 index da0c065c8547..000000000000 --- a/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM ubuntu:24.04 - -WORKDIR /build - -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y --no-install-recommends \ - ca-certificates \ - cmake \ - curl \ - g++ \ - git \ - make \ - ninja-build \ - python3 \ - xz-utils - -ENV ARCH='i686 x86_64' -COPY host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh /build -RUN ./install-llvm-mingw.sh - -COPY scripts/sccache.sh /scripts/ -RUN sh /scripts/sccache.sh - -ENV CC_i686_pc_windows_gnullvm=i686-w64-mingw32-clang \ - CC_x86_64_pc_windows_gnullvm=x86_64-w64-mingw32-clang \ - CXX_x86_64_pc_windows_gnullvm=x86_64-w64-mingw32-clang++ - -ENV HOST=x86_64-pc-windows-gnullvm -ENV TARGETS=i686-pc-windows-gnullvm,x86_64-pc-windows-gnullvm - -ENV RUST_CONFIGURE_ARGS \ - --enable-full-tools \ - --enable-profiler \ - --enable-sanitizers \ - --disable-docs - -ENV SCRIPT python3 ../x.py dist --host $HOST --target $TARGETS diff --git a/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh b/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh deleted file mode 100755 index 0ea5dae3ffbd..000000000000 --- a/src/ci/docker/host-x86_64/dist-x86_64-windows-gnullvm/install-llvm-mingw.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -release_date=20250613 -archive=llvm-mingw-${release_date}-ucrt-ubuntu-22.04-x86_64.tar.xz -curl -L https://github.com/mstorsjo/llvm-mingw/releases/download/${release_date}/${archive} | \ -tar --extract --xz --strip 1 --directory /usr/local - -# https://github.com/mstorsjo/llvm-mingw/issues/493 -for arch in $ARCH; do - ln -s $arch-w64-windows-gnu.cfg /usr/local/bin/$arch-pc-windows-gnu.cfg -done diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 33de0b09d94d..ee10e36e1c37 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -247,12 +247,6 @@ auto: - name: dist-s390x-linux <<: *job-linux-4c - - name: dist-aarch64-windows-gnullvm - <<: *job-linux-4c - - - name: dist-x86_64-windows-gnullvm - <<: *job-linux-4c - - name: dist-various-1 <<: *job-linux-4c @@ -689,6 +683,28 @@ auto: CODEGEN_BACKENDS: llvm,cranelift <<: *job-windows + - name: dist-aarch64-llvm-mingw + env: + SCRIPT: python x.py dist bootstrap --include-default-paths + RUST_CONFIGURE_ARGS: >- + --build=aarch64-pc-windows-gnullvm + --enable-full-tools + --enable-profiler + DIST_REQUIRE_ALL_TOOLS: 1 + CODEGEN_BACKENDS: llvm,cranelift + <<: *job-windows-aarch64 + + - name: dist-x86_64-llvm-mingw + env: + SCRIPT: python x.py dist bootstrap --include-default-paths + RUST_CONFIGURE_ARGS: >- + --build=x86_64-pc-windows-gnullvm + --enable-full-tools + --enable-profiler + DIST_REQUIRE_ALL_TOOLS: 1 + CODEGEN_BACKENDS: llvm,cranelift + <<: *job-windows + - name: dist-x86_64-msvc-alt env: RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-extended --enable-profiler diff --git a/src/ci/scripts/install-mingw.sh b/src/ci/scripts/install-mingw.sh index ed87628659b4..17bedaa7b826 100755 --- a/src/ci/scripts/install-mingw.sh +++ b/src/ci/scripts/install-mingw.sh @@ -8,22 +8,37 @@ source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" MINGW_ARCHIVE_32="i686-14.1.0-release-posix-dwarf-msvcrt-rt_v12-rev0.7z" MINGW_ARCHIVE_64="x86_64-14.1.0-release-posix-seh-msvcrt-rt_v12-rev0.7z" +LLVM_MINGW_ARCHIVE_AARCH64="llvm-mingw-20251104-ucrt-aarch64.zip" +LLVM_MINGW_ARCHIVE_X86_64="llvm-mingw-20251104-ucrt-x86_64.zip" if isWindows && isKnownToBeMingwBuild; then case "${CI_JOB_NAME}" in + *aarch64-llvm*) + mingw_dir="clangarm64" + mingw_archive="${LLVM_MINGW_ARCHIVE_AARCH64}" + arch="aarch64" + # Rustup defaults to AArch64 MSVC which has a hard time building Ring crate + # for citool. MSVC jobs install special Clang build to solve that, but here + # it would be an overkill. So we just use toolchain that doesn't have this + # issue. + rustup default stable-aarch64-pc-windows-gnullvm + ;; + *x86_64-llvm*) + mingw_dir="clang64" + mingw_archive="${LLVM_MINGW_ARCHIVE_X86_64}" + arch="x86_64" + ;; *i686*) - bits=32 + mingw_dir="mingw32" mingw_archive="${MINGW_ARCHIVE_32}" ;; *x86_64*) - bits=64 + mingw_dir="mingw64" mingw_archive="${MINGW_ARCHIVE_64}" ;; *aarch64*) - # aarch64 is a cross-compiled target. Use the x86_64 - # mingw, since that's the host architecture. - bits=64 - mingw_archive="${MINGW_ARCHIVE_64}" + echo "AArch64 Windows is not supported by GNU tools" + exit 1 ;; *) echo "src/ci/scripts/install-mingw.sh can't detect the builder's architecture" @@ -38,14 +53,32 @@ if isWindows && isKnownToBeMingwBuild; then msys2Path="c:/msys64" ciCommandAddPath "${msys2Path}/usr/bin" - mingw_dir="mingw${bits}" + case "${mingw_archive}" in + *.7z) + curl -o mingw.7z "${MIRRORS_BASE}/${mingw_archive}" + 7z x -y mingw.7z > /dev/null + ;; + *.zip) + curl -o mingw.zip "${MIRRORS_BASE}/${mingw_archive}" + unzip -q mingw.zip + mv llvm-mingw-20251104-ucrt-$arch $mingw_dir + # Temporary workaround: https://github.com/mstorsjo/llvm-mingw/issues/493 + mkdir -p $mingw_dir/bin + ln -s $arch-w64-windows-gnu.cfg $mingw_dir/bin/$arch-pc-windows-gnu.cfg + ;; + *) + echo "Unrecognized archive type" + exit 1 + ;; + esac - curl -o mingw.7z "${MIRRORS_BASE}/${mingw_archive}" - 7z x -y mingw.7z > /dev/null ciCommandAddPath "$(cygpath -m "$(pwd)/${mingw_dir}/bin")" - # Initialize mingw for the user. - # This should be done by github but isn't for some reason. - # (see https://github.com/actions/runner-images/issues/12600) - /c/msys64/usr/bin/bash -lc ' ' + # MSYS2 is not installed on AArch64 runners + if [[ "${CI_JOB_NAME}" != *aarch64-llvm* ]]; then + # Initialize mingw for the user. + # This should be done by github but isn't for some reason. + # (see https://github.com/actions/runner-images/issues/12600) + /c/msys64/usr/bin/bash -lc ' ' + fi fi diff --git a/src/etc/installer/msi/rust.wxs b/src/etc/installer/msi/rust.wxs index 64cceccc9758..43a436f1e695 100644 --- a/src/etc/installer/msi/rust.wxs +++ b/src/etc/installer/msi/rust.wxs @@ -38,6 +38,16 @@ + + + + + + + + + + @@ -61,6 +71,16 @@ + + + + + + + + + + From 95b031e7a8409b8299bb0f103636dc4d65e0f2aa Mon Sep 17 00:00:00 2001 From: Walnut <39544927+Walnut356@users.noreply.github.com> Date: Wed, 15 Oct 2025 20:23:11 -0500 Subject: [PATCH 152/194] align gnu enum output with msvc enum output --- src/etc/lldb_commands | 3 +- src/etc/lldb_lookup.py | 23 ++++++- src/etc/lldb_providers.py | 122 +++++++++++++++++++++++--------------- 3 files changed, 95 insertions(+), 53 deletions(-) diff --git a/src/etc/lldb_commands b/src/etc/lldb_commands index 508296c3a5ae..eff065d54565 100644 --- a/src/etc/lldb_commands +++ b/src/etc/lldb_commands @@ -1,6 +1,5 @@ # Forces test-compliant formatting to all other types type synthetic add -l lldb_lookup.synthetic_lookup -x ".*" --category Rust -type summary add -F _ -e -x -h "^.*$" --category Rust # Std String type synthetic add -l lldb_lookup.StdStringSyntheticProvider -x "^(alloc::([a-z_]+::)+)String$" --category Rust type summary add -F lldb_lookup.StdStringSummaryProvider -e -x -h "^(alloc::([a-z_]+::)+)String$" --category Rust @@ -66,6 +65,7 @@ type summary add -F lldb_lookup.summary_lookup -e -x -h "^(std::([a-z_]+::)+)Pa type synthetic add -l lldb_lookup.synthetic_lookup -x "^&(mut )?(std::([a-z_]+::)+)Path$" --category Rust type summary add -F lldb_lookup.summary_lookup -e -x -h "^&(mut )?(std::([a-z_]+::)+)Path$" --category Rust # Enum +# type summary add -F lldb_lookup.ClangEncodedEnumSummaryProvider -e -h "lldb_lookup.is_sum_type_enum" --recognizer-function --category Rust ## MSVC type synthetic add -l lldb_lookup.MSVCEnumSyntheticProvider -x "^enum2\$<.+>$" --category Rust type summary add -F lldb_lookup.MSVCEnumSummaryProvider -e -x -h "^enum2\$<.+>$" --category Rust @@ -74,6 +74,7 @@ type synthetic add -l lldb_lookup.synthetic_lookup -x "^enum2\$<.+>::.*$" --cate type summary add -F lldb_lookup.summary_lookup -e -x -h "^enum2\$<.+>::.*$" --category Rust # Tuple type synthetic add -l lldb_lookup.synthetic_lookup -x "^\(.*\)$" --category Rust +type summary add -F lldb_lookup.TupleSummaryProvider -e -x -h "^\(.*\)$" --category Rust ## MSVC type synthetic add -l lldb_lookup.MSVCTupleSyntheticProvider -x "^tuple\$<.+>$" --category Rust type summary add -F lldb_lookup.TupleSummaryProvider -e -x -h "^tuple\$<.+>$" --category Rust diff --git a/src/etc/lldb_lookup.py b/src/etc/lldb_lookup.py index f43d2c6a7252..2b90d4022f7f 100644 --- a/src/etc/lldb_lookup.py +++ b/src/etc/lldb_lookup.py @@ -10,9 +10,6 @@ def is_hashbrown_hashmap(hash_map: lldb.SBValue) -> bool: def classify_rust_type(type: lldb.SBType) -> str: - if type.IsPointerType(): - type = type.GetPointeeType() - type_class = type.GetTypeClass() if type_class == lldb.eTypeClassStruct: return classify_struct(type.name, type.fields) @@ -88,6 +85,26 @@ def synthetic_lookup(valobj: lldb.SBValue, _dict: LLDBOpaque) -> object: if rust_type == RustType.SINGLETON_ENUM: return synthetic_lookup(valobj.GetChildAtIndex(0), _dict) if rust_type == RustType.ENUM: + # this little trick lets us treat `synthetic_lookup` as a "recognizer function" for the enum + # summary providers, reducing the number of lookups we have to do. This is a huge time save + # because there's no way (via type name) to recognize sum-type enums on `*-gnu` targets. The + # alternative would be to shove every single type through `summary_lookup`, which is + # incredibly wasteful. Once these scripts are updated for LLDB 19.0 and we can use + # `--recognizer-function`, this hack will only be needed for backwards compatibility. + summary: lldb.SBTypeSummary = valobj.GetTypeSummary() + if ( + summary.summary_data is None + or summary.summary_data.strip() + != "lldb_lookup.ClangEncodedEnumSummaryProvider(valobj,internal_dict)" + ): + rust_category: lldb.SBTypeCategory = lldb.debugger.GetCategory("Rust") + rust_category.AddTypeSummary( + lldb.SBTypeNameSpecifier(valobj.GetTypeName()), + lldb.SBTypeSummary().CreateWithFunctionName( + "lldb_lookup.ClangEncodedEnumSummaryProvider" + ), + ) + return ClangEncodedEnumProvider(valobj, _dict) if rust_type == RustType.STD_VEC: return StdVecSyntheticProvider(valobj, _dict) diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 13c66ee8298b..582471622baa 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -1,7 +1,6 @@ from __future__ import annotations -import re import sys -from typing import List, TYPE_CHECKING, Generator +from typing import Generator, List, TYPE_CHECKING from lldb import ( SBData, @@ -12,6 +11,8 @@ from lldb import ( eFormatChar, ) +from rust_types import is_tuple_fields + if TYPE_CHECKING: from lldb import SBValue, SBType, SBTypeStaticField, SBTarget @@ -206,6 +207,34 @@ def resolve_msvc_template_arg(arg_name: str, target: SBTarget) -> SBType: return result +def StructSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: + # structs need the field name before the field value + output = ( + f"{valobj.GetChildAtIndex(i).GetName()}:{child}" + for i, child in enumerate(aggregate_field_summary(valobj, _dict)) + ) + + return "{" + ", ".join(output) + "}" + + +def TupleSummaryProvider(valobj: SBValue, _dict: LLDBOpaque): + return "(" + ", ".join(aggregate_field_summary(valobj, _dict)) + ")" + + +def aggregate_field_summary(valobj: SBValue, _dict) -> Generator[str, None, None]: + for i in range(0, valobj.GetNumChildren()): + child: SBValue = valobj.GetChildAtIndex(i) + summary = child.summary + if summary is None: + summary = child.value + if summary is None: + if is_tuple_fields(child): + summary = TupleSummaryProvider(child, _dict) + else: + summary = StructSummaryProvider(child, _dict) + yield summary + + def SizeSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: return "size=" + str(valobj.GetNumChildren()) @@ -454,49 +483,55 @@ class MSVCStrSyntheticProvider: return "&str" -def _getVariantName(variant) -> str: +def _getVariantName(variant: SBValue) -> str: """ Since the enum variant's type name is in the form `TheEnumName::TheVariantName$Variant`, we can extract `TheVariantName` from it for display purpose. """ s = variant.GetType().GetName() - match = re.search(r"::([^:]+)\$Variant$", s) - return match.group(1) if match else "" + if not s.endswith("$Variant"): + return "" + + # trim off path and "$Variant" + # len("$Variant") == 8 + return s.rsplit("::", 1)[1][:-8] class ClangEncodedEnumProvider: """Pretty-printer for 'clang-encoded' enums support implemented in LLDB""" + valobj: SBValue + variant: SBValue + value: SBValue + DISCRIMINANT_MEMBER_NAME = "$discr$" VALUE_MEMBER_NAME = "value" + __slots__ = ("valobj", "variant", "value") + def __init__(self, valobj: SBValue, _dict: LLDBOpaque): self.valobj = valobj self.update() def has_children(self) -> bool: - return True + return self.value.MightHaveChildren() def num_children(self) -> int: - return 1 + return self.value.GetNumChildren() - def get_child_index(self, _name: str) -> int: - return -1 + def get_child_index(self, name: str) -> int: + return self.value.GetIndexOfChildWithName(name) def get_child_at_index(self, index: int) -> SBValue: - if index == 0: - value = self.variant.GetChildMemberWithName( - ClangEncodedEnumProvider.VALUE_MEMBER_NAME - ) - return value.CreateChildAtOffset( - _getVariantName(self.variant), 0, value.GetType() - ) - return None + return self.value.GetChildAtIndex(index) def update(self): all_variants = self.valobj.GetChildAtIndex(0) index = self._getCurrentVariantIndex(all_variants) self.variant = all_variants.GetChildAtIndex(index) + self.value = self.variant.GetChildMemberWithName( + ClangEncodedEnumProvider.VALUE_MEMBER_NAME + ).GetSyntheticValue() def _getCurrentVariantIndex(self, all_variants: SBValue) -> int: default_index = 0 @@ -514,6 +549,23 @@ class ClangEncodedEnumProvider: return default_index +def ClangEncodedEnumSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: + enum_synth = ClangEncodedEnumProvider(valobj.GetNonSyntheticValue(), _dict) + variant = enum_synth.variant + name = _getVariantName(variant) + + if valobj.GetNumChildren() == 0: + return name + + child_name: str = valobj.GetChildAtIndex(0).name + if child_name == "0" or child_name == "__0": + # enum variant is a tuple struct + return name + TupleSummaryProvider(valobj, _dict) + else: + # enum variant is a regular struct + return name + StructSummaryProvider(valobj, _dict) + + class MSVCEnumSyntheticProvider: """ Synthetic provider for sum-type enums on MSVC. For a detailed explanation of the internals, @@ -522,12 +574,14 @@ class MSVCEnumSyntheticProvider: https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs """ + valobj: SBValue + variant: SBValue + value: SBValue + __slots__ = ["valobj", "variant", "value"] def __init__(self, valobj: SBValue, _dict: LLDBOpaque): self.valobj = valobj - self.variant: SBValue - self.value: SBValue self.update() def update(self): @@ -695,21 +749,6 @@ class MSVCEnumSyntheticProvider: return name -def StructSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: - output = [] - for i in range(valobj.GetNumChildren()): - child: SBValue = valobj.GetChildAtIndex(i) - summary = child.summary - if summary is None: - summary = child.value - if summary is None: - summary = StructSummaryProvider(child, _dict) - summary = child.GetName() + ":" + summary - output.append(summary) - - return "{" + ", ".join(output) + "}" - - def MSVCEnumSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: enum_synth = MSVCEnumSyntheticProvider(valobj.GetNonSyntheticValue(), _dict) variant_names: SBType = valobj.target.FindFirstType( @@ -826,21 +865,6 @@ class MSVCTupleSyntheticProvider: return "(" + name + ")" -def TupleSummaryProvider(valobj: SBValue, _dict: LLDBOpaque): - output: List[str] = [] - - for i in range(0, valobj.GetNumChildren()): - child: SBValue = valobj.GetChildAtIndex(i) - summary = child.summary - if summary is None: - summary = child.value - if summary is None: - summary = "{...}" - output.append(summary) - - return "(" + ", ".join(output) + ")" - - class StdVecSyntheticProvider: """Pretty-printer for alloc::vec::Vec From d3e4dd29a8c617e1c7bf74cf09452f76bd5f90eb Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Mon, 24 Nov 2025 11:20:03 +0900 Subject: [PATCH 153/194] Use `let...else` consistently in user-facing diagnostics --- compiler/rustc_hir_analysis/src/check/region.rs | 2 +- compiler/rustc_mir_build/messages.ftl | 2 +- compiler/rustc_parse/src/parser/stmt.rs | 2 +- tests/ui/empty/empty-never-array.stderr | 2 +- tests/ui/error-codes/E0005.stderr | 2 +- .../ui/feature-gates/feature-gate-exhaustive-patterns.stderr | 2 +- .../feature-gate-half-open-range-patterns-in-slices.stderr | 2 +- .../slice_pattern_syntax_problem1.stderr | 2 +- tests/ui/pattern/issue-106552.stderr | 2 +- .../pattern/usefulness/empty-types.exhaustive_patterns.stderr | 2 +- tests/ui/pattern/usefulness/empty-types.never_pats.stderr | 4 ++-- tests/ui/pattern/usefulness/empty-types.normal.stderr | 4 ++-- tests/ui/pattern/usefulness/issue-31561.stderr | 2 +- .../ui/pattern/usefulness/non-exhaustive-defined-here.stderr | 2 +- tests/ui/recursion/recursive-types-are-not-uninhabited.stderr | 2 +- tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr | 2 +- tests/ui/uninhabited/missing-if-let-or-let-else.rs | 4 ++-- tests/ui/uninhabited/missing-if-let-or-let-else.stderr | 4 ++-- .../uninhabited-irrefutable.exhaustive_patterns.stderr | 2 +- tests/ui/uninhabited/uninhabited-irrefutable.normal.stderr | 2 +- tests/ui/uninhabited/uninhabited-irrefutable.rs | 2 +- 21 files changed, 25 insertions(+), 25 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/region.rs b/compiler/rustc_hir_analysis/src/check/region.rs index 4e605ef62519..0e8cdc266f89 100644 --- a/compiler/rustc_hir_analysis/src/check/region.rs +++ b/compiler/rustc_hir_analysis/src/check/region.rs @@ -99,7 +99,7 @@ fn resolve_block<'tcx>( for (i, statement) in blk.stmts.iter().enumerate() { match statement.kind { hir::StmtKind::Let(LetStmt { els: Some(els), .. }) => { - // Let-else has a special lexical structure for variables. + // let-else has a special lexical structure for variables. // First we take a checkpoint of the current scope context here. let mut prev_cx = visitor.cx; diff --git a/compiler/rustc_mir_build/messages.ftl b/compiler/rustc_mir_build/messages.ftl index 4a741169443d..f65b99d5f99f 100644 --- a/compiler/rustc_mir_build/messages.ftl +++ b/compiler/rustc_mir_build/messages.ftl @@ -334,7 +334,7 @@ mir_build_suggest_if_let = you might want to use `if let` to ignore the {$count *[other] variants that aren't } matched -mir_build_suggest_let_else = you might want to use `let else` to handle the {$count -> +mir_build_suggest_let_else = you might want to use `let...else` to handle the {$count -> [one] variant that isn't *[other] variants that aren't } matched diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 3fe8971f3d6c..26393bf61a32 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -867,7 +867,7 @@ fn visit_expr(&mut self, node: &'a Expr) { if let_else || !if_let { err.span_suggestion_verbose( block_span.shrink_to_lo(), - format!("{alternatively}you might have meant to use `let else`"), + format!("{alternatively}you might have meant to use `let...else`"), "else ".to_string(), if let_else { Applicability::MachineApplicable diff --git a/tests/ui/empty/empty-never-array.stderr b/tests/ui/empty/empty-never-array.stderr index ee04ff162a4c..cd8a80e3d49d 100644 --- a/tests/ui/empty/empty-never-array.stderr +++ b/tests/ui/empty/empty-never-array.stderr @@ -14,7 +14,7 @@ LL | enum Helper { LL | T(T, [!; 0]), | - not covered = note: the matched value is of type `Helper` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Helper::U(u) = Helper::T(t, []) else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/error-codes/E0005.stderr b/tests/ui/error-codes/E0005.stderr index c643ee07a373..004812cad9f1 100644 --- a/tests/ui/error-codes/E0005.stderr +++ b/tests/ui/error-codes/E0005.stderr @@ -7,7 +7,7 @@ LL | let Some(y) = x; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `Option` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Some(y) = x else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr b/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr index b596da8463f2..614f382d6732 100644 --- a/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr +++ b/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr @@ -7,7 +7,7 @@ LL | let Ok(_x) = &foo(); = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `&Result` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Ok(_x) = &foo() else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/half-open-range-patterns/feature-gate-half-open-range-patterns-in-slices.stderr b/tests/ui/half-open-range-patterns/feature-gate-half-open-range-patterns-in-slices.stderr index 65903dbe12e5..9e13cf510e83 100644 --- a/tests/ui/half-open-range-patterns/feature-gate-half-open-range-patterns-in-slices.stderr +++ b/tests/ui/half-open-range-patterns/feature-gate-half-open-range-patterns-in-slices.stderr @@ -17,7 +17,7 @@ LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `[i32; 8]` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/half-open-range-patterns/slice_pattern_syntax_problem1.stderr b/tests/ui/half-open-range-patterns/slice_pattern_syntax_problem1.stderr index 17b65c1dae54..dec0fe1fe0d7 100644 --- a/tests/ui/half-open-range-patterns/slice_pattern_syntax_problem1.stderr +++ b/tests/ui/half-open-range-patterns/slice_pattern_syntax_problem1.stderr @@ -17,7 +17,7 @@ LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `[i32; 8]` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/pattern/issue-106552.stderr b/tests/ui/pattern/issue-106552.stderr index 6d9a989f182e..06f33ecf1066 100644 --- a/tests/ui/pattern/issue-106552.stderr +++ b/tests/ui/pattern/issue-106552.stderr @@ -25,7 +25,7 @@ LL | let x @ 5 = 6; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `i32` -help: you might want to use `let else` to handle the variants that aren't matched +help: you might want to use `let...else` to handle the variants that aren't matched | LL | let x @ 5 = 6 else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr index d241f417553f..a234ad435c97 100644 --- a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr @@ -152,7 +152,7 @@ LL | let Ok(_x) = res_u32_never.as_ref(); = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `Result<&u32, &!>` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr index ea63d7ba1afd..3fff1a3805c8 100644 --- a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr +++ b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr @@ -106,7 +106,7 @@ LL | let Ok(_x) = res_u32_never.as_ref(); = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `Result<&u32, &!>` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ @@ -120,7 +120,7 @@ LL | let Ok(_x) = &res_u32_never; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `&Result` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Ok(_x) = &res_u32_never else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/pattern/usefulness/empty-types.normal.stderr b/tests/ui/pattern/usefulness/empty-types.normal.stderr index a1a44e777442..28f9650557ef 100644 --- a/tests/ui/pattern/usefulness/empty-types.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-types.normal.stderr @@ -97,7 +97,7 @@ LL | let Ok(_x) = res_u32_never.as_ref(); = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `Result<&u32, &!>` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ @@ -111,7 +111,7 @@ LL | let Ok(_x) = &res_u32_never; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `&Result` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Ok(_x) = &res_u32_never else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/pattern/usefulness/issue-31561.stderr b/tests/ui/pattern/usefulness/issue-31561.stderr index 382b2337ffab..389c1126b984 100644 --- a/tests/ui/pattern/usefulness/issue-31561.stderr +++ b/tests/ui/pattern/usefulness/issue-31561.stderr @@ -17,7 +17,7 @@ LL | Bar, LL | Baz | --- not covered = note: the matched value is of type `Thing` -help: you might want to use `let else` to handle the variants that aren't matched +help: you might want to use `let...else` to handle the variants that aren't matched | LL | let Thing::Foo(y) = Thing::Foo(1) else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr index 48d7a636055d..d31510d66e0c 100644 --- a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr +++ b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr @@ -183,7 +183,7 @@ LL | enum Opt { LL | None, | ---- not covered = note: the matched value is of type `Opt` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Opt::Some(ref _x) = e else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/recursion/recursive-types-are-not-uninhabited.stderr b/tests/ui/recursion/recursive-types-are-not-uninhabited.stderr index 35d436a1413e..cd78c0f0bb45 100644 --- a/tests/ui/recursion/recursive-types-are-not-uninhabited.stderr +++ b/tests/ui/recursion/recursive-types-are-not-uninhabited.stderr @@ -7,7 +7,7 @@ LL | let Ok(x) = res; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `Result>` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Ok(x) = res else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr index c2c9ac15ab22..f8bf6f8cb28b 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/omitted-patterns.stderr @@ -138,7 +138,7 @@ LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html = note: the matched value is of type `NonExhaustiveEnum` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/uninhabited/missing-if-let-or-let-else.rs b/tests/ui/uninhabited/missing-if-let-or-let-else.rs index 51fedb797562..c8cc672a82aa 100644 --- a/tests/ui/uninhabited/missing-if-let-or-let-else.rs +++ b/tests/ui/uninhabited/missing-if-let-or-let-else.rs @@ -6,14 +6,14 @@ fn a() { } fn b() { let Some(x) = foo() { //~ ERROR expected one of - //~^ HELP you might have meant to use `let else` + //~^ HELP you might have meant to use `let...else` return; } } fn c() { let Some(x) = foo() { //~ ERROR expected one of //~^ HELP you might have meant to use `if let` - //~| HELP alternatively, you might have meant to use `let else` + //~| HELP alternatively, you might have meant to use `let...else` // The parser check happens pre-macro-expansion, so we don't know for sure. println!("{x}"); } diff --git a/tests/ui/uninhabited/missing-if-let-or-let-else.stderr b/tests/ui/uninhabited/missing-if-let-or-let-else.stderr index 4b78a0fa16e8..f13147dd7fc5 100644 --- a/tests/ui/uninhabited/missing-if-let-or-let-else.stderr +++ b/tests/ui/uninhabited/missing-if-let-or-let-else.stderr @@ -15,7 +15,7 @@ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `{` LL | let Some(x) = foo() { | ^ expected one of `.`, `;`, `?`, `else`, or an operator | -help: you might have meant to use `let else` +help: you might have meant to use `let...else` | LL | let Some(x) = foo() else { | ++++ @@ -30,7 +30,7 @@ help: you might have meant to use `if let` | LL | if let Some(x) = foo() { | ++ -help: alternatively, you might have meant to use `let else` +help: alternatively, you might have meant to use `let...else` | LL | let Some(x) = foo() else { | ++++ diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr b/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr index 0e87f14aa14a..a4270c29ff35 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr +++ b/tests/ui/uninhabited/uninhabited-irrefutable.exhaustive_patterns.stderr @@ -16,7 +16,7 @@ LL | A(foo::SecretlyEmpty), | - not covered = note: pattern `Foo::A(_)` is currently uninhabited, but this variant contains private fields which may become inhabited in the future = note: the matched value is of type `Foo` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Foo::D(_y, _z) = x else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.normal.stderr b/tests/ui/uninhabited/uninhabited-irrefutable.normal.stderr index 0e87f14aa14a..a4270c29ff35 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.normal.stderr +++ b/tests/ui/uninhabited/uninhabited-irrefutable.normal.stderr @@ -16,7 +16,7 @@ LL | A(foo::SecretlyEmpty), | - not covered = note: pattern `Foo::A(_)` is currently uninhabited, but this variant contains private fields which may become inhabited in the future = note: the matched value is of type `Foo` -help: you might want to use `let else` to handle the variant that isn't matched +help: you might want to use `let...else` to handle the variant that isn't matched | LL | let Foo::D(_y, _z) = x else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.rs b/tests/ui/uninhabited/uninhabited-irrefutable.rs index 3f7414e596bf..9f4731e6e71a 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.rs +++ b/tests/ui/uninhabited/uninhabited-irrefutable.rs @@ -34,5 +34,5 @@ fn main() { //~| NOTE for more information //~| NOTE pattern `Foo::A(_)` is currently uninhabited //~| NOTE the matched value is of type `Foo` - //~| HELP you might want to use `let else` + //~| HELP you might want to use `let...else` } From af1c2b277d534679d7defdc0816a30b58d7a7ea9 Mon Sep 17 00:00:00 2001 From: Walnut <39544927+Walnut356@users.noreply.github.com> Date: Mon, 24 Nov 2025 00:17:53 -0600 Subject: [PATCH 154/194] update tests --- tests/debuginfo/basic-types-globals.rs | 2 +- tests/debuginfo/borrowed-enum.rs | 6 +++--- tests/debuginfo/c-style-enum-in-composite.rs | 2 +- tests/debuginfo/coroutine-objects.rs | 2 +- tests/debuginfo/enum-thinlto.rs | 2 +- .../debuginfo/generic-method-on-generic-struct.rs | 4 ++-- tests/debuginfo/issue-57822.rs | 2 +- tests/debuginfo/method-on-generic-struct.rs | 4 ++-- tests/debuginfo/msvc-pretty-enums.rs | 1 + tests/debuginfo/option-like-enum.rs | 10 +++++----- tests/debuginfo/pretty-std-collections.rs | 2 +- tests/debuginfo/strings-and-strs.rs | 5 ++--- tests/debuginfo/struct-in-enum.rs | 7 ++++--- tests/debuginfo/struct-style-enum.rs | 8 ++++---- tests/debuginfo/tuple-in-tuple.rs | 14 +++++++------- tests/debuginfo/tuple-style-enum.rs | 8 ++++---- tests/debuginfo/union-smoke.rs | 4 ++-- tests/debuginfo/unique-enum.rs | 6 +++--- tests/debuginfo/vec-slices.rs | 2 +- 19 files changed, 46 insertions(+), 45 deletions(-) diff --git a/tests/debuginfo/basic-types-globals.rs b/tests/debuginfo/basic-types-globals.rs index 6e4150873832..b56a7108121f 100644 --- a/tests/debuginfo/basic-types-globals.rs +++ b/tests/debuginfo/basic-types-globals.rs @@ -13,7 +13,7 @@ // lldb-command:v I // lldb-check: ::I = -1 // lldb-command:v --format=d C -// lldb-check: ::C = 97 +// lldb-check: ::C = 97 U+0x00000061 U'a' // lldb-command:v --format=d I8 // lldb-check: ::I8 = 68 // lldb-command:v I16 diff --git a/tests/debuginfo/borrowed-enum.rs b/tests/debuginfo/borrowed-enum.rs index 48dce139a2f3..f3769172558b 100644 --- a/tests/debuginfo/borrowed-enum.rs +++ b/tests/debuginfo/borrowed-enum.rs @@ -23,11 +23,11 @@ // lldb-command:run // lldb-command:v *the_a_ref -// lldb-check:(borrowed_enum::ABC) *the_a_ref = { TheA = { x = 0 y = 8970181431921507452 } } +// lldb-check:(borrowed_enum::ABC) *the_a_ref = TheA{x:0, y:8970181431921507452} { x = 0 y = 8970181431921507452 } // lldb-command:v *the_b_ref -// lldb-check:(borrowed_enum::ABC) *the_b_ref = { TheB = { 0 = 0 1 = 286331153 2 = 286331153 } } +// lldb-check:(borrowed_enum::ABC) *the_b_ref = TheB(0, 286331153, 286331153) { 0 = 0 1 = 286331153 2 = 286331153 } // lldb-command:v *univariant_ref -// lldb-check:(borrowed_enum::Univariant) *univariant_ref = { TheOnlyCase = { 0 = 4820353753753434 } } +// lldb-check:(borrowed_enum::Univariant) *univariant_ref = TheOnlyCase(4820353753753434) { 0 = 4820353753753434 } #![allow(unused_variables)] diff --git a/tests/debuginfo/c-style-enum-in-composite.rs b/tests/debuginfo/c-style-enum-in-composite.rs index dd5e4f8b65d7..137cb2656fc5 100644 --- a/tests/debuginfo/c-style-enum-in-composite.rs +++ b/tests/debuginfo/c-style-enum-in-composite.rs @@ -35,7 +35,7 @@ // lldb-check:[...] { 0 = 0 1 = OneHundred } // lldb-command:v tuple_padding_at_end -// lldb-check:[...] { 0 = { 0 = 1 1 = OneThousand } 1 = 2 } +// lldb-check:[...] ((1, OneThousand), 2) { 0 = (1, OneThousand) { 0 = 1 1 = OneThousand } 1 = 2 } // lldb-command:v tuple_different_enums // lldb-check:[...] { 0 = OneThousand 1 = MountainView 2 = OneMillion 3 = Vienna } diff --git a/tests/debuginfo/coroutine-objects.rs b/tests/debuginfo/coroutine-objects.rs index f1165de4bfaa..b9d015ef6d1b 100644 --- a/tests/debuginfo/coroutine-objects.rs +++ b/tests/debuginfo/coroutine-objects.rs @@ -27,7 +27,7 @@ // lldb-command:run // lldb-command:v b -// lldb-check:(coroutine_objects::main::{coroutine_env#0}) b = { value = { _ref__a = 0x[...] } $discr$ = [...] } +// lldb-check:(coroutine_objects::main::{coroutine_env#0}) b = 0{_ref__a:0x[...]} { _ref__a = 0x[...] } // === CDB TESTS =================================================================================== diff --git a/tests/debuginfo/enum-thinlto.rs b/tests/debuginfo/enum-thinlto.rs index 789755438a6b..9b77b1d9ba4a 100644 --- a/tests/debuginfo/enum-thinlto.rs +++ b/tests/debuginfo/enum-thinlto.rs @@ -15,7 +15,7 @@ // lldb-command:run // lldb-command:v *abc -// lldb-check:(enum_thinlto::ABC) *abc = { value = { x = 0 y = 8970181431921507452 } $discr$ = 0 } +// lldb-check:(enum_thinlto::ABC) *abc = TheA{x:0, y:8970181431921507452} { x = 0 y = 8970181431921507452 } #![allow(unused_variables)] diff --git a/tests/debuginfo/generic-method-on-generic-struct.rs b/tests/debuginfo/generic-method-on-generic-struct.rs index c549a1415365..9c1d87ac8c87 100644 --- a/tests/debuginfo/generic-method-on-generic-struct.rs +++ b/tests/debuginfo/generic-method-on-generic-struct.rs @@ -58,7 +58,7 @@ // STACK BY REF // lldb-command:v *self -// lldb-check:[...] { x = { 0 = 8888 1 = -8888 } } +// lldb-check:[...] { x = (8888, -8888) { 0 = 8888 1 = -8888 } } // lldb-command:v arg1 // lldb-check:[...] -1 // lldb-command:v arg2 @@ -67,7 +67,7 @@ // STACK BY VAL // lldb-command:v self -// lldb-check:[...] { x = { 0 = 8888 1 = -8888 } } +// lldb-check:[...] { x = (8888, -8888) { 0 = 8888 1 = -8888 } } // lldb-command:v arg1 // lldb-check:[...] -3 // lldb-command:v arg2 diff --git a/tests/debuginfo/issue-57822.rs b/tests/debuginfo/issue-57822.rs index 59c0759737dd..aa829dfb21ad 100644 --- a/tests/debuginfo/issue-57822.rs +++ b/tests/debuginfo/issue-57822.rs @@ -24,7 +24,7 @@ // lldb-check:(issue_57822::main::{closure_env#1}) g = { f = { x = 1 } } // lldb-command:v b -// lldb-check:(issue_57822::main::{coroutine_env#3}) b = { value = { a = { value = { y = 2 } $discr$ = '\x02' } } $discr$ = '\x02' } +// lldb-check:(issue_57822::main::{coroutine_env#3}) b = 2{a:2{y:2}} { a = 2{y:2} { y = 2 } } #![feature(coroutines, coroutine_trait, stmt_expr_attributes)] diff --git a/tests/debuginfo/method-on-generic-struct.rs b/tests/debuginfo/method-on-generic-struct.rs index b9627f27b912..01e7ffc749da 100644 --- a/tests/debuginfo/method-on-generic-struct.rs +++ b/tests/debuginfo/method-on-generic-struct.rs @@ -58,7 +58,7 @@ // STACK BY REF // lldb-command:v *self -// lldb-check:[...]Struct<(u32, i32)>) *self = { x = { 0 = 8888 1 = -8888 } } +// lldb-check:[...]Struct<(u32, i32)>) *self = { x = (8888, -8888) { 0 = 8888 1 = -8888 } } // lldb-command:v arg1 // lldb-check:[...] -1 // lldb-command:v arg2 @@ -67,7 +67,7 @@ // STACK BY VAL // lldb-command:v self -// lldb-check:[...]Struct<(u32, i32)>) self = { x = { 0 = 8888 1 = -8888 } } +// lldb-check:[...]Struct<(u32, i32)>) self = { x = (8888, -8888) { 0 = 8888 1 = -8888 } } // lldb-command:v arg1 // lldb-check:[...] -3 // lldb-command:v arg2 diff --git a/tests/debuginfo/msvc-pretty-enums.rs b/tests/debuginfo/msvc-pretty-enums.rs index aa6629ef1e1b..7d9f867efcdd 100644 --- a/tests/debuginfo/msvc-pretty-enums.rs +++ b/tests/debuginfo/msvc-pretty-enums.rs @@ -1,3 +1,4 @@ +//@ only-msvc //@ min-lldb-version: 1800 //@ ignore-gdb //@ compile-flags:-g diff --git a/tests/debuginfo/option-like-enum.rs b/tests/debuginfo/option-like-enum.rs index 5a55b143fbbd..0e419978d62e 100644 --- a/tests/debuginfo/option-like-enum.rs +++ b/tests/debuginfo/option-like-enum.rs @@ -40,31 +40,31 @@ // lldb-command:run // lldb-command:v some -// lldb-check:[...] Some(&0x[...]) +// lldb-check:[...] Some(0x[...]) { 0 = 0x[...] } // lldb-command:v none // lldb-check:[...] None // lldb-command:v full -// lldb-check:[...] Full(454545, &0x[...], 9988) +// lldb-check:[...] Full(454545, 0x[...], 9988) { 0 = 454545 1 = 0x[...] 2 = 9988 } // lldb-command:v empty // lldb-check:[...] Empty // lldb-command:v droid -// lldb-check:[...] Droid { id: 675675, range: 10000001, internals: &0x[...] } +// lldb-check:[...] Droid{id:675675, range:10000001, internals:0x[...]} { id = 675675 range = 10000001 internals = 0x[...] } // lldb-command:v void_droid // lldb-check:[...] Void // lldb-command:v some_str -// lldb-check:[...] Some("abc") +// lldb-check:[...] Some("abc") [...] // lldb-command:v none_str // lldb-check:[...] None // lldb-command:v nested_non_zero_yep -// lldb-check:[...] Yep(10.5, NestedNonZeroField { a: 10, b: 20, c: &[...] }) +// lldb-check:[...] Yep(10.5, {a:10, b:20, c:[...]}) { 0 = 10.5 1 = { a = 10 b = 20 c = [...] } } // lldb-command:v nested_non_zero_nope // lldb-check:[...] Nope diff --git a/tests/debuginfo/pretty-std-collections.rs b/tests/debuginfo/pretty-std-collections.rs index 568ca0fd2303..3592122375dd 100644 --- a/tests/debuginfo/pretty-std-collections.rs +++ b/tests/debuginfo/pretty-std-collections.rs @@ -59,7 +59,7 @@ // lldb-check:[...] size=7 { [0] = 2 [1] = 3 [2] = 4 [3] = 5 [4] = 6 [5] = 7 [6] = 8 } // lldb-command:v hash_map -// lldb-check:[...] size=4 { [0] = { 0 = 1 1 = 10 } [1] = { 0 = 2 1 = 20 } [2] = { 0 = 3 1 = 30 } [3] = { 0 = 4 1 = 40 } } +// lldb-check:[...] size=4 { [0] = (1, 10) { 0 = 1 1 = 10 } [1] = (2, 20) { 0 = 2 1 = 20 } [2] = (3, 30) { 0 = 3 1 = 30 } [3] = (4, 40) { 0 = 4 1 = 40 } } // lldb-command:v hash_set // lldb-check:[...] size=4 { [0] = 1 [1] = 2 [2] = 3 [3] = 4 } diff --git a/tests/debuginfo/strings-and-strs.rs b/tests/debuginfo/strings-and-strs.rs index 392cf697e110..baeebda26a90 100644 --- a/tests/debuginfo/strings-and-strs.rs +++ b/tests/debuginfo/strings-and-strs.rs @@ -31,15 +31,14 @@ // lldb-check:(&str) plain_str = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } // lldb-command:v str_in_struct -// lldb-check:((&str, &str)) str_in_tuple = { 0 = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } 1 = "World" { [0] = 'W' [1] = 'o' [2] = 'r' [3] = 'l' [4] = 'd' } } +// lldb-check:(strings_and_strs::Foo) str_in_struct = { inner = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } // lldb-command:v str_in_tuple -// lldb-check:((&str, &str)) str_in_tuple = { 0 = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } 1 = "World" { [0] = 'W' [1] = 'o' [2] = 'r' [3] = 'l' [4] = 'd' } } +// lldb-check:((&str, &str)) str_in_tuple = ("Hello", "World") { 0 = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } 1 = "World" { [0] = 'W' [1] = 'o' [2] = 'r' [3] = 'l' [4] = 'd' } } // lldb-command:v str_in_rc // lldb-check:(alloc::rc::Rc<&str, alloc::alloc::Global>) str_in_rc = strong=1, weak=0 { value = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } - #![allow(unused_variables)] pub struct Foo<'a> { diff --git a/tests/debuginfo/struct-in-enum.rs b/tests/debuginfo/struct-in-enum.rs index bd61e7cb1437..640066b8d0b1 100644 --- a/tests/debuginfo/struct-in-enum.rs +++ b/tests/debuginfo/struct-in-enum.rs @@ -24,12 +24,13 @@ // lldb-command:run // lldb-command:v case1 -// lldb-check:[...] Case1(0, Struct { x: 2088533116, y: 2088533116, z: 31868 }) +// lldb-check:[...] Case1(0, {x:2088533116, y:2088533116, z:31868}) { 0 = 0 1 = { x = 2088533116 y = 2088533116 z = 31868 } } + // lldb-command:v case2 -// lldb-check:[...] Case2(0, 1229782938247303441, 4369) +// lldb-check:[...] Case2(0, 1229782938247303441, 4369) { 0 = 0 1 = 1229782938247303441 2 = 4369 } // lldb-command:v univariant -// lldb-check:[...] TheOnlyCase(Struct { x: 123, y: 456, z: 789 }) +// lldb-check:[...] TheOnlyCase({x:123, y:456, z:789}) { 0 = { x = 123 y = 456 z = 789 } } #![allow(unused_variables)] diff --git a/tests/debuginfo/struct-style-enum.rs b/tests/debuginfo/struct-style-enum.rs index 48ef97896ac1..4bbd87925704 100644 --- a/tests/debuginfo/struct-style-enum.rs +++ b/tests/debuginfo/struct-style-enum.rs @@ -26,16 +26,16 @@ // lldb-command:run // lldb-command:v case1 -// lldb-check:(struct_style_enum::Regular) case1 = { value = { a = 0 b = 31868 c = 31868 d = 31868 e = 31868 } $discr$ = 0 } +// lldb-check:(struct_style_enum::Regular) case1 = Case1{a:0, b:31868, c:31868, d:31868, e:31868} { a = 0 b = 31868 c = 31868 d = 31868 e = 31868 } // lldb-command:v case2 -// lldb-check:(struct_style_enum::Regular) case2 = { value = { a = 0 b = 286331153 c = 286331153 } $discr$ = 1 } +// lldb-check:(struct_style_enum::Regular) case2 = Case2{a:0, b:286331153, c:286331153} { a = 0 b = 286331153 c = 286331153 } // lldb-command:v case3 -// lldb-check:(struct_style_enum::Regular) case3 = { value = { a = 0 b = 6438275382588823897 } $discr$ = 2 } +// lldb-check:(struct_style_enum::Regular) case3 = Case3{a:0, b:6438275382588823897} { a = 0 b = 6438275382588823897 } // lldb-command:v univariant -// lldb-check:(struct_style_enum::Univariant) univariant = { value = { a = -1 } } +// lldb-check:(struct_style_enum::Univariant) univariant = TheOnlyCase{a:-1} { a = -1 } #![allow(unused_variables)] diff --git a/tests/debuginfo/tuple-in-tuple.rs b/tests/debuginfo/tuple-in-tuple.rs index e906cbed67db..40e88f1b2084 100644 --- a/tests/debuginfo/tuple-in-tuple.rs +++ b/tests/debuginfo/tuple-in-tuple.rs @@ -29,21 +29,21 @@ // lldb-command:run // lldb-command:v no_padding1 -// lldb-check:[...] { 0 = { 0 = 0 1 = 1 } 1 = 2 2 = 3 } +// lldb-check:[...] ((0, 1), 2, 3) { 0 = (0, 1) { 0 = 0 1 = 1 } 1 = 2 2 = 3 } // lldb-command:v no_padding2 -// lldb-check:[...] { 0 = 4 1 = { 0 = 5 1 = 6 } 2 = 7 } +// lldb-check:[...] (4, (5, 6), 7) { 0 = 4 1 = (5, 6) { 0 = 5 1 = 6 } 2 = 7 } // lldb-command:v no_padding3 -// lldb-check:[...] { 0 = 8 1 = 9 2 = { 0 = 10 1 = 11 } } +// lldb-check:[...] (8, 9, (10, 11)) { 0 = 8 1 = 9 2 = (10, 11) { 0 = 10 1 = 11 } } // lldb-command:v internal_padding1 -// lldb-check:[...] { 0 = 12 1 = { 0 = 13 1 = 14 } } +// lldb-check:[...] (12, (13, 14)) { 0 = 12 1 = (13, 14) { 0 = 13 1 = 14 } } // lldb-command:v internal_padding2 -// lldb-check:[...] { 0 = 15 1 = { 0 = 16 1 = 17 } } +// lldb-check:[...] (15, (16, 17)) { 0 = 15 1 = (16, 17) { 0 = 16 1 = 17 } } // lldb-command:v padding_at_end1 -// lldb-check:[...] { 0 = 18 1 = { 0 = 19 1 = 20 } } +// lldb-check:[...] (18, (19, 20)) { 0 = 18 1 = (19, 20) { 0 = 19 1 = 20 } } // lldb-command:v padding_at_end2 -// lldb-check:[...] { 0 = { 0 = 21 1 = 22 } 1 = 23 } +// lldb-check:[...] ((21, 22), 23) { 0 = (21, 22) { 0 = 21 1 = 22 } 1 = 23 } // === CDB TESTS ================================================================================== diff --git a/tests/debuginfo/tuple-style-enum.rs b/tests/debuginfo/tuple-style-enum.rs index a452c57b3042..6568a2f70ab3 100644 --- a/tests/debuginfo/tuple-style-enum.rs +++ b/tests/debuginfo/tuple-style-enum.rs @@ -27,16 +27,16 @@ // lldb-command:run // lldb-command:v case1 -// lldb-check:(tuple_style_enum::Regular) case1 = { value = { 0 = 0 1 = 31868 2 = 31868 3 = 31868 4 = 31868 } $discr$ = 0 } +// lldb-check:(tuple_style_enum::Regular) case1 = Case1(0, 31868, 31868, 31868, 31868) { 0 = 0 1 = 31868 2 = 31868 3 = 31868 4 = 31868 } // lldb-command:v case2 -// lldb-check:(tuple_style_enum::Regular) case2 = { value = { 0 = 0 1 = 286331153 2 = 286331153 } $discr$ = 1 } +// lldb-check:(tuple_style_enum::Regular) case2 = Case2(0, 286331153, 286331153) { 0 = 0 1 = 286331153 2 = 286331153 } // lldb-command:v case3 -// lldb-check:(tuple_style_enum::Regular) case3 = { value = { 0 = 0 1 = 6438275382588823897 } $discr$ = 2 } +// lldb-check:(tuple_style_enum::Regular) case3 = Case3(0, 6438275382588823897) { 0 = 0 1 = 6438275382588823897 } // lldb-command:v univariant -// lldb-check:(tuple_style_enum::Univariant) univariant = { value = { 0 = -1 } } +// lldb-check:(tuple_style_enum::Univariant) univariant = TheOnlyCase(-1) { 0 = -1 } #![allow(unused_variables)] diff --git a/tests/debuginfo/union-smoke.rs b/tests/debuginfo/union-smoke.rs index beaf4c8fa8fe..be6a9d578646 100644 --- a/tests/debuginfo/union-smoke.rs +++ b/tests/debuginfo/union-smoke.rs @@ -14,10 +14,10 @@ // lldb-command:run // lldb-command:v u -// lldb-check:[...] { a = { 0 = '\x02' 1 = '\x02' } b = 514 } +// lldb-check:[...] { a = ('\x02', '\x02') { 0 = '\x02' 1 = '\x02' } b = 514 } // lldb-command:print union_smoke::SU -// lldb-check:[...] { a = { 0 = '\x01' 1 = '\x01' } b = 257 } +// lldb-check:[...] { a = ('\x01', '\x01') { 0 = '\x01' 1 = '\x01' } b = 257 } #![allow(unused)] diff --git a/tests/debuginfo/unique-enum.rs b/tests/debuginfo/unique-enum.rs index a9b928456e93..6a742f9378df 100644 --- a/tests/debuginfo/unique-enum.rs +++ b/tests/debuginfo/unique-enum.rs @@ -23,13 +23,13 @@ // lldb-command:run // lldb-command:v *the_a -// lldb-check:(unique_enum::ABC) *the_a = { value = { x = 0 y = 8970181431921507452 } $discr$ = 0 } +// lldb-check:(unique_enum::ABC) *the_a = TheA{x:0, y:8970181431921507452} { x = 0 y = 8970181431921507452 } // lldb-command:v *the_b -// lldb-check:(unique_enum::ABC) *the_b = { value = { 0 = 0 1 = 286331153 2 = 286331153 } $discr$ = 1 } +// lldb-check:(unique_enum::ABC) *the_b = TheB(0, 286331153, 286331153) { 0 = 0 1 = 286331153 2 = 286331153 } // lldb-command:v *univariant -// lldb-check:(unique_enum::Univariant) *univariant = { value = { 0 = 123234 } } +// lldb-check:(unique_enum::Univariant) *univariant = TheOnlyCase(123234) { 0 = 123234 } #![allow(unused_variables)] diff --git a/tests/debuginfo/vec-slices.rs b/tests/debuginfo/vec-slices.rs index 7ed6b0cb6640..fdfc7019add6 100644 --- a/tests/debuginfo/vec-slices.rs +++ b/tests/debuginfo/vec-slices.rs @@ -67,7 +67,7 @@ // lldb-check:[...] size=2 { [0] = 3 [1] = 4 } // lldb-command:v padded_tuple -// lldb-check:[...] size=2 { [0] = { 0 = 6 1 = 7 } [1] = { 0 = 8 1 = 9 } } +// lldb-check:[...] size=2 { [0] = (6, 7) { 0 = 6 1 = 7 } [1] = (8, 9) { 0 = 8 1 = 9 } } // lldb-command:v padded_struct // lldb-check:[...] size=2 { [0] = { x = 10 y = 11 z = 12 } [1] = { x = 13 y = 14 z = 15 } } From eb72e6764e30003fab1d46ecc22e4938b060aaed Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Mon, 24 Nov 2025 16:06:15 +0900 Subject: [PATCH 155/194] Fix None handling for simplify_type in for_each_relevant_impl --- compiler/rustc_middle/src/ty/context.rs | 8 ++++---- .../traits/dispatch-from-dyn-blanket-impl.rs | 10 ++++++++++ .../dispatch-from-dyn-blanket-impl.stderr | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 tests/ui/traits/dispatch-from-dyn-blanket-impl.rs create mode 100644 tests/ui/traits/dispatch-from-dyn-blanket-impl.stderr diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 876297d3e407..3092c6e76c03 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -589,13 +589,13 @@ fn for_each_relevant_impl( | ty::Never | ty::Tuple(_) | ty::UnsafeBinder(_) => { - let simp = ty::fast_reject::simplify_type( + if let Some(simp) = ty::fast_reject::simplify_type( tcx, self_ty, ty::fast_reject::TreatParams::AsRigid, - ) - .unwrap(); - consider_impls_for_simplified_type(simp); + ) { + consider_impls_for_simplified_type(simp); + } } // HACK: For integer and float variables we have to manually look at all impls diff --git a/tests/ui/traits/dispatch-from-dyn-blanket-impl.rs b/tests/ui/traits/dispatch-from-dyn-blanket-impl.rs new file mode 100644 index 000000000000..4e0e7ca9793f --- /dev/null +++ b/tests/ui/traits/dispatch-from-dyn-blanket-impl.rs @@ -0,0 +1,10 @@ +// Test that blanket impl of DispatchFromDyn is rejected. +// regression test for issue + +#![feature(dispatch_from_dyn)] + +impl std::ops::DispatchFromDyn for T {} +//~^ ERROR type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) +//~| ERROR the trait `DispatchFromDyn` may only be implemented for a coercion between structures + +fn main() {} diff --git a/tests/ui/traits/dispatch-from-dyn-blanket-impl.stderr b/tests/ui/traits/dispatch-from-dyn-blanket-impl.stderr new file mode 100644 index 000000000000..69f360817805 --- /dev/null +++ b/tests/ui/traits/dispatch-from-dyn-blanket-impl.stderr @@ -0,0 +1,19 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/dispatch-from-dyn-blanket-impl.rs:6:6 + | +LL | impl std::ops::DispatchFromDyn for T {} + | ^ type parameter `T` must be used as the type parameter for some local type + | + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local + = note: only traits defined in the current crate can be implemented for a type parameter + +error[E0377]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures + --> $DIR/dispatch-from-dyn-blanket-impl.rs:6:1 + | +LL | impl std::ops::DispatchFromDyn for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0210, E0377. +For more information about an error, try `rustc --explain E0210`. From 522e47fd602a1622570fe38d50fa889e8e5f0a86 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 24 Nov 2025 01:37:55 +0100 Subject: [PATCH 156/194] miri: use tikv-jemalloc-sys from sysroot This allows LTO to work when compiling jemalloc, which should yield a small performance boost, and makes miri's behaviour here match clippy and rustdoc. --- Cargo.lock | 1 - src/bootstrap/src/core/build_steps/tool.rs | 5 +++++ src/tools/miri/Cargo.toml | 8 +------- src/tools/miri/src/bin/miri.rs | 10 +++++++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 04397408099e..4d8d5111583e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2486,7 +2486,6 @@ dependencies = [ "serde_json", "smallvec", "tempfile", - "tikv-jemalloc-sys", "ui_test", ] diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 0d765018d77b..535e6a510ca6 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -1567,6 +1567,11 @@ fn build_extended_rustc_tool( tool_name: "miri", stable: false, add_bins_to_sysroot: ["miri"], + add_features: |builder, target, features| { + if builder.config.jemalloc(target) { + features.push("jemalloc".to_string()); + } + }, // Always compile also tests when building miri. Otherwise feature unification can cause rebuilds between building and testing miri. cargo_args: &["--all-targets"], }); diff --git a/src/tools/miri/Cargo.toml b/src/tools/miri/Cargo.toml index 611e549930a9..2235203e2d79 100644 --- a/src/tools/miri/Cargo.toml +++ b/src/tools/miri/Cargo.toml @@ -29,13 +29,6 @@ directories = "6" bitflags = "2.6" serde_json = { version = "1.0", optional = true } -# Copied from `compiler/rustc/Cargo.toml`. -# 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'] - [target.'cfg(unix)'.dependencies] libc = "0.2" # native-lib dependencies @@ -75,6 +68,7 @@ stack-cache = [] expensive-consistency-checks = ["stack-cache"] tracing = ["serde_json"] native-lib = ["dep:libffi", "dep:libloading", "dep:capstone", "dep:ipc-channel", "dep:nix", "dep:serde"] +jemalloc = [] [lints.rust.unexpected_cfgs] level = "warn" diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index d7c5cb68e4f0..9f1ff238359a 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -21,9 +21,13 @@ 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 _; +/// and https://github.com/rust-lang/rust/pull/146627 for why we need this. +/// +/// FIXME(madsmtm): This is loaded from the sysroot that was built with the other `rustc` crates +/// above, instead of via Cargo as you'd normally do. This is currently needed for LTO due to +/// https://github.com/rust-lang/cc-rs/issues/1613. +#[cfg(feature = "jemalloc")] +extern crate tikv_jemalloc_sys as _; mod log; From c524ed710d1573f8f5c92281fc2efd1d29918c56 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 22 Nov 2025 12:45:31 +0100 Subject: [PATCH 157/194] Make more functions return `fmt::Result` and reduce number of `.unwrap()` calls --- src/librustdoc/html/format.rs | 6 +- src/librustdoc/html/length_limit.rs | 4 +- src/librustdoc/html/render/mod.rs | 85 ++++++++++++------------ src/librustdoc/html/render/print_item.rs | 62 +++++++++-------- 4 files changed, 78 insertions(+), 79 deletions(-) diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index dd91cec531f5..eee13ff2b0dc 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -1252,9 +1252,9 @@ fn write_str(&mut self, s: &str) -> fmt::Result { impl Display for Indent { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (0..self.0).for_each(|_| { - f.write_char(' ').unwrap(); - }); + for _ in 0..self.0 { + f.write_char(' ')?; + } Ok(()) } } diff --git a/src/librustdoc/html/length_limit.rs b/src/librustdoc/html/length_limit.rs index fdb1ddc1f531..f786215a93be 100644 --- a/src/librustdoc/html/length_limit.rs +++ b/src/librustdoc/html/length_limit.rs @@ -87,7 +87,7 @@ pub(super) fn open_tag(&mut self, tag_name: &'static str) { pub(super) fn close_tag(&mut self) { if let Some(tag_name) = self.unclosed_tags.pop() { // Close the most recently opened tag. - write!(self.buf, "").unwrap() + write!(self.buf, "").expect("infallible string operation"); } // There are valid cases where `close_tag()` is called without // there being any tags to close. For example, this occurs when @@ -99,7 +99,7 @@ pub(super) fn close_tag(&mut self) { /// Write all queued tags and add them to the `unclosed_tags` list. fn flush_queue(&mut self) { for tag_name in self.queued_tags.drain(..) { - write!(self.buf, "<{tag_name}>").unwrap(); + write!(self.buf, "<{tag_name}>").expect("infallible string operation"); self.unclosed_tags.push(tag_name); } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 871ed53bd338..9c8e599104be 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -916,7 +916,7 @@ fn render_impls( impls: &[&Impl], containing_item: &clean::Item, toggle_open_by_default: bool, -) { +) -> fmt::Result { let mut rendered_impls = impls .iter() .map(|i| { @@ -942,7 +942,7 @@ fn render_impls( }) .collect::>(); rendered_impls.sort(); - w.write_str(&rendered_impls.join("")).unwrap(); + w.write_str(&rendered_impls.join("")) } /// Build a (possibly empty) `href` attribute (a key-value pair) for the given associated item. @@ -1037,7 +1037,7 @@ fn assoc_const( ) -> impl fmt::Display { let tcx = cx.tcx(); fmt::from_fn(move |w| { - render_attributes_in_code(w, it, &" ".repeat(indent), cx); + render_attributes_in_code(w, it, &" ".repeat(indent), cx)?; write!( w, "{indent}{vis}const {name}{generics}: {ty}", @@ -1145,10 +1145,10 @@ fn assoc_method( let (indent, indent_str, end_newline) = if parent == ItemType::Trait { header_len += 4; let indent_str = " "; - render_attributes_in_code(w, meth, indent_str, cx); + render_attributes_in_code(w, meth, indent_str, cx)?; (4, indent_str, Ending::NoNewline) } else { - render_attributes_in_code(w, meth, "", cx); + render_attributes_in_code(w, meth, "", cx)?; (0, "", Ending::Newline) }; write!( @@ -1365,10 +1365,10 @@ fn render_all_impls( concrete: &[&Impl], synthetic: &[&Impl], blanket_impl: &[&Impl], -) { +) -> fmt::Result { let impls = { let mut buf = String::new(); - render_impls(cx, &mut buf, concrete, containing_item, true); + render_impls(cx, &mut buf, concrete, containing_item, true)?; buf }; if !impls.is_empty() { @@ -1376,8 +1376,7 @@ fn render_all_impls( w, "{}
{impls}
", write_impl_section_heading("Trait Implementations", "trait-implementations") - ) - .unwrap(); + )?; } if !synthetic.is_empty() { @@ -1385,10 +1384,9 @@ fn render_all_impls( w, "{}
", write_impl_section_heading("Auto Trait Implementations", "synthetic-implementations",) - ) - .unwrap(); - render_impls(cx, &mut w, synthetic, containing_item, false); - w.write_str("
").unwrap(); + )?; + render_impls(cx, &mut w, synthetic, containing_item, false)?; + w.write_str("")?; } if !blanket_impl.is_empty() { @@ -1396,11 +1394,11 @@ fn render_all_impls( w, "{}
", write_impl_section_heading("Blanket Implementations", "blanket-implementations") - ) - .unwrap(); - render_impls(cx, &mut w, blanket_impl, containing_item, false); - w.write_str("
").unwrap(); + )?; + render_impls(cx, &mut w, blanket_impl, containing_item, false)?; + w.write_str("")?; } + Ok(()) } fn render_assoc_items( @@ -1412,8 +1410,7 @@ fn render_assoc_items( fmt::from_fn(move |f| { let mut derefs = DefIdSet::default(); derefs.insert(it); - render_assoc_items_inner(f, cx, containing_item, it, what, &mut derefs); - Ok(()) + render_assoc_items_inner(f, cx, containing_item, it, what, &mut derefs) }) } @@ -1424,10 +1421,10 @@ fn render_assoc_items_inner( it: DefId, what: AssocItemRender<'_>, derefs: &mut DefIdSet, -) { +) -> fmt::Result { info!("Documenting associated items of {:?}", containing_item.name); let cache = &cx.shared.cache; - let Some(v) = cache.impls.get(&it) else { return }; + let Some(v) = cache.impls.get(&it) else { return Ok(()) }; let (mut non_trait, traits): (Vec<_>, _) = v.iter().partition(|i| i.inner_impl().trait_.is_none()); if !non_trait.is_empty() { @@ -1511,8 +1508,7 @@ fn render_assoc_items_inner( matches!(what, AssocItemRender::DerefFor { .. }) .then_some("
") .maybe_display(), - ) - .unwrap(); + )?; } } @@ -1522,13 +1518,13 @@ fn render_assoc_items_inner( if let Some(impl_) = deref_impl { let has_deref_mut = traits.iter().any(|t| t.trait_did() == cx.tcx().lang_items().deref_mut_trait()); - render_deref_methods(&mut w, cx, impl_, containing_item, has_deref_mut, derefs); + render_deref_methods(&mut w, cx, impl_, containing_item, has_deref_mut, derefs)?; } // If we were already one level into rendering deref methods, we don't want to render // anything after recursing into any further deref methods above. if let AssocItemRender::DerefFor { .. } = what { - return; + return Ok(()); } let (synthetic, concrete): (Vec<&Impl>, Vec<&Impl>) = @@ -1536,8 +1532,9 @@ fn render_assoc_items_inner( let (blanket_impl, concrete): (Vec<&Impl>, _) = concrete.into_iter().partition(|t| t.inner_impl().kind.is_blanket()); - render_all_impls(w, cx, containing_item, &concrete, &synthetic, &blanket_impl); + render_all_impls(w, cx, containing_item, &concrete, &synthetic, &blanket_impl)?; } + Ok(()) } /// `derefs` is the set of all deref targets that have already been handled. @@ -1548,7 +1545,7 @@ fn render_deref_methods( container_item: &clean::Item, deref_mut: bool, derefs: &mut DefIdSet, -) { +) -> fmt::Result { let cache = cx.cache(); let deref_type = impl_.inner_impl().trait_.as_ref().unwrap(); let (target, real_target) = impl_ @@ -1574,15 +1571,16 @@ fn render_deref_methods( // `impl Deref for S` if did == type_did || !derefs.insert(did) { // Avoid infinite cycles - return; + return Ok(()); } } - render_assoc_items_inner(&mut w, cx, container_item, did, what, derefs); + render_assoc_items_inner(&mut w, cx, container_item, did, what, derefs)?; } else if let Some(prim) = target.primitive_type() && let Some(&did) = cache.primitive_locations.get(&prim) { - render_assoc_items_inner(&mut w, cx, container_item, did, what, derefs); + render_assoc_items_inner(&mut w, cx, container_item, did, what, derefs)?; } + Ok(()) } fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) -> bool { @@ -1805,8 +1803,7 @@ fn doc_impl_item( // because impls can't have a stability. if !item.doc_value().is_empty() { document_item_info(cx, it, Some(parent)) - .render_into(&mut info_buffer) - .unwrap(); + .render_into(&mut info_buffer)?; doc_buffer = document_full(item, cx, HeadingOffset::H5).to_string(); short_documented = false; } else { @@ -1823,9 +1820,7 @@ fn doc_impl_item( } } } else { - document_item_info(cx, item, Some(parent)) - .render_into(&mut info_buffer) - .unwrap(); + document_item_info(cx, item, Some(parent)).render_into(&mut info_buffer)?; if rendering_params.show_def_docs { doc_buffer = document_full(item, cx, HeadingOffset::H5).to_string(); short_documented = false; @@ -2920,7 +2915,7 @@ fn render_attributes_in_code( item: &clean::Item, prefix: &str, cx: &Context<'_>, -) { +) -> fmt::Result { for attr in &item.attrs.other_attrs { let hir::Attribute::Parsed(kind) = attr else { continue }; let attr = match kind { @@ -2934,24 +2929,30 @@ fn render_attributes_in_code( AttributeKind::NonExhaustive(..) => Cow::Borrowed("#[non_exhaustive]"), _ => continue, }; - render_code_attribute(prefix, attr.as_ref(), w); + render_code_attribute(prefix, attr.as_ref(), w)?; } if let Some(def_id) = item.def_id() && let Some(repr) = repr_attribute(cx.tcx(), cx.cache(), def_id) { - render_code_attribute(prefix, &repr, w); + render_code_attribute(prefix, &repr, w)?; } + Ok(()) } -fn render_repr_attribute_in_code(w: &mut impl fmt::Write, cx: &Context<'_>, def_id: DefId) { +fn render_repr_attribute_in_code( + w: &mut impl fmt::Write, + cx: &Context<'_>, + def_id: DefId, +) -> fmt::Result { if let Some(repr) = repr_attribute(cx.tcx(), cx.cache(), def_id) { - render_code_attribute("", &repr, w); + render_code_attribute("", &repr, w)?; } + Ok(()) } -fn render_code_attribute(prefix: &str, attr: &str, w: &mut impl fmt::Write) { - write!(w, "
{prefix}{attr}
").unwrap(); +fn render_code_attribute(prefix: &str, attr: &str, w: &mut impl fmt::Write) -> fmt::Result { + write!(w, "
{prefix}{attr}
") } /// Compute the *public* `#[repr]` of the item given by `DefId`. diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index fa7c9e75fdac..0c511738d7c8 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -457,7 +457,7 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, tcx: TyCtxt<'_>) -> Ordering { "\ " )?; - render_attributes_in_code(w, myitem, "", cx); + render_attributes_in_code(w, myitem, "", cx)?; write!( w, "{vis}{imp}{stab_tags}\ @@ -625,7 +625,7 @@ fn item_function(cx: &Context<'_>, it: &clean::Item, f: &clean::Function) -> imp let notable_traits = notable_traits_button(&f.decl.output, cx).maybe_display(); wrap_item(w, |w| { - render_attributes_in_code(w, it, "", cx); + render_attributes_in_code(w, it, "", cx)?; write!( w, "{vis}{constness}{asyncness}{safety}{abi}fn \ @@ -666,7 +666,7 @@ fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt: // Output the trait definition wrap_item(w, |mut w| { - render_attributes_in_code(&mut w, it, "", cx); + render_attributes_in_code(&mut w, it, "", cx)?; write!( w, "{vis}{safety}{is_auto}trait {name}{generics}{bounds}", @@ -1240,7 +1240,7 @@ fn item_trait_alias( ) -> impl fmt::Display { fmt::from_fn(|w| { wrap_item(w, |w| { - render_attributes_in_code(w, it, "", cx); + render_attributes_in_code(w, it, "", cx)?; write!( w, "trait {name}{generics} = {bounds}{where_clause};", @@ -1268,7 +1268,7 @@ fn item_trait_alias( fn item_type_alias(cx: &Context<'_>, it: &clean::Item, t: &clean::TypeAlias) -> impl fmt::Display { fmt::from_fn(|w| { wrap_item(w, |w| { - render_attributes_in_code(w, it, "", cx); + render_attributes_in_code(w, it, "", cx)?; write!( w, "{vis}type {name}{generics}{where_clause} = {type_};", @@ -1464,7 +1464,7 @@ fn render_union(&self) -> impl Display { fn print_field_attrs(&self, field: &'a clean::Item) -> impl Display { fmt::from_fn(move |w| { - render_attributes_in_code(w, field, "", self.cx); + render_attributes_in_code(w, field, "", self.cx)?; Ok(()) }) } @@ -1554,9 +1554,9 @@ fn render_into( wrap_item(w, |w| { if is_type_alias { // For now the only attributes we render for type aliases are `repr` attributes. - render_repr_attribute_in_code(w, cx, self.def_id); + render_repr_attribute_in_code(w, cx, self.def_id)?; } else { - render_attributes_in_code(w, it, "", cx); + render_attributes_in_code(w, it, "", cx)?; } write!( w, @@ -1695,7 +1695,7 @@ fn render_enum_fields( if v.is_stripped() { continue; } - render_attributes_in_code(w, v, TAB, cx); + render_attributes_in_code(w, v, TAB, cx)?; w.write_str(TAB)?; match v.kind { clean::VariantItem(ref var) => match var.kind { @@ -1779,7 +1779,7 @@ fn item_variants( ) .maybe_display() )?; - render_attributes_in_code(w, variant, "", cx); + render_attributes_in_code(w, variant, "", cx)?; if let clean::VariantItem(ref var) = variant.kind && let clean::VariantKind::CLike = var.kind { @@ -1855,7 +1855,7 @@ fn item_variants( §\ " )?; - render_attributes_in_code(w, field, "", cx); + render_attributes_in_code(w, field, "", cx)?; write!( w, "{f}: {t}\ @@ -1881,7 +1881,7 @@ fn item_macro(cx: &Context<'_>, it: &clean::Item, t: &clean::Macro) -> impl fmt: fmt::from_fn(|w| { wrap_item(w, |w| { // FIXME: Also print `#[doc(hidden)]` for `macro_rules!` if it `is_doc_hidden`. - render_attributes_in_code(w, it, "", cx); + render_attributes_in_code(w, it, "", cx)?; if !t.macro_rules { write!(w, "{}", visibility_print_with_space(it, cx))?; } @@ -1927,16 +1927,15 @@ fn item_primitive(cx: &Context<'_>, it: &clean::Item) -> impl fmt::Display { let def_id = it.item_id.expect_def_id(); write!(w, "{}", document(cx, it, None, HeadingOffset::H2))?; if it.name.map(|n| n.as_str() != "reference").unwrap_or(false) { - write!(w, "{}", render_assoc_items(cx, it, def_id, AssocItemRender::All))?; + write!(w, "{}", render_assoc_items(cx, it, def_id, AssocItemRender::All)) } else { // We handle the "reference" primitive type on its own because we only want to list // implementations on generic types. let (concrete, synthetic, blanket_impl) = get_filtered_impls_for_reference(&cx.shared, it); - render_all_impls(w, cx, it, &concrete, &synthetic, &blanket_impl); + render_all_impls(w, cx, it, &concrete, &synthetic, &blanket_impl) } - Ok(()) }) } @@ -1950,7 +1949,7 @@ fn item_constant( fmt::from_fn(|w| { wrap_item(w, |w| { let tcx = cx.tcx(); - render_attributes_in_code(w, it, "", cx); + render_attributes_in_code(w, it, "", cx)?; write!( w, @@ -2016,9 +2015,9 @@ fn render_into( wrap_item(w, |w| { if is_type_alias { // For now the only attributes we render for type aliases are `repr` attributes. - render_repr_attribute_in_code(w, cx, self.def_id); + render_repr_attribute_in_code(w, cx, self.def_id)?; } else { - render_attributes_in_code(w, it, "", cx); + render_attributes_in_code(w, it, "", cx)?; } write!( w, @@ -2097,7 +2096,7 @@ fn item_fields( ", item_type = ItemType::StructField, )?; - render_attributes_in_code(w, field, "", cx); + render_attributes_in_code(w, field, "", cx)?; write!( w, "{field_name}: {ty}\ @@ -2120,7 +2119,7 @@ fn item_static( ) -> impl fmt::Display { fmt::from_fn(move |w| { wrap_item(w, |w| { - render_attributes_in_code(w, it, "", cx); + render_attributes_in_code(w, it, "", cx)?; write!( w, "{vis}{safe}static {mutability}{name}: {typ}", @@ -2140,8 +2139,8 @@ fn item_foreign_type(cx: &Context<'_>, it: &clean::Item) -> impl fmt::Display { fmt::from_fn(|w| { wrap_item(w, |w| { w.write_str("extern {\n")?; - render_attributes_in_code(w, it, "", cx); - write!(w, " {}type {};\n}}", visibility_print_with_space(it, cx), it.name.unwrap(),) + render_attributes_in_code(w, it, "", cx)?; + write!(w, " {}type {};\n}}", visibility_print_with_space(it, cx), it.name.unwrap()) })?; write!( @@ -2292,15 +2291,14 @@ fn print_bounds( .maybe_display() } -fn wrap_item(w: &mut W, f: F) -> T +fn wrap_item(w: &mut W, f: F) -> fmt::Result where W: fmt::Write, - F: FnOnce(&mut W) -> T, + F: FnOnce(&mut W) -> fmt::Result, { - write!(w, r#"
"#).unwrap();
-    let res = f(w);
-    write!(w, "
").unwrap(); - res + w.write_str(r#"
"#)?;
+    f(w)?;
+    w.write_str("
") } #[derive(PartialEq, Eq)] @@ -2370,9 +2368,9 @@ fn render_union( fmt::from_fn(move |mut f| { if is_type_alias { // For now the only attributes we render for type aliases are `repr` attributes. - render_repr_attribute_in_code(f, cx, def_id); + render_repr_attribute_in_code(f, cx, def_id)?; } else { - render_attributes_in_code(f, it, "", cx); + render_attributes_in_code(f, it, "", cx)?; } write!(f, "{}union {}", visibility_print_with_space(it, cx), it.name.unwrap(),)?; @@ -2403,7 +2401,7 @@ fn render_union( for field in fields { if let clean::StructFieldItem(ref ty) = field.kind { - render_attributes_in_code(&mut f, field, " ", cx); + render_attributes_in_code(&mut f, field, " ", cx)?; writeln!( f, " {}{}: {},", @@ -2500,7 +2498,7 @@ fn render_struct_fields( } for field in fields { if let clean::StructFieldItem(ref ty) = field.kind { - render_attributes_in_code(w, field, &format!("{tab} "), cx); + render_attributes_in_code(w, field, &format!("{tab} "), cx)?; writeln!( w, "{tab} {vis}{name}: {ty},", From 87e4974fa8f3d0314991640bfd0162adc5d8a18d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 24 Nov 2025 13:07:39 +0200 Subject: [PATCH 158/194] Reformat python script --- .../lib/smol_str/src/gdb_smolstr_printer.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/tools/rust-analyzer/lib/smol_str/src/gdb_smolstr_printer.py b/src/tools/rust-analyzer/lib/smol_str/src/gdb_smolstr_printer.py index 9b2984fc6d0e..5f28ddd5e64e 100644 --- a/src/tools/rust-analyzer/lib/smol_str/src/gdb_smolstr_printer.py +++ b/src/tools/rust-analyzer/lib/smol_str/src/gdb_smolstr_printer.py @@ -25,15 +25,17 @@ import re SMOL_INLINE_SIZE_RE = re.compile(r".*::_V(\d+)$") + def _read_utf8(mem): try: return mem.tobytes().decode("utf-8", errors="replace") except Exception: return repr(mem.tobytes()) + def _active_variant(enum_val): """Return (variant_name, variant_value) for a Rust enum value using discriminant logic. - Assume layout: fields[0] is unnamed u8 discriminant; fields[1] is the active variant. + Assume layout: fields[0] is unnamed u8 discriminant; fields[1] is the active variant. """ fields = enum_val.type.fields() if len(fields) < 2: @@ -41,6 +43,7 @@ def _active_variant(enum_val): variant_field = fields[1] return variant_field.name, enum_val[variant_field] + class SmolStrProvider: def __init__(self, val): self.val = val @@ -86,8 +89,10 @@ class SmolStrProvider: length = int(inner["length"]) # ArcInner layout: # strong: Atomic, weak: Atomic | unsized tail 'data' bytes. - sizeof_AtomicUsize = gdb.lookup_type("core::sync::atomic::AtomicUsize").sizeof - header_size = sizeof_AtomicUsize * 2 # strong + weak counters + sizeof_AtomicUsize = gdb.lookup_type( + "core::sync::atomic::AtomicUsize" + ).sizeof + header_size = sizeof_AtomicUsize * 2 # strong + weak counters data_arr = int(data_ptr) + header_size mem = gdb.selected_inferior().read_memory(data_arr, length) return _read_utf8(mem) @@ -99,6 +104,7 @@ class SmolStrProvider: def display_hint(self): return "string" + class SmolStrSubPrinter(gdb.printing.SubPrettyPrinter): def __init__(self): super(SmolStrSubPrinter, self).__init__("SmolStr") @@ -114,6 +120,7 @@ class SmolStrSubPrinter(gdb.printing.SubPrettyPrinter): pass return None + class SmolStrPrettyPrinter(gdb.printing.PrettyPrinter): def __init__(self): super(SmolStrPrettyPrinter, self).__init__("smol_str", []) @@ -129,9 +136,12 @@ class SmolStrPrettyPrinter(gdb.printing.PrettyPrinter): return pp return None + printer = SmolStrPrettyPrinter() + def register_printers(objfile=None): gdb.printing.register_pretty_printer(objfile, printer, replace=True) + register_printers() From 4d4f3151fb02b85de504a40e54484ea4645c1326 Mon Sep 17 00:00:00 2001 From: yukang Date: Sat, 22 Nov 2025 11:52:22 +0800 Subject: [PATCH 159/194] Add suggest alternatives for Out-of-range \x escapes --- compiler/rustc_parse/messages.ftl | 2 - compiler/rustc_parse/src/errors.rs | 6 -- .../src/lexer/unescape_error_reporting.rs | 19 ++++- .../parser/ascii-only-character-escape.stderr | 9 +++ ...-of-range-hex-escape-suggestions-148917.rs | 21 +++++ ...range-hex-escape-suggestions-148917.stderr | 77 +++++++++++++++++++ 6 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 tests/ui/parser/out-of-range-hex-escape-suggestions-148917.rs create mode 100644 tests/ui/parser/out-of-range-hex-escape-suggestions-148917.stderr diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index c74333f5655a..7055e60956a9 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -732,8 +732,6 @@ parse_or_in_let_chain = `||` operators are not supported in let chain conditions parse_or_pattern_not_allowed_in_fn_parameters = function parameters require top-level or-patterns in parentheses parse_or_pattern_not_allowed_in_let_binding = `let` bindings require top-level or-patterns in parentheses -parse_out_of_range_hex_escape = out of range hex escape - .label = must be a character in the range [\x00-\x7f] parse_outer_attr_explanation = outer attributes, like `#[test]`, annotate the item following them diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index bde179c9438f..62a333fbf81d 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -2455,12 +2455,6 @@ pub(crate) enum UnescapeError { is_hex: bool, ch: String, }, - #[diag(parse_out_of_range_hex_escape)] - OutOfRangeHexEscape( - #[primary_span] - #[label] - Span, - ), #[diag(parse_leading_underscore_unicode_escape)] LeadingUnderscoreUnicodeEscape { #[primary_span] diff --git a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs index ec59a1a01314..895374ab2cc4 100644 --- a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs +++ b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs @@ -226,7 +226,24 @@ pub(crate) fn emit_unescape_error( err.emit() } EscapeError::OutOfRangeHexEscape => { - dcx.emit_err(UnescapeError::OutOfRangeHexEscape(err_span)) + let mut err = dcx.struct_span_err(err_span, "out of range hex escape"); + err.span_label(err_span, "must be a character in the range [\\x00-\\x7f]"); + + let escape_str = &lit[range]; + if lit.len() <= 4 + && escape_str.len() == 4 + && escape_str.starts_with("\\x") + && let Ok(value) = u8::from_str_radix(&escape_str[2..4], 16) + && matches!(mode, Mode::Char | Mode::Str) + { + err.help(format!("if you want to write a byte literal, use `b'{}'`", escape_str)); + err.help(format!( + "if you want to write a Unicode character, use `'\\u{{{:X}}}'`", + value + )); + } + + err.emit() } EscapeError::LeadingUnderscoreUnicodeEscape => { let (c, span) = last_char(); diff --git a/tests/ui/parser/ascii-only-character-escape.stderr b/tests/ui/parser/ascii-only-character-escape.stderr index b599b35f4b32..78844ae385e4 100644 --- a/tests/ui/parser/ascii-only-character-escape.stderr +++ b/tests/ui/parser/ascii-only-character-escape.stderr @@ -3,18 +3,27 @@ error: out of range hex escape | LL | let x = "\x80"; | ^^^^ must be a character in the range [\x00-\x7f] + | + = help: if you want to write a byte literal, use `b'\x80'` + = help: if you want to write a Unicode character, use `'\u{80}'` error: out of range hex escape --> $DIR/ascii-only-character-escape.rs:3:14 | LL | let y = "\xff"; | ^^^^ must be a character in the range [\x00-\x7f] + | + = help: if you want to write a byte literal, use `b'\xff'` + = help: if you want to write a Unicode character, use `'\u{FF}'` error: out of range hex escape --> $DIR/ascii-only-character-escape.rs:4:14 | LL | let z = "\xe2"; | ^^^^ must be a character in the range [\x00-\x7f] + | + = help: if you want to write a byte literal, use `b'\xe2'` + = help: if you want to write a Unicode character, use `'\u{E2}'` error: aborting due to 3 previous errors diff --git a/tests/ui/parser/out-of-range-hex-escape-suggestions-148917.rs b/tests/ui/parser/out-of-range-hex-escape-suggestions-148917.rs new file mode 100644 index 000000000000..ee8489fef800 --- /dev/null +++ b/tests/ui/parser/out-of-range-hex-escape-suggestions-148917.rs @@ -0,0 +1,21 @@ +fn main() { + let _c = '\xFF'; //~ ERROR out of range hex escape + let _s = "\xFF"; //~ ERROR out of range hex escape + + let _c2 = '\xff'; //~ ERROR out of range hex escape + let _s2 = "\xff"; //~ ERROR out of range hex escape + + let _c3 = '\x80'; //~ ERROR out of range hex escape + let _s3 = "\x80"; //~ ERROR out of range hex escape + + // Byte literals should not get suggestions (they're already valid) + let _b = b'\xFF'; // OK + let _bs = b"\xFF"; // OK + + dbg!('\xFF'); //~ ERROR out of range hex escape + + // do not suggest for out of range escapes that are too long + dbg!("\xFFFFF"); //~ ERROR out of range hex escape + + dbg!("this is some kind of string \xa7"); //~ ERROR out of range hex escape +} diff --git a/tests/ui/parser/out-of-range-hex-escape-suggestions-148917.stderr b/tests/ui/parser/out-of-range-hex-escape-suggestions-148917.stderr new file mode 100644 index 000000000000..e0485bfe50ea --- /dev/null +++ b/tests/ui/parser/out-of-range-hex-escape-suggestions-148917.stderr @@ -0,0 +1,77 @@ +error: out of range hex escape + --> $DIR/out-of-range-hex-escape-suggestions-148917.rs:2:15 + | +LL | let _c = '\xFF'; + | ^^^^ must be a character in the range [\x00-\x7f] + | + = help: if you want to write a byte literal, use `b'\xFF'` + = help: if you want to write a Unicode character, use `'\u{FF}'` + +error: out of range hex escape + --> $DIR/out-of-range-hex-escape-suggestions-148917.rs:3:15 + | +LL | let _s = "\xFF"; + | ^^^^ must be a character in the range [\x00-\x7f] + | + = help: if you want to write a byte literal, use `b'\xFF'` + = help: if you want to write a Unicode character, use `'\u{FF}'` + +error: out of range hex escape + --> $DIR/out-of-range-hex-escape-suggestions-148917.rs:5:16 + | +LL | let _c2 = '\xff'; + | ^^^^ must be a character in the range [\x00-\x7f] + | + = help: if you want to write a byte literal, use `b'\xff'` + = help: if you want to write a Unicode character, use `'\u{FF}'` + +error: out of range hex escape + --> $DIR/out-of-range-hex-escape-suggestions-148917.rs:6:16 + | +LL | let _s2 = "\xff"; + | ^^^^ must be a character in the range [\x00-\x7f] + | + = help: if you want to write a byte literal, use `b'\xff'` + = help: if you want to write a Unicode character, use `'\u{FF}'` + +error: out of range hex escape + --> $DIR/out-of-range-hex-escape-suggestions-148917.rs:8:16 + | +LL | let _c3 = '\x80'; + | ^^^^ must be a character in the range [\x00-\x7f] + | + = help: if you want to write a byte literal, use `b'\x80'` + = help: if you want to write a Unicode character, use `'\u{80}'` + +error: out of range hex escape + --> $DIR/out-of-range-hex-escape-suggestions-148917.rs:9:16 + | +LL | let _s3 = "\x80"; + | ^^^^ must be a character in the range [\x00-\x7f] + | + = help: if you want to write a byte literal, use `b'\x80'` + = help: if you want to write a Unicode character, use `'\u{80}'` + +error: out of range hex escape + --> $DIR/out-of-range-hex-escape-suggestions-148917.rs:15:11 + | +LL | dbg!('\xFF'); + | ^^^^ must be a character in the range [\x00-\x7f] + | + = help: if you want to write a byte literal, use `b'\xFF'` + = help: if you want to write a Unicode character, use `'\u{FF}'` + +error: out of range hex escape + --> $DIR/out-of-range-hex-escape-suggestions-148917.rs:18:11 + | +LL | dbg!("\xFFFFF"); + | ^^^^ must be a character in the range [\x00-\x7f] + +error: out of range hex escape + --> $DIR/out-of-range-hex-escape-suggestions-148917.rs:20:39 + | +LL | dbg!("this is some kind of string \xa7"); + | ^^^^ must be a character in the range [\x00-\x7f] + +error: aborting due to 9 previous errors + From 62c5ea65dc42e28c6ac7016a9cf4bb64036a8a85 Mon Sep 17 00:00:00 2001 From: David Wood Date: Thu, 20 Nov 2025 14:42:38 +0000 Subject: [PATCH 160/194] v0 mangling for std on nightly --- src/bootstrap/src/core/builder/cargo.rs | 2 ++ tests/ui/sanitizer/dataflow-abilist.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index c38e14089854..7f68fba26cb0 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -647,6 +647,8 @@ fn cargo( // If an explicit setting is given, use that setting } + // Per compiler-team#938, v0 mangling is used on nightly + None if self.config.channel == "dev" || self.config.channel == "nightly" => true, None => { if mode == Mode::Std { // The standard library defaults to the legacy scheme diff --git a/tests/ui/sanitizer/dataflow-abilist.txt b/tests/ui/sanitizer/dataflow-abilist.txt index b6fdfe3cbf6e..1fa78ebd5593 100644 --- a/tests/ui/sanitizer/dataflow-abilist.txt +++ b/tests/ui/sanitizer/dataflow-abilist.txt @@ -491,6 +491,8 @@ fun:__dfso_*=discard # Rust functions. fun:_ZN4core*=uninstrumented +fun:_R*4core*=uninstrumented fun:_ZN3std*=uninstrumented +fun:_R*3std*=uninstrumented fun:rust_eh_personality=uninstrumented fun:_R*__rustc*=uninstrumented From cf4668285f0800f9818e65dc5ad807ea1e268109 Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Sat, 22 Nov 2025 21:11:07 +0900 Subject: [PATCH 161/194] fix: Do not ICE on normalization failure of an extern static item --- .../rustc_hir_analysis/src/check/wfcheck.rs | 15 +++++++++---- ...atic-normalization-failure-issue-148161.rs | 21 +++++++++++++++++++ ...-normalization-failure-issue-148161.stderr | 20 ++++++++++++++++++ 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 tests/ui/static/extern-static-normalization-failure-issue-148161.rs create mode 100644 tests/ui/static/extern-static-normalization-failure-issue-148161.stderr diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index ccae524352a5..06738d99bf56 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1186,14 +1186,21 @@ pub(crate) fn check_static_item<'tcx>( ) -> Result<(), ErrorGuaranteed> { enter_wf_checking_ctxt(tcx, item_id, |wfcx| { let span = tcx.ty_span(item_id); - let item_ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(item_id)), ty); + let loc = Some(WellFormedLoc::Ty(item_id)); + let item_ty = wfcx.deeply_normalize(span, loc, ty); let is_foreign_item = tcx.is_foreign_item(item_id); + let is_structurally_foreign_item = || { + let tail = tcx.struct_tail_raw( + item_ty, + &ObligationCause::dummy(), + |ty| wfcx.deeply_normalize(span, loc, ty), + || {}, + ); - let forbid_unsized = !is_foreign_item || { - let tail = tcx.struct_tail_for_codegen(item_ty, wfcx.infcx.typing_env(wfcx.param_env)); - !matches!(tail.kind(), ty::Foreign(_)) + matches!(tail.kind(), ty::Foreign(_)) }; + let forbid_unsized = !(is_foreign_item && is_structurally_foreign_item()); wfcx.register_wf_obligation(span, Some(WellFormedLoc::Ty(item_id)), item_ty.into()); if forbid_unsized { diff --git a/tests/ui/static/extern-static-normalization-failure-issue-148161.rs b/tests/ui/static/extern-static-normalization-failure-issue-148161.rs new file mode 100644 index 000000000000..2995c3ed2ec7 --- /dev/null +++ b/tests/ui/static/extern-static-normalization-failure-issue-148161.rs @@ -0,0 +1,21 @@ +// Regression test for https://github.com/rust-lang/rust/issues/148161 +trait Trait { + type Assoc; +} + +impl Trait for u8 { + type Assoc = i8; +} + +struct Struct { + member: T::Assoc, +} + +unsafe extern "C" { + // This used to be an ICE due to normalization failure on ` as Trait>::Assoc` + // while wf checking this static item. + static VAR: Struct; + //~^ ERROR: the trait bound `i8: Trait` is not satisfied +} + +fn main() {} diff --git a/tests/ui/static/extern-static-normalization-failure-issue-148161.stderr b/tests/ui/static/extern-static-normalization-failure-issue-148161.stderr new file mode 100644 index 000000000000..e2c7d30e2e43 --- /dev/null +++ b/tests/ui/static/extern-static-normalization-failure-issue-148161.stderr @@ -0,0 +1,20 @@ +error[E0277]: the trait bound `i8: Trait` is not satisfied + --> $DIR/extern-static-normalization-failure-issue-148161.rs:17:17 + | +LL | static VAR: Struct; + | ^^^^^^^^^^ the trait `Trait` is not implemented for `i8` + | +help: the trait `Trait` is implemented for `u8` + --> $DIR/extern-static-normalization-failure-issue-148161.rs:6:1 + | +LL | impl Trait for u8 { + | ^^^^^^^^^^^^^^^^^ +note: required by a bound in `Struct` + --> $DIR/extern-static-normalization-failure-issue-148161.rs:10:18 + | +LL | struct Struct { + | ^^^^^ required by this bound in `Struct` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. From a21affabf848c71e5a518410568cdadd455c509f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 24 Nov 2025 16:41:24 +0100 Subject: [PATCH 162/194] Fix invalid link generation for type alias methods --- src/librustdoc/html/render/write_shared.rs | 12 ++++-------- tests/rustdoc-gui/src/test_docs/lib.rs | 10 ++++++++++ tests/rustdoc-gui/type-alias.goml | 7 +++++++ 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 tests/rustdoc-gui/type-alias.goml diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 6045b9a77eca..31da7b7de920 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -568,18 +568,14 @@ fn get( if let Some(ret) = &mut ret { ret.aliases.push(type_alias_fqp); } else { - let target_did = impl_ - .inner_impl() - .trait_ - .as_ref() - .map(|trait_| trait_.def_id()) - .or_else(|| impl_.inner_impl().for_.def_id(&cx.shared.cache)); + let target_trait_did = + impl_.inner_impl().trait_.as_ref().map(|trait_| trait_.def_id()); let provided_methods; - let assoc_link = if let Some(target_did) = target_did { + let assoc_link = if let Some(target_trait_did) = target_trait_did { provided_methods = impl_.inner_impl().provided_trait_methods(cx.tcx()); AssocItemLink::GotoSource( - ItemId::DefId(target_did), + ItemId::DefId(target_trait_did), &provided_methods, ) } else { diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index c0771583ab65..0ee2a66d4b68 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -786,3 +786,13 @@ pub fn bar() -> Vec { Vec::new() } } + +pub mod tyalias { + pub struct X(pub T); + + impl X { + pub fn blob(&self) {} + } + + pub type Y = X; +} diff --git a/tests/rustdoc-gui/type-alias.goml b/tests/rustdoc-gui/type-alias.goml new file mode 100644 index 000000000000..a07f1b4eb814 --- /dev/null +++ b/tests/rustdoc-gui/type-alias.goml @@ -0,0 +1,7 @@ +// This test ensures that we correctly generate links to methods on type aliases. +go-to: "file://" + |DOC_PATH| + "/test_docs/tyalias/type.Y.html" + +// It's generated with JS so we need to wait for it to be done generating. +wait-for: "#implementations" +// We check that it's "#method." and not "#tymethod.". +assert-text: ('#method\.blob a.fn[href="#method.blob"]', "blob") From 3181c21b6cf996047113e91a2bf7f2c8abdafd1e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 24 Nov 2025 16:41:30 +0100 Subject: [PATCH 163/194] Improve variable naming --- src/librustdoc/html/render/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 871ed53bd338..b5c44686cafc 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -2025,13 +2025,11 @@ fn doc_impl_item( let mut methods = Vec::new(); if !impl_.is_negative_trait_impl() { - for trait_item in &impl_.items { - match trait_item.kind { - clean::MethodItem(..) | clean::RequiredMethodItem(_) => { - methods.push(trait_item) - } + for impl_item in &impl_.items { + match impl_item.kind { + clean::MethodItem(..) | clean::RequiredMethodItem(_) => methods.push(impl_item), clean::RequiredAssocTypeItem(..) | clean::AssocTypeItem(..) => { - assoc_types.push(trait_item) + assoc_types.push(impl_item) } clean::RequiredAssocConstItem(..) | clean::ProvidedAssocConstItem(_) @@ -2041,7 +2039,7 @@ fn doc_impl_item( &mut default_impl_items, &mut impl_items, cx, - trait_item, + impl_item, if trait_.is_some() { &i.impl_item } else { parent }, link, render_mode, From 6173a567167646e15ef8f00e36b4739b3bfa3bee Mon Sep 17 00:00:00 2001 From: Peter Badida Date: Mon, 24 Nov 2025 18:02:19 +0100 Subject: [PATCH 164/194] Fix missing double-quote in `std::env::consts::OS` values --- library/std/src/env.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index fd662e8a663a..5c068ad2471a 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -1097,7 +1097,7 @@ pub mod consts { /// * `"nto"` /// * `"redox"` /// * `"solaris"` - /// * `"solid_asp3` + /// * `"solid_asp3"` /// * `"vexos"` /// * `"vita"` /// * `"vxworks"` From 30c2e26506eb672386c70ea2e4d7e0b102f86d2d Mon Sep 17 00:00:00 2001 From: Jane Losare-Lusby Date: Fri, 21 Nov 2025 14:08:33 -0800 Subject: [PATCH 165/194] Add test for derive helper compat collisions --- .../auxiliary/extra-empty-derive.rs | 7 ++++++ .../helper-attr-compat-collision.rs | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/ui/proc-macro/auxiliary/extra-empty-derive.rs create mode 100644 tests/ui/proc-macro/helper-attr-compat-collision.rs diff --git a/tests/ui/proc-macro/auxiliary/extra-empty-derive.rs b/tests/ui/proc-macro/auxiliary/extra-empty-derive.rs new file mode 100644 index 000000000000..9a89e04364d7 --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/extra-empty-derive.rs @@ -0,0 +1,7 @@ +extern crate proc_macro; +use proc_macro::{TokenStream, TokenTree}; + +#[proc_macro_derive(Empty2, attributes(empty_helper))] +pub fn empty_derive2(_: TokenStream) -> TokenStream { + TokenStream::new() +} diff --git a/tests/ui/proc-macro/helper-attr-compat-collision.rs b/tests/ui/proc-macro/helper-attr-compat-collision.rs new file mode 100644 index 000000000000..1ed2f4c55066 --- /dev/null +++ b/tests/ui/proc-macro/helper-attr-compat-collision.rs @@ -0,0 +1,23 @@ +//@ proc-macro: test-macros.rs +//@ proc-macro: extra-empty-derive.rs +//@ build-pass + +#[macro_use(Empty)] +extern crate test_macros; +#[macro_use(Empty2)] +extern crate extra_empty_derive; + +// Testing the behavior of derive attributes with helpers that share the same name. +// +// Normally if the first derive below were absent the call to #[empty_helper] before it it +// introduced by its own derive would produce a future incompat error. +// +// With the extra derive also introducing that attribute in advanced the warning gets supressed. +// Demonstrates a lack of identity to helper attributes, the compiler does not track which derive +// introduced a helper, just that a derive introduced the helper. +#[derive(Empty)] +#[empty_helper] +#[derive(Empty2)] +struct S; + +fn main() {} From 7537b0bc068b021fb852e8df92c3476b61527e15 Mon Sep 17 00:00:00 2001 From: Jane Losare-Lusby Date: Mon, 24 Nov 2025 10:41:28 -0800 Subject: [PATCH 166/194] Update tests/ui/proc-macro/helper-attr-compat-collision.rs Co-authored-by: Vadim Petrochenkov --- tests/ui/proc-macro/helper-attr-compat-collision.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/proc-macro/helper-attr-compat-collision.rs b/tests/ui/proc-macro/helper-attr-compat-collision.rs index 1ed2f4c55066..7755582c4632 100644 --- a/tests/ui/proc-macro/helper-attr-compat-collision.rs +++ b/tests/ui/proc-macro/helper-attr-compat-collision.rs @@ -1,6 +1,6 @@ //@ proc-macro: test-macros.rs //@ proc-macro: extra-empty-derive.rs -//@ build-pass +//@ check-pass #[macro_use(Empty)] extern crate test_macros; From 17230eb5bba2b311f5048aea5073895572746637 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Fri, 14 Nov 2025 18:51:07 +0000 Subject: [PATCH 167/194] rustc_target: aarch64: Remove deprecated FEAT_TME ARM has withdrawn FEAT_TME https://developer.arm.com/documentation/102105/lb-05/ LLVM has dropped support for it recently as a result. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 2 ++ library/std/tests/run-time-detect.rs | 1 - library/std_detect/src/detect/os/aarch64.rs | 1 - library/std_detect/tests/cpu-detection.rs | 2 -- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index b498448417f5..687238968e97 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -243,6 +243,8 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option Some(LLVMFeature::new("fullfp16")), // Filter out features that are not supported by the current LLVM version "fpmr" => None, // only existed in 18 + // Withdrawn by ARM; removed from LLVM in 22 + "tme" if major >= 22 => None, s => Some(LLVMFeature::new(s)), } } diff --git a/library/std/tests/run-time-detect.rs b/library/std/tests/run-time-detect.rs index be2980f73268..5506fd469732 100644 --- a/library/std/tests/run-time-detect.rs +++ b/library/std/tests/run-time-detect.rs @@ -106,7 +106,6 @@ fn aarch64_linux() { println!("sve2: {}", is_aarch64_feature_detected!("sve2")); println!("sve2p1: {}", is_aarch64_feature_detected!("sve2p1")); println!("sve: {}", is_aarch64_feature_detected!("sve")); - println!("tme: {}", is_aarch64_feature_detected!("tme")); println!("wfxt: {}", is_aarch64_feature_detected!("wfxt")); // tidy-alphabetical-end } diff --git a/library/std_detect/src/detect/os/aarch64.rs b/library/std_detect/src/detect/os/aarch64.rs index c2c754ccf8db..3232e435d524 100644 --- a/library/std_detect/src/detect/os/aarch64.rs +++ b/library/std_detect/src/detect/os/aarch64.rs @@ -84,7 +84,6 @@ pub(crate) fn parse_system_registers( // ID_AA64ISAR0_EL1 - Instruction Set Attribute Register 0 enable_feature(Feature::pmull, bits_shift(aa64isar0, 7, 4) >= 2); - enable_feature(Feature::tme, bits_shift(aa64isar0, 27, 24) == 1); enable_feature(Feature::lse, bits_shift(aa64isar0, 23, 20) >= 2); enable_feature(Feature::crc, bits_shift(aa64isar0, 19, 16) >= 1); diff --git a/library/std_detect/tests/cpu-detection.rs b/library/std_detect/tests/cpu-detection.rs index e653889c3788..196abfdb7c4d 100644 --- a/library/std_detect/tests/cpu-detection.rs +++ b/library/std_detect/tests/cpu-detection.rs @@ -85,7 +85,6 @@ fn aarch64_linux() { println!("rcpc2: {}", is_aarch64_feature_detected!("rcpc2")); println!("rcpc3: {}", is_aarch64_feature_detected!("rcpc3")); println!("dotprod: {}", is_aarch64_feature_detected!("dotprod")); - println!("tme: {}", is_aarch64_feature_detected!("tme")); println!("fhm: {}", is_aarch64_feature_detected!("fhm")); println!("dit: {}", is_aarch64_feature_detected!("dit")); println!("flagm: {}", is_aarch64_feature_detected!("flagm")); @@ -175,7 +174,6 @@ fn aarch64_bsd() { println!("rdm: {:?}", is_aarch64_feature_detected!("rdm")); println!("rcpc: {:?}", is_aarch64_feature_detected!("rcpc")); println!("dotprod: {:?}", is_aarch64_feature_detected!("dotprod")); - println!("tme: {:?}", is_aarch64_feature_detected!("tme")); println!("paca: {:?}", is_aarch64_feature_detected!("paca")); println!("pacg: {:?}", is_aarch64_feature_detected!("pacg")); println!("aes: {:?}", is_aarch64_feature_detected!("aes")); From c0097978aa2514056d75d2ab33db6efe6510cf70 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 25 Oct 2025 21:30:46 -0400 Subject: [PATCH 168/194] Make deref_nullptr deny by default instead of warn --- compiler/rustc_lint/src/builtin.rs | 4 ++-- tests/ui/lint/lint-forbid-internal-unsafe.rs | 2 +- tests/ui/lint/lint-forbid-internal-unsafe.stderr | 6 +++--- tests/ui/unreachable-code/unreachable-bool-read-7246.rs | 2 +- tests/ui/unreachable-code/unreachable-bool-read-7246.stderr | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 4e9ecb9006ab..37d0e2a51bac 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -2697,7 +2697,7 @@ fn ty_find_init_error<'tcx>( /// /// ### Example /// - /// ```rust,no_run + /// ```rust,compile_fail /// # #![allow(unused)] /// use std::ptr; /// unsafe { @@ -2716,7 +2716,7 @@ fn ty_find_init_error<'tcx>( /// /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html pub DEREF_NULLPTR, - Warn, + Deny, "detects when an null pointer is dereferenced" } diff --git a/tests/ui/lint/lint-forbid-internal-unsafe.rs b/tests/ui/lint/lint-forbid-internal-unsafe.rs index 3ee55ba96b13..ab3769b06cbe 100644 --- a/tests/ui/lint/lint-forbid-internal-unsafe.rs +++ b/tests/ui/lint/lint-forbid-internal-unsafe.rs @@ -13,5 +13,5 @@ macro_rules! evil { fn main() { println!("{}", evil!(*(0 as *const u8))); - //~^ WARNING dereferencing a null pointer + //~^ ERROR dereferencing a null pointer } diff --git a/tests/ui/lint/lint-forbid-internal-unsafe.stderr b/tests/ui/lint/lint-forbid-internal-unsafe.stderr index 52d9c8471e56..a58bd467f675 100644 --- a/tests/ui/lint/lint-forbid-internal-unsafe.stderr +++ b/tests/ui/lint/lint-forbid-internal-unsafe.stderr @@ -10,13 +10,13 @@ note: the lint level is defined here LL | #![forbid(unsafe_code)] | ^^^^^^^^^^^ -warning: dereferencing a null pointer +error: dereferencing a null pointer --> $DIR/lint-forbid-internal-unsafe.rs:15:26 | LL | println!("{}", evil!(*(0 as *const u8))); | ^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed | - = note: `#[warn(deref_nullptr)]` on by default + = note: `#[deny(deref_nullptr)]` on by default -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 2 previous errors diff --git a/tests/ui/unreachable-code/unreachable-bool-read-7246.rs b/tests/ui/unreachable-code/unreachable-bool-read-7246.rs index 8bbaa1025493..212828679800 100644 --- a/tests/ui/unreachable-code/unreachable-bool-read-7246.rs +++ b/tests/ui/unreachable-code/unreachable-bool-read-7246.rs @@ -5,7 +5,7 @@ pub unsafe fn g() { return; if *ptr::null() {}; //~ ERROR unreachable - //~| WARNING dereferencing a null pointer + //~| ERROR dereferencing a null pointer } pub fn main() {} diff --git a/tests/ui/unreachable-code/unreachable-bool-read-7246.stderr b/tests/ui/unreachable-code/unreachable-bool-read-7246.stderr index 6072160cb5f1..6e4123760a79 100644 --- a/tests/ui/unreachable-code/unreachable-bool-read-7246.stderr +++ b/tests/ui/unreachable-code/unreachable-bool-read-7246.stderr @@ -12,13 +12,13 @@ note: the lint level is defined here LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ -warning: dereferencing a null pointer +error: dereferencing a null pointer --> $DIR/unreachable-bool-read-7246.rs:7:8 | LL | if *ptr::null() {}; | ^^^^^^^^^^^^ this code causes undefined behavior when executed | - = note: `#[warn(deref_nullptr)]` on by default + = note: `#[deny(deref_nullptr)]` on by default -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 2 previous errors From bef49a02ef209b14d4ad203dacf53b0034742c8c Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Thu, 6 Nov 2025 18:50:04 -0500 Subject: [PATCH 169/194] Don't lint on derefs of null pointers to ZSTs --- compiler/rustc_lint/src/builtin.rs | 10 ++++++++++ tests/ui/lint/lint-deref-nullptr.rs | 10 ++++++++-- tests/ui/lint/lint-deref-nullptr.stderr | 22 +++++++++------------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 37d0e2a51bac..185cb4d522f2 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -2726,6 +2726,16 @@ impl<'tcx> LateLintPass<'tcx> for DerefNullPtr { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &hir::Expr<'_>) { /// test if expression is a null ptr fn is_null_ptr(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { + let pointer_ty = cx.typeck_results().expr_ty(expr); + let ty::RawPtr(pointee, _) = pointer_ty.kind() else { + return false; + }; + if let Ok(layout) = cx.tcx.layout_of(cx.typing_env().as_query_input(*pointee)) { + if layout.layout.size() == rustc_abi::Size::ZERO { + return false; + } + } + match &expr.kind { hir::ExprKind::Cast(expr, ty) => { if let hir::TyKind::Ptr(_) = ty.kind { diff --git a/tests/ui/lint/lint-deref-nullptr.rs b/tests/ui/lint/lint-deref-nullptr.rs index f83d88309b9a..ed0cc7fa3ee9 100644 --- a/tests/ui/lint/lint-deref-nullptr.rs +++ b/tests/ui/lint/lint-deref-nullptr.rs @@ -1,13 +1,14 @@ // test the deref_nullptr lint -#![deny(deref_nullptr)] - use std::ptr; struct Struct { field: u8, } +#[derive(Clone, Copy)] +struct Zst; + fn f() { unsafe { let a = 1; @@ -32,6 +33,11 @@ fn f() { // ^^ OKAY let offset = ptr::addr_of!((*ptr::null::()).field); //~^ ERROR dereferencing a null pointer + + // Make sure the lint permits derefs of null pointers to ZSTs + let ok: Zst = *ptr::null(); + let ok: Zst = *ptr::null_mut(); + let ok: Zst = *(0 as *const Zst); } } diff --git a/tests/ui/lint/lint-deref-nullptr.stderr b/tests/ui/lint/lint-deref-nullptr.stderr index 175431b2994b..1216e455485a 100644 --- a/tests/ui/lint/lint-deref-nullptr.stderr +++ b/tests/ui/lint/lint-deref-nullptr.stderr @@ -1,53 +1,49 @@ error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:15:18 + --> $DIR/lint-deref-nullptr.rs:16:18 | LL | let ub = *(0 as *const i32); | ^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed | -note: the lint level is defined here - --> $DIR/lint-deref-nullptr.rs:3:9 - | -LL | #![deny(deref_nullptr)] - | ^^^^^^^^^^^^^ + = note: `#[deny(deref_nullptr)]` on by default error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:17:18 + --> $DIR/lint-deref-nullptr.rs:18:18 | LL | let ub = *ptr::null::(); | ^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:19:18 + --> $DIR/lint-deref-nullptr.rs:20:18 | LL | let ub = *ptr::null_mut::(); | ^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:21:18 + --> $DIR/lint-deref-nullptr.rs:22:18 | LL | let ub = *(ptr::null::() as *const i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:23:18 + --> $DIR/lint-deref-nullptr.rs:24:18 | LL | let ub = *(ptr::null::() as *mut i32 as *mut usize as *const u8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:25:19 + --> $DIR/lint-deref-nullptr.rs:26:19 | LL | let ub = &*ptr::null::(); | ^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:27:19 + --> $DIR/lint-deref-nullptr.rs:28:19 | LL | let ub = &*ptr::null_mut::(); | ^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed error: dereferencing a null pointer - --> $DIR/lint-deref-nullptr.rs:33:36 + --> $DIR/lint-deref-nullptr.rs:34:36 | LL | let offset = ptr::addr_of!((*ptr::null::()).field); | ^^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed From 47523223436d870e921d660bfa7441be58509b38 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Mon, 24 Nov 2025 21:50:02 -0500 Subject: [PATCH 170/194] Add a little cfg_attr(bootstrap) to make the doctest work on stage1 --- compiler/rustc_lint/src/builtin.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 185cb4d522f2..36f4ad64a42b 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -2699,6 +2699,7 @@ fn ty_find_init_error<'tcx>( /// /// ```rust,compile_fail /// # #![allow(unused)] + /// # #![cfg_attr(bootstrap, deny(deref_nullptr))] /// use std::ptr; /// unsafe { /// let x = &*ptr::null::(); From 525cdc75dc2a821ab01867f904f06cc8a7f66c41 Mon Sep 17 00:00:00 2001 From: Adwin White Date: Fri, 21 Nov 2025 11:54:27 +0800 Subject: [PATCH 171/194] skip checking supertraits in assembly_object_bound_candidate for NormalizesTo goal --- .../src/solve/assembly/mod.rs | 2 + .../src/solve/normalizes_to/mod.rs | 14 +++++++ .../skip-supertraits-in-object-candidate.rs | 39 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 tests/ui/traits/next-solver/normalize/skip-supertraits-in-object-candidate.rs diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs index 4ecd56dfa40b..d27d80a086ad 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs @@ -74,6 +74,8 @@ fn probe_and_consider_implied_clause( /// Consider a clause specifically for a `dyn Trait` self type. This requires /// additionally checking all of the supertraits and object bounds to hold, /// since they're not implied by the well-formedness of the object type. + /// `NormalizesTo` overrides this to not check the supertraits for backwards + /// compatibility with the old solver. cc trait-system-refactor-initiative#245. fn probe_and_consider_object_bound_candidate( ecx: &mut EvalCtxt<'_, D>, source: CandidateSource, diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs index 794bda7726a4..c65e0bb25897 100644 --- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs @@ -184,6 +184,20 @@ fn match_assumption( then(ecx) } + // Hack for trait-system-refactor-initiative#245. + // FIXME(-Zhigher-ranked-assumptions): this impl differs from trait goals and we should unify + // them again once we properly support binders. + fn probe_and_consider_object_bound_candidate( + ecx: &mut EvalCtxt<'_, D>, + source: CandidateSource, + goal: Goal, + assumption: I::Clause, + ) -> Result, NoSolution> { + Self::probe_and_match_goal_against_assumption(ecx, source, goal, assumption, |ecx| { + ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) + }) + } + fn consider_additional_alias_assumptions( _ecx: &mut EvalCtxt<'_, D>, _goal: Goal, diff --git a/tests/ui/traits/next-solver/normalize/skip-supertraits-in-object-candidate.rs b/tests/ui/traits/next-solver/normalize/skip-supertraits-in-object-candidate.rs new file mode 100644 index 000000000000..9b13b78d024b --- /dev/null +++ b/tests/ui/traits/next-solver/normalize/skip-supertraits-in-object-candidate.rs @@ -0,0 +1,39 @@ +//@ check-pass +//@ compile-flags: -Znext-solver +//@ edition: 2024 + +// A regression test for trait-system-refactor-initiative#245. +// The old solver doesn't check the supertraits of the principal trait +// when considering object candidate for normalization. +// And the new solver previously did, resulting in a placeholder error +// while normalizing inside of a generator witness. + +trait AsyncFn: Send + 'static { + type Fut: Future + Send; + + fn call(&self) -> Self::Fut; +} + +type BoxFuture<'a, T> = std::pin::Pin + Send + 'a>>; +type DynAsyncFnBoxed = dyn AsyncFn>; + +fn wrap_call(func: Box

) -> impl Future { + func.call() +} + +fn get_boxed_fn() -> Box { + todo!() +} + +async fn cursed_fut() { + wrap_call(get_boxed_fn()).await; +} + +fn observe_fut_not_send() { + fn assert_send(t: T) -> T { + t + } + assert_send(cursed_fut()); +} + +fn main() {} From 5b57d02e9fc0816da86fdb7aaa1d496b6e9b522a Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 17 Oct 2025 06:19:58 +0200 Subject: [PATCH 172/194] compiletest: Use `//@` prefixes also for debuginfo test directives So that when we later add support for revisions we can use the same syntax for revisions as elsewhere. This also prevents people from making typos for commands since `src/tools/compiletest/src/directives/directive_names.rs` will catch such typos now. Note that we one FIXME for a non-trivial change for later: ``` // FIXME(148097): Change `// cdb-checksimple_closure` to `//@ cdb-check:simple_closure` ``` --- .../src/directives/directive_names.rs | 6 + src/tools/compiletest/src/runtest/debugger.rs | 2 +- src/tools/tidy/src/style.rs | 6 +- tests/debuginfo/associated-types.rs | 100 ++-- tests/debuginfo/basic-stepping.rs | 32 +- .../debuginfo/basic-types-globals-metadata.rs | 64 +-- tests/debuginfo/basic-types-globals.rs | 126 ++--- tests/debuginfo/basic-types-metadata.rs | 99 ++-- tests/debuginfo/basic-types-mut-globals.rs | 124 ++--- tests/debuginfo/basic-types.rs | 188 +++---- tests/debuginfo/borrowed-basic.rs | 120 ++-- tests/debuginfo/borrowed-c-style-enum.rs | 28 +- tests/debuginfo/borrowed-enum.rs | 28 +- tests/debuginfo/borrowed-struct.rs | 60 +- tests/debuginfo/borrowed-tuple.rs | 28 +- tests/debuginfo/borrowed-unique-basic.rs | 124 ++--- tests/debuginfo/box.rs | 20 +- tests/debuginfo/boxed-struct.rs | 20 +- .../by-value-non-immediate-argument.rs | 80 +-- .../by-value-self-argument-in-trait-impl.rs | 40 +- tests/debuginfo/c-style-enum-in-composite.rs | 60 +- tests/debuginfo/c-style-enum.rs | 104 ++-- tests/debuginfo/captured-fields-1.rs | 76 +-- tests/debuginfo/captured-fields-2.rs | 28 +- .../debuginfo/closure-in-generic-function.rs | 44 +- tests/debuginfo/closures.rs | 89 +-- .../collapse-debuginfo-external-attr.rs | 10 +- ...buginfo-external-flag-overriden-by-attr.rs | 14 +- .../collapse-debuginfo-external-flag.rs | 10 +- ...ollapse-debuginfo-in-non-collapse-macro.rs | 88 +-- tests/debuginfo/collapse-debuginfo-no-attr.rs | 28 +- .../collapse-debuginfo-static-external.rs | 4 +- tests/debuginfo/collapse-debuginfo-static.rs | 4 +- .../collapse-debuginfo-with-attr-flag.rs | 28 +- .../debuginfo/collapse-debuginfo-with-attr.rs | 22 +- .../collapse-debuginfo-with-yes-flag.rs | 22 +- tests/debuginfo/constant-ordering-prologue.rs | 32 +- tests/debuginfo/coroutine-closure.rs | 10 +- tests/debuginfo/coroutine-locals.rs | 76 +-- tests/debuginfo/coroutine-objects.rs | 70 +-- tests/debuginfo/cross-crate-spans.rs | 64 +-- tests/debuginfo/destructured-fn-argument.rs | 488 ++++++++-------- .../destructured-for-loop-variable.rs | 224 ++++---- tests/debuginfo/destructured-local.rs | 348 ++++++------ tests/debuginfo/drop-locations.rs | 80 +-- tests/debuginfo/dummy_span.rs | 28 +- tests/debuginfo/duration-type.rs | 12 +- tests/debuginfo/embedded-visualizer.rs | 78 +-- tests/debuginfo/empty-string.rs | 20 +- tests/debuginfo/enum-thinlto.rs | 12 +- tests/debuginfo/evec-in-struct.rs | 44 +- tests/debuginfo/extern-c-fn.rs | 44 +- tests/debuginfo/f16-natvis.rs | 58 +- tests/debuginfo/fixed-sized-array.rs | 26 +- tests/debuginfo/fn_ptr.rs | 26 +- .../debuginfo/function-arg-initialization.rs | 304 +++++----- tests/debuginfo/function-arguments.rs | 44 +- tests/debuginfo/function-call.rs | 14 +- tests/debuginfo/function-names.rs | 90 +-- .../function-prologue-stepping-regular.rs | 174 +++--- tests/debuginfo/gdb-char.rs | 6 +- .../debuginfo/gdb-pretty-struct-and-enums.rs | 22 +- .../generic-enum-with-different-disr-sizes.rs | 72 +-- tests/debuginfo/generic-function.rs | 64 +-- tests/debuginfo/generic-functions-nested.rs | 84 +-- .../generic-method-on-generic-struct.rs | 144 ++--- ...eneric-static-method-on-struct-and-enum.rs | 26 +- tests/debuginfo/generic-struct-style-enum.rs | 20 +- tests/debuginfo/generic-struct.rs | 70 +-- tests/debuginfo/generic-tuple-style-enum.rs | 30 +- tests/debuginfo/include_string.rs | 32 +- tests/debuginfo/issue-12886.rs | 8 +- tests/debuginfo/issue-22656.rs | 10 +- tests/debuginfo/issue-57822.rs | 20 +- tests/debuginfo/lexical-scope-in-for-loop.rs | 88 +-- tests/debuginfo/lexical-scope-in-if-let.rs | 108 ++-- tests/debuginfo/lexical-scope-in-if.rs | 164 +++--- tests/debuginfo/lexical-scope-in-match.rs | 180 +++--- .../lexical-scope-in-parameterless-closure.rs | 4 +- .../lexical-scope-in-stack-closure.rs | 76 +-- .../lexical-scope-in-unconditional-loop.rs | 160 +++--- .../lexical-scope-in-unique-closure.rs | 76 +-- tests/debuginfo/lexical-scope-in-while.rs | 160 +++--- tests/debuginfo/lexical-scope-with-macro.rs | 152 ++--- .../lexical-scopes-in-block-expression.rs | 520 +++++++++--------- tests/debuginfo/limited-debuginfo.rs | 18 +- tests/debuginfo/macro-stepping.rs | 126 ++--- tests/debuginfo/marker-types.rs | 38 +- tests/debuginfo/method-on-enum.rs | 144 ++--- tests/debuginfo/method-on-generic-struct.rs | 144 ++--- tests/debuginfo/method-on-struct.rs | 144 ++--- tests/debuginfo/method-on-trait.rs | 144 ++--- tests/debuginfo/method-on-tuple-struct.rs | 144 ++--- tests/debuginfo/msvc-pretty-enums.rs | 398 +++++++------- tests/debuginfo/msvc-scalarpair-params.rs | 80 +-- tests/debuginfo/multi-cgu.rs | 28 +- tests/debuginfo/multiline-calls.rs | 16 +- .../multiple-functions-equal-var-names.rs | 36 +- tests/debuginfo/multiple-functions.rs | 36 +- tests/debuginfo/mutable-locs.rs | 92 ++-- tests/debuginfo/mutex.rs | 24 +- .../name-shadowing-and-scope-nesting.rs | 124 ++--- tests/debuginfo/no_mangle-info.rs | 30 +- tests/debuginfo/numeric-types.rs | 316 +++++------ tests/debuginfo/opt/dead_refs.rs | 28 +- tests/debuginfo/option-like-enum.rs | 78 +-- .../packed-struct-with-destructor.rs | 68 +-- tests/debuginfo/packed-struct.rs | 52 +- tests/debuginfo/path.rs | 18 +- tests/debuginfo/pretty-huge-vec.rs | 10 +- tests/debuginfo/pretty-slices.rs | 36 +- .../debuginfo/pretty-std-collections-hash.rs | 136 ++--- tests/debuginfo/pretty-std-collections.rs | 72 +-- tests/debuginfo/pretty-std.rs | 196 +++---- tests/debuginfo/pretty-uninitialized-vec.rs | 6 +- tests/debuginfo/range-types.rs | 42 +- tests/debuginfo/rc_arc.rs | 150 ++--- tests/debuginfo/recursive-enum.rs | 2 +- tests/debuginfo/recursive-struct.rs | 84 +-- tests/debuginfo/reference-debuginfo.rs | 128 ++--- .../regression-bad-location-list-67992.rs | 12 +- tests/debuginfo/result-types.rs | 14 +- tests/debuginfo/rwlock-read.rs | 18 +- tests/debuginfo/rwlock-write.rs | 10 +- tests/debuginfo/self-in-default-method.rs | 144 ++--- .../self-in-generic-default-method.rs | 144 ++--- tests/debuginfo/shadowed-argument.rs | 64 +-- tests/debuginfo/shadowed-variable.rs | 104 ++-- tests/debuginfo/should-fail.rs | 18 +- tests/debuginfo/simd.rs | 44 +- tests/debuginfo/simple-lexical-scope.rs | 88 +-- tests/debuginfo/simple-struct.rs | 102 ++-- tests/debuginfo/simple-tuple.rs | 184 +++---- tests/debuginfo/skip_second_statement.rs | 158 +++--- .../skip_second_statement_collapse.rs | 158 +++--- .../static-method-on-struct-and-enum.rs | 52 +- tests/debuginfo/step-into-match.rs | 442 +++++++-------- tests/debuginfo/strings-and-strs.rs | 44 +- tests/debuginfo/struct-in-enum.rs | 30 +- tests/debuginfo/struct-in-struct.rs | 48 +- tests/debuginfo/struct-namespace.rs | 18 +- tests/debuginfo/struct-style-enum.rs | 38 +- tests/debuginfo/struct-with-destructor.rs | 36 +- tests/debuginfo/thread-names.rs | 26 +- tests/debuginfo/thread.rs | 14 +- tests/debuginfo/trait-pointers.rs | 4 +- tests/debuginfo/tuple-in-struct.rs | 42 +- tests/debuginfo/tuple-in-tuple.rs | 180 +++--- tests/debuginfo/tuple-struct.rs | 52 +- tests/debuginfo/tuple-style-enum.rs | 38 +- tests/debuginfo/type-names.rs | 338 ++++++------ tests/debuginfo/union-smoke.rs | 20 +- tests/debuginfo/unique-enum.rs | 28 +- tests/debuginfo/unit-type.rs | 54 +- tests/debuginfo/unsized.rs | 52 +- .../var-captured-in-nested-closure.rs | 192 +++---- .../var-captured-in-sendable-closure.rs | 36 +- .../var-captured-in-stack-closure.rs | 156 +++--- tests/debuginfo/vec-slices.rs | 96 ++-- tests/debuginfo/vec.rs | 16 +- .../debuginfo/zst-interferes-with-prologue.rs | 28 +- 161 files changed, 6562 insertions(+), 6556 deletions(-) diff --git a/src/tools/compiletest/src/directives/directive_names.rs b/src/tools/compiletest/src/directives/directive_names.rs index 8d1232a47596..7b1c0a18670d 100644 --- a/src/tools/compiletest/src/directives/directive_names.rs +++ b/src/tools/compiletest/src/directives/directive_names.rs @@ -18,6 +18,8 @@ "build-aux-docs", "build-fail", "build-pass", + "cdb-check", + "cdb-command", "check-fail", "check-pass", "check-run-results", @@ -39,6 +41,8 @@ "filecheck-flags", "forbid-output", "force-host", + "gdb-check", + "gdb-command", "ignore-16bit", "ignore-32bit", "ignore-64bit", @@ -139,6 +143,8 @@ "ignore-x86_64-unknown-linux-gnu", "incremental", "known-bug", + "lldb-check", + "lldb-command", "llvm-cov-flags", "max-llvm-major-version", "min-cdb-version", diff --git a/src/tools/compiletest/src/runtest/debugger.rs b/src/tools/compiletest/src/runtest/debugger.rs index 3d439e98eb7e..00935ab57d1c 100644 --- a/src/tools/compiletest/src/runtest/debugger.rs +++ b/src/tools/compiletest/src/runtest/debugger.rs @@ -38,7 +38,7 @@ pub fn parse_from(file: &Utf8Path, debugger_prefix: &str) -> Result {b: -1, b1: 0} -// gdb-command:continue +//@ gdb-command:print arg +//@ gdb-check:$1 = associated_types::Struct {b: -1, b1: 0} +//@ gdb-command:continue -// gdb-command:print inferred -// gdb-check:$2 = 1 -// gdb-command:print explicitly -// gdb-check:$3 = 1 -// gdb-command:continue +//@ gdb-command:print inferred +//@ gdb-check:$2 = 1 +//@ gdb-command:print explicitly +//@ gdb-check:$3 = 1 +//@ gdb-command:continue -// gdb-command:print arg -// gdb-check:$4 = 2 -// gdb-command:continue +//@ gdb-command:print arg +//@ gdb-check:$4 = 2 +//@ gdb-command:continue -// gdb-command:print arg -// gdb-check:$5 = (4, 5) -// gdb-command:continue +//@ gdb-command:print arg +//@ gdb-check:$5 = (4, 5) +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$6 = 6 -// gdb-command:print b -// gdb-check:$7 = 7 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$6 = 6 +//@ gdb-command:print b +//@ gdb-check:$7 = 7 +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$8 = 8 -// gdb-command:print b -// gdb-check:$9 = 9 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$8 = 8 +//@ gdb-command:print b +//@ gdb-check:$9 = 9 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v arg -// lldb-check:[...] { b = -1 b1 = 0 } -// lldb-command:continue +//@ lldb-command:v arg +//@ lldb-check:[...] { b = -1 b1 = 0 } +//@ lldb-command:continue -// lldb-command:v inferred -// lldb-check:[...] 1 -// lldb-command:v explicitly -// lldb-check:[...] 1 -// lldb-command:continue +//@ lldb-command:v inferred +//@ lldb-check:[...] 1 +//@ lldb-command:v explicitly +//@ lldb-check:[...] 1 +//@ lldb-command:continue -// lldb-command:v arg -// lldb-check:[...] 2 -// lldb-command:continue +//@ lldb-command:v arg +//@ lldb-check:[...] 2 +//@ lldb-command:continue -// lldb-command:v arg -// lldb-check:[...] { 0 = 4 1 = 5 } -// lldb-command:continue +//@ lldb-command:v arg +//@ lldb-check:[...] { 0 = 4 1 = 5 } +//@ lldb-command:continue -// lldb-command:v a -// lldb-check:[...] 6 -// lldb-command:v b -// lldb-check:[...] 7 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 6 +//@ lldb-command:v b +//@ lldb-check:[...] 7 +//@ lldb-command:continue -// lldb-command:v a -// lldb-check:[...] 8 -// lldb-command:v b -// lldb-check:[...] 9 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 8 +//@ lldb-command:v b +//@ lldb-check:[...] 9 +//@ lldb-command:continue #![allow(unused_variables)] #![allow(dead_code)] diff --git a/tests/debuginfo/basic-stepping.rs b/tests/debuginfo/basic-stepping.rs index f8198f54830c..ffb5d87710dc 100644 --- a/tests/debuginfo/basic-stepping.rs +++ b/tests/debuginfo/basic-stepping.rs @@ -8,30 +8,30 @@ //@ compile-flags: -g //@ ignore-backends: gcc -// gdb-command: run +//@ gdb-command: run // FIXME(#97083): Should we be able to break on initialization of zero-sized types? // FIXME(#97083): Right now the first breakable line is: -// gdb-check: let mut c = 27; -// gdb-command: next -// gdb-check: let d = c = 99; -// gdb-command: next +//@ gdb-check: let mut c = 27; +//@ gdb-command: next +//@ gdb-check: let d = c = 99; +//@ gdb-command: next // FIXME(#33013): gdb-check: let e = "hi bob"; // FIXME(#33013): gdb-command: next // FIXME(#33013): gdb-check: let f = b"hi bob"; // FIXME(#33013): gdb-command: next // FIXME(#33013): gdb-check: let g = b'9'; // FIXME(#33013): gdb-command: next -// gdb-check: let h = ["whatever"; 8]; -// gdb-command: next -// gdb-check: let i = [1,2,3,4]; -// gdb-command: next -// gdb-check: let j = (23, "hi"); -// gdb-command: next -// gdb-check: let k = 2..3; -// gdb-command: next -// gdb-check: let l = &i[k]; -// gdb-command: next -// gdb-check: let m: *const() = &a; +//@ gdb-check: let h = ["whatever"; 8]; +//@ gdb-command: next +//@ gdb-check: let i = [1,2,3,4]; +//@ gdb-command: next +//@ gdb-check: let j = (23, "hi"); +//@ gdb-command: next +//@ gdb-check: let k = 2..3; +//@ gdb-command: next +//@ gdb-check: let l = &i[k]; +//@ gdb-command: next +//@ gdb-check: let m: *const() = &a; fn main () { let a = (); // #break diff --git a/tests/debuginfo/basic-types-globals-metadata.rs b/tests/debuginfo/basic-types-globals-metadata.rs index cc32b338da72..3f1d9fd5de27 100644 --- a/tests/debuginfo/basic-types-globals-metadata.rs +++ b/tests/debuginfo/basic-types-globals-metadata.rs @@ -2,38 +2,38 @@ //@ disable-gdb-pretty-printers //@ ignore-backends: gcc -// gdb-command:run -// gdb-command:whatis basic_types_globals_metadata::B -// gdb-check:type = bool -// gdb-command:whatis basic_types_globals_metadata::I -// gdb-check:type = isize -// gdb-command:whatis basic_types_globals_metadata::C -// gdb-check:type = char -// gdb-command:whatis basic_types_globals_metadata::I8 -// gdb-check:type = i8 -// gdb-command:whatis basic_types_globals_metadata::I16 -// gdb-check:type = i16 -// gdb-command:whatis basic_types_globals_metadata::I32 -// gdb-check:type = i32 -// gdb-command:whatis basic_types_globals_metadata::I64 -// gdb-check:type = i64 -// gdb-command:whatis basic_types_globals_metadata::U -// gdb-check:type = usize -// gdb-command:whatis basic_types_globals_metadata::U8 -// gdb-check:type = u8 -// gdb-command:whatis basic_types_globals_metadata::U16 -// gdb-check:type = u16 -// gdb-command:whatis basic_types_globals_metadata::U32 -// gdb-check:type = u32 -// gdb-command:whatis basic_types_globals_metadata::U64 -// gdb-check:type = u64 -// gdb-command:whatis basic_types_globals_metadata::F16 -// gdb-check:type = f16 -// gdb-command:whatis basic_types_globals_metadata::F32 -// gdb-check:type = f32 -// gdb-command:whatis basic_types_globals_metadata::F64 -// gdb-check:type = f64 -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:whatis basic_types_globals_metadata::B +//@ gdb-check:type = bool +//@ gdb-command:whatis basic_types_globals_metadata::I +//@ gdb-check:type = isize +//@ gdb-command:whatis basic_types_globals_metadata::C +//@ gdb-check:type = char +//@ gdb-command:whatis basic_types_globals_metadata::I8 +//@ gdb-check:type = i8 +//@ gdb-command:whatis basic_types_globals_metadata::I16 +//@ gdb-check:type = i16 +//@ gdb-command:whatis basic_types_globals_metadata::I32 +//@ gdb-check:type = i32 +//@ gdb-command:whatis basic_types_globals_metadata::I64 +//@ gdb-check:type = i64 +//@ gdb-command:whatis basic_types_globals_metadata::U +//@ gdb-check:type = usize +//@ gdb-command:whatis basic_types_globals_metadata::U8 +//@ gdb-check:type = u8 +//@ gdb-command:whatis basic_types_globals_metadata::U16 +//@ gdb-check:type = u16 +//@ gdb-command:whatis basic_types_globals_metadata::U32 +//@ gdb-check:type = u32 +//@ gdb-command:whatis basic_types_globals_metadata::U64 +//@ gdb-check:type = u64 +//@ gdb-command:whatis basic_types_globals_metadata::F16 +//@ gdb-check:type = f16 +//@ gdb-command:whatis basic_types_globals_metadata::F32 +//@ gdb-check:type = f32 +//@ gdb-command:whatis basic_types_globals_metadata::F64 +//@ gdb-check:type = f64 +//@ gdb-command:continue #![allow(unused_variables)] #![allow(dead_code)] diff --git a/tests/debuginfo/basic-types-globals.rs b/tests/debuginfo/basic-types-globals.rs index b56a7108121f..819a016401a9 100644 --- a/tests/debuginfo/basic-types-globals.rs +++ b/tests/debuginfo/basic-types-globals.rs @@ -7,70 +7,70 @@ //@ [lto] no-prefer-dynamic //@ ignore-backends: gcc -// lldb-command:run -// lldb-command:v B -// lldb-check: ::B = false -// lldb-command:v I -// lldb-check: ::I = -1 -// lldb-command:v --format=d C -// lldb-check: ::C = 97 U+0x00000061 U'a' -// lldb-command:v --format=d I8 -// lldb-check: ::I8 = 68 -// lldb-command:v I16 -// lldb-check: ::I16 = -16 -// lldb-command:v I32 -// lldb-check: ::I32 = -32 -// lldb-command:v I64 -// lldb-check: ::I64 = -64 -// lldb-command:v U -// lldb-check: ::U = 1 -// lldb-command:v --format=d U8 -// lldb-check: ::U8 = 100 -// lldb-command:v U16 -// lldb-check: ::U16 = 16 -// lldb-command:v U32 -// lldb-check: ::U32 = 32 -// lldb-command:v U64 -// lldb-check: ::U64 = 64 -// lldb-command:v F16 -// lldb-check: ::F16 = 1.5 -// lldb-command:v F32 -// lldb-check: ::F32 = 2.5 -// lldb-command:v F64 -// lldb-check: ::F64 = 3.5 +//@ lldb-command:run +//@ lldb-command:v B +//@ lldb-check: ::B = false +//@ lldb-command:v I +//@ lldb-check: ::I = -1 +//@ lldb-command:v --format=d C +//@ lldb-check: ::C = 97 U+0x00000061 U'a' +//@ lldb-command:v --format=d I8 +//@ lldb-check: ::I8 = 68 +//@ lldb-command:v I16 +//@ lldb-check: ::I16 = -16 +//@ lldb-command:v I32 +//@ lldb-check: ::I32 = -32 +//@ lldb-command:v I64 +//@ lldb-check: ::I64 = -64 +//@ lldb-command:v U +//@ lldb-check: ::U = 1 +//@ lldb-command:v --format=d U8 +//@ lldb-check: ::U8 = 100 +//@ lldb-command:v U16 +//@ lldb-check: ::U16 = 16 +//@ lldb-command:v U32 +//@ lldb-check: ::U32 = 32 +//@ lldb-command:v U64 +//@ lldb-check: ::U64 = 64 +//@ lldb-command:v F16 +//@ lldb-check: ::F16 = 1.5 +//@ lldb-command:v F32 +//@ lldb-check: ::F32 = 2.5 +//@ lldb-command:v F64 +//@ lldb-check: ::F64 = 3.5 -// gdb-command:run -// gdb-command:print B -// gdb-check:$1 = false -// gdb-command:print I -// gdb-check:$2 = -1 -// gdb-command:print/d C -// gdb-check:$3 = 97 -// gdb-command:print I8 -// gdb-check:$4 = 68 -// gdb-command:print I16 -// gdb-check:$5 = -16 -// gdb-command:print I32 -// gdb-check:$6 = -32 -// gdb-command:print I64 -// gdb-check:$7 = -64 -// gdb-command:print U -// gdb-check:$8 = 1 -// gdb-command:print U8 -// gdb-check:$9 = 100 -// gdb-command:print U16 -// gdb-check:$10 = 16 -// gdb-command:print U32 -// gdb-check:$11 = 32 -// gdb-command:print U64 -// gdb-check:$12 = 64 -// gdb-command:print F16 -// gdb-check:$13 = 1.5 -// gdb-command:print F32 -// gdb-check:$14 = 2.5 -// gdb-command:print F64 -// gdb-check:$15 = 3.5 -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:print B +//@ gdb-check:$1 = false +//@ gdb-command:print I +//@ gdb-check:$2 = -1 +//@ gdb-command:print/d C +//@ gdb-check:$3 = 97 +//@ gdb-command:print I8 +//@ gdb-check:$4 = 68 +//@ gdb-command:print I16 +//@ gdb-check:$5 = -16 +//@ gdb-command:print I32 +//@ gdb-check:$6 = -32 +//@ gdb-command:print I64 +//@ gdb-check:$7 = -64 +//@ gdb-command:print U +//@ gdb-check:$8 = 1 +//@ gdb-command:print U8 +//@ gdb-check:$9 = 100 +//@ gdb-command:print U16 +//@ gdb-check:$10 = 16 +//@ gdb-command:print U32 +//@ gdb-check:$11 = 32 +//@ gdb-command:print U64 +//@ gdb-check:$12 = 64 +//@ gdb-command:print F16 +//@ gdb-check:$13 = 1.5 +//@ gdb-command:print F32 +//@ gdb-check:$14 = 2.5 +//@ gdb-command:print F64 +//@ gdb-check:$15 = 3.5 +//@ gdb-command:continue #![allow(unused_variables)] #![feature(f16)] diff --git a/tests/debuginfo/basic-types-metadata.rs b/tests/debuginfo/basic-types-metadata.rs index 495ef81a16c6..d3a3d03ef742 100644 --- a/tests/debuginfo/basic-types-metadata.rs +++ b/tests/debuginfo/basic-types-metadata.rs @@ -2,57 +2,56 @@ //@ disable-gdb-pretty-printers //@ ignore-backends: gcc -// gdb-command:run -// gdb-command:whatis unit -// gdb-check:type = () -// gdb-command:whatis b -// gdb-check:type = bool -// gdb-command:whatis i -// gdb-check:type = isize -// gdb-command:whatis c -// gdb-check:type = char -// gdb-command:whatis i8 -// gdb-check:type = i8 -// gdb-command:whatis i16 -// gdb-check:type = i16 -// gdb-command:whatis i32 -// gdb-check:type = i32 -// gdb-command:whatis i64 -// gdb-check:type = i64 -// gdb-command:whatis u -// gdb-check:type = usize -// gdb-command:whatis u8 -// gdb-check:type = u8 -// gdb-command:whatis u16 -// gdb-check:type = u16 -// gdb-command:whatis u32 -// gdb-check:type = u32 -// gdb-command:whatis u64 -// gdb-check:type = u64 -// gdb-command:whatis f16 -// gdb-check:type = f16 -// gdb-command:whatis f32 -// gdb-check:type = f32 -// gdb-command:whatis f64 -// gdb-check:type = f64 -// gdb-command:whatis fnptr -// gdb-check:type = *mut fn () -// gdb-command:info functions _yyy -// gdb-check:static fn basic_types_metadata::_yyy(); -// gdb-command:ptype closure_0 -// gdb-check: type = struct basic_types_metadata::main::{closure_env#0} -// gdb-command:ptype closure_1 -// gdb-check: type = struct basic_types_metadata::main::{closure_env#1} { -// gdb-check: *mut bool, -// gdb-check: } -// gdb-command:ptype closure_2 -// gdb-check: type = struct basic_types_metadata::main::{closure_env#2} { -// gdb-check: *mut bool, -// gdb-check: *mut isize, -// gdb-check: } +//@ gdb-command:run +//@ gdb-command:whatis unit +//@ gdb-check:type = () +//@ gdb-command:whatis b +//@ gdb-check:type = bool +//@ gdb-command:whatis i +//@ gdb-check:type = isize +//@ gdb-command:whatis c +//@ gdb-check:type = char +//@ gdb-command:whatis i8 +//@ gdb-check:type = i8 +//@ gdb-command:whatis i16 +//@ gdb-check:type = i16 +//@ gdb-command:whatis i32 +//@ gdb-check:type = i32 +//@ gdb-command:whatis i64 +//@ gdb-check:type = i64 +//@ gdb-command:whatis u +//@ gdb-check:type = usize +//@ gdb-command:whatis u8 +//@ gdb-check:type = u8 +//@ gdb-command:whatis u16 +//@ gdb-check:type = u16 +//@ gdb-command:whatis u32 +//@ gdb-check:type = u32 +//@ gdb-command:whatis u64 +//@ gdb-check:type = u64 +//@ gdb-command:whatis f16 +//@ gdb-check:type = f16 +//@ gdb-command:whatis f32 +//@ gdb-check:type = f32 +//@ gdb-command:whatis f64 +//@ gdb-check:type = f64 +//@ gdb-command:whatis fnptr +//@ gdb-check:type = *mut fn () +//@ gdb-command:info functions _yyy +//@ gdb-check:static fn basic_types_metadata::_yyy(); +//@ gdb-command:ptype closure_0 +//@ gdb-check: type = struct basic_types_metadata::main::{closure_env#0} +//@ gdb-command:ptype closure_1 +//@ gdb-check: type = struct basic_types_metadata::main::{closure_env#1} { +//@ gdb-check: *mut bool, +//@ gdb-check: } +//@ gdb-command:ptype closure_2 +//@ gdb-check: type = struct basic_types_metadata::main::{closure_env#2} { +//@ gdb-check: *mut bool, +//@ gdb-check: *mut isize, +//@ gdb-check: } -// -// gdb-command:continue +//@ gdb-command:continue #![allow(unused_variables)] #![feature(f16)] diff --git a/tests/debuginfo/basic-types-mut-globals.rs b/tests/debuginfo/basic-types-mut-globals.rs index 6617f91c3df5..c3cc7be549d4 100644 --- a/tests/debuginfo/basic-types-mut-globals.rs +++ b/tests/debuginfo/basic-types-mut-globals.rs @@ -8,72 +8,72 @@ //@ disable-gdb-pretty-printers //@ ignore-backends: gcc -// gdb-command:run +//@ gdb-command:run // Check initializers -// gdb-command:print B -// gdb-check:$1 = false -// gdb-command:print I -// gdb-check:$2 = -1 -// gdb-command:print C -// gdb-check:$3 = 97 'a' -// gdb-command:print I8 -// gdb-check:$4 = 68 -// gdb-command:print I16 -// gdb-check:$5 = -16 -// gdb-command:print I32 -// gdb-check:$6 = -32 -// gdb-command:print I64 -// gdb-check:$7 = -64 -// gdb-command:print U -// gdb-check:$8 = 1 -// gdb-command:print U8 -// gdb-check:$9 = 100 -// gdb-command:print U16 -// gdb-check:$10 = 16 -// gdb-command:print U32 -// gdb-check:$11 = 32 -// gdb-command:print U64 -// gdb-check:$12 = 64 -// gdb-command:print F16 -// gdb-check:$13 = 1.5 -// gdb-command:print F32 -// gdb-check:$14 = 2.5 -// gdb-command:print F64 -// gdb-check:$15 = 3.5 -// gdb-command:continue +//@ gdb-command:print B +//@ gdb-check:$1 = false +//@ gdb-command:print I +//@ gdb-check:$2 = -1 +//@ gdb-command:print C +//@ gdb-check:$3 = 97 'a' +//@ gdb-command:print I8 +//@ gdb-check:$4 = 68 +//@ gdb-command:print I16 +//@ gdb-check:$5 = -16 +//@ gdb-command:print I32 +//@ gdb-check:$6 = -32 +//@ gdb-command:print I64 +//@ gdb-check:$7 = -64 +//@ gdb-command:print U +//@ gdb-check:$8 = 1 +//@ gdb-command:print U8 +//@ gdb-check:$9 = 100 +//@ gdb-command:print U16 +//@ gdb-check:$10 = 16 +//@ gdb-command:print U32 +//@ gdb-check:$11 = 32 +//@ gdb-command:print U64 +//@ gdb-check:$12 = 64 +//@ gdb-command:print F16 +//@ gdb-check:$13 = 1.5 +//@ gdb-command:print F32 +//@ gdb-check:$14 = 2.5 +//@ gdb-command:print F64 +//@ gdb-check:$15 = 3.5 +//@ gdb-command:continue // Check new values -// gdb-command:print B -// gdb-check:$16 = true -// gdb-command:print I -// gdb-check:$17 = 2 -// gdb-command:print C -// gdb-check:$18 = 102 'f' -// gdb-command:print/d I8 -// gdb-check:$19 = 78 -// gdb-command:print I16 -// gdb-check:$20 = -26 -// gdb-command:print I32 -// gdb-check:$21 = -12 -// gdb-command:print I64 -// gdb-check:$22 = -54 -// gdb-command:print U -// gdb-check:$23 = 5 -// gdb-command:print/d U8 -// gdb-check:$24 = 20 -// gdb-command:print U16 -// gdb-check:$25 = 32 -// gdb-command:print U32 -// gdb-check:$26 = 16 -// gdb-command:print U64 -// gdb-check:$27 = 128 -// gdb-command:print F16 -// gdb-check:$28 = 2.25 -// gdb-command:print F32 -// gdb-check:$29 = 5.75 -// gdb-command:print F64 -// gdb-check:$30 = 9.25 +//@ gdb-command:print B +//@ gdb-check:$16 = true +//@ gdb-command:print I +//@ gdb-check:$17 = 2 +//@ gdb-command:print C +//@ gdb-check:$18 = 102 'f' +//@ gdb-command:print/d I8 +//@ gdb-check:$19 = 78 +//@ gdb-command:print I16 +//@ gdb-check:$20 = -26 +//@ gdb-command:print I32 +//@ gdb-check:$21 = -12 +//@ gdb-command:print I64 +//@ gdb-check:$22 = -54 +//@ gdb-command:print U +//@ gdb-check:$23 = 5 +//@ gdb-command:print/d U8 +//@ gdb-check:$24 = 20 +//@ gdb-command:print U16 +//@ gdb-check:$25 = 32 +//@ gdb-command:print U32 +//@ gdb-check:$26 = 16 +//@ gdb-command:print U64 +//@ gdb-check:$27 = 128 +//@ gdb-command:print F16 +//@ gdb-check:$28 = 2.25 +//@ gdb-command:print F32 +//@ gdb-check:$29 = 5.75 +//@ gdb-command:print F64 +//@ gdb-check:$30 = 9.25 #![allow(unused_variables)] #![feature(f16)] diff --git a/tests/debuginfo/basic-types.rs b/tests/debuginfo/basic-types.rs index 9b1452fab413..eea5c68d886f 100644 --- a/tests/debuginfo/basic-types.rs +++ b/tests/debuginfo/basic-types.rs @@ -10,108 +10,108 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print b -// gdb-check:$1 = false -// gdb-command:print i -// gdb-check:$2 = -1 -// gdb-command:print c -// gdb-check:$3 = 97 'a' -// gdb-command:print/d i8 -// gdb-check:$4 = 68 -// gdb-command:print i16 -// gdb-check:$5 = -16 -// gdb-command:print i32 -// gdb-check:$6 = -32 -// gdb-command:print i64 -// gdb-check:$7 = -64 -// gdb-command:print u -// gdb-check:$8 = 1 -// gdb-command:print/d u8 -// gdb-check:$9 = 100 -// gdb-command:print u16 -// gdb-check:$10 = 16 -// gdb-command:print u32 -// gdb-check:$11 = 32 -// gdb-command:print u64 -// gdb-check:$12 = 64 -// gdb-command:print f16 -// gdb-check:$13 = 1.5 -// gdb-command:print f32 -// gdb-check:$14 = 2.5 -// gdb-command:print f64 -// gdb-check:$15 = 3.5 -// gdb-command:print s -// gdb-check:$16 = "Hello, World!" +//@ gdb-command:run +//@ gdb-command:print b +//@ gdb-check:$1 = false +//@ gdb-command:print i +//@ gdb-check:$2 = -1 +//@ gdb-command:print c +//@ gdb-check:$3 = 97 'a' +//@ gdb-command:print/d i8 +//@ gdb-check:$4 = 68 +//@ gdb-command:print i16 +//@ gdb-check:$5 = -16 +//@ gdb-command:print i32 +//@ gdb-check:$6 = -32 +//@ gdb-command:print i64 +//@ gdb-check:$7 = -64 +//@ gdb-command:print u +//@ gdb-check:$8 = 1 +//@ gdb-command:print/d u8 +//@ gdb-check:$9 = 100 +//@ gdb-command:print u16 +//@ gdb-check:$10 = 16 +//@ gdb-command:print u32 +//@ gdb-check:$11 = 32 +//@ gdb-command:print u64 +//@ gdb-check:$12 = 64 +//@ gdb-command:print f16 +//@ gdb-check:$13 = 1.5 +//@ gdb-command:print f32 +//@ gdb-check:$14 = 2.5 +//@ gdb-command:print f64 +//@ gdb-check:$15 = 3.5 +//@ gdb-command:print s +//@ gdb-check:$16 = "Hello, World!" // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v b -// lldb-check:[...] false -// lldb-command:v i -// lldb-check:[...] -1 +//@ lldb-command:run +//@ lldb-command:v b +//@ lldb-check:[...] false +//@ lldb-command:v i +//@ lldb-check:[...] -1 -// lldb-command:v i8 -// lldb-check:[...] 'D' -// lldb-command:v i16 -// lldb-check:[...] -16 -// lldb-command:v i32 -// lldb-check:[...] -32 -// lldb-command:v i64 -// lldb-check:[...] -64 -// lldb-command:v u -// lldb-check:[...] 1 -// lldb-command:v u8 -// lldb-check:[...] 'd' -// lldb-command:v u16 -// lldb-check:[...] 16 -// lldb-command:v u32 -// lldb-check:[...] 32 -// lldb-command:v u64 -// lldb-check:[...] 64 -// lldb-command:v f32 -// lldb-check:[...] 2.5 -// lldb-command:v f64 -// lldb-check:[...] 3.5 +//@ lldb-command:v i8 +//@ lldb-check:[...] 'D' +//@ lldb-command:v i16 +//@ lldb-check:[...] -16 +//@ lldb-command:v i32 +//@ lldb-check:[...] -32 +//@ lldb-command:v i64 +//@ lldb-check:[...] -64 +//@ lldb-command:v u +//@ lldb-check:[...] 1 +//@ lldb-command:v u8 +//@ lldb-check:[...] 'd' +//@ lldb-command:v u16 +//@ lldb-check:[...] 16 +//@ lldb-command:v u32 +//@ lldb-check:[...] 32 +//@ lldb-command:v u64 +//@ lldb-check:[...] 64 +//@ lldb-command:v f32 +//@ lldb-check:[...] 2.5 +//@ lldb-command:v f64 +//@ lldb-check:[...] 3.5 // === CDB TESTS =================================================================================== -// cdb-command:g -// cdb-command:dx b -// cdb-check:b : false [Type: bool] -// cdb-command:dx i -// cdb-check:i : -1 [Type: [...]] -// cdb-command:dx c -// cdb-check:c : 0x61 'a' [Type: char32_t] -// cdb-command:dx i8 -// cdb-check:i8 : 68 [Type: char] -// cdb-command:dx i16 -// cdb-check:i16 : -16 [Type: short] -// cdb-command:dx i32 -// cdb-check:i32 : -32 [Type: int] -// cdb-command:dx i64 -// cdb-check:i64 : -64 [Type: __int64] -// cdb-command:dx u -// cdb-check:u : 0x1 [Type: [...]] -// cdb-command:dx u8 -// cdb-check:u8 : 0x64 [Type: unsigned char] -// cdb-command:dx u16 -// cdb-check:u16 : 0x10 [Type: unsigned short] -// cdb-command:dx u32 -// cdb-check:u32 : 0x20 [Type: unsigned int] -// cdb-command:dx u64 -// cdb-check:u64 : 0x40 [Type: unsigned __int64] -// cdb-command:dx f16 -// cdb-check:f16 : 1.500000 [Type: f16] -// cdb-command:dx f32 -// cdb-check:f32 : 2.500000 [Type: float] -// cdb-command:dx f64 -// cdb-check:f64 : 3.500000 [Type: double] -// cdb-command:.enable_unicode 1 +//@ cdb-command:g +//@ cdb-command:dx b +//@ cdb-check:b : false [Type: bool] +//@ cdb-command:dx i +//@ cdb-check:i : -1 [Type: [...]] +//@ cdb-command:dx c +//@ cdb-check:c : 0x61 'a' [Type: char32_t] +//@ cdb-command:dx i8 +//@ cdb-check:i8 : 68 [Type: char] +//@ cdb-command:dx i16 +//@ cdb-check:i16 : -16 [Type: short] +//@ cdb-command:dx i32 +//@ cdb-check:i32 : -32 [Type: int] +//@ cdb-command:dx i64 +//@ cdb-check:i64 : -64 [Type: __int64] +//@ cdb-command:dx u +//@ cdb-check:u : 0x1 [Type: [...]] +//@ cdb-command:dx u8 +//@ cdb-check:u8 : 0x64 [Type: unsigned char] +//@ cdb-command:dx u16 +//@ cdb-check:u16 : 0x10 [Type: unsigned short] +//@ cdb-command:dx u32 +//@ cdb-check:u32 : 0x20 [Type: unsigned int] +//@ cdb-command:dx u64 +//@ cdb-check:u64 : 0x40 [Type: unsigned __int64] +//@ cdb-command:dx f16 +//@ cdb-check:f16 : 1.500000 [Type: f16] +//@ cdb-command:dx f32 +//@ cdb-check:f32 : 2.500000 [Type: float] +//@ cdb-command:dx f64 +//@ cdb-check:f64 : 3.500000 [Type: double] +//@ cdb-command:.enable_unicode 1 // FIXME(#88840): The latest version of the Windows SDK broke the visualizer for str. -// cdb-command:dx s -// cdb-check:s : [...] [Type: ref$] +//@ cdb-command:dx s +//@ cdb-check:s : [...] [Type: ref$] #![allow(unused_variables)] #![feature(f16)] diff --git a/tests/debuginfo/borrowed-basic.rs b/tests/debuginfo/borrowed-basic.rs index 86c4df12866e..a3cffe3c6520 100644 --- a/tests/debuginfo/borrowed-basic.rs +++ b/tests/debuginfo/borrowed-basic.rs @@ -4,98 +4,98 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print *bool_ref -// gdb-check:$1 = true +//@ gdb-command:run +//@ gdb-command:print *bool_ref +//@ gdb-check:$1 = true -// gdb-command:print *int_ref -// gdb-check:$2 = -1 +//@ gdb-command:print *int_ref +//@ gdb-check:$2 = -1 -// gdb-command:print/d *char_ref -// gdb-check:$3 = 97 +//@ gdb-command:print/d *char_ref +//@ gdb-check:$3 = 97 -// gdb-command:print *i8_ref -// gdb-check:$4 = 68 +//@ gdb-command:print *i8_ref +//@ gdb-check:$4 = 68 -// gdb-command:print *i16_ref -// gdb-check:$5 = -16 +//@ gdb-command:print *i16_ref +//@ gdb-check:$5 = -16 -// gdb-command:print *i32_ref -// gdb-check:$6 = -32 +//@ gdb-command:print *i32_ref +//@ gdb-check:$6 = -32 -// gdb-command:print *i64_ref -// gdb-check:$7 = -64 +//@ gdb-command:print *i64_ref +//@ gdb-check:$7 = -64 -// gdb-command:print *uint_ref -// gdb-check:$8 = 1 +//@ gdb-command:print *uint_ref +//@ gdb-check:$8 = 1 -// gdb-command:print *u8_ref -// gdb-check:$9 = 100 +//@ gdb-command:print *u8_ref +//@ gdb-check:$9 = 100 -// gdb-command:print *u16_ref -// gdb-check:$10 = 16 +//@ gdb-command:print *u16_ref +//@ gdb-check:$10 = 16 -// gdb-command:print *u32_ref -// gdb-check:$11 = 32 +//@ gdb-command:print *u32_ref +//@ gdb-check:$11 = 32 -// gdb-command:print *u64_ref -// gdb-check:$12 = 64 +//@ gdb-command:print *u64_ref +//@ gdb-check:$12 = 64 -// gdb-command:print *f16_ref -// gdb-check:$13 = 1.5 +//@ gdb-command:print *f16_ref +//@ gdb-check:$13 = 1.5 -// gdb-command:print *f32_ref -// gdb-check:$14 = 2.5 +//@ gdb-command:print *f32_ref +//@ gdb-check:$14 = 2.5 -// gdb-command:print *f64_ref -// gdb-check:$15 = 3.5 +//@ gdb-command:print *f64_ref +//@ gdb-check:$15 = 3.5 // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v *bool_ref -// lldb-check:[...] true +//@ lldb-command:run +//@ lldb-command:v *bool_ref +//@ lldb-check:[...] true -// lldb-command:v *int_ref -// lldb-check:[...] -1 +//@ lldb-command:v *int_ref +//@ lldb-check:[...] -1 -// lldb-command:v *i8_ref -// lldb-check:[...] 'D' +//@ lldb-command:v *i8_ref +//@ lldb-check:[...] 'D' -// lldb-command:v *i16_ref -// lldb-check:[...] -16 +//@ lldb-command:v *i16_ref +//@ lldb-check:[...] -16 -// lldb-command:v *i32_ref -// lldb-check:[...] -32 +//@ lldb-command:v *i32_ref +//@ lldb-check:[...] -32 -// lldb-command:v *i64_ref -// lldb-check:[...] -64 +//@ lldb-command:v *i64_ref +//@ lldb-check:[...] -64 -// lldb-command:v *uint_ref -// lldb-check:[...] 1 +//@ lldb-command:v *uint_ref +//@ lldb-check:[...] 1 -// lldb-command:v *u8_ref -// lldb-check:[...] 'd' +//@ lldb-command:v *u8_ref +//@ lldb-check:[...] 'd' -// lldb-command:v *u16_ref -// lldb-check:[...] 16 +//@ lldb-command:v *u16_ref +//@ lldb-check:[...] 16 -// lldb-command:v *u32_ref -// lldb-check:[...] 32 +//@ lldb-command:v *u32_ref +//@ lldb-check:[...] 32 -// lldb-command:v *u64_ref -// lldb-check:[...] 64 +//@ lldb-command:v *u64_ref +//@ lldb-check:[...] 64 -// lldb-command:v *f16_ref -// lldb-check:[...] 1.5 +//@ lldb-command:v *f16_ref +//@ lldb-check:[...] 1.5 -// lldb-command:v *f32_ref -// lldb-check:[...] 2.5 +//@ lldb-command:v *f32_ref +//@ lldb-check:[...] 2.5 -// lldb-command:v *f64_ref -// lldb-check:[...] 3.5 +//@ lldb-command:v *f64_ref +//@ lldb-check:[...] 3.5 #![allow(unused_variables)] #![feature(f16)] diff --git a/tests/debuginfo/borrowed-c-style-enum.rs b/tests/debuginfo/borrowed-c-style-enum.rs index b331775743b4..2aad83841213 100644 --- a/tests/debuginfo/borrowed-c-style-enum.rs +++ b/tests/debuginfo/borrowed-c-style-enum.rs @@ -4,30 +4,30 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print *the_a_ref -// gdb-check:$1 = borrowed_c_style_enum::ABC::TheA +//@ gdb-command:print *the_a_ref +//@ gdb-check:$1 = borrowed_c_style_enum::ABC::TheA -// gdb-command:print *the_b_ref -// gdb-check:$2 = borrowed_c_style_enum::ABC::TheB +//@ gdb-command:print *the_b_ref +//@ gdb-check:$2 = borrowed_c_style_enum::ABC::TheB -// gdb-command:print *the_c_ref -// gdb-check:$3 = borrowed_c_style_enum::ABC::TheC +//@ gdb-command:print *the_c_ref +//@ gdb-check:$3 = borrowed_c_style_enum::ABC::TheC // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v *the_a_ref -// lldb-check:[...] TheA +//@ lldb-command:v *the_a_ref +//@ lldb-check:[...] TheA -// lldb-command:v *the_b_ref -// lldb-check:[...] TheB +//@ lldb-command:v *the_b_ref +//@ lldb-check:[...] TheB -// lldb-command:v *the_c_ref -// lldb-check:[...] TheC +//@ lldb-command:v *the_c_ref +//@ lldb-check:[...] TheC #![allow(unused_variables)] diff --git a/tests/debuginfo/borrowed-enum.rs b/tests/debuginfo/borrowed-enum.rs index f3769172558b..9c6e466c43c2 100644 --- a/tests/debuginfo/borrowed-enum.rs +++ b/tests/debuginfo/borrowed-enum.rs @@ -6,28 +6,28 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print *the_a_ref -// gdb-check:$1 = borrowed_enum::ABC::TheA{x: 0, y: 8970181431921507452} +//@ gdb-command:print *the_a_ref +//@ gdb-check:$1 = borrowed_enum::ABC::TheA{x: 0, y: 8970181431921507452} -// gdb-command:print *the_b_ref -// gdb-check:$2 = borrowed_enum::ABC::TheB(0, 286331153, 286331153) +//@ gdb-command:print *the_b_ref +//@ gdb-check:$2 = borrowed_enum::ABC::TheB(0, 286331153, 286331153) -// gdb-command:print *univariant_ref -// gdb-check:$3 = borrowed_enum::Univariant::TheOnlyCase(4820353753753434) +//@ gdb-command:print *univariant_ref +//@ gdb-check:$3 = borrowed_enum::Univariant::TheOnlyCase(4820353753753434) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v *the_a_ref -// lldb-check:(borrowed_enum::ABC) *the_a_ref = TheA{x:0, y:8970181431921507452} { x = 0 y = 8970181431921507452 } -// lldb-command:v *the_b_ref -// lldb-check:(borrowed_enum::ABC) *the_b_ref = TheB(0, 286331153, 286331153) { 0 = 0 1 = 286331153 2 = 286331153 } -// lldb-command:v *univariant_ref -// lldb-check:(borrowed_enum::Univariant) *univariant_ref = TheOnlyCase(4820353753753434) { 0 = 4820353753753434 } +//@ lldb-command:v *the_a_ref +//@ lldb-check:(borrowed_enum::ABC) *the_a_ref = TheA{x:0, y:8970181431921507452} { x = 0 y = 8970181431921507452 } +//@ lldb-command:v *the_b_ref +//@ lldb-check:(borrowed_enum::ABC) *the_b_ref = TheB(0, 286331153, 286331153) { 0 = 0 1 = 286331153 2 = 286331153 } +//@ lldb-command:v *univariant_ref +//@ lldb-check:(borrowed_enum::Univariant) *univariant_ref = TheOnlyCase(4820353753753434) { 0 = 4820353753753434 } #![allow(unused_variables)] diff --git a/tests/debuginfo/borrowed-struct.rs b/tests/debuginfo/borrowed-struct.rs index 876ec30b1401..fccca09e91bb 100644 --- a/tests/debuginfo/borrowed-struct.rs +++ b/tests/debuginfo/borrowed-struct.rs @@ -4,54 +4,54 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print *stack_val_ref -// gdb-check:$1 = borrowed_struct::SomeStruct {x: 10, y: 23.5} +//@ gdb-command:print *stack_val_ref +//@ gdb-check:$1 = borrowed_struct::SomeStruct {x: 10, y: 23.5} -// gdb-command:print *stack_val_interior_ref_1 -// gdb-check:$2 = 10 +//@ gdb-command:print *stack_val_interior_ref_1 +//@ gdb-check:$2 = 10 -// gdb-command:print *stack_val_interior_ref_2 -// gdb-check:$3 = 23.5 +//@ gdb-command:print *stack_val_interior_ref_2 +//@ gdb-check:$3 = 23.5 -// gdb-command:print *ref_to_unnamed -// gdb-check:$4 = borrowed_struct::SomeStruct {x: 11, y: 24.5} +//@ gdb-command:print *ref_to_unnamed +//@ gdb-check:$4 = borrowed_struct::SomeStruct {x: 11, y: 24.5} -// gdb-command:print *unique_val_ref -// gdb-check:$5 = borrowed_struct::SomeStruct {x: 13, y: 26.5} +//@ gdb-command:print *unique_val_ref +//@ gdb-check:$5 = borrowed_struct::SomeStruct {x: 13, y: 26.5} -// gdb-command:print *unique_val_interior_ref_1 -// gdb-check:$6 = 13 +//@ gdb-command:print *unique_val_interior_ref_1 +//@ gdb-check:$6 = 13 -// gdb-command:print *unique_val_interior_ref_2 -// gdb-check:$7 = 26.5 +//@ gdb-command:print *unique_val_interior_ref_2 +//@ gdb-check:$7 = 26.5 // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v *stack_val_ref -// lldb-check:[...] { x = 10 y = 23.5 } +//@ lldb-command:v *stack_val_ref +//@ lldb-check:[...] { x = 10 y = 23.5 } -// lldb-command:v *stack_val_interior_ref_1 -// lldb-check:[...] 10 +//@ lldb-command:v *stack_val_interior_ref_1 +//@ lldb-check:[...] 10 -// lldb-command:v *stack_val_interior_ref_2 -// lldb-check:[...] 23.5 +//@ lldb-command:v *stack_val_interior_ref_2 +//@ lldb-check:[...] 23.5 -// lldb-command:v *ref_to_unnamed -// lldb-check:[...] { x = 11 y = 24.5 } +//@ lldb-command:v *ref_to_unnamed +//@ lldb-check:[...] { x = 11 y = 24.5 } -// lldb-command:v *unique_val_ref -// lldb-check:[...] { x = 13 y = 26.5 } +//@ lldb-command:v *unique_val_ref +//@ lldb-check:[...] { x = 13 y = 26.5 } -// lldb-command:v *unique_val_interior_ref_1 -// lldb-check:[...] 13 +//@ lldb-command:v *unique_val_interior_ref_1 +//@ lldb-check:[...] 13 -// lldb-command:v *unique_val_interior_ref_2 -// lldb-check:[...] 26.5 +//@ lldb-command:v *unique_val_interior_ref_2 +//@ lldb-check:[...] 26.5 #![allow(unused_variables)] diff --git a/tests/debuginfo/borrowed-tuple.rs b/tests/debuginfo/borrowed-tuple.rs index 42964c79485a..901d7f6ed08b 100644 --- a/tests/debuginfo/borrowed-tuple.rs +++ b/tests/debuginfo/borrowed-tuple.rs @@ -4,30 +4,30 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print *stack_val_ref -// gdb-check:$1 = (-14, -19) +//@ gdb-command:print *stack_val_ref +//@ gdb-check:$1 = (-14, -19) -// gdb-command:print *ref_to_unnamed -// gdb-check:$2 = (-15, -20) +//@ gdb-command:print *ref_to_unnamed +//@ gdb-check:$2 = (-15, -20) -// gdb-command:print *unique_val_ref -// gdb-check:$3 = (-17, -22) +//@ gdb-command:print *unique_val_ref +//@ gdb-check:$3 = (-17, -22) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v *stack_val_ref -// lldb-check:[...] { 0 = -14 1 = -19 } +//@ lldb-command:v *stack_val_ref +//@ lldb-check:[...] { 0 = -14 1 = -19 } -// lldb-command:v *ref_to_unnamed -// lldb-check:[...] { 0 = -15 1 = -20 } +//@ lldb-command:v *ref_to_unnamed +//@ lldb-check:[...] { 0 = -15 1 = -20 } -// lldb-command:v *unique_val_ref -// lldb-check:[...] { 0 = -17 1 = -22 } +//@ lldb-command:v *unique_val_ref +//@ lldb-check:[...] { 0 = -17 1 = -22 } #![allow(unused_variables)] diff --git a/tests/debuginfo/borrowed-unique-basic.rs b/tests/debuginfo/borrowed-unique-basic.rs index c230ceae1c75..b1c555569cce 100644 --- a/tests/debuginfo/borrowed-unique-basic.rs +++ b/tests/debuginfo/borrowed-unique-basic.rs @@ -4,102 +4,102 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print *bool_ref -// gdb-check:$1 = true +//@ gdb-command:print *bool_ref +//@ gdb-check:$1 = true -// gdb-command:print *int_ref -// gdb-check:$2 = -1 +//@ gdb-command:print *int_ref +//@ gdb-check:$2 = -1 -// gdb-command:print/d *char_ref -// gdb-check:$3 = 97 +//@ gdb-command:print/d *char_ref +//@ gdb-check:$3 = 97 -// gdb-command:print/d *i8_ref -// gdb-check:$4 = 68 +//@ gdb-command:print/d *i8_ref +//@ gdb-check:$4 = 68 -// gdb-command:print *i16_ref -// gdb-check:$5 = -16 +//@ gdb-command:print *i16_ref +//@ gdb-check:$5 = -16 -// gdb-command:print *i32_ref -// gdb-check:$6 = -32 +//@ gdb-command:print *i32_ref +//@ gdb-check:$6 = -32 -// gdb-command:print *i64_ref -// gdb-check:$7 = -64 +//@ gdb-command:print *i64_ref +//@ gdb-check:$7 = -64 -// gdb-command:print *uint_ref -// gdb-check:$8 = 1 +//@ gdb-command:print *uint_ref +//@ gdb-check:$8 = 1 -// gdb-command:print/d *u8_ref -// gdb-check:$9 = 100 +//@ gdb-command:print/d *u8_ref +//@ gdb-check:$9 = 100 -// gdb-command:print *u16_ref -// gdb-check:$10 = 16 +//@ gdb-command:print *u16_ref +//@ gdb-check:$10 = 16 -// gdb-command:print *u32_ref -// gdb-check:$11 = 32 +//@ gdb-command:print *u32_ref +//@ gdb-check:$11 = 32 -// gdb-command:print *u64_ref -// gdb-check:$12 = 64 +//@ gdb-command:print *u64_ref +//@ gdb-check:$12 = 64 -// gdb-command:print *f16_ref -// gdb-check:$13 = 1.5 +//@ gdb-command:print *f16_ref +//@ gdb-check:$13 = 1.5 -// gdb-command:print *f32_ref -// gdb-check:$14 = 2.5 +//@ gdb-command:print *f32_ref +//@ gdb-check:$14 = 2.5 -// gdb-command:print *f64_ref -// gdb-check:$15 = 3.5 +//@ gdb-command:print *f64_ref +//@ gdb-check:$15 = 3.5 // === LLDB TESTS ================================================================================== -// lldb-command:type format add -f decimal char -// lldb-command:type format add -f decimal 'unsigned char' -// lldb-command:run +//@ lldb-command:type format add -f decimal char +//@ lldb-command:type format add -f decimal 'unsigned char' +//@ lldb-command:run -// lldb-command:v *bool_ref -// lldb-check:[...] true +//@ lldb-command:v *bool_ref +//@ lldb-check:[...] true -// lldb-command:v *int_ref -// lldb-check:[...] -1 +//@ lldb-command:v *int_ref +//@ lldb-check:[...] -1 -// lldb-command:v *i8_ref -// lldb-check:[...] 68 +//@ lldb-command:v *i8_ref +//@ lldb-check:[...] 68 -// lldb-command:v *i16_ref -// lldb-check:[...] -16 +//@ lldb-command:v *i16_ref +//@ lldb-check:[...] -16 -// lldb-command:v *i32_ref -// lldb-check:[...] -32 +//@ lldb-command:v *i32_ref +//@ lldb-check:[...] -32 -// lldb-command:v *i64_ref -// lldb-check:[...] -64 +//@ lldb-command:v *i64_ref +//@ lldb-check:[...] -64 -// lldb-command:v *uint_ref -// lldb-check:[...] 1 +//@ lldb-command:v *uint_ref +//@ lldb-check:[...] 1 -// lldb-command:v *u8_ref -// lldb-check:[...] 100 +//@ lldb-command:v *u8_ref +//@ lldb-check:[...] 100 -// lldb-command:v *u16_ref -// lldb-check:[...] 16 +//@ lldb-command:v *u16_ref +//@ lldb-check:[...] 16 -// lldb-command:v *u32_ref -// lldb-check:[...] 32 +//@ lldb-command:v *u32_ref +//@ lldb-check:[...] 32 -// lldb-command:v *u64_ref -// lldb-check:[...] 64 +//@ lldb-command:v *u64_ref +//@ lldb-check:[...] 64 -// lldb-command:v *f16_ref -// lldb-check:[...] 1.5 +//@ lldb-command:v *f16_ref +//@ lldb-check:[...] 1.5 -// lldb-command:v *f32_ref -// lldb-check:[...] 2.5 +//@ lldb-command:v *f32_ref +//@ lldb-check:[...] 2.5 -// lldb-command:v *f64_ref -// lldb-check:[...] 3.5 +//@ lldb-command:v *f64_ref +//@ lldb-check:[...] 3.5 #![allow(unused_variables)] #![feature(f16)] diff --git a/tests/debuginfo/box.rs b/tests/debuginfo/box.rs index c5034410f49f..3d9d568e8e63 100644 --- a/tests/debuginfo/box.rs +++ b/tests/debuginfo/box.rs @@ -4,21 +4,21 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print *a -// gdb-check:$1 = 1 -// gdb-command:print *b -// gdb-check:$2 = (2, 3.5) +//@ gdb-command:print *a +//@ gdb-check:$1 = 1 +//@ gdb-command:print *b +//@ gdb-check:$2 = (2, 3.5) // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v *a -// lldb-check:[...] 1 -// lldb-command:v *b -// lldb-check:[...] { 0 = 2 1 = 3.5 } +//@ lldb-command:run +//@ lldb-command:v *a +//@ lldb-check:[...] 1 +//@ lldb-command:v *b +//@ lldb-check:[...] { 0 = 2 1 = 3.5 } #![allow(unused_variables)] diff --git a/tests/debuginfo/boxed-struct.rs b/tests/debuginfo/boxed-struct.rs index fc676e8ce618..4990a189f2f1 100644 --- a/tests/debuginfo/boxed-struct.rs +++ b/tests/debuginfo/boxed-struct.rs @@ -4,24 +4,24 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print *boxed_with_padding -// gdb-check:$1 = boxed_struct::StructWithSomePadding {x: 99, y: 999, z: 9999, w: 99999} +//@ gdb-command:print *boxed_with_padding +//@ gdb-check:$1 = boxed_struct::StructWithSomePadding {x: 99, y: 999, z: 9999, w: 99999} -// gdb-command:print *boxed_with_dtor -// gdb-check:$2 = boxed_struct::StructWithDestructor {x: 77, y: 777, z: 7777, w: 77777} +//@ gdb-command:print *boxed_with_dtor +//@ gdb-check:$2 = boxed_struct::StructWithDestructor {x: 77, y: 777, z: 7777, w: 77777} // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v *boxed_with_padding -// lldb-check:[...] { x = 99 y = 999 z = 9999 w = 99999 } +//@ lldb-command:v *boxed_with_padding +//@ lldb-check:[...] { x = 99 y = 999 z = 9999 w = 99999 } -// lldb-command:v *boxed_with_dtor -// lldb-check:[...] { x = 77 y = 777 z = 7777 w = 77777 } +//@ lldb-command:v *boxed_with_dtor +//@ lldb-check:[...] { x = 77 y = 777 z = 7777 w = 77777 } #![allow(unused_variables)] diff --git a/tests/debuginfo/by-value-non-immediate-argument.rs b/tests/debuginfo/by-value-non-immediate-argument.rs index b5b0df73a68a..523f6b7623d1 100644 --- a/tests/debuginfo/by-value-non-immediate-argument.rs +++ b/tests/debuginfo/by-value-non-immediate-argument.rs @@ -8,60 +8,60 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print s -// gdb-check:$1 = by_value_non_immediate_argument::Struct {a: 1, b: 2.5} -// gdb-command:continue +//@ gdb-command:print s +//@ gdb-check:$1 = by_value_non_immediate_argument::Struct {a: 1, b: 2.5} +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$2 = by_value_non_immediate_argument::Struct {a: 3, b: 4.5} -// gdb-command:print y -// gdb-check:$3 = 5 -// gdb-command:print z -// gdb-check:$4 = 6.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$2 = by_value_non_immediate_argument::Struct {a: 3, b: 4.5} +//@ gdb-command:print y +//@ gdb-check:$3 = 5 +//@ gdb-command:print z +//@ gdb-check:$4 = 6.5 +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$5 = (7, 8, 9.5, 10.5) -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$5 = (7, 8, 9.5, 10.5) +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$6 = by_value_non_immediate_argument::Newtype (11.5, 12.5, 13, 14) -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$6 = by_value_non_immediate_argument::Newtype (11.5, 12.5, 13, 14) +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$7 = by_value_non_immediate_argument::Enum::Case1{x: 0, y: 8970181431921507452} -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$7 = by_value_non_immediate_argument::Enum::Case1{x: 0, y: 8970181431921507452} +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v s -// lldb-check:[...] Struct { a = 1 b = 2.5 } -// lldb-command:continue +//@ lldb-command:v s +//@ lldb-check:[...] Struct { a = 1 b = 2.5 } +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] Struct { a = 3 b = 4.5 } -// lldb-command:v y -// lldb-check:[...] 5 -// lldb-command:v z -// lldb-check:[...] 6.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] Struct { a = 3 b = 4.5 } +//@ lldb-command:v y +//@ lldb-check:[...] 5 +//@ lldb-command:v z +//@ lldb-check:[...] 6.5 +//@ lldb-command:continue -// lldb-command:v a -// lldb-check:[...] (7, 8, 9.5, 10.5) -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] (7, 8, 9.5, 10.5) +//@ lldb-command:continue -// lldb-command:v a -// lldb-check:[...] Newtype(11.5, 12.5, 13, 14) -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] Newtype(11.5, 12.5, 13, 14) +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] Case1 { x: 0, y: 8970181431921507452 } -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] Case1 { x: 0, y: 8970181431921507452 } +//@ lldb-command:continue #[derive(Clone)] struct Struct { diff --git a/tests/debuginfo/by-value-self-argument-in-trait-impl.rs b/tests/debuginfo/by-value-self-argument-in-trait-impl.rs index 409cfc533c87..9f36e3d89ee9 100644 --- a/tests/debuginfo/by-value-self-argument-in-trait-impl.rs +++ b/tests/debuginfo/by-value-self-argument-in-trait-impl.rs @@ -4,36 +4,36 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print self -// gdb-check:$1 = 1111 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$1 = 1111 +//@ gdb-command:continue -// gdb-command:print self -// gdb-check:$2 = by_value_self_argument_in_trait_impl::Struct {x: 2222, y: 3333} -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$2 = by_value_self_argument_in_trait_impl::Struct {x: 2222, y: 3333} +//@ gdb-command:continue -// gdb-command:print self -// gdb-check:$3 = (4444.5, 5555, 6666, 7777.5) -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$3 = (4444.5, 5555, 6666, 7777.5) +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v self -// lldb-check:[...] 1111 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] 1111 +//@ lldb-command:continue -// lldb-command:v self -// lldb-check:[...] { x = 2222 y = 3333 } -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = 2222 y = 3333 } +//@ lldb-command:continue -// lldb-command:v self -// lldb-check:[...] { 0 = 4444.5 1 = 5555 2 = 6666 3 = 7777.5 } -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { 0 = 4444.5 1 = 5555 2 = 6666 3 = 7777.5 } +//@ lldb-command:continue trait Trait { fn method(self) -> Self; diff --git a/tests/debuginfo/c-style-enum-in-composite.rs b/tests/debuginfo/c-style-enum-in-composite.rs index 137cb2656fc5..d28ad6cc7370 100644 --- a/tests/debuginfo/c-style-enum-in-composite.rs +++ b/tests/debuginfo/c-style-enum-in-composite.rs @@ -4,53 +4,53 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print tuple_interior_padding -// gdb-check:$1 = (0, c_style_enum_in_composite::AnEnum::OneHundred) +//@ gdb-command:print tuple_interior_padding +//@ gdb-check:$1 = (0, c_style_enum_in_composite::AnEnum::OneHundred) -// gdb-command:print tuple_padding_at_end -// gdb-check:$2 = ((1, c_style_enum_in_composite::AnEnum::OneThousand), 2) +//@ gdb-command:print tuple_padding_at_end +//@ gdb-check:$2 = ((1, c_style_enum_in_composite::AnEnum::OneThousand), 2) -// gdb-command:print tuple_different_enums -// gdb-check:$3 = (c_style_enum_in_composite::AnEnum::OneThousand, c_style_enum_in_composite::AnotherEnum::MountainView, c_style_enum_in_composite::AnEnum::OneMillion, c_style_enum_in_composite::AnotherEnum::Vienna) +//@ gdb-command:print tuple_different_enums +//@ gdb-check:$3 = (c_style_enum_in_composite::AnEnum::OneThousand, c_style_enum_in_composite::AnotherEnum::MountainView, c_style_enum_in_composite::AnEnum::OneMillion, c_style_enum_in_composite::AnotherEnum::Vienna) -// gdb-command:print padded_struct -// gdb-check:$4 = c_style_enum_in_composite::PaddedStruct {a: 3, b: c_style_enum_in_composite::AnEnum::OneMillion, c: 4, d: c_style_enum_in_composite::AnotherEnum::Toronto, e: 5} +//@ gdb-command:print padded_struct +//@ gdb-check:$4 = c_style_enum_in_composite::PaddedStruct {a: 3, b: c_style_enum_in_composite::AnEnum::OneMillion, c: 4, d: c_style_enum_in_composite::AnotherEnum::Toronto, e: 5} -// gdb-command:print packed_struct -// gdb-check:$5 = c_style_enum_in_composite::PackedStruct {a: 6, b: c_style_enum_in_composite::AnEnum::OneHundred, c: 7, d: c_style_enum_in_composite::AnotherEnum::Vienna, e: 8} +//@ gdb-command:print packed_struct +//@ gdb-check:$5 = c_style_enum_in_composite::PackedStruct {a: 6, b: c_style_enum_in_composite::AnEnum::OneHundred, c: 7, d: c_style_enum_in_composite::AnotherEnum::Vienna, e: 8} -// gdb-command:print non_padded_struct -// gdb-check:$6 = c_style_enum_in_composite::NonPaddedStruct {a: c_style_enum_in_composite::AnEnum::OneMillion, b: c_style_enum_in_composite::AnotherEnum::MountainView, c: c_style_enum_in_composite::AnEnum::OneThousand, d: c_style_enum_in_composite::AnotherEnum::Toronto} +//@ gdb-command:print non_padded_struct +//@ gdb-check:$6 = c_style_enum_in_composite::NonPaddedStruct {a: c_style_enum_in_composite::AnEnum::OneMillion, b: c_style_enum_in_composite::AnotherEnum::MountainView, c: c_style_enum_in_composite::AnEnum::OneThousand, d: c_style_enum_in_composite::AnotherEnum::Toronto} -// gdb-command:print struct_with_drop -// gdb-check:$7 = (c_style_enum_in_composite::StructWithDrop {a: c_style_enum_in_composite::AnEnum::OneHundred, b: c_style_enum_in_composite::AnotherEnum::Vienna}, 9) +//@ gdb-command:print struct_with_drop +//@ gdb-check:$7 = (c_style_enum_in_composite::StructWithDrop {a: c_style_enum_in_composite::AnEnum::OneHundred, b: c_style_enum_in_composite::AnotherEnum::Vienna}, 9) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v tuple_interior_padding -// lldb-check:[...] { 0 = 0 1 = OneHundred } +//@ lldb-command:v tuple_interior_padding +//@ lldb-check:[...] { 0 = 0 1 = OneHundred } -// lldb-command:v tuple_padding_at_end -// lldb-check:[...] ((1, OneThousand), 2) { 0 = (1, OneThousand) { 0 = 1 1 = OneThousand } 1 = 2 } +//@ lldb-command:v tuple_padding_at_end +//@ lldb-check:[...] ((1, OneThousand), 2) { 0 = (1, OneThousand) { 0 = 1 1 = OneThousand } 1 = 2 } -// lldb-command:v tuple_different_enums -// lldb-check:[...] { 0 = OneThousand 1 = MountainView 2 = OneMillion 3 = Vienna } +//@ lldb-command:v tuple_different_enums +//@ lldb-check:[...] { 0 = OneThousand 1 = MountainView 2 = OneMillion 3 = Vienna } -// lldb-command:v padded_struct -// lldb-check:[...] { a = 3 b = OneMillion c = 4 d = Toronto e = 5 } +//@ lldb-command:v padded_struct +//@ lldb-check:[...] { a = 3 b = OneMillion c = 4 d = Toronto e = 5 } -// lldb-command:v packed_struct -// lldb-check:[...] { a = 6 b = OneHundred c = 7 d = Vienna e = 8 } +//@ lldb-command:v packed_struct +//@ lldb-check:[...] { a = 6 b = OneHundred c = 7 d = Vienna e = 8 } -// lldb-command:v non_padded_struct -// lldb-check:[...] { a = OneMillion b = MountainView c = OneThousand d = Toronto } +//@ lldb-command:v non_padded_struct +//@ lldb-check:[...] { a = OneMillion b = MountainView c = OneThousand d = Toronto } -// lldb-command:v struct_with_drop -// lldb-check:[...] { 0 = { a = OneHundred b = Vienna } 1 = 9 } +//@ lldb-command:v struct_with_drop +//@ lldb-check:[...] { 0 = { a = OneHundred b = Vienna } 1 = 9 } #![allow(unused_variables)] diff --git a/tests/debuginfo/c-style-enum.rs b/tests/debuginfo/c-style-enum.rs index 79438e3f2d43..5e568222727c 100644 --- a/tests/debuginfo/c-style-enum.rs +++ b/tests/debuginfo/c-style-enum.rs @@ -6,87 +6,87 @@ // === GDB TESTS =================================================================================== -// gdb-command:print c_style_enum::SINGLE_VARIANT -// gdb-check:$1 = c_style_enum::SingleVariant::TheOnlyVariant +//@ gdb-command:print c_style_enum::SINGLE_VARIANT +//@ gdb-check:$1 = c_style_enum::SingleVariant::TheOnlyVariant -// gdb-command:print c_style_enum::AUTO_ONE -// gdb-check:$2 = c_style_enum::AutoDiscriminant::One +//@ gdb-command:print c_style_enum::AUTO_ONE +//@ gdb-check:$2 = c_style_enum::AutoDiscriminant::One -// gdb-command:print c_style_enum::AUTO_TWO -// gdb-check:$3 = c_style_enum::AutoDiscriminant::One +//@ gdb-command:print c_style_enum::AUTO_TWO +//@ gdb-check:$3 = c_style_enum::AutoDiscriminant::One -// gdb-command:print c_style_enum::AUTO_THREE -// gdb-check:$4 = c_style_enum::AutoDiscriminant::One +//@ gdb-command:print c_style_enum::AUTO_THREE +//@ gdb-check:$4 = c_style_enum::AutoDiscriminant::One -// gdb-command:print c_style_enum::MANUAL_ONE -// gdb-check:$5 = c_style_enum::ManualDiscriminant::OneHundred +//@ gdb-command:print c_style_enum::MANUAL_ONE +//@ gdb-check:$5 = c_style_enum::ManualDiscriminant::OneHundred -// gdb-command:print c_style_enum::MANUAL_TWO -// gdb-check:$6 = c_style_enum::ManualDiscriminant::OneHundred +//@ gdb-command:print c_style_enum::MANUAL_TWO +//@ gdb-check:$6 = c_style_enum::ManualDiscriminant::OneHundred -// gdb-command:print c_style_enum::MANUAL_THREE -// gdb-check:$7 = c_style_enum::ManualDiscriminant::OneHundred +//@ gdb-command:print c_style_enum::MANUAL_THREE +//@ gdb-check:$7 = c_style_enum::ManualDiscriminant::OneHundred -// gdb-command:run +//@ gdb-command:run -// gdb-command:print auto_one -// gdb-check:$8 = c_style_enum::AutoDiscriminant::One +//@ gdb-command:print auto_one +//@ gdb-check:$8 = c_style_enum::AutoDiscriminant::One -// gdb-command:print auto_two -// gdb-check:$9 = c_style_enum::AutoDiscriminant::Two +//@ gdb-command:print auto_two +//@ gdb-check:$9 = c_style_enum::AutoDiscriminant::Two -// gdb-command:print auto_three -// gdb-check:$10 = c_style_enum::AutoDiscriminant::Three +//@ gdb-command:print auto_three +//@ gdb-check:$10 = c_style_enum::AutoDiscriminant::Three -// gdb-command:print manual_one_hundred -// gdb-check:$11 = c_style_enum::ManualDiscriminant::OneHundred +//@ gdb-command:print manual_one_hundred +//@ gdb-check:$11 = c_style_enum::ManualDiscriminant::OneHundred -// gdb-command:print manual_one_thousand -// gdb-check:$12 = c_style_enum::ManualDiscriminant::OneThousand +//@ gdb-command:print manual_one_thousand +//@ gdb-check:$12 = c_style_enum::ManualDiscriminant::OneThousand -// gdb-command:print manual_one_million -// gdb-check:$13 = c_style_enum::ManualDiscriminant::OneMillion +//@ gdb-command:print manual_one_million +//@ gdb-check:$13 = c_style_enum::ManualDiscriminant::OneMillion -// gdb-command:print single_variant -// gdb-check:$14 = c_style_enum::SingleVariant::TheOnlyVariant +//@ gdb-command:print single_variant +//@ gdb-check:$14 = c_style_enum::SingleVariant::TheOnlyVariant -// gdb-command:print AUTO_TWO -// gdb-check:$15 = c_style_enum::AutoDiscriminant::Two +//@ gdb-command:print AUTO_TWO +//@ gdb-check:$15 = c_style_enum::AutoDiscriminant::Two -// gdb-command:print AUTO_THREE -// gdb-check:$16 = c_style_enum::AutoDiscriminant::Three +//@ gdb-command:print AUTO_THREE +//@ gdb-check:$16 = c_style_enum::AutoDiscriminant::Three -// gdb-command:print MANUAL_TWO -// gdb-check:$17 = c_style_enum::ManualDiscriminant::OneThousand +//@ gdb-command:print MANUAL_TWO +//@ gdb-check:$17 = c_style_enum::ManualDiscriminant::OneThousand -// gdb-command:print MANUAL_THREE -// gdb-check:$18 = c_style_enum::ManualDiscriminant::OneMillion +//@ gdb-command:print MANUAL_THREE +//@ gdb-check:$18 = c_style_enum::ManualDiscriminant::OneMillion // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v auto_one -// lldb-check:[...] One +//@ lldb-command:v auto_one +//@ lldb-check:[...] One -// lldb-command:v auto_two -// lldb-check:[...] Two +//@ lldb-command:v auto_two +//@ lldb-check:[...] Two -// lldb-command:v auto_three -// lldb-check:[...] Three +//@ lldb-command:v auto_three +//@ lldb-check:[...] Three -// lldb-command:v manual_one_hundred -// lldb-check:[...] OneHundred +//@ lldb-command:v manual_one_hundred +//@ lldb-check:[...] OneHundred -// lldb-command:v manual_one_thousand -// lldb-check:[...] OneThousand +//@ lldb-command:v manual_one_thousand +//@ lldb-check:[...] OneThousand -// lldb-command:v manual_one_million -// lldb-check:[...] OneMillion +//@ lldb-command:v manual_one_million +//@ lldb-check:[...] OneMillion -// lldb-command:v single_variant -// lldb-check:[...] TheOnlyVariant +//@ lldb-command:v single_variant +//@ lldb-check:[...] TheOnlyVariant #![allow(unused_variables)] #![allow(dead_code)] diff --git a/tests/debuginfo/captured-fields-1.rs b/tests/debuginfo/captured-fields-1.rs index 53f77d314685..81651331519c 100644 --- a/tests/debuginfo/captured-fields-1.rs +++ b/tests/debuginfo/captured-fields-1.rs @@ -3,47 +3,47 @@ //@ ignore-backends: gcc // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print test -// gdb-check:$1 = captured_fields_1::main::{closure_env#0} {_ref__my_ref__my_field1: 0x[...]} -// gdb-command:continue -// gdb-command:print test -// gdb-check:$2 = captured_fields_1::main::{closure_env#1} {_ref__my_ref__my_field2: 0x[...]} -// gdb-command:continue -// gdb-command:print test -// gdb-check:$3 = captured_fields_1::main::{closure_env#2} {_ref__my_ref: 0x[...]} -// gdb-command:continue -// gdb-command:print test -// gdb-check:$4 = captured_fields_1::main::{closure_env#3} {my_ref: 0x[...]} -// gdb-command:continue -// gdb-command:print test -// gdb-check:$5 = captured_fields_1::main::{closure_env#4} {my_var__my_field2: 22} -// gdb-command:continue -// gdb-command:print test -// gdb-check:$6 = captured_fields_1::main::{closure_env#5} {my_var: captured_fields_1::MyStruct {my_field1: 11, my_field2: 22}} -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:print test +//@ gdb-check:$1 = captured_fields_1::main::{closure_env#0} {_ref__my_ref__my_field1: 0x[...]} +//@ gdb-command:continue +//@ gdb-command:print test +//@ gdb-check:$2 = captured_fields_1::main::{closure_env#1} {_ref__my_ref__my_field2: 0x[...]} +//@ gdb-command:continue +//@ gdb-command:print test +//@ gdb-check:$3 = captured_fields_1::main::{closure_env#2} {_ref__my_ref: 0x[...]} +//@ gdb-command:continue +//@ gdb-command:print test +//@ gdb-check:$4 = captured_fields_1::main::{closure_env#3} {my_ref: 0x[...]} +//@ gdb-command:continue +//@ gdb-command:print test +//@ gdb-check:$5 = captured_fields_1::main::{closure_env#4} {my_var__my_field2: 22} +//@ gdb-command:continue +//@ gdb-command:print test +//@ gdb-check:$6 = captured_fields_1::main::{closure_env#5} {my_var: captured_fields_1::MyStruct {my_field1: 11, my_field2: 22}} +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v test -// lldb-check:(captured_fields_1::main::{closure_env#0}) test = { _ref__my_ref__my_field1 = 0x[...] } -// lldb-command:continue -// lldb-command:v test -// lldb-check:(captured_fields_1::main::{closure_env#1}) test = { _ref__my_ref__my_field2 = 0x[...] } -// lldb-command:continue -// lldb-command:v test -// lldb-check:(captured_fields_1::main::{closure_env#2}) test = { _ref__my_ref = 0x[...] } -// lldb-command:continue -// lldb-command:v test -// lldb-check:(captured_fields_1::main::{closure_env#3}) test = { my_ref = 0x[...] } -// lldb-command:continue -// lldb-command:v test -// lldb-check:(captured_fields_1::main::{closure_env#4}) test = { my_var__my_field2 = 22 } -// lldb-command:continue -// lldb-command:v test -// lldb-check:(captured_fields_1::main::{closure_env#5}) test = { my_var = { my_field1 = 11 my_field2 = 22 } } -// lldb-command:continue +//@ lldb-command:run +//@ lldb-command:v test +//@ lldb-check:(captured_fields_1::main::{closure_env#0}) test = { _ref__my_ref__my_field1 = 0x[...] } +//@ lldb-command:continue +//@ lldb-command:v test +//@ lldb-check:(captured_fields_1::main::{closure_env#1}) test = { _ref__my_ref__my_field2 = 0x[...] } +//@ lldb-command:continue +//@ lldb-command:v test +//@ lldb-check:(captured_fields_1::main::{closure_env#2}) test = { _ref__my_ref = 0x[...] } +//@ lldb-command:continue +//@ lldb-command:v test +//@ lldb-check:(captured_fields_1::main::{closure_env#3}) test = { my_ref = 0x[...] } +//@ lldb-command:continue +//@ lldb-command:v test +//@ lldb-check:(captured_fields_1::main::{closure_env#4}) test = { my_var__my_field2 = 22 } +//@ lldb-command:continue +//@ lldb-command:v test +//@ lldb-check:(captured_fields_1::main::{closure_env#5}) test = { my_var = { my_field1 = 11 my_field2 = 22 } } +//@ lldb-command:continue #![allow(unused)] diff --git a/tests/debuginfo/captured-fields-2.rs b/tests/debuginfo/captured-fields-2.rs index cdebeaf3a975..db1b867cb90e 100644 --- a/tests/debuginfo/captured-fields-2.rs +++ b/tests/debuginfo/captured-fields-2.rs @@ -3,23 +3,23 @@ //@ ignore-backends: gcc // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print my_ref__my_field1 -// gdb-check:$1 = 11 -// gdb-command:continue -// gdb-command:print my_var__my_field2 -// gdb-check:$2 = 22 -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:print my_ref__my_field1 +//@ gdb-check:$1 = 11 +//@ gdb-command:continue +//@ gdb-command:print my_var__my_field2 +//@ gdb-check:$2 = 22 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v my_ref__my_field1 -// lldb-check:(unsigned int) my_ref__my_field1 = 11 -// lldb-command:continue -// lldb-command:v my_var__my_field2 -// lldb-check:(unsigned int) my_var__my_field2 = 22 -// lldb-command:continue +//@ lldb-command:run +//@ lldb-command:v my_ref__my_field1 +//@ lldb-check:(unsigned int) my_ref__my_field1 = 11 +//@ lldb-command:continue +//@ lldb-command:v my_var__my_field2 +//@ lldb-check:(unsigned int) my_var__my_field2 = 22 +//@ lldb-command:continue #![allow(unused)] diff --git a/tests/debuginfo/closure-in-generic-function.rs b/tests/debuginfo/closure-in-generic-function.rs index 88769399f089..1f171c24d162 100644 --- a/tests/debuginfo/closure-in-generic-function.rs +++ b/tests/debuginfo/closure-in-generic-function.rs @@ -4,36 +4,36 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print x -// gdb-check:$1 = 0.5 -// gdb-command:print y -// gdb-check:$2 = 10 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = 0.5 +//@ gdb-command:print y +//@ gdb-check:$2 = 10 +//@ gdb-command:continue -// gdb-command:print *x -// gdb-check:$3 = 29 -// gdb-command:print *y -// gdb-check:$4 = 110 -// gdb-command:continue +//@ gdb-command:print *x +//@ gdb-check:$3 = 29 +//@ gdb-command:print *y +//@ gdb-check:$4 = 110 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v x -// lldb-check:[...] 0.5 -// lldb-command:v y -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 0.5 +//@ lldb-command:v y +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v *x -// lldb-check:[...] 29 -// lldb-command:v *y -// lldb-check:[...] 110 -// lldb-command:continue +//@ lldb-command:v *x +//@ lldb-check:[...] 29 +//@ lldb-command:v *y +//@ lldb-check:[...] 110 +//@ lldb-command:continue fn some_generic_fun(a: T1, b: T2) -> (T2, T1) { diff --git a/tests/debuginfo/closures.rs b/tests/debuginfo/closures.rs index f5220a49e29d..2cad6aacae7b 100644 --- a/tests/debuginfo/closures.rs +++ b/tests/debuginfo/closures.rs @@ -3,51 +3,52 @@ // === CDB TESTS =================================================================================== // Generic functions cause ambigious breakpoints. -// cdb-command:dx @$debuggerRootNamespace.Debugger.Settings.EngineInitialization.ResolveAmbiguousBreakpoints = true; -// cdb-command:bp `closures.rs:57` -// cdb-command:g -// cdb-command:dx add_closure -// cdb-check:add_closure [Type: closures::main::closure_env$0] -// cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] -// cdb-command:dx increment -// cdb-check:increment [Type: closures::main::closure_env$1] -// cdb-check: [+0x[...]] _ref__count : 0x[...] : 2 [Type: int *] -// cdb-command:dx consume_closure -// cdb-check:consume_closure [Type: closures::main::closure_env$2] -// cdb-check: [+0x[...]] x : [...] [Type: alloc::string::String] -// cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] -// cdb-command:dx simple_closure +//@ cdb-command:dx @$debuggerRootNamespace.Debugger.Settings.EngineInitialization.ResolveAmbiguousBreakpoints = true; +//@ cdb-command:bp `closures.rs:57` +//@ cdb-command:g +//@ cdb-command:dx add_closure +//@ cdb-check:add_closure [Type: closures::main::closure_env$0] +//@ cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] +//@ cdb-command:dx increment +//@ cdb-check:increment [Type: closures::main::closure_env$1] +//@ cdb-check: [+0x[...]] _ref__count : 0x[...] : 2 [Type: int *] +//@ cdb-command:dx consume_closure +//@ cdb-check:consume_closure [Type: closures::main::closure_env$2] +//@ cdb-check: [+0x[...]] x : [...] [Type: alloc::string::String] +//@ cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] +//@ cdb-command:dx simple_closure +// FIXME(#148097): Change `// cdb-checksimple_closure` to `//@ cdb-check:simple_closure` // cdb-checksimple_closure [Type: closures::main::closure_env$5] -// cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] -// cdb-command:g -// cdb-command:dx first_closure -// cdb-check:first_closure [Type: closures::main::closure_env$6] -// cdb-check: [+0x[...]] _ref__variable : 0x[...] : 1 [Type: int *] -// cdb-check: [+0x[...]] _ref__constant : 0x[...] : 2 [Type: int *] -// cdb-check: [+0x[...]] _ref__a_struct : 0x[...] [Type: closures::Struct *] -// cdb-check: [+0x[...]] _ref__struct_ref : 0x[...] [Type: closures::Struct * *] -// cdb-check: [+0x[...]] _ref__owned_value : 0x[...] [Type: int * *] -// cdb-command:g -// cdb-command:dx many_param_closure -// cdb-check:many_param_closure [Type: closures::main::closure_env$7] -// cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] -// cdb-command:g -// cdb-command:dv -// cdb-command:dx generic_closure -// cdb-check:generic_closure [Type: closures::generic_func::closure_env$0] -// cdb-check: [+0x[...]] _ref__x : 0x[...] : 42 [Type: int *] -// cdb-command:g -// cdb-command:dx generic_closure -// cdb-check:generic_closure [Type: closures::generic_func::closure_env$0 >] -// cdb-check: [+0x000] _ref__x : 0x[...] : "base_value" [Type: ref$ *] -// cdb-command:g -// cdb-command:dx second_closure -// cdb-check:second_closure [Type: closures::main::closure_env$8] -// cdb-check: [+0x[...]] _ref__variable : 0x[...] : 2 [Type: int *] -// cdb-check: [+0x[...]] _ref__constant : 0x[...] : 2 [Type: int *] -// cdb-check: [+0x[...]] _ref__a_struct : 0x[...] [Type: closures::Struct *] -// cdb-check: [+0x[...]] _ref__struct_ref : 0x[...] [Type: closures::Struct * *] -// cdb-check: [+0x[...]] _ref__owned_value : 0x[...] [Type: int * *] +//@ cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] +//@ cdb-command:g +//@ cdb-command:dx first_closure +//@ cdb-check:first_closure [Type: closures::main::closure_env$6] +//@ cdb-check: [+0x[...]] _ref__variable : 0x[...] : 1 [Type: int *] +//@ cdb-check: [+0x[...]] _ref__constant : 0x[...] : 2 [Type: int *] +//@ cdb-check: [+0x[...]] _ref__a_struct : 0x[...] [Type: closures::Struct *] +//@ cdb-check: [+0x[...]] _ref__struct_ref : 0x[...] [Type: closures::Struct * *] +//@ cdb-check: [+0x[...]] _ref__owned_value : 0x[...] [Type: int * *] +//@ cdb-command:g +//@ cdb-command:dx many_param_closure +//@ cdb-check:many_param_closure [Type: closures::main::closure_env$7] +//@ cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *] +//@ cdb-command:g +//@ cdb-command:dv +//@ cdb-command:dx generic_closure +//@ cdb-check:generic_closure [Type: closures::generic_func::closure_env$0] +//@ cdb-check: [+0x[...]] _ref__x : 0x[...] : 42 [Type: int *] +//@ cdb-command:g +//@ cdb-command:dx generic_closure +//@ cdb-check:generic_closure [Type: closures::generic_func::closure_env$0 >] +//@ cdb-check: [+0x000] _ref__x : 0x[...] : "base_value" [Type: ref$ *] +//@ cdb-command:g +//@ cdb-command:dx second_closure +//@ cdb-check:second_closure [Type: closures::main::closure_env$8] +//@ cdb-check: [+0x[...]] _ref__variable : 0x[...] : 2 [Type: int *] +//@ cdb-check: [+0x[...]] _ref__constant : 0x[...] : 2 [Type: int *] +//@ cdb-check: [+0x[...]] _ref__a_struct : 0x[...] [Type: closures::Struct *] +//@ cdb-check: [+0x[...]] _ref__struct_ref : 0x[...] [Type: closures::Struct * *] +//@ cdb-check: [+0x[...]] _ref__owned_value : 0x[...] [Type: int * *] #[inline(never)] fn generic_func(x: Tfunc) { diff --git a/tests/debuginfo/collapse-debuginfo-external-attr.rs b/tests/debuginfo/collapse-debuginfo-external-attr.rs index 4d4fa92726f8..7f4e6cda9f3f 100644 --- a/tests/debuginfo/collapse-debuginfo-external-attr.rs +++ b/tests/debuginfo/collapse-debuginfo-external-attr.rs @@ -6,11 +6,11 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#one_callsite[...] -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#one_callsite[...] +//@ gdb-command:continue fn one() { println!("one"); diff --git a/tests/debuginfo/collapse-debuginfo-external-flag-overriden-by-attr.rs b/tests/debuginfo/collapse-debuginfo-external-flag-overriden-by-attr.rs index ab0ae8fef4df..adbd1e4d9eab 100644 --- a/tests/debuginfo/collapse-debuginfo-external-flag-overriden-by-attr.rs +++ b/tests/debuginfo/collapse-debuginfo-external-flag-overriden-by-attr.rs @@ -7,13 +7,13 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#one_callsite[...] -// gdb-command:next -// gdb-command:frame -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#one_callsite[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-command:continue fn one() { println!("one"); diff --git a/tests/debuginfo/collapse-debuginfo-external-flag.rs b/tests/debuginfo/collapse-debuginfo-external-flag.rs index b8e73d227b36..40082dce86c8 100644 --- a/tests/debuginfo/collapse-debuginfo-external-flag.rs +++ b/tests/debuginfo/collapse-debuginfo-external-flag.rs @@ -6,11 +6,11 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#println_callsite[...] -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#println_callsite[...] +//@ gdb-command:continue macro_rules! outer { () => { diff --git a/tests/debuginfo/collapse-debuginfo-in-non-collapse-macro.rs b/tests/debuginfo/collapse-debuginfo-in-non-collapse-macro.rs index bafa5408b197..29ed348340bb 100644 --- a/tests/debuginfo/collapse-debuginfo-in-non-collapse-macro.rs +++ b/tests/debuginfo/collapse-debuginfo-in-non-collapse-macro.rs @@ -10,50 +10,50 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_rem_call1[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call1_pre[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_in_proxy[...] -// gdb-command:next 2 -// gdb-check:[...]#loc_rem_call3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_add_call1[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call1_pre[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_in_proxy[...] -// gdb-command:next 2 -// gdb-check:[...]#loc_add_macro[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_add_call3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_reorder_call2[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_reorder_call3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_reorder_call1[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call1_pre[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_in_proxy[...] -// gdb-command:next 2 -// gdb-command:frame -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_rem_call1[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call1_pre[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_in_proxy[...] +//@ gdb-command:next 2 +//@ gdb-check:[...]#loc_rem_call3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add_call1[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call1_pre[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_in_proxy[...] +//@ gdb-command:next 2 +//@ gdb-check:[...]#loc_add_macro[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add_call3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder_call2[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder_call3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder_call1[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call1_pre[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_in_proxy[...] +//@ gdb-command:next 2 +//@ gdb-command:frame +//@ gdb-command:continue #[inline(never)] fn myprintln_impl(text: &str) { diff --git a/tests/debuginfo/collapse-debuginfo-no-attr.rs b/tests/debuginfo/collapse-debuginfo-no-attr.rs index 6f0d041024f4..b55c7d6c948f 100644 --- a/tests/debuginfo/collapse-debuginfo-no-attr.rs +++ b/tests/debuginfo/collapse-debuginfo-no-attr.rs @@ -7,20 +7,20 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc2[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc4[...] -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc2[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc4[...] +//@ gdb-command:continue fn one() { println!("one"); diff --git a/tests/debuginfo/collapse-debuginfo-static-external.rs b/tests/debuginfo/collapse-debuginfo-static-external.rs index 6389bb734ddf..764985ceeb04 100644 --- a/tests/debuginfo/collapse-debuginfo-static-external.rs +++ b/tests/debuginfo/collapse-debuginfo-static-external.rs @@ -7,8 +7,8 @@ // === GDB TESTS =================================================================================== -// gdb-command:info line collapse_debuginfo_static_external::FOO -// gdb-check:[...]Line 16[...] +//@ gdb-command:info line collapse_debuginfo_static_external::FOO +//@ gdb-check:[...]Line 16[...] #[collapse_debuginfo(external)] macro_rules! decl_foo { diff --git a/tests/debuginfo/collapse-debuginfo-static.rs b/tests/debuginfo/collapse-debuginfo-static.rs index a5542a44091a..faa89f2784e5 100644 --- a/tests/debuginfo/collapse-debuginfo-static.rs +++ b/tests/debuginfo/collapse-debuginfo-static.rs @@ -7,8 +7,8 @@ // === GDB TESTS =================================================================================== -// gdb-command:info line collapse_debuginfo_static::FOO -// gdb-check:[...]Line 20[...] +//@ gdb-command:info line collapse_debuginfo_static::FOO +//@ gdb-check:[...]Line 20[...] #[collapse_debuginfo(yes)] macro_rules! decl_foo { diff --git a/tests/debuginfo/collapse-debuginfo-with-attr-flag.rs b/tests/debuginfo/collapse-debuginfo-with-attr-flag.rs index 8da084126ca0..759f42c3a235 100644 --- a/tests/debuginfo/collapse-debuginfo-with-attr-flag.rs +++ b/tests/debuginfo/collapse-debuginfo-with-attr-flag.rs @@ -7,20 +7,20 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc2[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc4[...] -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc2[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc4[...] +//@ gdb-command:continue fn one() { println!("one"); diff --git a/tests/debuginfo/collapse-debuginfo-with-attr.rs b/tests/debuginfo/collapse-debuginfo-with-attr.rs index fa6646877965..fc85da42308d 100644 --- a/tests/debuginfo/collapse-debuginfo-with-attr.rs +++ b/tests/debuginfo/collapse-debuginfo-with-attr.rs @@ -7,17 +7,17 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc2[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc3[...] -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc2[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc3[...] +//@ gdb-command:continue fn one() { println!("one"); diff --git a/tests/debuginfo/collapse-debuginfo-with-yes-flag.rs b/tests/debuginfo/collapse-debuginfo-with-yes-flag.rs index ef92f87ef468..835eb6d86344 100644 --- a/tests/debuginfo/collapse-debuginfo-with-yes-flag.rs +++ b/tests/debuginfo/collapse-debuginfo-with-yes-flag.rs @@ -7,17 +7,17 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc2[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc3[...] -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc2[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc3[...] +//@ gdb-command:continue fn one() { println!("one"); diff --git a/tests/debuginfo/constant-ordering-prologue.rs b/tests/debuginfo/constant-ordering-prologue.rs index 1d4674b1d32b..65a5d39a858a 100644 --- a/tests/debuginfo/constant-ordering-prologue.rs +++ b/tests/debuginfo/constant-ordering-prologue.rs @@ -5,27 +5,27 @@ // === GDB TESTS =================================================================================== -// gdb-command:break constant_ordering_prologue::binding -// gdb-command:run +//@ gdb-command:break constant_ordering_prologue::binding +//@ gdb-command:run -// gdb-command:print a -// gdb-check: = 19 -// gdb-command:print b -// gdb-check: = 20 -// gdb-command:print c -// gdb-check: = 21.5 +//@ gdb-command:print a +//@ gdb-check: = 19 +//@ gdb-command:print b +//@ gdb-check: = 20 +//@ gdb-command:print c +//@ gdb-check: = 21.5 // === LLDB TESTS ================================================================================== -// lldb-command:b "constant_ordering_prologue::binding" -// lldb-command:run +//@ lldb-command:b "constant_ordering_prologue::binding" +//@ lldb-command:run -// lldb-command:print a -// lldb-check: 19 -// lldb-command:print b -// lldb-check: 20 -// lldb-command:print c -// lldb-check: 21.5 +//@ lldb-command:print a +//@ lldb-check: 19 +//@ lldb-command:print b +//@ lldb-check: 20 +//@ lldb-command:print c +//@ lldb-check: 21.5 fn binding(a: i64, b: u64, c: f64) { let x = 0; diff --git a/tests/debuginfo/coroutine-closure.rs b/tests/debuginfo/coroutine-closure.rs index 002531084fb9..882ecda240e5 100644 --- a/tests/debuginfo/coroutine-closure.rs +++ b/tests/debuginfo/coroutine-closure.rs @@ -5,11 +5,11 @@ // === CDB TESTS ================================================================================== -// cdb-command: g -// cdb-command: dx closure -// cdb-check:closure [Type: coroutine_closure::main::closure_env$0] -// cdb-check: [+0x[...]] y : "" [Type: alloc::string::String] -// cdb-check: [+0x[...]] x : "" [Type: alloc::string::String] +//@ cdb-command: g +//@ cdb-command: dx closure +//@ cdb-check:closure [Type: coroutine_closure::main::closure_env$0] +//@ cdb-check: [+0x[...]] y : "" [Type: alloc::string::String] +//@ cdb-check: [+0x[...]] x : "" [Type: alloc::string::String] #![allow(unused)] fn main() { let x = String::new(); diff --git a/tests/debuginfo/coroutine-locals.rs b/tests/debuginfo/coroutine-locals.rs index d63ea4bde367..ac870ce8fa43 100644 --- a/tests/debuginfo/coroutine-locals.rs +++ b/tests/debuginfo/coroutine-locals.rs @@ -4,47 +4,47 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print a -// gdb-check:$1 = 5 -// gdb-command:print c -// gdb-check:$2 = 6 -// gdb-command:print d -// gdb-check:$3 = 7 -// gdb-command:continue -// gdb-command:print a -// gdb-check:$4 = 7 -// gdb-command:print c -// gdb-check:$5 = 6 -// gdb-command:print e -// gdb-check:$6 = 8 -// gdb-command:continue -// gdb-command:print a -// gdb-check:$7 = 8 -// gdb-command:print c -// gdb-check:$8 = 6 +//@ gdb-command:run +//@ gdb-command:print a +//@ gdb-check:$1 = 5 +//@ gdb-command:print c +//@ gdb-check:$2 = 6 +//@ gdb-command:print d +//@ gdb-check:$3 = 7 +//@ gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$4 = 7 +//@ gdb-command:print c +//@ gdb-check:$5 = 6 +//@ gdb-command:print e +//@ gdb-check:$6 = 8 +//@ gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$7 = 8 +//@ gdb-command:print c +//@ gdb-check:$8 = 6 // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v a -// lldb-check:(int) a = 5 -// lldb-command:v c -// lldb-check:(int) c = 6 -// lldb-command:v d -// lldb-check:(int) d = 7 -// lldb-command:continue -// lldb-command:v a -// lldb-check:(int) a = 7 -// lldb-command:v c -// lldb-check:(int) c = 6 -// lldb-command:v e -// lldb-check:(int) e = 8 -// lldb-command:continue -// lldb-command:v a -// lldb-check:(int) a = 8 -// lldb-command:v c -// lldb-check:(int) c = 6 +//@ lldb-command:run +//@ lldb-command:v a +//@ lldb-check:(int) a = 5 +//@ lldb-command:v c +//@ lldb-check:(int) c = 6 +//@ lldb-command:v d +//@ lldb-check:(int) d = 7 +//@ lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:(int) a = 7 +//@ lldb-command:v c +//@ lldb-check:(int) c = 6 +//@ lldb-command:v e +//@ lldb-check:(int) e = 8 +//@ lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:(int) a = 8 +//@ lldb-command:v c +//@ lldb-check:(int) c = 6 #![feature(coroutines, coroutine_trait, stmt_expr_attributes)] diff --git a/tests/debuginfo/coroutine-objects.rs b/tests/debuginfo/coroutine-objects.rs index b9d015ef6d1b..598de2ee4538 100644 --- a/tests/debuginfo/coroutine-objects.rs +++ b/tests/debuginfo/coroutine-objects.rs @@ -10,50 +10,50 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print b -// gdb-check:$1 = coroutine_objects::main::{coroutine_env#0}::Unresumed{_ref__a: 0x[...]} -// gdb-command:continue -// gdb-command:print b -// gdb-check:$2 = coroutine_objects::main::{coroutine_env#0}::Suspend0{c: 6, d: 7, _ref__a: 0x[...]} -// gdb-command:continue -// gdb-command:print b -// gdb-check:$3 = coroutine_objects::main::{coroutine_env#0}::Suspend1{c: 7, d: 8, _ref__a: 0x[...]} -// gdb-command:continue -// gdb-command:print b -// gdb-check:$4 = coroutine_objects::main::{coroutine_env#0}::Returned{_ref__a: 0x[...]} +//@ gdb-command:run +//@ gdb-command:print b +//@ gdb-check:$1 = coroutine_objects::main::{coroutine_env#0}::Unresumed{_ref__a: 0x[...]} +//@ gdb-command:continue +//@ gdb-command:print b +//@ gdb-check:$2 = coroutine_objects::main::{coroutine_env#0}::Suspend0{c: 6, d: 7, _ref__a: 0x[...]} +//@ gdb-command:continue +//@ gdb-command:print b +//@ gdb-check:$3 = coroutine_objects::main::{coroutine_env#0}::Suspend1{c: 7, d: 8, _ref__a: 0x[...]} +//@ gdb-command:continue +//@ gdb-command:print b +//@ gdb-check:$4 = coroutine_objects::main::{coroutine_env#0}::Returned{_ref__a: 0x[...]} // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v b -// lldb-check:(coroutine_objects::main::{coroutine_env#0}) b = 0{_ref__a:0x[...]} { _ref__a = 0x[...] } +//@ lldb-command:run +//@ lldb-command:v b +//@ lldb-check:(coroutine_objects::main::{coroutine_env#0}) b = 0{_ref__a:0x[...]} { _ref__a = 0x[...] } // === CDB TESTS =================================================================================== -// cdb-command: g -// cdb-command: dx b -// cdb-check: b : Unresumed [Type: enum2$] -// cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *] +//@ cdb-command: g +//@ cdb-command: dx b +//@ cdb-check: b : Unresumed [Type: enum2$] +//@ cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *] -// cdb-command: g -// cdb-command: dx b -// cdb-check: b : Suspend0 [Type: enum2$] -// cdb-check: [+0x[...]] c : 6 [Type: int] -// cdb-check: [+0x[...]] d : 7 [Type: int] -// cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *] +//@ cdb-command: g +//@ cdb-command: dx b +//@ cdb-check: b : Suspend0 [Type: enum2$] +//@ cdb-check: [+0x[...]] c : 6 [Type: int] +//@ cdb-check: [+0x[...]] d : 7 [Type: int] +//@ cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *] -// cdb-command: g -// cdb-command: dx b -// cdb-check: b : Suspend1 [Type: enum2$] -// cdb-check: [+0x[...]] c : 7 [Type: int] -// cdb-check: [+0x[...]] d : 8 [Type: int] -// cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *] +//@ cdb-command: g +//@ cdb-command: dx b +//@ cdb-check: b : Suspend1 [Type: enum2$] +//@ cdb-check: [+0x[...]] c : 7 [Type: int] +//@ cdb-check: [+0x[...]] d : 8 [Type: int] +//@ cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *] -// cdb-command: g -// cdb-command: dx b -// cdb-check: b : Returned [Type: enum2$] -// cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *] +//@ cdb-command: g +//@ cdb-command: dx b +//@ cdb-check: b : Returned [Type: enum2$] +//@ cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *] #![feature(coroutines, coroutine_trait, stmt_expr_attributes)] diff --git a/tests/debuginfo/cross-crate-spans.rs b/tests/debuginfo/cross-crate-spans.rs index 6ef17061070e..97fcda13fe4b 100644 --- a/tests/debuginfo/cross-crate-spans.rs +++ b/tests/debuginfo/cross-crate-spans.rs @@ -8,47 +8,47 @@ // === GDB TESTS =================================================================================== -// gdb-command:break cross_crate_spans.rs:12 -// gdb-command:run +//@ gdb-command:break cross_crate_spans.rs:12 +//@ gdb-command:run -// gdb-command:print result -// gdb-check:$1 = (17, 17) -// gdb-command:print a_variable -// gdb-check:$2 = 123456789 -// gdb-command:print another_variable -// gdb-check:$3 = 123456789.5 -// gdb-command:continue +//@ gdb-command:print result +//@ gdb-check:$1 = (17, 17) +//@ gdb-command:print a_variable +//@ gdb-check:$2 = 123456789 +//@ gdb-command:print another_variable +//@ gdb-check:$3 = 123456789.5 +//@ gdb-command:continue -// gdb-command:print result -// gdb-check:$4 = (1212, 1212) -// gdb-command:print a_variable -// gdb-check:$5 = 123456789 -// gdb-command:print another_variable -// gdb-check:$6 = 123456789.5 -// gdb-command:continue +//@ gdb-command:print result +//@ gdb-check:$4 = (1212, 1212) +//@ gdb-command:print a_variable +//@ gdb-check:$5 = 123456789 +//@ gdb-command:print another_variable +//@ gdb-check:$6 = 123456789.5 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:b cross_crate_spans.rs:12 -// lldb-command:run +//@ lldb-command:b cross_crate_spans.rs:12 +//@ lldb-command:run -// lldb-command:v result -// lldb-check:[...] { 0 = 17 1 = 17 } -// lldb-command:v a_variable -// lldb-check:[...] 123456789 -// lldb-command:v another_variable -// lldb-check:[...] 123456789.5 -// lldb-command:continue +//@ lldb-command:v result +//@ lldb-check:[...] { 0 = 17 1 = 17 } +//@ lldb-command:v a_variable +//@ lldb-check:[...] 123456789 +//@ lldb-command:v another_variable +//@ lldb-check:[...] 123456789.5 +//@ lldb-command:continue -// lldb-command:v result -// lldb-check:[...] { 0 = 1212 1 = 1212 } -// lldb-command:v a_variable -// lldb-check:[...] 123456789 -// lldb-command:v another_variable -// lldb-check:[...] 123456789.5 -// lldb-command:continue +//@ lldb-command:v result +//@ lldb-check:[...] { 0 = 1212 1 = 1212 } +//@ lldb-command:v a_variable +//@ lldb-check:[...] 123456789 +//@ lldb-command:v another_variable +//@ lldb-check:[...] 123456789.5 +//@ lldb-command:continue // This test makes sure that we can break in functions inlined from other crates. diff --git a/tests/debuginfo/destructured-fn-argument.rs b/tests/debuginfo/destructured-fn-argument.rs index 27910ed46882..af9e620e6151 100644 --- a/tests/debuginfo/destructured-fn-argument.rs +++ b/tests/debuginfo/destructured-fn-argument.rs @@ -4,300 +4,300 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print a -// gdb-check:$1 = 1 -// gdb-command:print b -// gdb-check:$2 = false -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$1 = 1 +//@ gdb-command:print b +//@ gdb-check:$2 = false +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$3 = 2 -// gdb-command:print b -// gdb-check:$4 = 3 -// gdb-command:print c -// gdb-check:$5 = 4 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$3 = 2 +//@ gdb-command:print b +//@ gdb-check:$4 = 3 +//@ gdb-command:print c +//@ gdb-check:$5 = 4 +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$6 = 5 -// gdb-command:print b -// gdb-check:$7 = (6, 7) -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$6 = 5 +//@ gdb-command:print b +//@ gdb-check:$7 = (6, 7) +//@ gdb-command:continue -// gdb-command:print h -// gdb-check:$8 = 8 -// gdb-command:print i -// gdb-check:$9 = destructured_fn_argument::Struct {a: 9, b: 10} -// gdb-command:print j -// gdb-check:$10 = 11 -// gdb-command:continue +//@ gdb-command:print h +//@ gdb-check:$8 = 8 +//@ gdb-command:print i +//@ gdb-check:$9 = destructured_fn_argument::Struct {a: 9, b: 10} +//@ gdb-command:print j +//@ gdb-check:$10 = 11 +//@ gdb-command:continue -// gdb-command:print k -// gdb-check:$11 = 12 -// gdb-command:print l -// gdb-check:$12 = 13 -// gdb-command:continue +//@ gdb-command:print k +//@ gdb-check:$11 = 12 +//@ gdb-command:print l +//@ gdb-check:$12 = 13 +//@ gdb-command:continue -// gdb-command:print m -// gdb-check:$13 = 14 -// gdb-command:print n -// gdb-check:$14 = 16 -// gdb-command:continue +//@ gdb-command:print m +//@ gdb-check:$13 = 14 +//@ gdb-command:print n +//@ gdb-check:$14 = 16 +//@ gdb-command:continue -// gdb-command:print o -// gdb-check:$15 = 18 -// gdb-command:continue +//@ gdb-command:print o +//@ gdb-check:$15 = 18 +//@ gdb-command:continue -// gdb-command:print p -// gdb-check:$16 = 19 -// gdb-command:print q -// gdb-check:$17 = 20 -// gdb-command:print r -// gdb-check:$18 = destructured_fn_argument::Struct {a: 21, b: 22} -// gdb-command:continue +//@ gdb-command:print p +//@ gdb-check:$16 = 19 +//@ gdb-command:print q +//@ gdb-check:$17 = 20 +//@ gdb-command:print r +//@ gdb-check:$18 = destructured_fn_argument::Struct {a: 21, b: 22} +//@ gdb-command:continue -// gdb-command:print s -// gdb-check:$19 = 24 -// gdb-command:print t -// gdb-check:$20 = 23 -// gdb-command:continue +//@ gdb-command:print s +//@ gdb-check:$19 = 24 +//@ gdb-command:print t +//@ gdb-check:$20 = 23 +//@ gdb-command:continue -// gdb-command:print u -// gdb-check:$21 = 25 -// gdb-command:print v -// gdb-check:$22 = 26 -// gdb-command:print w -// gdb-check:$23 = 27 -// gdb-command:print x -// gdb-check:$24 = 28 -// gdb-command:print y -// gdb-check:$25 = 29 -// gdb-command:print z -// gdb-check:$26 = 30 -// gdb-command:print ae -// gdb-check:$27 = 31 -// gdb-command:print oe -// gdb-check:$28 = 32 -// gdb-command:print ue -// gdb-check:$29 = 33 -// gdb-command:continue +//@ gdb-command:print u +//@ gdb-check:$21 = 25 +//@ gdb-command:print v +//@ gdb-check:$22 = 26 +//@ gdb-command:print w +//@ gdb-check:$23 = 27 +//@ gdb-command:print x +//@ gdb-check:$24 = 28 +//@ gdb-command:print y +//@ gdb-check:$25 = 29 +//@ gdb-command:print z +//@ gdb-check:$26 = 30 +//@ gdb-command:print ae +//@ gdb-check:$27 = 31 +//@ gdb-command:print oe +//@ gdb-check:$28 = 32 +//@ gdb-command:print ue +//@ gdb-check:$29 = 33 +//@ gdb-command:continue -// gdb-command:print aa -// gdb-check:$30 = (34, 35) -// gdb-command:continue +//@ gdb-command:print aa +//@ gdb-check:$30 = (34, 35) +//@ gdb-command:continue -// gdb-command:print bb -// gdb-check:$31 = (36, 37) -// gdb-command:continue +//@ gdb-command:print bb +//@ gdb-check:$31 = (36, 37) +//@ gdb-command:continue -// gdb-command:print cc -// gdb-check:$32 = 38 -// gdb-command:continue +//@ gdb-command:print cc +//@ gdb-check:$32 = 38 +//@ gdb-command:continue -// gdb-command:print dd -// gdb-check:$33 = (40, 41, 42) -// gdb-command:continue +//@ gdb-command:print dd +//@ gdb-check:$33 = (40, 41, 42) +//@ gdb-command:continue -// gdb-command:print *ee -// gdb-check:$34 = (43, 44, 45) -// gdb-command:continue +//@ gdb-command:print *ee +//@ gdb-check:$34 = (43, 44, 45) +//@ gdb-command:continue -// gdb-command:print *ff -// gdb-check:$35 = 46 -// gdb-command:print gg -// gdb-check:$36 = (47, 48) -// gdb-command:continue +//@ gdb-command:print *ff +//@ gdb-check:$35 = 46 +//@ gdb-command:print gg +//@ gdb-check:$36 = (47, 48) +//@ gdb-command:continue -// gdb-command:print *hh -// gdb-check:$37 = 50 -// gdb-command:continue +//@ gdb-command:print *hh +//@ gdb-check:$37 = 50 +//@ gdb-command:continue -// gdb-command:print ii -// gdb-check:$38 = 51 -// gdb-command:continue +//@ gdb-command:print ii +//@ gdb-check:$38 = 51 +//@ gdb-command:continue -// gdb-command:print *jj -// gdb-check:$39 = 52 -// gdb-command:continue +//@ gdb-command:print *jj +//@ gdb-check:$39 = 52 +//@ gdb-command:continue -// gdb-command:print kk -// gdb-check:$40 = 53 -// gdb-command:print ll -// gdb-check:$41 = 54 -// gdb-command:continue +//@ gdb-command:print kk +//@ gdb-check:$40 = 53 +//@ gdb-command:print ll +//@ gdb-check:$41 = 54 +//@ gdb-command:continue -// gdb-command:print mm -// gdb-check:$42 = 55 -// gdb-command:print *nn -// gdb-check:$43 = 56 -// gdb-command:continue +//@ gdb-command:print mm +//@ gdb-check:$42 = 55 +//@ gdb-command:print *nn +//@ gdb-check:$43 = 56 +//@ gdb-command:continue -// gdb-command:print oo -// gdb-check:$44 = 57 -// gdb-command:print pp -// gdb-check:$45 = 58 -// gdb-command:print qq -// gdb-check:$46 = 59 -// gdb-command:continue +//@ gdb-command:print oo +//@ gdb-check:$44 = 57 +//@ gdb-command:print pp +//@ gdb-check:$45 = 58 +//@ gdb-command:print qq +//@ gdb-check:$46 = 59 +//@ gdb-command:continue -// gdb-command:print rr -// gdb-check:$47 = 60 -// gdb-command:print ss -// gdb-check:$48 = 61 -// gdb-command:print tt -// gdb-check:$49 = 62 -// gdb-command:continue +//@ gdb-command:print rr +//@ gdb-check:$47 = 60 +//@ gdb-command:print ss +//@ gdb-check:$48 = 61 +//@ gdb-command:print tt +//@ gdb-check:$49 = 62 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v a -// lldb-check:[...] 1 -// lldb-command:v b -// lldb-check:[...] false -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 1 +//@ lldb-command:v b +//@ lldb-check:[...] false +//@ lldb-command:continue -// lldb-command:v a -// lldb-check:[...] 2 -// lldb-command:v b -// lldb-check:[...] 3 -// lldb-command:v c -// lldb-check:[...] 4 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 2 +//@ lldb-command:v b +//@ lldb-check:[...] 3 +//@ lldb-command:v c +//@ lldb-check:[...] 4 +//@ lldb-command:continue -// lldb-command:v a -// lldb-check:[...] 5 -// lldb-command:v b -// lldb-check:[...] { 0 = 6 1 = 7 } -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 5 +//@ lldb-command:v b +//@ lldb-check:[...] { 0 = 6 1 = 7 } +//@ lldb-command:continue -// lldb-command:v h -// lldb-check:[...] 8 -// lldb-command:v i -// lldb-check:[...] { a = 9 b = 10 } -// lldb-command:v j -// lldb-check:[...] 11 -// lldb-command:continue +//@ lldb-command:v h +//@ lldb-check:[...] 8 +//@ lldb-command:v i +//@ lldb-check:[...] { a = 9 b = 10 } +//@ lldb-command:v j +//@ lldb-check:[...] 11 +//@ lldb-command:continue -// lldb-command:v k -// lldb-check:[...] 12 -// lldb-command:v l -// lldb-check:[...] 13 -// lldb-command:continue +//@ lldb-command:v k +//@ lldb-check:[...] 12 +//@ lldb-command:v l +//@ lldb-check:[...] 13 +//@ lldb-command:continue -// lldb-command:v m -// lldb-check:[...] 14 -// lldb-command:v n -// lldb-check:[...] 16 -// lldb-command:continue +//@ lldb-command:v m +//@ lldb-check:[...] 14 +//@ lldb-command:v n +//@ lldb-check:[...] 16 +//@ lldb-command:continue -// lldb-command:v o -// lldb-check:[...] 18 -// lldb-command:continue +//@ lldb-command:v o +//@ lldb-check:[...] 18 +//@ lldb-command:continue -// lldb-command:v p -// lldb-check:[...] 19 -// lldb-command:v q -// lldb-check:[...] 20 -// lldb-command:v r -// lldb-check:[...] { a = 21 b = 22 } -// lldb-command:continue +//@ lldb-command:v p +//@ lldb-check:[...] 19 +//@ lldb-command:v q +//@ lldb-check:[...] 20 +//@ lldb-command:v r +//@ lldb-check:[...] { a = 21 b = 22 } +//@ lldb-command:continue -// lldb-command:v s -// lldb-check:[...] 24 -// lldb-command:v t -// lldb-check:[...] 23 -// lldb-command:continue +//@ lldb-command:v s +//@ lldb-check:[...] 24 +//@ lldb-command:v t +//@ lldb-check:[...] 23 +//@ lldb-command:continue -// lldb-command:v u -// lldb-check:[...] 25 -// lldb-command:v v -// lldb-check:[...] 26 -// lldb-command:v w -// lldb-check:[...] 27 -// lldb-command:v x -// lldb-check:[...] 28 -// lldb-command:v y -// lldb-check:[...] 29 -// lldb-command:v z -// lldb-check:[...] 30 -// lldb-command:v ae -// lldb-check:[...] 31 -// lldb-command:v oe -// lldb-check:[...] 32 -// lldb-command:v ue -// lldb-check:[...] 33 -// lldb-command:continue +//@ lldb-command:v u +//@ lldb-check:[...] 25 +//@ lldb-command:v v +//@ lldb-check:[...] 26 +//@ lldb-command:v w +//@ lldb-check:[...] 27 +//@ lldb-command:v x +//@ lldb-check:[...] 28 +//@ lldb-command:v y +//@ lldb-check:[...] 29 +//@ lldb-command:v z +//@ lldb-check:[...] 30 +//@ lldb-command:v ae +//@ lldb-check:[...] 31 +//@ lldb-command:v oe +//@ lldb-check:[...] 32 +//@ lldb-command:v ue +//@ lldb-check:[...] 33 +//@ lldb-command:continue -// lldb-command:v aa -// lldb-check:[...] { 0 = 34 1 = 35 } -// lldb-command:continue +//@ lldb-command:v aa +//@ lldb-check:[...] { 0 = 34 1 = 35 } +//@ lldb-command:continue -// lldb-command:v bb -// lldb-check:[...] { 0 = 36 1 = 37 } -// lldb-command:continue +//@ lldb-command:v bb +//@ lldb-check:[...] { 0 = 36 1 = 37 } +//@ lldb-command:continue -// lldb-command:v cc -// lldb-check:[...] 38 -// lldb-command:continue +//@ lldb-command:v cc +//@ lldb-check:[...] 38 +//@ lldb-command:continue -// lldb-command:v dd -// lldb-check:[...] { 0 = 40 1 = 41 2 = 42 } -// lldb-command:continue +//@ lldb-command:v dd +//@ lldb-check:[...] { 0 = 40 1 = 41 2 = 42 } +//@ lldb-command:continue -// lldb-command:v *ee -// lldb-check:[...] { 0 = 43 1 = 44 2 = 45 } -// lldb-command:continue +//@ lldb-command:v *ee +//@ lldb-check:[...] { 0 = 43 1 = 44 2 = 45 } +//@ lldb-command:continue -// lldb-command:v *ff -// lldb-check:[...] 46 -// lldb-command:v gg -// lldb-check:[...] { 0 = 47 1 = 48 } -// lldb-command:continue +//@ lldb-command:v *ff +//@ lldb-check:[...] 46 +//@ lldb-command:v gg +//@ lldb-check:[...] { 0 = 47 1 = 48 } +//@ lldb-command:continue -// lldb-command:v *hh -// lldb-check:[...] 50 -// lldb-command:continue +//@ lldb-command:v *hh +//@ lldb-check:[...] 50 +//@ lldb-command:continue -// lldb-command:v ii -// lldb-check:[...] 51 -// lldb-command:continue +//@ lldb-command:v ii +//@ lldb-check:[...] 51 +//@ lldb-command:continue -// lldb-command:v *jj -// lldb-check:[...] 52 -// lldb-command:continue +//@ lldb-command:v *jj +//@ lldb-check:[...] 52 +//@ lldb-command:continue -// lldb-command:v kk -// lldb-check:[...] 53 -// lldb-command:v ll -// lldb-check:[...] 54 -// lldb-command:continue +//@ lldb-command:v kk +//@ lldb-check:[...] 53 +//@ lldb-command:v ll +//@ lldb-check:[...] 54 +//@ lldb-command:continue -// lldb-command:v mm -// lldb-check:[...] 55 -// lldb-command:v *nn -// lldb-check:[...] 56 -// lldb-command:continue +//@ lldb-command:v mm +//@ lldb-check:[...] 55 +//@ lldb-command:v *nn +//@ lldb-check:[...] 56 +//@ lldb-command:continue -// lldb-command:v oo -// lldb-check:[...] 57 -// lldb-command:v pp -// lldb-check:[...] 58 -// lldb-command:v qq -// lldb-check:[...] 59 -// lldb-command:continue +//@ lldb-command:v oo +//@ lldb-check:[...] 57 +//@ lldb-command:v pp +//@ lldb-check:[...] 58 +//@ lldb-command:v qq +//@ lldb-check:[...] 59 +//@ lldb-command:continue -// lldb-command:v rr -// lldb-check:[...] 60 -// lldb-command:v ss -// lldb-check:[...] 61 -// lldb-command:v tt -// lldb-check:[...] 62 -// lldb-command:continue +//@ lldb-command:v rr +//@ lldb-check:[...] 60 +//@ lldb-command:v ss +//@ lldb-check:[...] 61 +//@ lldb-command:v tt +//@ lldb-check:[...] 62 +//@ lldb-command:continue #![allow(unused_variables)] #![feature(box_patterns)] diff --git a/tests/debuginfo/destructured-for-loop-variable.rs b/tests/debuginfo/destructured-for-loop-variable.rs index 12a9ff417258..8ea6f70aa049 100644 --- a/tests/debuginfo/destructured-for-loop-variable.rs +++ b/tests/debuginfo/destructured-for-loop-variable.rs @@ -4,142 +4,142 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // DESTRUCTURED STRUCT -// gdb-command:print x -// gdb-check:$1 = 400 -// gdb-command:print y -// gdb-check:$2 = 401.5 -// gdb-command:print z -// gdb-check:$3 = true -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = 400 +//@ gdb-command:print y +//@ gdb-check:$2 = 401.5 +//@ gdb-command:print z +//@ gdb-check:$3 = true +//@ gdb-command:continue // DESTRUCTURED TUPLE -// gdb-command:print/x _i8 -// gdb-check:$4 = 0x6f -// gdb-command:print/x _u8 -// gdb-check:$5 = 0x70 -// gdb-command:print _i16 -// gdb-check:$6 = -113 -// gdb-command:print _u16 -// gdb-check:$7 = 114 -// gdb-command:print _i32 -// gdb-check:$8 = -115 -// gdb-command:print _u32 -// gdb-check:$9 = 116 -// gdb-command:print _i64 -// gdb-check:$10 = -117 -// gdb-command:print _u64 -// gdb-check:$11 = 118 -// gdb-command:print _f32 -// gdb-check:$12 = 119.5 -// gdb-command:print _f64 -// gdb-check:$13 = 120.5 -// gdb-command:continue +//@ gdb-command:print/x _i8 +//@ gdb-check:$4 = 0x6f +//@ gdb-command:print/x _u8 +//@ gdb-check:$5 = 0x70 +//@ gdb-command:print _i16 +//@ gdb-check:$6 = -113 +//@ gdb-command:print _u16 +//@ gdb-check:$7 = 114 +//@ gdb-command:print _i32 +//@ gdb-check:$8 = -115 +//@ gdb-command:print _u32 +//@ gdb-check:$9 = 116 +//@ gdb-command:print _i64 +//@ gdb-check:$10 = -117 +//@ gdb-command:print _u64 +//@ gdb-check:$11 = 118 +//@ gdb-command:print _f32 +//@ gdb-check:$12 = 119.5 +//@ gdb-command:print _f64 +//@ gdb-check:$13 = 120.5 +//@ gdb-command:continue // MORE COMPLEX CASE -// gdb-command:print v1 -// gdb-check:$14 = 80000 -// gdb-command:print x1 -// gdb-check:$15 = 8000 -// gdb-command:print *y1 -// gdb-check:$16 = 80001.5 -// gdb-command:print z1 -// gdb-check:$17 = false -// gdb-command:print *x2 -// gdb-check:$18 = -30000 -// gdb-command:print y2 -// gdb-check:$19 = -300001.5 -// gdb-command:print *z2 -// gdb-check:$20 = true -// gdb-command:print v2 -// gdb-check:$21 = 854237.5 -// gdb-command:continue +//@ gdb-command:print v1 +//@ gdb-check:$14 = 80000 +//@ gdb-command:print x1 +//@ gdb-check:$15 = 8000 +//@ gdb-command:print *y1 +//@ gdb-check:$16 = 80001.5 +//@ gdb-command:print z1 +//@ gdb-check:$17 = false +//@ gdb-command:print *x2 +//@ gdb-check:$18 = -30000 +//@ gdb-command:print y2 +//@ gdb-check:$19 = -300001.5 +//@ gdb-command:print *z2 +//@ gdb-check:$20 = true +//@ gdb-command:print v2 +//@ gdb-check:$21 = 854237.5 +//@ gdb-command:continue // SIMPLE IDENTIFIER -// gdb-command:print i -// gdb-check:$22 = 1234 -// gdb-command:continue +//@ gdb-command:print i +//@ gdb-check:$22 = 1234 +//@ gdb-command:continue -// gdb-command:print simple_struct_ident -// gdb-check:$23 = destructured_for_loop_variable::Struct {x: 3537, y: 35437.5, z: true} -// gdb-command:continue +//@ gdb-command:print simple_struct_ident +//@ gdb-check:$23 = destructured_for_loop_variable::Struct {x: 3537, y: 35437.5, z: true} +//@ gdb-command:continue -// gdb-command:print simple_tuple_ident -// gdb-check:$24 = (34903493, 232323) -// gdb-command:continue +//@ gdb-command:print simple_tuple_ident +//@ gdb-check:$24 = (34903493, 232323) +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:type format add --format hex char -// lldb-command:type format add --format hex 'unsigned char' +//@ lldb-command:type format add --format hex char +//@ lldb-command:type format add --format hex 'unsigned char' -// lldb-command:run +//@ lldb-command:run // DESTRUCTURED STRUCT -// lldb-command:v x -// lldb-check:[...] 400 -// lldb-command:v y -// lldb-check:[...] 401.5 -// lldb-command:v z -// lldb-check:[...] true -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 400 +//@ lldb-command:v y +//@ lldb-check:[...] 401.5 +//@ lldb-command:v z +//@ lldb-check:[...] true +//@ lldb-command:continue // DESTRUCTURED TUPLE -// lldb-command:v _i8 -// lldb-check:[...] 0x6f -// lldb-command:v _u8 -// lldb-check:[...] 0x70 -// lldb-command:v _i16 -// lldb-check:[...] -113 -// lldb-command:v _u16 -// lldb-check:[...] 114 -// lldb-command:v _i32 -// lldb-check:[...] -115 -// lldb-command:v _u32 -// lldb-check:[...] 116 -// lldb-command:v _i64 -// lldb-check:[...] -117 -// lldb-command:v _u64 -// lldb-check:[...] 118 -// lldb-command:v _f32 -// lldb-check:[...] 119.5 -// lldb-command:v _f64 -// lldb-check:[...] 120.5 -// lldb-command:continue +//@ lldb-command:v _i8 +//@ lldb-check:[...] 0x6f +//@ lldb-command:v _u8 +//@ lldb-check:[...] 0x70 +//@ lldb-command:v _i16 +//@ lldb-check:[...] -113 +//@ lldb-command:v _u16 +//@ lldb-check:[...] 114 +//@ lldb-command:v _i32 +//@ lldb-check:[...] -115 +//@ lldb-command:v _u32 +//@ lldb-check:[...] 116 +//@ lldb-command:v _i64 +//@ lldb-check:[...] -117 +//@ lldb-command:v _u64 +//@ lldb-check:[...] 118 +//@ lldb-command:v _f32 +//@ lldb-check:[...] 119.5 +//@ lldb-command:v _f64 +//@ lldb-check:[...] 120.5 +//@ lldb-command:continue // MORE COMPLEX CASE -// lldb-command:v v1 -// lldb-check:[...] 80000 -// lldb-command:v x1 -// lldb-check:[...] 8000 -// lldb-command:v *y1 -// lldb-check:[...] 80001.5 -// lldb-command:v z1 -// lldb-check:[...] false -// lldb-command:v *x2 -// lldb-check:[...] -30000 -// lldb-command:v y2 -// lldb-check:[...] -300001.5 -// lldb-command:v *z2 -// lldb-check:[...] true -// lldb-command:v v2 -// lldb-check:[...] 854237.5 -// lldb-command:continue +//@ lldb-command:v v1 +//@ lldb-check:[...] 80000 +//@ lldb-command:v x1 +//@ lldb-check:[...] 8000 +//@ lldb-command:v *y1 +//@ lldb-check:[...] 80001.5 +//@ lldb-command:v z1 +//@ lldb-check:[...] false +//@ lldb-command:v *x2 +//@ lldb-check:[...] -30000 +//@ lldb-command:v y2 +//@ lldb-check:[...] -300001.5 +//@ lldb-command:v *z2 +//@ lldb-check:[...] true +//@ lldb-command:v v2 +//@ lldb-check:[...] 854237.5 +//@ lldb-command:continue // SIMPLE IDENTIFIER -// lldb-command:v i -// lldb-check:[...] 1234 -// lldb-command:continue +//@ lldb-command:v i +//@ lldb-check:[...] 1234 +//@ lldb-command:continue -// lldb-command:v simple_struct_ident -// lldb-check:[...] { x = 3537 y = 35437.5 z = true } -// lldb-command:continue +//@ lldb-command:v simple_struct_ident +//@ lldb-check:[...] { x = 3537 y = 35437.5 z = true } +//@ lldb-command:continue -// lldb-command:v simple_tuple_ident -// lldb-check:[...] { 0 = 34903493 1 = 232323 } -// lldb-command:continue +//@ lldb-command:v simple_tuple_ident +//@ lldb-check:[...] { 0 = 34903493 1 = 232323 } +//@ lldb-command:continue #![allow(unused_variables)] #![feature(box_patterns)] diff --git a/tests/debuginfo/destructured-local.rs b/tests/debuginfo/destructured-local.rs index ef595468b473..13399480ca44 100644 --- a/tests/debuginfo/destructured-local.rs +++ b/tests/debuginfo/destructured-local.rs @@ -4,232 +4,232 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print a -// gdb-check:$1 = 1 -// gdb-command:print b -// gdb-check:$2 = false +//@ gdb-command:print a +//@ gdb-check:$1 = 1 +//@ gdb-command:print b +//@ gdb-check:$2 = false -// gdb-command:print c -// gdb-check:$3 = 2 -// gdb-command:print d -// gdb-check:$4 = 3 -// gdb-command:print e -// gdb-check:$5 = 4 +//@ gdb-command:print c +//@ gdb-check:$3 = 2 +//@ gdb-command:print d +//@ gdb-check:$4 = 3 +//@ gdb-command:print e +//@ gdb-check:$5 = 4 -// gdb-command:print f -// gdb-check:$6 = 5 -// gdb-command:print g -// gdb-check:$7 = (6, 7) +//@ gdb-command:print f +//@ gdb-check:$6 = 5 +//@ gdb-command:print g +//@ gdb-check:$7 = (6, 7) -// gdb-command:print h -// gdb-check:$8 = 8 -// gdb-command:print i -// gdb-check:$9 = destructured_local::Struct {a: 9, b: 10} -// gdb-command:print j -// gdb-check:$10 = 11 +//@ gdb-command:print h +//@ gdb-check:$8 = 8 +//@ gdb-command:print i +//@ gdb-check:$9 = destructured_local::Struct {a: 9, b: 10} +//@ gdb-command:print j +//@ gdb-check:$10 = 11 -// gdb-command:print k -// gdb-check:$11 = 12 -// gdb-command:print l -// gdb-check:$12 = 13 +//@ gdb-command:print k +//@ gdb-check:$11 = 12 +//@ gdb-command:print l +//@ gdb-check:$12 = 13 -// gdb-command:print m -// gdb-check:$13 = 14 -// gdb-command:print n -// gdb-check:$14 = 16 +//@ gdb-command:print m +//@ gdb-check:$13 = 14 +//@ gdb-command:print n +//@ gdb-check:$14 = 16 -// gdb-command:print o -// gdb-check:$15 = 18 +//@ gdb-command:print o +//@ gdb-check:$15 = 18 -// gdb-command:print p -// gdb-check:$16 = 19 -// gdb-command:print q -// gdb-check:$17 = 20 -// gdb-command:print r -// gdb-check:$18 = destructured_local::Struct {a: 21, b: 22} +//@ gdb-command:print p +//@ gdb-check:$16 = 19 +//@ gdb-command:print q +//@ gdb-check:$17 = 20 +//@ gdb-command:print r +//@ gdb-check:$18 = destructured_local::Struct {a: 21, b: 22} -// gdb-command:print s -// gdb-check:$19 = 24 -// gdb-command:print t -// gdb-check:$20 = 23 +//@ gdb-command:print s +//@ gdb-check:$19 = 24 +//@ gdb-command:print t +//@ gdb-check:$20 = 23 -// gdb-command:print u -// gdb-check:$21 = 25 -// gdb-command:print v -// gdb-check:$22 = 26 -// gdb-command:print w -// gdb-check:$23 = 27 -// gdb-command:print x -// gdb-check:$24 = 28 -// gdb-command:print y -// gdb-check:$25 = 29 -// gdb-command:print z -// gdb-check:$26 = 30 -// gdb-command:print ae -// gdb-check:$27 = 31 -// gdb-command:print oe -// gdb-check:$28 = 32 -// gdb-command:print ue -// gdb-check:$29 = 33 +//@ gdb-command:print u +//@ gdb-check:$21 = 25 +//@ gdb-command:print v +//@ gdb-check:$22 = 26 +//@ gdb-command:print w +//@ gdb-check:$23 = 27 +//@ gdb-command:print x +//@ gdb-check:$24 = 28 +//@ gdb-command:print y +//@ gdb-check:$25 = 29 +//@ gdb-command:print z +//@ gdb-check:$26 = 30 +//@ gdb-command:print ae +//@ gdb-check:$27 = 31 +//@ gdb-command:print oe +//@ gdb-check:$28 = 32 +//@ gdb-command:print ue +//@ gdb-check:$29 = 33 -// gdb-command:print aa -// gdb-check:$30 = (34, 35) +//@ gdb-command:print aa +//@ gdb-check:$30 = (34, 35) -// gdb-command:print bb -// gdb-check:$31 = (36, 37) +//@ gdb-command:print bb +//@ gdb-check:$31 = (36, 37) -// gdb-command:print cc -// gdb-check:$32 = 38 +//@ gdb-command:print cc +//@ gdb-check:$32 = 38 -// gdb-command:print dd -// gdb-check:$33 = (40, 41, 42) +//@ gdb-command:print dd +//@ gdb-check:$33 = (40, 41, 42) -// gdb-command:print *ee -// gdb-check:$34 = (43, 44, 45) +//@ gdb-command:print *ee +//@ gdb-check:$34 = (43, 44, 45) -// gdb-command:print *ff -// gdb-check:$35 = 46 +//@ gdb-command:print *ff +//@ gdb-check:$35 = 46 -// gdb-command:print gg -// gdb-check:$36 = (47, 48) +//@ gdb-command:print gg +//@ gdb-check:$36 = (47, 48) -// gdb-command:print *hh -// gdb-check:$37 = 50 +//@ gdb-command:print *hh +//@ gdb-check:$37 = 50 -// gdb-command:print ii -// gdb-check:$38 = 51 +//@ gdb-command:print ii +//@ gdb-check:$38 = 51 -// gdb-command:print *jj -// gdb-check:$39 = 52 +//@ gdb-command:print *jj +//@ gdb-check:$39 = 52 -// gdb-command:print kk -// gdb-check:$40 = 53 +//@ gdb-command:print kk +//@ gdb-check:$40 = 53 -// gdb-command:print ll -// gdb-check:$41 = 54 +//@ gdb-command:print ll +//@ gdb-check:$41 = 54 -// gdb-command:print mm -// gdb-check:$42 = 55 +//@ gdb-command:print mm +//@ gdb-check:$42 = 55 -// gdb-command:print *nn -// gdb-check:$43 = 56 +//@ gdb-command:print *nn +//@ gdb-check:$43 = 56 // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v a -// lldb-check:[...] 1 -// lldb-command:v b -// lldb-check:[...] false +//@ lldb-command:v a +//@ lldb-check:[...] 1 +//@ lldb-command:v b +//@ lldb-check:[...] false -// lldb-command:v c -// lldb-check:[...] 2 -// lldb-command:v d -// lldb-check:[...] 3 -// lldb-command:v e -// lldb-check:[...] 4 +//@ lldb-command:v c +//@ lldb-check:[...] 2 +//@ lldb-command:v d +//@ lldb-check:[...] 3 +//@ lldb-command:v e +//@ lldb-check:[...] 4 -// lldb-command:v f -// lldb-check:[...] 5 -// lldb-command:v g -// lldb-check:[...] { 0 = 6 1 = 7 } +//@ lldb-command:v f +//@ lldb-check:[...] 5 +//@ lldb-command:v g +//@ lldb-check:[...] { 0 = 6 1 = 7 } -// lldb-command:v h -// lldb-check:[...] 8 -// lldb-command:v i -// lldb-check:[...] { a = 9 b = 10 } -// lldb-command:v j -// lldb-check:[...] 11 +//@ lldb-command:v h +//@ lldb-check:[...] 8 +//@ lldb-command:v i +//@ lldb-check:[...] { a = 9 b = 10 } +//@ lldb-command:v j +//@ lldb-check:[...] 11 -// lldb-command:v k -// lldb-check:[...] 12 -// lldb-command:v l -// lldb-check:[...] 13 +//@ lldb-command:v k +//@ lldb-check:[...] 12 +//@ lldb-command:v l +//@ lldb-check:[...] 13 -// lldb-command:v m -// lldb-check:[...] 14 -// lldb-command:v n -// lldb-check:[...] 16 +//@ lldb-command:v m +//@ lldb-check:[...] 14 +//@ lldb-command:v n +//@ lldb-check:[...] 16 -// lldb-command:v o -// lldb-check:[...] 18 +//@ lldb-command:v o +//@ lldb-check:[...] 18 -// lldb-command:v p -// lldb-check:[...] 19 -// lldb-command:v q -// lldb-check:[...] 20 -// lldb-command:v r -// lldb-check:[...] { a = 21 b = 22 } +//@ lldb-command:v p +//@ lldb-check:[...] 19 +//@ lldb-command:v q +//@ lldb-check:[...] 20 +//@ lldb-command:v r +//@ lldb-check:[...] { a = 21 b = 22 } -// lldb-command:v s -// lldb-check:[...] 24 -// lldb-command:v t -// lldb-check:[...] 23 +//@ lldb-command:v s +//@ lldb-check:[...] 24 +//@ lldb-command:v t +//@ lldb-check:[...] 23 -// lldb-command:v u -// lldb-check:[...] 25 -// lldb-command:v v -// lldb-check:[...] 26 -// lldb-command:v w -// lldb-check:[...] 27 -// lldb-command:v x -// lldb-check:[...] 28 -// lldb-command:v y -// lldb-check:[...] 29 -// lldb-command:v z -// lldb-check:[...] 30 -// lldb-command:v ae -// lldb-check:[...] 31 -// lldb-command:v oe -// lldb-check:[...] 32 -// lldb-command:v ue -// lldb-check:[...] 33 +//@ lldb-command:v u +//@ lldb-check:[...] 25 +//@ lldb-command:v v +//@ lldb-check:[...] 26 +//@ lldb-command:v w +//@ lldb-check:[...] 27 +//@ lldb-command:v x +//@ lldb-check:[...] 28 +//@ lldb-command:v y +//@ lldb-check:[...] 29 +//@ lldb-command:v z +//@ lldb-check:[...] 30 +//@ lldb-command:v ae +//@ lldb-check:[...] 31 +//@ lldb-command:v oe +//@ lldb-check:[...] 32 +//@ lldb-command:v ue +//@ lldb-check:[...] 33 -// lldb-command:v aa -// lldb-check:[...] { 0 = 34 1 = 35 } +//@ lldb-command:v aa +//@ lldb-check:[...] { 0 = 34 1 = 35 } -// lldb-command:v bb -// lldb-check:[...] { 0 = 36 1 = 37 } +//@ lldb-command:v bb +//@ lldb-check:[...] { 0 = 36 1 = 37 } -// lldb-command:v cc -// lldb-check:[...] 38 +//@ lldb-command:v cc +//@ lldb-check:[...] 38 -// lldb-command:v dd -// lldb-check:[...] { 0 = 40 1 = 41 2 = 42 } +//@ lldb-command:v dd +//@ lldb-check:[...] { 0 = 40 1 = 41 2 = 42 } -// lldb-command:v *ee -// lldb-check:[...] { 0 = 43 1 = 44 2 = 45 } +//@ lldb-command:v *ee +//@ lldb-check:[...] { 0 = 43 1 = 44 2 = 45 } -// lldb-command:v *ff -// lldb-check:[...] 46 +//@ lldb-command:v *ff +//@ lldb-check:[...] 46 -// lldb-command:v gg -// lldb-check:[...] { 0 = 47 1 = 48 } +//@ lldb-command:v gg +//@ lldb-check:[...] { 0 = 47 1 = 48 } -// lldb-command:v *hh -// lldb-check:[...] 50 +//@ lldb-command:v *hh +//@ lldb-check:[...] 50 -// lldb-command:v ii -// lldb-check:[...] 51 +//@ lldb-command:v ii +//@ lldb-check:[...] 51 -// lldb-command:v *jj -// lldb-check:[...] 52 +//@ lldb-command:v *jj +//@ lldb-check:[...] 52 -// lldb-command:v kk -// lldb-check:[...] 53 +//@ lldb-command:v kk +//@ lldb-check:[...] 53 -// lldb-command:v ll -// lldb-check:[...] 54 +//@ lldb-command:v ll +//@ lldb-check:[...] 54 -// lldb-command:v mm -// lldb-check:[...] 55 +//@ lldb-command:v mm +//@ lldb-check:[...] 55 -// lldb-command:v *nn -// lldb-check:[...] 56 +//@ lldb-command:v *nn +//@ lldb-check:[...] 56 #![allow(unused_variables)] diff --git a/tests/debuginfo/drop-locations.rs b/tests/debuginfo/drop-locations.rs index 91b3da5c34a8..527ea8d9ed3a 100644 --- a/tests/debuginfo/drop-locations.rs +++ b/tests/debuginfo/drop-locations.rs @@ -12,52 +12,52 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc2[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc4[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc5[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc6[...] +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc2[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc4[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc5[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc6[...] // === LLDB TESTS ================================================================================== -// lldb-command:set set stop-line-count-before 0 -// lldb-command:set set stop-line-count-after 1 +//@ lldb-command:set set stop-line-count-before 0 +//@ lldb-command:set set stop-line-count-after 1 // Can't set both to zero or lldb will stop printing source at all. So it will output the current // line and the next. We deal with this by having at least 2 lines between the #loc's -// lldb-command:run -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc1 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc2 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc3 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc4 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc5 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc6 [...] +//@ lldb-command:run +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc1 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc2 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc3 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc4 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc5 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc6 [...] fn main() { diff --git a/tests/debuginfo/dummy_span.rs b/tests/debuginfo/dummy_span.rs index 23822222006c..fec4f33e3d56 100644 --- a/tests/debuginfo/dummy_span.rs +++ b/tests/debuginfo/dummy_span.rs @@ -5,25 +5,25 @@ // === GDB TESTS =================================================================================== -// gdb-command:run 7 +//@ gdb-command:run 7 -// gdb-command:next -// gdb-command:next -// gdb-check:[...]#loc1[...] -// gdb-command:next -// gdb-check:[...]#loc2[...] +//@ gdb-command:next +//@ gdb-command:next +//@ gdb-check:[...]#loc1[...] +//@ gdb-command:next +//@ gdb-check:[...]#loc2[...] // === LLDB TESTS ================================================================================== -// lldb-command:run 7 +//@ lldb-command:run 7 -// lldb-command:next -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...]#loc1[...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...]#loc2[...] +//@ lldb-command:next +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...]#loc1[...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...]#loc2[...] use std::env; use std::num::ParseIntError; diff --git a/tests/debuginfo/duration-type.rs b/tests/debuginfo/duration-type.rs index 4e4b17c02e10..2d980cc29556 100644 --- a/tests/debuginfo/duration-type.rs +++ b/tests/debuginfo/duration-type.rs @@ -3,13 +3,13 @@ // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx duration -// cdb-check:duration : 5s 12ns [Type: core::time::Duration] -// cdb-check: [] [Type: core::time::Duration] -// cdb-check: seconds : 5 [Type: unsigned __int64] -// cdb-check: nanoseconds : 12 [Type: unsigned int] +//@ cdb-command: dx duration +//@ cdb-check:duration : 5s 12ns [Type: core::time::Duration] +//@ cdb-check: [] [Type: core::time::Duration] +//@ cdb-check: seconds : 5 [Type: unsigned __int64] +//@ cdb-check: nanoseconds : 12 [Type: unsigned int] use std::time::Duration; diff --git a/tests/debuginfo/embedded-visualizer.rs b/tests/debuginfo/embedded-visualizer.rs index 3652036ae8b6..3f403d57abe9 100644 --- a/tests/debuginfo/embedded-visualizer.rs +++ b/tests/debuginfo/embedded-visualizer.rs @@ -4,59 +4,59 @@ // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g // The .nvlist command in cdb does not always have a deterministic output // for the order that NatVis files are displayed. -// cdb-command: .nvlist -// cdb-check: [...].exe (embedded NatVis "[...]embedded_visualizer-0.natvis") +//@ cdb-command: .nvlist +//@ cdb-check: [...].exe (embedded NatVis "[...]embedded_visualizer-0.natvis") -// cdb-command: .nvlist -// cdb-check: [...].exe (embedded NatVis "[...]embedded_visualizer-1.natvis") +//@ cdb-command: .nvlist +//@ cdb-check: [...].exe (embedded NatVis "[...]embedded_visualizer-1.natvis") -// cdb-command: .nvlist -// cdb-check: [...].exe (embedded NatVis "[...]embedded_visualizer-2.natvis") +//@ cdb-command: .nvlist +//@ cdb-check: [...].exe (embedded NatVis "[...]embedded_visualizer-2.natvis") -// cdb-command: dx point_a -// cdb-check:point_a : (0, 0) [Type: embedded_visualizer::point::Point] -// cdb-check: [] [Type: embedded_visualizer::point::Point] -// cdb-check: [x] : 0 [Type: int] -// cdb-check: [y] : 0 [Type: int] +//@ cdb-command: dx point_a +//@ cdb-check:point_a : (0, 0) [Type: embedded_visualizer::point::Point] +//@ cdb-check: [] [Type: embedded_visualizer::point::Point] +//@ cdb-check: [x] : 0 [Type: int] +//@ cdb-check: [y] : 0 [Type: int] -// cdb-command: dx point_b -// cdb-check:point_b : (5, 8) [Type: embedded_visualizer::point::Point] -// cdb-check: [] [Type: embedded_visualizer::point::Point] -// cdb-check: [x] : 5 [Type: int] -// cdb-check: [y] : 8 [Type: int] +//@ cdb-command: dx point_b +//@ cdb-check:point_b : (5, 8) [Type: embedded_visualizer::point::Point] +//@ cdb-check: [] [Type: embedded_visualizer::point::Point] +//@ cdb-check: [x] : 5 [Type: int] +//@ cdb-check: [y] : 8 [Type: int] -// cdb-command: dx line -// cdb-check:line : ((0, 0), (5, 8)) [Type: embedded_visualizer::Line] -// cdb-check: [] [Type: embedded_visualizer::Line] -// cdb-check: [a] : (0, 0) [Type: embedded_visualizer::point::Point] -// cdb-check: [b] : (5, 8) [Type: embedded_visualizer::point::Point] +//@ cdb-command: dx line +//@ cdb-check:line : ((0, 0), (5, 8)) [Type: embedded_visualizer::Line] +//@ cdb-check: [] [Type: embedded_visualizer::Line] +//@ cdb-check: [a] : (0, 0) [Type: embedded_visualizer::point::Point] +//@ cdb-check: [b] : (5, 8) [Type: embedded_visualizer::point::Point] -// cdb-command: dx person -// cdb-check:person : "Person A" is 10 years old. [Type: dependency_with_embedded_visualizers::Person] -// cdb-check: [] [Type: dependency_with_embedded_visualizers::Person] -// cdb-check: [name] : "Person A" [Type: alloc::string::String] -// cdb-check: [age] : 10 [Type: int] +//@ cdb-command: dx person +//@ cdb-check:person : "Person A" is 10 years old. [Type: dependency_with_embedded_visualizers::Person] +//@ cdb-check: [] [Type: dependency_with_embedded_visualizers::Person] +//@ cdb-check: [name] : "Person A" [Type: alloc::string::String] +//@ cdb-check: [age] : 10 [Type: int] // === GDB TESTS =================================================================================== -// gdb-command: run +//@ gdb-command: run -// gdb-command: info auto-load python-scripts -// gdb-check:Yes pretty-printer-embedded_visualizer-0 -// gdb-check:Yes pretty-printer-embedded_visualizer-1 -// gdb-command: print point_a -// gdb-check:$1 = (0, 0) -// gdb-command: print point_b -// gdb-check:$2 = (5, 8) -// gdb-command: print line -// gdb-check:$3 = ((0, 0), (5, 8)) -// gdb-command: print person -// gdb-check:$4 = "Person A" is 10 years old. +//@ gdb-command: info auto-load python-scripts +//@ gdb-check:Yes pretty-printer-embedded_visualizer-0 +//@ gdb-check:Yes pretty-printer-embedded_visualizer-1 +//@ gdb-command: print point_a +//@ gdb-check:$1 = (0, 0) +//@ gdb-command: print point_b +//@ gdb-check:$2 = (5, 8) +//@ gdb-command: print line +//@ gdb-check:$3 = ((0, 0), (5, 8)) +//@ gdb-command: print person +//@ gdb-check:$4 = "Person A" is 10 years old. #![allow(unused_variables)] #![debugger_visualizer(natvis_file = "embedded-visualizer.natvis")] diff --git a/tests/debuginfo/empty-string.rs b/tests/debuginfo/empty-string.rs index d9368001b631..7454d171a459 100644 --- a/tests/debuginfo/empty-string.rs +++ b/tests/debuginfo/empty-string.rs @@ -5,23 +5,23 @@ // === GDB TESTS =================================================================================== -// gdb-command: run +//@ gdb-command: run -// gdb-command: print empty_string -// gdb-check:$1 = "" +//@ gdb-command: print empty_string +//@ gdb-check:$1 = "" -// gdb-command: print empty_str -// gdb-check:$2 = "" +//@ gdb-command: print empty_str +//@ gdb-check:$2 = "" // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:fr v empty_string -// lldb-check:[...] empty_string = "" +//@ lldb-command:fr v empty_string +//@ lldb-check:[...] empty_string = "" -// lldb-command:fr v empty_str -// lldb-check:[...] empty_str = "" +//@ lldb-command:fr v empty_str +//@ lldb-check:[...] empty_str = "" fn main() { let empty_string = String::new(); diff --git a/tests/debuginfo/enum-thinlto.rs b/tests/debuginfo/enum-thinlto.rs index 9b77b1d9ba4a..4da49022630a 100644 --- a/tests/debuginfo/enum-thinlto.rs +++ b/tests/debuginfo/enum-thinlto.rs @@ -5,17 +5,17 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print *abc -// gdb-check:$1 = enum_thinlto::ABC::TheA{x: 0, y: 8970181431921507452} +//@ gdb-command:print *abc +//@ gdb-check:$1 = enum_thinlto::ABC::TheA{x: 0, y: 8970181431921507452} // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v *abc -// lldb-check:(enum_thinlto::ABC) *abc = TheA{x:0, y:8970181431921507452} { x = 0 y = 8970181431921507452 } +//@ lldb-command:v *abc +//@ lldb-check:(enum_thinlto::ABC) *abc = TheA{x:0, y:8970181431921507452} { x = 0 y = 8970181431921507452 } #![allow(unused_variables)] diff --git a/tests/debuginfo/evec-in-struct.rs b/tests/debuginfo/evec-in-struct.rs index 1c0c0a36bace..bbcad48259e0 100644 --- a/tests/debuginfo/evec-in-struct.rs +++ b/tests/debuginfo/evec-in-struct.rs @@ -4,40 +4,40 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print no_padding1 -// gdb-check:$1 = evec_in_struct::NoPadding1 {x: [0, 1, 2], y: -3, z: [4.5, 5.5]} -// gdb-command:print no_padding2 -// gdb-check:$2 = evec_in_struct::NoPadding2 {x: [6, 7, 8], y: [[9, 10], [11, 12]]} +//@ gdb-command:print no_padding1 +//@ gdb-check:$1 = evec_in_struct::NoPadding1 {x: [0, 1, 2], y: -3, z: [4.5, 5.5]} +//@ gdb-command:print no_padding2 +//@ gdb-check:$2 = evec_in_struct::NoPadding2 {x: [6, 7, 8], y: [[9, 10], [11, 12]]} -// gdb-command:print struct_internal_padding -// gdb-check:$3 = evec_in_struct::StructInternalPadding {x: [13, 14], y: [15, 16]} +//@ gdb-command:print struct_internal_padding +//@ gdb-check:$3 = evec_in_struct::StructInternalPadding {x: [13, 14], y: [15, 16]} -// gdb-command:print single_vec -// gdb-check:$4 = evec_in_struct::SingleVec {x: [17, 18, 19, 20, 21]} +//@ gdb-command:print single_vec +//@ gdb-check:$4 = evec_in_struct::SingleVec {x: [17, 18, 19, 20, 21]} -// gdb-command:print struct_padded_at_end -// gdb-check:$5 = evec_in_struct::StructPaddedAtEnd {x: [22, 23], y: [24, 25]} +//@ gdb-command:print struct_padded_at_end +//@ gdb-check:$5 = evec_in_struct::StructPaddedAtEnd {x: [22, 23], y: [24, 25]} // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v no_padding1 -// lldb-check:[...] { x = { [0] = 0 [1] = 1 [2] = 2 } y = -3 z = { [0] = 4.5 [1] = 5.5 } } -// lldb-command:v no_padding2 -// lldb-check:[...] { x = { [0] = 6 [1] = 7 [2] = 8 } y = { [0] = { [0] = 9 [1] = 10 } [1] = { [0] = 11 [1] = 12 } } } +//@ lldb-command:v no_padding1 +//@ lldb-check:[...] { x = { [0] = 0 [1] = 1 [2] = 2 } y = -3 z = { [0] = 4.5 [1] = 5.5 } } +//@ lldb-command:v no_padding2 +//@ lldb-check:[...] { x = { [0] = 6 [1] = 7 [2] = 8 } y = { [0] = { [0] = 9 [1] = 10 } [1] = { [0] = 11 [1] = 12 } } } -// lldb-command:v struct_internal_padding -// lldb-check:[...] { x = { [0] = 13 [1] = 14 } y = { [0] = 15 [1] = 16 } } +//@ lldb-command:v struct_internal_padding +//@ lldb-check:[...] { x = { [0] = 13 [1] = 14 } y = { [0] = 15 [1] = 16 } } -// lldb-command:v single_vec -// lldb-check:[...] { x = { [0] = 17 [1] = 18 [2] = 19 [3] = 20 [4] = 21 } } +//@ lldb-command:v single_vec +//@ lldb-check:[...] { x = { [0] = 17 [1] = 18 [2] = 19 [3] = 20 [4] = 21 } } -// lldb-command:v struct_padded_at_end -// lldb-check:[...] { x = { [0] = 22 [1] = 23 } y = { [0] = 24 [1] = 25 } } +//@ lldb-command:v struct_padded_at_end +//@ lldb-check:[...] { x = { [0] = 22 [1] = 23 } y = { [0] = 24 [1] = 25 } } #![allow(unused_variables)] diff --git a/tests/debuginfo/extern-c-fn.rs b/tests/debuginfo/extern-c-fn.rs index 3a8a110afa2c..522787ecf570 100644 --- a/tests/debuginfo/extern-c-fn.rs +++ b/tests/debuginfo/extern-c-fn.rs @@ -3,34 +3,34 @@ //@ ignore-backends: gcc // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:printf "s = \"%s\"\n", s -// gdb-check:s = "abcd" -// gdb-command:print len -// gdb-check:$1 = 20 -// gdb-command:print local0 -// gdb-check:$2 = 19 -// gdb-command:print local1 -// gdb-check:$3 = true -// gdb-command:print local2 -// gdb-check:$4 = 20.5 +//@ gdb-command:printf "s = \"%s\"\n", s +//@ gdb-check:s = "abcd" +//@ gdb-command:print len +//@ gdb-check:$1 = 20 +//@ gdb-command:print local0 +//@ gdb-check:$2 = 19 +//@ gdb-command:print local1 +//@ gdb-check:$3 = true +//@ gdb-command:print local2 +//@ gdb-check:$4 = 20.5 -// gdb-command:continue +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v len -// lldb-check:[...] 20 -// lldb-command:v local0 -// lldb-check:[...] 19 -// lldb-command:v local1 -// lldb-check:[...] true -// lldb-command:v local2 -// lldb-check:[...] 20.5 +//@ lldb-command:v len +//@ lldb-check:[...] 20 +//@ lldb-command:v local0 +//@ lldb-check:[...] 19 +//@ lldb-command:v local1 +//@ lldb-check:[...] true +//@ lldb-command:v local2 +//@ lldb-check:[...] 20.5 -// lldb-command:continue +//@ lldb-command:continue #![allow(unused_variables)] #![allow(dead_code)] diff --git a/tests/debuginfo/f16-natvis.rs b/tests/debuginfo/f16-natvis.rs index 9b9749f2bad4..92775548a942 100644 --- a/tests/debuginfo/f16-natvis.rs +++ b/tests/debuginfo/f16-natvis.rs @@ -2,35 +2,35 @@ //@ only-msvc // This tests the `f16` Natvis visualiser. -// cdb-command:g -// cdb-command:dx v0_0 -// cdb-check:v0_0 : 0.000000 [Type: f16] -// cdb-command:dx neg_0_0 -// cdb-check:neg_0_0 : -0.000000 [Type: f16] -// cdb-command:dx v1_0 -// cdb-check:v1_0 : 1.000000 [Type: f16] -// cdb-command:dx v1_5 -// cdb-check:v1_5 : 1.500000 [Type: f16] -// cdb-command:dx v72_3 -// cdb-check:v72_3 : 72.312500 [Type: f16] -// cdb-command:dx neg_0_126 -// cdb-check:neg_0_126 : -0.125977 [Type: f16] -// cdb-command:dx v0_00003 -// cdb-check:v0_00003 : 0.000030 [Type: f16] -// cdb-command:dx neg_0_00004 -// cdb-check:neg_0_00004 : -0.000040 [Type: f16] -// cdb-command:dx max -// cdb-check:max : 65504.000000 [Type: f16] -// cdb-command:dx min -// cdb-check:min : -65504.000000 [Type: f16] -// cdb-command:dx inf -// cdb-check:inf : inf [Type: f16] -// cdb-command:dx neg_inf -// cdb-check:neg_inf : -inf [Type: f16] -// cdb-command:dx nan -// cdb-check:nan : NaN [Type: f16] -// cdb-command:dx other_nan -// cdb-check:other_nan : NaN [Type: f16] +//@ cdb-command:g +//@ cdb-command:dx v0_0 +//@ cdb-check:v0_0 : 0.000000 [Type: f16] +//@ cdb-command:dx neg_0_0 +//@ cdb-check:neg_0_0 : -0.000000 [Type: f16] +//@ cdb-command:dx v1_0 +//@ cdb-check:v1_0 : 1.000000 [Type: f16] +//@ cdb-command:dx v1_5 +//@ cdb-check:v1_5 : 1.500000 [Type: f16] +//@ cdb-command:dx v72_3 +//@ cdb-check:v72_3 : 72.312500 [Type: f16] +//@ cdb-command:dx neg_0_126 +//@ cdb-check:neg_0_126 : -0.125977 [Type: f16] +//@ cdb-command:dx v0_00003 +//@ cdb-check:v0_00003 : 0.000030 [Type: f16] +//@ cdb-command:dx neg_0_00004 +//@ cdb-check:neg_0_00004 : -0.000040 [Type: f16] +//@ cdb-command:dx max +//@ cdb-check:max : 65504.000000 [Type: f16] +//@ cdb-command:dx min +//@ cdb-check:min : -65504.000000 [Type: f16] +//@ cdb-command:dx inf +//@ cdb-check:inf : inf [Type: f16] +//@ cdb-command:dx neg_inf +//@ cdb-check:neg_inf : -inf [Type: f16] +//@ cdb-command:dx nan +//@ cdb-check:nan : NaN [Type: f16] +//@ cdb-command:dx other_nan +//@ cdb-check:other_nan : NaN [Type: f16] #![feature(f16)] diff --git a/tests/debuginfo/fixed-sized-array.rs b/tests/debuginfo/fixed-sized-array.rs index e538c57f5fef..91ce7cecf8a7 100644 --- a/tests/debuginfo/fixed-sized-array.rs +++ b/tests/debuginfo/fixed-sized-array.rs @@ -6,21 +6,21 @@ // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx xs,d -// cdb-check:xs,d [Type: int [5]] -// cdb-check: [0] : 1 [Type: int] -// cdb-check: [1] : 2 [Type: int] -// cdb-check: [2] : 3 [Type: int] -// cdb-check: [3] : 4 [Type: int] -// cdb-check: [4] : 5 [Type: int] +//@ cdb-command: dx xs,d +//@ cdb-check:xs,d [Type: int [5]] +//@ cdb-check: [0] : 1 [Type: int] +//@ cdb-check: [1] : 2 [Type: int] +//@ cdb-check: [2] : 3 [Type: int] +//@ cdb-check: [3] : 4 [Type: int] +//@ cdb-check: [4] : 5 [Type: int] -// cdb-command: dx ys,d -// cdb-check:ys,d [Type: int [3]] -// cdb-check: [0] : 0 [Type: int] -// cdb-check: [1] : 0 [Type: int] -// cdb-check: [2] : 0 [Type: int] +//@ cdb-command: dx ys,d +//@ cdb-check:ys,d [Type: int [3]] +//@ cdb-check: [0] : 0 [Type: int] +//@ cdb-check: [1] : 0 [Type: int] +//@ cdb-check: [2] : 0 [Type: int] fn main() { // Fixed-size array (type signature is superfluous) diff --git a/tests/debuginfo/fn_ptr.rs b/tests/debuginfo/fn_ptr.rs index b6eb0f11a25c..22e98ae04d07 100644 --- a/tests/debuginfo/fn_ptr.rs +++ b/tests/debuginfo/fn_ptr.rs @@ -3,22 +3,22 @@ // === CDB TESTS ================================================================================== -// cdb-command: g -// cdb-command: dx basic -// cdb-check: basic : [...] : a!core::ops::function::FnOnce::call_once >+0x0 [Type: int (__cdecl*)(int,int)] -// cdb-check: a!core::ops::function::FnOnce::call_once >+0x0 [Type: int __cdecl(int,int)] +//@ cdb-command: g +//@ cdb-command: dx basic +//@ cdb-check: basic : [...] : a!core::ops::function::FnOnce::call_once >+0x0 [Type: int (__cdecl*)(int,int)] +//@ cdb-check: a!core::ops::function::FnOnce::call_once >+0x0 [Type: int __cdecl(int,int)] -// cdb-command: dx paramless -// cdb-check: paramless : [...] : a!core::ops::function::FnOnce::call_once >+0x0 [Type: int (__cdecl*)()] -// cdb-check: a!core::ops::function::FnOnce::call_once >+0x0 [Type: int __cdecl()] +//@ cdb-command: dx paramless +//@ cdb-check: paramless : [...] : a!core::ops::function::FnOnce::call_once >+0x0 [Type: int (__cdecl*)()] +//@ cdb-check: a!core::ops::function::FnOnce::call_once >+0x0 [Type: int __cdecl()] -// cdb-command: dx my_struct -// cdb-check: my_struct [Type: fn_ptr::MyStruct] -// cdb-check: [+0x000] my_field : [...] : a!core::ops::function::FnOnce::call_once > >+0x0 [Type: int (__cdecl*)(fn_ptr::MyStruct *)] +//@ cdb-command: dx my_struct +//@ cdb-check: my_struct [Type: fn_ptr::MyStruct] +//@ cdb-check: [+0x000] my_field : [...] : a!core::ops::function::FnOnce::call_once > >+0x0 [Type: int (__cdecl*)(fn_ptr::MyStruct *)] -// cdb-command: dx non_rec_struct -// cdb-check: non_rec_struct [Type: fn_ptr::NonRecStruct] -// cdb-check: [+0x000] my_field : [...] : a!core::ops::function::FnOnce::call_once >+0x0 [Type: int (__cdecl*)(int)] +//@ cdb-command: dx non_rec_struct +//@ cdb-check: non_rec_struct [Type: fn_ptr::NonRecStruct] +//@ cdb-check: [+0x000] my_field : [...] : a!core::ops::function::FnOnce::call_once >+0x0 [Type: int (__cdecl*)(int)] type BasicFnPtr = fn(i32, i32) -> i32; diff --git a/tests/debuginfo/function-arg-initialization.rs b/tests/debuginfo/function-arg-initialization.rs index d9ce6ead5f2b..c3b7ed81d026 100644 --- a/tests/debuginfo/function-arg-initialization.rs +++ b/tests/debuginfo/function-arg-initialization.rs @@ -13,206 +13,206 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // IMMEDIATE ARGS -// gdb-command:print a -// gdb-check:$1 = 1 -// gdb-command:print b -// gdb-check:$2 = true -// gdb-command:print c -// gdb-check:$3 = 2.5 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$1 = 1 +//@ gdb-command:print b +//@ gdb-check:$2 = true +//@ gdb-command:print c +//@ gdb-check:$3 = 2.5 +//@ gdb-command:continue // NON IMMEDIATE ARGS -// gdb-command:print a -// gdb-check:$4 = function_arg_initialization::BigStruct {a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10} -// gdb-command:print b -// gdb-check:$5 = function_arg_initialization::BigStruct {a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18} -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$4 = function_arg_initialization::BigStruct {a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10} +//@ gdb-command:print b +//@ gdb-check:$5 = function_arg_initialization::BigStruct {a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18} +//@ gdb-command:continue // BINDING -// gdb-command:print a -// gdb-check:$6 = 19 -// gdb-command:print b -// gdb-check:$7 = 20 -// gdb-command:print c -// gdb-check:$8 = 21.5 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$6 = 19 +//@ gdb-command:print b +//@ gdb-check:$7 = 20 +//@ gdb-command:print c +//@ gdb-check:$8 = 21.5 +//@ gdb-command:continue // ASSIGNMENT -// gdb-command:print a -// gdb-check:$9 = 22 -// gdb-command:print b -// gdb-check:$10 = 23 -// gdb-command:print c -// gdb-check:$11 = 24.5 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$9 = 22 +//@ gdb-command:print b +//@ gdb-check:$10 = 23 +//@ gdb-command:print c +//@ gdb-check:$11 = 24.5 +//@ gdb-command:continue // FUNCTION CALL -// gdb-command:print x -// gdb-check:$12 = 25 -// gdb-command:print y -// gdb-check:$13 = 26 -// gdb-command:print z -// gdb-check:$14 = 27.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$12 = 25 +//@ gdb-command:print y +//@ gdb-check:$13 = 26 +//@ gdb-command:print z +//@ gdb-check:$14 = 27.5 +//@ gdb-command:continue // EXPR -// gdb-command:print x -// gdb-check:$15 = 28 -// gdb-command:print y -// gdb-check:$16 = 29 -// gdb-command:print z -// gdb-check:$17 = 30.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$15 = 28 +//@ gdb-command:print y +//@ gdb-check:$16 = 29 +//@ gdb-command:print z +//@ gdb-check:$17 = 30.5 +//@ gdb-command:continue // RETURN EXPR -// gdb-command:print x -// gdb-check:$18 = 31 -// gdb-command:print y -// gdb-check:$19 = 32 -// gdb-command:print z -// gdb-check:$20 = 33.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$18 = 31 +//@ gdb-command:print y +//@ gdb-check:$19 = 32 +//@ gdb-command:print z +//@ gdb-check:$20 = 33.5 +//@ gdb-command:continue // ARITHMETIC EXPR -// gdb-command:print x -// gdb-check:$21 = 34 -// gdb-command:print y -// gdb-check:$22 = 35 -// gdb-command:print z -// gdb-check:$23 = 36.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$21 = 34 +//@ gdb-command:print y +//@ gdb-check:$22 = 35 +//@ gdb-command:print z +//@ gdb-check:$23 = 36.5 +//@ gdb-command:continue // IF EXPR -// gdb-command:print x -// gdb-check:$24 = 37 -// gdb-command:print y -// gdb-check:$25 = 38 -// gdb-command:print z -// gdb-check:$26 = 39.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$24 = 37 +//@ gdb-command:print y +//@ gdb-check:$25 = 38 +//@ gdb-command:print z +//@ gdb-check:$26 = 39.5 +//@ gdb-command:continue // WHILE EXPR -// gdb-command:print x -// gdb-check:$27 = 40 -// gdb-command:print y -// gdb-check:$28 = 41 -// gdb-command:print z -// gdb-check:$29 = 42 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$27 = 40 +//@ gdb-command:print y +//@ gdb-check:$28 = 41 +//@ gdb-command:print z +//@ gdb-check:$29 = 42 +//@ gdb-command:continue // LOOP EXPR -// gdb-command:print x -// gdb-check:$30 = 43 -// gdb-command:print y -// gdb-check:$31 = 44 -// gdb-command:print z -// gdb-check:$32 = 45 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$30 = 43 +//@ gdb-command:print y +//@ gdb-check:$31 = 44 +//@ gdb-command:print z +//@ gdb-check:$32 = 45 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // IMMEDIATE ARGS -// lldb-command:v a -// lldb-check:[...] 1 -// lldb-command:v b -// lldb-check:[...] true -// lldb-command:v c -// lldb-check:[...] 2.5 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 1 +//@ lldb-command:v b +//@ lldb-check:[...] true +//@ lldb-command:v c +//@ lldb-check:[...] 2.5 +//@ lldb-command:continue // NON IMMEDIATE ARGS -// lldb-command:v a -// lldb-check:[...] BigStruct { a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10 } -// lldb-command:v b -// lldb-check:[...] BigStruct { a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18 } -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] BigStruct { a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10 } +//@ lldb-command:v b +//@ lldb-check:[...] BigStruct { a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18 } +//@ lldb-command:continue // BINDING -// lldb-command:v a -// lldb-check:[...] 19 -// lldb-command:v b -// lldb-check:[...] 20 -// lldb-command:v c -// lldb-check:[...] 21.5 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 19 +//@ lldb-command:v b +//@ lldb-check:[...] 20 +//@ lldb-command:v c +//@ lldb-check:[...] 21.5 +//@ lldb-command:continue // ASSIGNMENT -// lldb-command:v a -// lldb-check:[...] 22 -// lldb-command:v b -// lldb-check:[...] 23 -// lldb-command:v c -// lldb-check:[...] 24.5 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 22 +//@ lldb-command:v b +//@ lldb-check:[...] 23 +//@ lldb-command:v c +//@ lldb-check:[...] 24.5 +//@ lldb-command:continue // FUNCTION CALL -// lldb-command:v x -// lldb-check:[...] 25 -// lldb-command:v y -// lldb-check:[...] 26 -// lldb-command:v z -// lldb-check:[...] 27.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 25 +//@ lldb-command:v y +//@ lldb-check:[...] 26 +//@ lldb-command:v z +//@ lldb-check:[...] 27.5 +//@ lldb-command:continue // EXPR -// lldb-command:v x -// lldb-check:[...] 28 -// lldb-command:v y -// lldb-check:[...] 29 -// lldb-command:v z -// lldb-check:[...] 30.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 28 +//@ lldb-command:v y +//@ lldb-check:[...] 29 +//@ lldb-command:v z +//@ lldb-check:[...] 30.5 +//@ lldb-command:continue // RETURN EXPR -// lldb-command:v x -// lldb-check:[...] 31 -// lldb-command:v y -// lldb-check:[...] 32 -// lldb-command:v z -// lldb-check:[...] 33.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 31 +//@ lldb-command:v y +//@ lldb-check:[...] 32 +//@ lldb-command:v z +//@ lldb-check:[...] 33.5 +//@ lldb-command:continue // ARITHMETIC EXPR -// lldb-command:v x -// lldb-check:[...] 34 -// lldb-command:v y -// lldb-check:[...] 35 -// lldb-command:v z -// lldb-check:[...] 36.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 34 +//@ lldb-command:v y +//@ lldb-check:[...] 35 +//@ lldb-command:v z +//@ lldb-check:[...] 36.5 +//@ lldb-command:continue // IF EXPR -// lldb-command:v x -// lldb-check:[...] 37 -// lldb-command:v y -// lldb-check:[...] 38 -// lldb-command:v z -// lldb-check:[...] 39.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 37 +//@ lldb-command:v y +//@ lldb-check:[...] 38 +//@ lldb-command:v z +//@ lldb-check:[...] 39.5 +//@ lldb-command:continue // WHILE EXPR -// lldb-command:v x -// lldb-check:[...] 40 -// lldb-command:v y -// lldb-check:[...] 41 -// lldb-command:v z -// lldb-check:[...] 42 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 40 +//@ lldb-command:v y +//@ lldb-check:[...] 41 +//@ lldb-command:v z +//@ lldb-check:[...] 42 +//@ lldb-command:continue // LOOP EXPR -// lldb-command:v x -// lldb-check:[...] 43 -// lldb-command:v y -// lldb-check:[...] 44 -// lldb-command:v z -// lldb-check:[...] 45 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 43 +//@ lldb-command:v y +//@ lldb-check:[...] 44 +//@ lldb-command:v z +//@ lldb-check:[...] 45 +//@ lldb-command:continue #![allow(unused_variables)] diff --git a/tests/debuginfo/function-arguments.rs b/tests/debuginfo/function-arguments.rs index 47c6ebe11554..6fdf299004b3 100644 --- a/tests/debuginfo/function-arguments.rs +++ b/tests/debuginfo/function-arguments.rs @@ -4,35 +4,35 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print x -// gdb-check:$1 = 111102 -// gdb-command:print y -// gdb-check:$2 = true -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = 111102 +//@ gdb-command:print y +//@ gdb-check:$2 = true +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$3 = 2000 -// gdb-command:print b -// gdb-check:$4 = 3000 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$3 = 2000 +//@ gdb-command:print b +//@ gdb-check:$4 = 3000 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v x -// lldb-check:[...] 111102 -// lldb-command:v y -// lldb-check:[...] true -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 111102 +//@ lldb-command:v y +//@ lldb-check:[...] true +//@ lldb-command:continue -// lldb-command:v a -// lldb-check:[...] 2000 -// lldb-command:v b -// lldb-check:[...] 3000 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 2000 +//@ lldb-command:v b +//@ lldb-check:[...] 3000 +//@ lldb-command:continue fn main() { diff --git a/tests/debuginfo/function-call.rs b/tests/debuginfo/function-call.rs index c0b23dc551ea..37eda165d99c 100644 --- a/tests/debuginfo/function-call.rs +++ b/tests/debuginfo/function-call.rs @@ -6,15 +6,15 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print fun(45, true) -// gdb-check:$1 = true -// gdb-command:print fun(444, false) -// gdb-check:$2 = false +//@ gdb-command:print fun(45, true) +//@ gdb-check:$1 = true +//@ gdb-command:print fun(444, false) +//@ gdb-check:$2 = false -// gdb-command:print r.get_x() -// gdb-check:$3 = 4 +//@ gdb-command:print r.get_x() +//@ gdb-check:$3 = 4 #![allow(dead_code, unused_variables)] diff --git a/tests/debuginfo/function-names.rs b/tests/debuginfo/function-names.rs index 75fc14129761..e2f106e56543 100644 --- a/tests/debuginfo/function-names.rs +++ b/tests/debuginfo/function-names.rs @@ -8,76 +8,76 @@ // === GDB TESTS =================================================================================== // Top-level function -// gdb-command:info functions -q function_names::main -// gdb-check:[...]static fn function_names::main(); -// gdb-command:info functions -q function_names::generic_func<* -// gdb-check:[...]static fn function_names::generic_func(i32) -> i32; +//@ gdb-command:info functions -q function_names::main +//@ gdb-check:[...]static fn function_names::main(); +//@ gdb-command:info functions -q function_names::generic_func<* +//@ gdb-check:[...]static fn function_names::generic_func(i32) -> i32; // Implementations -// gdb-command:info functions -q function_names::.*::impl_function.* -// gdb-check:[...]static fn function_names::GenericStruct::impl_function(); -// gdb-check:[...]static fn function_names::Mod1::TestStruct2::impl_function(); -// gdb-check:[...]static fn function_names::TestStruct1::impl_function(); +//@ gdb-command:info functions -q function_names::.*::impl_function.* +//@ gdb-check:[...]static fn function_names::GenericStruct::impl_function(); +//@ gdb-check:[...]static fn function_names::Mod1::TestStruct2::impl_function(); +//@ gdb-check:[...]static fn function_names::TestStruct1::impl_function(); // Trait implementations -// gdb-command:info functions -q function_names::.*::trait_function.* -// gdb-check:[...]static fn function_names::Mod1::{impl#1}::trait_function(); -// gdb-check:[...]static fn function_names::{impl#1}::trait_function(); -// gdb-check:[...]static fn function_names::{impl#3}::trait_function(); -// gdb-check:[...]static fn function_names::{impl#5}::trait_function3(); -// gdb-check:[...]static fn function_names::{impl#6}::trait_function(); +//@ gdb-command:info functions -q function_names::.*::trait_function.* +//@ gdb-check:[...]static fn function_names::Mod1::{impl#1}::trait_function(); +//@ gdb-check:[...]static fn function_names::{impl#1}::trait_function(); +//@ gdb-check:[...]static fn function_names::{impl#3}::trait_function(); +//@ gdb-check:[...]static fn function_names::{impl#5}::trait_function3(); +//@ gdb-check:[...]static fn function_names::{impl#6}::trait_function(); // Closure -// gdb-command:info functions -q function_names::.*::{closure.* -// gdb-check:[...]static fn function_names::generic_func::{closure#0}(*mut function_names::generic_func::{closure_env#0}); -// gdb-check:[...]static fn function_names::main::{closure#0}(*mut function_names::main::{closure_env#0}); -// gdb-check:[...]static fn function_names::{impl#2}::impl_function::{closure#0}(*mut function_names::{impl#2}::impl_function::{closure_env#0}); +//@ gdb-command:info functions -q function_names::.*::{closure.* +//@ gdb-check:[...]static fn function_names::generic_func::{closure#0}(*mut function_names::generic_func::{closure_env#0}); +//@ gdb-check:[...]static fn function_names::main::{closure#0}(*mut function_names::main::{closure_env#0}); +//@ gdb-check:[...]static fn function_names::{impl#2}::impl_function::{closure#0}(*mut function_names::{impl#2}::impl_function::{closure_env#0}); // Coroutine // Coroutines don't seem to appear in GDB's symbol table. // Const generic parameter -// gdb-command:info functions -q function_names::const_generic_fn.* -// gdb-check:[...]static fn function_names::const_generic_fn_bool(); -// gdb-check:[...]static fn function_names::const_generic_fn_non_int<{CONST#ffa3db4ca1d52dce}>(); -// gdb-check:[...]static fn function_names::const_generic_fn_signed_int<-7>(); -// gdb-check:[...]static fn function_names::const_generic_fn_unsigned_int<14>(); +//@ gdb-command:info functions -q function_names::const_generic_fn.* +//@ gdb-check:[...]static fn function_names::const_generic_fn_bool(); +//@ gdb-check:[...]static fn function_names::const_generic_fn_non_int<{CONST#ffa3db4ca1d52dce}>(); +//@ gdb-check:[...]static fn function_names::const_generic_fn_signed_int<-7>(); +//@ gdb-check:[...]static fn function_names::const_generic_fn_unsigned_int<14>(); // === CDB TESTS =================================================================================== // Top-level function -// cdb-command:x a!function_names::main -// cdb-check:[...] a!function_names::main (void) -// cdb-command:x a!function_names::generic_func<* -// cdb-check:[...] a!function_names::generic_func (int) +//@ cdb-command:x a!function_names::main +//@ cdb-check:[...] a!function_names::main (void) +//@ cdb-command:x a!function_names::generic_func<* +//@ cdb-check:[...] a!function_names::generic_func (int) // Implementations -// cdb-command:x a!function_names::*::impl_function* -// cdb-check:[...] a!function_names::Mod1::TestStruct2::impl_function (void) -// cdb-check:[...] a!function_names::TestStruct1::impl_function (void) -// cdb-check:[...] a!function_names::GenericStruct::impl_function (void) +//@ cdb-command:x a!function_names::*::impl_function* +//@ cdb-check:[...] a!function_names::Mod1::TestStruct2::impl_function (void) +//@ cdb-check:[...] a!function_names::TestStruct1::impl_function (void) +//@ cdb-check:[...] a!function_names::GenericStruct::impl_function (void) // Trait implementations -// cdb-command:x a!function_names::*::trait_function* -// cdb-check:[...] a!function_names::impl$3::trait_function (void) -// cdb-check:[...] a!function_names::impl$6::trait_function (void) -// cdb-check:[...] a!function_names::impl$1::trait_function (void) -// cdb-check:[...] a!function_names::impl$5::trait_function3 (void) -// cdb-check:[...] a!function_names::Mod1::impl$1::trait_function (void) +//@ cdb-command:x a!function_names::*::trait_function* +//@ cdb-check:[...] a!function_names::impl$3::trait_function (void) +//@ cdb-check:[...] a!function_names::impl$6::trait_function (void) +//@ cdb-check:[...] a!function_names::impl$1::trait_function (void) +//@ cdb-check:[...] a!function_names::impl$5::trait_function3 (void) +//@ cdb-check:[...] a!function_names::Mod1::impl$1::trait_function (void) // Closure -// cdb-command:x a!function_names::*::closure* -// cdb-check:[...] a!function_names::impl$2::impl_function::closure$0 (void) -// cdb-check:[...] a!function_names::main::closure$0 (void) -// cdb-check:[...] a!function_names::generic_func::closure$0 (void) +//@ cdb-command:x a!function_names::*::closure* +//@ cdb-check:[...] a!function_names::impl$2::impl_function::closure$0 (void) +//@ cdb-check:[...] a!function_names::main::closure$0 (void) +//@ cdb-check:[...] a!function_names::generic_func::closure$0 (void) // Coroutine -// cdb-command:x a!function_names::*::coroutine* -// cdb-check:[...] a!function_names::main::coroutine$1 (void) +//@ cdb-command:x a!function_names::*::coroutine* +//@ cdb-check:[...] a!function_names::main::coroutine$1 (void) // Const generic parameter -// cdb-command:x a!function_names::const_generic_fn* -// cdb-check:[...] a!function_names::const_generic_fn_bool (void) +//@ cdb-command:x a!function_names::const_generic_fn* +//@ cdb-check:[...] a!function_names::const_generic_fn_bool (void) #![allow(unused_variables)] #![feature(adt_const_params, coroutines, coroutine_trait, stmt_expr_attributes)] diff --git a/tests/debuginfo/function-prologue-stepping-regular.rs b/tests/debuginfo/function-prologue-stepping-regular.rs index f61128ca2df1..83d5aa3c0a10 100644 --- a/tests/debuginfo/function-prologue-stepping-regular.rs +++ b/tests/debuginfo/function-prologue-stepping-regular.rs @@ -6,115 +6,115 @@ //@ compile-flags:-g //@ disable-gdb-pretty-printers -// lldb-command:breakpoint set --name immediate_args -// lldb-command:breakpoint set --name non_immediate_args -// lldb-command:breakpoint set --name binding -// lldb-command:breakpoint set --name assignment -// lldb-command:breakpoint set --name function_call -// lldb-command:breakpoint set --name identifier -// lldb-command:breakpoint set --name return_expr -// lldb-command:breakpoint set --name arithmetic_expr -// lldb-command:breakpoint set --name if_expr -// lldb-command:breakpoint set --name while_expr -// lldb-command:breakpoint set --name loop_expr -// lldb-command:run +//@ lldb-command:breakpoint set --name immediate_args +//@ lldb-command:breakpoint set --name non_immediate_args +//@ lldb-command:breakpoint set --name binding +//@ lldb-command:breakpoint set --name assignment +//@ lldb-command:breakpoint set --name function_call +//@ lldb-command:breakpoint set --name identifier +//@ lldb-command:breakpoint set --name return_expr +//@ lldb-command:breakpoint set --name arithmetic_expr +//@ lldb-command:breakpoint set --name if_expr +//@ lldb-command:breakpoint set --name while_expr +//@ lldb-command:breakpoint set --name loop_expr +//@ lldb-command:run // IMMEDIATE ARGS -// lldb-command:v a -// lldb-check:[...] 1 -// lldb-command:v b -// lldb-check:[...] true -// lldb-command:v c -// lldb-check:[...] 2.5 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 1 +//@ lldb-command:v b +//@ lldb-check:[...] true +//@ lldb-command:v c +//@ lldb-check:[...] 2.5 +//@ lldb-command:continue // NON IMMEDIATE ARGS -// lldb-command:v a -// lldb-check:[...] { a = 3, b = 4, c = 5, d = 6, e = 7, f = 8, g = 9, h = 10 } -// lldb-command:v b -// lldb-check:[...] { a = 11, b = 12, c = 13, d = 14, e = 15, f = 16, g = 17, h = 18 } -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] { a = 3, b = 4, c = 5, d = 6, e = 7, f = 8, g = 9, h = 10 } +//@ lldb-command:v b +//@ lldb-check:[...] { a = 11, b = 12, c = 13, d = 14, e = 15, f = 16, g = 17, h = 18 } +//@ lldb-command:continue // BINDING -// lldb-command:v a -// lldb-check:[...] 19 -// lldb-command:v b -// lldb-check:[...] 20 -// lldb-command:v c -// lldb-check:[...] 21.5 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 19 +//@ lldb-command:v b +//@ lldb-check:[...] 20 +//@ lldb-command:v c +//@ lldb-check:[...] 21.5 +//@ lldb-command:continue // ASSIGNMENT -// lldb-command:v a -// lldb-check:[...] 22 -// lldb-command:v b -// lldb-check:[...] 23 -// lldb-command:v c -// lldb-check:[...] 24.5 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 22 +//@ lldb-command:v b +//@ lldb-check:[...] 23 +//@ lldb-command:v c +//@ lldb-check:[...] 24.5 +//@ lldb-command:continue // FUNCTION CALL -// lldb-command:v x -// lldb-check:[...] 25 -// lldb-command:v y -// lldb-check:[...] 26 -// lldb-command:v z -// lldb-check:[...] 27.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 25 +//@ lldb-command:v y +//@ lldb-check:[...] 26 +//@ lldb-command:v z +//@ lldb-check:[...] 27.5 +//@ lldb-command:continue // EXPR -// lldb-command:v x -// lldb-check:[...] 28 -// lldb-command:v y -// lldb-check:[...] 29 -// lldb-command:v z -// lldb-check:[...] 30.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 28 +//@ lldb-command:v y +//@ lldb-check:[...] 29 +//@ lldb-command:v z +//@ lldb-check:[...] 30.5 +//@ lldb-command:continue // RETURN EXPR -// lldb-command:v x -// lldb-check:[...] 31 -// lldb-command:v y -// lldb-check:[...] 32 -// lldb-command:v z -// lldb-check:[...] 33.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 31 +//@ lldb-command:v y +//@ lldb-check:[...] 32 +//@ lldb-command:v z +//@ lldb-check:[...] 33.5 +//@ lldb-command:continue // ARITHMETIC EXPR -// lldb-command:v x -// lldb-check:[...] 34 -// lldb-command:v y -// lldb-check:[...] 35 -// lldb-command:v z -// lldb-check:[...] 36.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 34 +//@ lldb-command:v y +//@ lldb-check:[...] 35 +//@ lldb-command:v z +//@ lldb-check:[...] 36.5 +//@ lldb-command:continue // IF EXPR -// lldb-command:v x -// lldb-check:[...] 37 -// lldb-command:v y -// lldb-check:[...] 38 -// lldb-command:v z -// lldb-check:[...] 39.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 37 +//@ lldb-command:v y +//@ lldb-check:[...] 38 +//@ lldb-command:v z +//@ lldb-check:[...] 39.5 +//@ lldb-command:continue // WHILE EXPR -// lldb-command:v x -// lldb-check:[...] 40 -// lldb-command:v y -// lldb-check:[...] 41 -// lldb-command:v z -// lldb-check:[...] 42 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 40 +//@ lldb-command:v y +//@ lldb-check:[...] 41 +//@ lldb-command:v z +//@ lldb-check:[...] 42 +//@ lldb-command:continue // LOOP EXPR -// lldb-command:v x -// lldb-check:[...] 43 -// lldb-command:v y -// lldb-check:[...] 44 -// lldb-command:v z -// lldb-check:[...] 45 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 43 +//@ lldb-command:v y +//@ lldb-check:[...] 44 +//@ lldb-command:v z +//@ lldb-check:[...] 45 +//@ lldb-command:continue #![allow(unused_variables)] diff --git a/tests/debuginfo/gdb-char.rs b/tests/debuginfo/gdb-char.rs index 5f44fa5c4233..a2e4c278a660 100644 --- a/tests/debuginfo/gdb-char.rs +++ b/tests/debuginfo/gdb-char.rs @@ -8,9 +8,9 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print ch -// gdb-check:$1 = 97 'a' +//@ gdb-command:run +//@ gdb-command:print ch +//@ gdb-check:$1 = 97 'a' #![allow(unused_variables)] diff --git a/tests/debuginfo/gdb-pretty-struct-and-enums.rs b/tests/debuginfo/gdb-pretty-struct-and-enums.rs index ab6aea6b6316..74197cddb0d8 100644 --- a/tests/debuginfo/gdb-pretty-struct-and-enums.rs +++ b/tests/debuginfo/gdb-pretty-struct-and-enums.rs @@ -4,22 +4,22 @@ //@ compile-flags:-g //@ ignore-backends: gcc -// gdb-command: run +//@ gdb-command: run -// gdb-command: print regular_struct -// gdb-check:$1 = gdb_pretty_struct_and_enums::RegularStruct {the_first_field: 101, the_second_field: 102.5, the_third_field: false} +//@ gdb-command: print regular_struct +//@ gdb-check:$1 = gdb_pretty_struct_and_enums::RegularStruct {the_first_field: 101, the_second_field: 102.5, the_third_field: false} -// gdb-command: print empty_struct -// gdb-check:$2 = gdb_pretty_struct_and_enums::EmptyStruct +//@ gdb-command: print empty_struct +//@ gdb-check:$2 = gdb_pretty_struct_and_enums::EmptyStruct -// gdb-command: print c_style_enum1 -// gdb-check:$3 = gdb_pretty_struct_and_enums::CStyleEnum::CStyleEnumVar1 +//@ gdb-command: print c_style_enum1 +//@ gdb-check:$3 = gdb_pretty_struct_and_enums::CStyleEnum::CStyleEnumVar1 -// gdb-command: print c_style_enum2 -// gdb-check:$4 = gdb_pretty_struct_and_enums::CStyleEnum::CStyleEnumVar2 +//@ gdb-command: print c_style_enum2 +//@ gdb-check:$4 = gdb_pretty_struct_and_enums::CStyleEnum::CStyleEnumVar2 -// gdb-command: print c_style_enum3 -// gdb-check:$5 = gdb_pretty_struct_and_enums::CStyleEnum::CStyleEnumVar3 +//@ gdb-command: print c_style_enum3 +//@ gdb-check:$5 = gdb_pretty_struct_and_enums::CStyleEnum::CStyleEnumVar3 #![allow(dead_code, unused_variables)] diff --git a/tests/debuginfo/generic-enum-with-different-disr-sizes.rs b/tests/debuginfo/generic-enum-with-different-disr-sizes.rs index 07a92619e211..24381d4accda 100644 --- a/tests/debuginfo/generic-enum-with-different-disr-sizes.rs +++ b/tests/debuginfo/generic-enum-with-different-disr-sizes.rs @@ -5,57 +5,57 @@ //@ ignore-backends: gcc // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print eight_bytes1 -// gdb-check:$1 = generic_enum_with_different_disr_sizes::Enum::Variant1(100) +//@ gdb-command:print eight_bytes1 +//@ gdb-check:$1 = generic_enum_with_different_disr_sizes::Enum::Variant1(100) -// gdb-command:print four_bytes1 -// gdb-check:$2 = generic_enum_with_different_disr_sizes::Enum::Variant1(101) +//@ gdb-command:print four_bytes1 +//@ gdb-check:$2 = generic_enum_with_different_disr_sizes::Enum::Variant1(101) -// gdb-command:print two_bytes1 -// gdb-check:$3 = generic_enum_with_different_disr_sizes::Enum::Variant1(102) +//@ gdb-command:print two_bytes1 +//@ gdb-check:$3 = generic_enum_with_different_disr_sizes::Enum::Variant1(102) -// gdb-command:print one_byte1 -// gdb-check:$4 = generic_enum_with_different_disr_sizes::Enum::Variant1(65) +//@ gdb-command:print one_byte1 +//@ gdb-check:$4 = generic_enum_with_different_disr_sizes::Enum::Variant1(65) -// gdb-command:print eight_bytes2 -// gdb-check:$5 = generic_enum_with_different_disr_sizes::Enum::Variant2(100) +//@ gdb-command:print eight_bytes2 +//@ gdb-check:$5 = generic_enum_with_different_disr_sizes::Enum::Variant2(100) -// gdb-command:print four_bytes2 -// gdb-check:$6 = generic_enum_with_different_disr_sizes::Enum::Variant2(101) +//@ gdb-command:print four_bytes2 +//@ gdb-check:$6 = generic_enum_with_different_disr_sizes::Enum::Variant2(101) -// gdb-command:print two_bytes2 -// gdb-check:$7 = generic_enum_with_different_disr_sizes::Enum::Variant2(102) +//@ gdb-command:print two_bytes2 +//@ gdb-check:$7 = generic_enum_with_different_disr_sizes::Enum::Variant2(102) -// gdb-command:print one_byte2 -// gdb-check:$8 = generic_enum_with_different_disr_sizes::Enum::Variant2(65) +//@ gdb-command:print one_byte2 +//@ gdb-check:$8 = generic_enum_with_different_disr_sizes::Enum::Variant2(65) -// gdb-command:continue +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v eight_bytes1 -// lldb-check:[...] Variant1(100) -// lldb-command:v four_bytes1 -// lldb-check:[...] Variant1(101) -// lldb-command:v two_bytes1 -// lldb-check:[...] Variant1(102) -// lldb-command:v one_byte1 -// lldb-check:[...] Variant1('A') +//@ lldb-command:v eight_bytes1 +//@ lldb-check:[...] Variant1(100) +//@ lldb-command:v four_bytes1 +//@ lldb-check:[...] Variant1(101) +//@ lldb-command:v two_bytes1 +//@ lldb-check:[...] Variant1(102) +//@ lldb-command:v one_byte1 +//@ lldb-check:[...] Variant1('A') -// lldb-command:v eight_bytes2 -// lldb-check:[...] Variant2(100) -// lldb-command:v four_bytes2 -// lldb-check:[...] Variant2(101) -// lldb-command:v two_bytes2 -// lldb-check:[...] Variant2(102) -// lldb-command:v one_byte2 -// lldb-check:[...] Variant2('A') +//@ lldb-command:v eight_bytes2 +//@ lldb-check:[...] Variant2(100) +//@ lldb-command:v four_bytes2 +//@ lldb-check:[...] Variant2(101) +//@ lldb-command:v two_bytes2 +//@ lldb-check:[...] Variant2(102) +//@ lldb-command:v one_byte2 +//@ lldb-check:[...] Variant2('A') -// lldb-command:continue +//@ lldb-command:continue #![allow(unused_variables)] #![allow(dead_code)] diff --git a/tests/debuginfo/generic-function.rs b/tests/debuginfo/generic-function.rs index 9ca9eb32a2e1..4e66021b633c 100644 --- a/tests/debuginfo/generic-function.rs +++ b/tests/debuginfo/generic-function.rs @@ -4,47 +4,47 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print *t0 -// gdb-check:$1 = 1 -// gdb-command:print *t1 -// gdb-check:$2 = 2.5 -// gdb-command:continue +//@ gdb-command:print *t0 +//@ gdb-check:$1 = 1 +//@ gdb-command:print *t1 +//@ gdb-check:$2 = 2.5 +//@ gdb-command:continue -// gdb-command:print *t0 -// gdb-check:$3 = 3.5 -// gdb-command:print *t1 -// gdb-check:$4 = 4 -// gdb-command:continue +//@ gdb-command:print *t0 +//@ gdb-check:$3 = 3.5 +//@ gdb-command:print *t1 +//@ gdb-check:$4 = 4 +//@ gdb-command:continue -// gdb-command:print *t0 -// gdb-check:$5 = 5 -// gdb-command:print *t1 -// gdb-check:$6 = generic_function::Struct {a: 6, b: 7.5} -// gdb-command:continue +//@ gdb-command:print *t0 +//@ gdb-check:$5 = 5 +//@ gdb-command:print *t1 +//@ gdb-check:$6 = generic_function::Struct {a: 6, b: 7.5} +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v *t0 -// lldb-check:[...] 1 -// lldb-command:v *t1 -// lldb-check:[...] 2.5 -// lldb-command:continue +//@ lldb-command:v *t0 +//@ lldb-check:[...] 1 +//@ lldb-command:v *t1 +//@ lldb-check:[...] 2.5 +//@ lldb-command:continue -// lldb-command:v *t0 -// lldb-check:[...] 3.5 -// lldb-command:v *t1 -// lldb-check:[...] 4 -// lldb-command:continue +//@ lldb-command:v *t0 +//@ lldb-check:[...] 3.5 +//@ lldb-command:v *t1 +//@ lldb-check:[...] 4 +//@ lldb-command:continue -// lldb-command:v *t0 -// lldb-check:[...] 5 -// lldb-command:v *t1 -// lldb-check:[...] { a = 6 b = 7.5 } -// lldb-command:continue +//@ lldb-command:v *t0 +//@ lldb-check:[...] 5 +//@ lldb-command:v *t1 +//@ lldb-check:[...] { a = 6 b = 7.5 } +//@ lldb-command:continue #[derive(Clone)] struct Struct { diff --git a/tests/debuginfo/generic-functions-nested.rs b/tests/debuginfo/generic-functions-nested.rs index 1a87827c7759..eab4a5f6c4af 100644 --- a/tests/debuginfo/generic-functions-nested.rs +++ b/tests/debuginfo/generic-functions-nested.rs @@ -4,60 +4,60 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print x -// gdb-check:$1 = -1 -// gdb-command:print y -// gdb-check:$2 = 1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = -1 +//@ gdb-command:print y +//@ gdb-check:$2 = 1 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$3 = -1 -// gdb-command:print y -// gdb-check:$4 = 2.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = -1 +//@ gdb-command:print y +//@ gdb-check:$4 = 2.5 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$5 = -2.5 -// gdb-command:print y -// gdb-check:$6 = 1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = -2.5 +//@ gdb-command:print y +//@ gdb-check:$6 = 1 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$7 = -2.5 -// gdb-command:print y -// gdb-check:$8 = 2.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$7 = -2.5 +//@ gdb-command:print y +//@ gdb-check:$8 = 2.5 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v x -// lldb-check:[...] -1 -// lldb-command:v y -// lldb-check:[...] 1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -1 +//@ lldb-command:v y +//@ lldb-check:[...] 1 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] -1 -// lldb-command:v y -// lldb-check:[...] 2.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -1 +//@ lldb-command:v y +//@ lldb-check:[...] 2.5 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] -2.5 -// lldb-command:v y -// lldb-check:[...] 1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -2.5 +//@ lldb-command:v y +//@ lldb-check:[...] 1 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] -2.5 -// lldb-command:v y -// lldb-check:[...] 2.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -2.5 +//@ lldb-command:v y +//@ lldb-check:[...] 2.5 +//@ lldb-command:continue fn outer(a: TA) { inner(a.clone(), 1); diff --git a/tests/debuginfo/generic-method-on-generic-struct.rs b/tests/debuginfo/generic-method-on-generic-struct.rs index 9c1d87ac8c87..54e0798c90dc 100644 --- a/tests/debuginfo/generic-method-on-generic-struct.rs +++ b/tests/debuginfo/generic-method-on-generic-struct.rs @@ -4,102 +4,102 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // STACK BY REF -// gdb-command:print *self -// gdb-check:$1 = generic_method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)} -// gdb-command:print arg1 -// gdb-check:$2 = -1 -// gdb-command:print arg2 -// gdb-check:$3 = 2 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$1 = generic_method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)} +//@ gdb-command:print arg1 +//@ gdb-check:$2 = -1 +//@ gdb-command:print arg2 +//@ gdb-check:$3 = 2 +//@ gdb-command:continue // STACK BY VAL -// gdb-command:print self -// gdb-check:$4 = generic_method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)} -// gdb-command:print arg1 -// gdb-check:$5 = -3 -// gdb-command:print arg2 -// gdb-check:$6 = -4 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$4 = generic_method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)} +//@ gdb-command:print arg1 +//@ gdb-check:$5 = -3 +//@ gdb-command:print arg2 +//@ gdb-check:$6 = -4 +//@ gdb-command:continue // OWNED BY REF -// gdb-command:print *self -// gdb-check:$7 = generic_method_on_generic_struct::Struct {x: 1234.5} -// gdb-command:print arg1 -// gdb-check:$8 = -5 -// gdb-command:print arg2 -// gdb-check:$9 = -6 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$7 = generic_method_on_generic_struct::Struct {x: 1234.5} +//@ gdb-command:print arg1 +//@ gdb-check:$8 = -5 +//@ gdb-command:print arg2 +//@ gdb-check:$9 = -6 +//@ gdb-command:continue // OWNED BY VAL -// gdb-command:print self -// gdb-check:$10 = generic_method_on_generic_struct::Struct {x: 1234.5} -// gdb-command:print arg1 -// gdb-check:$11 = -7 -// gdb-command:print arg2 -// gdb-check:$12 = -8 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$10 = generic_method_on_generic_struct::Struct {x: 1234.5} +//@ gdb-command:print arg1 +//@ gdb-check:$11 = -7 +//@ gdb-command:print arg2 +//@ gdb-check:$12 = -8 +//@ gdb-command:continue // OWNED MOVED -// gdb-command:print *self -// gdb-check:$13 = generic_method_on_generic_struct::Struct {x: 1234.5} -// gdb-command:print arg1 -// gdb-check:$14 = -9 -// gdb-command:print arg2 -// gdb-check:$15 = -10.5 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$13 = generic_method_on_generic_struct::Struct {x: 1234.5} +//@ gdb-command:print arg1 +//@ gdb-check:$14 = -9 +//@ gdb-command:print arg2 +//@ gdb-check:$15 = -10.5 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // STACK BY REF -// lldb-command:v *self -// lldb-check:[...] { x = (8888, -8888) { 0 = 8888 1 = -8888 } } -// lldb-command:v arg1 -// lldb-check:[...] -1 -// lldb-command:v arg2 -// lldb-check:[...] 2 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = (8888, -8888) { 0 = 8888 1 = -8888 } } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -1 +//@ lldb-command:v arg2 +//@ lldb-check:[...] 2 +//@ lldb-command:continue // STACK BY VAL -// lldb-command:v self -// lldb-check:[...] { x = (8888, -8888) { 0 = 8888 1 = -8888 } } -// lldb-command:v arg1 -// lldb-check:[...] -3 -// lldb-command:v arg2 -// lldb-check:[...] -4 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = (8888, -8888) { 0 = 8888 1 = -8888 } } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -3 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -4 +//@ lldb-command:continue // OWNED BY REF -// lldb-command:v *self -// lldb-check:[...] { x = 1234.5 } -// lldb-command:v arg1 -// lldb-check:[...] -5 -// lldb-command:v arg2 -// lldb-check:[...] -6 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 1234.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -5 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -6 +//@ lldb-command:continue // OWNED BY VAL -// lldb-command:v self -// lldb-check:[...] { x = 1234.5 } -// lldb-command:v arg1 -// lldb-check:[...] -7 -// lldb-command:v arg2 -// lldb-check:[...] -8 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = 1234.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -7 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -8 +//@ lldb-command:continue // OWNED MOVED -// lldb-command:v *self -// lldb-check:[...] { x = 1234.5 } -// lldb-command:v arg1 -// lldb-check:[...] -9 -// lldb-command:v arg2 -// lldb-check:[...] -10.5 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 1234.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -9 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -10.5 +//@ lldb-command:continue #[derive(Copy, Clone)] struct Struct { diff --git a/tests/debuginfo/generic-static-method-on-struct-and-enum.rs b/tests/debuginfo/generic-static-method-on-struct-and-enum.rs index be9f394f133d..d2800f24092a 100644 --- a/tests/debuginfo/generic-static-method-on-struct-and-enum.rs +++ b/tests/debuginfo/generic-static-method-on-struct-and-enum.rs @@ -2,23 +2,23 @@ //@ disable-gdb-pretty-printers //@ ignore-backends: gcc -// gdb-command:run +//@ gdb-command:run // STRUCT -// gdb-command:print arg1 -// gdb-check:$1 = 1 -// gdb-command:print arg2 -// gdb-check:$2 = 2 -// gdb-command:continue +//@ gdb-command:print arg1 +//@ gdb-check:$1 = 1 +//@ gdb-command:print arg2 +//@ gdb-check:$2 = 2 +//@ gdb-command:continue // ENUM -// gdb-command:print arg1 -// gdb-check:$3 = -3 -// gdb-command:print arg2 -// gdb-check:$4 = 4.5 -// gdb-command:print arg3 -// gdb-check:$5 = 5 -// gdb-command:continue +//@ gdb-command:print arg1 +//@ gdb-check:$3 = -3 +//@ gdb-command:print arg2 +//@ gdb-check:$4 = 4.5 +//@ gdb-command:print arg3 +//@ gdb-check:$5 = 5 +//@ gdb-command:continue struct Struct { diff --git a/tests/debuginfo/generic-struct-style-enum.rs b/tests/debuginfo/generic-struct-style-enum.rs index 7b7a36effd57..4c6ebdfb0fd0 100644 --- a/tests/debuginfo/generic-struct-style-enum.rs +++ b/tests/debuginfo/generic-struct-style-enum.rs @@ -2,20 +2,20 @@ //@ disable-gdb-pretty-printers //@ ignore-backends: gcc -// gdb-command:set print union on -// gdb-command:run +//@ gdb-command:set print union on +//@ gdb-command:run -// gdb-command:print case1 -// gdb-check:$1 = generic_struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868} +//@ gdb-command:print case1 +//@ gdb-check:$1 = generic_struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868} -// gdb-command:print case2 -// gdb-check:$2 = generic_struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153} +//@ gdb-command:print case2 +//@ gdb-check:$2 = generic_struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153} -// gdb-command:print case3 -// gdb-check:$3 = generic_struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897} +//@ gdb-command:print case3 +//@ gdb-check:$3 = generic_struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897} -// gdb-command:print univariant -// gdb-check:$4 = generic_struct_style_enum::Univariant::TheOnlyCase{a: -1} +//@ gdb-command:print univariant +//@ gdb-check:$4 = generic_struct_style_enum::Univariant::TheOnlyCase{a: -1} use self::Regular::{Case1, Case2, Case3}; diff --git a/tests/debuginfo/generic-struct.rs b/tests/debuginfo/generic-struct.rs index daf6554fab0a..e6e56e288e8d 100644 --- a/tests/debuginfo/generic-struct.rs +++ b/tests/debuginfo/generic-struct.rs @@ -4,51 +4,51 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print int_int -// gdb-check:$1 = generic_struct::AGenericStruct {key: 0, value: 1} -// gdb-command:print int_float -// gdb-check:$2 = generic_struct::AGenericStruct {key: 2, value: 3.5} -// gdb-command:print float_int -// gdb-check:$3 = generic_struct::AGenericStruct {key: 4.5, value: 5} -// gdb-command:print float_int_float -// gdb-check:$4 = generic_struct::AGenericStruct> {key: 6.5, value: generic_struct::AGenericStruct {key: 7, value: 8.5}} +//@ gdb-command:print int_int +//@ gdb-check:$1 = generic_struct::AGenericStruct {key: 0, value: 1} +//@ gdb-command:print int_float +//@ gdb-check:$2 = generic_struct::AGenericStruct {key: 2, value: 3.5} +//@ gdb-command:print float_int +//@ gdb-check:$3 = generic_struct::AGenericStruct {key: 4.5, value: 5} +//@ gdb-command:print float_int_float +//@ gdb-check:$4 = generic_struct::AGenericStruct> {key: 6.5, value: generic_struct::AGenericStruct {key: 7, value: 8.5}} // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v int_int -// lldb-check:[...]AGenericStruct) int_int = { key = 0 value = 1 } -// lldb-command:v int_float -// lldb-check:[...]AGenericStruct) int_float = { key = 2 value = 3.5 } -// lldb-command:v float_int -// lldb-check:[...]AGenericStruct) float_int = { key = 4.5 value = 5 } +//@ lldb-command:v int_int +//@ lldb-check:[...]AGenericStruct) int_int = { key = 0 value = 1 } +//@ lldb-command:v int_float +//@ lldb-check:[...]AGenericStruct) int_float = { key = 2 value = 3.5 } +//@ lldb-command:v float_int +//@ lldb-check:[...]AGenericStruct) float_int = { key = 4.5 value = 5 } -// lldb-command:v float_int_float -// lldb-check:[...]AGenericStruct >) float_int_float = { key = 6.5 value = { key = 7 value = 8.5 } } +//@ lldb-command:v float_int_float +//@ lldb-check:[...]AGenericStruct >) float_int_float = { key = 6.5 value = { key = 7 value = 8.5 } } // === CDB TESTS =================================================================================== -// cdb-command:g +//@ cdb-command:g -// cdb-command:dx int_int -// cdb-check:int_int [Type: generic_struct::AGenericStruct] -// cdb-check:[...]key : 0 [Type: int] -// cdb-check:[...]value : 1 [Type: int] -// cdb-command:dx int_float -// cdb-check:int_float [Type: generic_struct::AGenericStruct] -// cdb-check:[...]key : 2 [Type: int] -// cdb-check:[...]value : 3.500000 [Type: double] -// cdb-command:dx float_int -// cdb-check:float_int [Type: generic_struct::AGenericStruct] -// cdb-check:[...]key : 4.500000 [Type: double] -// cdb-check:[...]value : 5 [Type: int] -// cdb-command:dx float_int_float -// cdb-check:float_int_float [Type: generic_struct::AGenericStruct >] -// cdb-check:[...]key : 6.500000 [Type: double] -// cdb-check:[...]value [Type: generic_struct::AGenericStruct] +//@ cdb-command:dx int_int +//@ cdb-check:int_int [Type: generic_struct::AGenericStruct] +//@ cdb-check:[...]key : 0 [Type: int] +//@ cdb-check:[...]value : 1 [Type: int] +//@ cdb-command:dx int_float +//@ cdb-check:int_float [Type: generic_struct::AGenericStruct] +//@ cdb-check:[...]key : 2 [Type: int] +//@ cdb-check:[...]value : 3.500000 [Type: double] +//@ cdb-command:dx float_int +//@ cdb-check:float_int [Type: generic_struct::AGenericStruct] +//@ cdb-check:[...]key : 4.500000 [Type: double] +//@ cdb-check:[...]value : 5 [Type: int] +//@ cdb-command:dx float_int_float +//@ cdb-check:float_int_float [Type: generic_struct::AGenericStruct >] +//@ cdb-check:[...]key : 6.500000 [Type: double] +//@ cdb-check:[...]value [Type: generic_struct::AGenericStruct] struct AGenericStruct { diff --git a/tests/debuginfo/generic-tuple-style-enum.rs b/tests/debuginfo/generic-tuple-style-enum.rs index de8681bc5361..e805e1fea9f6 100644 --- a/tests/debuginfo/generic-tuple-style-enum.rs +++ b/tests/debuginfo/generic-tuple-style-enum.rs @@ -4,33 +4,33 @@ // === GDB TESTS =================================================================================== -// gdb-command:set print union on -// gdb-command:run +//@ gdb-command:set print union on +//@ gdb-command:run -// gdb-command:print case1 -// gdb-check:$1 = generic_tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868) +//@ gdb-command:print case1 +//@ gdb-check:$1 = generic_tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868) -// gdb-command:print case2 -// gdb-check:$2 = generic_tuple_style_enum::Regular::Case2(0, 286331153, 286331153) +//@ gdb-command:print case2 +//@ gdb-check:$2 = generic_tuple_style_enum::Regular::Case2(0, 286331153, 286331153) -// gdb-command:print case3 -// gdb-check:$3 = generic_tuple_style_enum::Regular::Case3(0, 6438275382588823897) +//@ gdb-command:print case3 +//@ gdb-check:$3 = generic_tuple_style_enum::Regular::Case3(0, 6438275382588823897) -// gdb-command:print univariant -// gdb-check:$4 = generic_tuple_style_enum::Univariant::TheOnlyCase(-1) +//@ gdb-command:print univariant +//@ gdb-check:$4 = generic_tuple_style_enum::Univariant::TheOnlyCase(-1) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v case1 +//@ lldb-command:v case1 -// lldb-command:v case2 +//@ lldb-command:v case2 -// lldb-command:v case3 +//@ lldb-command:v case3 -// lldb-command:v univariant +//@ lldb-command:v univariant use self::Regular::{Case1, Case2, Case3}; diff --git a/tests/debuginfo/include_string.rs b/tests/debuginfo/include_string.rs index 565bd09f89e9..e61aa3026b27 100644 --- a/tests/debuginfo/include_string.rs +++ b/tests/debuginfo/include_string.rs @@ -4,28 +4,28 @@ //@ compile-flags:-g //@ disable-gdb-pretty-printers //@ ignore-backends: gcc -// gdb-command:run -// gdb-command:print string1.length -// gdb-check:$1 = 48 -// gdb-command:print string2.length -// gdb-check:$2 = 49 -// gdb-command:print string3.length -// gdb-check:$3 = 50 -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:print string1.length +//@ gdb-check:$1 = 48 +//@ gdb-command:print string2.length +//@ gdb-check:$2 = 49 +//@ gdb-command:print string3.length +//@ gdb-check:$3 = 50 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v string1.length -// lldb-check:[...] 48 -// lldb-command:v string2.length -// lldb-check:[...] 49 -// lldb-command:v string3.length -// lldb-check:[...] 50 +//@ lldb-command:v string1.length +//@ lldb-check:[...] 48 +//@ lldb-command:v string2.length +//@ lldb-check:[...] 49 +//@ lldb-command:v string3.length +//@ lldb-check:[...] 50 -// lldb-command:continue +//@ lldb-command:continue #![allow(unused_variables)] diff --git a/tests/debuginfo/issue-12886.rs b/tests/debuginfo/issue-12886.rs index 5574294cd57c..b775505a0c6c 100644 --- a/tests/debuginfo/issue-12886.rs +++ b/tests/debuginfo/issue-12886.rs @@ -4,10 +4,10 @@ //@ compile-flags:-g //@ disable-gdb-pretty-printers -// gdb-command:run -// gdb-command:next -// gdb-check:[...]22[...]let s = Some(5).unwrap(); // #break -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-check:[...]22[...]let s = Some(5).unwrap(); // #break +//@ gdb-command:continue // IF YOU MODIFY THIS FILE, BE CAREFUL TO ADAPT THE LINE NUMBERS IN THE DEBUGGER COMMANDS diff --git a/tests/debuginfo/issue-22656.rs b/tests/debuginfo/issue-22656.rs index 3407c0524ebb..54c381b4e76a 100644 --- a/tests/debuginfo/issue-22656.rs +++ b/tests/debuginfo/issue-22656.rs @@ -8,12 +8,12 @@ //@ disable-gdb-pretty-printers // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v v -// lldb-check:[...] size=3 { [0] = 1 [1] = 2 [2] = 3 } -// lldb-command:v zs -// lldb-check:[...] { x = y = 123 z = w = 456 } +//@ lldb-command:v v +//@ lldb-check:[...] size=3 { [0] = 1 [1] = 2 [2] = 3 } +//@ lldb-command:v zs +//@ lldb-check:[...] { x = y = 123 z = w = 456 } #![allow(unused_variables)] #![allow(dead_code)] diff --git a/tests/debuginfo/issue-57822.rs b/tests/debuginfo/issue-57822.rs index aa829dfb21ad..6b030686e4ea 100644 --- a/tests/debuginfo/issue-57822.rs +++ b/tests/debuginfo/issue-57822.rs @@ -8,23 +8,23 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print g -// gdb-check:$1 = issue_57822::main::{closure_env#1} {f: issue_57822::main::{closure_env#0} {x: 1}} +//@ gdb-command:print g +//@ gdb-check:$1 = issue_57822::main::{closure_env#1} {f: issue_57822::main::{closure_env#0} {x: 1}} -// gdb-command:print b -// gdb-check:$2 = issue_57822::main::{coroutine_env#3}::Unresumed{a: issue_57822::main::{coroutine_env#2}::Unresumed{y: 2}} +//@ gdb-command:print b +//@ gdb-check:$2 = issue_57822::main::{coroutine_env#3}::Unresumed{a: issue_57822::main::{coroutine_env#2}::Unresumed{y: 2}} // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v g -// lldb-check:(issue_57822::main::{closure_env#1}) g = { f = { x = 1 } } +//@ lldb-command:v g +//@ lldb-check:(issue_57822::main::{closure_env#1}) g = { f = { x = 1 } } -// lldb-command:v b -// lldb-check:(issue_57822::main::{coroutine_env#3}) b = 2{a:2{y:2}} { a = 2{y:2} { y = 2 } } +//@ lldb-command:v b +//@ lldb-check:(issue_57822::main::{coroutine_env#3}) b = 2{a:2{y:2}} { a = 2{y:2} { y = 2 } } #![feature(coroutines, coroutine_trait, stmt_expr_attributes)] diff --git a/tests/debuginfo/lexical-scope-in-for-loop.rs b/tests/debuginfo/lexical-scope-in-for-loop.rs index c2e97ad469ef..8c5f195452f9 100644 --- a/tests/debuginfo/lexical-scope-in-for-loop.rs +++ b/tests/debuginfo/lexical-scope-in-for-loop.rs @@ -4,76 +4,76 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // FIRST ITERATION -// gdb-command:print x -// gdb-check:$1 = 1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = 1 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$2 = -1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$2 = -1 +//@ gdb-command:continue // SECOND ITERATION -// gdb-command:print x -// gdb-check:$3 = 2 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = 2 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$4 = -2 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$4 = -2 +//@ gdb-command:continue // THIRD ITERATION -// gdb-command:print x -// gdb-check:$5 = 3 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = 3 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$6 = -3 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$6 = -3 +//@ gdb-command:continue // AFTER LOOP -// gdb-command:print x -// gdb-check:$7 = 1000000 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$7 = 1000000 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // FIRST ITERATION -// lldb-command:v x -// lldb-check:[...] 1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] -1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -1 +//@ lldb-command:continue // SECOND ITERATION -// lldb-command:v x -// lldb-check:[...] 2 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 2 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] -2 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -2 +//@ lldb-command:continue // THIRD ITERATION -// lldb-command:v x -// lldb-check:[...] 3 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 3 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] -3 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -3 +//@ lldb-command:continue // AFTER LOOP -// lldb-command:v x -// lldb-check:[...] 1000000 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1000000 +//@ lldb-command:continue fn main() { diff --git a/tests/debuginfo/lexical-scope-in-if-let.rs b/tests/debuginfo/lexical-scope-in-if-let.rs index 3bc0c231b4d3..0c16fbf751ff 100644 --- a/tests/debuginfo/lexical-scope-in-if-let.rs +++ b/tests/debuginfo/lexical-scope-in-if-let.rs @@ -3,78 +3,78 @@ // === GDB TESTS ================================================================================== -// gdb-command:run -// gdb-command:info locals -// gdb-check:a = 123 +//@ gdb-command:run +//@ gdb-command:info locals +//@ gdb-check:a = 123 -// gdb-command:continue -// gdb-command:info locals -// gdb-check:x = 42 -// gdb-check:a = 123 +//@ gdb-command:continue +//@ gdb-command:info locals +//@ gdb-check:x = 42 +//@ gdb-check:a = 123 -// gdb-command:continue -// gdb-command:info locals -// gdb-check:y = true -// gdb-check:b = 456 -// gdb-check:x = 42 -// gdb-check:a = 123 +//@ gdb-command:continue +//@ gdb-command:info locals +//@ gdb-check:y = true +//@ gdb-check:b = 456 +//@ gdb-check:x = 42 +//@ gdb-check:a = 123 -// gdb-command:continue -// gdb-command:info locals -// gdb-check:z = 10 -// gdb-check:c = 789 -// gdb-check:y = true -// gdb-check:b = 456 -// gdb-check:x = 42 -// gdb-check:a = 123 +//@ gdb-command:continue +//@ gdb-command:info locals +//@ gdb-check:z = 10 +//@ gdb-check:c = 789 +//@ gdb-check:y = true +//@ gdb-check:b = 456 +//@ gdb-check:x = 42 +//@ gdb-check:a = 123 // === LLDB TESTS ================================================================================= -// lldb-command:run -// lldb-command:frame variable -// lldb-check:(int) a = 123 +//@ lldb-command:run +//@ lldb-command:frame variable +//@ lldb-check:(int) a = 123 -// lldb-command:continue -// lldb-command:frame variable -// lldb-check:(int) a = 123 (int) x = 42 +//@ lldb-command:continue +//@ lldb-command:frame variable +//@ lldb-check:(int) a = 123 (int) x = 42 -// lldb-command:continue -// lldb-command:frame variable -// lldb-check:(int) a = 123 (int) x = 42 (int) b = 456 (bool) y = true +//@ lldb-command:continue +//@ lldb-command:frame variable +//@ lldb-check:(int) a = 123 (int) x = 42 (int) b = 456 (bool) y = true -// lldb-command:continue -// lldb-command:frame variable -// lldb-check:(int) a = 123 (int) x = 42 (int) b = 456 (bool) y = true (int) c = 789 (int) z = 10 +//@ lldb-command:continue +//@ lldb-command:frame variable +//@ lldb-check:(int) a = 123 (int) x = 42 (int) b = 456 (bool) y = true (int) c = 789 (int) z = 10 // === CDB TESTS ================================================================================== // Note: `/n` causes the the output to be sorted to avoid depending on the order in PDB which may // be arbitrary. -// cdb-command: g -// cdb-command: dv /n -// cdb-check:[...]a = 0n123 +//@ cdb-command: g +//@ cdb-command: dv /n +//@ cdb-check:[...]a = 0n123 -// cdb-command: g -// cdb-command: dv /n -// cdb-check:[...]a = 0n123 -// cdb-check:[...]x = 0n42 +//@ cdb-command: g +//@ cdb-command: dv /n +//@ cdb-check:[...]a = 0n123 +//@ cdb-check:[...]x = 0n42 -// cdb-command: g -// cdb-command: dv /n -// cdb-check:[...]a = 0n123 -// cdb-check:[...]b = 0n456 -// cdb-check:[...]x = 0n42 -// cdb-check:[...]y = true +//@ cdb-command: g +//@ cdb-command: dv /n +//@ cdb-check:[...]a = 0n123 +//@ cdb-check:[...]b = 0n456 +//@ cdb-check:[...]x = 0n42 +//@ cdb-check:[...]y = true -// cdb-command: g -// cdb-command: dv /n -// cdb-check:[...]a = 0n123 -// cdb-check:[...]b = 0n456 -// cdb-check:[...]c = 0n789 -// cdb-check:[...]x = 0n42 -// cdb-check:[...]y = true -// cdb-check:[...]z = 0n10 +//@ cdb-command: g +//@ cdb-command: dv /n +//@ cdb-check:[...]a = 0n123 +//@ cdb-check:[...]b = 0n456 +//@ cdb-check:[...]c = 0n789 +//@ cdb-check:[...]x = 0n42 +//@ cdb-check:[...]y = true +//@ cdb-check:[...]z = 0n10 fn main() { let a = id(123); diff --git a/tests/debuginfo/lexical-scope-in-if.rs b/tests/debuginfo/lexical-scope-in-if.rs index 622188269307..b52f22132164 100644 --- a/tests/debuginfo/lexical-scope-in-if.rs +++ b/tests/debuginfo/lexical-scope-in-if.rs @@ -4,124 +4,124 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // BEFORE if -// gdb-command:print x -// gdb-check:$1 = 999 -// gdb-command:print y -// gdb-check:$2 = -1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = 999 +//@ gdb-command:print y +//@ gdb-check:$2 = -1 +//@ gdb-command:continue // AT BEGINNING of 'then' block -// gdb-command:print x -// gdb-check:$3 = 999 -// gdb-command:print y -// gdb-check:$4 = -1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = 999 +//@ gdb-command:print y +//@ gdb-check:$4 = -1 +//@ gdb-command:continue // AFTER 1st redeclaration of 'x' -// gdb-command:print x -// gdb-check:$5 = 1001 -// gdb-command:print y -// gdb-check:$6 = -1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = 1001 +//@ gdb-command:print y +//@ gdb-check:$6 = -1 +//@ gdb-command:continue // AFTER 2st redeclaration of 'x' -// gdb-command:print x -// gdb-check:$7 = 1002 -// gdb-command:print y -// gdb-check:$8 = 1003 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$7 = 1002 +//@ gdb-command:print y +//@ gdb-check:$8 = 1003 +//@ gdb-command:continue // AFTER 1st if expression -// gdb-command:print x -// gdb-check:$9 = 999 -// gdb-command:print y -// gdb-check:$10 = -1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$9 = 999 +//@ gdb-command:print y +//@ gdb-check:$10 = -1 +//@ gdb-command:continue // BEGINNING of else branch -// gdb-command:print x -// gdb-check:$11 = 999 -// gdb-command:print y -// gdb-check:$12 = -1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$11 = 999 +//@ gdb-command:print y +//@ gdb-check:$12 = -1 +//@ gdb-command:continue // BEGINNING of else branch -// gdb-command:print x -// gdb-check:$13 = 1004 -// gdb-command:print y -// gdb-check:$14 = 1005 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$13 = 1004 +//@ gdb-command:print y +//@ gdb-check:$14 = 1005 +//@ gdb-command:continue // BEGINNING of else branch -// gdb-command:print x -// gdb-check:$15 = 999 -// gdb-command:print y -// gdb-check:$16 = -1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$15 = 999 +//@ gdb-command:print y +//@ gdb-check:$16 = -1 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // BEFORE if -// lldb-command:v x -// lldb-check:[...] 999 -// lldb-command:v y -// lldb-check:[...] -1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 999 +//@ lldb-command:v y +//@ lldb-check:[...] -1 +//@ lldb-command:continue // AT BEGINNING of 'then' block -// lldb-command:v x -// lldb-check:[...] 999 -// lldb-command:v y -// lldb-check:[...] -1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 999 +//@ lldb-command:v y +//@ lldb-check:[...] -1 +//@ lldb-command:continue // AFTER 1st redeclaration of 'x' -// lldb-command:v x -// lldb-check:[...] 1001 -// lldb-command:v y -// lldb-check:[...] -1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1001 +//@ lldb-command:v y +//@ lldb-check:[...] -1 +//@ lldb-command:continue // AFTER 2st redeclaration of 'x' -// lldb-command:v x -// lldb-check:[...] 1002 -// lldb-command:v y -// lldb-check:[...] 1003 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1002 +//@ lldb-command:v y +//@ lldb-check:[...] 1003 +//@ lldb-command:continue // AFTER 1st if expression -// lldb-command:v x -// lldb-check:[...] 999 -// lldb-command:v y -// lldb-check:[...] -1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 999 +//@ lldb-command:v y +//@ lldb-check:[...] -1 +//@ lldb-command:continue // BEGINNING of else branch -// lldb-command:v x -// lldb-check:[...] 999 -// lldb-command:v y -// lldb-check:[...] -1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 999 +//@ lldb-command:v y +//@ lldb-check:[...] -1 +//@ lldb-command:continue // BEGINNING of else branch -// lldb-command:v x -// lldb-check:[...] 1004 -// lldb-command:v y -// lldb-check:[...] 1005 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1004 +//@ lldb-command:v y +//@ lldb-check:[...] 1005 +//@ lldb-command:continue // BEGINNING of else branch -// lldb-command:v x -// lldb-check:[...] 999 -// lldb-command:v y -// lldb-check:[...] -1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 999 +//@ lldb-command:v y +//@ lldb-check:[...] -1 +//@ lldb-command:continue fn main() { diff --git a/tests/debuginfo/lexical-scope-in-match.rs b/tests/debuginfo/lexical-scope-in-match.rs index 329d959bc848..f91a623112e3 100644 --- a/tests/debuginfo/lexical-scope-in-match.rs +++ b/tests/debuginfo/lexical-scope-in-match.rs @@ -4,116 +4,116 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print shadowed -// gdb-check:$1 = 231 -// gdb-command:print not_shadowed -// gdb-check:$2 = 232 -// gdb-command:continue +//@ gdb-command:print shadowed +//@ gdb-check:$1 = 231 +//@ gdb-command:print not_shadowed +//@ gdb-check:$2 = 232 +//@ gdb-command:continue -// gdb-command:print shadowed -// gdb-check:$3 = 233 -// gdb-command:print not_shadowed -// gdb-check:$4 = 232 -// gdb-command:print local_to_arm -// gdb-check:$5 = 234 -// gdb-command:continue +//@ gdb-command:print shadowed +//@ gdb-check:$3 = 233 +//@ gdb-command:print not_shadowed +//@ gdb-check:$4 = 232 +//@ gdb-command:print local_to_arm +//@ gdb-check:$5 = 234 +//@ gdb-command:continue -// gdb-command:print shadowed -// gdb-check:$6 = 236 -// gdb-command:print not_shadowed -// gdb-check:$7 = 232 -// gdb-command:continue +//@ gdb-command:print shadowed +//@ gdb-check:$6 = 236 +//@ gdb-command:print not_shadowed +//@ gdb-check:$7 = 232 +//@ gdb-command:continue -// gdb-command:print shadowed -// gdb-check:$8 = 237 -// gdb-command:print not_shadowed -// gdb-check:$9 = 232 -// gdb-command:print local_to_arm -// gdb-check:$10 = 238 -// gdb-command:continue +//@ gdb-command:print shadowed +//@ gdb-check:$8 = 237 +//@ gdb-command:print not_shadowed +//@ gdb-check:$9 = 232 +//@ gdb-command:print local_to_arm +//@ gdb-check:$10 = 238 +//@ gdb-command:continue -// gdb-command:print shadowed -// gdb-check:$11 = 239 -// gdb-command:print not_shadowed -// gdb-check:$12 = 232 -// gdb-command:continue +//@ gdb-command:print shadowed +//@ gdb-check:$11 = 239 +//@ gdb-command:print not_shadowed +//@ gdb-check:$12 = 232 +//@ gdb-command:continue -// gdb-command:print shadowed -// gdb-check:$13 = 241 -// gdb-command:print not_shadowed -// gdb-check:$14 = 232 -// gdb-command:continue +//@ gdb-command:print shadowed +//@ gdb-check:$13 = 241 +//@ gdb-command:print not_shadowed +//@ gdb-check:$14 = 232 +//@ gdb-command:continue -// gdb-command:print shadowed -// gdb-check:$15 = 243 -// gdb-command:print *local_to_arm -// gdb-check:$16 = 244 -// gdb-command:continue +//@ gdb-command:print shadowed +//@ gdb-check:$15 = 243 +//@ gdb-command:print *local_to_arm +//@ gdb-check:$16 = 244 +//@ gdb-command:continue -// gdb-command:print shadowed -// gdb-check:$17 = 231 -// gdb-command:print not_shadowed -// gdb-check:$18 = 232 -// gdb-command:continue +//@ gdb-command:print shadowed +//@ gdb-check:$17 = 231 +//@ gdb-command:print not_shadowed +//@ gdb-check:$18 = 232 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v shadowed -// lldb-check:[...] 231 -// lldb-command:v not_shadowed -// lldb-check:[...] 232 -// lldb-command:continue +//@ lldb-command:v shadowed +//@ lldb-check:[...] 231 +//@ lldb-command:v not_shadowed +//@ lldb-check:[...] 232 +//@ lldb-command:continue -// lldb-command:v shadowed -// lldb-check:[...] 233 -// lldb-command:v not_shadowed -// lldb-check:[...] 232 -// lldb-command:v local_to_arm -// lldb-check:[...] 234 -// lldb-command:continue +//@ lldb-command:v shadowed +//@ lldb-check:[...] 233 +//@ lldb-command:v not_shadowed +//@ lldb-check:[...] 232 +//@ lldb-command:v local_to_arm +//@ lldb-check:[...] 234 +//@ lldb-command:continue -// lldb-command:v shadowed -// lldb-check:[...] 236 -// lldb-command:v not_shadowed -// lldb-check:[...] 232 -// lldb-command:continue +//@ lldb-command:v shadowed +//@ lldb-check:[...] 236 +//@ lldb-command:v not_shadowed +//@ lldb-check:[...] 232 +//@ lldb-command:continue -// lldb-command:v shadowed -// lldb-check:[...] 237 -// lldb-command:v not_shadowed -// lldb-check:[...] 232 -// lldb-command:v local_to_arm -// lldb-check:[...] 238 -// lldb-command:continue +//@ lldb-command:v shadowed +//@ lldb-check:[...] 237 +//@ lldb-command:v not_shadowed +//@ lldb-check:[...] 232 +//@ lldb-command:v local_to_arm +//@ lldb-check:[...] 238 +//@ lldb-command:continue -// lldb-command:v shadowed -// lldb-check:[...] 239 -// lldb-command:v not_shadowed -// lldb-check:[...] 232 -// lldb-command:continue +//@ lldb-command:v shadowed +//@ lldb-check:[...] 239 +//@ lldb-command:v not_shadowed +//@ lldb-check:[...] 232 +//@ lldb-command:continue -// lldb-command:v shadowed -// lldb-check:[...] 241 -// lldb-command:v not_shadowed -// lldb-check:[...] 232 -// lldb-command:continue +//@ lldb-command:v shadowed +//@ lldb-check:[...] 241 +//@ lldb-command:v not_shadowed +//@ lldb-check:[...] 232 +//@ lldb-command:continue -// lldb-command:v shadowed -// lldb-check:[...] 243 -// lldb-command:v *local_to_arm -// lldb-check:[...] 244 -// lldb-command:continue +//@ lldb-command:v shadowed +//@ lldb-check:[...] 243 +//@ lldb-command:v *local_to_arm +//@ lldb-check:[...] 244 +//@ lldb-command:continue -// lldb-command:v shadowed -// lldb-check:[...] 231 -// lldb-command:v not_shadowed -// lldb-check:[...] 232 -// lldb-command:continue +//@ lldb-command:v shadowed +//@ lldb-check:[...] 231 +//@ lldb-command:v not_shadowed +//@ lldb-check:[...] 232 +//@ lldb-command:continue struct Struct { x: isize, diff --git a/tests/debuginfo/lexical-scope-in-parameterless-closure.rs b/tests/debuginfo/lexical-scope-in-parameterless-closure.rs index dd6da95d388c..225f52f0bfd0 100644 --- a/tests/debuginfo/lexical-scope-in-parameterless-closure.rs +++ b/tests/debuginfo/lexical-scope-in-parameterless-closure.rs @@ -1,7 +1,7 @@ //@ compile-flags:-C debuginfo=1 -// gdb-command:run -// lldb-command:run +//@ gdb-command:run +//@ lldb-command:run // Nothing to do here really, just make sure it compiles. See issue #8513. fn main() { diff --git a/tests/debuginfo/lexical-scope-in-stack-closure.rs b/tests/debuginfo/lexical-scope-in-stack-closure.rs index b6abf507f26b..0bb01b397598 100644 --- a/tests/debuginfo/lexical-scope-in-stack-closure.rs +++ b/tests/debuginfo/lexical-scope-in-stack-closure.rs @@ -4,60 +4,60 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print x -// gdb-check:$1 = false -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = false +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$2 = false -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$2 = false +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$3 = 1000 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = 1000 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$4 = 2.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$4 = 2.5 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$5 = true -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = true +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$6 = false -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$6 = false +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 1000 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1000 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 2.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 2.5 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] true -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] true +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:continue fn main() { diff --git a/tests/debuginfo/lexical-scope-in-unconditional-loop.rs b/tests/debuginfo/lexical-scope-in-unconditional-loop.rs index 270fbcf6ebf5..0dd2136b474b 100644 --- a/tests/debuginfo/lexical-scope-in-unconditional-loop.rs +++ b/tests/debuginfo/lexical-scope-in-unconditional-loop.rs @@ -4,122 +4,122 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // FIRST ITERATION -// gdb-command:print x -// gdb-check:$1 = 0 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = 0 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$2 = 1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$2 = 1 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$3 = 101 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = 101 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$4 = 101 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$4 = 101 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$5 = -987 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = -987 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$6 = 101 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$6 = 101 +//@ gdb-command:continue // SECOND ITERATION -// gdb-command:print x -// gdb-check:$7 = 1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$7 = 1 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$8 = 2 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$8 = 2 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$9 = 102 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$9 = 102 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$10 = 102 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$10 = 102 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$11 = -987 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$11 = -987 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$12 = 102 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$12 = 102 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$13 = 2 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$13 = 2 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // FIRST ITERATION -// lldb-command:v x -// lldb-check:[...] 0 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 0 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 101 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 101 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 101 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 101 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] -987 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -987 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 101 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 101 +//@ lldb-command:continue // SECOND ITERATION -// lldb-command:v x -// lldb-check:[...] 1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 2 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 2 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 102 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 102 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 102 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 102 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] -987 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -987 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 102 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 102 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 2 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 2 +//@ lldb-command:continue fn main() { diff --git a/tests/debuginfo/lexical-scope-in-unique-closure.rs b/tests/debuginfo/lexical-scope-in-unique-closure.rs index b4909a97bea5..890de7fde794 100644 --- a/tests/debuginfo/lexical-scope-in-unique-closure.rs +++ b/tests/debuginfo/lexical-scope-in-unique-closure.rs @@ -4,60 +4,60 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print x -// gdb-check:$1 = false -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = false +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$2 = false -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$2 = false +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$3 = 1000 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = 1000 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$4 = 2.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$4 = 2.5 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$5 = true -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = true +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$6 = false -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$6 = false +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 1000 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1000 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 2.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 2.5 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] true -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] true +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:continue fn main() { diff --git a/tests/debuginfo/lexical-scope-in-while.rs b/tests/debuginfo/lexical-scope-in-while.rs index e8e66d2835cd..7bfbfe4c2156 100644 --- a/tests/debuginfo/lexical-scope-in-while.rs +++ b/tests/debuginfo/lexical-scope-in-while.rs @@ -4,122 +4,122 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // FIRST ITERATION -// gdb-command:print x -// gdb-check:$1 = 0 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = 0 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$2 = 1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$2 = 1 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$3 = 101 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = 101 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$4 = 101 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$4 = 101 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$5 = -987 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = -987 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$6 = 101 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$6 = 101 +//@ gdb-command:continue // SECOND ITERATION -// gdb-command:print x -// gdb-check:$7 = 1 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$7 = 1 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$8 = 2 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$8 = 2 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$9 = 102 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$9 = 102 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$10 = 102 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$10 = 102 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$11 = -987 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$11 = -987 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$12 = 102 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$12 = 102 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$13 = 2 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$13 = 2 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // FIRST ITERATION -// lldb-command:v x -// lldb-check:[...] 0 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 0 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 101 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 101 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 101 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 101 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] -987 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -987 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 101 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 101 +//@ lldb-command:continue // SECOND ITERATION -// lldb-command:v x -// lldb-check:[...] 1 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 1 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 2 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 2 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 102 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 102 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 102 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 102 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] -987 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] -987 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 102 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 102 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 2 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 2 +//@ lldb-command:continue fn main() { diff --git a/tests/debuginfo/lexical-scope-with-macro.rs b/tests/debuginfo/lexical-scope-with-macro.rs index 8c302a94ea2a..080eded4000b 100644 --- a/tests/debuginfo/lexical-scope-with-macro.rs +++ b/tests/debuginfo/lexical-scope-with-macro.rs @@ -4,100 +4,100 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print a -// gdb-check:$1 = 10 -// gdb-command:print b -// gdb-check:$2 = 34 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$1 = 10 +//@ gdb-command:print b +//@ gdb-check:$2 = 34 +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$3 = 890242 -// gdb-command:print b -// gdb-check:$4 = 34 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$3 = 890242 +//@ gdb-command:print b +//@ gdb-check:$4 = 34 +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$5 = 10 -// gdb-command:print b -// gdb-check:$6 = 34 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$5 = 10 +//@ gdb-command:print b +//@ gdb-check:$6 = 34 +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$7 = 102 -// gdb-command:print b -// gdb-check:$8 = 34 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$7 = 102 +//@ gdb-command:print b +//@ gdb-check:$8 = 34 +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$9 = 110 -// gdb-command:print b -// gdb-check:$10 = 34 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$9 = 110 +//@ gdb-command:print b +//@ gdb-check:$10 = 34 +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$11 = 10 -// gdb-command:print b -// gdb-check:$12 = 34 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$11 = 10 +//@ gdb-command:print b +//@ gdb-check:$12 = 34 +//@ gdb-command:continue -// gdb-command:print a -// gdb-check:$13 = 10 -// gdb-command:print b -// gdb-check:$14 = 34 -// gdb-command:print c -// gdb-check:$15 = 400 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$13 = 10 +//@ gdb-command:print b +//@ gdb-check:$14 = 34 +//@ gdb-command:print c +//@ gdb-check:$15 = 400 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v a -// lldb-check:[...] 10 -// lldb-command:v b -// lldb-check:[...] 34 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 10 +//@ lldb-command:v b +//@ lldb-check:[...] 34 +//@ lldb-command:continue -// lldb-command:v a -// lldb-check:[...] 890242 -// lldb-command:v b -// lldb-check:[...] 34 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 890242 +//@ lldb-command:v b +//@ lldb-check:[...] 34 +//@ lldb-command:continue -// lldb-command:v a -// lldb-check:[...] 10 -// lldb-command:v b -// lldb-check:[...] 34 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 10 +//@ lldb-command:v b +//@ lldb-check:[...] 34 +//@ lldb-command:continue -// lldb-command:v a -// lldb-check:[...] 102 -// lldb-command:v b -// lldb-check:[...] 34 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 102 +//@ lldb-command:v b +//@ lldb-check:[...] 34 +//@ lldb-command:continue -// lldb-command:print a -// lldb-check:[...] 110 -// lldb-command:print b -// lldb-check:[...] 34 -// lldb-command:continue +//@ lldb-command:print a +//@ lldb-check:[...] 110 +//@ lldb-command:print b +//@ lldb-check:[...] 34 +//@ lldb-command:continue -// lldb-command:print a -// lldb-check:[...] 10 -// lldb-command:print b -// lldb-check:[...] 34 -// lldb-command:continue +//@ lldb-command:print a +//@ lldb-check:[...] 10 +//@ lldb-command:print b +//@ lldb-check:[...] 34 +//@ lldb-command:continue -// lldb-command:print a -// lldb-check:[...] 10 -// lldb-command:print b -// lldb-check:[...] 34 -// lldb-command:print c -// lldb-check:[...] 400 -// lldb-command:continue +//@ lldb-command:print a +//@ lldb-check:[...] 10 +//@ lldb-command:print b +//@ lldb-check:[...] 34 +//@ lldb-command:print c +//@ lldb-check:[...] 400 +//@ lldb-command:continue macro_rules! trivial { ($e1:expr) => ($e1) diff --git a/tests/debuginfo/lexical-scopes-in-block-expression.rs b/tests/debuginfo/lexical-scopes-in-block-expression.rs index 9a7fba30397e..36705eb19232 100644 --- a/tests/debuginfo/lexical-scopes-in-block-expression.rs +++ b/tests/debuginfo/lexical-scopes-in-block-expression.rs @@ -4,337 +4,337 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print lexical_scopes_in_block_expression::MUT_INT -// gdb-check:$1 = 0 +//@ gdb-command:print lexical_scopes_in_block_expression::MUT_INT +//@ gdb-check:$1 = 0 // STRUCT EXPRESSION -// gdb-command:print val -// gdb-check:$2 = -1 -// gdb-command:print ten -// gdb-check:$3 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$2 = -1 +//@ gdb-command:print ten +//@ gdb-check:$3 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$4 = 11 -// gdb-command:print lexical_scopes_in_block_expression::MUT_INT -// gdb-check:$5 = 1 -// gdb-command:print ten -// gdb-check:$6 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$4 = 11 +//@ gdb-command:print lexical_scopes_in_block_expression::MUT_INT +//@ gdb-check:$5 = 1 +//@ gdb-command:print ten +//@ gdb-check:$6 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$7 = -1 -// gdb-command:print ten -// gdb-check:$8 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$7 = -1 +//@ gdb-command:print ten +//@ gdb-check:$8 = 10 +//@ gdb-command:continue // FUNCTION CALL -// gdb-command:print val -// gdb-check:$9 = -1 -// gdb-command:print ten -// gdb-check:$10 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$9 = -1 +//@ gdb-command:print ten +//@ gdb-check:$10 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$11 = 12 -// gdb-command:print lexical_scopes_in_block_expression::MUT_INT -// gdb-check:$12 = 2 -// gdb-command:print ten -// gdb-check:$13 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$11 = 12 +//@ gdb-command:print lexical_scopes_in_block_expression::MUT_INT +//@ gdb-check:$12 = 2 +//@ gdb-command:print ten +//@ gdb-check:$13 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$14 = -1 -// gdb-command:print ten -// gdb-check:$15 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$14 = -1 +//@ gdb-command:print ten +//@ gdb-check:$15 = 10 +//@ gdb-command:continue // TUPLE EXPRESSION -// gdb-command:print val -// gdb-check:$16 = -1 -// gdb-command:print ten -// gdb-check:$17 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$16 = -1 +//@ gdb-command:print ten +//@ gdb-check:$17 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$18 = 13 -// gdb-command:print lexical_scopes_in_block_expression::MUT_INT -// gdb-check:$19 = 3 -// gdb-command:print ten -// gdb-check:$20 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$18 = 13 +//@ gdb-command:print lexical_scopes_in_block_expression::MUT_INT +//@ gdb-check:$19 = 3 +//@ gdb-command:print ten +//@ gdb-check:$20 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$21 = -1 -// gdb-command:print ten -// gdb-check:$22 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$21 = -1 +//@ gdb-command:print ten +//@ gdb-check:$22 = 10 +//@ gdb-command:continue // VEC EXPRESSION -// gdb-command:print val -// gdb-check:$23 = -1 -// gdb-command:print ten -// gdb-check:$24 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$23 = -1 +//@ gdb-command:print ten +//@ gdb-check:$24 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$25 = 14 -// gdb-command:print lexical_scopes_in_block_expression::MUT_INT -// gdb-check:$26 = 4 -// gdb-command:print ten -// gdb-check:$27 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$25 = 14 +//@ gdb-command:print lexical_scopes_in_block_expression::MUT_INT +//@ gdb-check:$26 = 4 +//@ gdb-command:print ten +//@ gdb-check:$27 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$28 = -1 -// gdb-command:print ten -// gdb-check:$29 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$28 = -1 +//@ gdb-command:print ten +//@ gdb-check:$29 = 10 +//@ gdb-command:continue // REPEAT VEC EXPRESSION -// gdb-command:print val -// gdb-check:$30 = -1 -// gdb-command:print ten -// gdb-check:$31 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$30 = -1 +//@ gdb-command:print ten +//@ gdb-check:$31 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$32 = 15 -// gdb-command:print lexical_scopes_in_block_expression::MUT_INT -// gdb-check:$33 = 5 -// gdb-command:print ten -// gdb-check:$34 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$32 = 15 +//@ gdb-command:print lexical_scopes_in_block_expression::MUT_INT +//@ gdb-check:$33 = 5 +//@ gdb-command:print ten +//@ gdb-check:$34 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$35 = -1 -// gdb-command:print ten -// gdb-check:$36 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$35 = -1 +//@ gdb-command:print ten +//@ gdb-check:$36 = 10 +//@ gdb-command:continue // ASSIGNMENT EXPRESSION -// gdb-command:print val -// gdb-check:$37 = -1 -// gdb-command:print ten -// gdb-check:$38 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$37 = -1 +//@ gdb-command:print ten +//@ gdb-check:$38 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$39 = 16 -// gdb-command:print lexical_scopes_in_block_expression::MUT_INT -// gdb-check:$40 = 6 -// gdb-command:print ten -// gdb-check:$41 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$39 = 16 +//@ gdb-command:print lexical_scopes_in_block_expression::MUT_INT +//@ gdb-check:$40 = 6 +//@ gdb-command:print ten +//@ gdb-check:$41 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$42 = -1 -// gdb-command:print ten -// gdb-check:$43 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$42 = -1 +//@ gdb-command:print ten +//@ gdb-check:$43 = 10 +//@ gdb-command:continue // ARITHMETIC EXPRESSION -// gdb-command:print val -// gdb-check:$44 = -1 -// gdb-command:print ten -// gdb-check:$45 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$44 = -1 +//@ gdb-command:print ten +//@ gdb-check:$45 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$46 = 17 -// gdb-command:print lexical_scopes_in_block_expression::MUT_INT -// gdb-check:$47 = 7 -// gdb-command:print ten -// gdb-check:$48 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$46 = 17 +//@ gdb-command:print lexical_scopes_in_block_expression::MUT_INT +//@ gdb-check:$47 = 7 +//@ gdb-command:print ten +//@ gdb-check:$48 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$49 = -1 -// gdb-command:print ten -// gdb-check:$50 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$49 = -1 +//@ gdb-command:print ten +//@ gdb-check:$50 = 10 +//@ gdb-command:continue // INDEX EXPRESSION -// gdb-command:print val -// gdb-check:$51 = -1 -// gdb-command:print ten -// gdb-check:$52 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$51 = -1 +//@ gdb-command:print ten +//@ gdb-check:$52 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$53 = 18 -// gdb-command:print lexical_scopes_in_block_expression::MUT_INT -// gdb-check:$54 = 8 -// gdb-command:print ten -// gdb-check:$55 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$53 = 18 +//@ gdb-command:print lexical_scopes_in_block_expression::MUT_INT +//@ gdb-check:$54 = 8 +//@ gdb-command:print ten +//@ gdb-check:$55 = 10 +//@ gdb-command:continue -// gdb-command:print val -// gdb-check:$56 = -1 -// gdb-command:print ten -// gdb-check:$57 = 10 -// gdb-command:continue +//@ gdb-command:print val +//@ gdb-check:$56 = -1 +//@ gdb-command:print ten +//@ gdb-check:$57 = 10 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // STRUCT EXPRESSION -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] 11 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] 11 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue // FUNCTION CALL -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] 12 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] 12 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue // TUPLE EXPRESSION -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] 13 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] 13 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue // VEC EXPRESSION -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] 14 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] 14 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue // REPEAT VEC EXPRESSION -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] 15 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] 15 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue // ASSIGNMENT EXPRESSION -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] 16 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] 16 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue // ARITHMETIC EXPRESSION -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] 17 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] 17 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue // INDEX EXPRESSION -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] 18 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] 18 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v val -// lldb-check:[...] -1 -// lldb-command:v ten -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v val +//@ lldb-check:[...] -1 +//@ lldb-command:v ten +//@ lldb-check:[...] 10 +//@ lldb-command:continue #![allow(unused_variables)] #![allow(unused_assignments)] diff --git a/tests/debuginfo/limited-debuginfo.rs b/tests/debuginfo/limited-debuginfo.rs index 136953641a4d..d44e07882727 100644 --- a/tests/debuginfo/limited-debuginfo.rs +++ b/tests/debuginfo/limited-debuginfo.rs @@ -5,18 +5,18 @@ //@ ignore-backends: gcc // Make sure functions have proper names -// gdb-command:info functions -// gdb-check:fn limited_debuginfo::main(); -// gdb-check:fn limited_debuginfo::some_function(); -// gdb-check:fn limited_debuginfo::some_other_function(); -// gdb-check:fn limited_debuginfo::zzz(); +//@ gdb-command:info functions +//@ gdb-check:fn limited_debuginfo::main(); +//@ gdb-check:fn limited_debuginfo::some_function(); +//@ gdb-check:fn limited_debuginfo::some_other_function(); +//@ gdb-check:fn limited_debuginfo::zzz(); -// gdb-command:run +//@ gdb-command:run // Make sure there is no information about locals -// gdb-command:info locals -// gdb-check:No locals. -// gdb-command:continue +//@ gdb-command:info locals +//@ gdb-check:No locals. +//@ gdb-command:continue #![allow(unused_variables)] diff --git a/tests/debuginfo/macro-stepping.rs b/tests/debuginfo/macro-stepping.rs index e58975764e53..bdeadf8a5c05 100644 --- a/tests/debuginfo/macro-stepping.rs +++ b/tests/debuginfo/macro-stepping.rs @@ -14,77 +14,77 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc2[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc4[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc5[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc6[...] +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc2[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc4[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc5[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc6[...] -// gdb-command:continue -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#inc-loc1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#inc-loc2[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#inc-loc3[...] +//@ gdb-command:continue +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#inc-loc1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#inc-loc2[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#inc-loc3[...] // === LLDB TESTS ================================================================================== -// lldb-command:set set stop-line-count-before 0 -// lldb-command:set set stop-line-count-after 1 +//@ lldb-command:set set stop-line-count-before 0 +//@ lldb-command:set set stop-line-count-after 1 // Can't set both to zero or lldb will stop printing source at all. So it will output the current // line and the next. We deal with this by having at least 2 lines between the #loc's -// lldb-command:run -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc1 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc2 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc3 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc4 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #loc5 [...] +//@ lldb-command:run +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc1 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc2 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc3 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc4 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #loc5 [...] -// lldb-command:continue -// lldb-command:step -// lldb-command:frame select -// lldb-check:[...] #inc-loc1 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #inc-loc2 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #inc-loc1 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #inc-loc2 [...] -// lldb-command:next -// lldb-command:frame select -// lldb-check:[...] #inc-loc3 [...] +//@ lldb-command:continue +//@ lldb-command:step +//@ lldb-command:frame select +//@ lldb-check:[...] #inc-loc1 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #inc-loc2 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #inc-loc1 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #inc-loc2 [...] +//@ lldb-command:next +//@ lldb-command:frame select +//@ lldb-check:[...] #inc-loc3 [...] #[collapse_debuginfo(yes)] macro_rules! foo { diff --git a/tests/debuginfo/marker-types.rs b/tests/debuginfo/marker-types.rs index 6686b057ef7b..3c9cba608178 100644 --- a/tests/debuginfo/marker-types.rs +++ b/tests/debuginfo/marker-types.rs @@ -3,29 +3,29 @@ // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx nonnull -// cdb-check:nonnull : NonNull(0x[...]: 0xc) [Type: core::ptr::non_null::NonNull] -// cdb-check: [] [Type: core::ptr::non_null::NonNull] -// cdb-check: 0xc [Type: unsigned int] +//@ cdb-command: dx nonnull +//@ cdb-check:nonnull : NonNull(0x[...]: 0xc) [Type: core::ptr::non_null::NonNull] +//@ cdb-check: [] [Type: core::ptr::non_null::NonNull] +//@ cdb-check: 0xc [Type: unsigned int] -// cdb-command: dx manuallydrop -// cdb-check:manuallydrop : 12345 [Type: core::mem::manually_drop::ManuallyDrop] -// cdb-check: [] [Type: core::mem::manually_drop::ManuallyDrop] +//@ cdb-command: dx manuallydrop +//@ cdb-check:manuallydrop : 12345 [Type: core::mem::manually_drop::ManuallyDrop] +//@ cdb-check: [] [Type: core::mem::manually_drop::ManuallyDrop] -// cdb-command: dx pin -// cdb-check:pin : Pin(0x[...]: "this") [Type: core::pin::Pin >] -// cdb-check: [] [Type: core::pin::Pin >] -// cdb-check: [len] : 0x4 [Type: unsigned [...]] -// cdb-check: [capacity] : 0x4 [Type: unsigned [...]] -// cdb-check: [chars] : "this" +//@ cdb-command: dx pin +//@ cdb-check:pin : Pin(0x[...]: "this") [Type: core::pin::Pin >] +//@ cdb-check: [] [Type: core::pin::Pin >] +//@ cdb-check: [len] : 0x4 [Type: unsigned [...]] +//@ cdb-check: [capacity] : 0x4 [Type: unsigned [...]] +//@ cdb-check: [chars] : "this" -// cdb-command: dx unique -// cdb-check:unique : Unique(0x[...]: (0x2a, 4321)) [Type: core::ptr::unique::Unique >] -// cdb-check: [] [Type: core::ptr::unique::Unique >] -// cdb-check: [0] : 0x2a [Type: unsigned __int64] -// cdb-check: [1] : 4321 [Type: int] +//@ cdb-command: dx unique +//@ cdb-check:unique : Unique(0x[...]: (0x2a, 4321)) [Type: core::ptr::unique::Unique >] +//@ cdb-check: [] [Type: core::ptr::unique::Unique >] +//@ cdb-check: [0] : 0x2a [Type: unsigned __int64] +//@ cdb-check: [1] : 4321 [Type: int] #![feature(ptr_internals)] diff --git a/tests/debuginfo/method-on-enum.rs b/tests/debuginfo/method-on-enum.rs index f86cf8ccfdf7..c7955a7e875a 100644 --- a/tests/debuginfo/method-on-enum.rs +++ b/tests/debuginfo/method-on-enum.rs @@ -8,102 +8,102 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // STACK BY REF -// gdb-command:print *self -// gdb-check:$1 = method_on_enum::Enum::Variant2(117901063) -// gdb-command:print arg1 -// gdb-check:$2 = -1 -// gdb-command:print arg2 -// gdb-check:$3 = -2 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$1 = method_on_enum::Enum::Variant2(117901063) +//@ gdb-command:print arg1 +//@ gdb-check:$2 = -1 +//@ gdb-command:print arg2 +//@ gdb-check:$3 = -2 +//@ gdb-command:continue // STACK BY VAL -// gdb-command:print self -// gdb-check:$4 = method_on_enum::Enum::Variant2(117901063) -// gdb-command:print arg1 -// gdb-check:$5 = -3 -// gdb-command:print arg2 -// gdb-check:$6 = -4 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$4 = method_on_enum::Enum::Variant2(117901063) +//@ gdb-command:print arg1 +//@ gdb-check:$5 = -3 +//@ gdb-command:print arg2 +//@ gdb-check:$6 = -4 +//@ gdb-command:continue // OWNED BY REF -// gdb-command:print *self -// gdb-check:$7 = method_on_enum::Enum::Variant1{x: 1799, y: 1799} -// gdb-command:print arg1 -// gdb-check:$8 = -5 -// gdb-command:print arg2 -// gdb-check:$9 = -6 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$7 = method_on_enum::Enum::Variant1{x: 1799, y: 1799} +//@ gdb-command:print arg1 +//@ gdb-check:$8 = -5 +//@ gdb-command:print arg2 +//@ gdb-check:$9 = -6 +//@ gdb-command:continue // OWNED BY VAL -// gdb-command:print self -// gdb-check:$10 = method_on_enum::Enum::Variant1{x: 1799, y: 1799} -// gdb-command:print arg1 -// gdb-check:$11 = -7 -// gdb-command:print arg2 -// gdb-check:$12 = -8 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$10 = method_on_enum::Enum::Variant1{x: 1799, y: 1799} +//@ gdb-command:print arg1 +//@ gdb-check:$11 = -7 +//@ gdb-command:print arg2 +//@ gdb-check:$12 = -8 +//@ gdb-command:continue // OWNED MOVED -// gdb-command:print *self -// gdb-check:$13 = method_on_enum::Enum::Variant1{x: 1799, y: 1799} -// gdb-command:print arg1 -// gdb-check:$14 = -9 -// gdb-command:print arg2 -// gdb-check:$15 = -10 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$13 = method_on_enum::Enum::Variant1{x: 1799, y: 1799} +//@ gdb-command:print arg1 +//@ gdb-check:$14 = -9 +//@ gdb-command:print arg2 +//@ gdb-check:$15 = -10 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // STACK BY REF -// lldb-command:v *self -// lldb-check:[...] Variant2(117901063) -// lldb-command:v arg1 -// lldb-check:[...] -1 -// lldb-command:v arg2 -// lldb-check:[...] -2 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] Variant2(117901063) +//@ lldb-command:v arg1 +//@ lldb-check:[...] -1 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -2 +//@ lldb-command:continue // STACK BY VAL -// lldb-command:v self -// lldb-check:[...] Variant2(117901063) -// lldb-command:v arg1 -// lldb-check:[...] -3 -// lldb-command:v arg2 -// lldb-check:[...] -4 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] Variant2(117901063) +//@ lldb-command:v arg1 +//@ lldb-check:[...] -3 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -4 +//@ lldb-command:continue // OWNED BY REF -// lldb-command:v *self -// lldb-check:[...] Variant1 { x: 1799, y: 1799 } -// lldb-command:v arg1 -// lldb-check:[...] -5 -// lldb-command:v arg2 -// lldb-check:[...] -6 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] Variant1 { x: 1799, y: 1799 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -5 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -6 +//@ lldb-command:continue // OWNED BY VAL -// lldb-command:v self -// lldb-check:[...] Variant1 { x: 1799, y: 1799 } -// lldb-command:v arg1 -// lldb-check:[...] -7 -// lldb-command:v arg2 -// lldb-check:[...] -8 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] Variant1 { x: 1799, y: 1799 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -7 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -8 +//@ lldb-command:continue // OWNED MOVED -// lldb-command:v *self -// lldb-check:[...] Variant1 { x: 1799, y: 1799 } -// lldb-command:v arg1 -// lldb-check:[...] -9 -// lldb-command:v arg2 -// lldb-check:[...] -10 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] Variant1 { x: 1799, y: 1799 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -9 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -10 +//@ lldb-command:continue #[derive(Copy, Clone)] enum Enum { diff --git a/tests/debuginfo/method-on-generic-struct.rs b/tests/debuginfo/method-on-generic-struct.rs index 01e7ffc749da..e050d3074f44 100644 --- a/tests/debuginfo/method-on-generic-struct.rs +++ b/tests/debuginfo/method-on-generic-struct.rs @@ -4,102 +4,102 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // STACK BY REF -// gdb-command:print *self -// gdb-check:$1 = method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)} -// gdb-command:print arg1 -// gdb-check:$2 = -1 -// gdb-command:print arg2 -// gdb-check:$3 = -2 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$1 = method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)} +//@ gdb-command:print arg1 +//@ gdb-check:$2 = -1 +//@ gdb-command:print arg2 +//@ gdb-check:$3 = -2 +//@ gdb-command:continue // STACK BY VAL -// gdb-command:print self -// gdb-check:$4 = method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)} -// gdb-command:print arg1 -// gdb-check:$5 = -3 -// gdb-command:print arg2 -// gdb-check:$6 = -4 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$4 = method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)} +//@ gdb-command:print arg1 +//@ gdb-check:$5 = -3 +//@ gdb-command:print arg2 +//@ gdb-check:$6 = -4 +//@ gdb-command:continue // OWNED BY REF -// gdb-command:print *self -// gdb-check:$7 = method_on_generic_struct::Struct {x: 1234.5} -// gdb-command:print arg1 -// gdb-check:$8 = -5 -// gdb-command:print arg2 -// gdb-check:$9 = -6 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$7 = method_on_generic_struct::Struct {x: 1234.5} +//@ gdb-command:print arg1 +//@ gdb-check:$8 = -5 +//@ gdb-command:print arg2 +//@ gdb-check:$9 = -6 +//@ gdb-command:continue // OWNED BY VAL -// gdb-command:print self -// gdb-check:$10 = method_on_generic_struct::Struct {x: 1234.5} -// gdb-command:print arg1 -// gdb-check:$11 = -7 -// gdb-command:print arg2 -// gdb-check:$12 = -8 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$10 = method_on_generic_struct::Struct {x: 1234.5} +//@ gdb-command:print arg1 +//@ gdb-check:$11 = -7 +//@ gdb-command:print arg2 +//@ gdb-check:$12 = -8 +//@ gdb-command:continue // OWNED MOVED -// gdb-command:print *self -// gdb-check:$13 = method_on_generic_struct::Struct {x: 1234.5} -// gdb-command:print arg1 -// gdb-check:$14 = -9 -// gdb-command:print arg2 -// gdb-check:$15 = -10 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$13 = method_on_generic_struct::Struct {x: 1234.5} +//@ gdb-command:print arg1 +//@ gdb-check:$14 = -9 +//@ gdb-command:print arg2 +//@ gdb-check:$15 = -10 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // STACK BY REF -// lldb-command:v *self -// lldb-check:[...]Struct<(u32, i32)>) *self = { x = (8888, -8888) { 0 = 8888 1 = -8888 } } -// lldb-command:v arg1 -// lldb-check:[...] -1 -// lldb-command:v arg2 -// lldb-check:[...] -2 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...]Struct<(u32, i32)>) *self = { x = (8888, -8888) { 0 = 8888 1 = -8888 } } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -1 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -2 +//@ lldb-command:continue // STACK BY VAL -// lldb-command:v self -// lldb-check:[...]Struct<(u32, i32)>) self = { x = (8888, -8888) { 0 = 8888 1 = -8888 } } -// lldb-command:v arg1 -// lldb-check:[...] -3 -// lldb-command:v arg2 -// lldb-check:[...] -4 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...]Struct<(u32, i32)>) self = { x = (8888, -8888) { 0 = 8888 1 = -8888 } } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -3 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -4 +//@ lldb-command:continue // OWNED BY REF -// lldb-command:v *self -// lldb-check:[...]Struct) *self = { x = 1234.5 } -// lldb-command:v arg1 -// lldb-check:[...] -5 -// lldb-command:v arg2 -// lldb-check:[...] -6 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...]Struct) *self = { x = 1234.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -5 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -6 +//@ lldb-command:continue // OWNED BY VAL -// lldb-command:v self -// lldb-check:[...]Struct) self = { x = 1234.5 } -// lldb-command:v arg1 -// lldb-check:[...] -7 -// lldb-command:v arg2 -// lldb-check:[...] -8 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...]Struct) self = { x = 1234.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -7 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -8 +//@ lldb-command:continue // OWNED MOVED -// lldb-command:v *self -// lldb-check:[...]Struct) *self = { x = 1234.5 } -// lldb-command:v arg1 -// lldb-check:[...] -9 -// lldb-command:v arg2 -// lldb-check:[...] -10 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...]Struct) *self = { x = 1234.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -9 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -10 +//@ lldb-command:continue #[derive(Copy, Clone)] struct Struct { diff --git a/tests/debuginfo/method-on-struct.rs b/tests/debuginfo/method-on-struct.rs index 4ccb55d3704b..5a4c275e7041 100644 --- a/tests/debuginfo/method-on-struct.rs +++ b/tests/debuginfo/method-on-struct.rs @@ -4,102 +4,102 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // STACK BY REF -// gdb-command:print *self -// gdb-check:$1 = method_on_struct::Struct {x: 100} -// gdb-command:print arg1 -// gdb-check:$2 = -1 -// gdb-command:print arg2 -// gdb-check:$3 = -2 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$1 = method_on_struct::Struct {x: 100} +//@ gdb-command:print arg1 +//@ gdb-check:$2 = -1 +//@ gdb-command:print arg2 +//@ gdb-check:$3 = -2 +//@ gdb-command:continue // STACK BY VAL -// gdb-command:print self -// gdb-check:$4 = method_on_struct::Struct {x: 100} -// gdb-command:print arg1 -// gdb-check:$5 = -3 -// gdb-command:print arg2 -// gdb-check:$6 = -4 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$4 = method_on_struct::Struct {x: 100} +//@ gdb-command:print arg1 +//@ gdb-check:$5 = -3 +//@ gdb-command:print arg2 +//@ gdb-check:$6 = -4 +//@ gdb-command:continue // OWNED BY REF -// gdb-command:print *self -// gdb-check:$7 = method_on_struct::Struct {x: 200} -// gdb-command:print arg1 -// gdb-check:$8 = -5 -// gdb-command:print arg2 -// gdb-check:$9 = -6 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$7 = method_on_struct::Struct {x: 200} +//@ gdb-command:print arg1 +//@ gdb-check:$8 = -5 +//@ gdb-command:print arg2 +//@ gdb-check:$9 = -6 +//@ gdb-command:continue // OWNED BY VAL -// gdb-command:print self -// gdb-check:$10 = method_on_struct::Struct {x: 200} -// gdb-command:print arg1 -// gdb-check:$11 = -7 -// gdb-command:print arg2 -// gdb-check:$12 = -8 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$10 = method_on_struct::Struct {x: 200} +//@ gdb-command:print arg1 +//@ gdb-check:$11 = -7 +//@ gdb-command:print arg2 +//@ gdb-check:$12 = -8 +//@ gdb-command:continue // OWNED MOVED -// gdb-command:print *self -// gdb-check:$13 = method_on_struct::Struct {x: 200} -// gdb-command:print arg1 -// gdb-check:$14 = -9 -// gdb-command:print arg2 -// gdb-check:$15 = -10 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$13 = method_on_struct::Struct {x: 200} +//@ gdb-command:print arg1 +//@ gdb-check:$14 = -9 +//@ gdb-command:print arg2 +//@ gdb-check:$15 = -10 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // STACK BY REF -// lldb-command:v *self -// lldb-check:[...] { x = 100 } -// lldb-command:v arg1 -// lldb-check:[...] -1 -// lldb-command:v arg2 -// lldb-check:[...] -2 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 100 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -1 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -2 +//@ lldb-command:continue // STACK BY VAL -// lldb-command:v self -// lldb-check:[...] { x = 100 } -// lldb-command:v arg1 -// lldb-check:[...] -3 -// lldb-command:v arg2 -// lldb-check:[...] -4 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = 100 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -3 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -4 +//@ lldb-command:continue // OWNED BY REF -// lldb-command:v *self -// lldb-check:[...] { x = 200 } -// lldb-command:v arg1 -// lldb-check:[...] -5 -// lldb-command:v arg2 -// lldb-check:[...] -6 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 200 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -5 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -6 +//@ lldb-command:continue // OWNED BY VAL -// lldb-command:v self -// lldb-check:[...] { x = 200 } -// lldb-command:v arg1 -// lldb-check:[...] -7 -// lldb-command:v arg2 -// lldb-check:[...] -8 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = 200 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -7 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -8 +//@ lldb-command:continue // OWNED MOVED -// lldb-command:v *self -// lldb-check:[...] { x = 200 } -// lldb-command:v arg1 -// lldb-check:[...] -9 -// lldb-command:v arg2 -// lldb-check:[...] -10 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 200 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -9 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -10 +//@ lldb-command:continue #[derive(Copy, Clone)] struct Struct { diff --git a/tests/debuginfo/method-on-trait.rs b/tests/debuginfo/method-on-trait.rs index baf1a8567bbf..673d25a72845 100644 --- a/tests/debuginfo/method-on-trait.rs +++ b/tests/debuginfo/method-on-trait.rs @@ -4,102 +4,102 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // STACK BY REF -// gdb-command:print *self -// gdb-check:$1 = method_on_trait::Struct {x: 100} -// gdb-command:print arg1 -// gdb-check:$2 = -1 -// gdb-command:print arg2 -// gdb-check:$3 = -2 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$1 = method_on_trait::Struct {x: 100} +//@ gdb-command:print arg1 +//@ gdb-check:$2 = -1 +//@ gdb-command:print arg2 +//@ gdb-check:$3 = -2 +//@ gdb-command:continue // STACK BY VAL -// gdb-command:print self -// gdb-check:$4 = method_on_trait::Struct {x: 100} -// gdb-command:print arg1 -// gdb-check:$5 = -3 -// gdb-command:print arg2 -// gdb-check:$6 = -4 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$4 = method_on_trait::Struct {x: 100} +//@ gdb-command:print arg1 +//@ gdb-check:$5 = -3 +//@ gdb-command:print arg2 +//@ gdb-check:$6 = -4 +//@ gdb-command:continue // OWNED BY REF -// gdb-command:print *self -// gdb-check:$7 = method_on_trait::Struct {x: 200} -// gdb-command:print arg1 -// gdb-check:$8 = -5 -// gdb-command:print arg2 -// gdb-check:$9 = -6 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$7 = method_on_trait::Struct {x: 200} +//@ gdb-command:print arg1 +//@ gdb-check:$8 = -5 +//@ gdb-command:print arg2 +//@ gdb-check:$9 = -6 +//@ gdb-command:continue // OWNED BY VAL -// gdb-command:print self -// gdb-check:$10 = method_on_trait::Struct {x: 200} -// gdb-command:print arg1 -// gdb-check:$11 = -7 -// gdb-command:print arg2 -// gdb-check:$12 = -8 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$10 = method_on_trait::Struct {x: 200} +//@ gdb-command:print arg1 +//@ gdb-check:$11 = -7 +//@ gdb-command:print arg2 +//@ gdb-check:$12 = -8 +//@ gdb-command:continue // OWNED MOVED -// gdb-command:print *self -// gdb-check:$13 = method_on_trait::Struct {x: 200} -// gdb-command:print arg1 -// gdb-check:$14 = -9 -// gdb-command:print arg2 -// gdb-check:$15 = -10 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$13 = method_on_trait::Struct {x: 200} +//@ gdb-command:print arg1 +//@ gdb-check:$14 = -9 +//@ gdb-command:print arg2 +//@ gdb-check:$15 = -10 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // STACK BY REF -// lldb-command:v *self -// lldb-check:[...] { x = 100 } -// lldb-command:v arg1 -// lldb-check:[...] -1 -// lldb-command:v arg2 -// lldb-check:[...] -2 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 100 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -1 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -2 +//@ lldb-command:continue // STACK BY VAL -// lldb-command:v self -// lldb-check:[...] { x = 100 } -// lldb-command:v arg1 -// lldb-check:[...] -3 -// lldb-command:v arg2 -// lldb-check:[...] -4 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = 100 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -3 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -4 +//@ lldb-command:continue // OWNED BY REF -// lldb-command:v *self -// lldb-check:[...] { x = 200 } -// lldb-command:v arg1 -// lldb-check:[...] -5 -// lldb-command:v arg2 -// lldb-check:[...] -6 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 200 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -5 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -6 +//@ lldb-command:continue // OWNED BY VAL -// lldb-command:v self -// lldb-check:[...] { x = 200 } -// lldb-command:v arg1 -// lldb-check:[...] -7 -// lldb-command:v arg2 -// lldb-check:[...] -8 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = 200 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -7 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -8 +//@ lldb-command:continue // OWNED MOVED -// lldb-command:v *self -// lldb-check:[...] { x = 200 } -// lldb-command:v arg1 -// lldb-check:[...] -9 -// lldb-command:v arg2 -// lldb-check:[...] -10 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 200 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -9 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -10 +//@ lldb-command:continue #[derive(Copy, Clone)] struct Struct { diff --git a/tests/debuginfo/method-on-tuple-struct.rs b/tests/debuginfo/method-on-tuple-struct.rs index 077c0bc13d90..03c00d668741 100644 --- a/tests/debuginfo/method-on-tuple-struct.rs +++ b/tests/debuginfo/method-on-tuple-struct.rs @@ -4,102 +4,102 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // STACK BY REF -// gdb-command:print *self -// gdb-check:$1 = method_on_tuple_struct::TupleStruct (100, -100.5) -// gdb-command:print arg1 -// gdb-check:$2 = -1 -// gdb-command:print arg2 -// gdb-check:$3 = -2 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$1 = method_on_tuple_struct::TupleStruct (100, -100.5) +//@ gdb-command:print arg1 +//@ gdb-check:$2 = -1 +//@ gdb-command:print arg2 +//@ gdb-check:$3 = -2 +//@ gdb-command:continue // STACK BY VAL -// gdb-command:print self -// gdb-check:$4 = method_on_tuple_struct::TupleStruct (100, -100.5) -// gdb-command:print arg1 -// gdb-check:$5 = -3 -// gdb-command:print arg2 -// gdb-check:$6 = -4 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$4 = method_on_tuple_struct::TupleStruct (100, -100.5) +//@ gdb-command:print arg1 +//@ gdb-check:$5 = -3 +//@ gdb-command:print arg2 +//@ gdb-check:$6 = -4 +//@ gdb-command:continue // OWNED BY REF -// gdb-command:print *self -// gdb-check:$7 = method_on_tuple_struct::TupleStruct (200, -200.5) -// gdb-command:print arg1 -// gdb-check:$8 = -5 -// gdb-command:print arg2 -// gdb-check:$9 = -6 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$7 = method_on_tuple_struct::TupleStruct (200, -200.5) +//@ gdb-command:print arg1 +//@ gdb-check:$8 = -5 +//@ gdb-command:print arg2 +//@ gdb-check:$9 = -6 +//@ gdb-command:continue // OWNED BY VAL -// gdb-command:print self -// gdb-check:$10 = method_on_tuple_struct::TupleStruct (200, -200.5) -// gdb-command:print arg1 -// gdb-check:$11 = -7 -// gdb-command:print arg2 -// gdb-check:$12 = -8 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$10 = method_on_tuple_struct::TupleStruct (200, -200.5) +//@ gdb-command:print arg1 +//@ gdb-check:$11 = -7 +//@ gdb-command:print arg2 +//@ gdb-check:$12 = -8 +//@ gdb-command:continue // OWNED MOVED -// gdb-command:print *self -// gdb-check:$13 = method_on_tuple_struct::TupleStruct (200, -200.5) -// gdb-command:print arg1 -// gdb-check:$14 = -9 -// gdb-command:print arg2 -// gdb-check:$15 = -10 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$13 = method_on_tuple_struct::TupleStruct (200, -200.5) +//@ gdb-command:print arg1 +//@ gdb-check:$14 = -9 +//@ gdb-command:print arg2 +//@ gdb-check:$15 = -10 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // STACK BY REF -// lldb-command:v *self -// lldb-check:[...] { 0 = 100 1 = -100.5 } -// lldb-command:v arg1 -// lldb-check:[...] -1 -// lldb-command:v arg2 -// lldb-check:[...] -2 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { 0 = 100 1 = -100.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -1 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -2 +//@ lldb-command:continue // STACK BY VAL -// lldb-command:v self -// lldb-check:[...] { 0 = 100 1 = -100.5 } -// lldb-command:v arg1 -// lldb-check:[...] -3 -// lldb-command:v arg2 -// lldb-check:[...] -4 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { 0 = 100 1 = -100.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -3 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -4 +//@ lldb-command:continue // OWNED BY REF -// lldb-command:v *self -// lldb-check:[...] { 0 = 200 1 = -200.5 } -// lldb-command:v arg1 -// lldb-check:[...] -5 -// lldb-command:v arg2 -// lldb-check:[...] -6 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { 0 = 200 1 = -200.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -5 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -6 +//@ lldb-command:continue // OWNED BY VAL -// lldb-command:v self -// lldb-check:[...] { 0 = 200 1 = -200.5 } -// lldb-command:v arg1 -// lldb-check:[...] -7 -// lldb-command:v arg2 -// lldb-check:[...] -8 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { 0 = 200 1 = -200.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -7 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -8 +//@ lldb-command:continue // OWNED MOVED -// lldb-command:v *self -// lldb-check:[...] { 0 = 200 1 = -200.5 } -// lldb-command:v arg1 -// lldb-check:[...] -9 -// lldb-command:v arg2 -// lldb-check:[...] -10 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { 0 = 200 1 = -200.5 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -9 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -10 +//@ lldb-command:continue #[derive(Copy, Clone)] struct TupleStruct(isize, f64); diff --git a/tests/debuginfo/msvc-pretty-enums.rs b/tests/debuginfo/msvc-pretty-enums.rs index 7d9f867efcdd..efe5b066b52c 100644 --- a/tests/debuginfo/msvc-pretty-enums.rs +++ b/tests/debuginfo/msvc-pretty-enums.rs @@ -4,233 +4,233 @@ //@ compile-flags:-g // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v a -// lldb-check:(core::option::Option) a = { value = { 0 = Low } } +//@ lldb-command:v a +//@ lldb-check:(core::option::Option) a = { value = { 0 = Low } } -// lldb-command:v b -// lldb-check:(core::option::Option) b = { value = $discr$ = '\x01' } +//@ lldb-command:v b +//@ lldb-check:(core::option::Option) b = { value = $discr$ = '\x01' } -// lldb-command:v c -// lldb-check:(msvc_pretty_enums::NicheLayoutEnum) c = { value = $discr$ = '\x11' } +//@ lldb-command:v c +//@ lldb-check:(msvc_pretty_enums::NicheLayoutEnum) c = { value = $discr$ = '\x11' } -// lldb-command:v d -// lldb-check:(msvc_pretty_enums::NicheLayoutEnum) d = { value = { my_data = High } } +//@ lldb-command:v d +//@ lldb-check:(msvc_pretty_enums::NicheLayoutEnum) d = { value = { my_data = High } } -// lldb-command:v e -// lldb-check:(msvc_pretty_enums::NicheLayoutEnum) e = { value = $discr$ = '\x13' } +//@ lldb-command:v e +//@ lldb-check:(msvc_pretty_enums::NicheLayoutEnum) e = { value = $discr$ = '\x13' } -// lldb-command:v h -// lldb-check:(core::option::Option) h = { value = { 0 = 12 } $discr$ = 1 } +//@ lldb-command:v h +//@ lldb-check:(core::option::Option) h = { value = { 0 = 12 } $discr$ = 1 } -// lldb-command:v i -// lldb-check:(core::option::Option) i = { value = $discr$ = 0 } +//@ lldb-command:v i +//@ lldb-check:(core::option::Option) i = { value = $discr$ = 0 } -// lldb-command:v j -// lldb-check:(msvc_pretty_enums::CStyleEnum) j = High +//@ lldb-command:v j +//@ lldb-check:(msvc_pretty_enums::CStyleEnum) j = High -// lldb-command:v k -// lldb-check:(core::option::Option) k = { value = { 0 = "IAMA optional string!" { [0] = 'I' [1] = 'A' [2] = 'M' [3] = 'A' [4] = ' ' [5] = 'o' [6] = 'p' [7] = 't' [8] = 'i' [9] = 'o' [10] = 'n' [11] = 'a' [12] = 'l' [13] = ' ' [14] = 's' [15] = 't' [16] = 'r' [17] = 'i' [18] = 'n' [19] = 'g' [20] = '!' } } } +//@ lldb-command:v k +//@ lldb-check:(core::option::Option) k = { value = { 0 = "IAMA optional string!" { [0] = 'I' [1] = 'A' [2] = 'M' [3] = 'A' [4] = ' ' [5] = 'o' [6] = 'p' [7] = 't' [8] = 'i' [9] = 'o' [10] = 'n' [11] = 'a' [12] = 'l' [13] = ' ' [14] = 's' [15] = 't' [16] = 'r' [17] = 'i' [18] = 'n' [19] = 'g' [20] = '!' } } } -// lldb-command:v l -// lldb-check:(core::result::Result) l = { value = { 0 = {} } } +//@ lldb-command:v l +//@ lldb-check:(core::result::Result) l = { value = { 0 = {} } } -// lldb-command:v niche128_some -// lldb-check:(core::option::Option>) niche128_some = { value = $discr$ = 123456 } +//@ lldb-command:v niche128_some +//@ lldb-check:(core::option::Option>) niche128_some = { value = $discr$ = 123456 } -// lldb-command:v niche128_none -// lldb-check:(core::option::Option>) niche128_none = { value = $discr$ = 0 } +//@ lldb-command:v niche128_none +//@ lldb-check:(core::option::Option>) niche128_none = { value = $discr$ = 0 } -// lldb-command:v wrapping_niche128_untagged -// lldb-check:(msvc_pretty_enums::Wrapping128Niche) wrapping_niche128_untagged = { value = { 0 = { 0 = 340282366920938463463374607431768211454 } } } +//@ lldb-command:v wrapping_niche128_untagged +//@ lldb-check:(msvc_pretty_enums::Wrapping128Niche) wrapping_niche128_untagged = { value = { 0 = { 0 = 340282366920938463463374607431768211454 } } } -// lldb-command:v wrapping_niche128_none1 -// lldb-check:(msvc_pretty_enums::Wrapping128Niche) wrapping_niche128_none1 = { value = { 0 = { 0 = 2 } } } +//@ lldb-command:v wrapping_niche128_none1 +//@ lldb-check:(msvc_pretty_enums::Wrapping128Niche) wrapping_niche128_none1 = { value = { 0 = { 0 = 2 } } } -// lldb-command:v direct_tag_128_a -// lldb-check:(msvc_pretty_enums::DirectTag128) direct_tag_128_a = { value = { 0 = 42 } $discr$ = 0 } +//@ lldb-command:v direct_tag_128_a +//@ lldb-check:(msvc_pretty_enums::DirectTag128) direct_tag_128_a = { value = { 0 = 42 } $discr$ = 0 } -// lldb-command:v direct_tag_128_b -// lldb-check:(msvc_pretty_enums::DirectTag128) direct_tag_128_b = { value = { 0 = 137 } $discr$ = 1 } +//@ lldb-command:v direct_tag_128_b +//@ lldb-check:(msvc_pretty_enums::DirectTag128) direct_tag_128_b = { value = { 0 = 137 } $discr$ = 1 } // &u32 is incorrectly formatted and LLDB thinks it's a char* so skipping niche_w_fields_1_some -// lldb-command:v niche_w_fields_1_none -// lldb-check:(msvc_pretty_enums::NicheLayoutWithFields1) niche_w_fields_1_none = { value = { 0 = 99 } $discr$ = 1 } +//@ lldb-command:v niche_w_fields_1_none +//@ lldb-check:(msvc_pretty_enums::NicheLayoutWithFields1) niche_w_fields_1_none = { value = { 0 = 99 } $discr$ = 1 } -// lldb-command:v niche_w_fields_2_some -// lldb-check:(msvc_pretty_enums::NicheLayoutWithFields2) niche_w_fields_2_some = { value = { 0 = 800 { __0 = { 0 = 800 } } 1 = 900 } $discr$ = 0 } +//@ lldb-command:v niche_w_fields_2_some +//@ lldb-check:(msvc_pretty_enums::NicheLayoutWithFields2) niche_w_fields_2_some = { value = { 0 = 800 { __0 = { 0 = 800 } } 1 = 900 } $discr$ = 0 } -// lldb-command:v niche_w_fields_3_some -// lldb-check:(msvc_pretty_enums::NicheLayoutWithFields3) niche_w_fields_3_some = { value = { 0 = '\x89' 1 = true } } +//@ lldb-command:v niche_w_fields_3_some +//@ lldb-check:(msvc_pretty_enums::NicheLayoutWithFields3) niche_w_fields_3_some = { value = { 0 = '\x89' 1 = true } } -// lldb-command:v niche_w_fields_3_niche3 -// lldb-check:(msvc_pretty_enums::NicheLayoutWithFields3) niche_w_fields_3_niche3 = { value = { 0 = '"' } $discr$ = '\x04' } +//@ lldb-command:v niche_w_fields_3_niche3 +//@ lldb-check:(msvc_pretty_enums::NicheLayoutWithFields3) niche_w_fields_3_niche3 = { value = { 0 = '"' } $discr$ = '\x04' } -// lldb-command:v arbitrary_discr1 -// lldb-check:(msvc_pretty_enums::ArbitraryDiscr) arbitrary_discr1 = { value = { 0 = 1234 } $discr$ = 1000 } +//@ lldb-command:v arbitrary_discr1 +//@ lldb-check:(msvc_pretty_enums::ArbitraryDiscr) arbitrary_discr1 = { value = { 0 = 1234 } $discr$ = 1000 } -// lldb-command:v arbitrary_discr2 -// lldb-check:(msvc_pretty_enums::ArbitraryDiscr) arbitrary_discr2 = { value = { 0 = 5678 } $discr$ = 5000000 } +//@ lldb-command:v arbitrary_discr2 +//@ lldb-check:(msvc_pretty_enums::ArbitraryDiscr) arbitrary_discr2 = { value = { 0 = 5678 } $discr$ = 5000000 } // === CDB TESTS ================================================================================== -// cdb-command: g -// -// cdb-command: dx a -// cdb-check:a : Some [Type: enum2$ >] -// cdb-check: [+0x000] __0 : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum] -// -// cdb-command: dx b -// cdb-check:b : None [Type: enum2$ >] -// -// cdb-command: dx c -// cdb-check:c : Tag1 [Type: enum2$] -// -// cdb-command: dx d -// cdb-check:d : Data [Type: enum2$] -// cdb-check: [+0x000] my_data : High (0x10) [Type: msvc_pretty_enums::CStyleEnum] -// -// cdb-command: dx e -// cdb-check:e : Tag2 [Type: enum2$] -// -// cdb-command: dx f -// cdb-check:f : Some [Type: enum2$ > >] -// cdb-check: [+0x000] __0 : 0x[...] : 0x1 [Type: unsigned int *] -// -// cdb-command: dx g -// cdb-check:g : None [Type: enum2$ > >] -// -// cdb-command: dx h -// cdb-check:h : Some [Type: enum2$ >] -// cdb-check: [+0x004] __0 : 0xc [Type: unsigned int] -// -// cdb-command: dx i -// cdb-check:i : None [Type: enum2$ >] -// -// cdb-command: dx j -// cdb-check:j : High (0x10) [Type: msvc_pretty_enums::CStyleEnum] -// -// cdb-command: dx k -// cdb-check:k : Some [Type: enum2$ >] -// cdb-check: [+0x000] __0 : "IAMA optional string!" [Type: alloc::string::String] -// -// cdb-command: dx l -// cdb-check:l : Ok [Type: enum2$ > >] -// cdb-check: [+0x000] __0 : 0x2a [Type: unsigned int] -// -// cdb-command: dx niche128_some -// cdb-check: niche128_some : Some [Type: enum2$ > >] +//@ cdb-command: g + +//@ cdb-command: dx a +//@ cdb-check:a : Some [Type: enum2$ >] +//@ cdb-check: [+0x000] __0 : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum] + +//@ cdb-command: dx b +//@ cdb-check:b : None [Type: enum2$ >] + +//@ cdb-command: dx c +//@ cdb-check:c : Tag1 [Type: enum2$] + +//@ cdb-command: dx d +//@ cdb-check:d : Data [Type: enum2$] +//@ cdb-check: [+0x000] my_data : High (0x10) [Type: msvc_pretty_enums::CStyleEnum] + +//@ cdb-command: dx e +//@ cdb-check:e : Tag2 [Type: enum2$] + +//@ cdb-command: dx f +//@ cdb-check:f : Some [Type: enum2$ > >] +//@ cdb-check: [+0x000] __0 : 0x[...] : 0x1 [Type: unsigned int *] + +//@ cdb-command: dx g +//@ cdb-check:g : None [Type: enum2$ > >] + +//@ cdb-command: dx h +//@ cdb-check:h : Some [Type: enum2$ >] +//@ cdb-check: [+0x004] __0 : 0xc [Type: unsigned int] + +//@ cdb-command: dx i +//@ cdb-check:i : None [Type: enum2$ >] + +//@ cdb-command: dx j +//@ cdb-check:j : High (0x10) [Type: msvc_pretty_enums::CStyleEnum] + +//@ cdb-command: dx k +//@ cdb-check:k : Some [Type: enum2$ >] +//@ cdb-check: [+0x000] __0 : "IAMA optional string!" [Type: alloc::string::String] + +//@ cdb-command: dx l +//@ cdb-check:l : Ok [Type: enum2$ > >] +//@ cdb-check: [+0x000] __0 : 0x2a [Type: unsigned int] + +//@ cdb-command: dx niche128_some +//@ cdb-check: niche128_some : Some [Type: enum2$ > >] // Note: we can't actually read the value of the field because CDB cannot handle 128 bit integers. -// cdb-check: [+0x000] __0 [...] [Type: core::num::nonzero::NonZero] -// -// cdb-command: dx niche128_none -// cdb-check: niche128_none : None [Type: enum2$ > >] -// -// cdb-command: dx wrapping_niche128_untagged -// cdb-check: wrapping_niche128_untagged : X [Type: enum2$] -// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] -// -// cdb-command: dx wrapping_niche128_none1 -// cdb-check: wrapping_niche128_none1 : Y [Type: enum2$] -// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] -// -// cdb-command: dx wrapping_niche128_none2 -// cdb-check: wrapping_niche128_none2 : Z [Type: enum2$] -// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] -// -// cdb-command: dx direct_tag_128_a,d -// cdb-check: direct_tag_128_a,d : A [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 42 [Type: unsigned int] -// -// cdb-command: dx direct_tag_128_b,d -// cdb-check: direct_tag_128_b,d : B [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 137 [Type: unsigned int] -// -// cdb-command: dx niche_w_fields_1_some,d -// cdb-check: niche_w_fields_1_some,d : A [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 0x[...] : 77 [Type: unsigned char *] -// cdb-check: [+0x[...]] __1 : 7 [Type: unsigned int] -// -// cdb-command: dx niche_w_fields_1_none,d -// cdb-check: niche_w_fields_1_none,d : B [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 99 [Type: unsigned int] -// -// cdb-command: dx niche_w_fields_2_some,d -// cdb-check: niche_w_fields_2_some,d : A [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 800 [Type: core::num::nonzero::NonZero] -// cdb-check: [+0x[...]] __1 : 900 [Type: unsigned __int64] -// -// cdb-command: dx niche_w_fields_2_none,d -// cdb-check: niche_w_fields_2_none,d : B [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 1000 [Type: unsigned __int64] -// -// cdb-command: dx niche_w_fields_3_some,d -// cdb-check: niche_w_fields_3_some,d : A [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 137 [Type: unsigned char] -// cdb-check: [+0x[...]] __1 : true [Type: bool] -// -// cdb-command: dx niche_w_fields_3_niche1,d -// cdb-check: niche_w_fields_3_niche1,d : B [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 12 [Type: unsigned char] -// -// cdb-command: dx niche_w_fields_3_niche2,d -// cdb-check: niche_w_fields_3_niche2,d : C [Type: enum2$] -// cdb-check: [+0x[...]] __0 : false [Type: bool] -// -// cdb-command: dx niche_w_fields_3_niche3,d -// cdb-check: niche_w_fields_3_niche3,d : D [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 34 [Type: unsigned char] -// -// cdb-command: dx niche_w_fields_3_niche4,d -// cdb-check: niche_w_fields_3_niche4,d : E [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 56 [Type: unsigned char] -// -// cdb-command: dx niche_w_fields_3_niche5,d -// cdb-check: niche_w_fields_3_niche5,d : F [Type: enum2$] -// -// cdb-command: dx -r3 niche_w_fields_std_result_ok,d -// cdb-check: niche_w_fields_std_result_ok,d : Ok [Type: enum2$,alloc::alloc::Global>,u64> >] -// cdb-check: [+0x[...]] __0 [Type: alloc::boxed::Box,alloc::alloc::Global>] -// cdb-check: [+0x[...]] data_ptr : [...] -// cdb-check: [+0x[...]] length : 3 [...] -// -// cdb-command: dx -r3 niche_w_fields_std_result_err,d -// cdb-check: niche_w_fields_std_result_err,d : Err [Type: enum2$,alloc::alloc::Global>,u64> >] -// cdb-check: [+0x[...]] __0 : 789 [Type: unsigned __int64] -// -// cdb-command: dx -r2 arbitrary_discr1,d -// cdb-check: arbitrary_discr1,d : Abc [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 1234 [Type: unsigned int] -// -// cdb-command: dx -r2 arbitrary_discr2,d -// cdb-check: arbitrary_discr2,d : Def [Type: enum2$] -// cdb-check: [+0x[...]] __0 : 5678 [Type: unsigned int] -// -// cdb-command: dx c_style_u128_a -// cdb-check: c_style_u128_a : A [Type: enum2$] -// -// cdb-command: dx c_style_u128_b -// cdb-check: c_style_u128_b : B [Type: enum2$] -// -// cdb-command: dx c_style_u128_c -// cdb-check: c_style_u128_c : C [Type: enum2$] -// -// cdb-command: dx c_style_u128_d -// cdb-check: c_style_u128_d : D [Type: enum2$] -// -// cdb-command: dx c_style_i128_a -// cdb-check: c_style_i128_a : A [Type: enum2$] -// -// cdb-command: dx c_style_i128_b -// cdb-check: c_style_i128_b : B [Type: enum2$] -// -// cdb-command: dx c_style_i128_c -// cdb-check: c_style_i128_c : C [Type: enum2$] -// -// cdb-command: dx c_style_i128_d -// cdb-check: c_style_i128_d : D [Type: enum2$] +//@ cdb-check: [+0x000] __0 [...] [Type: core::num::nonzero::NonZero] + +//@ cdb-command: dx niche128_none +//@ cdb-check: niche128_none : None [Type: enum2$ > >] + +//@ cdb-command: dx wrapping_niche128_untagged +//@ cdb-check: wrapping_niche128_untagged : X [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] + +//@ cdb-command: dx wrapping_niche128_none1 +//@ cdb-check: wrapping_niche128_none1 : Y [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] + +//@ cdb-command: dx wrapping_niche128_none2 +//@ cdb-check: wrapping_niche128_none2 : Z [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] + +//@ cdb-command: dx direct_tag_128_a,d +//@ cdb-check: direct_tag_128_a,d : A [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 42 [Type: unsigned int] + +//@ cdb-command: dx direct_tag_128_b,d +//@ cdb-check: direct_tag_128_b,d : B [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 137 [Type: unsigned int] + +//@ cdb-command: dx niche_w_fields_1_some,d +//@ cdb-check: niche_w_fields_1_some,d : A [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 0x[...] : 77 [Type: unsigned char *] +//@ cdb-check: [+0x[...]] __1 : 7 [Type: unsigned int] + +//@ cdb-command: dx niche_w_fields_1_none,d +//@ cdb-check: niche_w_fields_1_none,d : B [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 99 [Type: unsigned int] + +//@ cdb-command: dx niche_w_fields_2_some,d +//@ cdb-check: niche_w_fields_2_some,d : A [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 800 [Type: core::num::nonzero::NonZero] +//@ cdb-check: [+0x[...]] __1 : 900 [Type: unsigned __int64] + +//@ cdb-command: dx niche_w_fields_2_none,d +//@ cdb-check: niche_w_fields_2_none,d : B [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 1000 [Type: unsigned __int64] + +//@ cdb-command: dx niche_w_fields_3_some,d +//@ cdb-check: niche_w_fields_3_some,d : A [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 137 [Type: unsigned char] +//@ cdb-check: [+0x[...]] __1 : true [Type: bool] + +//@ cdb-command: dx niche_w_fields_3_niche1,d +//@ cdb-check: niche_w_fields_3_niche1,d : B [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 12 [Type: unsigned char] + +//@ cdb-command: dx niche_w_fields_3_niche2,d +//@ cdb-check: niche_w_fields_3_niche2,d : C [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : false [Type: bool] + +//@ cdb-command: dx niche_w_fields_3_niche3,d +//@ cdb-check: niche_w_fields_3_niche3,d : D [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 34 [Type: unsigned char] + +//@ cdb-command: dx niche_w_fields_3_niche4,d +//@ cdb-check: niche_w_fields_3_niche4,d : E [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 56 [Type: unsigned char] + +//@ cdb-command: dx niche_w_fields_3_niche5,d +//@ cdb-check: niche_w_fields_3_niche5,d : F [Type: enum2$] + +//@ cdb-command: dx -r3 niche_w_fields_std_result_ok,d +//@ cdb-check: niche_w_fields_std_result_ok,d : Ok [Type: enum2$,alloc::alloc::Global>,u64> >] +//@ cdb-check: [+0x[...]] __0 [Type: alloc::boxed::Box,alloc::alloc::Global>] +//@ cdb-check: [+0x[...]] data_ptr : [...] +//@ cdb-check: [+0x[...]] length : 3 [...] + +//@ cdb-command: dx -r3 niche_w_fields_std_result_err,d +//@ cdb-check: niche_w_fields_std_result_err,d : Err [Type: enum2$,alloc::alloc::Global>,u64> >] +//@ cdb-check: [+0x[...]] __0 : 789 [Type: unsigned __int64] + +//@ cdb-command: dx -r2 arbitrary_discr1,d +//@ cdb-check: arbitrary_discr1,d : Abc [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 1234 [Type: unsigned int] + +//@ cdb-command: dx -r2 arbitrary_discr2,d +//@ cdb-check: arbitrary_discr2,d : Def [Type: enum2$] +//@ cdb-check: [+0x[...]] __0 : 5678 [Type: unsigned int] + +//@ cdb-command: dx c_style_u128_a +//@ cdb-check: c_style_u128_a : A [Type: enum2$] + +//@ cdb-command: dx c_style_u128_b +//@ cdb-check: c_style_u128_b : B [Type: enum2$] + +//@ cdb-command: dx c_style_u128_c +//@ cdb-check: c_style_u128_c : C [Type: enum2$] + +//@ cdb-command: dx c_style_u128_d +//@ cdb-check: c_style_u128_d : D [Type: enum2$] + +//@ cdb-command: dx c_style_i128_a +//@ cdb-check: c_style_i128_a : A [Type: enum2$] + +//@ cdb-command: dx c_style_i128_b +//@ cdb-check: c_style_i128_b : B [Type: enum2$] + +//@ cdb-command: dx c_style_i128_c +//@ cdb-check: c_style_i128_c : C [Type: enum2$] + +//@ cdb-command: dx c_style_i128_d +//@ cdb-check: c_style_i128_d : D [Type: enum2$] #![feature(rustc_attrs)] use std::num::NonZero; diff --git a/tests/debuginfo/msvc-scalarpair-params.rs b/tests/debuginfo/msvc-scalarpair-params.rs index 436a5e07035e..857852cbcf29 100644 --- a/tests/debuginfo/msvc-scalarpair-params.rs +++ b/tests/debuginfo/msvc-scalarpair-params.rs @@ -1,57 +1,57 @@ //@ only-cdb //@ compile-flags: -g -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx r1 -// cdb-check:r1 : (0xa..0xc) [Type: core::ops::range::Range] -// cdb-command: dx r2 -// cdb-check:r2 : (0x14..0x1e) [Type: core::ops::range::Range] +//@ cdb-command: dx r1 +//@ cdb-check:r1 : (0xa..0xc) [Type: core::ops::range::Range] +//@ cdb-command: dx r2 +//@ cdb-check:r2 : (0x14..0x1e) [Type: core::ops::range::Range] -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx r1 -// cdb-check:r1 : (0x9..0x64) [Type: core::ops::range::Range] -// cdb-command: dx r2 -// cdb-check:r2 : (0xc..0x5a) [Type: core::ops::range::Range] +//@ cdb-command: dx r1 +//@ cdb-check:r1 : (0x9..0x64) [Type: core::ops::range::Range] +//@ cdb-command: dx r2 +//@ cdb-check:r2 : (0xc..0x5a) [Type: core::ops::range::Range] -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx o1 -// cdb-check:o1 : Some [Type: enum2$ >] -// cdb-check: [+0x004] __0 : 0x4d2 [Type: [...]] -// cdb-command: dx o2 -// cdb-check:o2 : Some [Type: enum2$ >] -// cdb-check: [+0x008] __0 : 0x162e [Type: unsigned __int64] +//@ cdb-command: dx o1 +//@ cdb-check:o1 : Some [Type: enum2$ >] +//@ cdb-check: [+0x004] __0 : 0x4d2 [Type: [...]] +//@ cdb-command: dx o2 +//@ cdb-check:o2 : Some [Type: enum2$ >] +//@ cdb-check: [+0x008] __0 : 0x162e [Type: unsigned __int64] -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx t1 -// cdb-check:t1 : (0xa, 0x14) [Type: tuple$] -// cdb-check: [0] : 0xa [Type: unsigned int] -// cdb-check: [1] : 0x14 [Type: unsigned int] -// cdb-command: dx t2 -// cdb-check:t2 : (0x1e, 0x28) [Type: tuple$] -// cdb-check: [0] : 0x1e [Type: unsigned __int64] -// cdb-check: [1] : 0x28 [Type: unsigned __int64] +//@ cdb-command: dx t1 +//@ cdb-check:t1 : (0xa, 0x14) [Type: tuple$] +//@ cdb-check: [0] : 0xa [Type: unsigned int] +//@ cdb-check: [1] : 0x14 [Type: unsigned int] +//@ cdb-command: dx t2 +//@ cdb-check:t2 : (0x1e, 0x28) [Type: tuple$] +//@ cdb-check: [0] : 0x1e [Type: unsigned __int64] +//@ cdb-check: [1] : 0x28 [Type: unsigned __int64] -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx s -// cdb-check:s : "this is a static str" [Type: ref$] -// cdb-check: [len] : 0x14 [Type: unsigned [...]] -// cdb-check: [chars] +//@ cdb-command: dx s +//@ cdb-check:s : "this is a static str" [Type: ref$] +//@ cdb-check: [len] : 0x14 [Type: unsigned [...]] +//@ cdb-check: [chars] -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx s -// cdb-check:s : { len=0x5 } [Type: ref$ >] -// cdb-check: [len] : 0x5 [Type: unsigned [...]] -// cdb-check: [0] : 0x1 [Type: unsigned char] -// cdb-check: [1] : 0x2 [Type: unsigned char] -// cdb-check: [2] : 0x3 [Type: unsigned char] -// cdb-check: [3] : 0x4 [Type: unsigned char] -// cdb-check: [4] : 0x5 [Type: unsigned char] +//@ cdb-command: dx s +//@ cdb-check:s : { len=0x5 } [Type: ref$ >] +//@ cdb-check: [len] : 0x5 [Type: unsigned [...]] +//@ cdb-check: [0] : 0x1 [Type: unsigned char] +//@ cdb-check: [1] : 0x2 [Type: unsigned char] +//@ cdb-check: [2] : 0x3 [Type: unsigned char] +//@ cdb-check: [3] : 0x4 [Type: unsigned char] +//@ cdb-check: [4] : 0x5 [Type: unsigned char] use std::ops::Range; diff --git a/tests/debuginfo/multi-cgu.rs b/tests/debuginfo/multi-cgu.rs index e3fa68d77659..35a64928585f 100644 --- a/tests/debuginfo/multi-cgu.rs +++ b/tests/debuginfo/multi-cgu.rs @@ -7,28 +7,28 @@ // === GDB TESTS =============================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print xxx -// gdb-check:$1 = 12345 -// gdb-command:continue +//@ gdb-command:print xxx +//@ gdb-check:$1 = 12345 +//@ gdb-command:continue -// gdb-command:print yyy -// gdb-check:$2 = 67890 -// gdb-command:continue +//@ gdb-command:print yyy +//@ gdb-check:$2 = 67890 +//@ gdb-command:continue // === LLDB TESTS ============================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v xxx -// lldb-check:[...] 12345 -// lldb-command:continue +//@ lldb-command:v xxx +//@ lldb-check:[...] 12345 +//@ lldb-command:continue -// lldb-command:v yyy -// lldb-check:[...] 67890 -// lldb-command:continue +//@ lldb-command:v yyy +//@ lldb-check:[...] 67890 +//@ lldb-command:continue mod a { diff --git a/tests/debuginfo/multiline-calls.rs b/tests/debuginfo/multiline-calls.rs index 724ad29729fd..04b7bd558082 100644 --- a/tests/debuginfo/multiline-calls.rs +++ b/tests/debuginfo/multiline-calls.rs @@ -3,17 +3,17 @@ // === GDB TESTS =================================================================================== -// gdb-command: run -// gdb-check:[...]#break[...] -// gdb-command: up -// gdb-check:[...]zzz[...] +//@ gdb-command: run +//@ gdb-check:[...]#break[...] +//@ gdb-command: up +//@ gdb-check:[...]zzz[...] // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-check:[...]#break[...] -// lldb-command: up -// lldb-check:[...]zzz[...] +//@ lldb-command:run +//@ lldb-check:[...]#break[...] +//@ lldb-command: up +//@ lldb-check:[...]zzz[...] struct Foo; diff --git a/tests/debuginfo/multiple-functions-equal-var-names.rs b/tests/debuginfo/multiple-functions-equal-var-names.rs index 9df1fe1b9ca1..143f0013744c 100644 --- a/tests/debuginfo/multiple-functions-equal-var-names.rs +++ b/tests/debuginfo/multiple-functions-equal-var-names.rs @@ -4,34 +4,34 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print abc -// gdb-check:$1 = 10101 -// gdb-command:continue +//@ gdb-command:print abc +//@ gdb-check:$1 = 10101 +//@ gdb-command:continue -// gdb-command:print abc -// gdb-check:$2 = 20202 -// gdb-command:continue +//@ gdb-command:print abc +//@ gdb-check:$2 = 20202 +//@ gdb-command:continue -// gdb-command:print abc -// gdb-check:$3 = 30303 +//@ gdb-command:print abc +//@ gdb-check:$3 = 30303 // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v abc -// lldb-check:[...] 10101 -// lldb-command:continue +//@ lldb-command:v abc +//@ lldb-check:[...] 10101 +//@ lldb-command:continue -// lldb-command:v abc -// lldb-check:[...] 20202 -// lldb-command:continue +//@ lldb-command:v abc +//@ lldb-check:[...] 20202 +//@ lldb-command:continue -// lldb-command:v abc -// lldb-check:[...] 30303 +//@ lldb-command:v abc +//@ lldb-check:[...] 30303 #![allow(unused_variables)] diff --git a/tests/debuginfo/multiple-functions.rs b/tests/debuginfo/multiple-functions.rs index a5fe01f9dd2c..28a68663e265 100644 --- a/tests/debuginfo/multiple-functions.rs +++ b/tests/debuginfo/multiple-functions.rs @@ -4,34 +4,34 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print a -// gdb-check:$1 = 10101 -// gdb-command:continue +//@ gdb-command:print a +//@ gdb-check:$1 = 10101 +//@ gdb-command:continue -// gdb-command:print b -// gdb-check:$2 = 20202 -// gdb-command:continue +//@ gdb-command:print b +//@ gdb-check:$2 = 20202 +//@ gdb-command:continue -// gdb-command:print c -// gdb-check:$3 = 30303 +//@ gdb-command:print c +//@ gdb-check:$3 = 30303 // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v a -// lldb-check:[...] 10101 -// lldb-command:continue +//@ lldb-command:v a +//@ lldb-check:[...] 10101 +//@ lldb-command:continue -// lldb-command:v b -// lldb-check:[...] 20202 -// lldb-command:continue +//@ lldb-command:v b +//@ lldb-check:[...] 20202 +//@ lldb-command:continue -// lldb-command:v c -// lldb-check:[...] 30303 +//@ lldb-command:v c +//@ lldb-check:[...] 30303 #![allow(unused_variables)] diff --git a/tests/debuginfo/mutable-locs.rs b/tests/debuginfo/mutable-locs.rs index 5ba4adeca20e..8e6f9fa130b3 100644 --- a/tests/debuginfo/mutable-locs.rs +++ b/tests/debuginfo/mutable-locs.rs @@ -6,67 +6,67 @@ // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command:dx static_c,d -// cdb-check:static_c,d : 10 [Type: core::cell::Cell] -// cdb-check: [] [Type: core::cell::Cell] +//@ cdb-command:dx static_c,d +//@ cdb-check:static_c,d : 10 [Type: core::cell::Cell] +//@ cdb-check: [] [Type: core::cell::Cell] -// cdb-command: dx static_c.value,d -// cdb-check:static_c.value,d : 10 [Type: core::cell::UnsafeCell] -// cdb-check: [] [Type: core::cell::UnsafeCell] +//@ cdb-command: dx static_c.value,d +//@ cdb-check:static_c.value,d : 10 [Type: core::cell::UnsafeCell] +//@ cdb-check: [] [Type: core::cell::UnsafeCell] -// cdb-command: dx dynamic_c,d -// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] -// cdb-check: [] [Type: core::cell::RefCell] -// cdb-check: [Borrow state] : Unborrowed +//@ cdb-command: dx dynamic_c,d +//@ cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] +//@ cdb-check: [] [Type: core::cell::RefCell] +//@ cdb-check: [Borrow state] : Unborrowed -// cdb-command: dx dynamic_c.value,d -// cdb-check:dynamic_c.value,d : 15 [Type: core::cell::UnsafeCell] -// cdb-check: [] [Type: core::cell::UnsafeCell] +//@ cdb-command: dx dynamic_c.value,d +//@ cdb-check:dynamic_c.value,d : 15 [Type: core::cell::UnsafeCell] +//@ cdb-check: [] [Type: core::cell::UnsafeCell] -// cdb-command: dx b,d -// cdb-check:b,d : 42 [Type: core::cell::RefMut] -// cdb-check: [] [Type: core::cell::RefMut] -// cdb-check: 42 [Type: int] +//@ cdb-command: dx b,d +//@ cdb-check:b,d : 42 [Type: core::cell::RefMut] +//@ cdb-check: [] [Type: core::cell::RefMut] +//@ cdb-check: 42 [Type: int] -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx dynamic_c,d -// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] -// cdb-check: [] [Type: core::cell::RefCell] -// cdb-check: [Borrow state] : Immutably borrowed +//@ cdb-command: dx dynamic_c,d +//@ cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] +//@ cdb-check: [] [Type: core::cell::RefCell] +//@ cdb-check: [Borrow state] : Immutably borrowed -// cdb-command: dx r_borrow,d -// cdb-check:r_borrow,d : 15 [Type: core::cell::Ref] -// cdb-check: [] [Type: core::cell::Ref] -// cdb-check: 15 [Type: int] +//@ cdb-command: dx r_borrow,d +//@ cdb-check:r_borrow,d : 15 [Type: core::cell::Ref] +//@ cdb-check: [] [Type: core::cell::Ref] +//@ cdb-check: 15 [Type: int] -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx dynamic_c,d -// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] -// cdb-check: [] [Type: core::cell::RefCell] -// cdb-check: [Borrow state] : Unborrowed +//@ cdb-command: dx dynamic_c,d +//@ cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] +//@ cdb-check: [] [Type: core::cell::RefCell] +//@ cdb-check: [Borrow state] : Unborrowed -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx dynamic_c,d -// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] -// cdb-check: [] [Type: core::cell::RefCell] -// cdb-check: [Borrow state] : Mutably borrowed +//@ cdb-command: dx dynamic_c,d +//@ cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] +//@ cdb-check: [] [Type: core::cell::RefCell] +//@ cdb-check: [Borrow state] : Mutably borrowed -// cdb-command: dx r_borrow_mut,d -// cdb-check:r_borrow_mut,d : 15 [Type: core::cell::RefMut] -// cdb-check: [] [Type: core::cell::RefMut] -// cdb-check: 15 [Type: int] +//@ cdb-command: dx r_borrow_mut,d +//@ cdb-check:r_borrow_mut,d : 15 [Type: core::cell::RefMut] +//@ cdb-check: [] [Type: core::cell::RefMut] +//@ cdb-check: 15 [Type: int] -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx dynamic_c,d -// cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] -// cdb-check: [] [Type: core::cell::RefCell] -// cdb-check: [Borrow state] : Unborrowed +//@ cdb-command: dx dynamic_c,d +//@ cdb-check:dynamic_c,d : 15 [Type: core::cell::RefCell] +//@ cdb-check: [] [Type: core::cell::RefCell] +//@ cdb-check: [Borrow state] : Unborrowed #![allow(unused_variables)] diff --git a/tests/debuginfo/mutex.rs b/tests/debuginfo/mutex.rs index c47e3ac6dce3..829ad4a29ad2 100644 --- a/tests/debuginfo/mutex.rs +++ b/tests/debuginfo/mutex.rs @@ -6,23 +6,23 @@ // === CDB TESTS ================================================================================== // -// cdb-command:g +//@ cdb-command:g // -// cdb-command:dx m,d -// cdb-check:m,d [Type: std::sync::poison::mutex::Mutex] -// cdb-check: [...] inner [Type: std::sys::sync::mutex::futex::Mutex] -// cdb-check: [...] poison [Type: std::sync::poison::Flag] -// cdb-check: [...] data : 0 [Type: core::cell::UnsafeCell] +//@ cdb-command:dx m,d +//@ cdb-check:m,d [Type: std::sync::poison::mutex::Mutex] +//@ cdb-check: [...] inner [Type: std::sys::sync::mutex::futex::Mutex] +//@ cdb-check: [...] poison [Type: std::sync::poison::Flag] +//@ cdb-check: [...] data : 0 [Type: core::cell::UnsafeCell] // -// cdb-command:dx m.data,d -// cdb-check:m.data,d : 0 [Type: core::cell::UnsafeCell] -// cdb-check: [] [Type: core::cell::UnsafeCell] +//@ cdb-command:dx m.data,d +//@ cdb-check:m.data,d : 0 [Type: core::cell::UnsafeCell] +//@ cdb-check: [] [Type: core::cell::UnsafeCell] // -// cdb-command:dx _lock,d -// cdb-check:_lock,d : Ok [Type: enum2$,enum2$ > > > >] -// cdb-check: [...] __0 [Type: std::sync::poison::mutex::MutexGuard] +//@ cdb-command:dx _lock,d +//@ cdb-check:_lock,d : Ok [Type: enum2$,enum2$ > > > >] +//@ cdb-check: [...] __0 [Type: std::sync::poison::mutex::MutexGuard] use std::sync::Mutex; diff --git a/tests/debuginfo/name-shadowing-and-scope-nesting.rs b/tests/debuginfo/name-shadowing-and-scope-nesting.rs index 9a3393a71e83..45526f1390ab 100644 --- a/tests/debuginfo/name-shadowing-and-scope-nesting.rs +++ b/tests/debuginfo/name-shadowing-and-scope-nesting.rs @@ -4,84 +4,84 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print x -// gdb-check:$1 = false -// gdb-command:print y -// gdb-check:$2 = true -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = false +//@ gdb-command:print y +//@ gdb-check:$2 = true +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$3 = 10 -// gdb-command:print y -// gdb-check:$4 = true -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = 10 +//@ gdb-command:print y +//@ gdb-check:$4 = true +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$5 = 10.5 -// gdb-command:print y -// gdb-check:$6 = 20 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = 10.5 +//@ gdb-command:print y +//@ gdb-check:$6 = 20 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$7 = true -// gdb-command:print y -// gdb-check:$8 = 2220 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$7 = true +//@ gdb-command:print y +//@ gdb-check:$8 = 2220 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$9 = 203203.5 -// gdb-command:print y -// gdb-check:$10 = 2220 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$9 = 203203.5 +//@ gdb-command:print y +//@ gdb-check:$10 = 2220 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$11 = 10.5 -// gdb-command:print y -// gdb-check:$12 = 20 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$11 = 10.5 +//@ gdb-command:print y +//@ gdb-check:$12 = 20 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:v y -// lldb-check:[...] true -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:v y +//@ lldb-check:[...] true +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10 -// lldb-command:v y -// lldb-check:[...] true -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10 +//@ lldb-command:v y +//@ lldb-check:[...] true +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10.5 -// lldb-command:v y -// lldb-check:[...] 20 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10.5 +//@ lldb-command:v y +//@ lldb-check:[...] 20 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] true -// lldb-command:v y -// lldb-check:[...] 2220 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] true +//@ lldb-command:v y +//@ lldb-check:[...] 2220 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 203203.5 -// lldb-command:v y -// lldb-check:[...] 2220 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 203203.5 +//@ lldb-command:v y +//@ lldb-check:[...] 2220 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10.5 -// lldb-command:v y -// lldb-check:[...] 20 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10.5 +//@ lldb-command:v y +//@ lldb-check:[...] 20 +//@ lldb-command:continue fn main() { let x = false; diff --git a/tests/debuginfo/no_mangle-info.rs b/tests/debuginfo/no_mangle-info.rs index ed112bc05e31..262644ee2b6e 100644 --- a/tests/debuginfo/no_mangle-info.rs +++ b/tests/debuginfo/no_mangle-info.rs @@ -3,28 +3,28 @@ //@ ignore-backends: gcc // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:p TEST -// gdb-check:$1 = 3735928559 -// gdb-command:p no_mangle_info::namespace::OTHER_TEST -// gdb-check:$2 = 42 +//@ gdb-command:run +//@ gdb-command:p TEST +//@ gdb-check:$1 = 3735928559 +//@ gdb-command:p no_mangle_info::namespace::OTHER_TEST +//@ gdb-check:$2 = 42 // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v TEST -// lldb-check:(unsigned long) TEST = 3735928559 -// lldb-command:v OTHER_TEST -// lldb-check:(unsigned long) no_mangle_info::namespace::OTHER_TEST = 42 +//@ lldb-command:run +//@ lldb-command:v TEST +//@ lldb-check:(unsigned long) TEST = 3735928559 +//@ lldb-command:v OTHER_TEST +//@ lldb-check:(unsigned long) no_mangle_info::namespace::OTHER_TEST = 42 // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g // Note: LLDB and GDB allow referring to items that are in the same namespace of the symbol // we currently have a breakpoint on in an unqualified way. CDB does not, and thus we need to // refer to it in a fully qualified way. -// cdb-command: dx a!no_mangle_info::TEST -// cdb-check: a!no_mangle_info::TEST : 0xdeadbeef [Type: unsigned __int64] -// cdb-command: dx a!no_mangle_info::namespace::OTHER_TEST -// cdb-check: a!no_mangle_info::namespace::OTHER_TEST : 0x2a [Type: unsigned __int64] +//@ cdb-command: dx a!no_mangle_info::TEST +//@ cdb-check: a!no_mangle_info::TEST : 0xdeadbeef [Type: unsigned __int64] +//@ cdb-command: dx a!no_mangle_info::namespace::OTHER_TEST +//@ cdb-check: a!no_mangle_info::namespace::OTHER_TEST : 0x2a [Type: unsigned __int64] #[no_mangle] pub static TEST: u64 = 0xdeadbeef; diff --git a/tests/debuginfo/numeric-types.rs b/tests/debuginfo/numeric-types.rs index 37b6abf921ea..81fa7900c5fa 100644 --- a/tests/debuginfo/numeric-types.rs +++ b/tests/debuginfo/numeric-types.rs @@ -15,192 +15,192 @@ // `Atomic{Bool,I8,I16,I32,I64,Isize,U8,U16,U32,U64,Usize}` located in `libcore.natvis`. // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx nz_i8 -// cdb-check:nz_i8 : 11 [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_i8 +//@ cdb-check:nz_i8 : 11 [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx nz_i16 -// cdb-check:nz_i16 : 22 [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_i16 +//@ cdb-check:nz_i16 : 22 [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx nz_i32 -// cdb-check:nz_i32 : 33 [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_i32 +//@ cdb-check:nz_i32 : 33 [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx nz_i64 -// cdb-check:nz_i64 : 44 [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_i64 +//@ cdb-check:nz_i64 : 44 [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] // 128-bit integers don't seem to work in CDB -// cdb-command: dx nz_i128 -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_i128 +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx nz_isize -// cdb-check:nz_isize : 66 [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_isize +//@ cdb-check:nz_isize : 66 [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx nz_u8 -// cdb-check:nz_u8 : 0x4d [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_u8 +//@ cdb-check:nz_u8 : 0x4d [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx nz_u16 -// cdb-check:nz_u16 : 0x58 [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_u16 +//@ cdb-check:nz_u16 : 0x58 [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx nz_u32 -// cdb-check:nz_u32 : 0x63 [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_u32 +//@ cdb-check:nz_u32 : 0x63 [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx nz_u64 -// cdb-check:nz_u64 : 0x64 [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_u64 +//@ cdb-check:nz_u64 : 0x64 [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx nz_u128 -// cdb-check:nz_u128 : 111 [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_u128 +//@ cdb-check:nz_u128 : 111 [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx nz_usize -// cdb-check:nz_usize : 0x7a [Type: core::num::nonzero::NonZero] -// cdb-check: [] [Type: core::num::nonzero::NonZero] +//@ cdb-command: dx nz_usize +//@ cdb-check:nz_usize : 0x7a [Type: core::num::nonzero::NonZero] +//@ cdb-check: [] [Type: core::num::nonzero::NonZero] -// cdb-command: dx w_i8 -// cdb-check:w_i8 : 10 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 10 [Type: char] +//@ cdb-command: dx w_i8 +//@ cdb-check:w_i8 : 10 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 10 [Type: char] -// cdb-command: dx w_i16 -// cdb-check:w_i16 : 20 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 20 [Type: short] +//@ cdb-command: dx w_i16 +//@ cdb-check:w_i16 : 20 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 20 [Type: short] -// cdb-command: dx w_i32 -// cdb-check:w_i32 : 30 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 30 [Type: int] +//@ cdb-command: dx w_i32 +//@ cdb-check:w_i32 : 30 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 30 [Type: int] -// cdb-command: dx w_i64 -// cdb-check:w_i64 : 40 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 40 [Type: __int64] +//@ cdb-command: dx w_i64 +//@ cdb-check:w_i64 : 40 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 40 [Type: __int64] -// cdb-command: dx w_i128 -// cdb-check:w_i128 : 50 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 50 [Type: i128] +//@ cdb-command: dx w_i128 +//@ cdb-check:w_i128 : 50 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 50 [Type: i128] -// cdb-command: dx w_isize -// cdb-check:w_isize : 60 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 60 [Type: __int64] +//@ cdb-command: dx w_isize +//@ cdb-check:w_isize : 60 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 60 [Type: __int64] -// cdb-command: dx w_u8 -// cdb-check:w_u8 : 0x46 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 0x46 [Type: unsigned char] +//@ cdb-command: dx w_u8 +//@ cdb-check:w_u8 : 0x46 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 0x46 [Type: unsigned char] -// cdb-command: dx w_u16 -// cdb-check:w_u16 : 0x50 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 0x50 [Type: unsigned short] +//@ cdb-command: dx w_u16 +//@ cdb-check:w_u16 : 0x50 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 0x50 [Type: unsigned short] -// cdb-command: dx w_u32 -// cdb-check:w_u32 : 0x5a [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 0x5a [Type: unsigned int] +//@ cdb-command: dx w_u32 +//@ cdb-check:w_u32 : 0x5a [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 0x5a [Type: unsigned int] -// cdb-command: dx w_u64 -// cdb-check:w_u64 : 0x64 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 0x64 [Type: unsigned __int64] +//@ cdb-command: dx w_u64 +//@ cdb-check:w_u64 : 0x64 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 0x64 [Type: unsigned __int64] -// cdb-command: dx w_u128 -// cdb-check:w_u128 : 110 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 110 [Type: u128] +//@ cdb-command: dx w_u128 +//@ cdb-check:w_u128 : 110 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 110 [Type: u128] -// cdb-command: dx w_usize -// cdb-check:w_usize : 0x78 [Type: core::num::wrapping::Wrapping] -// cdb-check: [+0x000] __0 : 0x78 [Type: unsigned __int64] +//@ cdb-command: dx w_usize +//@ cdb-check:w_usize : 0x78 [Type: core::num::wrapping::Wrapping] +//@ cdb-check: [+0x000] __0 : 0x78 [Type: unsigned __int64] -// cdb-command: dx a_bool_t -// cdb-check:a_bool_t : true [Type: core::sync::atomic::AtomicBool] -// cdb-check: [+0x000] v : 0x1 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_bool_t +//@ cdb-check:a_bool_t : true [Type: core::sync::atomic::AtomicBool] +//@ cdb-check: [+0x000] v : 0x1 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_bool_f -// cdb-check:a_bool_f : false [Type: core::sync::atomic::AtomicBool] -// cdb-check: [+0x000] v : 0x0 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_bool_f +//@ cdb-check:a_bool_f : false [Type: core::sync::atomic::AtomicBool] +//@ cdb-check: [+0x000] v : 0x0 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_i8 -// cdb-check:a_i8 : 2 [Type: core::sync::atomic::AtomicI8] -// cdb-check: [+0x000] v : 2 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_i8 +//@ cdb-check:a_i8 : 2 [Type: core::sync::atomic::AtomicI8] +//@ cdb-check: [+0x000] v : 2 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_i16 -// cdb-check:a_i16 : 4 [Type: core::sync::atomic::AtomicI16] -// cdb-check: [+0x000] v : 4 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_i16 +//@ cdb-check:a_i16 : 4 [Type: core::sync::atomic::AtomicI16] +//@ cdb-check: [+0x000] v : 4 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_i32 -// cdb-check:a_i32 : 8 [Type: core::sync::atomic::AtomicI32] -// cdb-check: [+0x000] v : 8 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_i32 +//@ cdb-check:a_i32 : 8 [Type: core::sync::atomic::AtomicI32] +//@ cdb-check: [+0x000] v : 8 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_i64 -// cdb-check:a_i64 : 16 [Type: core::sync::atomic::AtomicI64] -// cdb-check: [+0x000] v : 16 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_i64 +//@ cdb-check:a_i64 : 16 [Type: core::sync::atomic::AtomicI64] +//@ cdb-check: [+0x000] v : 16 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_isize -// cdb-check:a_isize : 32 [Type: core::sync::atomic::AtomicIsize] -// cdb-check: [+0x000] v : 32 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_isize +//@ cdb-check:a_isize : 32 [Type: core::sync::atomic::AtomicIsize] +//@ cdb-check: [+0x000] v : 32 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_u8 -// cdb-check:a_u8 : 0x40 [Type: core::sync::atomic::AtomicU8] -// cdb-check: [+0x000] v : 0x40 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_u8 +//@ cdb-check:a_u8 : 0x40 [Type: core::sync::atomic::AtomicU8] +//@ cdb-check: [+0x000] v : 0x40 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_u16 -// cdb-check:a_u16 : 0x80 [Type: core::sync::atomic::AtomicU16] -// cdb-check: [+0x000] v : 0x80 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_u16 +//@ cdb-check:a_u16 : 0x80 [Type: core::sync::atomic::AtomicU16] +//@ cdb-check: [+0x000] v : 0x80 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_u32 -// cdb-check:a_u32 : 0x100 [Type: core::sync::atomic::AtomicU32] -// cdb-check: [+0x000] v : 0x100 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_u32 +//@ cdb-check:a_u32 : 0x100 [Type: core::sync::atomic::AtomicU32] +//@ cdb-check: [+0x000] v : 0x100 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_u64 -// cdb-check:a_u64 : 0x200 [Type: core::sync::atomic::AtomicU64] -// cdb-check: [+0x000] v : 0x200 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_u64 +//@ cdb-check:a_u64 : 0x200 [Type: core::sync::atomic::AtomicU64] +//@ cdb-check: [+0x000] v : 0x200 [Type: core::cell::UnsafeCell] -// cdb-command: dx a_usize -// cdb-check:a_usize : 0x400 [Type: core::sync::atomic::AtomicUsize] -// cdb-check: [+0x000] v : 0x400 [Type: core::cell::UnsafeCell] +//@ cdb-command: dx a_usize +//@ cdb-check:a_usize : 0x400 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [+0x000] v : 0x400 [Type: core::cell::UnsafeCell] // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print/d nz_i8 -// gdb-check:[...]$1 = 11 +//@ gdb-command:print/d nz_i8 +//@ gdb-check:[...]$1 = 11 -// gdb-command:print nz_i16 -// gdb-check:[...]$2 = 22 +//@ gdb-command:print nz_i16 +//@ gdb-check:[...]$2 = 22 -// gdb-command:print nz_i32 -// gdb-check:[...]$3 = 33 +//@ gdb-command:print nz_i32 +//@ gdb-check:[...]$3 = 33 -// gdb-command:print nz_i64 -// gdb-check:[...]$4 = 44 +//@ gdb-command:print nz_i64 +//@ gdb-check:[...]$4 = 44 -// gdb-command:print nz_i128 -// gdb-check:[...]$5 = 55 +//@ gdb-command:print nz_i128 +//@ gdb-check:[...]$5 = 55 -// gdb-command:print nz_isize -// gdb-check:[...]$6 = 66 +//@ gdb-command:print nz_isize +//@ gdb-check:[...]$6 = 66 -// gdb-command:print/d nz_u8 -// gdb-check:[...]$7 = 77 +//@ gdb-command:print/d nz_u8 +//@ gdb-check:[...]$7 = 77 -// gdb-command:print nz_u16 -// gdb-check:[...]$8 = 88 +//@ gdb-command:print nz_u16 +//@ gdb-check:[...]$8 = 88 -// gdb-command:print nz_u32 -// gdb-check:[...]$9 = 99 +//@ gdb-command:print nz_u32 +//@ gdb-check:[...]$9 = 99 -// gdb-command:print nz_u64 -// gdb-check:[...]$10 = 100 +//@ gdb-command:print nz_u64 +//@ gdb-check:[...]$10 = 100 -// gdb-command:print nz_u128 -// gdb-check:[...]$11 = 111 +//@ gdb-command:print nz_u128 +//@ gdb-check:[...]$11 = 111 -// gdb-command:print nz_usize -// gdb-check:[...]$12 = 122 +//@ gdb-command:print nz_usize +//@ gdb-check:[...]$12 = 122 // gdb-command:print/x nz_i8 // gdb-check:[...]$13 = 0xb @@ -208,43 +208,43 @@ // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v/d nz_i8 -// lldb-check:[...] 11 { __0 = { 0 = 11 } } +//@ lldb-command:v/d nz_i8 +//@ lldb-check:[...] 11 { __0 = { 0 = 11 } } -// lldb-command:v nz_i16 -// lldb-check:[...] 22 { __0 = { 0 = 22 } } +//@ lldb-command:v nz_i16 +//@ lldb-check:[...] 22 { __0 = { 0 = 22 } } -// lldb-command:v nz_i32 -// lldb-check:[...] 33 { __0 = { 0 = 33 } } +//@ lldb-command:v nz_i32 +//@ lldb-check:[...] 33 { __0 = { 0 = 33 } } -// lldb-command:v nz_i64 -// lldb-check:[...] 44 { __0 = { 0 = 44 } } +//@ lldb-command:v nz_i64 +//@ lldb-check:[...] 44 { __0 = { 0 = 44 } } -// lldb-command:v nz_i128 -// lldb-check:[...] 55 { __0 = { 0 = 55 } } +//@ lldb-command:v nz_i128 +//@ lldb-check:[...] 55 { __0 = { 0 = 55 } } -// lldb-command:v nz_isize -// lldb-check:[...] 66 { __0 = { 0 = 66 } } +//@ lldb-command:v nz_isize +//@ lldb-check:[...] 66 { __0 = { 0 = 66 } } -// lldb-command:v/d nz_u8 -// lldb-check:[...] 77 { __0 = { 0 = 77 } } +//@ lldb-command:v/d nz_u8 +//@ lldb-check:[...] 77 { __0 = { 0 = 77 } } -// lldb-command:v nz_u16 -// lldb-check:[...] 88 { __0 = { 0 = 88 } } +//@ lldb-command:v nz_u16 +//@ lldb-check:[...] 88 { __0 = { 0 = 88 } } -// lldb-command:v nz_u32 -// lldb-check:[...] 99 { __0 = { 0 = 99 } } +//@ lldb-command:v nz_u32 +//@ lldb-check:[...] 99 { __0 = { 0 = 99 } } -// lldb-command:v nz_u64 -// lldb-check:[...] 100 { __0 = { 0 = 100 } } +//@ lldb-command:v nz_u64 +//@ lldb-check:[...] 100 { __0 = { 0 = 100 } } -// lldb-command:v nz_u128 -// lldb-check:[...] 111 { __0 = { 0 = 111 } } +//@ lldb-command:v nz_u128 +//@ lldb-check:[...] 111 { __0 = { 0 = 111 } } -// lldb-command:v nz_usize -// lldb-check:[...] 122 { __0 = { 0 = 122 } } +//@ lldb-command:v nz_usize +//@ lldb-check:[...] 122 { __0 = { 0 = 122 } } use std::num::*; use std::sync::atomic::*; diff --git a/tests/debuginfo/opt/dead_refs.rs b/tests/debuginfo/opt/dead_refs.rs index 61e741573346..61c39f4fb778 100644 --- a/tests/debuginfo/opt/dead_refs.rs +++ b/tests/debuginfo/opt/dead_refs.rs @@ -7,27 +7,27 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print *ref_v0 -// gdb-check:$1 = 0 +//@ gdb-command:run +//@ gdb-command:print *ref_v0 +//@ gdb-check:$1 = 0 -// gdb-command:print *ref_v1 -// gdb-check:$2 = 1 +//@ gdb-command:print *ref_v1 +//@ gdb-check:$2 = 1 -// gdb-command:print *ref_v2 -// gdb-check:$3 = 2 +//@ gdb-command:print *ref_v2 +//@ gdb-check:$3 = 2 // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v *ref_v0 -// lldb-check:[...] 0 +//@ lldb-command:run +//@ lldb-command:v *ref_v0 +//@ lldb-check:[...] 0 -// lldb-command:v *ref_v1 -// lldb-check:[...] 1 +//@ lldb-command:v *ref_v1 +//@ lldb-check:[...] 1 -// lldb-command:v *ref_v2 -// lldb-check:[...] 2 +//@ lldb-command:v *ref_v2 +//@ lldb-check:[...] 2 #![allow(unused_variables)] diff --git a/tests/debuginfo/option-like-enum.rs b/tests/debuginfo/option-like-enum.rs index 0e419978d62e..047a738574c2 100644 --- a/tests/debuginfo/option-like-enum.rs +++ b/tests/debuginfo/option-like-enum.rs @@ -6,68 +6,68 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print some -// gdb-check:$1 = core::option::Option<&u32>::Some(0x[...]) +//@ gdb-command:print some +//@ gdb-check:$1 = core::option::Option<&u32>::Some(0x[...]) -// gdb-command:print none -// gdb-check:$2 = core::option::Option<&u32>::None +//@ gdb-command:print none +//@ gdb-check:$2 = core::option::Option<&u32>::None -// gdb-command:print full -// gdb-check:$3 = option_like_enum::MoreFields::Full(454545, 0x[...], 9988) +//@ gdb-command:print full +//@ gdb-check:$3 = option_like_enum::MoreFields::Full(454545, 0x[...], 9988) -// gdb-command:print empty -// gdb-check:$4 = option_like_enum::MoreFields::Empty +//@ gdb-command:print empty +//@ gdb-check:$4 = option_like_enum::MoreFields::Empty -// gdb-command:print droid -// gdb-check:$5 = option_like_enum::NamedFields::Droid{id: 675675, range: 10000001, internals: 0x[...]} +//@ gdb-command:print droid +//@ gdb-check:$5 = option_like_enum::NamedFields::Droid{id: 675675, range: 10000001, internals: 0x[...]} -// gdb-command:print void_droid -// gdb-check:$6 = option_like_enum::NamedFields::Void +//@ gdb-command:print void_droid +//@ gdb-check:$6 = option_like_enum::NamedFields::Void -// gdb-command:print nested_non_zero_yep -// gdb-check:$7 = option_like_enum::NestedNonZero::Yep(10.5, option_like_enum::NestedNonZeroField {a: 10, b: 20, c: 0x[...]}) +//@ gdb-command:print nested_non_zero_yep +//@ gdb-check:$7 = option_like_enum::NestedNonZero::Yep(10.5, option_like_enum::NestedNonZeroField {a: 10, b: 20, c: 0x[...]}) -// gdb-command:print nested_non_zero_nope -// gdb-check:$8 = option_like_enum::NestedNonZero::Nope +//@ gdb-command:print nested_non_zero_nope +//@ gdb-check:$8 = option_like_enum::NestedNonZero::Nope -// gdb-command:continue +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v some -// lldb-check:[...] Some(0x[...]) { 0 = 0x[...] } +//@ lldb-command:v some +//@ lldb-check:[...] Some(0x[...]) { 0 = 0x[...] } -// lldb-command:v none -// lldb-check:[...] None +//@ lldb-command:v none +//@ lldb-check:[...] None -// lldb-command:v full -// lldb-check:[...] Full(454545, 0x[...], 9988) { 0 = 454545 1 = 0x[...] 2 = 9988 } +//@ lldb-command:v full +//@ lldb-check:[...] Full(454545, 0x[...], 9988) { 0 = 454545 1 = 0x[...] 2 = 9988 } -// lldb-command:v empty -// lldb-check:[...] Empty +//@ lldb-command:v empty +//@ lldb-check:[...] Empty -// lldb-command:v droid -// lldb-check:[...] Droid{id:675675, range:10000001, internals:0x[...]} { id = 675675 range = 10000001 internals = 0x[...] } +//@ lldb-command:v droid +//@ lldb-check:[...] Droid{id:675675, range:10000001, internals:0x[...]} { id = 675675 range = 10000001 internals = 0x[...] } -// lldb-command:v void_droid -// lldb-check:[...] Void +//@ lldb-command:v void_droid +//@ lldb-check:[...] Void -// lldb-command:v some_str -// lldb-check:[...] Some("abc") [...] +//@ lldb-command:v some_str +//@ lldb-check:[...] Some("abc") [...] -// lldb-command:v none_str -// lldb-check:[...] None +//@ lldb-command:v none_str +//@ lldb-check:[...] None -// lldb-command:v nested_non_zero_yep -// lldb-check:[...] Yep(10.5, {a:10, b:20, c:[...]}) { 0 = 10.5 1 = { a = 10 b = 20 c = [...] } } +//@ lldb-command:v nested_non_zero_yep +//@ lldb-check:[...] Yep(10.5, {a:10, b:20, c:[...]}) { 0 = 10.5 1 = { a = 10 b = 20 c = [...] } } -// lldb-command:v nested_non_zero_nope -// lldb-check:[...] Nope +//@ lldb-command:v nested_non_zero_nope +//@ lldb-check:[...] Nope // If a struct has exactly two variants, one of them is empty, and the other one diff --git a/tests/debuginfo/packed-struct-with-destructor.rs b/tests/debuginfo/packed-struct-with-destructor.rs index 2150ec53501c..ec656f7ae612 100644 --- a/tests/debuginfo/packed-struct-with-destructor.rs +++ b/tests/debuginfo/packed-struct-with-destructor.rs @@ -4,61 +4,61 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print packed -// gdb-check:$1 = packed_struct_with_destructor::Packed {x: 123, y: 234, z: 345} +//@ gdb-command:print packed +//@ gdb-check:$1 = packed_struct_with_destructor::Packed {x: 123, y: 234, z: 345} -// gdb-command:print packedInPacked -// gdb-check:$2 = packed_struct_with_destructor::PackedInPacked {a: 1111, b: packed_struct_with_destructor::Packed {x: 2222, y: 3333, z: 4444}, c: 5555, d: packed_struct_with_destructor::Packed {x: 6666, y: 7777, z: 8888}} +//@ gdb-command:print packedInPacked +//@ gdb-check:$2 = packed_struct_with_destructor::PackedInPacked {a: 1111, b: packed_struct_with_destructor::Packed {x: 2222, y: 3333, z: 4444}, c: 5555, d: packed_struct_with_destructor::Packed {x: 6666, y: 7777, z: 8888}} -// gdb-command:print packedInUnpacked -// gdb-check:$3 = packed_struct_with_destructor::PackedInUnpacked {a: -1111, b: packed_struct_with_destructor::Packed {x: -2222, y: -3333, z: -4444}, c: -5555, d: packed_struct_with_destructor::Packed {x: -6666, y: -7777, z: -8888}} +//@ gdb-command:print packedInUnpacked +//@ gdb-check:$3 = packed_struct_with_destructor::PackedInUnpacked {a: -1111, b: packed_struct_with_destructor::Packed {x: -2222, y: -3333, z: -4444}, c: -5555, d: packed_struct_with_destructor::Packed {x: -6666, y: -7777, z: -8888}} -// gdb-command:print unpackedInPacked -// gdb-check:$4 = packed_struct_with_destructor::UnpackedInPacked {a: 987, b: packed_struct_with_destructor::Unpacked {x: 876, y: 765, z: 654}, c: packed_struct_with_destructor::Unpacked {x: 543, y: 432, z: 321}, d: 210} +//@ gdb-command:print unpackedInPacked +//@ gdb-check:$4 = packed_struct_with_destructor::UnpackedInPacked {a: 987, b: packed_struct_with_destructor::Unpacked {x: 876, y: 765, z: 654}, c: packed_struct_with_destructor::Unpacked {x: 543, y: 432, z: 321}, d: 210} -// gdb-command:print packedInPackedWithDrop -// gdb-check:$5 = packed_struct_with_destructor::PackedInPackedWithDrop {a: 11, b: packed_struct_with_destructor::Packed {x: 22, y: 33, z: 44}, c: 55, d: packed_struct_with_destructor::Packed {x: 66, y: 77, z: 88}} +//@ gdb-command:print packedInPackedWithDrop +//@ gdb-check:$5 = packed_struct_with_destructor::PackedInPackedWithDrop {a: 11, b: packed_struct_with_destructor::Packed {x: 22, y: 33, z: 44}, c: 55, d: packed_struct_with_destructor::Packed {x: 66, y: 77, z: 88}} -// gdb-command:print packedInUnpackedWithDrop -// gdb-check:$6 = packed_struct_with_destructor::PackedInUnpackedWithDrop {a: -11, b: packed_struct_with_destructor::Packed {x: -22, y: -33, z: -44}, c: -55, d: packed_struct_with_destructor::Packed {x: -66, y: -77, z: -88}} +//@ gdb-command:print packedInUnpackedWithDrop +//@ gdb-check:$6 = packed_struct_with_destructor::PackedInUnpackedWithDrop {a: -11, b: packed_struct_with_destructor::Packed {x: -22, y: -33, z: -44}, c: -55, d: packed_struct_with_destructor::Packed {x: -66, y: -77, z: -88}} -// gdb-command:print unpackedInPackedWithDrop -// gdb-check:$7 = packed_struct_with_destructor::UnpackedInPackedWithDrop {a: 98, b: packed_struct_with_destructor::Unpacked {x: 87, y: 76, z: 65}, c: packed_struct_with_destructor::Unpacked {x: 54, y: 43, z: 32}, d: 21} +//@ gdb-command:print unpackedInPackedWithDrop +//@ gdb-check:$7 = packed_struct_with_destructor::UnpackedInPackedWithDrop {a: 98, b: packed_struct_with_destructor::Unpacked {x: 87, y: 76, z: 65}, c: packed_struct_with_destructor::Unpacked {x: 54, y: 43, z: 32}, d: 21} -// gdb-command:print deeplyNested -// gdb-check:$8 = packed_struct_with_destructor::DeeplyNested {a: packed_struct_with_destructor::PackedInPacked {a: 1, b: packed_struct_with_destructor::Packed {x: 2, y: 3, z: 4}, c: 5, d: packed_struct_with_destructor::Packed {x: 6, y: 7, z: 8}}, b: packed_struct_with_destructor::UnpackedInPackedWithDrop {a: 9, b: packed_struct_with_destructor::Unpacked {x: 10, y: 11, z: 12}, c: packed_struct_with_destructor::Unpacked {x: 13, y: 14, z: 15}, d: 16}, c: packed_struct_with_destructor::PackedInUnpacked {a: 17, b: packed_struct_with_destructor::Packed {x: 18, y: 19, z: 20}, c: 21, d: packed_struct_with_destructor::Packed {x: 22, y: 23, z: 24}}, d: packed_struct_with_destructor::PackedInUnpackedWithDrop {a: 25, b: packed_struct_with_destructor::Packed {x: 26, y: 27, z: 28}, c: 29, d: packed_struct_with_destructor::Packed {x: 30, y: 31, z: 32}}, e: packed_struct_with_destructor::UnpackedInPacked {a: 33, b: packed_struct_with_destructor::Unpacked {x: 34, y: 35, z: 36}, c: packed_struct_with_destructor::Unpacked {x: 37, y: 38, z: 39}, d: 40}, f: packed_struct_with_destructor::PackedInPackedWithDrop {a: 41, b: packed_struct_with_destructor::Packed {x: 42, y: 43, z: 44}, c: 45, d: packed_struct_with_destructor::Packed {x: 46, y: 47, z: 48}}} +//@ gdb-command:print deeplyNested +//@ gdb-check:$8 = packed_struct_with_destructor::DeeplyNested {a: packed_struct_with_destructor::PackedInPacked {a: 1, b: packed_struct_with_destructor::Packed {x: 2, y: 3, z: 4}, c: 5, d: packed_struct_with_destructor::Packed {x: 6, y: 7, z: 8}}, b: packed_struct_with_destructor::UnpackedInPackedWithDrop {a: 9, b: packed_struct_with_destructor::Unpacked {x: 10, y: 11, z: 12}, c: packed_struct_with_destructor::Unpacked {x: 13, y: 14, z: 15}, d: 16}, c: packed_struct_with_destructor::PackedInUnpacked {a: 17, b: packed_struct_with_destructor::Packed {x: 18, y: 19, z: 20}, c: 21, d: packed_struct_with_destructor::Packed {x: 22, y: 23, z: 24}}, d: packed_struct_with_destructor::PackedInUnpackedWithDrop {a: 25, b: packed_struct_with_destructor::Packed {x: 26, y: 27, z: 28}, c: 29, d: packed_struct_with_destructor::Packed {x: 30, y: 31, z: 32}}, e: packed_struct_with_destructor::UnpackedInPacked {a: 33, b: packed_struct_with_destructor::Unpacked {x: 34, y: 35, z: 36}, c: packed_struct_with_destructor::Unpacked {x: 37, y: 38, z: 39}, d: 40}, f: packed_struct_with_destructor::PackedInPackedWithDrop {a: 41, b: packed_struct_with_destructor::Packed {x: 42, y: 43, z: 44}, c: 45, d: packed_struct_with_destructor::Packed {x: 46, y: 47, z: 48}}} // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v packed -// lldb-check:[...] { x = 123 y = 234 z = 345 } +//@ lldb-command:v packed +//@ lldb-check:[...] { x = 123 y = 234 z = 345 } -// lldb-command:v packedInPacked -// lldb-check:[...] { a = 1111 b = { x = 2222 y = 3333 z = 4444 } c = 5555 d = { x = 6666 y = 7777 z = 8888 } } +//@ lldb-command:v packedInPacked +//@ lldb-check:[...] { a = 1111 b = { x = 2222 y = 3333 z = 4444 } c = 5555 d = { x = 6666 y = 7777 z = 8888 } } -// lldb-command:v packedInUnpacked -// lldb-check:[...] { a = -1111 b = { x = -2222 y = -3333 z = -4444 } c = -5555 d = { x = -6666 y = -7777 z = -8888 } } +//@ lldb-command:v packedInUnpacked +//@ lldb-check:[...] { a = -1111 b = { x = -2222 y = -3333 z = -4444 } c = -5555 d = { x = -6666 y = -7777 z = -8888 } } -// lldb-command:v unpackedInPacked -// lldb-check:[...] { a = 987 b = { x = 876 y = 765 z = 654 } c = { x = 543 y = 432 z = 321 } d = 210 } +//@ lldb-command:v unpackedInPacked +//@ lldb-check:[...] { a = 987 b = { x = 876 y = 765 z = 654 } c = { x = 543 y = 432 z = 321 } d = 210 } -// lldb-command:v packedInPackedWithDrop -// lldb-check:[...] { a = 11 b = { x = 22 y = 33 z = 44 } c = 55 d = { x = 66 y = 77 z = 88 } } +//@ lldb-command:v packedInPackedWithDrop +//@ lldb-check:[...] { a = 11 b = { x = 22 y = 33 z = 44 } c = 55 d = { x = 66 y = 77 z = 88 } } -// lldb-command:v packedInUnpackedWithDrop -// lldb-check:[...] { a = -11 b = { x = -22 y = -33 z = -44 } c = -55 d = { x = -66 y = -77 z = -88 } } +//@ lldb-command:v packedInUnpackedWithDrop +//@ lldb-check:[...] { a = -11 b = { x = -22 y = -33 z = -44 } c = -55 d = { x = -66 y = -77 z = -88 } } -// lldb-command:v unpackedInPackedWithDrop -// lldb-check:[...] { a = 98 b = { x = 87 y = 76 z = 65 } c = { x = 54 y = 43 z = 32 } d = 21 } +//@ lldb-command:v unpackedInPackedWithDrop +//@ lldb-check:[...] { a = 98 b = { x = 87 y = 76 z = 65 } c = { x = 54 y = 43 z = 32 } d = 21 } -// lldb-command:v deeplyNested -// lldb-check:[...] { a = { a = 1 b = { x = 2 y = 3 z = 4 } c = 5 d = { x = 6 y = 7 z = 8 } } b = { a = 9 b = { x = 10 y = 11 z = 12 } c = { x = 13 y = 14 z = 15 } d = 16 } c = { a = 17 b = { x = 18 y = 19 z = 20 } c = 21 d = { x = 22 y = 23 z = 24 } } d = { a = 25 b = { x = 26 y = 27 z = 28 } c = 29 d = { x = 30 y = 31 z = 32 } } e = { a = 33 b = { x = 34 y = 35 z = 36 } c = { x = 37 y = 38 z = 39 } d = 40 } f = { a = 41 b = { x = 42 y = 43 z = 44 } c = 45 d = { x = 46 y = 47 z = 48 } } } +//@ lldb-command:v deeplyNested +//@ lldb-check:[...] { a = { a = 1 b = { x = 2 y = 3 z = 4 } c = 5 d = { x = 6 y = 7 z = 8 } } b = { a = 9 b = { x = 10 y = 11 z = 12 } c = { x = 13 y = 14 z = 15 } d = 16 } c = { a = 17 b = { x = 18 y = 19 z = 20 } c = 21 d = { x = 22 y = 23 z = 24 } } d = { a = 25 b = { x = 26 y = 27 z = 28 } c = 29 d = { x = 30 y = 31 z = 32 } } e = { a = 33 b = { x = 34 y = 35 z = 36 } c = { x = 37 y = 38 z = 39 } d = 40 } f = { a = 41 b = { x = 42 y = 43 z = 44 } c = 45 d = { x = 46 y = 47 z = 48 } } } #![allow(unused_variables)] diff --git a/tests/debuginfo/packed-struct.rs b/tests/debuginfo/packed-struct.rs index 427289c84774..38f846502af4 100644 --- a/tests/debuginfo/packed-struct.rs +++ b/tests/debuginfo/packed-struct.rs @@ -4,48 +4,48 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print packed -// gdb-check:$1 = packed_struct::Packed {x: 123, y: 234, z: 345} +//@ gdb-command:print packed +//@ gdb-check:$1 = packed_struct::Packed {x: 123, y: 234, z: 345} -// gdb-command:print packedInPacked -// gdb-check:$2 = packed_struct::PackedInPacked {a: 1111, b: packed_struct::Packed {x: 2222, y: 3333, z: 4444}, c: 5555, d: packed_struct::Packed {x: 6666, y: 7777, z: 8888}} +//@ gdb-command:print packedInPacked +//@ gdb-check:$2 = packed_struct::PackedInPacked {a: 1111, b: packed_struct::Packed {x: 2222, y: 3333, z: 4444}, c: 5555, d: packed_struct::Packed {x: 6666, y: 7777, z: 8888}} -// gdb-command:print packedInUnpacked -// gdb-check:$3 = packed_struct::PackedInUnpacked {a: -1111, b: packed_struct::Packed {x: -2222, y: -3333, z: -4444}, c: -5555, d: packed_struct::Packed {x: -6666, y: -7777, z: -8888}} +//@ gdb-command:print packedInUnpacked +//@ gdb-check:$3 = packed_struct::PackedInUnpacked {a: -1111, b: packed_struct::Packed {x: -2222, y: -3333, z: -4444}, c: -5555, d: packed_struct::Packed {x: -6666, y: -7777, z: -8888}} -// gdb-command:print unpackedInPacked -// gdb-check:$4 = packed_struct::UnpackedInPacked {a: 987, b: packed_struct::Unpacked {x: 876, y: 765, z: 654, w: 543}, c: packed_struct::Unpacked {x: 432, y: 321, z: 210, w: 109}, d: -98} +//@ gdb-command:print unpackedInPacked +//@ gdb-check:$4 = packed_struct::UnpackedInPacked {a: 987, b: packed_struct::Unpacked {x: 876, y: 765, z: 654, w: 543}, c: packed_struct::Unpacked {x: 432, y: 321, z: 210, w: 109}, d: -98} -// gdb-command:print sizeof(packed) -// gdb-check:$5 = 14 +//@ gdb-command:print sizeof(packed) +//@ gdb-check:$5 = 14 -// gdb-command:print sizeof(packedInPacked) -// gdb-check:$6 = 40 +//@ gdb-command:print sizeof(packedInPacked) +//@ gdb-check:$6 = 40 // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v packed -// lldb-check:[...] { x = 123 y = 234 z = 345 } +//@ lldb-command:v packed +//@ lldb-check:[...] { x = 123 y = 234 z = 345 } -// lldb-command:v packedInPacked -// lldb-check:[...] { a = 1111 b = { x = 2222 y = 3333 z = 4444 } c = 5555 d = { x = 6666 y = 7777 z = 8888 } } +//@ lldb-command:v packedInPacked +//@ lldb-check:[...] { a = 1111 b = { x = 2222 y = 3333 z = 4444 } c = 5555 d = { x = 6666 y = 7777 z = 8888 } } -// lldb-command:v packedInUnpacked -// lldb-check:[...] { a = -1111 b = { x = -2222 y = -3333 z = -4444 } c = -5555 d = { x = -6666 y = -7777 z = -8888 } } +//@ lldb-command:v packedInUnpacked +//@ lldb-check:[...] { a = -1111 b = { x = -2222 y = -3333 z = -4444 } c = -5555 d = { x = -6666 y = -7777 z = -8888 } } -// lldb-command:v unpackedInPacked -// lldb-check:[...] { a = 987 b = { x = 876 y = 765 z = 654 w = 543 } c = { x = 432 y = 321 z = 210 w = 109 } d = -98 } +//@ lldb-command:v unpackedInPacked +//@ lldb-check:[...] { a = 987 b = { x = 876 y = 765 z = 654 w = 543 } c = { x = 432 y = 321 z = 210 w = 109 } d = -98 } -// lldb-command:expr sizeof(packed) -// lldb-check:[...] 14 +//@ lldb-command:expr sizeof(packed) +//@ lldb-check:[...] 14 -// lldb-command:expr sizeof(packedInPacked) -// lldb-check:[...] 40 +//@ lldb-command:expr sizeof(packedInPacked) +//@ lldb-check:[...] 40 #![allow(unused_variables)] diff --git a/tests/debuginfo/path.rs b/tests/debuginfo/path.rs index 42bbacc3a91a..27b518fd8975 100644 --- a/tests/debuginfo/path.rs +++ b/tests/debuginfo/path.rs @@ -4,16 +4,16 @@ // === LLDB TESTS ================================================================================= -// lldb-command:run +//@ lldb-command:run -// lldb-command:print pathbuf -// lldb-check:[...] "/some/path" { inner = "/some/path" { inner = { inner = size=10 { [0] = '/' [1] = 's' [2] = 'o' [3] = 'm' [4] = 'e' [5] = '/' [6] = 'p' [7] = 'a' [8] = 't' [9] = 'h' } } } } -// lldb-command:po pathbuf -// lldb-check:"/some/path" -// lldb-command:print path -// lldb-check:[...] "/some/path" { data_ptr = [...] length = 10 } -// lldb-command:po path -// lldb-check:"/some/path" +//@ lldb-command:print pathbuf +//@ lldb-check:[...] "/some/path" { inner = "/some/path" { inner = { inner = size=10 { [0] = '/' [1] = 's' [2] = 'o' [3] = 'm' [4] = 'e' [5] = '/' [6] = 'p' [7] = 'a' [8] = 't' [9] = 'h' } } } } +//@ lldb-command:po pathbuf +//@ lldb-check:"/some/path" +//@ lldb-command:print path +//@ lldb-check:[...] "/some/path" { data_ptr = [...] length = 10 } +//@ lldb-command:po path +//@ lldb-check:"/some/path" use std::path::Path; diff --git a/tests/debuginfo/pretty-huge-vec.rs b/tests/debuginfo/pretty-huge-vec.rs index c73491bf2806..2cea3f224c4a 100644 --- a/tests/debuginfo/pretty-huge-vec.rs +++ b/tests/debuginfo/pretty-huge-vec.rs @@ -6,13 +6,13 @@ // === GDB TESTS =================================================================================== -// gdb-command: run +//@ gdb-command: run -// gdb-command: print vec -// gdb-check:$1 = Vec(size=1000000000) = {[...]...} +//@ gdb-command: print vec +//@ gdb-check:$1 = Vec(size=1000000000) = {[...]...} -// gdb-command: print slice -// gdb-check:$2 = &[u8](size=1000000000) = {[...]...} +//@ gdb-command: print slice +//@ gdb-check:$2 = &[u8](size=1000000000) = {[...]...} #![allow(unused_variables)] diff --git a/tests/debuginfo/pretty-slices.rs b/tests/debuginfo/pretty-slices.rs index fd347a4eb933..e8813e00ae63 100644 --- a/tests/debuginfo/pretty-slices.rs +++ b/tests/debuginfo/pretty-slices.rs @@ -3,33 +3,33 @@ //@ compile-flags:-g //@ ignore-backends: gcc -// gdb-command: run +//@ gdb-command: run -// gdb-command: print slice -// gdb-check: $1 = &[i32](size=3) = {0, 1, 2} +//@ gdb-command: print slice +//@ gdb-check: $1 = &[i32](size=3) = {0, 1, 2} -// gdb-command: print mut_slice -// gdb-check: $2 = &mut [i32](size=4) = {2, 3, 5, 7} +//@ gdb-command: print mut_slice +//@ gdb-check: $2 = &mut [i32](size=4) = {2, 3, 5, 7} -// gdb-command: print str_slice -// gdb-check: $3 = "string slice" +//@ gdb-command: print str_slice +//@ gdb-check: $3 = "string slice" -// gdb-command: print mut_str_slice -// gdb-check: $4 = "mutable string slice" +//@ gdb-command: print mut_str_slice +//@ gdb-check: $4 = "mutable string slice" -// lldb-command:run +//@ lldb-command:run -// lldb-command:v slice -// lldb-check:(&[i32]) slice = size=3 { [0] = 0 [1] = 1 [2] = 2 } +//@ lldb-command:v slice +//@ lldb-check:(&[i32]) slice = size=3 { [0] = 0 [1] = 1 [2] = 2 } -// lldb-command:v mut_slice -// lldb-check:(&mut [i32]) mut_slice = size=4 { [0] = 2 [1] = 3 [2] = 5 [3] = 7 } +//@ lldb-command:v mut_slice +//@ lldb-check:(&mut [i32]) mut_slice = size=4 { [0] = 2 [1] = 3 [2] = 5 [3] = 7 } -// lldb-command:v str_slice -// lldb-check:(&str) str_slice = "string slice" { [0] = 's' [1] = 't' [2] = 'r' [3] = 'i' [4] = 'n' [5] = 'g' [6] = ' ' [7] = 's' [8] = 'l' [9] = 'i' [10] = 'c' [11] = 'e' } +//@ lldb-command:v str_slice +//@ lldb-check:(&str) str_slice = "string slice" { [0] = 's' [1] = 't' [2] = 'r' [3] = 'i' [4] = 'n' [5] = 'g' [6] = ' ' [7] = 's' [8] = 'l' [9] = 'i' [10] = 'c' [11] = 'e' } -// lldb-command:v mut_str_slice -// lldb-check:(&mut str) mut_str_slice = "mutable string slice" { [0] = 'm' [1] = 'u' [2] = 't' [3] = 'a' [4] = 'b' [5] = 'l' [6] = 'e' [7] = ' ' [8] = 's' [9] = 't' [10] = 'r' [11] = 'i' [12] = 'n' [13] = 'g' [14] = ' ' [15] = 's' [16] = 'l' [17] = 'i' [18] = 'c' [19] = 'e' } +//@ lldb-command:v mut_str_slice +//@ lldb-check:(&mut str) mut_str_slice = "mutable string slice" { [0] = 'm' [1] = 'u' [2] = 't' [3] = 'a' [4] = 'b' [5] = 'l' [6] = 'e' [7] = ' ' [8] = 's' [9] = 't' [10] = 'r' [11] = 'i' [12] = 'n' [13] = 'g' [14] = ' ' [15] = 's' [16] = 'l' [17] = 'i' [18] = 'c' [19] = 'e' } fn b() {} diff --git a/tests/debuginfo/pretty-std-collections-hash.rs b/tests/debuginfo/pretty-std-collections-hash.rs index 2504a60cbcd8..efedb21784af 100644 --- a/tests/debuginfo/pretty-std-collections-hash.rs +++ b/tests/debuginfo/pretty-std-collections-hash.rs @@ -7,77 +7,77 @@ // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx hash_set,d -// cdb-check:hash_set,d [...] : { len=15 } [Type: [...]::HashSet] -// cdb-check: [len] : 15 [Type: [...]] -// cdb-check: [capacity] : [...] -// cdb-check: [[...]] [...] : 0 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 1 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 2 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 3 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 4 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 5 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 6 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 7 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 8 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 9 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 10 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 11 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 12 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 13 [Type: u64] -// cdb-command: dx hash_set,d -// cdb-check: [[...]] [...] : 14 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check:hash_set,d [...] : { len=15 } [Type: [...]::HashSet] +//@ cdb-check: [len] : 15 [Type: [...]] +//@ cdb-check: [capacity] : [...] +//@ cdb-check: [[...]] [...] : 0 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 1 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 2 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 3 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 4 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 5 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 6 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 7 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 8 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 9 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 10 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 11 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 12 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 13 [Type: u64] +//@ cdb-command: dx hash_set,d +//@ cdb-check: [[...]] [...] : 14 [Type: u64] -// cdb-command: dx hash_map,d -// cdb-check:hash_map,d [...] : { len=15 } [Type: [...]::HashMap] -// cdb-check: [len] : 15 [Type: [...]] -// cdb-check: [capacity] : [...] -// cdb-check: ["0x0"] : 0 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0x1"] : 1 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0x2"] : 2 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0x3"] : 3 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0x4"] : 4 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0x5"] : 5 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0x6"] : 6 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0x7"] : 7 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0x8"] : 8 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0x9"] : 9 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0xa"] : 10 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0xb"] : 11 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0xc"] : 12 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0xd"] : 13 [Type: unsigned __int64] -// cdb-command: dx hash_map,d -// cdb-check: ["0xe"] : 14 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check:hash_map,d [...] : { len=15 } [Type: [...]::HashMap] +//@ cdb-check: [len] : 15 [Type: [...]] +//@ cdb-check: [capacity] : [...] +//@ cdb-check: ["0x0"] : 0 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0x1"] : 1 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0x2"] : 2 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0x3"] : 3 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0x4"] : 4 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0x5"] : 5 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0x6"] : 6 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0x7"] : 7 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0x8"] : 8 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0x9"] : 9 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0xa"] : 10 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0xb"] : 11 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0xc"] : 12 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0xd"] : 13 [Type: unsigned __int64] +//@ cdb-command: dx hash_map,d +//@ cdb-check: ["0xe"] : 14 [Type: unsigned __int64] -// cdb-command: dx x +//@ cdb-command: dx x #![allow(unused_variables)] use std::collections::HashSet; diff --git a/tests/debuginfo/pretty-std-collections.rs b/tests/debuginfo/pretty-std-collections.rs index 3592122375dd..85292cdad67a 100644 --- a/tests/debuginfo/pretty-std-collections.rs +++ b/tests/debuginfo/pretty-std-collections.rs @@ -5,64 +5,64 @@ // === GDB TESTS =================================================================================== -// gdb-command: run +//@ gdb-command: run -// gdb-command: print btree_set -// gdb-check:$1 = BTreeSet(size=15) = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14} +//@ gdb-command: print btree_set +//@ gdb-check:$1 = BTreeSet(size=15) = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14} -// gdb-command: print empty_btree_set -// gdb-check:$2 = BTreeSet(size=0) +//@ gdb-command: print empty_btree_set +//@ gdb-check:$2 = BTreeSet(size=0) -// gdb-command: print btree_map -// gdb-check:$3 = BTreeMap(size=15) = {[0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9, [10] = 10, [11] = 11, [12] = 12, [13] = 13, [14] = 14} +//@ gdb-command: print btree_map +//@ gdb-check:$3 = BTreeMap(size=15) = {[0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 5, [6] = 6, [7] = 7, [8] = 8, [9] = 9, [10] = 10, [11] = 11, [12] = 12, [13] = 13, [14] = 14} -// gdb-command: print empty_btree_map -// gdb-check:$4 = BTreeMap(size=0) +//@ gdb-command: print empty_btree_map +//@ gdb-check:$4 = BTreeMap(size=0) -// gdb-command: print option_btree_map -// gdb-check:$5 = BTreeMap(size=2) = {[false] = [...], [true] = [...]} +//@ gdb-command: print option_btree_map +//@ gdb-check:$5 = BTreeMap(size=2) = {[false] = [...], [true] = [...]} // (abbreviated because both values vary wildly over gdb versions and/or linux distributions) -// gdb-command: print nasty_btree_map -// gdb-check:$6 = BTreeMap(size=15) = {[0] = pretty_std_collections::MyLeafNode (0), [...]} +//@ gdb-command: print nasty_btree_map +//@ gdb-check:$6 = BTreeMap(size=15) = {[0] = pretty_std_collections::MyLeafNode (0), [...]} // (abbreviated because it's boring but we need enough elements to include internal nodes) -// gdb-command: print zst_key_btree_map -// gdb-check:$7 = BTreeMap(size=1) = {[()] = 1} +//@ gdb-command: print zst_key_btree_map +//@ gdb-check:$7 = BTreeMap(size=1) = {[()] = 1} -// gdb-command: print zst_val_btree_map -// gdb-check:$8 = BTreeMap(size=1) = {[1] = ()} +//@ gdb-command: print zst_val_btree_map +//@ gdb-check:$8 = BTreeMap(size=1) = {[1] = ()} -// gdb-command: print zst_key_val_btree_map -// gdb-check:$9 = BTreeMap(size=1) = {[()] = ()} +//@ gdb-command: print zst_key_val_btree_map +//@ gdb-check:$9 = BTreeMap(size=1) = {[()] = ()} -// gdb-command: print vec_deque -// gdb-check:$10 = VecDeque(size=3) = {5, 3, 7} +//@ gdb-command: print vec_deque +//@ gdb-check:$10 = VecDeque(size=3) = {5, 3, 7} -// gdb-command: print vec_deque2 -// gdb-check:$11 = VecDeque(size=7) = {2, 3, 4, 5, 6, 7, 8} +//@ gdb-command: print vec_deque2 +//@ gdb-check:$11 = VecDeque(size=7) = {2, 3, 4, 5, 6, 7, 8} -// gdb-command: print hash_map -// gdb-check:$12 = HashMap(size=4) = {[1] = 10, [2] = 20, [3] = 30, [4] = 40} +//@ gdb-command: print hash_map +//@ gdb-check:$12 = HashMap(size=4) = {[1] = 10, [2] = 20, [3] = 30, [4] = 40} -// gdb-command: print hash_set -// gdb-check:$13 = HashSet(size=4) = {1, 2, 3, 4} +//@ gdb-command: print hash_set +//@ gdb-check:$13 = HashSet(size=4) = {1, 2, 3, 4} // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v vec_deque -// lldb-check:[...] size=3 { [0] = 5 [1] = 3 [2] = 7 } +//@ lldb-command:v vec_deque +//@ lldb-check:[...] size=3 { [0] = 5 [1] = 3 [2] = 7 } -// lldb-command:v vec_deque2 -// lldb-check:[...] size=7 { [0] = 2 [1] = 3 [2] = 4 [3] = 5 [4] = 6 [5] = 7 [6] = 8 } +//@ lldb-command:v vec_deque2 +//@ lldb-check:[...] size=7 { [0] = 2 [1] = 3 [2] = 4 [3] = 5 [4] = 6 [5] = 7 [6] = 8 } -// lldb-command:v hash_map -// lldb-check:[...] size=4 { [0] = (1, 10) { 0 = 1 1 = 10 } [1] = (2, 20) { 0 = 2 1 = 20 } [2] = (3, 30) { 0 = 3 1 = 30 } [3] = (4, 40) { 0 = 4 1 = 40 } } +//@ lldb-command:v hash_map +//@ lldb-check:[...] size=4 { [0] = (1, 10) { 0 = 1 1 = 10 } [1] = (2, 20) { 0 = 2 1 = 20 } [2] = (3, 30) { 0 = 3 1 = 30 } [3] = (4, 40) { 0 = 4 1 = 40 } } -// lldb-command:v hash_set -// lldb-check:[...] size=4 { [0] = 1 [1] = 2 [2] = 3 [3] = 4 } +//@ lldb-command:v hash_set +//@ lldb-check:[...] size=4 { [0] = 1 [1] = 2 [2] = 3 [3] = 4 } #![allow(unused_variables)] use std::collections::BTreeMap; diff --git a/tests/debuginfo/pretty-std.rs b/tests/debuginfo/pretty-std.rs index 2620557eaf99..d4cb2f6625f4 100644 --- a/tests/debuginfo/pretty-std.rs +++ b/tests/debuginfo/pretty-std.rs @@ -8,140 +8,140 @@ // === GDB TESTS =================================================================================== -// gdb-command: run +//@ gdb-command: run -// gdb-command: print slice -// gdb-check:$1 = &[i32](size=4) = {0, 1, 2, 3} +//@ gdb-command: print slice +//@ gdb-check:$1 = &[i32](size=4) = {0, 1, 2, 3} -// gdb-command: print vec -// gdb-check:$2 = Vec(size=4) = {4, 5, 6, 7} +//@ gdb-command: print vec +//@ gdb-check:$2 = Vec(size=4) = {4, 5, 6, 7} -// gdb-command: print str_slice -// gdb-check:$3 = "IAMA string slice!" +//@ gdb-command: print str_slice +//@ gdb-check:$3 = "IAMA string slice!" -// gdb-command: print string -// gdb-check:$4 = "IAMA string!" +//@ gdb-command: print string +//@ gdb-check:$4 = "IAMA string!" -// gdb-command: print some -// gdb-check:$5 = core::option::Option::Some(8) +//@ gdb-command: print some +//@ gdb-check:$5 = core::option::Option::Some(8) -// gdb-command: print none -// gdb-check:$6 = core::option::Option::None +//@ gdb-command: print none +//@ gdb-check:$6 = core::option::Option::None -// gdb-command: print os_string -// gdb-check:$7 = "IAMA OS string 😃" +//@ gdb-command: print os_string +//@ gdb-check:$7 = "IAMA OS string 😃" -// gdb-command: print some_string -// gdb-check:$8 = core::option::Option::Some("IAMA optional string!") +//@ gdb-command: print some_string +//@ gdb-check:$8 = core::option::Option::Some("IAMA optional string!") -// gdb-command: set print elements 5 -// gdb-command: print some_string -// gdb-check:$9 = core::option::Option::Some("IAMA "...) +//@ gdb-command: set print elements 5 +//@ gdb-command: print some_string +//@ gdb-check:$9 = core::option::Option::Some("IAMA "...) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v slice -// lldb-check:[...] slice = size=4 { [0] = 0 [1] = 1 [2] = 2 [3] = 3 } +//@ lldb-command:v slice +//@ lldb-check:[...] slice = size=4 { [0] = 0 [1] = 1 [2] = 2 [3] = 3 } -// lldb-command:v vec -// lldb-check:[...] vec = size=4 { [0] = 4 [1] = 5 [2] = 6 [3] = 7 } +//@ lldb-command:v vec +//@ lldb-check:[...] vec = size=4 { [0] = 4 [1] = 5 [2] = 6 [3] = 7 } -// lldb-command:v str_slice -// lldb-check:[...] str_slice = "IAMA string slice!" { [0] = 'I' [1] = 'A' [2] = 'M' [3] = 'A' [4] = ' ' [5] = 's' [6] = 't' [7] = 'r' [8] = 'i' [9] = 'n' [10] = 'g' [11] = ' ' [12] = 's' [13] = 'l' [14] = 'i' [15] = 'c' [16] = 'e' [17] = '!' } +//@ lldb-command:v str_slice +//@ lldb-check:[...] str_slice = "IAMA string slice!" { [0] = 'I' [1] = 'A' [2] = 'M' [3] = 'A' [4] = ' ' [5] = 's' [6] = 't' [7] = 'r' [8] = 'i' [9] = 'n' [10] = 'g' [11] = ' ' [12] = 's' [13] = 'l' [14] = 'i' [15] = 'c' [16] = 'e' [17] = '!' } -// lldb-command:v string -// lldb-check:[...] string = "IAMA string!" { [0] = 'I' [1] = 'A' [2] = 'M' [3] = 'A' [4] = ' ' [5] = 's' [6] = 't' [7] = 'r' [8] = 'i' [9] = 'n' [10] = 'g' [11] = '!' } +//@ lldb-command:v string +//@ lldb-check:[...] string = "IAMA string!" { [0] = 'I' [1] = 'A' [2] = 'M' [3] = 'A' [4] = ' ' [5] = 's' [6] = 't' [7] = 'r' [8] = 'i' [9] = 'n' [10] = 'g' [11] = '!' } -// lldb-command:v some -// lldb-check:[...] some = Some(8) +//@ lldb-command:v some +//@ lldb-check:[...] some = Some(8) -// lldb-command:v none -// lldb-check:[...] none = None +//@ lldb-command:v none +//@ lldb-check:[...] none = None -// lldb-command:v os_string -// lldb-check:[...] os_string = "IAMA OS string 😃" { inner = { inner = size=19 { [0] = 'I' [1] = 'A' [2] = 'M' [3] = 'A' [4] = ' ' [5] = 'O' [6] = 'S' [7] = ' ' [8] = 's' [9] = 't' [10] = 'r' [11] = 'i' [12] = 'n' [13] = 'g' [14] = ' ' [15] = '\xf0' [16] = '\x9f' [17] = '\x98' [18] = '\x83' } } } +//@ lldb-command:v os_string +//@ lldb-check:[...] os_string = "IAMA OS string 😃" { inner = { inner = size=19 { [0] = 'I' [1] = 'A' [2] = 'M' [3] = 'A' [4] = ' ' [5] = 'O' [6] = 'S' [7] = ' ' [8] = 's' [9] = 't' [10] = 'r' [11] = 'i' [12] = 'n' [13] = 'g' [14] = ' ' [15] = '\xf0' [16] = '\x9f' [17] = '\x98' [18] = '\x83' } } } // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx slice,d -// cdb-check:slice,d : { len=4 } [Type: ref$ >] -// cdb-check: [len] : 4 [Type: [...]] -// cdb-check: [0] : 0 [Type: int] -// cdb-check: [1] : 1 [Type: int] -// cdb-check: [2] : 2 [Type: int] -// cdb-check: [3] : 3 [Type: int] +//@ cdb-command: dx slice,d +//@ cdb-check:slice,d : { len=4 } [Type: ref$ >] +//@ cdb-check: [len] : 4 [Type: [...]] +//@ cdb-check: [0] : 0 [Type: int] +//@ cdb-check: [1] : 1 [Type: int] +//@ cdb-check: [2] : 2 [Type: int] +//@ cdb-check: [3] : 3 [Type: int] -// cdb-command: dx vec,d -// cdb-check:vec,d [...] : { len=4 } [Type: [...]::Vec] -// cdb-check: [len] : 4 [Type: [...]] -// cdb-check: [capacity] : [...] [Type: [...]] -// cdb-check: [0] : 4 [Type: u64] -// cdb-check: [1] : 5 [Type: u64] -// cdb-check: [2] : 6 [Type: u64] -// cdb-check: [3] : 7 [Type: u64] +//@ cdb-command: dx vec,d +//@ cdb-check:vec,d [...] : { len=4 } [Type: [...]::Vec] +//@ cdb-check: [len] : 4 [Type: [...]] +//@ cdb-check: [capacity] : [...] [Type: [...]] +//@ cdb-check: [0] : 4 [Type: u64] +//@ cdb-check: [1] : 5 [Type: u64] +//@ cdb-check: [2] : 6 [Type: u64] +//@ cdb-check: [3] : 7 [Type: u64] -// cdb-command: dx str_slice -// cdb-check:str_slice : "IAMA string slice!" [Type: ref$] +//@ cdb-command: dx str_slice +//@ cdb-check:str_slice : "IAMA string slice!" [Type: ref$] -// cdb-command: dx string -// cdb-check:string : "IAMA string!" [Type: [...]::String] -// cdb-check: [] [Type: [...]::String] -// cdb-check: [len] : 0xc [Type: [...]] -// cdb-check: [capacity] : 0xc [Type: [...]] +//@ cdb-command: dx string +//@ cdb-check:string : "IAMA string!" [Type: [...]::String] +//@ cdb-check: [] [Type: [...]::String] +//@ cdb-check: [len] : 0xc [Type: [...]] +//@ cdb-check: [capacity] : 0xc [Type: [...]] -// cdb-command: dx -r2 string -// cdb-check: [0] : 73 'I' [Type: char] -// cdb-check: [1] : 65 'A' [Type: char] -// cdb-check: [2] : 77 'M' [Type: char] -// cdb-check: [3] : 65 'A' [Type: char] -// cdb-check: [4] : 32 ' ' [Type: char] -// cdb-check: [5] : 115 's' [Type: char] -// cdb-check: [6] : 116 't' [Type: char] -// cdb-check: [7] : 114 'r' [Type: char] -// cdb-check: [8] : 105 'i' [Type: char] -// cdb-check: [9] : 110 'n' [Type: char] -// cdb-check: [10] : 103 'g' [Type: char] -// cdb-check: [11] : 33 '!' [Type: char] +//@ cdb-command: dx -r2 string +//@ cdb-check: [0] : 73 'I' [Type: char] +//@ cdb-check: [1] : 65 'A' [Type: char] +//@ cdb-check: [2] : 77 'M' [Type: char] +//@ cdb-check: [3] : 65 'A' [Type: char] +//@ cdb-check: [4] : 32 ' ' [Type: char] +//@ cdb-check: [5] : 115 's' [Type: char] +//@ cdb-check: [6] : 116 't' [Type: char] +//@ cdb-check: [7] : 114 'r' [Type: char] +//@ cdb-check: [8] : 105 'i' [Type: char] +//@ cdb-check: [9] : 110 'n' [Type: char] +//@ cdb-check: [10] : 103 'g' [Type: char] +//@ cdb-check: [11] : 33 '!' [Type: char] -// cdb-command: dx os_string +//@ cdb-command: dx os_string // NOTE: OSString is WTF-8 encoded which Windows debuggers don't understand. Verify the UTF-8 // portion displays correctly. -// cdb-check:os_string : "IAMA OS string [...]" [Type: std::ffi::os_str::OsString] -// cdb-check: [] [Type: std::ffi::os_str::OsString] -// cdb-check: [chars] : "IAMA OS string [...]" +//@ cdb-check:os_string : "IAMA OS string [...]" [Type: std::ffi::os_str::OsString] +//@ cdb-check: [] [Type: std::ffi::os_str::OsString] +//@ cdb-check: [chars] : "IAMA OS string [...]" -// cdb-command: dx some -// cdb-check:some : Some [Type: enum2$ >] -// cdb-check: [] [Type: enum2$ >] -// cdb-check: [+0x002] __0 : 8 [Type: short] +//@ cdb-command: dx some +//@ cdb-check:some : Some [Type: enum2$ >] +//@ cdb-check: [] [Type: enum2$ >] +//@ cdb-check: [+0x002] __0 : 8 [Type: short] -// cdb-command: dx none -// cdb-check:none : None [Type: enum2$ >] -// cdb-check: [] [Type: enum2$ >] +//@ cdb-command: dx none +//@ cdb-check:none : None [Type: enum2$ >] +//@ cdb-check: [] [Type: enum2$ >] -// cdb-command: dx some_string -// cdb-check:some_string : Some [Type: enum2$ >] -// cdb-check: [] [Type: enum2$ >] -// cdb-check: [+0x000] __0 : "IAMA optional string!" [Type: alloc::string::String] +//@ cdb-command: dx some_string +//@ cdb-check:some_string : Some [Type: enum2$ >] +//@ cdb-check: [] [Type: enum2$ >] +//@ cdb-check: [+0x000] __0 : "IAMA optional string!" [Type: alloc::string::String] -// cdb-command: dx linkedlist -// cdb-check:linkedlist : { len=0x2 } [Type: alloc::collections::linked_list::LinkedList] -// cdb-check: [] [Type: alloc::collections::linked_list::LinkedList] -// cdb-check: [0x0] : 128 [Type: int] -// cdb-check: [0x1] : 42 [Type: int] +//@ cdb-command: dx linkedlist +//@ cdb-check:linkedlist : { len=0x2 } [Type: alloc::collections::linked_list::LinkedList] +//@ cdb-check: [] [Type: alloc::collections::linked_list::LinkedList] +//@ cdb-check: [0x0] : 128 [Type: int] +//@ cdb-check: [0x1] : 42 [Type: int] -// cdb-command: dx vecdeque -// cdb-check:vecdeque : { len=0x2 } [Type: alloc::collections::vec_deque::VecDeque] -// cdb-check: [] [Type: alloc::collections::vec_deque::VecDeque] -// cdb-check: [len] : 0x2 [Type: unsigned [...]] -// cdb-check: [capacity] : 0x8 [Type: unsigned [...]] -// cdb-check: [0x0] : 90 [Type: i32] -// cdb-check: [0x1] : 20 [Type: i32] +//@ cdb-command: dx vecdeque +//@ cdb-check:vecdeque : { len=0x2 } [Type: alloc::collections::vec_deque::VecDeque] +//@ cdb-check: [] [Type: alloc::collections::vec_deque::VecDeque] +//@ cdb-check: [len] : 0x2 [Type: unsigned [...]] +//@ cdb-check: [capacity] : 0x8 [Type: unsigned [...]] +//@ cdb-check: [0x0] : 90 [Type: i32] +//@ cdb-check: [0x1] : 20 [Type: i32] #![allow(unused_variables)] use std::collections::{LinkedList, VecDeque}; diff --git a/tests/debuginfo/pretty-uninitialized-vec.rs b/tests/debuginfo/pretty-uninitialized-vec.rs index e5a2df5c9345..f3e02fa06f9f 100644 --- a/tests/debuginfo/pretty-uninitialized-vec.rs +++ b/tests/debuginfo/pretty-uninitialized-vec.rs @@ -5,10 +5,10 @@ // === GDB TESTS =================================================================================== -// gdb-command: run +//@ gdb-command: run -// gdb-command: print vec -// gdb-check:$1 = Vec(size=[...])[...] +//@ gdb-command: print vec +//@ gdb-check:$1 = Vec(size=[...])[...] #![allow(unused_variables)] diff --git a/tests/debuginfo/range-types.rs b/tests/debuginfo/range-types.rs index 068a55a57672..f54773f7987f 100644 --- a/tests/debuginfo/range-types.rs +++ b/tests/debuginfo/range-types.rs @@ -9,33 +9,33 @@ // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx r1,d -// cdb-check:r1,d : (3..5) [Type: core::ops::range::Range] -// cdb-check: [+0x000] start : 3 [Type: int] -// cdb-check: [+0x004] end : 5 [Type: int] +//@ cdb-command: dx r1,d +//@ cdb-check:r1,d : (3..5) [Type: core::ops::range::Range] +//@ cdb-check: [+0x000] start : 3 [Type: int] +//@ cdb-check: [+0x004] end : 5 [Type: int] -// cdb-command: dx r2,d -// cdb-check:r2,d : (2..) [Type: core::ops::range::RangeFrom] -// cdb-check: [+0x000] start : 2 [Type: int] +//@ cdb-command: dx r2,d +//@ cdb-check:r2,d : (2..) [Type: core::ops::range::RangeFrom] +//@ cdb-check: [+0x000] start : 2 [Type: int] -// cdb-command: dx r3,d -// cdb-check:r3,d : (1..=4) [Type: core::ops::range::RangeInclusive] -// cdb-check: [+0x000] start : 1 [Type: int] -// cdb-check: [+0x004] end : 4 [Type: int] -// cdb-check: [+0x008] exhausted : false [Type: bool] +//@ cdb-command: dx r3,d +//@ cdb-check:r3,d : (1..=4) [Type: core::ops::range::RangeInclusive] +//@ cdb-check: [+0x000] start : 1 [Type: int] +//@ cdb-check: [+0x004] end : 4 [Type: int] +//@ cdb-check: [+0x008] exhausted : false [Type: bool] -// cdb-command: dx r4,d -// cdb-check:r4,d : (..10) [Type: core::ops::range::RangeTo] -// cdb-check: [+0x000] end : 10 [Type: int] +//@ cdb-command: dx r4,d +//@ cdb-check:r4,d : (..10) [Type: core::ops::range::RangeTo] +//@ cdb-check: [+0x000] end : 10 [Type: int] -// cdb-command: dx r5,d -// cdb-check:r5,d : (..=3) [Type: core::ops::range::RangeToInclusive] -// cdb-check: [+0x000] end : 3 [Type: int] +//@ cdb-command: dx r5,d +//@ cdb-check:r5,d : (..=3) [Type: core::ops::range::RangeToInclusive] +//@ cdb-check: [+0x000] end : 3 [Type: int] -// cdb-command: dx r6,d -// cdb-check:r6,d [Type: core::ops::range::RangeFull] +//@ cdb-command: dx r6,d +//@ cdb-check:r6,d [Type: core::ops::range::RangeFull] #[allow(unused_variables)] diff --git a/tests/debuginfo/rc_arc.rs b/tests/debuginfo/rc_arc.rs index c439ff7484fe..a2eeeaad6aa8 100644 --- a/tests/debuginfo/rc_arc.rs +++ b/tests/debuginfo/rc_arc.rs @@ -6,101 +6,101 @@ // === GDB TESTS ================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print rc -// gdb-check:[...]$1 = Rc(strong=11, weak=1) = {value = 111, strong = 11, weak = 1} -// gdb-command:print arc -// gdb-check:[...]$2 = Arc(strong=21, weak=1) = {value = 222, strong = 21, weak = 1} +//@ gdb-command:print rc +//@ gdb-check:[...]$1 = Rc(strong=11, weak=1) = {value = 111, strong = 11, weak = 1} +//@ gdb-command:print arc +//@ gdb-check:[...]$2 = Arc(strong=21, weak=1) = {value = 222, strong = 21, weak = 1} // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v rc -// lldb-check:[...] strong=11, weak=1 { value = 111 } -// lldb-command:v arc -// lldb-check:[...] strong=21, weak=1 { data = 222 } +//@ lldb-command:v rc +//@ lldb-check:[...] strong=11, weak=1 { value = 111 } +//@ lldb-command:v arc +//@ lldb-check:[...] strong=21, weak=1 { data = 222 } // === CDB TESTS ================================================================================== -// cdb-command:g +//@ cdb-command:g -// cdb-command:dx rc,d -// cdb-check:rc,d : 111 [Type: alloc::rc::Rc] -// cdb-check: [Reference count] : 11 [Type: core::cell::Cell] -// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] +//@ cdb-command:dx rc,d +//@ cdb-check:rc,d : 111 [Type: alloc::rc::Rc] +//@ cdb-check: [Reference count] : 11 [Type: core::cell::Cell] +//@ cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] -// cdb-command:dx weak_rc,d -// cdb-check:weak_rc,d : 111 [Type: alloc::rc::Weak] -// cdb-check: [Reference count] : 11 [Type: core::cell::Cell] -// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] +//@ cdb-command:dx weak_rc,d +//@ cdb-check:weak_rc,d : 111 [Type: alloc::rc::Weak] +//@ cdb-check: [Reference count] : 11 [Type: core::cell::Cell] +//@ cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] -// cdb-command:dx arc,d -// cdb-check:arc,d : 222 [Type: alloc::sync::Arc] -// cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] -// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-command:dx arc,d +//@ cdb-check:arc,d : 222 [Type: alloc::sync::Arc] +//@ cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] -// cdb-command:dx weak_arc,d -// cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak] -// cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] -// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-command:dx weak_arc,d +//@ cdb-check:weak_arc,d : 222 [Type: alloc::sync::Weak] +//@ cdb-check: [Reference count] : 21 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] -// cdb-command:dx dyn_rc,d -// cdb-check:dyn_rc,d [Type: alloc::rc::Rc,alloc::alloc::Global>] -// cdb-check: [Reference count] : 31 [Type: core::cell::Cell] -// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] +//@ cdb-command:dx dyn_rc,d +//@ cdb-check:dyn_rc,d [Type: alloc::rc::Rc,alloc::alloc::Global>] +//@ cdb-check: [Reference count] : 31 [Type: core::cell::Cell] +//@ cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] -// cdb-command:dx dyn_rc_weak,d -// cdb-check:dyn_rc_weak,d [Type: alloc::rc::Weak,alloc::alloc::Global>] -// cdb-check: [Reference count] : 31 [Type: core::cell::Cell] -// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] +//@ cdb-command:dx dyn_rc_weak,d +//@ cdb-check:dyn_rc_weak,d [Type: alloc::rc::Weak,alloc::alloc::Global>] +//@ cdb-check: [Reference count] : 31 [Type: core::cell::Cell] +//@ cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] -// cdb-command:dx slice_rc,d -// cdb-check:slice_rc,d : { len=3 } [Type: alloc::rc::Rc,alloc::alloc::Global>] -// cdb-check: [Length] : 3 [Type: [...]] -// cdb-check: [Reference count] : 41 [Type: core::cell::Cell] -// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] -// cdb-check: [0] : 1 [Type: u32] -// cdb-check: [1] : 2 [Type: u32] -// cdb-check: [2] : 3 [Type: u32] +//@ cdb-command:dx slice_rc,d +//@ cdb-check:slice_rc,d : { len=3 } [Type: alloc::rc::Rc,alloc::alloc::Global>] +//@ cdb-check: [Length] : 3 [Type: [...]] +//@ cdb-check: [Reference count] : 41 [Type: core::cell::Cell] +//@ cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] +//@ cdb-check: [0] : 1 [Type: u32] +//@ cdb-check: [1] : 2 [Type: u32] +//@ cdb-check: [2] : 3 [Type: u32] -// cdb-command:dx slice_rc_weak,d -// cdb-check:slice_rc_weak,d : { len=3 } [Type: alloc::rc::Weak,alloc::alloc::Global>] -// cdb-check: [Length] : 3 [Type: [...]] -// cdb-check: [Reference count] : 41 [Type: core::cell::Cell] -// cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] -// cdb-check: [0] : 1 [Type: u32] -// cdb-check: [1] : 2 [Type: u32] -// cdb-check: [2] : 3 [Type: u32] +//@ cdb-command:dx slice_rc_weak,d +//@ cdb-check:slice_rc_weak,d : { len=3 } [Type: alloc::rc::Weak,alloc::alloc::Global>] +//@ cdb-check: [Length] : 3 [Type: [...]] +//@ cdb-check: [Reference count] : 41 [Type: core::cell::Cell] +//@ cdb-check: [Weak reference count] : 2 [Type: core::cell::Cell] +//@ cdb-check: [0] : 1 [Type: u32] +//@ cdb-check: [1] : 2 [Type: u32] +//@ cdb-check: [2] : 3 [Type: u32] -// cdb-command:dx dyn_arc,d -// cdb-check:dyn_arc,d [Type: alloc::sync::Arc,alloc::alloc::Global>] -// cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] -// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-command:dx dyn_arc,d +//@ cdb-check:dyn_arc,d [Type: alloc::sync::Arc,alloc::alloc::Global>] +//@ cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] -// cdb-command:dx dyn_arc_weak,d -// cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak,alloc::alloc::Global>] -// cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] -// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-command:dx dyn_arc_weak,d +//@ cdb-check:dyn_arc_weak,d [Type: alloc::sync::Weak,alloc::alloc::Global>] +//@ cdb-check: [Reference count] : 51 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] -// cdb-command:dx slice_arc,d -// cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc,alloc::alloc::Global>] -// cdb-check: [Length] : 3 [Type: [...]] -// cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] -// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] -// cdb-check: [0] : 4 [Type: u32] -// cdb-check: [1] : 5 [Type: u32] -// cdb-check: [2] : 6 [Type: u32] +//@ cdb-command:dx slice_arc,d +//@ cdb-check:slice_arc,d : { len=3 } [Type: alloc::sync::Arc,alloc::alloc::Global>] +//@ cdb-check: [Length] : 3 [Type: [...]] +//@ cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [0] : 4 [Type: u32] +//@ cdb-check: [1] : 5 [Type: u32] +//@ cdb-check: [2] : 6 [Type: u32] -// cdb-command:dx slice_arc_weak,d -// cdb-check:slice_arc_weak,d : { len=3 } [Type: alloc::sync::Weak,alloc::alloc::Global>] -// cdb-check: [Length] : 3 [Type: [...]] -// cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] -// cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] -// cdb-check: [0] : 4 [Type: u32] -// cdb-check: [1] : 5 [Type: u32] -// cdb-check: [2] : 6 [Type: u32] +//@ cdb-command:dx slice_arc_weak,d +//@ cdb-check:slice_arc_weak,d : { len=3 } [Type: alloc::sync::Weak,alloc::alloc::Global>] +//@ cdb-check: [Length] : 3 [Type: [...]] +//@ cdb-check: [Reference count] : 61 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [Weak reference count] : 2 [Type: core::sync::atomic::AtomicUsize] +//@ cdb-check: [0] : 4 [Type: u32] +//@ cdb-check: [1] : 5 [Type: u32] +//@ cdb-check: [2] : 6 [Type: u32] use std::fmt::Debug; use std::rc::Rc; diff --git a/tests/debuginfo/recursive-enum.rs b/tests/debuginfo/recursive-enum.rs index 5fb339f54f39..bb139cb8541b 100644 --- a/tests/debuginfo/recursive-enum.rs +++ b/tests/debuginfo/recursive-enum.rs @@ -2,7 +2,7 @@ //@ compile-flags:-g //@ disable-gdb-pretty-printers -// gdb-command:run +//@ gdb-command:run // Test whether compiling a recursive enum definition crashes debug info generation. The test case // is taken from issue #11083 and #135093. diff --git a/tests/debuginfo/recursive-struct.rs b/tests/debuginfo/recursive-struct.rs index 723ab06a8b26..a01c6c0ceca5 100644 --- a/tests/debuginfo/recursive-struct.rs +++ b/tests/debuginfo/recursive-struct.rs @@ -4,60 +4,60 @@ //@ disable-gdb-pretty-printers //@ ignore-backends: gcc -// gdb-command:run +//@ gdb-command:run -// gdb-command:print stack_unique.value -// gdb-check:$1 = 0 -// gdb-command:print stack_unique.next.val.value -// gdb-check:$2 = 1 +//@ gdb-command:print stack_unique.value +//@ gdb-check:$1 = 0 +//@ gdb-command:print stack_unique.next.val.value +//@ gdb-check:$2 = 1 -// gdb-command:print unique_unique.value -// gdb-check:$3 = 2 -// gdb-command:print unique_unique.next.val.value -// gdb-check:$4 = 3 +//@ gdb-command:print unique_unique.value +//@ gdb-check:$3 = 2 +//@ gdb-command:print unique_unique.next.val.value +//@ gdb-check:$4 = 3 -// gdb-command:print vec_unique[0].value -// gdb-check:$5 = 6.5 -// gdb-command:print vec_unique[0].next.val.value -// gdb-check:$6 = 7.5 +//@ gdb-command:print vec_unique[0].value +//@ gdb-check:$5 = 6.5 +//@ gdb-command:print vec_unique[0].next.val.value +//@ gdb-check:$6 = 7.5 -// gdb-command:print borrowed_unique.value -// gdb-check:$7 = 8.5 -// gdb-command:print borrowed_unique.next.val.value -// gdb-check:$8 = 9.5 +//@ gdb-command:print borrowed_unique.value +//@ gdb-check:$7 = 8.5 +//@ gdb-command:print borrowed_unique.next.val.value +//@ gdb-check:$8 = 9.5 // LONG CYCLE -// gdb-command:print long_cycle1.value -// gdb-check:$9 = 20 -// gdb-command:print long_cycle1.next.value -// gdb-check:$10 = 21 -// gdb-command:print long_cycle1.next.next.value -// gdb-check:$11 = 22 -// gdb-command:print long_cycle1.next.next.next.value -// gdb-check:$12 = 23 +//@ gdb-command:print long_cycle1.value +//@ gdb-check:$9 = 20 +//@ gdb-command:print long_cycle1.next.value +//@ gdb-check:$10 = 21 +//@ gdb-command:print long_cycle1.next.next.value +//@ gdb-check:$11 = 22 +//@ gdb-command:print long_cycle1.next.next.next.value +//@ gdb-check:$12 = 23 -// gdb-command:print long_cycle2.value -// gdb-check:$13 = 24 -// gdb-command:print long_cycle2.next.value -// gdb-check:$14 = 25 -// gdb-command:print long_cycle2.next.next.value -// gdb-check:$15 = 26 +//@ gdb-command:print long_cycle2.value +//@ gdb-check:$13 = 24 +//@ gdb-command:print long_cycle2.next.value +//@ gdb-check:$14 = 25 +//@ gdb-command:print long_cycle2.next.next.value +//@ gdb-check:$15 = 26 -// gdb-command:print long_cycle3.value -// gdb-check:$16 = 27 -// gdb-command:print long_cycle3.next.value -// gdb-check:$17 = 28 +//@ gdb-command:print long_cycle3.value +//@ gdb-check:$16 = 27 +//@ gdb-command:print long_cycle3.next.value +//@ gdb-check:$17 = 28 -// gdb-command:print long_cycle4.value -// gdb-check:$18 = 29.5 +//@ gdb-command:print long_cycle4.value +//@ gdb-check:$18 = 29.5 -// gdb-command:print long_cycle_w_anon_types.value -// gdb-check:$19 = 30 +//@ gdb-command:print long_cycle_w_anon_types.value +//@ gdb-check:$19 = 30 -// gdb-command:print long_cycle_w_anon_types.next.val.value -// gdb-check:$20 = 31 +//@ gdb-command:print long_cycle_w_anon_types.next.val.value +//@ gdb-check:$20 = 31 -// gdb-command:continue +//@ gdb-command:continue #![allow(unused_variables)] diff --git a/tests/debuginfo/reference-debuginfo.rs b/tests/debuginfo/reference-debuginfo.rs index 75acbc131a8c..14e5d798195b 100644 --- a/tests/debuginfo/reference-debuginfo.rs +++ b/tests/debuginfo/reference-debuginfo.rs @@ -8,104 +8,104 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print *bool_ref -// gdb-check:$1 = true +//@ gdb-command:run +//@ gdb-command:print *bool_ref +//@ gdb-check:$1 = true -// gdb-command:print *int_ref -// gdb-check:$2 = -1 +//@ gdb-command:print *int_ref +//@ gdb-check:$2 = -1 -// gdb-command:print/d *char_ref -// gdb-check:$3 = 97 +//@ gdb-command:print/d *char_ref +//@ gdb-check:$3 = 97 -// gdb-command:print *i8_ref -// gdb-check:$4 = 68 +//@ gdb-command:print *i8_ref +//@ gdb-check:$4 = 68 -// gdb-command:print *i16_ref -// gdb-check:$5 = -16 +//@ gdb-command:print *i16_ref +//@ gdb-check:$5 = -16 -// gdb-command:print *i32_ref -// gdb-check:$6 = -32 +//@ gdb-command:print *i32_ref +//@ gdb-check:$6 = -32 -// gdb-command:print *i64_ref -// gdb-check:$7 = -64 +//@ gdb-command:print *i64_ref +//@ gdb-check:$7 = -64 -// gdb-command:print *uint_ref -// gdb-check:$8 = 1 +//@ gdb-command:print *uint_ref +//@ gdb-check:$8 = 1 -// gdb-command:print *u8_ref -// gdb-check:$9 = 100 +//@ gdb-command:print *u8_ref +//@ gdb-check:$9 = 100 -// gdb-command:print *u16_ref -// gdb-check:$10 = 16 +//@ gdb-command:print *u16_ref +//@ gdb-check:$10 = 16 -// gdb-command:print *u32_ref -// gdb-check:$11 = 32 +//@ gdb-command:print *u32_ref +//@ gdb-check:$11 = 32 -// gdb-command:print *u64_ref -// gdb-check:$12 = 64 +//@ gdb-command:print *u64_ref +//@ gdb-check:$12 = 64 -// gdb-command:print *f16_ref -// gdb-check:$13 = 1.5 +//@ gdb-command:print *f16_ref +//@ gdb-check:$13 = 1.5 -// gdb-command:print *f32_ref -// gdb-check:$14 = 2.5 +//@ gdb-command:print *f32_ref +//@ gdb-check:$14 = 2.5 -// gdb-command:print *f64_ref -// gdb-check:$15 = 3.5 +//@ gdb-command:print *f64_ref +//@ gdb-check:$15 = 3.5 -// gdb-command:print *f64_double_ref -// gdb-check:$16 = 3.5 +//@ gdb-command:print *f64_double_ref +//@ gdb-check:$16 = 3.5 // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v *bool_ref -// lldb-check:[...] true +//@ lldb-command:run +//@ lldb-command:v *bool_ref +//@ lldb-check:[...] true -// lldb-command:v *int_ref -// lldb-check:[...] -1 +//@ lldb-command:v *int_ref +//@ lldb-check:[...] -1 -// lldb-command:v *i8_ref -// lldb-check:[...] 'D' +//@ lldb-command:v *i8_ref +//@ lldb-check:[...] 'D' -// lldb-command:v *i16_ref -// lldb-check:[...] -16 +//@ lldb-command:v *i16_ref +//@ lldb-check:[...] -16 -// lldb-command:v *i32_ref -// lldb-check:[...] -32 +//@ lldb-command:v *i32_ref +//@ lldb-check:[...] -32 -// lldb-command:v *i64_ref -// lldb-check:[...] -64 +//@ lldb-command:v *i64_ref +//@ lldb-check:[...] -64 -// lldb-command:v *uint_ref -// lldb-check:[...] 1 +//@ lldb-command:v *uint_ref +//@ lldb-check:[...] 1 -// lldb-command:v *u8_ref -// lldb-check:[...] 'd' +//@ lldb-command:v *u8_ref +//@ lldb-check:[...] 'd' -// lldb-command:v *u16_ref -// lldb-check:[...] 16 +//@ lldb-command:v *u16_ref +//@ lldb-check:[...] 16 -// lldb-command:v *u32_ref -// lldb-check:[...] 32 +//@ lldb-command:v *u32_ref +//@ lldb-check:[...] 32 -// lldb-command:v *u64_ref -// lldb-check:[...] 64 +//@ lldb-command:v *u64_ref +//@ lldb-check:[...] 64 -// lldb-command:v *f16_ref -// lldb-check:[...] 1.5 +//@ lldb-command:v *f16_ref +//@ lldb-check:[...] 1.5 -// lldb-command:v *f32_ref -// lldb-check:[...] 2.5 +//@ lldb-command:v *f32_ref +//@ lldb-check:[...] 2.5 -// lldb-command:v *f64_ref -// lldb-check:[...] 3.5 +//@ lldb-command:v *f64_ref +//@ lldb-check:[...] 3.5 -// lldb-command:v *f64_double_ref -// lldb-check:[...] 3.5 +//@ lldb-command:v *f64_double_ref +//@ lldb-check:[...] 3.5 #![allow(unused_variables)] #![feature(f16)] diff --git a/tests/debuginfo/regression-bad-location-list-67992.rs b/tests/debuginfo/regression-bad-location-list-67992.rs index a5617a23c931..da5393f9f09a 100644 --- a/tests/debuginfo/regression-bad-location-list-67992.rs +++ b/tests/debuginfo/regression-bad-location-list-67992.rs @@ -3,16 +3,16 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print a -// gdb-check:$1 = regression_bad_location_list_67992::Foo {x: [0 ]} +//@ gdb-command:print a +//@ gdb-check:$1 = regression_bad_location_list_67992::Foo {x: [0 ]} // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v a -// lldb-check:(regression_bad_location_list_67992::Foo) [...] +//@ lldb-command:run +//@ lldb-command:v a +//@ lldb-check:(regression_bad_location_list_67992::Foo) [...] const ARRAY_SIZE: usize = 1024; diff --git a/tests/debuginfo/result-types.rs b/tests/debuginfo/result-types.rs index 8b91d0ba27ef..4fd80f19add7 100644 --- a/tests/debuginfo/result-types.rs +++ b/tests/debuginfo/result-types.rs @@ -4,15 +4,15 @@ // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx x,d -// cdb-check:x,d : Ok [Type: enum2$ > >] -// cdb-check: [...] __0 : -3 [Type: int] +//@ cdb-command: dx x,d +//@ cdb-check:x,d : Ok [Type: enum2$ > >] +//@ cdb-check: [...] __0 : -3 [Type: int] -// cdb-command: dx y -// cdb-check:y : Err [Type: enum2$ > >] -// cdb-check: [...] __0 : "Some error message" [Type: ref$] +//@ cdb-command: dx y +//@ cdb-check:y : Err [Type: enum2$ > >] +//@ cdb-check: [...] __0 : "Some error message" [Type: ref$] fn main() { let x: Result = Ok(-3); diff --git a/tests/debuginfo/rwlock-read.rs b/tests/debuginfo/rwlock-read.rs index 825cdbe55104..be29ffcc65fa 100644 --- a/tests/debuginfo/rwlock-read.rs +++ b/tests/debuginfo/rwlock-read.rs @@ -6,17 +6,17 @@ // === CDB TESTS ================================================================================== // -// cdb-command:g +//@ cdb-command:g // -// cdb-command:dx l -// cdb-check:l [Type: std::sync::poison::rwlock::RwLock] -// cdb-check: [...] poison [Type: std::sync::poison::Flag] -// cdb-check: [...] data : 0 [Type: core::cell::UnsafeCell] +//@ cdb-command:dx l +//@ cdb-check:l [Type: std::sync::poison::rwlock::RwLock] +//@ cdb-check: [...] poison [Type: std::sync::poison::Flag] +//@ cdb-check: [...] data : 0 [Type: core::cell::UnsafeCell] // -// cdb-command:dx r -// cdb-check:r [Type: std::sync::poison::rwlock::RwLockReadGuard] -// cdb-check: [...] data : NonNull([...]: 0) [Type: core::ptr::non_null::NonNull] -// cdb-check: [...] inner_lock : [...] [Type: std::sys::sync::rwlock::futex::RwLock *] +//@ cdb-command:dx r +//@ cdb-check:r [Type: std::sync::poison::rwlock::RwLockReadGuard] +//@ cdb-check: [...] data : NonNull([...]: 0) [Type: core::ptr::non_null::NonNull] +//@ cdb-check: [...] inner_lock : [...] [Type: std::sys::sync::rwlock::futex::RwLock *] #[allow(unused_variables)] diff --git a/tests/debuginfo/rwlock-write.rs b/tests/debuginfo/rwlock-write.rs index aaca048b8a7c..9ca03f19c6ff 100644 --- a/tests/debuginfo/rwlock-write.rs +++ b/tests/debuginfo/rwlock-write.rs @@ -6,12 +6,12 @@ // === CDB TESTS ================================================================================== // -// cdb-command:g +//@ cdb-command:g // -// cdb-command:dx w -// cdb-check:w [Type: std::sync::poison::rwlock::RwLockWriteGuard] -// cdb-check: [...] lock : [...] [Type: std::sync::poison::rwlock::RwLock *] -// cdb-check: [...] poison [Type: std::sync::poison::Guard] +//@ cdb-command:dx w +//@ cdb-check:w [Type: std::sync::poison::rwlock::RwLockWriteGuard] +//@ cdb-check: [...] lock : [...] [Type: std::sync::poison::rwlock::RwLock *] +//@ cdb-check: [...] poison [Type: std::sync::poison::Guard] #[allow(unused_variables)] diff --git a/tests/debuginfo/self-in-default-method.rs b/tests/debuginfo/self-in-default-method.rs index 6e08ef4cd83a..41e4ffc389b9 100644 --- a/tests/debuginfo/self-in-default-method.rs +++ b/tests/debuginfo/self-in-default-method.rs @@ -4,102 +4,102 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // STACK BY REF -// gdb-command:print *self -// gdb-check:$1 = self_in_default_method::Struct {x: 100} -// gdb-command:print arg1 -// gdb-check:$2 = -1 -// gdb-command:print arg2 -// gdb-check:$3 = -2 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$1 = self_in_default_method::Struct {x: 100} +//@ gdb-command:print arg1 +//@ gdb-check:$2 = -1 +//@ gdb-command:print arg2 +//@ gdb-check:$3 = -2 +//@ gdb-command:continue // STACK BY VAL -// gdb-command:print self -// gdb-check:$4 = self_in_default_method::Struct {x: 100} -// gdb-command:print arg1 -// gdb-check:$5 = -3 -// gdb-command:print arg2 -// gdb-check:$6 = -4 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$4 = self_in_default_method::Struct {x: 100} +//@ gdb-command:print arg1 +//@ gdb-check:$5 = -3 +//@ gdb-command:print arg2 +//@ gdb-check:$6 = -4 +//@ gdb-command:continue // OWNED BY REF -// gdb-command:print *self -// gdb-check:$7 = self_in_default_method::Struct {x: 200} -// gdb-command:print arg1 -// gdb-check:$8 = -5 -// gdb-command:print arg2 -// gdb-check:$9 = -6 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$7 = self_in_default_method::Struct {x: 200} +//@ gdb-command:print arg1 +//@ gdb-check:$8 = -5 +//@ gdb-command:print arg2 +//@ gdb-check:$9 = -6 +//@ gdb-command:continue // OWNED BY VAL -// gdb-command:print self -// gdb-check:$10 = self_in_default_method::Struct {x: 200} -// gdb-command:print arg1 -// gdb-check:$11 = -7 -// gdb-command:print arg2 -// gdb-check:$12 = -8 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$10 = self_in_default_method::Struct {x: 200} +//@ gdb-command:print arg1 +//@ gdb-check:$11 = -7 +//@ gdb-command:print arg2 +//@ gdb-check:$12 = -8 +//@ gdb-command:continue // OWNED MOVED -// gdb-command:print *self -// gdb-check:$13 = self_in_default_method::Struct {x: 200} -// gdb-command:print arg1 -// gdb-check:$14 = -9 -// gdb-command:print arg2 -// gdb-check:$15 = -10 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$13 = self_in_default_method::Struct {x: 200} +//@ gdb-command:print arg1 +//@ gdb-check:$14 = -9 +//@ gdb-command:print arg2 +//@ gdb-check:$15 = -10 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // STACK BY REF -// lldb-command:v *self -// lldb-check:[...] { x = 100 } -// lldb-command:v arg1 -// lldb-check:[...] -1 -// lldb-command:v arg2 -// lldb-check:[...] -2 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 100 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -1 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -2 +//@ lldb-command:continue // STACK BY VAL -// lldb-command:v self -// lldb-check:[...] { x = 100 } -// lldb-command:v arg1 -// lldb-check:[...] -3 -// lldb-command:v arg2 -// lldb-check:[...] -4 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = 100 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -3 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -4 +//@ lldb-command:continue // OWNED BY REF -// lldb-command:v *self -// lldb-check:[...] { x = 200 } -// lldb-command:v arg1 -// lldb-check:[...] -5 -// lldb-command:v arg2 -// lldb-check:[...] -6 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 200 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -5 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -6 +//@ lldb-command:continue // OWNED BY VAL -// lldb-command:v self -// lldb-check:[...] { x = 200 } -// lldb-command:v arg1 -// lldb-check:[...] -7 -// lldb-command:v arg2 -// lldb-check:[...] -8 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = 200 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -7 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -8 +//@ lldb-command:continue // OWNED MOVED -// lldb-command:v *self -// lldb-check:[...] { x = 200 } -// lldb-command:v arg1 -// lldb-check:[...] -9 -// lldb-command:v arg2 -// lldb-check:[...] -10 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 200 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -9 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -10 +//@ lldb-command:continue #[derive(Copy, Clone)] struct Struct { diff --git a/tests/debuginfo/self-in-generic-default-method.rs b/tests/debuginfo/self-in-generic-default-method.rs index a06731a54bd2..401d65291d35 100644 --- a/tests/debuginfo/self-in-generic-default-method.rs +++ b/tests/debuginfo/self-in-generic-default-method.rs @@ -4,102 +4,102 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // STACK BY REF -// gdb-command:print *self -// gdb-check:$1 = self_in_generic_default_method::Struct {x: 987} -// gdb-command:print arg1 -// gdb-check:$2 = -1 -// gdb-command:print arg2 -// gdb-check:$3 = 2 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$1 = self_in_generic_default_method::Struct {x: 987} +//@ gdb-command:print arg1 +//@ gdb-check:$2 = -1 +//@ gdb-command:print arg2 +//@ gdb-check:$3 = 2 +//@ gdb-command:continue // STACK BY VAL -// gdb-command:print self -// gdb-check:$4 = self_in_generic_default_method::Struct {x: 987} -// gdb-command:print arg1 -// gdb-check:$5 = -3 -// gdb-command:print arg2 -// gdb-check:$6 = -4 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$4 = self_in_generic_default_method::Struct {x: 987} +//@ gdb-command:print arg1 +//@ gdb-check:$5 = -3 +//@ gdb-command:print arg2 +//@ gdb-check:$6 = -4 +//@ gdb-command:continue // OWNED BY REF -// gdb-command:print *self -// gdb-check:$7 = self_in_generic_default_method::Struct {x: 879} -// gdb-command:print arg1 -// gdb-check:$8 = -5 -// gdb-command:print arg2 -// gdb-check:$9 = -6 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$7 = self_in_generic_default_method::Struct {x: 879} +//@ gdb-command:print arg1 +//@ gdb-check:$8 = -5 +//@ gdb-command:print arg2 +//@ gdb-check:$9 = -6 +//@ gdb-command:continue // OWNED BY VAL -// gdb-command:print self -// gdb-check:$10 = self_in_generic_default_method::Struct {x: 879} -// gdb-command:print arg1 -// gdb-check:$11 = -7 -// gdb-command:print arg2 -// gdb-check:$12 = -8 -// gdb-command:continue +//@ gdb-command:print self +//@ gdb-check:$10 = self_in_generic_default_method::Struct {x: 879} +//@ gdb-command:print arg1 +//@ gdb-check:$11 = -7 +//@ gdb-command:print arg2 +//@ gdb-check:$12 = -8 +//@ gdb-command:continue // OWNED MOVED -// gdb-command:print *self -// gdb-check:$13 = self_in_generic_default_method::Struct {x: 879} -// gdb-command:print arg1 -// gdb-check:$14 = -9 -// gdb-command:print arg2 -// gdb-check:$15 = -10.5 -// gdb-command:continue +//@ gdb-command:print *self +//@ gdb-check:$13 = self_in_generic_default_method::Struct {x: 879} +//@ gdb-command:print arg1 +//@ gdb-check:$14 = -9 +//@ gdb-command:print arg2 +//@ gdb-check:$15 = -10.5 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // STACK BY REF -// lldb-command:v *self -// lldb-check:[...] { x = 987 } -// lldb-command:v arg1 -// lldb-check:[...] -1 -// lldb-command:v arg2 -// lldb-check:[...] 2 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 987 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -1 +//@ lldb-command:v arg2 +//@ lldb-check:[...] 2 +//@ lldb-command:continue // STACK BY VAL -// lldb-command:v self -// lldb-check:[...] { x = 987 } -// lldb-command:v arg1 -// lldb-check:[...] -3 -// lldb-command:v arg2 -// lldb-check:[...] -4 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = 987 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -3 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -4 +//@ lldb-command:continue // OWNED BY REF -// lldb-command:v *self -// lldb-check:[...] { x = 879 } -// lldb-command:v arg1 -// lldb-check:[...] -5 -// lldb-command:v arg2 -// lldb-check:[...] -6 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 879 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -5 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -6 +//@ lldb-command:continue // OWNED BY VAL -// lldb-command:v self -// lldb-check:[...] { x = 879 } -// lldb-command:v arg1 -// lldb-check:[...] -7 -// lldb-command:v arg2 -// lldb-check:[...] -8 -// lldb-command:continue +//@ lldb-command:v self +//@ lldb-check:[...] { x = 879 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -7 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -8 +//@ lldb-command:continue // OWNED MOVED -// lldb-command:v *self -// lldb-check:[...] { x = 879 } -// lldb-command:v arg1 -// lldb-check:[...] -9 -// lldb-command:v arg2 -// lldb-check:[...] -10.5 -// lldb-command:continue +//@ lldb-command:v *self +//@ lldb-check:[...] { x = 879 } +//@ lldb-command:v arg1 +//@ lldb-check:[...] -9 +//@ lldb-command:v arg2 +//@ lldb-check:[...] -10.5 +//@ lldb-command:continue #[derive(Copy, Clone)] struct Struct { diff --git a/tests/debuginfo/shadowed-argument.rs b/tests/debuginfo/shadowed-argument.rs index 7a7e54545b88..eff59a2dfd18 100644 --- a/tests/debuginfo/shadowed-argument.rs +++ b/tests/debuginfo/shadowed-argument.rs @@ -4,48 +4,48 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print x -// gdb-check:$1 = false -// gdb-command:print y -// gdb-check:$2 = true -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = false +//@ gdb-command:print y +//@ gdb-check:$2 = true +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$3 = 10 -// gdb-command:print y -// gdb-check:$4 = true -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = 10 +//@ gdb-command:print y +//@ gdb-check:$4 = true +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$5 = 10.5 -// gdb-command:print y -// gdb-check:$6 = 20 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = 10.5 +//@ gdb-command:print y +//@ gdb-check:$6 = 20 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:v y -// lldb-check:[...] true -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:v y +//@ lldb-check:[...] true +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10 -// lldb-command:v y -// lldb-check:[...] true -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10 +//@ lldb-command:v y +//@ lldb-check:[...] true +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10.5 -// lldb-command:v y -// lldb-check:[...] 20 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10.5 +//@ lldb-command:v y +//@ lldb-check:[...] 20 +//@ lldb-command:continue fn a_function(x: bool, y: bool) { diff --git a/tests/debuginfo/shadowed-variable.rs b/tests/debuginfo/shadowed-variable.rs index c55f22df0037..0d15d5e97f70 100644 --- a/tests/debuginfo/shadowed-variable.rs +++ b/tests/debuginfo/shadowed-variable.rs @@ -4,71 +4,71 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print x -// gdb-check:$1 = false -// gdb-command:print y -// gdb-check:$2 = true -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = false +//@ gdb-command:print y +//@ gdb-check:$2 = true +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$3 = 10 -// gdb-command:print y -// gdb-check:$4 = true -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = 10 +//@ gdb-command:print y +//@ gdb-check:$4 = true +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$5 = 10.5 -// gdb-command:print y -// gdb-check:$6 = 20 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = 10.5 +//@ gdb-command:print y +//@ gdb-check:$6 = 20 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$7 = 10.5 -// gdb-command:print y -// gdb-check:$8 = 20 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$7 = 10.5 +//@ gdb-command:print y +//@ gdb-check:$8 = 20 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$9 = 11.5 -// gdb-command:print y -// gdb-check:$10 = 20 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$9 = 11.5 +//@ gdb-command:print y +//@ gdb-check:$10 = 20 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:v y -// lldb-check:[...] true -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:v y +//@ lldb-check:[...] true +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10 -// lldb-command:v y -// lldb-check:[...] true -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10 +//@ lldb-command:v y +//@ lldb-check:[...] true +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10.5 -// lldb-command:v y -// lldb-check:[...] 20 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10.5 +//@ lldb-command:v y +//@ lldb-check:[...] 20 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10.5 -// lldb-command:v y -// lldb-check:[...] 20 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10.5 +//@ lldb-command:v y +//@ lldb-check:[...] 20 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 11.5 -// lldb-command:v y -// lldb-check:[...] 20 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 11.5 +//@ lldb-command:v y +//@ lldb-check:[...] 20 +//@ lldb-command:continue fn main() { let x = false; diff --git a/tests/debuginfo/should-fail.rs b/tests/debuginfo/should-fail.rs index bc9b83fc2427..8a1a74a4130f 100644 --- a/tests/debuginfo/should-fail.rs +++ b/tests/debuginfo/should-fail.rs @@ -5,24 +5,24 @@ // === GDB TESTS =================================================================================== -// gdb-command: run +//@ gdb-command: run -// gdb-command: print x -// gdb-check:$1 = 5 +//@ gdb-command: print x +//@ gdb-check:$1 = 5 // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v x -// lldb-check:[...] 5 +//@ lldb-command:v x +//@ lldb-check:[...] 5 // === CDB TESTS ================================================================================== -// cdb-command:g +//@ cdb-command:g -// cdb-command:dx x -// cdb-check:string [...] : 5 [Type: [...]] +//@ cdb-command:dx x +//@ cdb-check:string [...] : 5 [Type: [...]] fn main() { let x = 1; diff --git a/tests/debuginfo/simd.rs b/tests/debuginfo/simd.rs index 888a78117b54..7bfb2fad3277 100644 --- a/tests/debuginfo/simd.rs +++ b/tests/debuginfo/simd.rs @@ -9,32 +9,32 @@ //@ compile-flags:-g //@ disable-gdb-pretty-printers //@ ignore-backends: gcc -// gdb-command:run +//@ gdb-command:run -// gdb-command:print vi8x16 -// gdb-check:$1 = simd::i8x16 ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) -// gdb-command:print vi16x8 -// gdb-check:$2 = simd::i16x8 ([16, 17, 18, 19, 20, 21, 22, 23]) -// gdb-command:print vi32x4 -// gdb-check:$3 = simd::i32x4 ([24, 25, 26, 27]) -// gdb-command:print vi64x2 -// gdb-check:$4 = simd::i64x2 ([28, 29]) +//@ gdb-command:print vi8x16 +//@ gdb-check:$1 = simd::i8x16 ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) +//@ gdb-command:print vi16x8 +//@ gdb-check:$2 = simd::i16x8 ([16, 17, 18, 19, 20, 21, 22, 23]) +//@ gdb-command:print vi32x4 +//@ gdb-check:$3 = simd::i32x4 ([24, 25, 26, 27]) +//@ gdb-command:print vi64x2 +//@ gdb-check:$4 = simd::i64x2 ([28, 29]) -// gdb-command:print vu8x16 -// gdb-check:$5 = simd::u8x16 ([30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]) -// gdb-command:print vu16x8 -// gdb-check:$6 = simd::u16x8 ([46, 47, 48, 49, 50, 51, 52, 53]) -// gdb-command:print vu32x4 -// gdb-check:$7 = simd::u32x4 ([54, 55, 56, 57]) -// gdb-command:print vu64x2 -// gdb-check:$8 = simd::u64x2 ([58, 59]) +//@ gdb-command:print vu8x16 +//@ gdb-check:$5 = simd::u8x16 ([30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]) +//@ gdb-command:print vu16x8 +//@ gdb-check:$6 = simd::u16x8 ([46, 47, 48, 49, 50, 51, 52, 53]) +//@ gdb-command:print vu32x4 +//@ gdb-check:$7 = simd::u32x4 ([54, 55, 56, 57]) +//@ gdb-command:print vu64x2 +//@ gdb-check:$8 = simd::u64x2 ([58, 59]) -// gdb-command:print vf32x4 -// gdb-check:$9 = simd::f32x4 ([60.5, 61.5, 62.5, 63.5]) -// gdb-command:print vf64x2 -// gdb-check:$10 = simd::f64x2 ([64.5, 65.5]) +//@ gdb-command:print vf32x4 +//@ gdb-check:$9 = simd::f32x4 ([60.5, 61.5, 62.5, 63.5]) +//@ gdb-command:print vf64x2 +//@ gdb-check:$10 = simd::f64x2 ([64.5, 65.5]) -// gdb-command:continue +//@ gdb-command:continue #![allow(unused_variables)] #![feature(repr_simd)] diff --git a/tests/debuginfo/simple-lexical-scope.rs b/tests/debuginfo/simple-lexical-scope.rs index 194da9169d9a..1d1b6f882ae1 100644 --- a/tests/debuginfo/simple-lexical-scope.rs +++ b/tests/debuginfo/simple-lexical-scope.rs @@ -4,68 +4,68 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print x -// gdb-check:$1 = false -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$1 = false +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$2 = false -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$2 = false +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$3 = 10 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$3 = 10 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$4 = 10 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$4 = 10 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$5 = 10.5 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$5 = 10.5 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$6 = 10 -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$6 = 10 +//@ gdb-command:continue -// gdb-command:print x -// gdb-check:$7 = false -// gdb-command:continue +//@ gdb-command:print x +//@ gdb-check:$7 = false +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10.5 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10.5 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] 10 -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] 10 +//@ lldb-command:continue -// lldb-command:v x -// lldb-check:[...] false -// lldb-command:continue +//@ lldb-command:v x +//@ lldb-check:[...] false +//@ lldb-command:continue fn main() { diff --git a/tests/debuginfo/simple-struct.rs b/tests/debuginfo/simple-struct.rs index 665bb2fdb579..a67dc13a5d43 100644 --- a/tests/debuginfo/simple-struct.rs +++ b/tests/debuginfo/simple-struct.rs @@ -4,85 +4,85 @@ // === GDB TESTS =================================================================================== -// gdb-command:print simple_struct::NO_PADDING_16 -// gdb-check:$1 = simple_struct::NoPadding16 {x: 1000, y: -1001} +//@ gdb-command:print simple_struct::NO_PADDING_16 +//@ gdb-check:$1 = simple_struct::NoPadding16 {x: 1000, y: -1001} -// gdb-command:print simple_struct::NO_PADDING_32 -// gdb-check:$2 = simple_struct::NoPadding32 {x: 1, y: 2, z: 3} +//@ gdb-command:print simple_struct::NO_PADDING_32 +//@ gdb-check:$2 = simple_struct::NoPadding32 {x: 1, y: 2, z: 3} -// gdb-command:print simple_struct::NO_PADDING_64 -// gdb-check:$3 = simple_struct::NoPadding64 {x: 4, y: 5, z: 6} +//@ gdb-command:print simple_struct::NO_PADDING_64 +//@ gdb-check:$3 = simple_struct::NoPadding64 {x: 4, y: 5, z: 6} -// gdb-command:print simple_struct::NO_PADDING_163264 -// gdb-check:$4 = simple_struct::NoPadding163264 {a: 7, b: 8, c: 9, d: 10} +//@ gdb-command:print simple_struct::NO_PADDING_163264 +//@ gdb-check:$4 = simple_struct::NoPadding163264 {a: 7, b: 8, c: 9, d: 10} -// gdb-command:print simple_struct::INTERNAL_PADDING -// gdb-check:$5 = simple_struct::InternalPadding {x: 11, y: 12} +//@ gdb-command:print simple_struct::INTERNAL_PADDING +//@ gdb-check:$5 = simple_struct::InternalPadding {x: 11, y: 12} -// gdb-command:print simple_struct::PADDING_AT_END -// gdb-check:$6 = simple_struct::PaddingAtEnd {x: 13, y: 14} +//@ gdb-command:print simple_struct::PADDING_AT_END +//@ gdb-check:$6 = simple_struct::PaddingAtEnd {x: 13, y: 14} -// gdb-command:run +//@ gdb-command:run -// gdb-command:print no_padding16 -// gdb-check:$7 = simple_struct::NoPadding16 {x: 10000, y: -10001} +//@ gdb-command:print no_padding16 +//@ gdb-check:$7 = simple_struct::NoPadding16 {x: 10000, y: -10001} -// gdb-command:print no_padding32 -// gdb-check:$8 = simple_struct::NoPadding32 {x: -10002, y: -10003.5, z: 10004} +//@ gdb-command:print no_padding32 +//@ gdb-check:$8 = simple_struct::NoPadding32 {x: -10002, y: -10003.5, z: 10004} -// gdb-command:print no_padding64 -// gdb-check:$9 = simple_struct::NoPadding64 {x: -10005.5, y: 10006, z: 10007} +//@ gdb-command:print no_padding64 +//@ gdb-check:$9 = simple_struct::NoPadding64 {x: -10005.5, y: 10006, z: 10007} -// gdb-command:print no_padding163264 -// gdb-check:$10 = simple_struct::NoPadding163264 {a: -10008, b: 10009, c: 10010, d: 10011} +//@ gdb-command:print no_padding163264 +//@ gdb-check:$10 = simple_struct::NoPadding163264 {a: -10008, b: 10009, c: 10010, d: 10011} -// gdb-command:print internal_padding -// gdb-check:$11 = simple_struct::InternalPadding {x: 10012, y: -10013} +//@ gdb-command:print internal_padding +//@ gdb-check:$11 = simple_struct::InternalPadding {x: 10012, y: -10013} -// gdb-command:print padding_at_end -// gdb-check:$12 = simple_struct::PaddingAtEnd {x: -10014, y: 10015} +//@ gdb-command:print padding_at_end +//@ gdb-check:$12 = simple_struct::PaddingAtEnd {x: -10014, y: 10015} -// gdb-command:print simple_struct::NO_PADDING_16 -// gdb-check:$13 = simple_struct::NoPadding16 {x: 100, y: -101} +//@ gdb-command:print simple_struct::NO_PADDING_16 +//@ gdb-check:$13 = simple_struct::NoPadding16 {x: 100, y: -101} -// gdb-command:print simple_struct::NO_PADDING_32 -// gdb-check:$14 = simple_struct::NoPadding32 {x: -15, y: -16, z: 17} +//@ gdb-command:print simple_struct::NO_PADDING_32 +//@ gdb-check:$14 = simple_struct::NoPadding32 {x: -15, y: -16, z: 17} -// gdb-command:print simple_struct::NO_PADDING_64 -// gdb-check:$15 = simple_struct::NoPadding64 {x: -18, y: 19, z: 20} +//@ gdb-command:print simple_struct::NO_PADDING_64 +//@ gdb-check:$15 = simple_struct::NoPadding64 {x: -18, y: 19, z: 20} -// gdb-command:print simple_struct::NO_PADDING_163264 -// gdb-check:$16 = simple_struct::NoPadding163264 {a: -21, b: 22, c: 23, d: 24} +//@ gdb-command:print simple_struct::NO_PADDING_163264 +//@ gdb-check:$16 = simple_struct::NoPadding163264 {a: -21, b: 22, c: 23, d: 24} -// gdb-command:print simple_struct::INTERNAL_PADDING -// gdb-check:$17 = simple_struct::InternalPadding {x: 25, y: -26} +//@ gdb-command:print simple_struct::INTERNAL_PADDING +//@ gdb-check:$17 = simple_struct::InternalPadding {x: 25, y: -26} -// gdb-command:print simple_struct::PADDING_AT_END -// gdb-check:$18 = simple_struct::PaddingAtEnd {x: -27, y: 28} +//@ gdb-command:print simple_struct::PADDING_AT_END +//@ gdb-check:$18 = simple_struct::PaddingAtEnd {x: -27, y: 28} -// gdb-command:continue +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v no_padding16 -// lldb-check:[...] { x = 10000 y = -10001 } +//@ lldb-command:v no_padding16 +//@ lldb-check:[...] { x = 10000 y = -10001 } -// lldb-command:v no_padding32 -// lldb-check:[...] { x = -10002 y = -10003.5 z = 10004 } +//@ lldb-command:v no_padding32 +//@ lldb-check:[...] { x = -10002 y = -10003.5 z = 10004 } -// lldb-command:v no_padding64 -// lldb-check:[...] { x = -10005.5 y = 10006 z = 10007 } +//@ lldb-command:v no_padding64 +//@ lldb-check:[...] { x = -10005.5 y = 10006 z = 10007 } -// lldb-command:v no_padding163264 -// lldb-check:[...] { a = -10008 b = 10009 c = 10010 d = 10011 } +//@ lldb-command:v no_padding163264 +//@ lldb-check:[...] { a = -10008 b = 10009 c = 10010 d = 10011 } -// lldb-command:v internal_padding -// lldb-check:[...] { x = 10012 y = -10013 } +//@ lldb-command:v internal_padding +//@ lldb-check:[...] { x = 10012 y = -10013 } -// lldb-command:v padding_at_end -// lldb-check:[...] { x = -10014 y = 10015 } +//@ lldb-command:v padding_at_end +//@ lldb-check:[...] { x = -10014 y = 10015 } #![allow(unused_variables)] #![allow(dead_code)] diff --git a/tests/debuginfo/simple-tuple.rs b/tests/debuginfo/simple-tuple.rs index c1509a8a9b4c..a82070900aaf 100644 --- a/tests/debuginfo/simple-tuple.rs +++ b/tests/debuginfo/simple-tuple.rs @@ -4,121 +4,121 @@ // === GDB TESTS =================================================================================== -// gdb-command:print simple_tuple::NO_PADDING_8 -// gdb-check:$1 = (-50, 50) -// gdb-command:print simple_tuple::NO_PADDING_16 -// gdb-check:$2 = (-1, 2, 3) -// gdb-command:print simple_tuple::NO_PADDING_32 -// gdb-check:$3 = (4, 5, 6) -// gdb-command:print simple_tuple::NO_PADDING_64 -// gdb-check:$4 = (7, 8, 9) +//@ gdb-command:print simple_tuple::NO_PADDING_8 +//@ gdb-check:$1 = (-50, 50) +//@ gdb-command:print simple_tuple::NO_PADDING_16 +//@ gdb-check:$2 = (-1, 2, 3) +//@ gdb-command:print simple_tuple::NO_PADDING_32 +//@ gdb-check:$3 = (4, 5, 6) +//@ gdb-command:print simple_tuple::NO_PADDING_64 +//@ gdb-check:$4 = (7, 8, 9) -// gdb-command:print simple_tuple::INTERNAL_PADDING_1 -// gdb-check:$5 = (10, 11) -// gdb-command:print simple_tuple::INTERNAL_PADDING_2 -// gdb-check:$6 = (12, 13, 14, 15) +//@ gdb-command:print simple_tuple::INTERNAL_PADDING_1 +//@ gdb-check:$5 = (10, 11) +//@ gdb-command:print simple_tuple::INTERNAL_PADDING_2 +//@ gdb-check:$6 = (12, 13, 14, 15) -// gdb-command:print simple_tuple::PADDING_AT_END -// gdb-check:$7 = (16, 17) +//@ gdb-command:print simple_tuple::PADDING_AT_END +//@ gdb-check:$7 = (16, 17) -// gdb-command:run +//@ gdb-command:run -// gdb-command:print noPadding8 -// gdb-check:$8 = (-100, 100) -// gdb-command:print noPadding16 -// gdb-check:$9 = (0, 1, 2) -// gdb-command:print noPadding32 -// gdb-check:$10 = (3, 4.5, 5) -// gdb-command:print noPadding64 -// gdb-check:$11 = (6, 7.5, 8) +//@ gdb-command:print noPadding8 +//@ gdb-check:$8 = (-100, 100) +//@ gdb-command:print noPadding16 +//@ gdb-check:$9 = (0, 1, 2) +//@ gdb-command:print noPadding32 +//@ gdb-check:$10 = (3, 4.5, 5) +//@ gdb-command:print noPadding64 +//@ gdb-check:$11 = (6, 7.5, 8) -// gdb-command:print internalPadding1 -// gdb-check:$12 = (9, 10) -// gdb-command:print internalPadding2 -// gdb-check:$13 = (11, 12, 13, 14) +//@ gdb-command:print internalPadding1 +//@ gdb-check:$12 = (9, 10) +//@ gdb-command:print internalPadding2 +//@ gdb-check:$13 = (11, 12, 13, 14) -// gdb-command:print paddingAtEnd -// gdb-check:$14 = (15, 16) +//@ gdb-command:print paddingAtEnd +//@ gdb-check:$14 = (15, 16) -// gdb-command:print simple_tuple::NO_PADDING_8 -// gdb-check:$15 = (-127, 127) -// gdb-command:print simple_tuple::NO_PADDING_16 -// gdb-check:$16 = (-10, 10, 9) -// gdb-command:print simple_tuple::NO_PADDING_32 -// gdb-check:$17 = (14, 15, 16) -// gdb-command:print simple_tuple::NO_PADDING_64 -// gdb-check:$18 = (17, 18, 19) +//@ gdb-command:print simple_tuple::NO_PADDING_8 +//@ gdb-check:$15 = (-127, 127) +//@ gdb-command:print simple_tuple::NO_PADDING_16 +//@ gdb-check:$16 = (-10, 10, 9) +//@ gdb-command:print simple_tuple::NO_PADDING_32 +//@ gdb-check:$17 = (14, 15, 16) +//@ gdb-command:print simple_tuple::NO_PADDING_64 +//@ gdb-check:$18 = (17, 18, 19) -// gdb-command:print simple_tuple::INTERNAL_PADDING_1 -// gdb-check:$19 = (110, 111) -// gdb-command:print simple_tuple::INTERNAL_PADDING_2 -// gdb-check:$20 = (112, 113, 114, 115) +//@ gdb-command:print simple_tuple::INTERNAL_PADDING_1 +//@ gdb-check:$19 = (110, 111) +//@ gdb-command:print simple_tuple::INTERNAL_PADDING_2 +//@ gdb-check:$20 = (112, 113, 114, 115) -// gdb-command:print simple_tuple::PADDING_AT_END -// gdb-check:$21 = (116, 117) +//@ gdb-command:print simple_tuple::PADDING_AT_END +//@ gdb-check:$21 = (116, 117) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v/d noPadding8 -// lldb-check:[...] { 0 = -100 1 = 100 } -// lldb-command:v noPadding16 -// lldb-check:[...] { 0 = 0 1 = 1 2 = 2 } -// lldb-command:v noPadding32 -// lldb-check:[...] { 0 = 3 1 = 4.5 2 = 5 } -// lldb-command:v noPadding64 -// lldb-check:[...] { 0 = 6 1 = 7.5 2 = 8 } +//@ lldb-command:v/d noPadding8 +//@ lldb-check:[...] { 0 = -100 1 = 100 } +//@ lldb-command:v noPadding16 +//@ lldb-check:[...] { 0 = 0 1 = 1 2 = 2 } +//@ lldb-command:v noPadding32 +//@ lldb-check:[...] { 0 = 3 1 = 4.5 2 = 5 } +//@ lldb-command:v noPadding64 +//@ lldb-check:[...] { 0 = 6 1 = 7.5 2 = 8 } -// lldb-command:v internalPadding1 -// lldb-check:[...] { 0 = 9 1 = 10 } -// lldb-command:v internalPadding2 -// lldb-check:[...] { 0 = 11 1 = 12 2 = 13 3 = 14 } +//@ lldb-command:v internalPadding1 +//@ lldb-check:[...] { 0 = 9 1 = 10 } +//@ lldb-command:v internalPadding2 +//@ lldb-check:[...] { 0 = 11 1 = 12 2 = 13 3 = 14 } -// lldb-command:v paddingAtEnd -// lldb-check:[...] { 0 = 15 1 = 16 } +//@ lldb-command:v paddingAtEnd +//@ lldb-check:[...] { 0 = 15 1 = 16 } // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command:dx noPadding8,d -// cdb-check:noPadding8,d [...]: (-100, 100) [Type: tuple$] -// cdb-check:[...][0] : -100 [Type: [...]] -// cdb-check:[...][1] : 100 [Type: [...]] -// cdb-command:dx noPadding16,d -// cdb-check:noPadding16,d [...]: (0, 1, 2) [Type: tuple$] -// cdb-check:[...][0] : 0 [Type: [...]] -// cdb-check:[...][1] : 1 [Type: [...]] -// cdb-check:[...][2] : 2 [Type: [...]] -// cdb-command:dx noPadding32,d -// cdb-check:noPadding32,d [...]: (3, 4.5[...], 5) [Type: tuple$] -// cdb-check:[...][0] : 3 [Type: [...]] -// cdb-check:[...][1] : 4.5[...] [Type: [...]] -// cdb-check:[...][2] : 5 [Type: [...]] -// cdb-command:dx noPadding64,d -// cdb-check:noPadding64,d [...]: (6, 7.5[...], 8) [Type: tuple$] -// cdb-check:[...][0] : 6 [Type: [...]] -// cdb-check:[...][1] : 7.500000 [Type: [...]] -// cdb-check:[...][2] : 8 [Type: [...]] +//@ cdb-command:dx noPadding8,d +//@ cdb-check:noPadding8,d [...]: (-100, 100) [Type: tuple$] +//@ cdb-check:[...][0] : -100 [Type: [...]] +//@ cdb-check:[...][1] : 100 [Type: [...]] +//@ cdb-command:dx noPadding16,d +//@ cdb-check:noPadding16,d [...]: (0, 1, 2) [Type: tuple$] +//@ cdb-check:[...][0] : 0 [Type: [...]] +//@ cdb-check:[...][1] : 1 [Type: [...]] +//@ cdb-check:[...][2] : 2 [Type: [...]] +//@ cdb-command:dx noPadding32,d +//@ cdb-check:noPadding32,d [...]: (3, 4.5[...], 5) [Type: tuple$] +//@ cdb-check:[...][0] : 3 [Type: [...]] +//@ cdb-check:[...][1] : 4.5[...] [Type: [...]] +//@ cdb-check:[...][2] : 5 [Type: [...]] +//@ cdb-command:dx noPadding64,d +//@ cdb-check:noPadding64,d [...]: (6, 7.5[...], 8) [Type: tuple$] +//@ cdb-check:[...][0] : 6 [Type: [...]] +//@ cdb-check:[...][1] : 7.500000 [Type: [...]] +//@ cdb-check:[...][2] : 8 [Type: [...]] -// cdb-command:dx internalPadding1,d -// cdb-check:internalPadding1,d [...]: (9, 10) [Type: tuple$] -// cdb-check:[...][0] : 9 [Type: short] -// cdb-check:[...][1] : 10 [Type: int] -// cdb-command:dx internalPadding2,d -// cdb-check:internalPadding2,d [...]: (11, 12, 13, 14) [Type: tuple$] -// cdb-check:[...][0] : 11 [Type: [...]] -// cdb-check:[...][1] : 12 [Type: [...]] -// cdb-check:[...][2] : 13 [Type: [...]] -// cdb-check:[...][3] : 14 [Type: [...]] +//@ cdb-command:dx internalPadding1,d +//@ cdb-check:internalPadding1,d [...]: (9, 10) [Type: tuple$] +//@ cdb-check:[...][0] : 9 [Type: short] +//@ cdb-check:[...][1] : 10 [Type: int] +//@ cdb-command:dx internalPadding2,d +//@ cdb-check:internalPadding2,d [...]: (11, 12, 13, 14) [Type: tuple$] +//@ cdb-check:[...][0] : 11 [Type: [...]] +//@ cdb-check:[...][1] : 12 [Type: [...]] +//@ cdb-check:[...][2] : 13 [Type: [...]] +//@ cdb-check:[...][3] : 14 [Type: [...]] -// cdb-command:dx paddingAtEnd,d -// cdb-check:paddingAtEnd,d [...]: (15, 16) [Type: tuple$] -// cdb-check:[...][0] : 15 [Type: [...]] -// cdb-check:[...][1] : 16 [Type: [...]] +//@ cdb-command:dx paddingAtEnd,d +//@ cdb-check:paddingAtEnd,d [...]: (15, 16) [Type: tuple$] +//@ cdb-check:[...][0] : 15 [Type: [...]] +//@ cdb-check:[...][1] : 16 [Type: [...]] #![allow(unused_variables)] diff --git a/tests/debuginfo/skip_second_statement.rs b/tests/debuginfo/skip_second_statement.rs index 452b6db3882d..d0eadd9aa0fb 100644 --- a/tests/debuginfo/skip_second_statement.rs +++ b/tests/debuginfo/skip_second_statement.rs @@ -8,85 +8,85 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_rem1_call1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_rem1_call3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_rem2_call1[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call1[...] -// gdb-command:next 2 -// gdb-check:[...]#loc_rem2_call3[...] -// gdb-command:step 2 -// gdb-command:frame -// gdb-check:[...]#loc_call3_println[...] -// gdb-command:next 3 -// gdb-command:frame -// gdb-check:[...]#loc_after_rem[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_add1_call1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_add1_hdr[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_add1_call3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_add2_call1[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call1[...] -// gdb-command:next 2 -// gdb-check:[...]#loc_add2_hdr[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call2[...] -// gdb-command:next 2 -// gdb-command:frame -// gdb-check:[...]#loc_add2_call3[...] -// gdb-command:step 2 -// gdb-command:frame -// gdb-check:[...]#loc_call3_println[...] -// gdb-command:next 3 -// gdb-command:frame -// gdb-check:[...]#loc_reorder1_call2[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_reorder1_call3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_reorder1_call1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_reorder2_call2[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call2[...] -// gdb-command:next 2 -// gdb-command:frame -// gdb-check:[...]#loc_reorder2_call3[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call3[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call3_println[...] -// gdb-command:next 3 -// gdb-command:frame -// gdb-check:[...]#loc_reorder2_call1[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call1[...] -// gdb-command:next 2 -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_rem1_call1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_rem1_call3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_rem2_call1[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call1[...] +//@ gdb-command:next 2 +//@ gdb-check:[...]#loc_rem2_call3[...] +//@ gdb-command:step 2 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call3_println[...] +//@ gdb-command:next 3 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_after_rem[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add1_call1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add1_hdr[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add1_call3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add2_call1[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call1[...] +//@ gdb-command:next 2 +//@ gdb-check:[...]#loc_add2_hdr[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call2[...] +//@ gdb-command:next 2 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add2_call3[...] +//@ gdb-command:step 2 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call3_println[...] +//@ gdb-command:next 3 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder1_call2[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder1_call3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder1_call1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder2_call2[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call2[...] +//@ gdb-command:next 2 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder2_call3[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call3[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call3_println[...] +//@ gdb-command:next 3 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder2_call1[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call1[...] +//@ gdb-command:next 2 +//@ gdb-command:continue #[inline(never)] fn myprintln_impl(text: &str) { diff --git a/tests/debuginfo/skip_second_statement_collapse.rs b/tests/debuginfo/skip_second_statement_collapse.rs index 52a85c5107e4..67cd2f0d9364 100644 --- a/tests/debuginfo/skip_second_statement_collapse.rs +++ b/tests/debuginfo/skip_second_statement_collapse.rs @@ -8,85 +8,85 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_rem1_call1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_rem1_call3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_rem2_call1[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call1[...] -// gdb-command:next 2 -// gdb-check:[...]#loc_rem2_call3[...] -// gdb-command:step 2 -// gdb-command:frame -// gdb-check:[...]#loc_call3_println[...] -// gdb-command:next 3 -// gdb-command:frame -// gdb-check:[...]#loc_after_rem[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_add1_call1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_add_macro[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_add1_call3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_add2_call1[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call1[...] -// gdb-command:next 2 -// gdb-check:[...]#loc_add_macro[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call2[...] -// gdb-command:next 2 -// gdb-command:frame -// gdb-check:[...]#loc_add2_call3[...] -// gdb-command:step 2 -// gdb-command:frame -// gdb-check:[...]#loc_call3_println[...] -// gdb-command:next 3 -// gdb-command:frame -// gdb-check:[...]#loc_reorder1_call2[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_reorder1_call3[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_reorder1_call1[...] -// gdb-command:next -// gdb-command:frame -// gdb-check:[...]#loc_reorder2_call2[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call2[...] -// gdb-command:next 2 -// gdb-command:frame -// gdb-check:[...]#loc_reorder2_call3[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call3[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call3_println[...] -// gdb-command:next 3 -// gdb-command:frame -// gdb-check:[...]#loc_reorder2_call1[...] -// gdb-command:step -// gdb-command:frame -// gdb-check:[...]#loc_call1[...] -// gdb-command:next 2 -// gdb-command:continue +//@ gdb-command:run +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_rem1_call1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_rem1_call3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_rem2_call1[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call1[...] +//@ gdb-command:next 2 +//@ gdb-check:[...]#loc_rem2_call3[...] +//@ gdb-command:step 2 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call3_println[...] +//@ gdb-command:next 3 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_after_rem[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add1_call1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add_macro[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add1_call3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add2_call1[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call1[...] +//@ gdb-command:next 2 +//@ gdb-check:[...]#loc_add_macro[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call2[...] +//@ gdb-command:next 2 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_add2_call3[...] +//@ gdb-command:step 2 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call3_println[...] +//@ gdb-command:next 3 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder1_call2[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder1_call3[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder1_call1[...] +//@ gdb-command:next +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder2_call2[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call2[...] +//@ gdb-command:next 2 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder2_call3[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call3[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call3_println[...] +//@ gdb-command:next 3 +//@ gdb-command:frame +//@ gdb-check:[...]#loc_reorder2_call1[...] +//@ gdb-command:step +//@ gdb-command:frame +//@ gdb-check:[...]#loc_call1[...] +//@ gdb-command:next 2 +//@ gdb-command:continue #[inline(never)] fn myprintln_impl(text: &str) { diff --git a/tests/debuginfo/static-method-on-struct-and-enum.rs b/tests/debuginfo/static-method-on-struct-and-enum.rs index 87b959f9df05..6491e3daf4c1 100644 --- a/tests/debuginfo/static-method-on-struct-and-enum.rs +++ b/tests/debuginfo/static-method-on-struct-and-enum.rs @@ -4,44 +4,44 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run // STRUCT -// gdb-command:print arg1 -// gdb-check:$1 = 1 -// gdb-command:print arg2 -// gdb-check:$2 = 2 -// gdb-command:continue +//@ gdb-command:print arg1 +//@ gdb-check:$1 = 1 +//@ gdb-command:print arg2 +//@ gdb-check:$2 = 2 +//@ gdb-command:continue // ENUM -// gdb-command:print arg1 -// gdb-check:$3 = -3 -// gdb-command:print arg2 -// gdb-check:$4 = 4.5 -// gdb-command:print arg3 -// gdb-check:$5 = 5 -// gdb-command:continue +//@ gdb-command:print arg1 +//@ gdb-check:$3 = -3 +//@ gdb-command:print arg2 +//@ gdb-check:$4 = 4.5 +//@ gdb-command:print arg3 +//@ gdb-check:$5 = 5 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run // STRUCT -// lldb-command:v arg1 -// lldb-check:[...] 1 -// lldb-command:v arg2 -// lldb-check:[...] 2 -// lldb-command:continue +//@ lldb-command:v arg1 +//@ lldb-check:[...] 1 +//@ lldb-command:v arg2 +//@ lldb-check:[...] 2 +//@ lldb-command:continue // ENUM -// lldb-command:v arg1 -// lldb-check:[...] -3 -// lldb-command:v arg2 -// lldb-check:[...] 4.5 -// lldb-command:v arg3 -// lldb-check:[...] 5 -// lldb-command:continue +//@ lldb-command:v arg1 +//@ lldb-check:[...] -3 +//@ lldb-command:v arg2 +//@ lldb-check:[...] 4.5 +//@ lldb-command:v arg3 +//@ lldb-check:[...] 5 +//@ lldb-command:continue struct Struct { x: isize diff --git a/tests/debuginfo/step-into-match.rs b/tests/debuginfo/step-into-match.rs index a05ed8653be2..8c9e91c8e835 100644 --- a/tests/debuginfo/step-into-match.rs +++ b/tests/debuginfo/step-into-match.rs @@ -8,340 +8,340 @@ // === GDB TESTS ============================================================== -// gdb-command: r +//@ gdb-command: r -// gdb-command: s -// gdb-check:[...]match x { +//@ gdb-command: s +//@ gdb-check:[...]match x { -// gdb-command: s -// gdb-check:[...] Some(42) => 1, +//@ gdb-command: s +//@ gdb-check:[...] Some(42) => 1, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_enum(Some(12)); +//@ gdb-command: s +//@ gdb-check:[...]match_enum(Some(12)); -// gdb-command: s -// gdb-check:[...]match x { +//@ gdb-command: s +//@ gdb-check:[...]match x { -// gdb-command: s -// gdb-check:[...]Some(_) => 2, +//@ gdb-command: s +//@ gdb-check:[...]Some(_) => 2, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_enum(None); +//@ gdb-command: s +//@ gdb-check:[...]match_enum(None); -// gdb-command: s -// gdb-check:[...]match x { +//@ gdb-command: s +//@ gdb-check:[...]match x { -// gdb-command: s -// gdb-check:[...]None => 3, +//@ gdb-command: s +//@ gdb-check:[...]None => 3, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_int(1); +//@ gdb-command: s +//@ gdb-check:[...]match_int(1); -// gdb-command: s -// gdb-check:[...]match y { +//@ gdb-command: s +//@ gdb-check:[...]match y { -// gdb-command: s -// gdb-check:[...]1 => 3, +//@ gdb-command: s +//@ gdb-check:[...]1 => 3, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_int(2); +//@ gdb-command: s +//@ gdb-check:[...]match_int(2); -// gdb-command: s -// gdb-check:[...]match y { +//@ gdb-command: s +//@ gdb-check:[...]match y { -// gdb-command: s -// gdb-check:[...]_ => 4, +//@ gdb-command: s +//@ gdb-check:[...]_ => 4, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_int(0); +//@ gdb-command: s +//@ gdb-check:[...]match_int(0); -// gdb-command: s -// gdb-check:[...]match y { +//@ gdb-command: s +//@ gdb-check:[...]match y { -// gdb-command: s -// gdb-check:[...]0 => 2, +//@ gdb-command: s +//@ gdb-check:[...]0 => 2, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_int(-1); +//@ gdb-command: s +//@ gdb-check:[...]match_int(-1); -// gdb-command: s -// gdb-check:[...]match y { +//@ gdb-command: s +//@ gdb-check:[...]match y { -// gdb-command: s -// gdb-check:[...]-1 => 1, +//@ gdb-command: s +//@ gdb-check:[...]-1 => 1, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_tuple(5, 12); +//@ gdb-command: s +//@ gdb-check:[...]match_tuple(5, 12); -// gdb-command: s -// gdb-check:[...]match (a, b) { +//@ gdb-command: s +//@ gdb-check:[...]match (a, b) { -// gdb-command: s -// gdb-check:[...](5, 12) => 3, +//@ gdb-command: s +//@ gdb-check:[...](5, 12) => 3, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_tuple(29, 1); +//@ gdb-command: s +//@ gdb-check:[...]match_tuple(29, 1); -// gdb-command: s -// gdb-check:[...]match (a, b) { +//@ gdb-command: s +//@ gdb-check:[...]match (a, b) { -// gdb-command: s -// gdb-check:[...](29, _) => 2, +//@ gdb-command: s +//@ gdb-check:[...](29, _) => 2, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_tuple(12, 12); +//@ gdb-command: s +//@ gdb-check:[...]match_tuple(12, 12); -// gdb-command: s -// gdb-check:[...]match (a, b) { +//@ gdb-command: s +//@ gdb-check:[...]match (a, b) { -// gdb-command: s -// gdb-check:[...](_, _) => 5, +//@ gdb-command: s +//@ gdb-check:[...](_, _) => 5, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_tuple(42, 12); +//@ gdb-command: s +//@ gdb-check:[...]match_tuple(42, 12); -// gdb-command: s -// gdb-check:[...]match (a, b) { +//@ gdb-command: s +//@ gdb-check:[...]match (a, b) { -// gdb-command: s -// gdb-check:[...](42, 12) => 1, +//@ gdb-command: s +//@ gdb-check:[...](42, 12) => 1, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]match_tuple(1, 9); +//@ gdb-command: s +//@ gdb-check:[...]match_tuple(1, 9); -// gdb-command: s -// gdb-check:[...]match (a, b) { +//@ gdb-command: s +//@ gdb-check:[...]match (a, b) { -// gdb-command: s -// gdb-check:[...](_, 9) => 4, +//@ gdb-command: s +//@ gdb-check:[...](_, 9) => 4, -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} -// gdb-command: s -// gdb-check:[...]} +//@ gdb-command: s +//@ gdb-check:[...]} // === CDB TESTS ============================================================== // Enable line-based debugging and print lines after stepping. -// cdb-command: .lines -e -// cdb-command: l+s -// cdb-command: l+t +//@ cdb-command: .lines -e +//@ cdb-command: l+s +//@ cdb-command: l+t -// cdb-command: g +//@ cdb-command: g -// cdb-command: t -// cdb-check: [...]: fn match_enum(x: Option) -> u8 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_enum(x: Option) -> u8 { -// cdb-command: t -// cdb-check: [...]: match x { +//@ cdb-command: t +//@ cdb-check: [...]: match x { -// cdb-command: t -// cdb-check: [...]: Some(42) => 1, +//@ cdb-command: t +//@ cdb-check: [...]: Some(42) => 1, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_enum(Some(12)); +//@ cdb-command: t +//@ cdb-check: [...]: match_enum(Some(12)); -// cdb-command: t -// cdb-check: [...]: fn match_enum(x: Option) -> u8 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_enum(x: Option) -> u8 { -// cdb-command: t -// cdb-check: [...]: match x { +//@ cdb-command: t +//@ cdb-check: [...]: match x { -// cdb-command: t -// cdb-check: [...]: Some(_) => 2, +//@ cdb-command: t +//@ cdb-check: [...]: Some(_) => 2, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_enum(None); +//@ cdb-command: t +//@ cdb-check: [...]: match_enum(None); -// cdb-command: t -// cdb-check: [...]: fn match_enum(x: Option) -> u8 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_enum(x: Option) -> u8 { -// cdb-command: t -// cdb-check: [...]: match x { +//@ cdb-command: t +//@ cdb-check: [...]: match x { -// cdb-command: t -// cdb-check: [...]: None => 3, +//@ cdb-command: t +//@ cdb-check: [...]: None => 3, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_int(1); +//@ cdb-command: t +//@ cdb-check: [...]: match_int(1); -// cdb-command: t -// cdb-check: [...]: fn match_int(y: i32) -> u16 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_int(y: i32) -> u16 { -// cdb-command: t -// cdb-check: [...]: match y { +//@ cdb-command: t +//@ cdb-check: [...]: match y { -// cdb-command: t -// cdb-check: [...]: 1 => 3, +//@ cdb-command: t +//@ cdb-check: [...]: 1 => 3, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_int(2); +//@ cdb-command: t +//@ cdb-check: [...]: match_int(2); -// cdb-command: t -// cdb-check: [...]: fn match_int(y: i32) -> u16 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_int(y: i32) -> u16 { -// cdb-command: t -// cdb-check: [...]: match y { +//@ cdb-command: t +//@ cdb-check: [...]: match y { -// cdb-command: t -// cdb-check: [...]: _ => 4, +//@ cdb-command: t +//@ cdb-check: [...]: _ => 4, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_int(0); +//@ cdb-command: t +//@ cdb-check: [...]: match_int(0); -// cdb-command: t -// cdb-check: [...]: fn match_int(y: i32) -> u16 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_int(y: i32) -> u16 { -// cdb-command: t -// cdb-check: [...]: match y { +//@ cdb-command: t +//@ cdb-check: [...]: match y { -// cdb-command: t -// cdb-check: [...]: 0 => 2, +//@ cdb-command: t +//@ cdb-check: [...]: 0 => 2, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_int(-1); +//@ cdb-command: t +//@ cdb-check: [...]: match_int(-1); -// cdb-command: t -// cdb-check: [...]: fn match_int(y: i32) -> u16 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_int(y: i32) -> u16 { -// cdb-command: t -// cdb-check: [...]: match y { +//@ cdb-command: t +//@ cdb-check: [...]: match y { -// cdb-command: t -// cdb-check: [...]: -1 => 1, +//@ cdb-command: t +//@ cdb-check: [...]: -1 => 1, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_tuple(5, 12); +//@ cdb-command: t +//@ cdb-check: [...]: match_tuple(5, 12); -// cdb-command: t -// cdb-check: [...]: fn match_tuple(a: u8, b: i8) -> u32 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_tuple(a: u8, b: i8) -> u32 { -// cdb-command: t -// cdb-check: [...]: match (a, b) { +//@ cdb-command: t +//@ cdb-check: [...]: match (a, b) { -// cdb-command: t -// cdb-check: [...]: (5, 12) => 3, +//@ cdb-command: t +//@ cdb-check: [...]: (5, 12) => 3, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_tuple(29, 1); +//@ cdb-command: t +//@ cdb-check: [...]: match_tuple(29, 1); -// cdb-command: t -// cdb-check: [...]: fn match_tuple(a: u8, b: i8) -> u32 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_tuple(a: u8, b: i8) -> u32 { -// cdb-command: t -// cdb-check: [...]: match (a, b) { +//@ cdb-command: t +//@ cdb-check: [...]: match (a, b) { -// cdb-command: t -// cdb-check: [...]: (29, _) => 2, +//@ cdb-command: t +//@ cdb-check: [...]: (29, _) => 2, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_tuple(12, 12); +//@ cdb-command: t +//@ cdb-check: [...]: match_tuple(12, 12); -// cdb-command: t -// cdb-check: [...]: fn match_tuple(a: u8, b: i8) -> u32 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_tuple(a: u8, b: i8) -> u32 { -// cdb-command: t -// cdb-check: [...]: match (a, b) { +//@ cdb-command: t +//@ cdb-check: [...]: match (a, b) { -// cdb-command: t -// cdb-check: [...]: (_, _) => 5, +//@ cdb-command: t +//@ cdb-check: [...]: (_, _) => 5, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_tuple(42, 12); +//@ cdb-command: t +//@ cdb-check: [...]: match_tuple(42, 12); -// cdb-command: t -// cdb-check: [...]: fn match_tuple(a: u8, b: i8) -> u32 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_tuple(a: u8, b: i8) -> u32 { -// cdb-command: t -// cdb-check: [...]: match (a, b) { +//@ cdb-command: t +//@ cdb-check: [...]: match (a, b) { -// cdb-command: t -// cdb-check: [...]: (42, 12) => 1, +//@ cdb-command: t +//@ cdb-check: [...]: (42, 12) => 1, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: match_tuple(1, 9); +//@ cdb-command: t +//@ cdb-check: [...]: match_tuple(1, 9); -// cdb-command: t -// cdb-check: [...]: fn match_tuple(a: u8, b: i8) -> u32 { +//@ cdb-command: t +//@ cdb-check: [...]: fn match_tuple(a: u8, b: i8) -> u32 { -// cdb-command: t -// cdb-check: [...]: match (a, b) { +//@ cdb-command: t +//@ cdb-check: [...]: match (a, b) { -// cdb-command: t -// cdb-check: [...]: (_, 9) => 4, +//@ cdb-command: t +//@ cdb-check: [...]: (_, 9) => 4, -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } -// cdb-command: t -// cdb-check: [...]: } +//@ cdb-command: t +//@ cdb-check: [...]: } fn main() { match_enum(Some(42)); // #break diff --git a/tests/debuginfo/strings-and-strs.rs b/tests/debuginfo/strings-and-strs.rs index baeebda26a90..afb8b873ca08 100644 --- a/tests/debuginfo/strings-and-strs.rs +++ b/tests/debuginfo/strings-and-strs.rs @@ -5,39 +5,39 @@ //@ disable-gdb-pretty-printers // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print plain_string -// gdb-check:$1 = alloc::string::String {vec: alloc::vec::Vec {buf: alloc::raw_vec::RawVec {inner: alloc::raw_vec::RawVecInner {ptr: core::ptr::unique::Unique {pointer: core::ptr::non_null::NonNull {pointer: 0x[...]}, _marker: core::marker::PhantomData}, cap: core::num::niche_types::UsizeNoHighBit (5), alloc: alloc::alloc::Global}, _marker: core::marker::PhantomData}, len: 5}} +//@ gdb-command:print plain_string +//@ gdb-check:$1 = alloc::string::String {vec: alloc::vec::Vec {buf: alloc::raw_vec::RawVec {inner: alloc::raw_vec::RawVecInner {ptr: core::ptr::unique::Unique {pointer: core::ptr::non_null::NonNull {pointer: 0x[...]}, _marker: core::marker::PhantomData}, cap: core::num::niche_types::UsizeNoHighBit (5), alloc: alloc::alloc::Global}, _marker: core::marker::PhantomData}, len: 5}} -// gdb-command:print plain_str -// gdb-check:$2 = "Hello" +//@ gdb-command:print plain_str +//@ gdb-check:$2 = "Hello" -// gdb-command:print str_in_struct -// gdb-check:$3 = strings_and_strs::Foo {inner: "Hello"} +//@ gdb-command:print str_in_struct +//@ gdb-check:$3 = strings_and_strs::Foo {inner: "Hello"} -// gdb-command:print str_in_tuple -// gdb-check:$4 = ("Hello", "World") +//@ gdb-command:print str_in_tuple +//@ gdb-check:$4 = ("Hello", "World") -// gdb-command:print str_in_rc -// gdb-check:$5 = alloc::rc::Rc<&str, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull> {pointer: 0x[...]}, phantom: core::marker::PhantomData>, alloc: alloc::alloc::Global} +//@ gdb-command:print str_in_rc +//@ gdb-check:$5 = alloc::rc::Rc<&str, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull> {pointer: 0x[...]}, phantom: core::marker::PhantomData>, alloc: alloc::alloc::Global} // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v plain_string -// lldb-check:(alloc::string::String) plain_string = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } +//@ lldb-command:run +//@ lldb-command:v plain_string +//@ lldb-check:(alloc::string::String) plain_string = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } -// lldb-command:v plain_str -// lldb-check:(&str) plain_str = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } +//@ lldb-command:v plain_str +//@ lldb-check:(&str) plain_str = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } -// lldb-command:v str_in_struct -// lldb-check:(strings_and_strs::Foo) str_in_struct = { inner = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } +//@ lldb-command:v str_in_struct +//@ lldb-check:(strings_and_strs::Foo) str_in_struct = { inner = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } -// lldb-command:v str_in_tuple -// lldb-check:((&str, &str)) str_in_tuple = ("Hello", "World") { 0 = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } 1 = "World" { [0] = 'W' [1] = 'o' [2] = 'r' [3] = 'l' [4] = 'd' } } +//@ lldb-command:v str_in_tuple +//@ lldb-check:((&str, &str)) str_in_tuple = ("Hello", "World") { 0 = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } 1 = "World" { [0] = 'W' [1] = 'o' [2] = 'r' [3] = 'l' [4] = 'd' } } -// lldb-command:v str_in_rc -// lldb-check:(alloc::rc::Rc<&str, alloc::alloc::Global>) str_in_rc = strong=1, weak=0 { value = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } +//@ lldb-command:v str_in_rc +//@ lldb-check:(alloc::rc::Rc<&str, alloc::alloc::Global>) str_in_rc = strong=1, weak=0 { value = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } } #![allow(unused_variables)] diff --git a/tests/debuginfo/struct-in-enum.rs b/tests/debuginfo/struct-in-enum.rs index 640066b8d0b1..02b2e6eb4cb7 100644 --- a/tests/debuginfo/struct-in-enum.rs +++ b/tests/debuginfo/struct-in-enum.rs @@ -6,31 +6,31 @@ // === GDB TESTS =================================================================================== -// gdb-command:set print union on -// gdb-command:run +//@ gdb-command:set print union on +//@ gdb-command:run -// gdb-command:print case1 -// gdb-check:$1 = struct_in_enum::Regular::Case1(0, struct_in_enum::Struct {x: 2088533116, y: 2088533116, z: 31868}) +//@ gdb-command:print case1 +//@ gdb-check:$1 = struct_in_enum::Regular::Case1(0, struct_in_enum::Struct {x: 2088533116, y: 2088533116, z: 31868}) -// gdb-command:print case2 -// gdb-check:$2 = struct_in_enum::Regular::Case2(0, 1229782938247303441, 4369) +//@ gdb-command:print case2 +//@ gdb-check:$2 = struct_in_enum::Regular::Case2(0, 1229782938247303441, 4369) -// gdb-command:print univariant -// gdb-check:$3 = struct_in_enum::Univariant::TheOnlyCase(struct_in_enum::Struct {x: 123, y: 456, z: 789}) +//@ gdb-command:print univariant +//@ gdb-check:$3 = struct_in_enum::Univariant::TheOnlyCase(struct_in_enum::Struct {x: 123, y: 456, z: 789}) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v case1 -// lldb-check:[...] Case1(0, {x:2088533116, y:2088533116, z:31868}) { 0 = 0 1 = { x = 2088533116 y = 2088533116 z = 31868 } } +//@ lldb-command:v case1 +//@ lldb-check:[...] Case1(0, {x:2088533116, y:2088533116, z:31868}) { 0 = 0 1 = { x = 2088533116 y = 2088533116 z = 31868 } } -// lldb-command:v case2 -// lldb-check:[...] Case2(0, 1229782938247303441, 4369) { 0 = 0 1 = 1229782938247303441 2 = 4369 } +//@ lldb-command:v case2 +//@ lldb-check:[...] Case2(0, 1229782938247303441, 4369) { 0 = 0 1 = 1229782938247303441 2 = 4369 } -// lldb-command:v univariant -// lldb-check:[...] TheOnlyCase({x:123, y:456, z:789}) { 0 = { x = 123 y = 456 z = 789 } } +//@ lldb-command:v univariant +//@ lldb-check:[...] TheOnlyCase({x:123, y:456, z:789}) { 0 = { x = 123 y = 456 z = 789 } } #![allow(unused_variables)] diff --git a/tests/debuginfo/struct-in-struct.rs b/tests/debuginfo/struct-in-struct.rs index 4f770e7e56c8..e5fa8412af8a 100644 --- a/tests/debuginfo/struct-in-struct.rs +++ b/tests/debuginfo/struct-in-struct.rs @@ -4,45 +4,45 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print three_simple_structs -// gdb-check:$1 = struct_in_struct::ThreeSimpleStructs {x: struct_in_struct::Simple {x: 1}, y: struct_in_struct::Simple {x: 2}, z: struct_in_struct::Simple {x: 3}} +//@ gdb-command:print three_simple_structs +//@ gdb-check:$1 = struct_in_struct::ThreeSimpleStructs {x: struct_in_struct::Simple {x: 1}, y: struct_in_struct::Simple {x: 2}, z: struct_in_struct::Simple {x: 3}} -// gdb-command:print internal_padding_parent -// gdb-check:$2 = struct_in_struct::InternalPaddingParent {x: struct_in_struct::InternalPadding {x: 4, y: 5}, y: struct_in_struct::InternalPadding {x: 6, y: 7}, z: struct_in_struct::InternalPadding {x: 8, y: 9}} +//@ gdb-command:print internal_padding_parent +//@ gdb-check:$2 = struct_in_struct::InternalPaddingParent {x: struct_in_struct::InternalPadding {x: 4, y: 5}, y: struct_in_struct::InternalPadding {x: 6, y: 7}, z: struct_in_struct::InternalPadding {x: 8, y: 9}} -// gdb-command:print padding_at_end_parent -// gdb-check:$3 = struct_in_struct::PaddingAtEndParent {x: struct_in_struct::PaddingAtEnd {x: 10, y: 11}, y: struct_in_struct::PaddingAtEnd {x: 12, y: 13}, z: struct_in_struct::PaddingAtEnd {x: 14, y: 15}} +//@ gdb-command:print padding_at_end_parent +//@ gdb-check:$3 = struct_in_struct::PaddingAtEndParent {x: struct_in_struct::PaddingAtEnd {x: 10, y: 11}, y: struct_in_struct::PaddingAtEnd {x: 12, y: 13}, z: struct_in_struct::PaddingAtEnd {x: 14, y: 15}} // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v three_simple_structs -// lldb-check:[...] { x = { x = 1 } y = { x = 2 } z = { x = 3 } } +//@ lldb-command:v three_simple_structs +//@ lldb-check:[...] { x = { x = 1 } y = { x = 2 } z = { x = 3 } } -// lldb-command:v internal_padding_parent -// lldb-check:[...] { x = { x = 4 y = 5 } y = { x = 6 y = 7 } z = { x = 8 y = 9 } } +//@ lldb-command:v internal_padding_parent +//@ lldb-check:[...] { x = { x = 4 y = 5 } y = { x = 6 y = 7 } z = { x = 8 y = 9 } } -// lldb-command:v padding_at_end_parent -// lldb-check:[...] { x = { x = 10 y = 11 } y = { x = 12 y = 13 } z = { x = 14 y = 15 } } +//@ lldb-command:v padding_at_end_parent +//@ lldb-check:[...] { x = { x = 10 y = 11 } y = { x = 12 y = 13 } z = { x = 14 y = 15 } } -// lldb-command:v mixed -// lldb-check:[...] { x = { x = 16 y = 17 } y = { x = 18 y = 19 } z = { x = 20 } w = 21 } +//@ lldb-command:v mixed +//@ lldb-check:[...] { x = { x = 16 y = 17 } y = { x = 18 y = 19 } z = { x = 20 } w = 21 } -// lldb-command:v bag -// lldb-check:[...] { x = { x = 22 } } +//@ lldb-command:v bag +//@ lldb-check:[...] { x = { x = 22 } } -// lldb-command:v bag_in_bag -// lldb-check:[...] { x = { x = { x = 23 } } } +//@ lldb-command:v bag_in_bag +//@ lldb-check:[...] { x = { x = { x = 23 } } } -// lldb-command:v tjo -// lldb-check:[...] { x = { x = { x = { x = 24 } } } } +//@ lldb-command:v tjo +//@ lldb-check:[...] { x = { x = { x = { x = 24 } } } } -// lldb-command:v tree -// lldb-check:[...] { x = { x = 25 } y = { x = { x = 26 y = 27 } y = { x = 28 y = 29 } z = { x = 30 y = 31 } } z = { x = { x = { x = 32 } } } } +//@ lldb-command:v tree +//@ lldb-check:[...] { x = { x = 25 } y = { x = { x = 26 y = 27 } y = { x = 28 y = 29 } z = { x = 30 y = 31 } } z = { x = { x = { x = 32 } } } } #![allow(unused_variables)] diff --git a/tests/debuginfo/struct-namespace.rs b/tests/debuginfo/struct-namespace.rs index d56c84c4f13b..67d2602a4046 100644 --- a/tests/debuginfo/struct-namespace.rs +++ b/tests/debuginfo/struct-namespace.rs @@ -4,16 +4,16 @@ // Check that structs get placed in the correct namespace -// lldb-command:run -// lldb-command:v struct1 -// lldb-check:(struct_namespace::Struct1)[...] -// lldb-command:v struct2 -// lldb-check:(struct_namespace::Struct2)[...] +//@ lldb-command:run +//@ lldb-command:v struct1 +//@ lldb-check:(struct_namespace::Struct1)[...] +//@ lldb-command:v struct2 +//@ lldb-check:(struct_namespace::Struct2)[...] -// lldb-command:v mod1_struct1 -// lldb-check:(struct_namespace::mod1::Struct1)[...] -// lldb-command:v mod1_struct2 -// lldb-check:(struct_namespace::mod1::Struct2)[...] +//@ lldb-command:v mod1_struct1 +//@ lldb-check:(struct_namespace::mod1::Struct1)[...] +//@ lldb-command:v mod1_struct2 +//@ lldb-check:(struct_namespace::mod1::Struct2)[...] #![allow(unused_variables)] #![allow(dead_code)] diff --git a/tests/debuginfo/struct-style-enum.rs b/tests/debuginfo/struct-style-enum.rs index 4bbd87925704..e3d6c64c36aa 100644 --- a/tests/debuginfo/struct-style-enum.rs +++ b/tests/debuginfo/struct-style-enum.rs @@ -5,37 +5,37 @@ // === GDB TESTS =================================================================================== -// gdb-command:set print union on -// gdb-command:run +//@ gdb-command:set print union on +//@ gdb-command:run -// gdb-command:print case1 -// gdb-check:$1 = struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868} +//@ gdb-command:print case1 +//@ gdb-check:$1 = struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868} -// gdb-command:print case2 -// gdb-check:$2 = struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153} +//@ gdb-command:print case2 +//@ gdb-check:$2 = struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153} -// gdb-command:print case3 -// gdb-check:$3 = struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897} +//@ gdb-command:print case3 +//@ gdb-check:$3 = struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897} -// gdb-command:print univariant -// gdb-check:$4 = struct_style_enum::Univariant::TheOnlyCase{a: -1} +//@ gdb-command:print univariant +//@ gdb-check:$4 = struct_style_enum::Univariant::TheOnlyCase{a: -1} // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v case1 -// lldb-check:(struct_style_enum::Regular) case1 = Case1{a:0, b:31868, c:31868, d:31868, e:31868} { a = 0 b = 31868 c = 31868 d = 31868 e = 31868 } +//@ lldb-command:v case1 +//@ lldb-check:(struct_style_enum::Regular) case1 = Case1{a:0, b:31868, c:31868, d:31868, e:31868} { a = 0 b = 31868 c = 31868 d = 31868 e = 31868 } -// lldb-command:v case2 -// lldb-check:(struct_style_enum::Regular) case2 = Case2{a:0, b:286331153, c:286331153} { a = 0 b = 286331153 c = 286331153 } +//@ lldb-command:v case2 +//@ lldb-check:(struct_style_enum::Regular) case2 = Case2{a:0, b:286331153, c:286331153} { a = 0 b = 286331153 c = 286331153 } -// lldb-command:v case3 -// lldb-check:(struct_style_enum::Regular) case3 = Case3{a:0, b:6438275382588823897} { a = 0 b = 6438275382588823897 } +//@ lldb-command:v case3 +//@ lldb-check:(struct_style_enum::Regular) case3 = Case3{a:0, b:6438275382588823897} { a = 0 b = 6438275382588823897 } -// lldb-command:v univariant -// lldb-check:(struct_style_enum::Univariant) univariant = TheOnlyCase{a:-1} { a = -1 } +//@ lldb-command:v univariant +//@ lldb-check:(struct_style_enum::Univariant) univariant = TheOnlyCase{a:-1} { a = -1 } #![allow(unused_variables)] diff --git a/tests/debuginfo/struct-with-destructor.rs b/tests/debuginfo/struct-with-destructor.rs index 2cdac43ba500..a27ac14b369f 100644 --- a/tests/debuginfo/struct-with-destructor.rs +++ b/tests/debuginfo/struct-with-destructor.rs @@ -4,34 +4,34 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print simple -// gdb-check:$1 = struct_with_destructor::WithDestructor {x: 10, y: 20} +//@ gdb-command:run +//@ gdb-command:print simple +//@ gdb-check:$1 = struct_with_destructor::WithDestructor {x: 10, y: 20} -// gdb-command:print noDestructor -// gdb-check:$2 = struct_with_destructor::NoDestructorGuarded {a: struct_with_destructor::NoDestructor {x: 10, y: 20}, guard: -1} +//@ gdb-command:print noDestructor +//@ gdb-check:$2 = struct_with_destructor::NoDestructorGuarded {a: struct_with_destructor::NoDestructor {x: 10, y: 20}, guard: -1} -// gdb-command:print withDestructor -// gdb-check:$3 = struct_with_destructor::WithDestructorGuarded {a: struct_with_destructor::WithDestructor {x: 10, y: 20}, guard: -1} +//@ gdb-command:print withDestructor +//@ gdb-check:$3 = struct_with_destructor::WithDestructorGuarded {a: struct_with_destructor::WithDestructor {x: 10, y: 20}, guard: -1} -// gdb-command:print nested -// gdb-check:$4 = struct_with_destructor::NestedOuter {a: struct_with_destructor::NestedInner {a: struct_with_destructor::WithDestructor {x: 7890, y: 9870}}} +//@ gdb-command:print nested +//@ gdb-check:$4 = struct_with_destructor::NestedOuter {a: struct_with_destructor::NestedInner {a: struct_with_destructor::WithDestructor {x: 7890, y: 9870}}} // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v simple -// lldb-check:[...] { x = 10 y = 20 } +//@ lldb-command:run +//@ lldb-command:v simple +//@ lldb-check:[...] { x = 10 y = 20 } -// lldb-command:v noDestructor -// lldb-check:[...] { a = { x = 10 y = 20 } guard = -1 } +//@ lldb-command:v noDestructor +//@ lldb-check:[...] { a = { x = 10 y = 20 } guard = -1 } -// lldb-command:v withDestructor -// lldb-check:[...] { a = { x = 10 y = 20 } guard = -1 } +//@ lldb-command:v withDestructor +//@ lldb-check:[...] { a = { x = 10 y = 20 } guard = -1 } -// lldb-command:v nested -// lldb-check:[...] { a = { a = { x = 7890 y = 9870 } } } +//@ lldb-command:v nested +//@ lldb-check:[...] { a = { a = { x = 7890 y = 9870 } } } #![allow(unused_variables)] diff --git a/tests/debuginfo/thread-names.rs b/tests/debuginfo/thread-names.rs index 265b9271cf30..19d27f55f80d 100644 --- a/tests/debuginfo/thread-names.rs +++ b/tests/debuginfo/thread-names.rs @@ -8,28 +8,28 @@ // === GDB TESTS ================================================================================== // -// gdb-command:run +//@ gdb-command:run // -// gdb-command:info threads -// gdb-check: 1 Thread [...] [...] "main" [...] -// gdb-check:* 2 Thread [...] [...] "my new thread" [...] +//@ gdb-command:info threads +//@ gdb-check: 1 Thread [...] [...] "main" [...] +//@ gdb-check:* 2 Thread [...] [...] "my new thread" [...] // === LLDB TESTS ================================================================================= // -// lldb-command:run +//@ lldb-command:run // -// lldb-command:thread info 1 -// lldb-check:thread #1:[...]name = 'main'[...] -// lldb-command:thread info 2 -// lldb-check:thread #2:[...]name = 'my new thread'[...] +//@ lldb-command:thread info 1 +//@ lldb-check:thread #1:[...]name = 'main'[...] +//@ lldb-command:thread info 2 +//@ lldb-check:thread #2:[...]name = 'my new thread'[...] // === CDB TESTS ================================================================================== // -// cdb-command:g +//@ cdb-command:g // -// cdb-command:~ -// cdb-check: 0 Id: [...] Suspend: 1 Teb: [...] Unfrozen "main" -// cdb-check:. [...] Id: [...] Suspend: 1 Teb: [...] Unfrozen "my new thread" +//@ cdb-command:~ +//@ cdb-check: 0 Id: [...] Suspend: 1 Teb: [...] Unfrozen "main" +//@ cdb-check:. [...] Id: [...] Suspend: 1 Teb: [...] Unfrozen "my new thread" use std::thread; diff --git a/tests/debuginfo/thread.rs b/tests/debuginfo/thread.rs index 0415f586f5d9..5120da62f2ab 100644 --- a/tests/debuginfo/thread.rs +++ b/tests/debuginfo/thread.rs @@ -6,15 +6,15 @@ // === CDB TESTS ================================================================================== // -// cdb-command:g +//@ cdb-command:g // -// cdb-command:dx join_handle,d -// cdb-check:join_handle,d [Type: std::thread::JoinHandle >] -// cdb-check: [...] __0 [Type: std::thread::JoinInner >] +//@ cdb-command:dx join_handle,d +//@ cdb-check:join_handle,d [Type: std::thread::JoinHandle >] +//@ cdb-check: [...] __0 [Type: std::thread::JoinInner >] // -// cdb-command:dx t,d -// cdb-check:t,d : [...] [Type: std::thread::Thread *] -// cdb-check:[...] inner [...][Type: core::pin::Pin >] +//@ cdb-command:dx t,d +//@ cdb-check:t,d : [...] [Type: std::thread::Thread *] +//@ cdb-check:[...] inner [...][Type: core::pin::Pin >] use std::thread; diff --git a/tests/debuginfo/trait-pointers.rs b/tests/debuginfo/trait-pointers.rs index 5cdefe94e507..c79b212b08f5 100644 --- a/tests/debuginfo/trait-pointers.rs +++ b/tests/debuginfo/trait-pointers.rs @@ -1,7 +1,7 @@ //@ compile-flags:-g //@ disable-gdb-pretty-printers -// gdb-command:run -// lldb-command:run +//@ gdb-command:run +//@ lldb-command:run #![allow(unused_variables)] diff --git a/tests/debuginfo/tuple-in-struct.rs b/tests/debuginfo/tuple-in-struct.rs index 3223532b16a4..4a80b56cf7cb 100644 --- a/tests/debuginfo/tuple-in-struct.rs +++ b/tests/debuginfo/tuple-in-struct.rs @@ -2,32 +2,32 @@ //@ disable-gdb-pretty-printers //@ ignore-backends: gcc -// gdb-command:run +//@ gdb-command:run -// gdb-command:print no_padding1 -// gdb-check:$1 = tuple_in_struct::NoPadding1 {x: (0, 1), y: 2, z: (3, 4, 5)} -// gdb-command:print no_padding2 -// gdb-check:$2 = tuple_in_struct::NoPadding2 {x: (6, 7), y: ((8, 9), 10)} +//@ gdb-command:print no_padding1 +//@ gdb-check:$1 = tuple_in_struct::NoPadding1 {x: (0, 1), y: 2, z: (3, 4, 5)} +//@ gdb-command:print no_padding2 +//@ gdb-check:$2 = tuple_in_struct::NoPadding2 {x: (6, 7), y: ((8, 9), 10)} -// gdb-command:print tuple_internal_padding -// gdb-check:$3 = tuple_in_struct::TupleInternalPadding {x: (11, 12), y: (13, 14)} -// gdb-command:print struct_internal_padding -// gdb-check:$4 = tuple_in_struct::StructInternalPadding {x: (15, 16), y: (17, 18)} -// gdb-command:print both_internally_padded -// gdb-check:$5 = tuple_in_struct::BothInternallyPadded {x: (19, 20, 21), y: (22, 23)} +//@ gdb-command:print tuple_internal_padding +//@ gdb-check:$3 = tuple_in_struct::TupleInternalPadding {x: (11, 12), y: (13, 14)} +//@ gdb-command:print struct_internal_padding +//@ gdb-check:$4 = tuple_in_struct::StructInternalPadding {x: (15, 16), y: (17, 18)} +//@ gdb-command:print both_internally_padded +//@ gdb-check:$5 = tuple_in_struct::BothInternallyPadded {x: (19, 20, 21), y: (22, 23)} -// gdb-command:print single_tuple -// gdb-check:$6 = tuple_in_struct::SingleTuple {x: (24, 25, 26)} +//@ gdb-command:print single_tuple +//@ gdb-check:$6 = tuple_in_struct::SingleTuple {x: (24, 25, 26)} -// gdb-command:print tuple_padded_at_end -// gdb-check:$7 = tuple_in_struct::TuplePaddedAtEnd {x: (27, 28), y: (29, 30)} -// gdb-command:print struct_padded_at_end -// gdb-check:$8 = tuple_in_struct::StructPaddedAtEnd {x: (31, 32), y: (33, 34)} -// gdb-command:print both_padded_at_end -// gdb-check:$9 = tuple_in_struct::BothPaddedAtEnd {x: (35, 36, 37), y: (38, 39)} +//@ gdb-command:print tuple_padded_at_end +//@ gdb-check:$7 = tuple_in_struct::TuplePaddedAtEnd {x: (27, 28), y: (29, 30)} +//@ gdb-command:print struct_padded_at_end +//@ gdb-check:$8 = tuple_in_struct::StructPaddedAtEnd {x: (31, 32), y: (33, 34)} +//@ gdb-command:print both_padded_at_end +//@ gdb-check:$9 = tuple_in_struct::BothPaddedAtEnd {x: (35, 36, 37), y: (38, 39)} -// gdb-command:print mixed_padding -// gdb-check:$10 = tuple_in_struct::MixedPadding {x: ((40, 41, 42), (43, 44)), y: (45, 46, 47, 48)} +//@ gdb-command:print mixed_padding +//@ gdb-check:$10 = tuple_in_struct::MixedPadding {x: ((40, 41, 42), (43, 44)), y: (45, 46, 47, 48)} #![allow(unused_variables)] diff --git a/tests/debuginfo/tuple-in-tuple.rs b/tests/debuginfo/tuple-in-tuple.rs index 40e88f1b2084..98e2daf623ef 100644 --- a/tests/debuginfo/tuple-in-tuple.rs +++ b/tests/debuginfo/tuple-in-tuple.rs @@ -4,113 +4,113 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print no_padding1 -// gdb-check:$1 = ((0, 1), 2, 3) -// gdb-command:print no_padding2 -// gdb-check:$2 = (4, (5, 6), 7) -// gdb-command:print no_padding3 -// gdb-check:$3 = (8, 9, (10, 11)) +//@ gdb-command:print no_padding1 +//@ gdb-check:$1 = ((0, 1), 2, 3) +//@ gdb-command:print no_padding2 +//@ gdb-check:$2 = (4, (5, 6), 7) +//@ gdb-command:print no_padding3 +//@ gdb-check:$3 = (8, 9, (10, 11)) -// gdb-command:print internal_padding1 -// gdb-check:$4 = (12, (13, 14)) -// gdb-command:print internal_padding2 -// gdb-check:$5 = (15, (16, 17)) +//@ gdb-command:print internal_padding1 +//@ gdb-check:$4 = (12, (13, 14)) +//@ gdb-command:print internal_padding2 +//@ gdb-check:$5 = (15, (16, 17)) -// gdb-command:print padding_at_end1 -// gdb-check:$6 = (18, (19, 20)) -// gdb-command:print padding_at_end2 -// gdb-check:$7 = ((21, 22), 23) +//@ gdb-command:print padding_at_end1 +//@ gdb-check:$6 = (18, (19, 20)) +//@ gdb-command:print padding_at_end2 +//@ gdb-check:$7 = ((21, 22), 23) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v no_padding1 -// lldb-check:[...] ((0, 1), 2, 3) { 0 = (0, 1) { 0 = 0 1 = 1 } 1 = 2 2 = 3 } -// lldb-command:v no_padding2 -// lldb-check:[...] (4, (5, 6), 7) { 0 = 4 1 = (5, 6) { 0 = 5 1 = 6 } 2 = 7 } -// lldb-command:v no_padding3 -// lldb-check:[...] (8, 9, (10, 11)) { 0 = 8 1 = 9 2 = (10, 11) { 0 = 10 1 = 11 } } +//@ lldb-command:v no_padding1 +//@ lldb-check:[...] ((0, 1), 2, 3) { 0 = (0, 1) { 0 = 0 1 = 1 } 1 = 2 2 = 3 } +//@ lldb-command:v no_padding2 +//@ lldb-check:[...] (4, (5, 6), 7) { 0 = 4 1 = (5, 6) { 0 = 5 1 = 6 } 2 = 7 } +//@ lldb-command:v no_padding3 +//@ lldb-check:[...] (8, 9, (10, 11)) { 0 = 8 1 = 9 2 = (10, 11) { 0 = 10 1 = 11 } } -// lldb-command:v internal_padding1 -// lldb-check:[...] (12, (13, 14)) { 0 = 12 1 = (13, 14) { 0 = 13 1 = 14 } } -// lldb-command:v internal_padding2 -// lldb-check:[...] (15, (16, 17)) { 0 = 15 1 = (16, 17) { 0 = 16 1 = 17 } } +//@ lldb-command:v internal_padding1 +//@ lldb-check:[...] (12, (13, 14)) { 0 = 12 1 = (13, 14) { 0 = 13 1 = 14 } } +//@ lldb-command:v internal_padding2 +//@ lldb-check:[...] (15, (16, 17)) { 0 = 15 1 = (16, 17) { 0 = 16 1 = 17 } } -// lldb-command:v padding_at_end1 -// lldb-check:[...] (18, (19, 20)) { 0 = 18 1 = (19, 20) { 0 = 19 1 = 20 } } -// lldb-command:v padding_at_end2 -// lldb-check:[...] ((21, 22), 23) { 0 = (21, 22) { 0 = 21 1 = 22 } 1 = 23 } +//@ lldb-command:v padding_at_end1 +//@ lldb-check:[...] (18, (19, 20)) { 0 = 18 1 = (19, 20) { 0 = 19 1 = 20 } } +//@ lldb-command:v padding_at_end2 +//@ lldb-check:[...] ((21, 22), 23) { 0 = (21, 22) { 0 = 21 1 = 22 } 1 = 23 } // === CDB TESTS ================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command:dx no_padding1,d -// cdb-check:no_padding1,d [...]: ((0, 1), 2, 3) [Type: tuple$,u32,u32>] -// cdb-check:[...][0] : (0, 1) [Type: tuple$] -// cdb-check:[...][1] : 2 [Type: [...]] -// cdb-check:[...][2] : 3 [Type: [...]] -// cdb-command:dx no_padding1.__0,d -// cdb-check:no_padding1.__0,d [...]: (0, 1) [Type: tuple$] -// cdb-check:[...][0] : 0 [Type: [...]] -// cdb-check:[...][1] : 1 [Type: [...]] -// cdb-command:dx no_padding2,d -// cdb-check:no_padding2,d [...]: (4, (5, 6), 7) [Type: tuple$,u32>] -// cdb-check:[...][0] : 4 [Type: [...]] -// cdb-check:[...][1] : (5, 6) [Type: tuple$] -// cdb-check:[...][2] : 7 [Type: [...]] -// cdb-command:dx no_padding2.__1,d -// cdb-check:no_padding2.__1,d [...]: (5, 6) [Type: tuple$] -// cdb-check:[...][0] : 5 [Type: [...]] -// cdb-check:[...][1] : 6 [Type: [...]] -// cdb-command:dx no_padding3,d -// cdb-check:no_padding3,d [...]: (8, 9, (10, 11)) [Type: tuple$ >] -// cdb-check:[...][0] : 8 [Type: [...]] -// cdb-check:[...][1] : 9 [Type: [...]] -// cdb-check:[...][2] : (10, 11) [Type: tuple$] -// cdb-command:dx no_padding3.__2,d -// cdb-check:no_padding3.__2,d [...]: (10, 11) [Type: tuple$] -// cdb-check:[...][0] : 10 [Type: [...]] -// cdb-check:[...][1] : 11 [Type: [...]] +//@ cdb-command:dx no_padding1,d +//@ cdb-check:no_padding1,d [...]: ((0, 1), 2, 3) [Type: tuple$,u32,u32>] +//@ cdb-check:[...][0] : (0, 1) [Type: tuple$] +//@ cdb-check:[...][1] : 2 [Type: [...]] +//@ cdb-check:[...][2] : 3 [Type: [...]] +//@ cdb-command:dx no_padding1.__0,d +//@ cdb-check:no_padding1.__0,d [...]: (0, 1) [Type: tuple$] +//@ cdb-check:[...][0] : 0 [Type: [...]] +//@ cdb-check:[...][1] : 1 [Type: [...]] +//@ cdb-command:dx no_padding2,d +//@ cdb-check:no_padding2,d [...]: (4, (5, 6), 7) [Type: tuple$,u32>] +//@ cdb-check:[...][0] : 4 [Type: [...]] +//@ cdb-check:[...][1] : (5, 6) [Type: tuple$] +//@ cdb-check:[...][2] : 7 [Type: [...]] +//@ cdb-command:dx no_padding2.__1,d +//@ cdb-check:no_padding2.__1,d [...]: (5, 6) [Type: tuple$] +//@ cdb-check:[...][0] : 5 [Type: [...]] +//@ cdb-check:[...][1] : 6 [Type: [...]] +//@ cdb-command:dx no_padding3,d +//@ cdb-check:no_padding3,d [...]: (8, 9, (10, 11)) [Type: tuple$ >] +//@ cdb-check:[...][0] : 8 [Type: [...]] +//@ cdb-check:[...][1] : 9 [Type: [...]] +//@ cdb-check:[...][2] : (10, 11) [Type: tuple$] +//@ cdb-command:dx no_padding3.__2,d +//@ cdb-check:no_padding3.__2,d [...]: (10, 11) [Type: tuple$] +//@ cdb-check:[...][0] : 10 [Type: [...]] +//@ cdb-check:[...][1] : 11 [Type: [...]] -// cdb-command:dx internal_padding1,d -// cdb-check:internal_padding1,d [...]: (12, (13, 14)) [Type: tuple$ >] -// cdb-check:[...][0] : 12 [Type: [...]] -// cdb-check:[...][1] : (13, 14) [Type: tuple$] -// cdb-command:dx internal_padding1.__1,d -// cdb-check:internal_padding1.__1,d [...]: (13, 14) [Type: tuple$] -// cdb-check:[...][0] : 13 [Type: [...]] -// cdb-check:[...][1] : 14 [Type: [...]] -// cdb-command:dx internal_padding2,d -// cdb-check:internal_padding2,d [...]: (15, (16, 17)) [Type: tuple$ >] -// cdb-check:[...][0] : 15 [Type: [...]] -// cdb-check:[...][1] : (16, 17) [Type: tuple$] -// cdb-command:dx internal_padding2.__1,d -// cdb-check:internal_padding2.__1,d [...]: (16, 17) [Type: tuple$] -// cdb-check:[...][0] : 16 [Type: [...]] -// cdb-check:[...][1] : 17 [Type: [...]] +//@ cdb-command:dx internal_padding1,d +//@ cdb-check:internal_padding1,d [...]: (12, (13, 14)) [Type: tuple$ >] +//@ cdb-check:[...][0] : 12 [Type: [...]] +//@ cdb-check:[...][1] : (13, 14) [Type: tuple$] +//@ cdb-command:dx internal_padding1.__1,d +//@ cdb-check:internal_padding1.__1,d [...]: (13, 14) [Type: tuple$] +//@ cdb-check:[...][0] : 13 [Type: [...]] +//@ cdb-check:[...][1] : 14 [Type: [...]] +//@ cdb-command:dx internal_padding2,d +//@ cdb-check:internal_padding2,d [...]: (15, (16, 17)) [Type: tuple$ >] +//@ cdb-check:[...][0] : 15 [Type: [...]] +//@ cdb-check:[...][1] : (16, 17) [Type: tuple$] +//@ cdb-command:dx internal_padding2.__1,d +//@ cdb-check:internal_padding2.__1,d [...]: (16, 17) [Type: tuple$] +//@ cdb-check:[...][0] : 16 [Type: [...]] +//@ cdb-check:[...][1] : 17 [Type: [...]] -// cdb-command:dx padding_at_end1,d -// cdb-check:padding_at_end1,d [...]: (18, (19, 20)) [Type: tuple$ >] -// cdb-check:[...][0] : 18 [Type: [...]] -// cdb-check:[...][1] : (19, 20) [Type: tuple$] -// cdb-command:dx padding_at_end1.__1,d -// cdb-check:padding_at_end1.__1,d [...][Type: tuple$] -// cdb-check:[...][0] : 19 [Type: [...]] -// cdb-check:[...][1] : 20 [Type: [...]] -// cdb-command:dx padding_at_end2,d -// cdb-check:padding_at_end2,d [...]: ((21, 22), 23) [Type: tuple$,i32>] -// cdb-check:[...][0] : (21, 22) [Type: tuple$] -// cdb-check:[...][1] : 23 [Type: [...]] -// cdb-command:dx padding_at_end2.__0,d -// cdb-check:padding_at_end2.__0,d [...]: (21, 22) [Type: tuple$] -// cdb-check:[...][0] : 21 [Type: [...]] -// cdb-check:[...][1] : 22 [Type: [...]] +//@ cdb-command:dx padding_at_end1,d +//@ cdb-check:padding_at_end1,d [...]: (18, (19, 20)) [Type: tuple$ >] +//@ cdb-check:[...][0] : 18 [Type: [...]] +//@ cdb-check:[...][1] : (19, 20) [Type: tuple$] +//@ cdb-command:dx padding_at_end1.__1,d +//@ cdb-check:padding_at_end1.__1,d [...][Type: tuple$] +//@ cdb-check:[...][0] : 19 [Type: [...]] +//@ cdb-check:[...][1] : 20 [Type: [...]] +//@ cdb-command:dx padding_at_end2,d +//@ cdb-check:padding_at_end2,d [...]: ((21, 22), 23) [Type: tuple$,i32>] +//@ cdb-check:[...][0] : (21, 22) [Type: tuple$] +//@ cdb-check:[...][1] : 23 [Type: [...]] +//@ cdb-command:dx padding_at_end2.__0,d +//@ cdb-check:padding_at_end2.__0,d [...]: (21, 22) [Type: tuple$] +//@ cdb-check:[...][0] : 21 [Type: [...]] +//@ cdb-check:[...][1] : 22 [Type: [...]] #![allow(unused_variables)] diff --git a/tests/debuginfo/tuple-struct.rs b/tests/debuginfo/tuple-struct.rs index 44fc862c43c9..9992732b8208 100644 --- a/tests/debuginfo/tuple-struct.rs +++ b/tests/debuginfo/tuple-struct.rs @@ -4,48 +4,48 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print no_padding16 -// gdb-check:$1 = tuple_struct::NoPadding16 (10000, -10001) +//@ gdb-command:print no_padding16 +//@ gdb-check:$1 = tuple_struct::NoPadding16 (10000, -10001) -// gdb-command:print no_padding32 -// gdb-check:$2 = tuple_struct::NoPadding32 (-10002, -10003.5, 10004) +//@ gdb-command:print no_padding32 +//@ gdb-check:$2 = tuple_struct::NoPadding32 (-10002, -10003.5, 10004) -// gdb-command:print no_padding64 -// gdb-check:$3 = tuple_struct::NoPadding64 (-10005.5, 10006, 10007) +//@ gdb-command:print no_padding64 +//@ gdb-check:$3 = tuple_struct::NoPadding64 (-10005.5, 10006, 10007) -// gdb-command:print no_padding163264 -// gdb-check:$4 = tuple_struct::NoPadding163264 (-10008, 10009, 10010, 10011) +//@ gdb-command:print no_padding163264 +//@ gdb-check:$4 = tuple_struct::NoPadding163264 (-10008, 10009, 10010, 10011) -// gdb-command:print internal_padding -// gdb-check:$5 = tuple_struct::InternalPadding (10012, -10013) +//@ gdb-command:print internal_padding +//@ gdb-check:$5 = tuple_struct::InternalPadding (10012, -10013) -// gdb-command:print padding_at_end -// gdb-check:$6 = tuple_struct::PaddingAtEnd (-10014, 10015) +//@ gdb-command:print padding_at_end +//@ gdb-check:$6 = tuple_struct::PaddingAtEnd (-10014, 10015) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v no_padding16 -// lldb-check:[...] { 0 = 10000 1 = -10001 } +//@ lldb-command:v no_padding16 +//@ lldb-check:[...] { 0 = 10000 1 = -10001 } -// lldb-command:v no_padding32 -// lldb-check:[...] { 0 = -10002 1 = -10003.5 2 = 10004 } +//@ lldb-command:v no_padding32 +//@ lldb-check:[...] { 0 = -10002 1 = -10003.5 2 = 10004 } -// lldb-command:v no_padding64 -// lldb-check:[...] { 0 = -10005.5 1 = 10006 2 = 10007 } +//@ lldb-command:v no_padding64 +//@ lldb-check:[...] { 0 = -10005.5 1 = 10006 2 = 10007 } -// lldb-command:v no_padding163264 -// lldb-check:[...] { 0 = -10008 1 = 10009 2 = 10010 3 = 10011 } +//@ lldb-command:v no_padding163264 +//@ lldb-check:[...] { 0 = -10008 1 = 10009 2 = 10010 3 = 10011 } -// lldb-command:v internal_padding -// lldb-check:[...] { 0 = 10012 1 = -10013 } +//@ lldb-command:v internal_padding +//@ lldb-check:[...] { 0 = 10012 1 = -10013 } -// lldb-command:v padding_at_end -// lldb-check:[...] { 0 = -10014 1 = 10015 } +//@ lldb-command:v padding_at_end +//@ lldb-check:[...] { 0 = -10014 1 = 10015 } // This test case mainly makes sure that no field names are generated for tuple structs (as opposed // to all fields having the name ""). Otherwise they are handled the same a normal diff --git a/tests/debuginfo/tuple-style-enum.rs b/tests/debuginfo/tuple-style-enum.rs index 6568a2f70ab3..7541b8aa3c6b 100644 --- a/tests/debuginfo/tuple-style-enum.rs +++ b/tests/debuginfo/tuple-style-enum.rs @@ -6,37 +6,37 @@ // === GDB TESTS =================================================================================== -// gdb-command:set print union on -// gdb-command:run +//@ gdb-command:set print union on +//@ gdb-command:run -// gdb-command:print case1 -// gdb-check:$1 = tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868) +//@ gdb-command:print case1 +//@ gdb-check:$1 = tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868) -// gdb-command:print case2 -// gdb-check:$2 = tuple_style_enum::Regular::Case2(0, 286331153, 286331153) +//@ gdb-command:print case2 +//@ gdb-check:$2 = tuple_style_enum::Regular::Case2(0, 286331153, 286331153) -// gdb-command:print case3 -// gdb-check:$3 = tuple_style_enum::Regular::Case3(0, 6438275382588823897) +//@ gdb-command:print case3 +//@ gdb-check:$3 = tuple_style_enum::Regular::Case3(0, 6438275382588823897) -// gdb-command:print univariant -// gdb-check:$4 = tuple_style_enum::Univariant::TheOnlyCase(-1) +//@ gdb-command:print univariant +//@ gdb-check:$4 = tuple_style_enum::Univariant::TheOnlyCase(-1) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v case1 -// lldb-check:(tuple_style_enum::Regular) case1 = Case1(0, 31868, 31868, 31868, 31868) { 0 = 0 1 = 31868 2 = 31868 3 = 31868 4 = 31868 } +//@ lldb-command:v case1 +//@ lldb-check:(tuple_style_enum::Regular) case1 = Case1(0, 31868, 31868, 31868, 31868) { 0 = 0 1 = 31868 2 = 31868 3 = 31868 4 = 31868 } -// lldb-command:v case2 -// lldb-check:(tuple_style_enum::Regular) case2 = Case2(0, 286331153, 286331153) { 0 = 0 1 = 286331153 2 = 286331153 } +//@ lldb-command:v case2 +//@ lldb-check:(tuple_style_enum::Regular) case2 = Case2(0, 286331153, 286331153) { 0 = 0 1 = 286331153 2 = 286331153 } -// lldb-command:v case3 -// lldb-check:(tuple_style_enum::Regular) case3 = Case3(0, 6438275382588823897) { 0 = 0 1 = 6438275382588823897 } +//@ lldb-command:v case3 +//@ lldb-check:(tuple_style_enum::Regular) case3 = Case3(0, 6438275382588823897) { 0 = 0 1 = 6438275382588823897 } -// lldb-command:v univariant -// lldb-check:(tuple_style_enum::Univariant) univariant = TheOnlyCase(-1) { 0 = -1 } +//@ lldb-command:v univariant +//@ lldb-check:(tuple_style_enum::Univariant) univariant = TheOnlyCase(-1) { 0 = -1 } #![allow(unused_variables)] diff --git a/tests/debuginfo/type-names.rs b/tests/debuginfo/type-names.rs index 341112b0b88e..3b15e0541867 100644 --- a/tests/debuginfo/type-names.rs +++ b/tests/debuginfo/type-names.rs @@ -11,266 +11,266 @@ // === GDB TESTS ================================================================================== -// gdb-command:run +//@ gdb-command:run // STRUCTS -// gdb-command:whatis simple_struct -// gdb-check:type = type_names::Struct1 +//@ gdb-command:whatis simple_struct +//@ gdb-check:type = type_names::Struct1 -// gdb-command:whatis generic_struct1 -// gdb-check:type = type_names::GenericStruct +//@ gdb-command:whatis generic_struct1 +//@ gdb-check:type = type_names::GenericStruct -// gdb-command:whatis generic_struct2 -// gdb-check:type = type_names::GenericStruct usize> +//@ gdb-command:whatis generic_struct2 +//@ gdb-check:type = type_names::GenericStruct usize> -// gdb-command:whatis mod_struct -// gdb-check:type = type_names::mod1::Struct2 +//@ gdb-command:whatis mod_struct +//@ gdb-check:type = type_names::mod1::Struct2 // ENUMS -// gdb-command:whatis simple_enum_1 -// gdb-check:type = type_names::Enum1 +//@ gdb-command:whatis simple_enum_1 +//@ gdb-check:type = type_names::Enum1 -// gdb-command:whatis simple_enum_2 -// gdb-check:type = type_names::Enum1 +//@ gdb-command:whatis simple_enum_2 +//@ gdb-check:type = type_names::Enum1 -// gdb-command:whatis simple_enum_3 -// gdb-check:type = type_names::mod1::Enum2 +//@ gdb-command:whatis simple_enum_3 +//@ gdb-check:type = type_names::mod1::Enum2 -// gdb-command:whatis generic_enum_1 -// gdb-check:type = type_names::mod1::mod2::Enum3 +//@ gdb-command:whatis generic_enum_1 +//@ gdb-check:type = type_names::mod1::mod2::Enum3 -// gdb-command:whatis generic_enum_2 -// gdb-check:type = type_names::mod1::mod2::Enum3 +//@ gdb-command:whatis generic_enum_2 +//@ gdb-check:type = type_names::mod1::mod2::Enum3 // TUPLES -// gdb-command:whatis tuple1 -// gdb-check:type = (u32, type_names::Struct1, type_names::mod1::mod2::Enum3) +//@ gdb-command:whatis tuple1 +//@ gdb-check:type = (u32, type_names::Struct1, type_names::mod1::mod2::Enum3) -// gdb-command:whatis tuple2 -// gdb-check:type = ((type_names::Struct1, type_names::mod1::mod2::Struct3), type_names::mod1::Enum2, char) +//@ gdb-command:whatis tuple2 +//@ gdb-check:type = ((type_names::Struct1, type_names::mod1::mod2::Struct3), type_names::mod1::Enum2, char) // BOX -// gdb-command:whatis box1 -// gdb-check:type = (alloc::boxed::Box, i32) +//@ gdb-command:whatis box1 +//@ gdb-check:type = (alloc::boxed::Box, i32) -// gdb-command:whatis box2 -// gdb-check:type = (alloc::boxed::Box, alloc::alloc::Global>, i32) +//@ gdb-command:whatis box2 +//@ gdb-check:type = (alloc::boxed::Box, alloc::alloc::Global>, i32) // REFERENCES -// gdb-command:whatis ref1 -// gdb-check:type = (&type_names::Struct1, i32) +//@ gdb-command:whatis ref1 +//@ gdb-check:type = (&type_names::Struct1, i32) -// gdb-command:whatis ref2 -// gdb-check:type = (&type_names::GenericStruct, i32) +//@ gdb-command:whatis ref2 +//@ gdb-check:type = (&type_names::GenericStruct, i32) -// gdb-command:whatis mut_ref1 -// gdb-check:type = (&mut type_names::Struct1, i32) +//@ gdb-command:whatis mut_ref1 +//@ gdb-check:type = (&mut type_names::Struct1, i32) -// gdb-command:whatis mut_ref2 -// gdb-check:type = (&mut type_names::GenericStruct, i32) +//@ gdb-command:whatis mut_ref2 +//@ gdb-check:type = (&mut type_names::GenericStruct, i32) // RAW POINTERS -// gdb-command:whatis mut_ptr1 -// gdb-check:type = (*mut type_names::Struct1, isize) +//@ gdb-command:whatis mut_ptr1 +//@ gdb-check:type = (*mut type_names::Struct1, isize) -// gdb-command:whatis mut_ptr2 -// gdb-check:type = (*mut isize, isize) +//@ gdb-command:whatis mut_ptr2 +//@ gdb-check:type = (*mut isize, isize) -// gdb-command:whatis mut_ptr3 -// gdb-check:type = (*mut type_names::mod1::mod2::Enum3, isize) +//@ gdb-command:whatis mut_ptr3 +//@ gdb-check:type = (*mut type_names::mod1::mod2::Enum3, isize) -// gdb-command:whatis const_ptr1 -// gdb-check:type = (*const type_names::Struct1, isize) +//@ gdb-command:whatis const_ptr1 +//@ gdb-check:type = (*const type_names::Struct1, isize) -// gdb-command:whatis const_ptr2 -// gdb-check:type = (*const isize, isize) +//@ gdb-command:whatis const_ptr2 +//@ gdb-check:type = (*const isize, isize) -// gdb-command:whatis const_ptr3 -// gdb-check:type = (*const type_names::mod1::mod2::Enum3, isize) +//@ gdb-command:whatis const_ptr3 +//@ gdb-check:type = (*const type_names::mod1::mod2::Enum3, isize) // VECTORS -// gdb-command:whatis fixed_size_vec1 -// gdb-check:type = ([type_names::Struct1; 3], i16) +//@ gdb-command:whatis fixed_size_vec1 +//@ gdb-check:type = ([type_names::Struct1; 3], i16) -// gdb-command:whatis fixed_size_vec2 -// gdb-check:type = ([usize; 3], i16) +//@ gdb-command:whatis fixed_size_vec2 +//@ gdb-check:type = ([usize; 3], i16) -// gdb-command:whatis slice1 -// gdb-check:type = &[usize] +//@ gdb-command:whatis slice1 +//@ gdb-check:type = &[usize] -// gdb-command:whatis slice2 -// gdb-check:type = &mut [type_names::mod1::Enum2] +//@ gdb-command:whatis slice2 +//@ gdb-check:type = &mut [type_names::mod1::Enum2] // TRAITS -// gdb-command:whatis box_trait -// gdb-check:type = alloc::boxed::Box +//@ gdb-command:whatis box_trait +//@ gdb-check:type = alloc::boxed::Box -// gdb-command:whatis ref_trait -// gdb-check:type = &dyn type_names::Trait1 +//@ gdb-command:whatis ref_trait +//@ gdb-check:type = &dyn type_names::Trait1 -// gdb-command:whatis mut_ref_trait -// gdb-check:type = &mut dyn type_names::Trait1 +//@ gdb-command:whatis mut_ref_trait +//@ gdb-check:type = &mut dyn type_names::Trait1 -// gdb-command:whatis generic_box_trait -// gdb-check:type = alloc::boxed::Box, alloc::alloc::Global> +//@ gdb-command:whatis generic_box_trait +//@ gdb-check:type = alloc::boxed::Box, alloc::alloc::Global> -// gdb-command:whatis generic_ref_trait -// gdb-check:type = &dyn type_names::Trait2 +//@ gdb-command:whatis generic_ref_trait +//@ gdb-check:type = &dyn type_names::Trait2 -// gdb-command:whatis generic_mut_ref_trait -// gdb-check:type = &mut dyn type_names::Trait2> +//@ gdb-command:whatis generic_mut_ref_trait +//@ gdb-check:type = &mut dyn type_names::Trait2> -// gdb-command:whatis no_principal_trait -// gdb-check:type = alloc::boxed::Box<(dyn core::marker::Send + core::marker::Sync), alloc::alloc::Global> +//@ gdb-command:whatis no_principal_trait +//@ gdb-check:type = alloc::boxed::Box<(dyn core::marker::Send + core::marker::Sync), alloc::alloc::Global> -// gdb-command:whatis has_associated_type_trait -// gdb-check:type = &(dyn type_names::Trait3 + core::marker::Send) +//@ gdb-command:whatis has_associated_type_trait +//@ gdb-check:type = &(dyn type_names::Trait3 + core::marker::Send) -// gdb-command:whatis has_associated_type_but_no_generics_trait -// gdb-check:type = &dyn type_names::TraitNoGenericsButWithAssocType +//@ gdb-command:whatis has_associated_type_but_no_generics_trait +//@ gdb-check:type = &dyn type_names::TraitNoGenericsButWithAssocType // BARE FUNCTIONS -// gdb-command:whatis rust_fn -// gdb-check:type = (fn(core::option::Option, core::option::Option<&type_names::mod1::Struct2>), usize) +//@ gdb-command:whatis rust_fn +//@ gdb-check:type = (fn(core::option::Option, core::option::Option<&type_names::mod1::Struct2>), usize) -// gdb-command:whatis extern_c_fn -// gdb-check:type = (extern "C" fn(isize), usize) +//@ gdb-command:whatis extern_c_fn +//@ gdb-check:type = (extern "C" fn(isize), usize) -// gdb-command:whatis unsafe_fn -// gdb-check:type = (unsafe fn(core::result::Result), usize) +//@ gdb-command:whatis unsafe_fn +//@ gdb-check:type = (unsafe fn(core::result::Result), usize) -// gdb-command:whatis rust_fn_with_return_value -// gdb-check:type = (fn(f64) -> usize, usize) +//@ gdb-command:whatis rust_fn_with_return_value +//@ gdb-check:type = (fn(f64) -> usize, usize) -// gdb-command:whatis extern_c_fn_with_return_value -// gdb-check:type = (extern "C" fn() -> type_names::Struct1, usize) +//@ gdb-command:whatis extern_c_fn_with_return_value +//@ gdb-check:type = (extern "C" fn() -> type_names::Struct1, usize) -// gdb-command:whatis unsafe_fn_with_return_value -// gdb-check:type = (unsafe fn(type_names::GenericStruct) -> type_names::mod1::Struct2, usize) +//@ gdb-command:whatis unsafe_fn_with_return_value +//@ gdb-check:type = (unsafe fn(type_names::GenericStruct) -> type_names::mod1::Struct2, usize) -// gdb-command:whatis generic_function_int -// gdb-check:type = (fn(isize) -> isize, usize) +//@ gdb-command:whatis generic_function_int +//@ gdb-check:type = (fn(isize) -> isize, usize) -// gdb-command:whatis generic_function_struct3 -// gdb-check:type = (fn(type_names::mod1::mod2::Struct3) -> type_names::mod1::mod2::Struct3, usize) +//@ gdb-command:whatis generic_function_struct3 +//@ gdb-check:type = (fn(type_names::mod1::mod2::Struct3) -> type_names::mod1::mod2::Struct3, usize) -// gdb-command:whatis variadic_function -// gdb-check:type = (unsafe extern "C" fn(*const u8, ...) -> isize, usize) +//@ gdb-command:whatis variadic_function +//@ gdb-check:type = (unsafe extern "C" fn(*const u8, ...) -> isize, usize) // CLOSURES -// gdb-command:whatis closure1 -// gdb-check:type = (type_names::main::{closure_env#0}, usize) +//@ gdb-command:whatis closure1 +//@ gdb-check:type = (type_names::main::{closure_env#0}, usize) -// gdb-command:whatis closure2 -// gdb-check:type = (type_names::main::{closure_env#1}, usize) +//@ gdb-command:whatis closure2 +//@ gdb-check:type = (type_names::main::{closure_env#1}, usize) // FOREIGN TYPES -// gdb-command:whatis foreign1 -// gdb-check:type = *mut type_names::{extern#0}::ForeignType1 +//@ gdb-command:whatis foreign1 +//@ gdb-check:type = *mut type_names::{extern#0}::ForeignType1 -// gdb-command:whatis foreign2 -// gdb-check:type = *mut type_names::mod1::{extern#0}::ForeignType2 +//@ gdb-command:whatis foreign2 +//@ gdb-check:type = *mut type_names::mod1::{extern#0}::ForeignType2 // === CDB TESTS ================================================================================== // Note: `/n` causes the wildcard matches to be sorted to avoid depending on order in PDB which // can be arbitrary. -// cdb-command: g +//@ cdb-command: g // STRUCTS // 0-sized structs appear to be optimized away in some cases, so only check the structs that do // actually appear. -// cdb-command:dv /t /n *_struct +//@ cdb-command:dv /t /n *_struct // ENUMS -// cdb-command:dv /t /n *_enum_* -// cdb-check:union enum2$ > generic_enum_1 = [...] -// cdb-check:union enum2$ > generic_enum_2 = [...] -// cdb-check:union enum2$ simple_enum_1 = [...] -// cdb-check:union enum2$ simple_enum_2 = [...] -// cdb-check:union enum2$ simple_enum_3 = [...] +//@ cdb-command:dv /t /n *_enum_* +//@ cdb-check:union enum2$ > generic_enum_1 = [...] +//@ cdb-check:union enum2$ > generic_enum_2 = [...] +//@ cdb-check:union enum2$ simple_enum_1 = [...] +//@ cdb-check:union enum2$ simple_enum_2 = [...] +//@ cdb-check:union enum2$ simple_enum_3 = [...] // TUPLES -// cdb-command:dv /t /n tuple* -// cdb-check:struct tuple$ > > tuple1 = [...] -// cdb-check:struct tuple$,enum2$,char> tuple2 = [...] +//@ cdb-command:dv /t /n tuple* +//@ cdb-check:struct tuple$ > > tuple1 = [...] +//@ cdb-check:struct tuple$,enum2$,char> tuple2 = [...] // BOX -// cdb-command:dv /t /n box* -// cdb-check:struct tuple$,i32> box1 = [...] -// cdb-check:struct tuple$ >,alloc::alloc::Global>,i32> box2 = [...] +//@ cdb-command:dv /t /n box* +//@ cdb-check:struct tuple$,i32> box1 = [...] +//@ cdb-check:struct tuple$ >,alloc::alloc::Global>,i32> box2 = [...] // REFERENCES -// cdb-command:dv /t /n *ref* -// cdb-check:struct tuple$,i32> mut_ref1 = [...] -// cdb-check:struct tuple$,f64> >,i32> mut_ref2 = [...] -// cdb-check:struct tuple$,i32> ref1 = [...] -// cdb-check:struct tuple$ >,i32> ref2 = [...] +//@ cdb-command:dv /t /n *ref* +//@ cdb-check:struct tuple$,i32> mut_ref1 = [...] +//@ cdb-check:struct tuple$,f64> >,i32> mut_ref2 = [...] +//@ cdb-check:struct tuple$,i32> ref1 = [...] +//@ cdb-check:struct tuple$ >,i32> ref2 = [...] // RAW POINTERS -// cdb-command:dv /t /n *_ptr* -// cdb-check:struct tuple$,isize> const_ptr1 = [...] -// cdb-check:struct tuple$,isize> const_ptr2 = [...] -// cdb-check:struct tuple$ > >,isize> const_ptr3 = [...] -// cdb-check:struct tuple$,isize> mut_ptr1 = [...] -// cdb-check:struct tuple$,isize> mut_ptr2 = [...] -// cdb-check:struct tuple$ > >,isize> mut_ptr3 = [...] +//@ cdb-command:dv /t /n *_ptr* +//@ cdb-check:struct tuple$,isize> const_ptr1 = [...] +//@ cdb-check:struct tuple$,isize> const_ptr2 = [...] +//@ cdb-check:struct tuple$ > >,isize> const_ptr3 = [...] +//@ cdb-check:struct tuple$,isize> mut_ptr1 = [...] +//@ cdb-check:struct tuple$,isize> mut_ptr2 = [...] +//@ cdb-check:struct tuple$ > >,isize> mut_ptr3 = [...] // VECTORS -// cdb-command:dv /t /n *vec* -// cdb-check:struct tuple$,i16> fixed_size_vec1 = [...] -// cdb-check:struct tuple$,i16> fixed_size_vec2 = [...] -// cdb-check:struct alloc::vec::Vec vec1 = [...] -// cdb-check:struct alloc::vec::Vec,alloc::alloc::Global> vec2 = [...] -// cdb-command:dv /t /n slice* -// cdb-check:struct ref$ > slice1 = [...] -// cdb-check:struct ref_mut$ > > slice2 = [...] +//@ cdb-command:dv /t /n *vec* +//@ cdb-check:struct tuple$,i16> fixed_size_vec1 = [...] +//@ cdb-check:struct tuple$,i16> fixed_size_vec2 = [...] +//@ cdb-check:struct alloc::vec::Vec vec1 = [...] +//@ cdb-check:struct alloc::vec::Vec,alloc::alloc::Global> vec2 = [...] +//@ cdb-command:dv /t /n slice* +//@ cdb-check:struct ref$ > slice1 = [...] +//@ cdb-check:struct ref_mut$ > > slice2 = [...] // TRAITS -// cdb-command:dv /t /n *_trait +//@ cdb-command:dv /t /n *_trait -// cdb-check:struct alloc::boxed::Box,alloc::alloc::Global> box_trait = [...] -// cdb-check:struct alloc::boxed::Box >,alloc::alloc::Global> generic_box_trait = [...] -// cdb-check:struct ref_mut$ > > > generic_mut_ref_trait = [...] -// cdb-check:struct ref$ > > generic_ref_trait = [...] -// cdb-check:struct ref$ > > > has_associated_type_but_no_generics_trait = struct ref$ > > > -// cdb-check:struct ref$ >,core::marker::Send> > has_associated_type_trait = struct ref$ >,core::marker::Send> > -// cdb-check:struct ref_mut$ > mut_ref_trait = [...] -// cdb-check:struct alloc::boxed::Box,alloc::alloc::Global> no_principal_trait = [...] -// cdb-check:struct ref$ > ref_trait = [...] +//@ cdb-check:struct alloc::boxed::Box,alloc::alloc::Global> box_trait = [...] +//@ cdb-check:struct alloc::boxed::Box >,alloc::alloc::Global> generic_box_trait = [...] +//@ cdb-check:struct ref_mut$ > > > generic_mut_ref_trait = [...] +//@ cdb-check:struct ref$ > > generic_ref_trait = [...] +//@ cdb-check:struct ref$ > > > has_associated_type_but_no_generics_trait = struct ref$ > > > +//@ cdb-check:struct ref$ >,core::marker::Send> > has_associated_type_trait = struct ref$ >,core::marker::Send> > +//@ cdb-check:struct ref_mut$ > mut_ref_trait = [...] +//@ cdb-check:struct alloc::boxed::Box,alloc::alloc::Global> no_principal_trait = [...] +//@ cdb-check:struct ref$ > ref_trait = [...] // BARE FUNCTIONS -// cdb-command:dv /t /n *_fn* -// cdb-check:struct tuple$ extern_c_fn = [...] -// cdb-check:struct tuple$ extern_c_fn_with_return_value = [...] -// cdb-check:struct tuple$ >,enum2$ > >),usize> rust_fn = [...] -// cdb-check:struct tuple$ rust_fn_with_return_value = [...] -// cdb-check:struct tuple$ >),usize> unsafe_fn = [...] -// cdb-check:struct tuple$),usize> unsafe_fn_with_return_value = [...] -// cdb-command:dv /t /n *_function* -// cdb-check:struct tuple$ generic_function_int = [...] -// cdb-check:struct tuple$ generic_function_struct3 = [...] -// cdb-check:struct tuple$, ...),usize> variadic_function = [...] -// cdb-command:dx Debugger.State.Scripts.@"type-names.cdb".Contents.getFunctionDetails("rust_fn") -// cdb-check:Return Type: void -// cdb-check:Parameter Types: enum2$ >,enum2$ > > -// cdb-command:dx Debugger.State.Scripts.@"type-names.cdb".Contents.getFunctionDetails("rust_fn_with_return_value") -// cdb-check:Return Type: usize -// cdb-check:Parameter Types: f64 -// cdb-command:dx Debugger.State.Scripts.@"type-names.cdb".Contents.getFunctionDetails("extern_c_fn_with_return_value") -// cdb-check:Return Type: type_names::Struct1 -// cdb-check:Parameter Types: +//@ cdb-command:dv /t /n *_fn* +//@ cdb-check:struct tuple$ extern_c_fn = [...] +//@ cdb-check:struct tuple$ extern_c_fn_with_return_value = [...] +//@ cdb-check:struct tuple$ >,enum2$ > >),usize> rust_fn = [...] +//@ cdb-check:struct tuple$ rust_fn_with_return_value = [...] +//@ cdb-check:struct tuple$ >),usize> unsafe_fn = [...] +//@ cdb-check:struct tuple$),usize> unsafe_fn_with_return_value = [...] +//@ cdb-command:dv /t /n *_function* +//@ cdb-check:struct tuple$ generic_function_int = [...] +//@ cdb-check:struct tuple$ generic_function_struct3 = [...] +//@ cdb-check:struct tuple$, ...),usize> variadic_function = [...] +//@ cdb-command:dx Debugger.State.Scripts.@"type-names.cdb".Contents.getFunctionDetails("rust_fn") +//@ cdb-check:Return Type: void +//@ cdb-check:Parameter Types: enum2$ >,enum2$ > > +//@ cdb-command:dx Debugger.State.Scripts.@"type-names.cdb".Contents.getFunctionDetails("rust_fn_with_return_value") +//@ cdb-check:Return Type: usize +//@ cdb-check:Parameter Types: f64 +//@ cdb-command:dx Debugger.State.Scripts.@"type-names.cdb".Contents.getFunctionDetails("extern_c_fn_with_return_value") +//@ cdb-check:Return Type: type_names::Struct1 +//@ cdb-check:Parameter Types: // CLOSURES -// cdb-command:dv /t /n closure* -// cdb-check:struct tuple$ closure1 = [...] -// cdb-check:struct tuple$ closure2 = [...] +//@ cdb-command:dv /t /n closure* +//@ cdb-check:struct tuple$ closure1 = [...] +//@ cdb-check:struct tuple$ closure2 = [...] // FOREIGN TYPES -// cdb-command:dv /t /n foreign* -// cdb-check:struct type_names::extern$0::ForeignType1 * foreign1 = [...] -// cdb-check:struct type_names::mod1::extern$0::ForeignType2 * foreign2 = [...] +//@ cdb-command:dv /t /n foreign* +//@ cdb-check:struct type_names::extern$0::ForeignType1 * foreign1 = [...] +//@ cdb-check:struct type_names::mod1::extern$0::ForeignType2 * foreign2 = [...] #![allow(unused_variables)] #![feature(extern_types)] diff --git a/tests/debuginfo/union-smoke.rs b/tests/debuginfo/union-smoke.rs index be6a9d578646..884a1f3e6992 100644 --- a/tests/debuginfo/union-smoke.rs +++ b/tests/debuginfo/union-smoke.rs @@ -4,20 +4,20 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print u -// gdb-check:$1 = union_smoke::U {a: (2, 2), b: 514} -// gdb-command:print union_smoke::SU -// gdb-check:$2 = union_smoke::U {a: (1, 1), b: 257} +//@ gdb-command:run +//@ gdb-command:print u +//@ gdb-check:$1 = union_smoke::U {a: (2, 2), b: 514} +//@ gdb-command:print union_smoke::SU +//@ gdb-check:$2 = union_smoke::U {a: (1, 1), b: 257} // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v u -// lldb-check:[...] { a = ('\x02', '\x02') { 0 = '\x02' 1 = '\x02' } b = 514 } +//@ lldb-command:run +//@ lldb-command:v u +//@ lldb-check:[...] { a = ('\x02', '\x02') { 0 = '\x02' 1 = '\x02' } b = 514 } -// lldb-command:print union_smoke::SU -// lldb-check:[...] { a = ('\x01', '\x01') { 0 = '\x01' 1 = '\x01' } b = 257 } +//@ lldb-command:print union_smoke::SU +//@ lldb-check:[...] { a = ('\x01', '\x01') { 0 = '\x01' 1 = '\x01' } b = 257 } #![allow(unused)] diff --git a/tests/debuginfo/unique-enum.rs b/tests/debuginfo/unique-enum.rs index 6a742f9378df..3cc9b7774193 100644 --- a/tests/debuginfo/unique-enum.rs +++ b/tests/debuginfo/unique-enum.rs @@ -6,30 +6,30 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print *the_a -// gdb-check:$1 = unique_enum::ABC::TheA{x: 0, y: 8970181431921507452} +//@ gdb-command:print *the_a +//@ gdb-check:$1 = unique_enum::ABC::TheA{x: 0, y: 8970181431921507452} -// gdb-command:print *the_b -// gdb-check:$2 = unique_enum::ABC::TheB(0, 286331153, 286331153) +//@ gdb-command:print *the_b +//@ gdb-check:$2 = unique_enum::ABC::TheB(0, 286331153, 286331153) -// gdb-command:print *univariant -// gdb-check:$3 = unique_enum::Univariant::TheOnlyCase(123234) +//@ gdb-command:print *univariant +//@ gdb-check:$3 = unique_enum::Univariant::TheOnlyCase(123234) // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v *the_a -// lldb-check:(unique_enum::ABC) *the_a = TheA{x:0, y:8970181431921507452} { x = 0 y = 8970181431921507452 } +//@ lldb-command:v *the_a +//@ lldb-check:(unique_enum::ABC) *the_a = TheA{x:0, y:8970181431921507452} { x = 0 y = 8970181431921507452 } -// lldb-command:v *the_b -// lldb-check:(unique_enum::ABC) *the_b = TheB(0, 286331153, 286331153) { 0 = 0 1 = 286331153 2 = 286331153 } +//@ lldb-command:v *the_b +//@ lldb-check:(unique_enum::ABC) *the_b = TheB(0, 286331153, 286331153) { 0 = 0 1 = 286331153 2 = 286331153 } -// lldb-command:v *univariant -// lldb-check:(unique_enum::Univariant) *univariant = TheOnlyCase(123234) { 0 = 123234 } +//@ lldb-command:v *univariant +//@ lldb-check:(unique_enum::Univariant) *univariant = TheOnlyCase(123234) { 0 = 123234 } #![allow(unused_variables)] diff --git a/tests/debuginfo/unit-type.rs b/tests/debuginfo/unit-type.rs index ce2a39521d90..5c6b81e8b5e7 100644 --- a/tests/debuginfo/unit-type.rs +++ b/tests/debuginfo/unit-type.rs @@ -6,48 +6,48 @@ // === GDB TESTS =================================================================================== -// gdb-command: run +//@ gdb-command: run -// gdb-command: print _ref -// gdb-check: $1 = (*mut ()) 0x[...] +//@ gdb-command: print _ref +//@ gdb-check: $1 = (*mut ()) 0x[...] -// gdb-command: print _ptr -// gdb-check: $2 = (*mut ()) 0x[...] +//@ gdb-command: print _ptr +//@ gdb-check: $2 = (*mut ()) 0x[...] -// gdb-command: print _local -// gdb-check: $3 = () +//@ gdb-command: print _local +//@ gdb-check: $3 = () -// gdb-command: print _field -// gdb-check: $4 = unit_type::_TypeContainingUnitField {_a: 123, _unit: (), _b: 456} +//@ gdb-command: print _field +//@ gdb-check: $4 = unit_type::_TypeContainingUnitField {_a: 123, _unit: (), _b: 456} // Check that we can cast "void pointers" to their actual type in the debugger -// gdb-command: print /x *(_ptr as *const u64) -// gdb-check: $5 = 0x1122334455667788 +//@ gdb-command: print /x *(_ptr as *const u64) +//@ gdb-check: $5 = 0x1122334455667788 // === CDB TESTS =================================================================================== -// cdb-command: g -// cdb-check: Breakpoint 0 hit +//@ cdb-command: g +//@ cdb-check: Breakpoint 0 hit -// cdb-command: dx _ref -// cdb-check: _ref : 0x[...] [Type: tuple$<> *] +//@ cdb-command: dx _ref +//@ cdb-check: _ref : 0x[...] [Type: tuple$<> *] -// cdb-command: dx _ptr -// cdb-check: _ptr : 0x[...] [Type: tuple$<> *] +//@ cdb-command: dx _ptr +//@ cdb-check: _ptr : 0x[...] [Type: tuple$<> *] -// cdb-command: dx _local -// cdb-check: _local [Type: tuple$<>] +//@ cdb-command: dx _local +//@ cdb-check: _local [Type: tuple$<>] -// cdb-command: dx _field,d -// cdb-check: _field,d [Type: unit_type::_TypeContainingUnitField] -// cdb-check: [+0x[...]] _a : 123 [Type: unsigned int] -// cdb-check: [+0x[...]] _unit [Type: tuple$<>] -// cdb-check: [+0x[...]] _b : 456 [Type: unsigned __int64] +//@ cdb-command: dx _field,d +//@ cdb-check: _field,d [Type: unit_type::_TypeContainingUnitField] +//@ cdb-check: [+0x[...]] _a : 123 [Type: unsigned int] +//@ cdb-check: [+0x[...]] _unit [Type: tuple$<>] +//@ cdb-check: [+0x[...]] _b : 456 [Type: unsigned __int64] // Check that we can cast "void pointers" to their actual type in the debugger -// cdb-command: dx ((__int64 *)_ptr),x -// cdb-check: ((__int64 *)_ptr),x : 0x[...] : 0x1122334455667788 [Type: __int64 *] -// cdb-check: 0x1122334455667788 [Type: __int64] +//@ cdb-command: dx ((__int64 *)_ptr),x +//@ cdb-check: ((__int64 *)_ptr),x : 0x[...] : 0x1122334455667788 [Type: __int64 *] +//@ cdb-check: 0x1122334455667788 [Type: __int64] struct _TypeContainingUnitField { _a: u32, diff --git a/tests/debuginfo/unsized.rs b/tests/debuginfo/unsized.rs index eb0fb8193bf7..ec5ab884c5b7 100644 --- a/tests/debuginfo/unsized.rs +++ b/tests/debuginfo/unsized.rs @@ -6,42 +6,42 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print a -// gdb-check:$1 = &unsized::Foo<[u8]> {data_ptr: [...], length: 4} +//@ gdb-command:print a +//@ gdb-check:$1 = &unsized::Foo<[u8]> {data_ptr: [...], length: 4} -// gdb-command:print b -// gdb-check:$2 = &unsized::Foo> {data_ptr: [...], length: 4} +//@ gdb-command:print b +//@ gdb-check:$2 = &unsized::Foo> {data_ptr: [...], length: 4} -// gdb-command:print c -// gdb-check:$3 = &unsized::Foo {pointer: [...], vtable: [...]} +//@ gdb-command:print c +//@ gdb-check:$3 = &unsized::Foo {pointer: [...], vtable: [...]} -// gdb-command:print _box -// gdb-check:$4 = alloc::boxed::Box, alloc::alloc::Global> {pointer: [...], vtable: [...]} +//@ gdb-command:print _box +//@ gdb-check:$4 = alloc::boxed::Box, alloc::alloc::Global> {pointer: [...], vtable: [...]} // === CDB TESTS =================================================================================== -// cdb-command: g -// cdb-command:dx a -// cdb-check:a [Type: ref$ > >] -// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo > *] -// cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...] +//@ cdb-command: g +//@ cdb-command:dx a +//@ cdb-check:a [Type: ref$ > >] +//@ cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo > *] +//@ cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...] -// cdb-command:dx b -// cdb-check:b [Type: ref$ > > >] -// cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo > > *] -// cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...] +//@ cdb-command:dx b +//@ cdb-check:b [Type: ref$ > > >] +//@ cdb-check: [+0x000] data_ptr : 0x[...] [Type: unsized::Foo > > *] +//@ cdb-check: [...] length : 0x4 [Type: unsigned [...]int[...] -// cdb-command:dx c -// cdb-check:c [Type: ref$ > >] -// cdb-check: [+0x000] pointer : 0x[...] [Type: unsized::Foo > *] -// cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[4]] +//@ cdb-command:dx c +//@ cdb-check:c [Type: ref$ > >] +//@ cdb-check: [+0x000] pointer : 0x[...] [Type: unsized::Foo > *] +//@ cdb-check: [...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[4]] -// cdb-command:dx _box -// cdb-check:_box [Type: alloc::boxed::Box >,alloc::alloc::Global>] -// cdb-check:[+0x000] pointer : 0x[...] [Type: unsized::Foo > *] -// cdb-check:[...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[4]] +//@ cdb-command:dx _box +//@ cdb-check:_box [Type: alloc::boxed::Box >,alloc::alloc::Global>] +//@ cdb-check:[+0x000] pointer : 0x[...] [Type: unsized::Foo > *] +//@ cdb-check:[...] vtable : 0x[...] [Type: unsigned [...]int[...] (*)[4]] struct Foo { value: T, diff --git a/tests/debuginfo/var-captured-in-nested-closure.rs b/tests/debuginfo/var-captured-in-nested-closure.rs index 0343aea309d5..0fdc6dfc7220 100644 --- a/tests/debuginfo/var-captured-in-nested-closure.rs +++ b/tests/debuginfo/var-captured-in-nested-closure.rs @@ -4,117 +4,117 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print variable -// gdb-check:$1 = 1 -// gdb-command:print constant -// gdb-check:$2 = 2 -// gdb-command:print a_struct -// gdb-check:$3 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5} -// gdb-command:print *struct_ref -// gdb-check:$4 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5} -// gdb-command:print *owned -// gdb-check:$5 = 6 -// gdb-command:print closure_local -// gdb-check:$6 = 8 -// gdb-command:continue +//@ gdb-command:print variable +//@ gdb-check:$1 = 1 +//@ gdb-command:print constant +//@ gdb-check:$2 = 2 +//@ gdb-command:print a_struct +//@ gdb-check:$3 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5} +//@ gdb-command:print *struct_ref +//@ gdb-check:$4 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5} +//@ gdb-command:print *owned +//@ gdb-check:$5 = 6 +//@ gdb-command:print closure_local +//@ gdb-check:$6 = 8 +//@ gdb-command:continue -// gdb-command:print variable -// gdb-check:$7 = 1 -// gdb-command:print constant -// gdb-check:$8 = 2 -// gdb-command:print a_struct -// gdb-check:$9 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5} -// gdb-command:print *struct_ref -// gdb-check:$10 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5} -// gdb-command:print *owned -// gdb-check:$11 = 6 -// gdb-command:print closure_local -// gdb-check:$12 = 8 -// gdb-command:continue +//@ gdb-command:print variable +//@ gdb-check:$7 = 1 +//@ gdb-command:print constant +//@ gdb-check:$8 = 2 +//@ gdb-command:print a_struct +//@ gdb-check:$9 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5} +//@ gdb-command:print *struct_ref +//@ gdb-check:$10 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5} +//@ gdb-command:print *owned +//@ gdb-check:$11 = 6 +//@ gdb-command:print closure_local +//@ gdb-check:$12 = 8 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v variable -// lldb-check:[...] 1 -// lldb-command:v constant -// lldb-check:[...] 2 -// lldb-command:v a_struct -// lldb-check:[...] { a = -3 b = 4.5 c = 5 } -// lldb-command:v *struct_ref -// lldb-check:[...] { a = -3 b = 4.5 c = 5 } -// lldb-command:v *owned -// lldb-check:[...] 6 -// lldb-command:v closure_local -// lldb-check:[...] 8 -// lldb-command:continue +//@ lldb-command:v variable +//@ lldb-check:[...] 1 +//@ lldb-command:v constant +//@ lldb-check:[...] 2 +//@ lldb-command:v a_struct +//@ lldb-check:[...] { a = -3 b = 4.5 c = 5 } +//@ lldb-command:v *struct_ref +//@ lldb-check:[...] { a = -3 b = 4.5 c = 5 } +//@ lldb-command:v *owned +//@ lldb-check:[...] 6 +//@ lldb-command:v closure_local +//@ lldb-check:[...] 8 +//@ lldb-command:continue -// lldb-command:v variable -// lldb-check:[...] 1 -// lldb-command:v constant -// lldb-check:[...] 2 -// lldb-command:v a_struct -// lldb-check:[...] { a = -3 b = 4.5 c = 5 } -// lldb-command:v *struct_ref -// lldb-check:[...] { a = -3 b = 4.5 c = 5 } -// lldb-command:v *owned -// lldb-check:[...] 6 -// lldb-command:v closure_local -// lldb-check:[...] 8 -// lldb-command:continue +//@ lldb-command:v variable +//@ lldb-check:[...] 1 +//@ lldb-command:v constant +//@ lldb-check:[...] 2 +//@ lldb-command:v a_struct +//@ lldb-check:[...] { a = -3 b = 4.5 c = 5 } +//@ lldb-command:v *struct_ref +//@ lldb-check:[...] { a = -3 b = 4.5 c = 5 } +//@ lldb-command:v *owned +//@ lldb-check:[...] 6 +//@ lldb-command:v closure_local +//@ lldb-check:[...] 8 +//@ lldb-command:continue // === CDB TESTS =================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx variable -// cdb-check:variable : 1 [Type: [...]] -// cdb-command: dx constant -// cdb-check:constant : 2 [Type: [...]] -// cdb-command: dx a_struct -// cdb-check:a_struct [Type: var_captured_in_nested_closure::Struct] -// cdb-check: [+0x[...]] a : -3 [Type: [...]] -// cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] -// cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] -// cdb-command: dx struct_ref -// cdb-check:struct_ref : 0x[...] [Type: var_captured_in_nested_closure::Struct *] -// cdb-check: [+0x[...]] a : -3 [Type: [...]] -// cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] -// cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] -// cdb-command: dx owned -// cdb-check:owned : 0x[...] : 6 [Type: [...] *] -// cdb-check: 6 [Type: [...]] -// cdb-command: dx closure_local -// cdb-check:closure_local : 8 [Type: [...]] -// cdb-command: dx nested_closure -// cdb-check:nested_closure [Type: var_captured_in_nested_closure::main::closure$0::closure_env$0] +//@ cdb-command: dx variable +//@ cdb-check:variable : 1 [Type: [...]] +//@ cdb-command: dx constant +//@ cdb-check:constant : 2 [Type: [...]] +//@ cdb-command: dx a_struct +//@ cdb-check:a_struct [Type: var_captured_in_nested_closure::Struct] +//@ cdb-check: [+0x[...]] a : -3 [Type: [...]] +//@ cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] +//@ cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] +//@ cdb-command: dx struct_ref +//@ cdb-check:struct_ref : 0x[...] [Type: var_captured_in_nested_closure::Struct *] +//@ cdb-check: [+0x[...]] a : -3 [Type: [...]] +//@ cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] +//@ cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] +//@ cdb-command: dx owned +//@ cdb-check:owned : 0x[...] : 6 [Type: [...] *] +//@ cdb-check: 6 [Type: [...]] +//@ cdb-command: dx closure_local +//@ cdb-check:closure_local : 8 [Type: [...]] +//@ cdb-command: dx nested_closure +//@ cdb-check:nested_closure [Type: var_captured_in_nested_closure::main::closure$0::closure_env$0] -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx variable -// cdb-check:variable : 1 [Type: [...]] -// cdb-command: dx constant -// cdb-check:constant : 2 [Type: [...]] -// cdb-command: dx a_struct -// cdb-check:a_struct [Type: var_captured_in_nested_closure::Struct] -// cdb-check: [+0x[...]] a : -3 [Type: [...]] -// cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] -// cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] -// cdb-command: dx struct_ref -// cdb-check:struct_ref : 0x[...] [Type: var_captured_in_nested_closure::Struct *] -// cdb-check: [+0x[...]] a : -3 [Type: [...]] -// cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] -// cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] -// cdb-command: dx owned -// cdb-check:owned : 0x[...] : 6 [Type: [...] *] -// cdb-check: 6 [Type: [...]] -// cdb-command: dx closure_local -// cdb-check:closure_local : 8 [Type: [...]] +//@ cdb-command: dx variable +//@ cdb-check:variable : 1 [Type: [...]] +//@ cdb-command: dx constant +//@ cdb-check:constant : 2 [Type: [...]] +//@ cdb-command: dx a_struct +//@ cdb-check:a_struct [Type: var_captured_in_nested_closure::Struct] +//@ cdb-check: [+0x[...]] a : -3 [Type: [...]] +//@ cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] +//@ cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] +//@ cdb-command: dx struct_ref +//@ cdb-check:struct_ref : 0x[...] [Type: var_captured_in_nested_closure::Struct *] +//@ cdb-check: [+0x[...]] a : -3 [Type: [...]] +//@ cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] +//@ cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] +//@ cdb-command: dx owned +//@ cdb-check:owned : 0x[...] : 6 [Type: [...] *] +//@ cdb-check: 6 [Type: [...]] +//@ cdb-command: dx closure_local +//@ cdb-check:closure_local : 8 [Type: [...]] #![allow(unused_variables)] diff --git a/tests/debuginfo/var-captured-in-sendable-closure.rs b/tests/debuginfo/var-captured-in-sendable-closure.rs index ad6aa5fb9c74..a52e1be482af 100644 --- a/tests/debuginfo/var-captured-in-sendable-closure.rs +++ b/tests/debuginfo/var-captured-in-sendable-closure.rs @@ -4,30 +4,30 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print constant -// gdb-check:$1 = 1 -// gdb-command:print a_struct -// gdb-check:$2 = var_captured_in_sendable_closure::Struct {a: -2, b: 3.5, c: 4} -// gdb-command:print *owned -// gdb-check:$3 = 5 -// gdb-command:continue +//@ gdb-command:print constant +//@ gdb-check:$1 = 1 +//@ gdb-command:print a_struct +//@ gdb-check:$2 = var_captured_in_sendable_closure::Struct {a: -2, b: 3.5, c: 4} +//@ gdb-command:print *owned +//@ gdb-check:$3 = 5 +//@ gdb-command:continue -// gdb-command:print constant2 -// gdb-check:$4 = 6 -// gdb-command:continue +//@ gdb-command:print constant2 +//@ gdb-check:$4 = 6 +//@ gdb-command:continue // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v constant -// lldb-check:[...] 1 -// lldb-command:v a_struct -// lldb-check:[...] { a = -2 b = 3.5 c = 4 } -// lldb-command:v *owned -// lldb-check:[...] 5 +//@ lldb-command:v constant +//@ lldb-check:[...] 1 +//@ lldb-command:v a_struct +//@ lldb-check:[...] { a = -2 b = 3.5 c = 4 } +//@ lldb-command:v *owned +//@ lldb-check:[...] 5 #![allow(unused_variables)] diff --git a/tests/debuginfo/var-captured-in-stack-closure.rs b/tests/debuginfo/var-captured-in-stack-closure.rs index cc7e2eff81b4..31cf0283c37b 100644 --- a/tests/debuginfo/var-captured-in-stack-closure.rs +++ b/tests/debuginfo/var-captured-in-stack-closure.rs @@ -4,102 +4,102 @@ // === GDB TESTS =================================================================================== -// gdb-command:run +//@ gdb-command:run -// gdb-command:print variable -// gdb-check:$1 = 1 -// gdb-command:print constant -// gdb-check:$2 = 2 -// gdb-command:print a_struct -// gdb-check:$3 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5} -// gdb-command:print *struct_ref -// gdb-check:$4 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5} -// gdb-command:print *owned -// gdb-check:$5 = 6 +//@ gdb-command:print variable +//@ gdb-check:$1 = 1 +//@ gdb-command:print constant +//@ gdb-check:$2 = 2 +//@ gdb-command:print a_struct +//@ gdb-check:$3 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5} +//@ gdb-command:print *struct_ref +//@ gdb-check:$4 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5} +//@ gdb-command:print *owned +//@ gdb-check:$5 = 6 -// gdb-command:continue +//@ gdb-command:continue -// gdb-command:print variable -// gdb-check:$6 = 2 -// gdb-command:print constant -// gdb-check:$7 = 2 -// gdb-command:print a_struct -// gdb-check:$8 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5} -// gdb-command:print *struct_ref -// gdb-check:$9 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5} -// gdb-command:print *owned -// gdb-check:$10 = 6 +//@ gdb-command:print variable +//@ gdb-check:$6 = 2 +//@ gdb-command:print constant +//@ gdb-check:$7 = 2 +//@ gdb-command:print a_struct +//@ gdb-check:$8 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5} +//@ gdb-command:print *struct_ref +//@ gdb-check:$9 = var_captured_in_stack_closure::Struct {a: -3, b: 4.5, c: 5} +//@ gdb-command:print *owned +//@ gdb-check:$10 = 6 // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v variable -// lldb-check:[...] 1 -// lldb-command:v constant -// lldb-check:[...] 2 -// lldb-command:v a_struct -// lldb-check:[...] { a = -3 b = 4.5 c = 5 } -// lldb-command:v *struct_ref -// lldb-check:[...] { a = -3 b = 4.5 c = 5 } -// lldb-command:v *owned -// lldb-check:[...] 6 +//@ lldb-command:v variable +//@ lldb-check:[...] 1 +//@ lldb-command:v constant +//@ lldb-check:[...] 2 +//@ lldb-command:v a_struct +//@ lldb-check:[...] { a = -3 b = 4.5 c = 5 } +//@ lldb-command:v *struct_ref +//@ lldb-check:[...] { a = -3 b = 4.5 c = 5 } +//@ lldb-command:v *owned +//@ lldb-check:[...] 6 -// lldb-command:continue +//@ lldb-command:continue -// lldb-command:v variable -// lldb-check:[...] 2 -// lldb-command:v constant -// lldb-check:[...] 2 -// lldb-command:v a_struct -// lldb-check:[...] { a = -3 b = 4.5 c = 5 } -// lldb-command:v *struct_ref -// lldb-check:[...] { a = -3 b = 4.5 c = 5 } -// lldb-command:v *owned -// lldb-check:[...] 6 +//@ lldb-command:v variable +//@ lldb-check:[...] 2 +//@ lldb-command:v constant +//@ lldb-check:[...] 2 +//@ lldb-command:v a_struct +//@ lldb-check:[...] { a = -3 b = 4.5 c = 5 } +//@ lldb-command:v *struct_ref +//@ lldb-check:[...] { a = -3 b = 4.5 c = 5 } +//@ lldb-command:v *owned +//@ lldb-check:[...] 6 // === CDB TESTS =================================================================================== -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx variable -// cdb-check:variable : 1 [Type: [...]] -// cdb-command: dx constant -// cdb-check:constant : 2 [Type: [...]] -// cdb-command: dx a_struct -// cdb-check:a_struct [Type: var_captured_in_stack_closure::Struct] -// cdb-check: [+0x[...]] a : -3 [Type: [...]] -// cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] -// cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] -// cdb-command: dx struct_ref -// cdb-check:struct_ref : 0x[...] [Type: var_captured_in_stack_closure::Struct *] -// cdb-check: [+0x[...]] a : -3 [Type: [...]] -// cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] -// cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] -// cdb-command: dx owned -// cdb-check:owned : 0x[...] : 6 [Type: [...] *] +//@ cdb-command: dx variable +//@ cdb-check:variable : 1 [Type: [...]] +//@ cdb-command: dx constant +//@ cdb-check:constant : 2 [Type: [...]] +//@ cdb-command: dx a_struct +//@ cdb-check:a_struct [Type: var_captured_in_stack_closure::Struct] +//@ cdb-check: [+0x[...]] a : -3 [Type: [...]] +//@ cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] +//@ cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] +//@ cdb-command: dx struct_ref +//@ cdb-check:struct_ref : 0x[...] [Type: var_captured_in_stack_closure::Struct *] +//@ cdb-check: [+0x[...]] a : -3 [Type: [...]] +//@ cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] +//@ cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] +//@ cdb-command: dx owned +//@ cdb-check:owned : 0x[...] : 6 [Type: [...] *] -// cdb-command: g +//@ cdb-command: g -// cdb-command: dx variable -// cdb-check:variable : 2 [Type: [...]] -// cdb-command: dx constant -// cdb-check:constant : 2 [Type: [...]] -// cdb-command: dx a_struct -// cdb-check:a_struct [Type: var_captured_in_stack_closure::Struct] -// cdb-check: [+0x[...]] a : -3 [Type: [...]] -// cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] -// cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] -// cdb-command: dx struct_ref -// cdb-check:struct_ref : 0x[...] [Type: var_captured_in_stack_closure::Struct *] -// cdb-check: [+0x[...]] a : -3 [Type: [...]] -// cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] -// cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] -// cdb-command: dx owned -// cdb-check:owned : 0x[...] : 6 [Type: [...] *] +//@ cdb-command: dx variable +//@ cdb-check:variable : 2 [Type: [...]] +//@ cdb-command: dx constant +//@ cdb-check:constant : 2 [Type: [...]] +//@ cdb-command: dx a_struct +//@ cdb-check:a_struct [Type: var_captured_in_stack_closure::Struct] +//@ cdb-check: [+0x[...]] a : -3 [Type: [...]] +//@ cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] +//@ cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] +//@ cdb-command: dx struct_ref +//@ cdb-check:struct_ref : 0x[...] [Type: var_captured_in_stack_closure::Struct *] +//@ cdb-check: [+0x[...]] a : -3 [Type: [...]] +//@ cdb-check: [+0x[...]] b : 4.500000 [Type: [...]] +//@ cdb-check: [+0x[...]] c : 0x5 [Type: unsigned [...]] +//@ cdb-command: dx owned +//@ cdb-check:owned : 0x[...] : 6 [Type: [...] *] #![allow(unused_variables)] diff --git a/tests/debuginfo/vec-slices.rs b/tests/debuginfo/vec-slices.rs index fdfc7019add6..e7f6fd03e541 100644 --- a/tests/debuginfo/vec-slices.rs +++ b/tests/debuginfo/vec-slices.rs @@ -7,70 +7,70 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print empty.length -// gdb-check:$1 = 0 +//@ gdb-command:run +//@ gdb-command:print empty.length +//@ gdb-check:$1 = 0 -// gdb-command:print singleton.length -// gdb-check:$2 = 1 -// gdb-command:print *(singleton.data_ptr as *const [i64; 1]) -// gdb-check:$3 = [1] +//@ gdb-command:print singleton.length +//@ gdb-check:$2 = 1 +//@ gdb-command:print *(singleton.data_ptr as *const [i64; 1]) +//@ gdb-check:$3 = [1] -// gdb-command:print multiple.length -// gdb-check:$4 = 4 -// gdb-command:print *(multiple.data_ptr as *const [i64; 4]) -// gdb-check:$5 = [2, 3, 4, 5] +//@ gdb-command:print multiple.length +//@ gdb-check:$4 = 4 +//@ gdb-command:print *(multiple.data_ptr as *const [i64; 4]) +//@ gdb-check:$5 = [2, 3, 4, 5] -// gdb-command:print slice_of_slice.length -// gdb-check:$6 = 2 -// gdb-command:print *(slice_of_slice.data_ptr as *const [i64; 2]) -// gdb-check:$7 = [3, 4] +//@ gdb-command:print slice_of_slice.length +//@ gdb-check:$6 = 2 +//@ gdb-command:print *(slice_of_slice.data_ptr as *const [i64; 2]) +//@ gdb-check:$7 = [3, 4] -// gdb-command:print padded_tuple.length -// gdb-check:$8 = 2 -// gdb-command:print padded_tuple.data_ptr[0] -// gdb-check:$9 = (6, 7) -// gdb-command:print padded_tuple.data_ptr[1] -// gdb-check:$10 = (8, 9) +//@ gdb-command:print padded_tuple.length +//@ gdb-check:$8 = 2 +//@ gdb-command:print padded_tuple.data_ptr[0] +//@ gdb-check:$9 = (6, 7) +//@ gdb-command:print padded_tuple.data_ptr[1] +//@ gdb-check:$10 = (8, 9) -// gdb-command:print padded_struct.length -// gdb-check:$11 = 2 -// gdb-command:print padded_struct.data_ptr[0] -// gdb-check:$12 = vec_slices::AStruct {x: 10, y: 11, z: 12} -// gdb-command:print padded_struct.data_ptr[1] -// gdb-check:$13 = vec_slices::AStruct {x: 13, y: 14, z: 15} +//@ gdb-command:print padded_struct.length +//@ gdb-check:$11 = 2 +//@ gdb-command:print padded_struct.data_ptr[0] +//@ gdb-check:$12 = vec_slices::AStruct {x: 10, y: 11, z: 12} +//@ gdb-command:print padded_struct.data_ptr[1] +//@ gdb-check:$13 = vec_slices::AStruct {x: 13, y: 14, z: 15} -// gdb-command:print mut_slice.length -// gdb-check:$14 = 5 -// gdb-command:print *(mut_slice.data_ptr as *const [i64; 5]) -// gdb-check:$15 = [1, 2, 3, 4, 5] +//@ gdb-command:print mut_slice.length +//@ gdb-check:$14 = 5 +//@ gdb-command:print *(mut_slice.data_ptr as *const [i64; 5]) +//@ gdb-check:$15 = [1, 2, 3, 4, 5] -// gdb-command:print MUT_VECT_SLICE.length -// gdb-check:$16 = 2 -// gdb-command:print *(MUT_VECT_SLICE.data_ptr as *const [i64; 2]) -// gdb-check:$17 = [64, 65] +//@ gdb-command:print MUT_VECT_SLICE.length +//@ gdb-check:$16 = 2 +//@ gdb-command:print *(MUT_VECT_SLICE.data_ptr as *const [i64; 2]) +//@ gdb-check:$17 = [64, 65] // === LLDB TESTS ================================================================================== -// lldb-command:run +//@ lldb-command:run -// lldb-command:v empty -// lldb-check:[...] size=0 +//@ lldb-command:v empty +//@ lldb-check:[...] size=0 -// lldb-command:v singleton -// lldb-check:[...] size=1 { [0] = 1 } +//@ lldb-command:v singleton +//@ lldb-check:[...] size=1 { [0] = 1 } -// lldb-command:v multiple -// lldb-check:[...] size=4 { [0] = 2 [1] = 3 [2] = 4 [3] = 5 } +//@ lldb-command:v multiple +//@ lldb-check:[...] size=4 { [0] = 2 [1] = 3 [2] = 4 [3] = 5 } -// lldb-command:v slice_of_slice -// lldb-check:[...] size=2 { [0] = 3 [1] = 4 } +//@ lldb-command:v slice_of_slice +//@ lldb-check:[...] size=2 { [0] = 3 [1] = 4 } -// lldb-command:v padded_tuple -// lldb-check:[...] size=2 { [0] = (6, 7) { 0 = 6 1 = 7 } [1] = (8, 9) { 0 = 8 1 = 9 } } +//@ lldb-command:v padded_tuple +//@ lldb-check:[...] size=2 { [0] = (6, 7) { 0 = 6 1 = 7 } [1] = (8, 9) { 0 = 8 1 = 9 } } -// lldb-command:v padded_struct -// lldb-check:[...] size=2 { [0] = { x = 10 y = 11 z = 12 } [1] = { x = 13 y = 14 z = 15 } } +//@ lldb-command:v padded_struct +//@ lldb-check:[...] size=2 { [0] = { x = 10 y = 11 z = 12 } [1] = { x = 13 y = 14 z = 15 } } #![allow(dead_code, unused_variables)] diff --git a/tests/debuginfo/vec.rs b/tests/debuginfo/vec.rs index c0e9f802f1e3..375ec156df58 100644 --- a/tests/debuginfo/vec.rs +++ b/tests/debuginfo/vec.rs @@ -4,18 +4,18 @@ // === GDB TESTS =================================================================================== -// gdb-command:run -// gdb-command:print a -// gdb-check:$1 = [1, 2, 3] -// gdb-command:print vec::VECT -// gdb-check:$2 = [4, 5, 6] +//@ gdb-command:run +//@ gdb-command:print a +//@ gdb-check:$1 = [1, 2, 3] +//@ gdb-command:print vec::VECT +//@ gdb-check:$2 = [4, 5, 6] // === LLDB TESTS ================================================================================== -// lldb-command:run -// lldb-command:v a -// lldb-check:[...] { [0] = 1 [1] = 2 [2] = 3 } +//@ lldb-command:run +//@ lldb-command:v a +//@ lldb-check:[...] { [0] = 1 [1] = 2 [2] = 3 } #![allow(unused_variables)] diff --git a/tests/debuginfo/zst-interferes-with-prologue.rs b/tests/debuginfo/zst-interferes-with-prologue.rs index 4d87df1abe7a..0f2c5cf8492d 100644 --- a/tests/debuginfo/zst-interferes-with-prologue.rs +++ b/tests/debuginfo/zst-interferes-with-prologue.rs @@ -5,25 +5,25 @@ // === GDB TESTS =================================================================================== -// gdb-command:break zst_interferes_with_prologue::Foo::var_return_opt_try -// gdb-command:run +//@ gdb-command:break zst_interferes_with_prologue::Foo::var_return_opt_try +//@ gdb-command:run -// gdb-command:print self -// gdb-command:next -// gdb-command:print self -// gdb-command:print $1 == $2 -// gdb-check:true +//@ gdb-command:print self +//@ gdb-command:next +//@ gdb-command:print self +//@ gdb-command:print $1 == $2 +//@ gdb-check:true // === LLDB TESTS ================================================================================== -// lldb-command:b "zst_interferes_with_prologue::Foo::var_return_opt_try" -// lldb-command:run +//@ lldb-command:b "zst_interferes_with_prologue::Foo::var_return_opt_try" +//@ lldb-command:run -// lldb-command:expr self -// lldb-command:next -// lldb-command:expr self -// lldb-command:print $0 == $1 -// lldb-check:true +//@ lldb-command:expr self +//@ lldb-command:next +//@ lldb-command:expr self +//@ lldb-command:print $0 == $1 +//@ lldb-check:true struct Foo { a: usize, From d8c9d705086e0a902a0084ab381a3fa25b133d52 Mon Sep 17 00:00:00 2001 From: zjumathcode Date: Tue, 25 Nov 2025 14:16:14 +0800 Subject: [PATCH 173/194] Fix comment wording in simplify_comparison_integral.rs Signed-off-by: zjumathcode --- .../rustc_mir_transform/src/simplify_comparison_integral.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs b/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs index 4597439e269f..2643d78990e5 100644 --- a/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs +++ b/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs @@ -74,7 +74,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { } // delete comparison statement if it the value being switched on was moved, which means - // it can not be user later on + // it can not be used later on if opt.can_remove_bin_op_stmt { bb.statements[opt.bin_op_stmt_idx].make_nop(true); } else { From a700e47675debbc1cce9a9ef6b9c5478be77f386 Mon Sep 17 00:00:00 2001 From: tison Date: Tue, 25 Nov 2025 15:16:43 +0800 Subject: [PATCH 174/194] Simplify OnceCell Clone impl Signed-off-by: tison --- library/core/src/cell/once.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/library/core/src/cell/once.rs b/library/core/src/cell/once.rs index 1e211ae66e79..6c71e2216a71 100644 --- a/library/core/src/cell/once.rs +++ b/library/core/src/cell/once.rs @@ -376,14 +376,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { impl Clone for OnceCell { #[inline] fn clone(&self) -> OnceCell { - let res = OnceCell::new(); - if let Some(value) = self.get() { - match res.set(value.clone()) { - Ok(()) => (), - Err(_) => unreachable!(), - } + match self.get() { + Some(value) => OnceCell::from(value.clone()), + None => OnceCell::new(), } - res } } From b93f2d8b2637f17c7df269955135ef33eedb94df Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 19 Nov 2025 16:02:12 +0000 Subject: [PATCH 175/194] Add a macro for defaulted enum encoding, use it for hir::Defaultness and deduplicate the logic for other similar enums --- compiler/rustc_hir/src/hir.rs | 8 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 4 +- compiler/rustc_metadata/src/rmeta/mod.rs | 2 +- compiler/rustc_metadata/src/rmeta/table.rs | 153 +++++++------------ 4 files changed, 68 insertions(+), 99 deletions(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index ea2f9e6d920f..0db3f456b60b 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -3841,8 +3841,12 @@ pub fn is_async(self) -> bool { } #[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable, Decodable, HashStable_Generic)] +#[derive(Default)] pub enum Defaultness { - Default { has_value: bool }, + Default { + has_value: bool, + }, + #[default] Final, } @@ -4231,8 +4235,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { #[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable, Decodable, HashStable_Generic)] #[derive(Default)] pub enum Constness { - Const, #[default] + Const, NotConst, } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index ca4cf260dffb..9fac68039f52 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1753,7 +1753,7 @@ fn encode_info_for_assoc_item(&mut self, def_id: DefId) { let item = tcx.associated_item(def_id); if matches!(item.container, AssocContainer::Trait | AssocContainer::TraitImpl(_)) { - self.tables.defaultness.set_some(def_id.index, item.defaultness(tcx)); + self.tables.defaultness.set(def_id.index, item.defaultness(tcx)); } record!(self.tables.assoc_container[def_id] <- item.container); @@ -2155,7 +2155,7 @@ fn encode_impls(&mut self) -> LazyArray { let header = tcx.impl_trait_header(def_id); record!(self.tables.impl_trait_header[def_id] <- header); - self.tables.defaultness.set_some(def_id.index, tcx.defaultness(def_id)); + self.tables.defaultness.set(def_id.index, tcx.defaultness(def_id)); let trait_ref = header.trait_ref.instantiate_identity(); let simplified_self_ty = fast_reject::simplify_type( diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 8c5737cb9eb6..ac042c2ca75d 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -403,6 +403,7 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { asyncness: Table, constness: Table, safety: Table, + defaultness: Table, - optional: attributes: Table>, @@ -436,7 +437,6 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables { thir_abstract_const: Table>>>, impl_parent: Table, const_conditions: Table>>, - defaultness: Table, // FIXME(eddyb) perhaps compute this on the fly if cheap enough? coerce_unsized_info: Table>, mir_const_qualif: Table>, diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 7a8190fcf2f7..4ce313f32a75 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -25,33 +25,6 @@ fn is_default(&self) -> bool { } } -impl IsDefault for ty::Asyncness { - fn is_default(&self) -> bool { - match self { - ty::Asyncness::Yes => false, - ty::Asyncness::No => true, - } - } -} - -impl IsDefault for hir::Constness { - fn is_default(&self) -> bool { - match self { - hir::Constness::Const => false, - hir::Constness::NotConst => true, - } - } -} - -impl IsDefault for hir::Safety { - fn is_default(&self) -> bool { - match self { - hir::Safety::Safe => false, - hir::Safety::Unsafe => true, - } - } -} - impl IsDefault for u32 { fn is_default(&self) -> bool { *self == 0 @@ -139,6 +112,43 @@ impl FixedSizeEncoding for Option<$ty> { } } +macro_rules! defaulted_enum { + ($ty:ty { $(($($pat:tt)*))* } $( unreachable { $(($($upat:tt)*))+ } )?) => { + impl FixedSizeEncoding for $ty { + type ByteArray = [u8; 1]; + + #[inline] + fn from_bytes(b: &[u8; 1]) -> Self { + use $ty::*; + let val = match b[0] { + $(${index()} => $($pat)*,)* + _ => panic!("Unexpected {} code: {:?}", stringify!($ty), b[0]), + }; + // Make sure the first entry is always the default value, + // and none of the other values are the default value + debug_assert_ne!((b[0] != 0), IsDefault::is_default(&val)); + val + } + + #[inline] + fn write_to_bytes(self, b: &mut [u8; 1]) { + debug_assert!(!IsDefault::is_default(&self)); + use $ty::*; + b[0] = match self { + $($($pat)* => ${index()},)* + $($($($upat)*)|+ => unreachable!(),)? + }; + debug_assert_ne!(b[0], 0); + } + } + impl IsDefault for $ty { + fn is_default(&self) -> bool { + <$ty as Default>::default() == *self + } + } + } +} + // Workaround; need const traits to construct bitflags in a const macro_rules! const_macro_kinds { ($($name:ident),+$(,)?) => (MacroKinds::from_bits_truncate($(MacroKinds::$name.bits())|+)) @@ -205,7 +215,7 @@ macro_rules! const_macro_kinds { } } -fixed_size_enum! { +defaulted_enum! { hir::Defaultness { ( Final ) ( Default { has_value: false } ) @@ -213,6 +223,27 @@ macro_rules! const_macro_kinds { } } +defaulted_enum! { + ty::Asyncness { + ( No ) + ( Yes ) + } +} + +defaulted_enum! { + hir::Constness { + ( Const ) + ( NotConst ) + } +} + +defaulted_enum! { + hir::Safety { + ( Unsafe ) + ( Safe ) + } +} + fixed_size_enum! { hir::CoroutineKind { ( Coroutine(hir::Movability::Movable) ) @@ -301,72 +332,6 @@ impl FixedSizeEncoding for bool { } } -impl FixedSizeEncoding for ty::Asyncness { - type ByteArray = [u8; 1]; - - #[inline] - fn from_bytes(b: &[u8; 1]) -> Self { - match b[0] { - 0 => ty::Asyncness::No, - 1 => ty::Asyncness::Yes, - _ => unreachable!(), - } - } - - #[inline] - fn write_to_bytes(self, b: &mut [u8; 1]) { - debug_assert!(!self.is_default()); - b[0] = match self { - ty::Asyncness::No => 0, - ty::Asyncness::Yes => 1, - } - } -} - -impl FixedSizeEncoding for hir::Constness { - type ByteArray = [u8; 1]; - - #[inline] - fn from_bytes(b: &[u8; 1]) -> Self { - match b[0] { - 0 => hir::Constness::NotConst, - 1 => hir::Constness::Const, - _ => unreachable!(), - } - } - - #[inline] - fn write_to_bytes(self, b: &mut [u8; 1]) { - debug_assert!(!self.is_default()); - b[0] = match self { - hir::Constness::NotConst => 0, - hir::Constness::Const => 1, - } - } -} - -impl FixedSizeEncoding for hir::Safety { - type ByteArray = [u8; 1]; - - #[inline] - fn from_bytes(b: &[u8; 1]) -> Self { - match b[0] { - 0 => hir::Safety::Unsafe, - 1 => hir::Safety::Safe, - _ => unreachable!(), - } - } - - #[inline] - fn write_to_bytes(self, b: &mut [u8; 1]) { - debug_assert!(!self.is_default()); - b[0] = match self { - hir::Safety::Unsafe => 0, - hir::Safety::Safe => 1, - } - } -} - // NOTE(eddyb) there could be an impl for `usize`, which would enable a more // generic `LazyValue` impl, but in the general case we might not need / want // to fit every `usize` in `u32`. From fd1852f5f338e38eda48a2616372758cd449d684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 25 Nov 2025 12:31:19 +0100 Subject: [PATCH 176/194] Mark riscv64gc-unknown-linux-musl as tier 2 target --- .../src/spec/targets/riscv64gc_unknown_linux_musl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs index f5d647d0fc54..6eba0994deb4 100644 --- a/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/riscv64gc_unknown_linux_musl.rs @@ -7,7 +7,7 @@ pub(crate) fn target() -> Target { llvm_target: "riscv64-unknown-linux-musl".into(), metadata: TargetMetadata { description: Some("RISC-V Linux (kernel 4.20, musl 1.2.5)".into()), - tier: Some(3), + tier: Some(2), host_tools: Some(false), std: Some(true), }, From 231a3a241bbf91771533d3c3b35e868a50ee6d15 Mon Sep 17 00:00:00 2001 From: lapla Date: Tue, 25 Nov 2025 17:53:48 +0900 Subject: [PATCH 177/194] Deny const auto traits --- compiler/rustc_ast_passes/messages.ftl | 3 +++ compiler/rustc_ast_passes/src/ast_validation.rs | 8 ++++++++ compiler/rustc_ast_passes/src/errors.rs | 8 ++++++++ tests/ui/traits/const-traits/const-auto-trait.rs | 6 ++++++ tests/ui/traits/const-traits/const-auto-trait.stderr | 10 ++++++++++ 5 files changed, 35 insertions(+) create mode 100644 tests/ui/traits/const-traits/const-auto-trait.rs create mode 100644 tests/ui/traits/const-traits/const-auto-trait.stderr diff --git a/compiler/rustc_ast_passes/messages.ftl b/compiler/rustc_ast_passes/messages.ftl index 9bdbcf6ab907..f03c7dd5b9d5 100644 --- a/compiler/rustc_ast_passes/messages.ftl +++ b/compiler/rustc_ast_passes/messages.ftl @@ -89,6 +89,9 @@ ast_passes_const_and_coroutine = functions cannot be both `const` and `{$corouti .coroutine = `{$coroutine_kind}` because of this .label = {""} +ast_passes_const_auto_trait = auto traits cannot be const + .help = remove the `const` keyword + ast_passes_const_bound_trait_object = const trait bounds are not allowed in trait object types ast_passes_const_without_body = diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 163dbc3350ba..e57f8da26769 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -820,6 +820,12 @@ fn check_mod_file_item_asciionly(&self, ident: Ident) { self.dcx().emit_err(errors::ModuleNonAscii { span: ident.span, name: ident.name }); } + fn deny_const_auto_traits(&self, constness: Const) { + if let Const::Yes(span) = constness { + self.dcx().emit_err(errors::ConstAutoTrait { span }); + } + } + fn deny_generic_params(&self, generics: &Generics, ident_span: Span) { if !generics.params.is_empty() { self.dcx() @@ -1257,6 +1263,8 @@ fn visit_item(&mut self, item: &'a Item) { }) => { self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident); if *is_auto == IsAuto::Yes { + // For why we reject `const auto trait`, see rust-lang/rust#149285. + self.deny_const_auto_traits(*constness); // Auto traits cannot have generics, super traits nor contain items. self.deny_generic_params(generics, ident.span); self.deny_super_traits(bounds, ident.span); diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index 02e6ecfbaee7..c700ae517140 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -429,6 +429,14 @@ pub(crate) struct AutoTraitItems { pub ident: Span, } +#[derive(Diagnostic)] +#[diag(ast_passes_const_auto_trait)] +#[help] +pub(crate) struct ConstAutoTrait { + #[primary_span] + pub span: Span, +} + #[derive(Diagnostic)] #[diag(ast_passes_generic_before_constraints)] pub(crate) struct ArgsBeforeConstraint { diff --git a/tests/ui/traits/const-traits/const-auto-trait.rs b/tests/ui/traits/const-traits/const-auto-trait.rs new file mode 100644 index 000000000000..06558df4623f --- /dev/null +++ b/tests/ui/traits/const-traits/const-auto-trait.rs @@ -0,0 +1,6 @@ +#![feature(auto_traits, const_trait_impl)] + +const auto trait Marker {} +//~^ ERROR: auto traits cannot be const + +fn main() {} diff --git a/tests/ui/traits/const-traits/const-auto-trait.stderr b/tests/ui/traits/const-traits/const-auto-trait.stderr new file mode 100644 index 000000000000..cb8ff8001ba0 --- /dev/null +++ b/tests/ui/traits/const-traits/const-auto-trait.stderr @@ -0,0 +1,10 @@ +error: auto traits cannot be const + --> $DIR/const-auto-trait.rs:3:1 + | +LL | const auto trait Marker {} + | ^^^^^ + | + = help: remove the `const` keyword + +error: aborting due to 1 previous error + From 3326fbd1f4670e0270cd92734cf468e90e2ccc0c Mon Sep 17 00:00:00 2001 From: lapla Date: Tue, 25 Nov 2025 17:54:16 +0900 Subject: [PATCH 178/194] Check existing tests to only verify const auto traits parsing --- tests/ui/traits/const-traits/parse-const-unsafe-trait.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui/traits/const-traits/parse-const-unsafe-trait.rs b/tests/ui/traits/const-traits/parse-const-unsafe-trait.rs index 3d62405d9ae2..58a3b5a4cc61 100644 --- a/tests/ui/traits/const-traits/parse-const-unsafe-trait.rs +++ b/tests/ui/traits/const-traits/parse-const-unsafe-trait.rs @@ -1,5 +1,6 @@ // Test that `const unsafe trait` and `const unsafe auto trait` works. +//@ compile-flags: -Zparse-crate-root-only //@ check-pass #![feature(const_trait_impl)] From 8ed8f1892cd092a8f7ada26a7541248c1e92d204 Mon Sep 17 00:00:00 2001 From: David Wood Date: Mon, 24 Nov 2025 09:35:43 +0000 Subject: [PATCH 179/194] add implementation-internal namespace for globalasm --- compiler/rustc_symbol_mangling/src/v0.rs | 2 +- tests/ui/symbol-names/const-in-global-asm.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/ui/symbol-names/const-in-global-asm.rs diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index e40fc04d7664..4880a79ea9cf 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -882,11 +882,11 @@ fn print_path_with_simple( DefPathData::OpaqueTy => 'i', DefPathData::SyntheticCoroutineBody => 's', DefPathData::NestedStatic => 'n', + DefPathData::GlobalAsm => 'a', // These should never show up as `print_path_with_simple` arguments. DefPathData::CrateRoot | DefPathData::Use - | DefPathData::GlobalAsm | DefPathData::Impl | DefPathData::MacroNs(_) | DefPathData::LifetimeNs(_) diff --git a/tests/ui/symbol-names/const-in-global-asm.rs b/tests/ui/symbol-names/const-in-global-asm.rs new file mode 100644 index 000000000000..16aa15d9a299 --- /dev/null +++ b/tests/ui/symbol-names/const-in-global-asm.rs @@ -0,0 +1,20 @@ +//@ build-pass +//@ compile-flags: -Clink-dead-code +//@ needs-asm-support + +#![allow(unused)] + +// Test that a symbol in a `global_asm` namespace doesn't cause an ICE during v0 symbol mangling +// due to a lack of missing namespace character for `global_asm`. +// +// FIXME: Can't use `#[rustc_symbol_name]` on the `foo` call to check its symbol, so just checking +// the test compiles. + +fn foo() {} + +core::arch::global_asm!("/* {} */", sym foo::<{ + || {}; + 0 +}>); + +fn main() {} From fedbccd3200099f7c4c1d28aa97ed6ce5e6aa71e Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 21 Nov 2025 10:15:19 +0000 Subject: [PATCH 180/194] Use rust rather than LLVM target features in the target spec This works better with non-LLVM codegen backends. --- compiler/rustc_codegen_gcc/src/gcc_util.rs | 15 +++-- compiler/rustc_codegen_llvm/src/llvm_util.rs | 55 ++++++++++--------- .../rustc_codegen_ssa/src/target_features.rs | 46 ++++++++++++++-- compiler/rustc_interface/src/util.rs | 7 ++- compiler/rustc_target/src/spec/mod.rs | 8 +-- .../src/spec/targets/aarch64_apple_ios.rs | 2 +- .../spec/targets/aarch64_apple_ios_macabi.rs | 2 +- .../src/spec/targets/aarch64_apple_ios_sim.rs | 2 +- .../src/spec/targets/aarch64_apple_tvos.rs | 2 +- .../spec/targets/aarch64_apple_tvos_sim.rs | 2 +- .../spec/targets/aarch64_apple_visionos.rs | 2 +- .../targets/aarch64_apple_visionos_sim.rs | 2 +- .../src/spec/targets/aarch64_apple_watchos.rs | 2 +- .../spec/targets/aarch64_apple_watchos_sim.rs | 2 +- .../spec/targets/aarch64_be_unknown_hermit.rs | 2 +- .../aarch64_be_unknown_none_softfloat.rs | 2 +- .../spec/targets/aarch64_kmc_solid_asp3.rs | 2 +- .../src/spec/targets/aarch64_linux_android.rs | 2 +- .../targets/aarch64_pc_windows_gnullvm.rs | 2 +- .../spec/targets/aarch64_pc_windows_msvc.rs | 2 +- .../spec/targets/aarch64_unknown_hermit.rs | 2 +- .../src/spec/targets/aarch64_unknown_none.rs | 2 +- .../targets/aarch64_unknown_none_softfloat.rs | 2 +- .../src/spec/targets/aarch64_unknown_nuttx.rs | 2 +- .../src/spec/targets/aarch64_unknown_teeos.rs | 2 +- .../spec/targets/aarch64_unknown_trusty.rs | 2 +- .../spec/targets/arm64_32_apple_watchos.rs | 2 +- .../src/spec/targets/arm64e_apple_ios.rs | 2 +- .../src/spec/targets/arm64e_apple_tvos.rs | 2 +- .../spec/targets/arm64ec_pc_windows_msvc.rs | 2 +- .../targets/x86_64_fortanix_unknown_sgx.rs | 2 +- .../src/spec/targets/x86_64_pc_windows_gnu.rs | 2 +- .../spec/targets/x86_64_pc_windows_gnullvm.rs | 2 +- .../spec/targets/x86_64_pc_windows_msvc.rs | 2 +- .../spec/targets/x86_64_unknown_fuchsia.rs | 2 +- .../src/spec/targets/x86_64_unknown_hermit.rs | 2 +- .../spec/targets/x86_64_uwp_windows_gnu.rs | 2 +- .../spec/targets/x86_64_uwp_windows_msvc.rs | 2 +- .../src/spec/targets/x86_64h_apple_darwin.rs | 2 +- 39 files changed, 120 insertions(+), 79 deletions(-) diff --git a/compiler/rustc_codegen_gcc/src/gcc_util.rs b/compiler/rustc_codegen_gcc/src/gcc_util.rs index e4e2dfdd5643..330b5ff6828d 100644 --- a/compiler/rustc_codegen_gcc/src/gcc_util.rs +++ b/compiler/rustc_codegen_gcc/src/gcc_util.rs @@ -33,11 +33,7 @@ pub(crate) fn global_gcc_features(sess: &Session) -> Vec { // should be taken in cases like these. let mut features = vec![]; - // Features implied by an implicit or explicit `--target`. - features.extend(sess.target.features.split(',').filter(|v| !v.is_empty()).map(String::from)); - - // -Ctarget-features - target_features::flag_to_backend_features(sess, |feature, enable| { + let mut extend_backend_features = |feature: &str, enable: bool| { // We run through `to_gcc_features` when // passing requests down to GCC. This means that all in-language // features also work on the command line instead of having two @@ -48,7 +44,13 @@ pub(crate) fn global_gcc_features(sess: &Session) -> Vec { .flat_map(|feat| to_gcc_features(sess, feat).into_iter()) .map(|feature| if !enable { format!("-{}", feature) } else { feature.to_string() }), ); - }); + }; + + // Features implied by an implicit or explicit `--target`. + target_features::target_spec_to_backend_features(sess, &mut extend_backend_features); + + // -Ctarget-features + target_features::flag_to_backend_features(sess, extend_backend_features); gcc_features_by_flags(sess, &mut features); @@ -66,6 +68,7 @@ pub(crate) fn global_gcc_features(sess: &Session) -> Vec { (&Arch::X86 | &Arch::X86_64, "rdrand") => smallvec!["rdrnd"], (&Arch::X86 | &Arch::X86_64, "bmi1") => smallvec!["bmi"], (&Arch::X86 | &Arch::X86_64, "cmpxchg16b") => smallvec!["cx16"], + (&Arch::X86 | &Arch::X86_64, "lahfsahf") => smallvec!["sahf"], (&Arch::X86 | &Arch::X86_64, "avx512vaes") => smallvec!["vaes"], (&Arch::X86 | &Arch::X86_64, "avx512gfni") => smallvec!["gfni"], (&Arch::X86 | &Arch::X86_64, "avx512vpclmulqdq") => smallvec!["vpclmulqdq"], diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index b498448417f5..56f5836acfc3 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -626,6 +626,10 @@ pub(crate) fn target_cpu(sess: &Session) -> &str { /// The target features for compiler flags other than `-Ctarget-features`. fn llvm_features_by_flags(sess: &Session, features: &mut Vec) { + if wants_wasm_eh(sess) && sess.panic_strategy() == PanicStrategy::Unwind { + features.push("+exception-handling".into()); + } + target_features::retpoline_features_by_flags(sess, features); // -Zfixed-x18 @@ -691,36 +695,35 @@ pub(crate) fn global_llvm_features(sess: &Session, only_base_features: bool) -> Some(_) | None => {} }; - // Features implied by an implicit or explicit `--target`. - features.extend(sess.target.features.split(',').filter(|v| !v.is_empty()).map(String::from)); + let mut extend_backend_features = |feature: &str, enable: bool| { + let enable_disable = if enable { '+' } else { '-' }; + // We run through `to_llvm_features` when + // passing requests down to LLVM. This means that all in-language + // features also work on the command line instead of having two + // different names when the LLVM name and the Rust name differ. + let Some(llvm_feature) = to_llvm_features(sess, feature) else { return }; - if wants_wasm_eh(sess) && sess.panic_strategy() == PanicStrategy::Unwind { - features.push("+exception-handling".into()); - } + features.extend( + std::iter::once(format!("{}{}", enable_disable, llvm_feature.llvm_feature_name)).chain( + llvm_feature.dependencies.into_iter().filter_map(move |feat| { + match (enable, feat) { + (_, TargetFeatureFoldStrength::Both(f)) + | (true, TargetFeatureFoldStrength::EnableOnly(f)) => { + Some(format!("{enable_disable}{f}")) + } + _ => None, + } + }), + ), + ); + }; + + // Features implied by an implicit or explicit `--target`. + target_features::target_spec_to_backend_features(sess, &mut extend_backend_features); // -Ctarget-features if !only_base_features { - target_features::flag_to_backend_features(sess, |feature, enable| { - let enable_disable = if enable { '+' } else { '-' }; - // We run through `to_llvm_features` when - // passing requests down to LLVM. This means that all in-language - // features also work on the command line instead of having two - // different names when the LLVM name and the Rust name differ. - let Some(llvm_feature) = to_llvm_features(sess, feature) else { return }; - - features.extend( - std::iter::once(format!("{}{}", enable_disable, llvm_feature.llvm_feature_name)) - .chain(llvm_feature.dependencies.into_iter().filter_map(move |feat| { - match (enable, feat) { - (_, TargetFeatureFoldStrength::Both(f)) - | (true, TargetFeatureFoldStrength::EnableOnly(f)) => { - Some(format!("{enable_disable}{f}")) - } - _ => None, - } - })), - ) - }); + target_features::flag_to_backend_features(sess, extend_backend_features); } // We add this in the "base target" so that these show up in `sess.unstable_target_features`. diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index 3267eb1a15c7..e9209657984e 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -139,11 +139,12 @@ pub(crate) fn check_target_feature_trait_unsafe(tcx: TyCtxt<'_>, id: LocalDefId, } } -/// Parse the value of `-Ctarget-feature`, also expanding implied features, -/// and call the closure for each (expanded) Rust feature. If the list contains +/// Parse the value of the target spec `features` field or `-Ctarget-feature`, also expanding +/// implied features, and call the closure for each (expanded) Rust feature. If the list contains /// a syntactically invalid item (not starting with `+`/`-`), the error callback is invoked. -fn parse_rust_feature_flag<'a>( +fn parse_rust_feature_list<'a>( sess: &'a Session, + features: &'a str, err_callback: impl Fn(&'a str), mut callback: impl FnMut( /* base_feature */ &'a str, @@ -154,7 +155,7 @@ fn parse_rust_feature_flag<'a>( // A cache for the backwards implication map. let mut inverse_implied_features: Option>> = None; - for feature in sess.opts.cg.target_feature.split(',') { + for feature in features.split(',') { if let Some(base_feature) = feature.strip_prefix('+') { // Skip features that are not target features, but rustc features. if RUSTC_SPECIFIC_FEATURES.contains(&base_feature) { @@ -244,8 +245,9 @@ pub fn cfg_target_feature<'a, const N: usize>( let mut enabled_disabled_features = FxHashMap::default(); // Add enabled and remove disabled features. - parse_rust_feature_flag( + parse_rust_feature_list( sess, + &sess.opts.cg.target_feature, /* err_callback */ |feature| { sess.dcx().emit_warn(errors::UnknownCTargetFeaturePrefix { feature }); @@ -366,6 +368,37 @@ pub fn check_tied_features( None } +/// Translates the target spec `features` field into a backend target feature list. +/// +/// `extend_backend_features` extends the set of backend features (assumed to be in mutable state +/// accessible by that closure) to enable/disable the given Rust feature name. +pub fn target_spec_to_backend_features<'a>( + sess: &'a Session, + mut extend_backend_features: impl FnMut(&'a str, /* enable */ bool), +) { + // Compute implied features + let mut rust_features = vec![]; + parse_rust_feature_list( + sess, + &sess.target.features, + /* err_callback */ + |feature| { + panic!("Target spec contains invalid feature {feature}"); + }, + |_base_feature, new_features, enable| { + // FIXME emit an error for unknown features like cfg_target_feature would for -Ctarget-feature + rust_features.extend( + UnordSet::from(new_features).to_sorted_stable_ord().iter().map(|&&s| (enable, s)), + ); + }, + ); + + // Add this to the backend features. + for (enable, feature) in rust_features { + extend_backend_features(feature, enable); + } +} + /// Translates the `-Ctarget-feature` flag into a backend target feature list. /// /// `extend_backend_features` extends the set of backend features (assumed to be in mutable state @@ -376,8 +409,9 @@ pub fn flag_to_backend_features<'a>( ) { // Compute implied features let mut rust_features = vec![]; - parse_rust_feature_flag( + parse_rust_feature_list( sess, + &sess.opts.cg.target_feature, /* err_callback */ |_feature| { // Errors are already emitted in `cfg_target_feature`; avoid duplicates. diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 2e100a6215c0..de4175c3511e 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -364,15 +364,16 @@ fn name(&self) -> &'static str { } fn target_config(&self, sess: &Session) -> TargetConfig { + let abi_required_features = sess.target.abi_required_features(); let (target_features, unstable_target_features) = cfg_target_feature::<0>( sess, |_feature| Default::default(), |feature| { // This is a standin for the list of features a backend is expected to enable. // It would be better to parse target.features instead and handle implied features, - // but target.features is a list of LLVM target features, not Rust target features. - // The dummy backend doesn't know the mapping between LLVM and Rust target features. - sess.target.abi_required_features().required.contains(&feature) + // but target.features doesn't contain features that are enabled by default for an + // architecture or target cpu. + abi_required_features.required.contains(&feature) }, ); diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 1a71e344276a..2779fb376616 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -2246,10 +2246,10 @@ pub struct TargetOptions { /// Whether a cpu needs to be explicitly set. /// Set to true if there is no default cpu. Defaults to false. pub need_explicit_cpu: bool, - /// Default target features to pass to LLVM. These features overwrite - /// `-Ctarget-cpu` but can be overwritten with `-Ctarget-features`. - /// Corresponds to `llc -mattr=$features`. - /// Note that these are LLVM feature names, not Rust feature names! + /// Default (Rust) target features to enable for this target. These features + /// overwrite `-Ctarget-cpu` but can be overwritten with `-Ctarget-features`. + /// Corresponds to `llc -mattr=$llvm_features` where `$llvm_features` is the + /// result of mapping the Rust features in this field to LLVM features. /// /// Generally it is a bad idea to use negative target features because they often interact very /// poorly with how `-Ctarget-cpu` works. Instead, try to use a lower "base CPU" and enable the diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs index e6c64add9ecb..4b8356cc71ca 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".into(), + features: "+neon,+apple-a7".into(), max_atomic_width: Some(128), supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::THREAD diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs index 28d22e022c4e..10d2dafb8db2 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a12".into(), + features: "+neon,+apple-a12".into(), max_atomic_width: Some(128), supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::THREAD, ..opts diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs index 3b6a075588a8..351f8ef9eb9a 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".into(), + features: "+neon,+apple-a7".into(), max_atomic_width: Some(128), supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::THREAD diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs index b4e60f769b3b..0916864ac4cc 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".into(), + features: "+neon,+apple-a7".into(), max_atomic_width: Some(128), ..opts }, diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs index 0f2f73c50d0b..2e18abdef399 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".into(), + features: "+neon,+apple-a7".into(), max_atomic_width: Some(128), ..opts }, diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs index b7ddd58fbb32..b771b3ff10b9 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a16".into(), + features: "+neon,+apple-a16".into(), max_atomic_width: Some(128), supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::THREAD, ..opts diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs index 9ad313f14922..d4b4d94115b4 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_visionos_sim.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a16".into(), + features: "+neon,+apple-a16".into(), max_atomic_width: Some(128), supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::THREAD, ..opts diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos.rs index f0a5a616a6d2..9f0a24ddd334 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+v8a,+neon,+fp-armv8,+apple-a7".into(), + features: "+v8a,+neon,+apple-a7".into(), max_atomic_width: Some(128), dynamic_linking: false, position_independent_executables: true, diff --git a/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs b/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs index db73687a715f..fabf01d641c3 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_apple_watchos_sim.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a7".into(), + features: "+neon,+apple-a7".into(), max_atomic_width: Some(128), ..opts }, diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs index 78ae0f55bb42..7b6326133073 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_hermit.rs @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { arch: Arch::AArch64, data_layout: "E-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), options: TargetOptions { - features: "+v8a,+strict-align,+neon,+fp-armv8".into(), + features: "+v8a,+strict-align,+neon".into(), max_atomic_width: Some(128), stack_probes: StackProbeType::Inline, endian: Endian::Big, diff --git a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs index 3b899b13d6d0..07512c01dc4a 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_be_unknown_none_softfloat.rs @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { abi: Abi::SoftFloat, linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), linker: Some("rust-lld".into()), - features: "+v8a,+strict-align,-neon,-fp-armv8".into(), + features: "+v8a,+strict-align,-neon".into(), relocation_model: RelocModel::Static, disable_redzone: true, max_atomic_width: Some(128), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs b/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs index 77ed9a6b82c1..b7709bd01340 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_kmc_solid_asp3.rs @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { arch: Arch::AArch64, options: TargetOptions { linker: Some("aarch64-kmc-elf-gcc".into()), - features: "+v8a,+neon,+fp-armv8".into(), + features: "+v8a,+neon".into(), relocation_model: RelocModel::Static, disable_redzone: true, max_atomic_width: Some(128), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs b/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs index 2bee1cf70b45..3b158c13521e 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_linux_android.rs @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target { max_atomic_width: Some(128), // As documented in https://developer.android.com/ndk/guides/cpu-features.html // the neon (ASIMD) and FP must exist on all android aarch64 targets. - features: "+v8a,+neon,+fp-armv8".into(), + features: "+v8a,+neon".into(), // the AAPCS64 expects use of non-leaf frame pointers per // https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer // and we tend to encounter interesting bugs in AArch64 unwinding code if we do not diff --git a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs index 7b3a234cd9e8..fc1aa7241c6c 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_gnullvm.rs @@ -3,7 +3,7 @@ pub(crate) fn target() -> Target { let mut base = base::windows_gnullvm::opts(); base.max_atomic_width = Some(128); - base.features = "+v8a,+neon,+fp-armv8".into(); + base.features = "+v8a,+neon".into(); base.linker = Some("aarch64-w64-mingw32-clang".into()); // Microsoft recommends enabling frame pointers on Arm64 Windows. diff --git a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs index 3453f1d6101b..0d06bec21f4a 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs @@ -3,7 +3,7 @@ pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); base.max_atomic_width = Some(128); - base.features = "+v8a,+neon,+fp-armv8".into(); + base.features = "+v8a,+neon".into(); // Microsoft recommends enabling frame pointers on Arm64 Windows. // From https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs index 2cf5c2519d56..4ecbb73f7a4e 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_hermit.rs @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target { arch: Arch::AArch64, data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), options: TargetOptions { - features: "+v8a,+strict-align,+neon,+fp-armv8".into(), + features: "+v8a,+strict-align,+neon".into(), max_atomic_width: Some(128), stack_probes: StackProbeType::Inline, ..base::hermit::opts() diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs index ffb136366acc..b6bc261cd0df 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none.rs @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { LinkerFlavor::Gnu(Cc::No, Lld::No), &["--fix-cortex-a53-843419"], ), - features: "+v8a,+strict-align,+neon,+fp-armv8".into(), + features: "+v8a,+strict-align,+neon".into(), supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS, relocation_model: RelocModel::Static, disable_redzone: true, diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs index c0fd021497b6..8e1484774cdb 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_none_softfloat.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { abi: Abi::SoftFloat, linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), linker: Some("rust-lld".into()), - features: "+v8a,+strict-align,-neon,-fp-armv8".into(), + features: "+v8a,+strict-align,-neon".into(), relocation_model: RelocModel::Static, disable_redzone: true, max_atomic_width: Some(128), diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_nuttx.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_nuttx.rs index b8618050074d..19b7ebe03674 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_nuttx.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_nuttx.rs @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { LinkerFlavor::Gnu(Cc::No, Lld::No), &["--fix-cortex-a53-843419"], ), - features: "+v8a,+strict-align,+neon,+fp-armv8".into(), + features: "+v8a,+strict-align,+neon".into(), supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS, relocation_model: RelocModel::Static, disable_redzone: true, diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs index 009f027ca24f..b8f1bf1ca1a9 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_teeos.rs @@ -2,7 +2,7 @@ pub(crate) fn target() -> Target { let mut base = base::teeos::opts(); - base.features = "+strict-align,+neon,+fp-armv8".into(); + base.features = "+strict-align,+neon".into(); base.max_atomic_width = Some(128); base.stack_probes = StackProbeType::Inline; diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_trusty.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_trusty.rs index 7dfa29787c86..bacc99c64f16 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_trusty.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_trusty.rs @@ -18,7 +18,7 @@ pub(crate) fn target() -> Target { data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(), arch: Arch::AArch64, options: TargetOptions { - features: "+neon,+fp-armv8,+reserve-x18".into(), + features: "+neon,+reserve-x18".into(), executables: true, max_atomic_width: Some(128), panic_strategy: PanicStrategy::Abort, diff --git a/compiler/rustc_target/src/spec/targets/arm64_32_apple_watchos.rs b/compiler/rustc_target/src/spec/targets/arm64_32_apple_watchos.rs index dab8cd157d2b..a9fe6bf0efd2 100644 --- a/compiler/rustc_target/src/spec/targets/arm64_32_apple_watchos.rs +++ b/compiler/rustc_target/src/spec/targets/arm64_32_apple_watchos.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32".into(), arch, options: TargetOptions { - features: "+v8a,+neon,+fp-armv8,+apple-a7".into(), + features: "+v8a,+neon,+apple-a7".into(), max_atomic_width: Some(128), dynamic_linking: false, position_independent_executables: true, diff --git a/compiler/rustc_target/src/spec/targets/arm64e_apple_ios.rs b/compiler/rustc_target/src/spec/targets/arm64e_apple_ios.rs index 4ee4a16ab747..396f0c347a08 100644 --- a/compiler/rustc_target/src/spec/targets/arm64e_apple_ios.rs +++ b/compiler/rustc_target/src/spec/targets/arm64e_apple_ios.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a12,+v8.3a,+pauth".into(), + features: "+neon,+apple-a12,+v8.3a,+paca,+pacg".into(), max_atomic_width: Some(128), supported_sanitizers: SanitizerSet::ADDRESS | SanitizerSet::THREAD, ..opts diff --git a/compiler/rustc_target/src/spec/targets/arm64e_apple_tvos.rs b/compiler/rustc_target/src/spec/targets/arm64e_apple_tvos.rs index c09591be95f9..3cd120567a33 100644 --- a/compiler/rustc_target/src/spec/targets/arm64e_apple_tvos.rs +++ b/compiler/rustc_target/src/spec/targets/arm64e_apple_tvos.rs @@ -16,7 +16,7 @@ pub(crate) fn target() -> Target { .into(), arch, options: TargetOptions { - features: "+neon,+fp-armv8,+apple-a12,+v8.3a,+pauth".into(), + features: "+neon,+apple-a12,+v8.3a,+paca,+pacg".into(), max_atomic_width: Some(128), ..opts }, diff --git a/compiler/rustc_target/src/spec/targets/arm64ec_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/arm64ec_pc_windows_msvc.rs index aa31f53bf0fc..b333f2891626 100644 --- a/compiler/rustc_target/src/spec/targets/arm64ec_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/arm64ec_pc_windows_msvc.rs @@ -5,7 +5,7 @@ pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); base.max_atomic_width = Some(128); - base.features = "+v8a,+neon,+fp-armv8".into(); + base.features = "+v8a,+neon".into(); add_link_args( &mut base.late_link_args, LinkerFlavor::Msvc(Lld::No), diff --git a/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs index 290087d8cef6..cd074a468fd6 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_fortanix_unknown_sgx.rs @@ -66,7 +66,7 @@ pub(crate) fn target() -> Target { max_atomic_width: Some(64), cpu: "x86-64".into(), plt_by_default: false, - features: "+rdrnd,+rdseed,+lvi-cfi,+lvi-load-hardening".into(), + features: "+rdrand,+rdseed,+lvi-cfi,+lvi-load-hardening".into(), llvm_args: cvs!["--x86-experimental-lvi-inline-asm-hardening"], position_independent_executables: true, pre_link_args, diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs index ba0882b8693b..995bfd07071e 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs @@ -3,7 +3,7 @@ pub(crate) fn target() -> Target { let mut base = base::windows_gnu::opts(); base.cpu = "x86-64".into(); - base.features = "+cx16,+sse3,+sahf".into(); + base.features = "+cmpxchg16b,+sse3,+lahfsahf".into(); base.plt_by_default = false; // Use high-entropy 64 bit address space for ASLR base.add_pre_link_args( diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs index 0606d4508bad..de3c960bced9 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnullvm.rs @@ -3,7 +3,7 @@ pub(crate) fn target() -> Target { let mut base = base::windows_gnullvm::opts(); base.cpu = "x86-64".into(); - base.features = "+cx16,+sse3,+sahf".into(); + base.features = "+cmpxchg16b,+sse3,+lahfsahf".into(); base.plt_by_default = false; base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); base.max_atomic_width = Some(128); diff --git a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs index 1eecec8e6bde..20b6e0701bff 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_msvc.rs @@ -3,7 +3,7 @@ pub(crate) fn target() -> Target { let mut base = base::windows_msvc::opts(); base.cpu = "x86-64".into(); - base.features = "+cx16,+sse3,+sahf".into(); + base.features = "+cmpxchg16b,+sse3,+lahfsahf".into(); base.plt_by_default = false; base.max_atomic_width = Some(128); base.supported_sanitizers = SanitizerSet::ADDRESS; diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs index 0d92097ad456..dbff5e30828a 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_fuchsia.rs @@ -6,7 +6,7 @@ pub(crate) fn target() -> Target { base.plt_by_default = false; // See https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0073_x86_64_platform_requirement, // which corresponds to x86-64-v2. - base.features = "+cx16,+sahf,+popcnt,+sse3,+sse4.1,+sse4.2,+ssse3".into(); + base.features = "+cmpxchg16b,+lahfsahf,+popcnt,+sse3,+sse4.1,+sse4.2,+ssse3".into(); base.max_atomic_width = Some(128); base.stack_probes = StackProbeType::Inline; base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK; diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs index ee191ac95ae7..d6630261e234 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_hermit.rs @@ -15,7 +15,7 @@ pub(crate) fn target() -> Target { "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(), options: TargetOptions { cpu: "x86-64".into(), - features: "+rdrnd,+rdseed".into(), + features: "+rdrand,+rdseed".into(), plt_by_default: false, max_atomic_width: Some(64), stack_probes: StackProbeType::Inline, diff --git a/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs index 96d1bd2764c8..9d53ce0e1c80 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_gnu.rs @@ -3,7 +3,7 @@ pub(crate) fn target() -> Target { let mut base = base::windows_uwp_gnu::opts(); base.cpu = "x86-64".into(); - base.features = "+cx16,+sse3,+sahf".into(); + base.features = "+cmpxchg16b,+sse3,+lahfsahf".into(); base.plt_by_default = false; // Use high-entropy 64 bit address space for ASLR base.add_pre_link_args( diff --git a/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs index 3be6abd3d975..003bcf1e0ddf 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_uwp_windows_msvc.rs @@ -3,7 +3,7 @@ pub(crate) fn target() -> Target { let mut base = base::windows_uwp_msvc::opts(); base.cpu = "x86-64".into(); - base.features = "+cx16,+sse3,+sahf".into(); + base.features = "+cmpxchg16b,+sse3,+lahfsahf".into(); base.plt_by_default = false; base.max_atomic_width = Some(128); diff --git a/compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs b/compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs index adc87378fc7e..7f1fe485aa15 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target { // It would be nice if this were not the case, but fixing it seems tricky // (and given that the main use-case for this target is for use in universal // binaries, probably not that important). - opts.features = "-rdrnd,-aes,-pclmul,-rtm,-fsgsbase".into(); + opts.features = "-rdrand,-aes,-pclmulqdq,-rtm,-fsgsbase".into(); // Double-check that the `cpu` is what we expect (if it's not the list above // may need updating). assert_eq!( From d3c580db2197e59603c2fdb8f111b684885d4096 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 20 Nov 2025 14:22:32 +0000 Subject: [PATCH 181/194] Handle inline asm in has_ffi_unwind_calls This is required for the soundness of options(may_unwind) --- compiler/rustc_mir_transform/messages.ftl | 3 ++ compiler/rustc_mir_transform/src/errors.rs | 7 +++++ .../src/ffi_unwind_calls.rs | 29 +++++++++++++++++++ tests/ui/asm/may_unwind_ffi_unwind.rs | 18 ++++++++++++ tests/ui/asm/may_unwind_ffi_unwind.stderr | 14 +++++++++ 5 files changed, 71 insertions(+) create mode 100644 tests/ui/asm/may_unwind_ffi_unwind.rs create mode 100644 tests/ui/asm/may_unwind_ffi_unwind.stderr diff --git a/compiler/rustc_mir_transform/messages.ftl b/compiler/rustc_mir_transform/messages.ftl index cfc9b8edf7a2..7924c015200f 100644 --- a/compiler/rustc_mir_transform/messages.ftl +++ b/compiler/rustc_mir_transform/messages.ftl @@ -1,4 +1,7 @@ mir_transform_arithmetic_overflow = this arithmetic operation will overflow + +mir_transform_asm_unwind_call = call to inline assembly that may unwind + mir_transform_const_defined_here = `const` item defined here mir_transform_const_modify = attempting to modify a `const` item diff --git a/compiler/rustc_mir_transform/src/errors.rs b/compiler/rustc_mir_transform/src/errors.rs index 517e4dd69262..ee21d4fbcead 100644 --- a/compiler/rustc_mir_transform/src/errors.rs +++ b/compiler/rustc_mir_transform/src/errors.rs @@ -143,6 +143,13 @@ pub(crate) fn lint(&self) -> &'static Lint { } } +#[derive(LintDiagnostic)] +#[diag(mir_transform_asm_unwind_call)] +pub(crate) struct AsmUnwindCall { + #[label(mir_transform_asm_unwind_call)] + pub span: Span, +} + #[derive(LintDiagnostic)] #[diag(mir_transform_ffi_unwind_call)] pub(crate) struct FfiUnwindCall { diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs index 7c66783548ea..06e7bf974b51 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -1,4 +1,5 @@ use rustc_abi::ExternAbi; +use rustc_ast::InlineAsmOptions; use rustc_hir::def_id::{LOCAL_CRATE, LocalDefId}; use rustc_middle::mir::*; use rustc_middle::query::{LocalCrate, Providers}; @@ -46,6 +47,34 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { continue; } let Some(terminator) = &block.terminator else { continue }; + + if let TerminatorKind::InlineAsm { options, .. } = &terminator.kind { + if options.contains(InlineAsmOptions::MAY_UNWIND) { + // We have detected an inline asm block that can possibly leak foreign unwind. + // + // Because the function body itself can unwind, we are not aborting this function call + // upon unwind, so this call can possibly leak foreign unwind into Rust code if the + // panic runtime linked is panic-abort. + + let lint_root = body.source_scopes[terminator.source_info.scope] + .local_data + .as_ref() + .unwrap_crate_local() + .lint_root; + let span = terminator.source_info.span; + + tcx.emit_node_span_lint( + FFI_UNWIND_CALLS, + lint_root, + span, + errors::AsmUnwindCall { span }, + ); + + tainted = true; + } + continue; + } + let TerminatorKind::Call { func, .. } = &terminator.kind else { continue }; let ty = func.ty(body, tcx); diff --git a/tests/ui/asm/may_unwind_ffi_unwind.rs b/tests/ui/asm/may_unwind_ffi_unwind.rs new file mode 100644 index 000000000000..65e2adac0a97 --- /dev/null +++ b/tests/ui/asm/may_unwind_ffi_unwind.rs @@ -0,0 +1,18 @@ +// Check that asm!() with options(may_unwind) is considered an FFI call by has_ffi_unwind_calls. + +//@ check-fail +//@ needs-asm-support +//@ needs-unwind + +#![feature(asm_unwind)] +#![deny(ffi_unwind_calls)] + +use std::arch::asm; + +#[no_mangle] +pub unsafe fn asm_may_unwind() { + asm!("", options(may_unwind)); + //~^ ERROR call to inline assembly that may unwind +} + +fn main() {} diff --git a/tests/ui/asm/may_unwind_ffi_unwind.stderr b/tests/ui/asm/may_unwind_ffi_unwind.stderr new file mode 100644 index 000000000000..de24b601219e --- /dev/null +++ b/tests/ui/asm/may_unwind_ffi_unwind.stderr @@ -0,0 +1,14 @@ +error: call to inline assembly that may unwind + --> $DIR/may_unwind_ffi_unwind.rs:14:5 + | +LL | asm!("", options(may_unwind)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to inline assembly that may unwind + | +note: the lint level is defined here + --> $DIR/may_unwind_ffi_unwind.rs:8:9 + | +LL | #![deny(ffi_unwind_calls)] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + From ae699c8e78469207ccd39f1165ab7f6e1e3f58fe Mon Sep 17 00:00:00 2001 From: lapla Date: Wed, 26 Nov 2025 01:02:01 +0900 Subject: [PATCH 182/194] Avoid ICE when handling const auto traits in the next-gen solver --- .../src/solve/effect_goals.rs | 5 +++-- .../ui/traits/const-traits/const-auto-trait.rs | 9 +++++++++ .../traits/const-traits/const-auto-trait.stderr | 17 +++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs b/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs index 2cb79a0219f6..2837b8565f60 100644 --- a/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs @@ -189,10 +189,11 @@ fn consider_error_guaranteed_candidate( } fn consider_auto_trait_candidate( - _ecx: &mut EvalCtxt<'_, D>, + ecx: &mut EvalCtxt<'_, D>, _goal: Goal, ) -> Result, NoSolution> { - unreachable!("auto traits are never const") + ecx.cx().delay_bug("auto traits are never const"); + Err(NoSolution) } fn consider_trait_alias_candidate( diff --git a/tests/ui/traits/const-traits/const-auto-trait.rs b/tests/ui/traits/const-traits/const-auto-trait.rs index 06558df4623f..d1745a2ec4c7 100644 --- a/tests/ui/traits/const-traits/const-auto-trait.rs +++ b/tests/ui/traits/const-traits/const-auto-trait.rs @@ -1,6 +1,15 @@ +//@ compile-flags: -Znext-solver +// See rust-lang/rust#149285 for this test + #![feature(auto_traits, const_trait_impl)] const auto trait Marker {} //~^ ERROR: auto traits cannot be const +fn scope() { + fn check() {} + check::<()>(); + //~^ ERROR: the trait bound `(): const Marker` is not satisfied +} + fn main() {} diff --git a/tests/ui/traits/const-traits/const-auto-trait.stderr b/tests/ui/traits/const-traits/const-auto-trait.stderr index cb8ff8001ba0..094c334fc289 100644 --- a/tests/ui/traits/const-traits/const-auto-trait.stderr +++ b/tests/ui/traits/const-traits/const-auto-trait.stderr @@ -1,10 +1,23 @@ error: auto traits cannot be const - --> $DIR/const-auto-trait.rs:3:1 + --> $DIR/const-auto-trait.rs:6:1 | LL | const auto trait Marker {} | ^^^^^ | = help: remove the `const` keyword -error: aborting due to 1 previous error +error[E0277]: the trait bound `(): const Marker` is not satisfied + --> $DIR/const-auto-trait.rs:11:13 + | +LL | check::<()>(); + | ^^ + | +note: required by a bound in `check` + --> $DIR/const-auto-trait.rs:10:17 + | +LL | fn check() {} + | ^^^^^^^^^^^^ required by this bound in `check` +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. From 5128ce10a077f96a79e278035522f1f8f9611a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Dom=C3=ADnguez?= Date: Sun, 19 Oct 2025 12:36:23 +0200 Subject: [PATCH 183/194] Implement offload intrinsic --- compiler/rustc_codegen_llvm/messages.ftl | 3 + compiler/rustc_codegen_llvm/src/attributes.rs | 12 + compiler/rustc_codegen_llvm/src/back/lto.rs | 10 +- compiler/rustc_codegen_llvm/src/back/write.rs | 11 +- .../src/builder/gpu_offload.rs | 206 +++++++++--------- compiler/rustc_codegen_llvm/src/context.rs | 10 + compiler/rustc_codegen_llvm/src/errors.rs | 8 + compiler/rustc_codegen_llvm/src/intrinsic.rs | 80 ++++++- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 6 +- compiler/rustc_codegen_llvm/src/llvm/mod.rs | 8 + .../rustc_codegen_ssa/src/codegen_attrs.rs | 3 + compiler/rustc_feature/src/builtin_attrs.rs | 5 + .../rustc_hir_analysis/src/check/intrinsic.rs | 2 + .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 33 +++ .../src/middle/codegen_fn_attrs.rs | 2 + compiler/rustc_middle/src/ty/mod.rs | 1 + compiler/rustc_middle/src/ty/offload_meta.rs | 119 ++++++++++ compiler/rustc_span/src/symbol.rs | 2 + library/core/src/intrinsics/mod.rs | 29 +++ tests/codegen-llvm/gpu_offload/gpu_host.rs | 114 +++++----- tests/ui/offload/check_config.fail.stderr | 6 + tests/ui/offload/check_config.rs | 23 ++ 22 files changed, 516 insertions(+), 177 deletions(-) create mode 100644 compiler/rustc_middle/src/ty/offload_meta.rs create mode 100644 tests/ui/offload/check_config.fail.stderr create mode 100644 tests/ui/offload/check_config.rs diff --git a/compiler/rustc_codegen_llvm/messages.ftl b/compiler/rustc_codegen_llvm/messages.ftl index c9d28160d66f..0e7b00d0bcb7 100644 --- a/compiler/rustc_codegen_llvm/messages.ftl +++ b/compiler/rustc_codegen_llvm/messages.ftl @@ -18,6 +18,9 @@ codegen_llvm_lto_bitcode_from_rlib = failed to get bitcode from object file for codegen_llvm_mismatch_data_layout = data-layout for target `{$rustc_target}`, `{$rustc_layout}`, differs from LLVM target's `{$llvm_target}` default layout, `{$llvm_layout}` +codegen_llvm_offload_without_enable = using the offload feature requires -Z offload=Enable +codegen_llvm_offload_without_fat_lto = using the offload feature requires -C lto=fat + codegen_llvm_parse_bitcode = failed to parse bitcode for LTO module codegen_llvm_parse_bitcode_with_llvm_err = failed to parse bitcode for LTO module: {$llvm_err} diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 89878d1e7e20..a25ce9e5a90a 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -30,6 +30,14 @@ pub(crate) fn apply_to_callsite(callsite: &Value, idx: AttributePlace, attrs: &[ } } +pub(crate) fn has_string_attr(llfn: &Value, name: &str) -> bool { + llvm::HasStringAttribute(llfn, name) +} + +pub(crate) fn remove_string_attr_from_llfn(llfn: &Value, name: &str) { + llvm::RemoveStringAttrFromFn(llfn, name); +} + /// Get LLVM attribute for the provided inline heuristic. pub(crate) fn inline_attr<'ll, 'tcx>( cx: &SimpleCx<'ll>, @@ -408,6 +416,10 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( to_add.push(llvm::CreateAttrString(cx.llcx, "no-builtins")); } + if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::OFFLOAD_KERNEL) { + to_add.push(llvm::CreateAttrString(cx.llcx, "offload-kernel")) + } + if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) { to_add.push(AttributeKind::Cold.create_attr(cx.llcx)); } diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index b820b992105f..482e95413855 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -26,7 +26,7 @@ }; use crate::errors::{LlvmError, LtoBitcodeFromRlib}; use crate::llvm::{self, build_string}; -use crate::{LlvmCodegenBackend, ModuleLlvm, SimpleCx}; +use crate::{LlvmCodegenBackend, ModuleLlvm}; /// We keep track of the computed LTO cache keys from the previous /// session to determine which CGUs we can reuse. @@ -601,7 +601,6 @@ pub(crate) fn run_pass_manager( // We then run the llvm_optimize function a second time, to optimize the code which we generated // in the enzyme differentiation pass. let enable_ad = config.autodiff.contains(&config::AutoDiff::Enable); - let enable_gpu = config.offload.contains(&config::Offload::Enable); let stage = if thin { write::AutodiffStage::PreAD } else { @@ -616,13 +615,6 @@ pub(crate) fn run_pass_manager( write::llvm_optimize(cgcx, dcx, module, None, config, opt_level, opt_stage, stage); } - // Here we only handle the GPU host (=cpu) code. - if enable_gpu && !thin && !cgcx.target_is_like_gpu { - let cx = - SimpleCx::new(module.module_llvm.llmod(), &module.module_llvm.llcx, cgcx.pointer_size); - crate::builder::gpu_offload::handle_gpu_code(cgcx, &cx); - } - if cfg!(feature = "llvm_enzyme") && enable_ad && !thin { let opt_stage = llvm::OptStage::FatLTO; let stage = write::AutodiffStage::PostAD; diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index fde7dd6ef7a8..4db4283adb40 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -43,7 +43,7 @@ use crate::llvm::diagnostic::OptimizationDiagnosticKind::*; use crate::llvm::{self, DiagnosticInfo}; use crate::type_::llvm_type_ptr; -use crate::{LlvmCodegenBackend, ModuleLlvm, SimpleCx, base, common, llvm_util}; +use crate::{LlvmCodegenBackend, ModuleLlvm, SimpleCx, attributes, base, common, llvm_util}; pub(crate) fn llvm_err<'a>(dcx: DiagCtxtHandle<'_>, err: LlvmError<'a>) -> ! { match llvm::last_error() { @@ -706,11 +706,12 @@ fn handle_offload<'ll>(cx: &'ll SimpleCx<'_>, old_fn: &llvm::Value) { SimpleCx::new(module.module_llvm.llmod(), module.module_llvm.llcx, cgcx.pointer_size); // For now we only support up to 10 kernels named kernel_0 ... kernel_9, a follow-up PR is // introducing a proper offload intrinsic to solve this limitation. - for num in 0..9 { - let name = format!("kernel_{num}"); - if let Some(kernel) = cx.get_function(&name) { - handle_offload(&cx, kernel); + for func in cx.get_functions() { + let offload_kernel = "offload-kernel"; + if attributes::has_string_attr(func, offload_kernel) { + handle_offload(&cx, func); } + attributes::remove_string_attr_from_llfn(func, offload_kernel); } } diff --git a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs index 5c2f8f700627..5d1ddd057d88 100644 --- a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs +++ b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs @@ -2,37 +2,13 @@ use llvm::Linkage::*; use rustc_abi::Align; -use rustc_codegen_ssa::back::write::CodegenContext; use rustc_codegen_ssa::traits::BaseTypeCodegenMethods; +use rustc_middle::ty::offload_meta::OffloadMetadata; use crate::builder::SBuilder; -use crate::common::AsCCharPtr; use crate::llvm::AttributePlace::Function; -use crate::llvm::{self, Linkage, Type, Value}; -use crate::{LlvmCodegenBackend, SimpleCx, attributes}; - -pub(crate) fn handle_gpu_code<'ll>( - _cgcx: &CodegenContext, - cx: &'ll SimpleCx<'_>, -) { - // The offload memory transfer type for each kernel - let mut memtransfer_types = vec![]; - let mut region_ids = vec![]; - let offload_entry_ty = TgtOffloadEntry::new_decl(&cx); - // This is a temporary hack, we only search for kernel_0 to kernel_9 functions. - // There is a draft PR in progress which will introduce a proper offload intrinsic to remove - // this limitation. - for num in 0..9 { - let kernel = cx.get_function(&format!("kernel_{num}")); - if let Some(kernel) = kernel { - let (o, k) = gen_define_handling(&cx, kernel, offload_entry_ty, num); - memtransfer_types.push(o); - region_ids.push(k); - } - } - - gen_call_handling(&cx, &memtransfer_types, ®ion_ids); -} +use crate::llvm::{self, BasicBlock, Linkage, Type, Value}; +use crate::{SimpleCx, attributes}; // ; Function Attrs: nounwind // declare i32 @__tgt_target_kernel(ptr, i64, i32, i32, ptr, ptr) #2 @@ -79,7 +55,7 @@ fn generate_at_one<'ll>(cx: &'ll SimpleCx<'_>) -> &'ll llvm::Value { at_one } -struct TgtOffloadEntry { +pub(crate) struct TgtOffloadEntry { // uint64_t Reserved; // uint16_t Version; // uint16_t Kind; @@ -167,7 +143,7 @@ fn new_decl<'ll>(cx: &'ll SimpleCx<'_>) -> &'ll Type { fn new<'ll>( cx: &'ll SimpleCx<'_>, num_args: u64, - memtransfer_types: &[&'ll Value], + memtransfer_types: &'ll Value, geps: [&'ll Value; 3], ) -> [(Align, &'ll Value); 13] { let four = Align::from_bytes(4).expect("4 Byte alignment should work"); @@ -181,7 +157,7 @@ fn new<'ll>( (eight, geps[0]), (eight, geps[1]), (eight, geps[2]), - (eight, memtransfer_types[0]), + (eight, memtransfer_types), // The next two are debug infos. FIXME(offload): set them (eight, cx.const_null(cx.type_ptr())), // dbg (eight, cx.const_null(cx.type_ptr())), // dbg @@ -194,6 +170,14 @@ fn new<'ll>( } } +// Contains LLVM values needed to manage offloading for a single kernel. +pub(crate) struct OffloadKernelData<'ll> { + pub offload_sizes: &'ll llvm::Value, + pub memtransfer_types: &'ll llvm::Value, + pub region_id: &'ll llvm::Value, + pub offload_entry: &'ll llvm::Value, +} + fn gen_tgt_data_mappers<'ll>( cx: &'ll SimpleCx<'_>, ) -> (&'ll llvm::Value, &'ll llvm::Value, &'ll llvm::Value, &'ll llvm::Type) { @@ -256,68 +240,68 @@ pub(crate) fn add_global<'ll>( // This function returns a memtransfer value which encodes how arguments to this kernel shall be // mapped to/from the gpu. It also returns a region_id with the name of this kernel, to be // concatenated into the list of region_ids. -fn gen_define_handling<'ll>( - cx: &'ll SimpleCx<'_>, - kernel: &'ll llvm::Value, +pub(crate) fn gen_define_handling<'ll>( + cx: &SimpleCx<'ll>, offload_entry_ty: &'ll llvm::Type, - num: i64, -) -> (&'ll llvm::Value, &'ll llvm::Value) { - let types = cx.func_params_types(cx.get_type_of_global(kernel)); + metadata: &[OffloadMetadata], + types: &[&Type], + symbol: &str, +) -> OffloadKernelData<'ll> { // It seems like non-pointer values are automatically mapped. So here, we focus on pointer (or // reference) types. - let num_ptr_types = types - .iter() - .filter(|&x| matches!(cx.type_kind(x), rustc_codegen_ssa::common::TypeKind::Pointer)) - .count(); + let ptr_meta = types.iter().zip(metadata).filter_map(|(&x, meta)| match cx.type_kind(x) { + rustc_codegen_ssa::common::TypeKind::Pointer => Some(meta), + _ => None, + }); - // We do not know their size anymore at this level, so hardcode a placeholder. - // A follow-up pr will track these from the frontend, where we still have Rust types. - // Then, we will be able to figure out that e.g. `&[f32;256]` will result in 4*256 bytes. - // I decided that 1024 bytes is a great placeholder value for now. - add_priv_unnamed_arr(&cx, &format!(".offload_sizes.{num}"), &vec![1024; num_ptr_types]); + // FIXME(Sa4dUs): add `OMP_MAP_TARGET_PARAM = 0x20` only if necessary + let (ptr_sizes, ptr_transfer): (Vec<_>, Vec<_>) = + ptr_meta.map(|m| (m.payload_size, m.mode.bits() | 0x20)).unzip(); + + let offload_sizes = add_priv_unnamed_arr(&cx, &format!(".offload_sizes.{symbol}"), &ptr_sizes); // Here we figure out whether something needs to be copied to the gpu (=1), from the gpu (=2), // or both to and from the gpu (=3). Other values shouldn't affect us for now. // A non-mutable reference or pointer will be 1, an array that's not read, but fully overwritten // will be 2. For now, everything is 3, until we have our frontend set up. // 1+2+32: 1 (MapTo), 2 (MapFrom), 32 (Add one extra input ptr per function, to be used later). - let memtransfer_types = add_priv_unnamed_arr( - &cx, - &format!(".offload_maptypes.{num}"), - &vec![1 + 2 + 32; num_ptr_types], - ); + let memtransfer_types = + add_priv_unnamed_arr(&cx, &format!(".offload_maptypes.{symbol}"), &ptr_transfer); + // Next: For each function, generate these three entries. A weak constant, // the llvm.rodata entry name, and the llvm_offload_entries value - let name = format!(".kernel_{num}.region_id"); + let name = format!(".{symbol}.region_id"); let initializer = cx.get_const_i8(0); let region_id = add_unnamed_global(&cx, &name, initializer, WeakAnyLinkage); - let c_entry_name = CString::new(format!("kernel_{num}")).unwrap(); + let c_entry_name = CString::new(symbol).unwrap(); let c_val = c_entry_name.as_bytes_with_nul(); - let offload_entry_name = format!(".offloading.entry_name.{num}"); + let offload_entry_name = format!(".offloading.entry_name.{symbol}"); let initializer = crate::common::bytes_in_context(cx.llcx, c_val); let llglobal = add_unnamed_global(&cx, &offload_entry_name, initializer, InternalLinkage); llvm::set_alignment(llglobal, Align::ONE); llvm::set_section(llglobal, c".llvm.rodata.offloading"); - let name = format!(".offloading.entry.kernel_{num}"); + + let name = format!(".offloading.entry.{symbol}"); // See the __tgt_offload_entry documentation above. let elems = TgtOffloadEntry::new(&cx, region_id, llglobal); let initializer = crate::common::named_struct(offload_entry_ty, &elems); let c_name = CString::new(name).unwrap(); - let llglobal = llvm::add_global(cx.llmod, offload_entry_ty, &c_name); - llvm::set_global_constant(llglobal, true); - llvm::set_linkage(llglobal, WeakAnyLinkage); - llvm::set_initializer(llglobal, initializer); - llvm::set_alignment(llglobal, Align::EIGHT); + let offload_entry = llvm::add_global(cx.llmod, offload_entry_ty, &c_name); + llvm::set_global_constant(offload_entry, true); + llvm::set_linkage(offload_entry, WeakAnyLinkage); + llvm::set_initializer(offload_entry, initializer); + llvm::set_alignment(offload_entry, Align::EIGHT); let c_section_name = CString::new("llvm_offload_entries").unwrap(); - llvm::set_section(llglobal, &c_section_name); - (memtransfer_types, region_id) + llvm::set_section(offload_entry, &c_section_name); + + OffloadKernelData { offload_sizes, memtransfer_types, region_id, offload_entry } } -pub(crate) fn declare_offload_fn<'ll>( +fn declare_offload_fn<'ll>( cx: &'ll SimpleCx<'_>, name: &str, ty: &'ll llvm::Type, @@ -333,8 +317,7 @@ pub(crate) fn declare_offload_fn<'ll>( } // For each kernel *call*, we now use some of our previous declared globals to move data to and from -// the gpu. We don't have a proper frontend yet, so we assume that every call to a kernel function -// from main is intended to run on the GPU. For now, we only handle the data transfer part of it. +// the gpu. For now, we only handle the data transfer part of it. // If two consecutive kernels use the same memory, we still move it to the host and back to the gpu. // Since in our frontend users (by default) don't have to specify data transfer, this is something // we should optimize in the future! We also assume that everything should be copied back and forth, @@ -352,11 +335,16 @@ pub(crate) fn declare_offload_fn<'ll>( // 4. set insert point after kernel call. // 5. generate all the GEPS and stores, to be used in 6) // 6. generate __tgt_target_data_end calls to move data from the GPU -fn gen_call_handling<'ll>( - cx: &'ll SimpleCx<'_>, - memtransfer_types: &[&'ll llvm::Value], - region_ids: &[&'ll llvm::Value], +pub(crate) fn gen_call_handling<'ll>( + cx: &SimpleCx<'ll>, + bb: &BasicBlock, + offload_data: &OffloadKernelData<'ll>, + args: &[&'ll Value], + types: &[&Type], + metadata: &[OffloadMetadata], ) { + let OffloadKernelData { offload_sizes, offload_entry, memtransfer_types, region_id } = + offload_data; let (tgt_decl, tgt_target_kernel_ty) = generate_launcher(&cx); // %struct.__tgt_bin_desc = type { i32, ptr, ptr, ptr } let tptr = cx.type_ptr(); @@ -368,27 +356,32 @@ fn gen_call_handling<'ll>( let tgt_kernel_decl = KernelArgsTy::new_decl(&cx); let (begin_mapper_decl, _, end_mapper_decl, fn_ty) = gen_tgt_data_mappers(&cx); - let main_fn = cx.get_function("main"); - let Some(main_fn) = main_fn else { return }; - let kernel_name = "kernel_1"; - let call = unsafe { - llvm::LLVMRustGetFunctionCall(main_fn, kernel_name.as_c_char_ptr(), kernel_name.len()) - }; - let Some(kernel_call) = call else { - return; - }; - let kernel_call_bb = unsafe { llvm::LLVMGetInstructionParent(kernel_call) }; - let called = unsafe { llvm::LLVMGetCalledValue(kernel_call).unwrap() }; - let mut builder = SBuilder::build(cx, kernel_call_bb); + let mut builder = SBuilder::build(cx, bb); - let types = cx.func_params_types(cx.get_type_of_global(called)); let num_args = types.len() as u64; + let ip = unsafe { llvm::LLVMRustGetInsertPoint(&builder.llbuilder) }; + + // FIXME(Sa4dUs): dummy loads are a temp workaround, we should find a proper way to prevent these + // variables from being optimized away + for val in [offload_sizes, offload_entry] { + unsafe { + let dummy = llvm::LLVMBuildLoad2( + &builder.llbuilder, + llvm::LLVMTypeOf(val), + val, + b"dummy\0".as_ptr() as *const _, + ); + llvm::LLVMSetVolatile(dummy, llvm::TRUE); + } + } // Step 0) // %struct.__tgt_bin_desc = type { i32, ptr, ptr, ptr } // %6 = alloca %struct.__tgt_bin_desc, align 8 - unsafe { llvm::LLVMRustPositionBuilderPastAllocas(builder.llbuilder, main_fn) }; - + let llfn = unsafe { llvm::LLVMGetBasicBlockParent(bb) }; + unsafe { + llvm::LLVMRustPositionBuilderPastAllocas(&builder.llbuilder, llfn); + } let tgt_bin_desc_alloca = builder.direct_alloca(tgt_bin_desc, Align::EIGHT, "EmptyDesc"); let ty = cx.type_array(cx.type_ptr(), num_args); @@ -404,15 +397,16 @@ fn gen_call_handling<'ll>( let a5 = builder.direct_alloca(tgt_kernel_decl, Align::EIGHT, "kernel_args"); // Step 1) - unsafe { llvm::LLVMRustPositionBefore(builder.llbuilder, kernel_call) }; + unsafe { + llvm::LLVMRustRestoreInsertPoint(&builder.llbuilder, ip); + } builder.memset(tgt_bin_desc_alloca, cx.get_const_i8(0), cx.get_const_i64(32), Align::EIGHT); // Now we allocate once per function param, a copy to be passed to one of our maps. let mut vals = vec![]; let mut geps = vec![]; let i32_0 = cx.get_const_i32(0); - for index in 0..types.len() { - let v = unsafe { llvm::LLVMGetOperand(kernel_call, index as u32).unwrap() }; + for &v in args { let gep = builder.inbounds_gep(cx.type_f32(), v, &[i32_0]); vals.push(v); geps.push(gep); @@ -437,10 +431,8 @@ fn gen_call_handling<'ll>( let gep2 = builder.inbounds_gep(ty, a2, &[i32_0, idx]); builder.store(geps[i as usize], gep2, Align::EIGHT); let gep3 = builder.inbounds_gep(ty2, a4, &[i32_0, idx]); - // As mentioned above, we don't use Rust type information yet. So for now we will just - // assume that we have 1024 bytes, 256 f32 values. // FIXME(offload): write an offload frontend and handle arbitrary types. - builder.store(cx.get_const_i64(1024), gep3, Align::EIGHT); + builder.store(cx.get_const_i64(metadata[i as usize].payload_size), gep3, Align::EIGHT); } // For now we have a very simplistic indexing scheme into our @@ -482,9 +474,17 @@ fn generate_mapper_call<'a, 'll>( // Step 2) let s_ident_t = generate_at_one(&cx); - let o = memtransfer_types[0]; let geps = get_geps(&mut builder, &cx, ty, ty2, a1, a2, a4); - generate_mapper_call(&mut builder, &cx, geps, o, begin_mapper_decl, fn_ty, num_args, s_ident_t); + generate_mapper_call( + &mut builder, + &cx, + geps, + memtransfer_types, + begin_mapper_decl, + fn_ty, + num_args, + s_ident_t, + ); let values = KernelArgsTy::new(&cx, num_args, memtransfer_types, geps); // Step 3) @@ -501,26 +501,26 @@ fn generate_mapper_call<'a, 'll>( // FIXME(offload): Don't hardcode the numbers of threads in the future. cx.get_const_i32(2097152), cx.get_const_i32(256), - region_ids[0], + region_id, a5, ]; - let offload_success = builder.call(tgt_target_kernel_ty, tgt_decl, &args, None); + builder.call(tgt_target_kernel_ty, tgt_decl, &args, None); // %41 = call i32 @__tgt_target_kernel(ptr @1, i64 -1, i32 2097152, i32 256, ptr @.kernel_1.region_id, ptr %kernel_args) - unsafe { - let next = llvm::LLVMGetNextInstruction(offload_success).unwrap(); - llvm::LLVMRustPositionAfter(builder.llbuilder, next); - llvm::LLVMInstructionEraseFromParent(next); - } // Step 4) let geps = get_geps(&mut builder, &cx, ty, ty2, a1, a2, a4); - generate_mapper_call(&mut builder, &cx, geps, o, end_mapper_decl, fn_ty, num_args, s_ident_t); + generate_mapper_call( + &mut builder, + &cx, + geps, + memtransfer_types, + end_mapper_decl, + fn_ty, + num_args, + s_ident_t, + ); builder.call(mapper_fn_ty, unregister_lib_decl, &[tgt_bin_desc_alloca], None); drop(builder); - // FIXME(offload) The issue is that we right now add a call to the gpu version of the function, - // and then delete the call to the CPU version. In the future, we should use an intrinsic which - // directly resolves to a call to the GPU version. - unsafe { llvm::LLVMDeleteFunction(called) }; } diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index b60c8a7d3719..6caf60e3cc41 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -791,6 +791,16 @@ pub(crate) fn create_metadata(&self, name: &[u8]) -> &'ll Metadata { llvm::LLVMMDStringInContext2(self.llcx(), name.as_ptr() as *const c_char, name.len()) } } + + pub(crate) fn get_functions(&self) -> Vec<&'ll Value> { + let mut functions = vec![]; + let mut func = unsafe { llvm::LLVMGetFirstFunction(self.llmod()) }; + while let Some(f) = func { + functions.push(f); + func = unsafe { llvm::LLVMGetNextFunction(f) } + } + functions + } } impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> { diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index 629afee8a667..dd9fde0b08c6 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -40,6 +40,14 @@ fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { #[diag(codegen_llvm_autodiff_without_enable)] pub(crate) struct AutoDiffWithoutEnable; +#[derive(Diagnostic)] +#[diag(codegen_llvm_offload_without_enable)] +pub(crate) struct OffloadWithoutEnable; + +#[derive(Diagnostic)] +#[diag(codegen_llvm_offload_without_fat_lto)] +pub(crate) struct OffloadWithoutFatLTO; + #[derive(Diagnostic)] #[diag(codegen_llvm_lto_bitcode_from_rlib)] pub(crate) struct LtoBitcodeFromRlib { diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 029c43e0ba82..33541f7b695f 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -13,6 +13,7 @@ use rustc_hir::{self as hir}; use rustc_middle::mir::BinOp; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf}; +use rustc_middle::ty::offload_meta::OffloadMetadata; use rustc_middle::ty::{self, GenericArgsRef, Instance, SimdAlign, Ty, TyCtxt, TypingEnv}; use rustc_middle::{bug, span_bug}; use rustc_session::config::CrateType; @@ -25,8 +26,11 @@ use crate::abi::FnAbiLlvmExt; use crate::builder::Builder; use crate::builder::autodiff::{adjust_activity_to_abi, generate_enzyme_call}; +use crate::builder::gpu_offload::TgtOffloadEntry; use crate::context::CodegenCx; -use crate::errors::{AutoDiffWithoutEnable, AutoDiffWithoutLto}; +use crate::errors::{ + AutoDiffWithoutEnable, AutoDiffWithoutLto, OffloadWithoutEnable, OffloadWithoutFatLTO, +}; use crate::llvm::{self, Metadata, Type, Value}; use crate::type_of::LayoutLlvmExt; use crate::va_arg::emit_va_arg; @@ -197,6 +201,24 @@ fn codegen_intrinsic_call( codegen_autodiff(self, tcx, instance, args, result); return Ok(()); } + sym::offload => { + if !tcx + .sess + .opts + .unstable_opts + .offload + .contains(&rustc_session::config::Offload::Enable) + { + let _ = tcx.dcx().emit_almost_fatal(OffloadWithoutEnable); + } + + if tcx.sess.lto() != rustc_session::config::Lto::Fat { + let _ = tcx.dcx().emit_almost_fatal(OffloadWithoutFatLTO); + } + + codegen_offload(self, tcx, instance, args); + return Ok(()); + } sym::is_val_statically_known => { if let OperandValue::Immediate(imm) = args[0].val { self.call_intrinsic( @@ -1231,6 +1253,62 @@ fn codegen_autodiff<'ll, 'tcx>( ); } +// Generates the LLVM code to offload a Rust function to a target device (e.g., GPU). +// For each kernel call, it generates the necessary globals (including metadata such as +// size and pass mode), manages memory mapping to and from the device, handles all +// data transfers, and launches the kernel on the target device. +fn codegen_offload<'ll, 'tcx>( + bx: &mut Builder<'_, 'll, 'tcx>, + tcx: TyCtxt<'tcx>, + instance: ty::Instance<'tcx>, + args: &[OperandRef<'tcx, &'ll Value>], +) { + let cx = bx.cx; + let fn_args = instance.args; + + let (target_id, target_args) = match fn_args.into_type_list(tcx)[0].kind() { + ty::FnDef(def_id, params) => (def_id, params), + _ => bug!("invalid offload intrinsic arg"), + }; + + let fn_target = match Instance::try_resolve(tcx, cx.typing_env(), *target_id, target_args) { + Ok(Some(instance)) => instance, + Ok(None) => bug!( + "could not resolve ({:?}, {:?}) to a specific offload instance", + target_id, + target_args + ), + Err(_) => { + // An error has already been emitted + return; + } + }; + + let args = get_args_from_tuple(bx, args[1], fn_target); + let target_symbol = symbol_name_for_instance_in_crate(tcx, fn_target, LOCAL_CRATE); + + let offload_entry_ty = TgtOffloadEntry::new_decl(&cx); + + let sig = tcx.fn_sig(fn_target.def_id()).skip_binder().skip_binder(); + let inputs = sig.inputs(); + + let metadata = inputs.iter().map(|ty| OffloadMetadata::from_ty(tcx, *ty)).collect::>(); + + let types = inputs.iter().map(|ty| cx.layout_of(*ty).llvm_type(cx)).collect::>(); + + let offload_data = crate::builder::gpu_offload::gen_define_handling( + cx, + offload_entry_ty, + &metadata, + &types, + &target_symbol, + ); + + // FIXME(Sa4dUs): pass the original builder once we separate kernel launch logic from globals + let bb = unsafe { llvm::LLVMGetInsertBlock(bx.llbuilder) }; + crate::builder::gpu_offload::gen_call_handling(cx, bb, &offload_data, &args, &types, &metadata); +} + fn get_args_from_tuple<'ll, 'tcx>( bx: &mut Builder<'_, 'll, 'tcx>, tuple_op: OperandRef<'tcx, &'ll Value>, diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index ca64d96c2a33..be99c79a9517 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1160,13 +1160,9 @@ pub(crate) fn LLVMAppendBasicBlockInContext<'a>( ) -> &'a BasicBlock; // Operations on instructions - pub(crate) fn LLVMGetInstructionParent(Inst: &Value) -> &BasicBlock; - pub(crate) fn LLVMGetCalledValue(CallInst: &Value) -> Option<&Value>; pub(crate) fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>; pub(crate) fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock; pub(crate) fn LLVMGetOperand(Val: &Value, Index: c_uint) -> Option<&Value>; - pub(crate) fn LLVMGetNextInstruction(Val: &Value) -> Option<&Value>; - pub(crate) fn LLVMInstructionEraseFromParent(Val: &Value); // Operations on call sites pub(crate) fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint); @@ -2454,6 +2450,8 @@ pub(crate) fn LLVMRustUnpackSMDiagnostic( pub(crate) fn LLVMRustPositionBuilderPastAllocas<'a>(B: &Builder<'a>, Fn: &'a Value); pub(crate) fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock); + pub(crate) fn LLVMRustGetInsertPoint<'a>(B: &Builder<'a>) -> &'a Value; + pub(crate) fn LLVMRustRestoreInsertPoint<'a>(B: &Builder<'a>, IP: &'a Value); pub(crate) fn LLVMRustSetModulePICLevel(M: &Module); pub(crate) fn LLVMRustSetModulePIELevel(M: &Module); diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index 4c58a92106d5..55a4b415a4e2 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -43,6 +43,14 @@ pub(crate) fn AddFunctionAttributes<'ll>( } } +pub(crate) fn HasStringAttribute<'ll>(llfn: &'ll Value, name: &str) -> bool { + unsafe { LLVMRustHasFnAttribute(llfn, name.as_c_char_ptr(), name.len()) } +} + +pub(crate) fn RemoveStringAttrFromFn<'ll>(llfn: &'ll Value, name: &str) { + unsafe { LLVMRustRemoveFnAttribute(llfn, name.as_c_char_ptr(), name.len()) } +} + pub(crate) fn AddCallSiteAttributes<'ll>( callsite: &'ll Value, idx: AttributePlace, diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index fd3d7d2a3ded..0ab0cb0ef88a 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -334,6 +334,9 @@ fn process_builtin_attrs( codegen_fn_attrs.patchable_function_entry = parse_patchable_function_entry(tcx, attr); } + sym::rustc_offload_kernel => { + codegen_fn_attrs.flags |= CodegenFnAttrFlags::OFFLOAD_KERNEL + } _ => {} } } diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index ce7dd16cd19c..8e10f6041d1c 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -1117,6 +1117,11 @@ pub struct BuiltinAttribute { rustc_autodiff, Normal, template!(Word, List: &[r#""...""#]), DuplicatesOk, EncodeCrossCrate::Yes, + ), + rustc_attr!( + rustc_offload_kernel, Normal, + template!(Word), DuplicatesOk, + EncodeCrossCrate::Yes, ), // Traces that are left when `cfg` and `cfg_attr` attributes are expanded. // The attributes are not gated, to avoid stability errors, but they cannot be used in stable diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index 8a505668d0da..676c9a980aff 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -163,6 +163,7 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi | sym::minnumf128 | sym::mul_with_overflow | sym::needs_drop + | sym::offload | sym::offset_of | sym::overflow_checks | sym::powf16 @@ -313,6 +314,7 @@ pub(crate) fn check_intrinsic_type( let type_id = tcx.type_of(tcx.lang_items().type_id().unwrap()).instantiate_identity(); (0, 0, vec![type_id, type_id], tcx.types.bool) } + sym::offload => (3, 0, vec![param(0), param(1)], param(2)), sym::offset => (2, 0, vec![param(0), param(1)], param(0)), sym::arith_offset => ( 1, diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 8823c8392282..7902d167dd5e 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -1378,6 +1378,39 @@ extern "C" void LLVMRustPositionAfter(LLVMBuilderRef B, LLVMValueRef Instr) { } } +extern "C" LLVMValueRef LLVMRustGetInsertPoint(LLVMBuilderRef B) { + llvm::IRBuilderBase &IRB = *unwrap(B); + + llvm::IRBuilderBase::InsertPoint ip = IRB.saveIP(); + llvm::BasicBlock *BB = ip.getBlock(); + + if (!BB) + return nullptr; + + auto it = ip.getPoint(); + + if (it == BB->end()) + return nullptr; + + llvm::Instruction *I = &*it; + return wrap(I); +} + +extern "C" void LLVMRustRestoreInsertPoint(LLVMBuilderRef B, + LLVMValueRef Instr) { + llvm::IRBuilderBase &IRB = *unwrap(B); + + if (!Instr) { + llvm::BasicBlock *BB = IRB.GetInsertBlock(); + if (BB) + IRB.SetInsertPoint(BB); + return; + } + + llvm::Instruction *I = unwrap(Instr); + IRB.SetInsertPoint(I); +} + extern "C" LLVMValueRef LLVMRustGetFunctionCall(LLVMValueRef Fn, const char *Name, size_t NameLen) { auto targetName = StringRef(Name, NameLen); diff --git a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs index 5a28d56d4e54..9630cfc94b43 100644 --- a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs +++ b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs @@ -190,6 +190,8 @@ impl CodegenFnAttrFlags: u32 { const NO_BUILTINS = 1 << 15; /// Marks foreign items, to make `contains_extern_indicator` cheaper. const FOREIGN_ITEM = 1 << 16; + /// `#[rustc_offload_kernel]`: indicates that this is an offload kernel, an extra ptr arg will be added. + const OFFLOAD_KERNEL = 1 << 17; } } rustc_data_structures::external_bitflags_debug! { CodegenFnAttrFlags } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index d3914d2aee74..61b3059ab425 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -129,6 +129,7 @@ pub mod inhabitedness; pub mod layout; pub mod normalize_erasing_regions; +pub mod offload_meta; pub mod pattern; pub mod print; pub mod relate; diff --git a/compiler/rustc_middle/src/ty/offload_meta.rs b/compiler/rustc_middle/src/ty/offload_meta.rs new file mode 100644 index 000000000000..04a7cd2c75f2 --- /dev/null +++ b/compiler/rustc_middle/src/ty/offload_meta.rs @@ -0,0 +1,119 @@ +use bitflags::bitflags; + +use crate::ty::{self, PseudoCanonicalInput, Ty, TyCtxt, TypingEnv}; + +pub struct OffloadMetadata { + pub payload_size: u64, + pub mode: MappingFlags, +} + +bitflags! { + /// Mirrors `OpenMPOffloadMappingFlags` from Clang/OpenMP. + #[derive(Debug, Copy, Clone)] + #[repr(transparent)] + pub struct MappingFlags: u64 { + /// No flags. + const NONE = 0x0; + /// Allocate memory on the device and move data from host to device. + const TO = 0x01; + /// Allocate memory on the device and move data from device to host. + const FROM = 0x02; + /// Always perform the requested mapping action, even if already mapped. + const ALWAYS = 0x04; + /// Delete the element from the device environment, ignoring ref count. + const DELETE = 0x08; + /// The element being mapped is a pointer-pointee pair. + const PTR_AND_OBJ = 0x10; + /// The base address should be passed to the target kernel as argument. + const TARGET_PARAM = 0x20; + /// The runtime must return the device pointer. + const RETURN_PARAM = 0x40; + /// The reference being passed is a pointer to private data. + const PRIVATE = 0x80; + /// Pass the element by value. + const LITERAL = 0x100; + /// Implicit map (generated by compiler, not explicit in code). + const IMPLICIT = 0x200; + /// Hint to allocate memory close to the target device. + const CLOSE = 0x400; + /// Reserved (0x800 in OpenMP for XLC compatibility). + const RESERVED = 0x800; + /// Require that the data is already allocated on the device. + const PRESENT = 0x1000; + /// Increment/decrement a separate ref counter (OpenACC compatibility). + const OMPX_HOLD = 0x2000; + /// Used for non-contiguous list items in target update. + const NON_CONTIG = 0x100000000000; + /// 16 MSBs indicate membership in a struct. + const MEMBER_OF = 0xffff000000000000; + } +} + +impl OffloadMetadata { + pub fn from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self { + OffloadMetadata { + payload_size: get_payload_size(tcx, ty), + mode: MappingFlags::from_ty(tcx, ty), + } + } +} + +// FIXME(Sa4dUs): implement a solid logic to determine the payload size +fn get_payload_size<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> u64 { + match ty.kind() { + ty::RawPtr(inner, _) | ty::Ref(_, inner, _) => get_payload_size(tcx, *inner), + _ => tcx + .layout_of(PseudoCanonicalInput { + typing_env: TypingEnv::fully_monomorphized(), + value: ty, + }) + .unwrap() + .size + .bytes(), + } +} + +impl MappingFlags { + fn from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Self { + use rustc_ast::Mutability::*; + + match ty.kind() { + ty::Bool + | ty::Char + | ty::Int(_) + | ty::Uint(_) + | ty::Float(_) + | ty::Adt(_, _) + | ty::Tuple(_) + | ty::Array(_, _) + | ty::Alias(_, _) + | ty::Param(_) => MappingFlags::TO, + + ty::RawPtr(_, Not) | ty::Ref(_, _, Not) => MappingFlags::TO, + + ty::RawPtr(_, Mut) | ty::Ref(_, _, Mut) => MappingFlags::TO | MappingFlags::FROM, + + ty::Slice(_) | ty::Str | ty::Dynamic(_, _) => MappingFlags::TO | MappingFlags::FROM, + + ty::Foreign(_) | ty::Pat(_, _) | ty::UnsafeBinder(_) => { + MappingFlags::TO | MappingFlags::FROM + } + + ty::FnDef(_, _) + | ty::FnPtr(_, _) + | ty::Closure(_, _) + | ty::CoroutineClosure(_, _) + | ty::Coroutine(_, _) + | ty::CoroutineWitness(_, _) + | ty::Never + | ty::Bound(_, _) + | ty::Placeholder(_) + | ty::Infer(_) + | ty::Error(_) => { + tcx.dcx() + .span_err(rustc_span::DUMMY_SP, format!("type `{ty:?}` cannot be offloaded")); + MappingFlags::empty() + } + } + } +} diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index eca4259efa7d..6576cd3cc329 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1584,6 +1584,7 @@ object_safe_for_dispatch, of, off, + offload, offset, offset_of, offset_of_enum, @@ -1966,6 +1967,7 @@ rustc_objc_class, rustc_objc_selector, rustc_object_lifetime_default, + rustc_offload_kernel, rustc_on_unimplemented, rustc_outlives, rustc_paren_sugar, diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 564a896076b0..798df502ce01 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -3324,6 +3324,35 @@ pub const fn maximumf128(x: f128, y: f128) -> f128 { #[rustc_intrinsic] pub const fn autodiff(f: F, df: G, args: T) -> R; +/// Generates the LLVM body of a wrapper function to offload a kernel `f`. +/// +/// Type Parameters: +/// - `F`: The kernel to offload. Must be a function item. +/// - `T`: A tuple of arguments passed to `f`. +/// - `R`: The return type of the kernel. +/// +/// Example usage (pseudocode): +/// +/// ```rust,ignore (pseudocode) +/// fn kernel(x: *mut [f64; 128]) { +/// core::intrinsics::offload(kernel_1, (x,)) +/// } +/// +/// #[cfg(target_os = "linux")] +/// extern "C" { +/// pub fn kernel_1(array_b: *mut [f64; 128]); +/// } +/// +/// #[cfg(not(target_os = "linux"))] +/// #[rustc_offload_kernel] +/// extern "gpu-kernel" fn kernel_1(x: *mut [f64; 128]) { +/// unsafe { (*x)[0] = 21.0 }; +/// } +/// ``` +#[rustc_nounwind] +#[rustc_intrinsic] +pub const fn offload(f: F, args: T) -> R; + /// Inform Miri that a given pointer definitely has a certain alignment. #[cfg(miri)] #[rustc_allow_const_fn_unstable(const_eval_select)] diff --git a/tests/codegen-llvm/gpu_offload/gpu_host.rs b/tests/codegen-llvm/gpu_offload/gpu_host.rs index fac4054d1b7f..b0f83c825705 100644 --- a/tests/codegen-llvm/gpu_offload/gpu_host.rs +++ b/tests/codegen-llvm/gpu_offload/gpu_host.rs @@ -11,6 +11,7 @@ // when inside of a function called main. This, too, is a temporary workaround for not having a // frontend. +#![feature(core_intrinsics)] #![no_main] #[unsafe(no_mangle)] @@ -25,73 +26,70 @@ fn main() { // CHECK: %struct.__tgt_bin_desc = type { i32, ptr, ptr, ptr } // CHECK: %struct.__tgt_kernel_arguments = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, [3 x i32], [3 x i32], i32 } -// CHECK: @.offload_sizes.1 = private unnamed_addr constant [1 x i64] [i64 1024] -// CHECK: @.offload_maptypes.1 = private unnamed_addr constant [1 x i64] [i64 35] -// CHECK: @.kernel_1.region_id = weak unnamed_addr constant i8 0 -// CHECK: @.offloading.entry_name.1 = internal unnamed_addr constant [9 x i8] c"kernel_1\00", section ".llvm.rodata.offloading", align 1 -// CHECK: @.offloading.entry.kernel_1 = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 1, i32 0, ptr @.kernel_1.region_id, ptr @.offloading.entry_name.1, i64 0, i64 0, ptr null }, section "llvm_offload_entries", align 8 -// CHECK: @0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 -// CHECK: @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @0 }, align 8 +// CHECK: @.offload_sizes._kernel_1 = private unnamed_addr constant [1 x i64] [i64 1024] +// CHECK: @.offload_maptypes._kernel_1 = private unnamed_addr constant [1 x i64] [i64 35] +// CHECK: @._kernel_1.region_id = internal unnamed_addr constant i8 0 +// CHECK: @.offloading.entry_name._kernel_1 = internal unnamed_addr constant [10 x i8] c"_kernel_1\00", section ".llvm.rodata.offloading", align 1 +// CHECK: @.offloading.entry._kernel_1 = internal constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 1, i32 0, ptr @._kernel_1.region_id, ptr @.offloading.entry_name._kernel_1, i64 0, i64 0, ptr null }, section "llvm_offload_entries", align 8 + +// CHECK: @anon.{{.*}}.0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1 +// CHECK: @anon.{{.*}}.1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 22, ptr @anon.{{.*}}.0 }, align 8 // CHECK: Function Attrs: // CHECK-NEXT: define{{( dso_local)?}} void @main() // CHECK-NEXT: start: // CHECK-NEXT: %0 = alloca [8 x i8], align 8 // CHECK-NEXT: %x = alloca [1024 x i8], align 16 +// CHECK: call void @kernel_1(ptr noalias noundef nonnull align 4 dereferenceable(1024) %x) +// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %0) +// CHECK-NEXT: store ptr %x, ptr %0, align 8 +// CHECK-NEXT: call void asm sideeffect "", "r,~{memory}"(ptr nonnull %0) #4, !srcloc !4 +// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %0) +// CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %x) +// CHECK-NEXT: ret void +// CHECK-NEXT: } + +// CHECK: define{{( dso_local)?}} void @kernel_1(ptr noalias noundef align 4 dereferenceable(1024) %x) +// CHECK-NEXT: start: // CHECK-NEXT: %EmptyDesc = alloca %struct.__tgt_bin_desc, align 8 // CHECK-NEXT: %.offload_baseptrs = alloca [1 x ptr], align 8 // CHECK-NEXT: %.offload_ptrs = alloca [1 x ptr], align 8 // CHECK-NEXT: %.offload_sizes = alloca [1 x i64], align 8 // CHECK-NEXT: %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8 -// CHECK: call void @llvm.memset.p0.i64(ptr align 8 %EmptyDesc, i8 0, i64 32, i1 false) -// CHECK-NEXT: %1 = getelementptr inbounds float, ptr %x, i32 0 -// CHECK-NEXT: call void @__tgt_register_lib(ptr %EmptyDesc) +// CHECK-NEXT: %dummy = load volatile ptr, ptr @.offload_sizes._kernel_1, align 8 +// CHECK-NEXT: %dummy1 = load volatile ptr, ptr @.offloading.entry._kernel_1, align 8 +// CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %EmptyDesc, i8 0, i64 32, i1 false) +// CHECK-NEXT: call void @__tgt_register_lib(ptr nonnull %EmptyDesc) // CHECK-NEXT: call void @__tgt_init_all_rtls() -// CHECK-NEXT: %2 = getelementptr inbounds [1 x ptr], ptr %.offload_baseptrs, i32 0, i32 0 -// CHECK-NEXT: store ptr %x, ptr %2, align 8 -// CHECK-NEXT: %3 = getelementptr inbounds [1 x ptr], ptr %.offload_ptrs, i32 0, i32 0 -// CHECK-NEXT: store ptr %1, ptr %3, align 8 -// CHECK-NEXT: %4 = getelementptr inbounds [1 x i64], ptr %.offload_sizes, i32 0, i32 0 -// CHECK-NEXT: store i64 1024, ptr %4, align 8 -// CHECK-NEXT: %5 = getelementptr inbounds [1 x ptr], ptr %.offload_baseptrs, i32 0, i32 0 -// CHECK-NEXT: %6 = getelementptr inbounds [1 x ptr], ptr %.offload_ptrs, i32 0, i32 0 -// CHECK-NEXT: %7 = getelementptr inbounds [1 x i64], ptr %.offload_sizes, i32 0, i32 0 -// CHECK-NEXT: call void @__tgt_target_data_begin_mapper(ptr @1, i64 -1, i32 1, ptr %5, ptr %6, ptr %7, ptr @.offload_maptypes.1, ptr null, ptr null) -// CHECK-NEXT: %8 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 0 -// CHECK-NEXT: store i32 3, ptr %8, align 4 -// CHECK-NEXT: %9 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 1 -// CHECK-NEXT: store i32 1, ptr %9, align 4 -// CHECK-NEXT: %10 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 2 -// CHECK-NEXT: store ptr %5, ptr %10, align 8 -// CHECK-NEXT: %11 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 3 -// CHECK-NEXT: store ptr %6, ptr %11, align 8 -// CHECK-NEXT: %12 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 4 -// CHECK-NEXT: store ptr %7, ptr %12, align 8 -// CHECK-NEXT: %13 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 5 -// CHECK-NEXT: store ptr @.offload_maptypes.1, ptr %13, align 8 -// CHECK-NEXT: %14 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 6 -// CHECK-NEXT: store ptr null, ptr %14, align 8 -// CHECK-NEXT: %15 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 7 -// CHECK-NEXT: store ptr null, ptr %15, align 8 -// CHECK-NEXT: %16 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 8 -// CHECK-NEXT: store i64 0, ptr %16, align 8 -// CHECK-NEXT: %17 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 9 -// CHECK-NEXT: store i64 0, ptr %17, align 8 -// CHECK-NEXT: %18 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 10 -// CHECK-NEXT: store [3 x i32] [i32 2097152, i32 0, i32 0], ptr %18, align 4 -// CHECK-NEXT: %19 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 11 -// CHECK-NEXT: store [3 x i32] [i32 256, i32 0, i32 0], ptr %19, align 4 -// CHECK-NEXT: %20 = getelementptr inbounds %struct.__tgt_kernel_arguments, ptr %kernel_args, i32 0, i32 12 -// CHECK-NEXT: store i32 0, ptr %20, align 4 -// CHECK-NEXT: %21 = call i32 @__tgt_target_kernel(ptr @1, i64 -1, i32 2097152, i32 256, ptr @.kernel_1.region_id, ptr %kernel_args) -// CHECK-NEXT: %22 = getelementptr inbounds [1 x ptr], ptr %.offload_baseptrs, i32 0, i32 0 -// CHECK-NEXT: %23 = getelementptr inbounds [1 x ptr], ptr %.offload_ptrs, i32 0, i32 0 -// CHECK-NEXT: %24 = getelementptr inbounds [1 x i64], ptr %.offload_sizes, i32 0, i32 0 -// CHECK-NEXT: call void @__tgt_target_data_end_mapper(ptr @1, i64 -1, i32 1, ptr %22, ptr %23, ptr %24, ptr @.offload_maptypes.1, ptr null, ptr null) -// CHECK-NEXT: call void @__tgt_unregister_lib(ptr %EmptyDesc) -// CHECK: store ptr %x, ptr %0, align 8 -// CHECK-NEXT: call void asm sideeffect "", "r,~{memory}"(ptr nonnull %0) -// CHECK: ret void +// CHECK-NEXT: store ptr %x, ptr %.offload_baseptrs, align 8 +// CHECK-NEXT: store ptr %x, ptr %.offload_ptrs, align 8 +// CHECK-NEXT: store i64 1024, ptr %.offload_sizes, align 8 +// CHECK-NEXT: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes._kernel_1, ptr null, ptr null) +// CHECK-NEXT: store i32 3, ptr %kernel_args, align 8 +// CHECK-NEXT: %0 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 4 +// CHECK-NEXT: store i32 1, ptr %0, align 4 +// CHECK-NEXT: %1 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 8 +// CHECK-NEXT: store ptr %.offload_baseptrs, ptr %1, align 8 +// CHECK-NEXT: %2 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 16 +// CHECK-NEXT: store ptr %.offload_ptrs, ptr %2, align 8 +// CHECK-NEXT: %3 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 24 +// CHECK-NEXT: store ptr %.offload_sizes, ptr %3, align 8 +// CHECK-NEXT: %4 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 32 +// CHECK-NEXT: store ptr @.offload_maptypes._kernel_1, ptr %4, align 8 +// CHECK-NEXT: %5 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 40 +// CHECK-NEXT: %6 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 72 +// CHECK-NEXT: call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %5, i8 0, i64 32, i1 false) +// CHECK-NEXT: store <4 x i32> , ptr %6, align 8 +// CHECK-NEXT: %.fca.1.gep3 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 88 +// CHECK-NEXT: store i32 0, ptr %.fca.1.gep3, align 8 +// CHECK-NEXT: %.fca.2.gep4 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 92 +// CHECK-NEXT: store i32 0, ptr %.fca.2.gep4, align 4 +// CHECK-NEXT: %7 = getelementptr inbounds nuw i8, ptr %kernel_args, i64 96 +// CHECK-NEXT: store i32 0, ptr %7, align 8 +// CHECK-NEXT: %8 = call i32 @__tgt_target_kernel(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 2097152, i32 256, ptr nonnull @._kernel_1.region_id, ptr nonnull %kernel_args) +// CHECK-NEXT: call void @__tgt_target_data_end_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes._kernel_1, ptr null, ptr null) +// CHECK-NEXT: call void @__tgt_unregister_lib(ptr nonnull %EmptyDesc) +// CHECK-NEXT: ret void // CHECK-NEXT: } // CHECK: Function Attrs: nounwind @@ -100,6 +98,12 @@ fn main() { #[unsafe(no_mangle)] #[inline(never)] pub fn kernel_1(x: &mut [f32; 256]) { + core::intrinsics::offload(_kernel_1, (x,)) +} + +#[unsafe(no_mangle)] +#[inline(never)] +pub fn _kernel_1(x: &mut [f32; 256]) { for i in 0..256 { x[i] = 21.0; } diff --git a/tests/ui/offload/check_config.fail.stderr b/tests/ui/offload/check_config.fail.stderr new file mode 100644 index 000000000000..a9162ed926cb --- /dev/null +++ b/tests/ui/offload/check_config.fail.stderr @@ -0,0 +1,6 @@ +error: using the offload feature requires -Z offload=Enable + +error: using the offload feature requires -C lto=fat + +error: aborting due to 2 previous errors + diff --git a/tests/ui/offload/check_config.rs b/tests/ui/offload/check_config.rs new file mode 100644 index 000000000000..667c6d9788ba --- /dev/null +++ b/tests/ui/offload/check_config.rs @@ -0,0 +1,23 @@ +//@ revisions: pass fail +//@ no-prefer-dynamic +//@ needs-enzyme +//@[pass] build-pass +//@[fail] build-fail +//@[pass] compile-flags: -Zunstable-options -Zoffload=Enable -Clto=fat --emit=metadata +//@[fail] compile-flags: -Clto=thin + +//[fail]~? ERROR: using the offload feature requires -Z offload=Enable +//[fail]~? ERROR: using the offload feature requires -C lto=fat + +#![feature(core_intrinsics)] + +fn main() { + let mut x = [3.0; 256]; + kernel_1(&mut x); +} + +fn kernel_1(x: &mut [f32; 256]) { + core::intrinsics::offload(_kernel_1, (x,)) +} + +fn _kernel_1(x: &mut [f32; 256]) {} From f39ec4756fd70ca2509d204bb5f508324c8bd774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Dom=C3=ADnguez?= Date: Mon, 17 Nov 2025 18:40:25 +0100 Subject: [PATCH 184/194] Update rustc-dev-guide --- library/core/src/intrinsics/mod.rs | 3 +++ src/doc/rustc-dev-guide/src/offload/usage.md | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 798df502ce01..9d99b05b38d6 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -3349,6 +3349,9 @@ pub const fn maximumf128(x: f128, y: f128) -> f128 { /// unsafe { (*x)[0] = 21.0 }; /// } /// ``` +/// +/// For reference, see the Clang documentation on offloading: +/// . #[rustc_nounwind] #[rustc_intrinsic] pub const fn offload(f: F, args: T) -> R; diff --git a/src/doc/rustc-dev-guide/src/offload/usage.md b/src/doc/rustc-dev-guide/src/offload/usage.md index 7abf90aa6e0b..bcb97d134b9e 100644 --- a/src/doc/rustc-dev-guide/src/offload/usage.md +++ b/src/doc/rustc-dev-guide/src/offload/usage.md @@ -5,6 +5,8 @@ We currently work on launching the following Rust kernel on the GPU. To follow a ```rust #![feature(abi_gpu_kernel)] +#![feature(rustc_attrs)] +#![feature(core_intrinsics)] #![no_std] #[cfg(target_os = "linux")] @@ -12,6 +14,7 @@ extern crate libc; #[cfg(target_os = "linux")] use libc::c_char; +#[cfg(target_os = "linux")] use core::mem; #[panic_handler] @@ -38,7 +41,7 @@ fn main() { } unsafe { - kernel_1(array_c); + kernel(array_c); } core::hint::black_box(&array_c); unsafe { @@ -52,6 +55,11 @@ fn main() { } } +#[inline(never)] +unsafe fn kernel(x: *mut [f64; 256]) { + core::intrinsics::offload(kernel_1, (x,)) +} + #[cfg(target_os = "linux")] unsafe extern "C" { pub fn kernel_1(array_b: *mut [f64; 256]); @@ -60,6 +68,7 @@ unsafe extern "C" { #[cfg(not(target_os = "linux"))] #[unsafe(no_mangle)] #[inline(never)] +#[rustc_offload_kernel] pub extern "gpu-kernel" fn kernel_1(x: *mut [f64; 256]) { unsafe { (*x)[0] = 21.0 }; } From 7693c0a3d1710cb299fb925e47b79ecfb41a4d17 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Tue, 25 Nov 2025 21:16:31 +0100 Subject: [PATCH 185/194] Remove unused `Clone` derive on `DelayedLint` --- compiler/rustc_hir/src/lints.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir/src/lints.rs b/compiler/rustc_hir/src/lints.rs index c9de6f6b5d52..8563937f70d3 100644 --- a/compiler/rustc_hir/src/lints.rs +++ b/compiler/rustc_hir/src/lints.rs @@ -17,19 +17,19 @@ pub struct DelayedLints { /// and then there's a gap where no lints can be emitted until HIR is done. /// The variants in this enum represent lints that are temporarily stashed during /// AST lowering to be emitted once HIR is built. -#[derive(Clone, Debug, HashStable_Generic)] +#[derive(Debug, HashStable_Generic)] pub enum DelayedLint { AttributeParsing(AttributeLint), } -#[derive(Clone, Debug, HashStable_Generic)] +#[derive(Debug, HashStable_Generic)] pub struct AttributeLint { pub id: Id, pub span: Span, pub kind: AttributeLintKind, } -#[derive(Clone, Debug, HashStable_Generic)] +#[derive(Debug, HashStable_Generic)] pub enum AttributeLintKind { /// Copy of `IllFormedAttributeInput` /// specifically for the `invalid_macro_export_arguments` lint until that is removed, From c2bbd6be1ef6f950f4060818a981d43721e6faa0 Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Tue, 25 Nov 2025 14:26:06 -0500 Subject: [PATCH 186/194] Update cargo submodule --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 9fa462fe3a81..2a7c49606779 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 9fa462fe3a81e07e0bfdcc75c29d312c55113ebb +Subproject commit 2a7c4960677971f88458b0f8b461a866836dff59 From c87bebd553041679ebac00ee572b9f6cce5b9260 Mon Sep 17 00:00:00 2001 From: Jason Newcomb Date: Tue, 25 Nov 2025 23:07:27 -0500 Subject: [PATCH 187/194] Add `Copy` to some AST enums. --- compiler/rustc_ast/src/ast.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index f2061f3088a2..900af43dc078 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -857,7 +857,7 @@ pub fn prefix_str(self) -> &'static str { } } -#[derive(Clone, Encodable, Decodable, Debug, Walkable)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, Walkable)] pub enum RangeEnd { /// `..=` or `...` Included(RangeSyntax), @@ -865,7 +865,7 @@ pub enum RangeEnd { Excluded, } -#[derive(Clone, Encodable, Decodable, Debug, Walkable)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, Walkable)] pub enum RangeSyntax { /// `...` DotDotDot, @@ -1915,7 +1915,7 @@ pub enum ForLoopKind { } /// Used to differentiate between `async {}` blocks and `gen {}` blocks. -#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq, Walkable)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, PartialEq, Eq, Walkable)] pub enum GenBlockKind { Async, Gen, From ab8730431019ca7328383618d7b95f7858d81c01 Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Sat, 8 Nov 2025 12:35:03 +0200 Subject: [PATCH 188/194] `map_fn_sig_item` doesn't need a mutable reference --- src/librustdoc/html/render/search_index.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 3514c517d913..33a86a54636a 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -458,7 +458,7 @@ pub(crate) fn union(mut self, other: &SerializedSearchIndex) -> SerializedSearch other.descs[other_entryid].clone(), other.function_data[other_entryid].clone().map(|mut func| { fn map_fn_sig_item( - map_other_pathid_to_self_pathid: &mut Vec, + map_other_pathid_to_self_pathid: &Vec, ty: &mut RenderType, ) { match ty.id { @@ -501,14 +501,14 @@ fn map_fn_sig_item( } } for input in &mut func.inputs { - map_fn_sig_item(&mut map_other_pathid_to_self_pathid, input); + map_fn_sig_item(&map_other_pathid_to_self_pathid, input); } for output in &mut func.output { - map_fn_sig_item(&mut map_other_pathid_to_self_pathid, output); + map_fn_sig_item(&map_other_pathid_to_self_pathid, output); } for clause in &mut func.where_clause { for entry in clause { - map_fn_sig_item(&mut map_other_pathid_to_self_pathid, entry); + map_fn_sig_item(&map_other_pathid_to_self_pathid, entry); } } func From 87b5802ef53271e8bacd19856c9130b0d4f625bc Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Fri, 21 Nov 2025 23:03:59 +0200 Subject: [PATCH 189/194] Small cleanups --- .../html/render/search_index/encode.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/html/render/search_index/encode.rs b/src/librustdoc/html/render/search_index/encode.rs index a05c14374d1d..92a01a085984 100644 --- a/src/librustdoc/html/render/search_index/encode.rs +++ b/src/librustdoc/html/render/search_index/encode.rs @@ -52,6 +52,9 @@ pub fn read_signed_vlqhex_from_string(string: &[u8]) -> Option<(i32, usize)> { } pub fn write_postings_to_string(postings: &[Vec], buf: &mut Vec) { + // there's gonna be at least 1 byte pushed for every posting + buf.reserve(postings.len()); + for list in postings { if list.is_empty() { buf.push(0); @@ -63,19 +66,14 @@ pub fn write_postings_to_string(postings: &[Vec], buf: &mut Vec) { if len_after - len_before > 1 + (4 * list.len()) && list.len() < 0x3a { buf.truncate(len_before); buf.push(list.len() as u8); - for &item in list { - buf.push(item as u8); - buf.push((item >> 8) as u8); - buf.push((item >> 16) as u8); - buf.push((item >> 24) as u8); - } + buf.extend(list.iter().copied().map(u32::to_le_bytes).flatten()); } } } pub fn read_postings_from_string(postings: &mut Vec>, mut buf: &[u8]) { use stringdex::internals::decode::RoaringBitmap; - while let Some(&c) = buf.get(0) { + while let Some(&c) = buf.first() { if c < 0x3a { buf = &buf[1..]; let buf = buf.split_off(..usize::from(c) * size_of::()).unwrap(); @@ -83,9 +81,7 @@ pub fn read_postings_from_string(postings: &mut Vec>, mut buf: &[u8]) { let slot = chunks.iter().copied().map(u32::from_le_bytes).collect(); postings.push(slot); } else { - let (bitmap, consumed_bytes_len) = - RoaringBitmap::from_bytes(buf).unwrap_or_else(|| (RoaringBitmap::default(), 0)); - assert_ne!(consumed_bytes_len, 0); + let (bitmap, consumed_bytes_len) = RoaringBitmap::from_bytes(buf).unwrap(); postings.push(bitmap.to_vec()); buf = &buf[consumed_bytes_len..]; } From 51866db456cfc33d3f7b43217e7d1f5472460964 Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Fri, 21 Nov 2025 23:05:22 +0200 Subject: [PATCH 190/194] Pre-ensure size of vectors when performing union, instead of `push`ing default elements one by one --- src/librustdoc/html/render/search_index.rs | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 33a86a54636a..c70fda58513b 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -3,9 +3,9 @@ use std::collections::BTreeSet; use std::collections::hash_map::Entry; -use std::io; use std::path::Path; use std::string::FromUtf8Error; +use std::{io, iter}; use ::serde::de::{self, Deserializer, Error as _}; use ::serde::ser::{SerializeSeq, Serializer}; @@ -555,19 +555,19 @@ fn map_fn_sig_item( ); } } - for (i, other_generic_inverted_index) in other.generic_inverted_index.iter().enumerate() { - for (size, other_list) in other_generic_inverted_index.iter().enumerate() { - let self_generic_inverted_index = match self.generic_inverted_index.get_mut(i) { - Some(self_generic_inverted_index) => self_generic_inverted_index, - None => { - self.generic_inverted_index.push(Vec::new()); - self.generic_inverted_index.last_mut().unwrap() - } - }; - while self_generic_inverted_index.len() <= size { - self_generic_inverted_index.push(Vec::new()); - } - self_generic_inverted_index[size].extend( + if other.generic_inverted_index.len() > self.generic_inverted_index.len() { + self.generic_inverted_index.resize(other.generic_inverted_index.len(), Vec::new()); + } + for (other_generic_inverted_index, self_generic_inverted_index) in + iter::zip(&other.generic_inverted_index, &mut self.generic_inverted_index) + { + if other_generic_inverted_index.len() > self_generic_inverted_index.len() { + self_generic_inverted_index.resize(other_generic_inverted_index.len(), Vec::new()); + } + for (other_list, self_list) in + iter::zip(other_generic_inverted_index, self_generic_inverted_index) + { + self_list.extend( other_list .iter() .copied() From 25b720755e17ea447ddf176176332ed49f174c04 Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Fri, 21 Nov 2025 23:31:09 +0200 Subject: [PATCH 191/194] Extract common functionality into closure Also, use `Vec::resize` instead of individual `push`es --- src/librustdoc/html/render/search_index.rs | 76 +++++++++++----------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index c70fda58513b..be5437395cb0 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -1864,48 +1864,50 @@ fn convert_render_type( // unoccupied size. if item.ty.is_fn_like() { 0 } else { 16 }; serialized_index.function_data[new_entry_id] = Some(search_type.clone()); - for index in used_in_function_inputs { - let postings = if index >= 0 { - assert!(serialized_index.path_data[index as usize].is_some()); - &mut serialized_index.type_data[index as usize] - .as_mut() - .unwrap() - .inverted_function_inputs_index - } else { - let generic_id = usize::try_from(-index).unwrap() - 1; - for _ in serialized_index.generic_inverted_index.len()..=generic_id { - serialized_index.generic_inverted_index.push(Vec::new()); + + #[derive(Clone, Copy)] + enum InvertedIndexType { + Inputs, + Output, + } + impl InvertedIndexType { + fn from_type_data(self, type_data: &mut TypeData) -> &mut Vec> { + match self { + Self::Inputs => &mut type_data.inverted_function_inputs_index, + Self::Output => &mut type_data.inverted_function_output_index, } - &mut serialized_index.generic_inverted_index[generic_id] - }; - while postings.len() <= search_type_size { - postings.push(Vec::new()); - } - if postings[search_type_size].last() != Some(&(new_entry_id as u32)) { - postings[search_type_size].push(new_entry_id as u32); } } - for index in used_in_function_output { - let postings = if index >= 0 { - assert!(serialized_index.path_data[index as usize].is_some()); - &mut serialized_index.type_data[index as usize] - .as_mut() - .unwrap() - .inverted_function_output_index - } else { - let generic_id = usize::try_from(-index).unwrap() - 1; - for _ in serialized_index.generic_inverted_index.len()..=generic_id { - serialized_index.generic_inverted_index.push(Vec::new()); + + let mut process_used_in_function = + |used_in_function: BTreeSet, index_type: InvertedIndexType| { + for index in used_in_function { + let postings = if index >= 0 { + assert!(serialized_index.path_data[index as usize].is_some()); + index_type.from_type_data( + serialized_index.type_data[index as usize].as_mut().unwrap(), + ) + } else { + let generic_id = index.unsigned_abs() - 1; + if generic_id >= serialized_index.generic_inverted_index.len() { + serialized_index + .generic_inverted_index + .resize(generic_id + 1, Vec::new()); + } + &mut serialized_index.generic_inverted_index[generic_id] + }; + if search_type_size >= postings.len() { + postings.resize(search_type_size + 1, Vec::new()); + } + let posting = &mut postings[search_type_size]; + if posting.last() != Some(&(new_entry_id as u32)) { + posting.push(new_entry_id as u32); + } } - &mut serialized_index.generic_inverted_index[generic_id] }; - while postings.len() <= search_type_size { - postings.push(Vec::new()); - } - if postings[search_type_size].last() != Some(&(new_entry_id as u32)) { - postings[search_type_size].push(new_entry_id as u32); - } - } + + process_used_in_function(used_in_function_inputs, InvertedIndexType::Inputs); + process_used_in_function(used_in_function_output, InvertedIndexType::Output); } } From b976f647683ff09c442075bb0198450398d58171 Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Sun, 23 Nov 2025 19:06:50 +0200 Subject: [PATCH 192/194] `collect` into vectors --- src/librustdoc/html/render/search_index.rs | 49 ++++++++++++---------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index be5437395cb0..d9f50da91706 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -256,10 +256,14 @@ fn push( /// The returned ID can be used to attach more data to the search result. fn add_entry(&mut self, name: Symbol, entry_data: EntryData, desc: String) -> usize { let fqp = if let Some(module_path_index) = entry_data.module_path { - let mut fqp = self.path_data[module_path_index].as_ref().unwrap().module_path.clone(); - fqp.push(Symbol::intern(&self.names[module_path_index])); - fqp.push(name); - fqp + self.path_data[module_path_index] + .as_ref() + .unwrap() + .module_path + .iter() + .copied() + .chain([Symbol::intern(&self.names[module_path_index]), name]) + .collect() } else { vec![name] }; @@ -306,13 +310,13 @@ fn get_id_by_module_path(&mut self, path: &[Symbol]) -> usize { pub(crate) fn union(mut self, other: &SerializedSearchIndex) -> SerializedSearchIndex { let other_entryid_offset = self.names.len(); - let mut map_other_pathid_to_self_pathid: Vec = Vec::new(); + let mut map_other_pathid_to_self_pathid = Vec::new(); let mut skips = FxHashSet::default(); for (other_pathid, other_path_data) in other.path_data.iter().enumerate() { if let Some(other_path_data) = other_path_data { - let mut fqp = other_path_data.module_path.clone(); let name = Symbol::intern(&other.names[other_pathid]); - fqp.push(name); + let fqp = + other_path_data.module_path.iter().copied().chain(iter::once(name)).collect(); let self_pathid = other_entryid_offset + other_pathid; let self_pathid = match self.crate_paths_index.entry((other_path_data.ty, fqp)) { Entry::Vacant(slot) => { @@ -1819,20 +1823,23 @@ fn convert_render_type( tcx, ); } - let mut used_in_constraints = Vec::new(); - for constraint in &mut search_type.where_clause { - let mut used_in_constraint = BTreeSet::new(); - for trait_ in &mut constraint[..] { - convert_render_type( - trait_, - cache, - &mut serialized_index, - &mut used_in_constraint, - tcx, - ); - } - used_in_constraints.push(used_in_constraint); - } + let used_in_constraints = search_type + .where_clause + .iter_mut() + .map(|constraint| { + let mut used_in_constraint = BTreeSet::new(); + for trait_ in constraint { + convert_render_type( + trait_, + cache, + &mut serialized_index, + &mut used_in_constraint, + tcx, + ); + } + used_in_constraint + }) + .collect::>(); loop { let mut inserted_any = false; for (i, used_in_constraint) in used_in_constraints.iter().enumerate() { From 2a34631ab6d92211a5e92e26f95b4b4689c7c833 Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Sun, 23 Nov 2025 19:46:52 +0200 Subject: [PATCH 193/194] `simplify_fn_type` can only ever return 0 or 1 types, doesn't need to take `&mut Vec` --- src/librustdoc/html/render/search_index.rs | 354 +++++++++------------ 1 file changed, 143 insertions(+), 211 deletions(-) diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index d9f50da91706..da6840c72f5b 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -2059,22 +2059,21 @@ enum SimplifiedParam { /// not be added to the map. /// /// This function also works recursively. -#[instrument(level = "trace", skip(tcx, res, rgen, cache))] +#[instrument(level = "trace", skip(tcx, rgen, cache))] fn simplify_fn_type<'a, 'tcx>( self_: Option<&'a Type>, generics: &Generics, arg: &'a Type, tcx: TyCtxt<'tcx>, recurse: usize, - res: &mut Vec, rgen: &mut FxIndexMap)>, is_return: bool, cache: &Cache, -) { +) -> Option { if recurse >= 10 { // FIXME: remove this whole recurse thing when the recursion bug is fixed // See #59502 for the original issue. - return; + return None; } // First, check if it's "Self". @@ -2091,179 +2090,120 @@ fn simplify_fn_type<'a, 'tcx>( match *arg { Type::Generic(arg_s) => { // First we check if the bounds are in a `where` predicate... - let mut type_bounds = Vec::new(); - for where_pred in generics.where_predicates.iter().filter(|g| match g { - WherePredicate::BoundPredicate { ty, .. } => *ty == *arg, - _ => false, - }) { - let bounds = where_pred.get_bounds().unwrap_or(&[]); - for bound in bounds.iter() { - if let Some(path) = bound.get_trait_path() { - let ty = Type::Path { path }; - simplify_fn_type( - self_, - generics, - &ty, - tcx, - recurse + 1, - &mut type_bounds, - rgen, - is_return, - cache, - ); + let where_bounds = generics + .where_predicates + .iter() + .filter_map(|g| { + if let WherePredicate::BoundPredicate { ty, bounds, .. } = g + && *ty == *arg + { + Some(bounds) + } else { + None } - } - } + }) + .flatten(); // Otherwise we check if the trait bounds are "inlined" like `T: Option`... - if let Some(bound) = generics.params.iter().find(|g| g.is_type() && g.name == arg_s) { - for bound in bound.get_bounds().unwrap_or(&[]) { - if let Some(path) = bound.get_trait_path() { - let ty = Type::Path { path }; - simplify_fn_type( - self_, - generics, - &ty, - tcx, - recurse + 1, - &mut type_bounds, - rgen, - is_return, - cache, - ); - } - } - } - if let Some((idx, _)) = rgen.get(&SimplifiedParam::Symbol(arg_s)) { - res.push(RenderType { - id: Some(RenderTypeId::Index(*idx)), - generics: None, - bindings: None, - }); + let inline_bounds = generics + .params + .iter() + .find(|g| g.is_type() && g.name == arg_s) + .and_then(|bound| bound.get_bounds()) + .into_iter() + .flatten(); + + let type_bounds = where_bounds + .chain(inline_bounds) + .filter_map( + |bound| if let Some(path) = bound.get_trait_path() { Some(path) } else { None }, + ) + .filter_map(|path| { + let ty = Type::Path { path }; + simplify_fn_type(self_, generics, &ty, tcx, recurse + 1, rgen, is_return, cache) + }) + .collect(); + + Some(if let Some((idx, _)) = rgen.get(&SimplifiedParam::Symbol(arg_s)) { + RenderType { id: Some(RenderTypeId::Index(*idx)), generics: None, bindings: None } } else { let idx = -isize::try_from(rgen.len() + 1).unwrap(); rgen.insert(SimplifiedParam::Symbol(arg_s), (idx, type_bounds)); - res.push(RenderType { - id: Some(RenderTypeId::Index(idx)), - generics: None, - bindings: None, - }); - } + RenderType { id: Some(RenderTypeId::Index(idx)), generics: None, bindings: None } + }) } Type::ImplTrait(ref bounds) => { - let mut type_bounds = Vec::new(); - for bound in bounds { - if let Some(path) = bound.get_trait_path() { + let type_bounds = bounds + .iter() + .filter_map(|bound| bound.get_trait_path()) + .filter_map(|path| { let ty = Type::Path { path }; - simplify_fn_type( - self_, - generics, - &ty, - tcx, - recurse + 1, - &mut type_bounds, - rgen, - is_return, - cache, - ); - } - } - if is_return && !type_bounds.is_empty() { + simplify_fn_type(self_, generics, &ty, tcx, recurse + 1, rgen, is_return, cache) + }) + .collect::>(); + Some(if is_return && !type_bounds.is_empty() { // In return position, `impl Trait` is a unique thing. - res.push(RenderType { id: None, generics: Some(type_bounds), bindings: None }); + RenderType { id: None, generics: Some(type_bounds), bindings: None } } else { // In parameter position, `impl Trait` is the same as an unnamed generic parameter. let idx = -isize::try_from(rgen.len() + 1).unwrap(); rgen.insert(SimplifiedParam::Anonymous(idx), (idx, type_bounds)); - res.push(RenderType { - id: Some(RenderTypeId::Index(idx)), - generics: None, - bindings: None, - }); - } + RenderType { id: Some(RenderTypeId::Index(idx)), generics: None, bindings: None } + }) } Type::Slice(ref ty) => { - let mut ty_generics = Vec::new(); - simplify_fn_type( - self_, - generics, - ty, - tcx, - recurse + 1, - &mut ty_generics, - rgen, - is_return, - cache, - ); - res.push(get_index_type(arg, ty_generics, rgen)); + let ty_generics = + simplify_fn_type(self_, generics, ty, tcx, recurse + 1, rgen, is_return, cache) + .into_iter() + .collect(); + Some(get_index_type(arg, ty_generics, rgen)) } Type::Array(ref ty, _) => { - let mut ty_generics = Vec::new(); - simplify_fn_type( - self_, - generics, - ty, - tcx, - recurse + 1, - &mut ty_generics, - rgen, - is_return, - cache, - ); - res.push(get_index_type(arg, ty_generics, rgen)); + let ty_generics = + simplify_fn_type(self_, generics, ty, tcx, recurse + 1, rgen, is_return, cache) + .into_iter() + .collect(); + Some(get_index_type(arg, ty_generics, rgen)) } Type::Tuple(ref tys) => { - let mut ty_generics = Vec::new(); - for ty in tys { - simplify_fn_type( - self_, - generics, - ty, - tcx, - recurse + 1, - &mut ty_generics, - rgen, - is_return, - cache, - ); - } - res.push(get_index_type(arg, ty_generics, rgen)); + let ty_generics = tys + .iter() + .filter_map(|ty| { + simplify_fn_type(self_, generics, ty, tcx, recurse + 1, rgen, is_return, cache) + }) + .collect(); + Some(get_index_type(arg, ty_generics, rgen)) } Type::BareFunction(ref bf) => { - let mut ty_generics = Vec::new(); - for ty in bf.decl.inputs.iter().map(|arg| &arg.type_) { - simplify_fn_type( - self_, - generics, - ty, - tcx, - recurse + 1, - &mut ty_generics, - rgen, - is_return, - cache, - ); - } + let ty_generics = bf + .decl + .inputs + .iter() + .map(|arg| &arg.type_) + .filter_map(|ty| { + simplify_fn_type(self_, generics, ty, tcx, recurse + 1, rgen, is_return, cache) + }) + .collect(); // The search index, for simplicity's sake, represents fn pointers and closures // the same way: as a tuple for the parameters, and an associated type for the // return type. - let mut ty_output = Vec::new(); - simplify_fn_type( + let ty_output = simplify_fn_type( self_, generics, &bf.decl.output, tcx, recurse + 1, - &mut ty_output, rgen, is_return, cache, - ); + ) + .into_iter() + .collect(); let ty_bindings = vec![(RenderTypeId::AssociatedType(sym::Output), ty_output)]; - res.push(RenderType { + Some(RenderType { id: get_index_type_id(arg, rgen), bindings: Some(ty_bindings), generics: Some(ty_generics), - }); + }) } Type::BorrowedRef { lifetime: _, mutability, ref type_ } | Type::RawPointer(mutability, ref type_) => { @@ -2275,18 +2215,12 @@ fn simplify_fn_type<'a, 'tcx>( bindings: None, }); } - simplify_fn_type( - self_, - generics, - type_, - tcx, - recurse + 1, - &mut ty_generics, - rgen, - is_return, - cache, - ); - res.push(get_index_type(arg, ty_generics, rgen)); + if let Some(ty) = + simplify_fn_type(self_, generics, type_, tcx, recurse + 1, rgen, is_return, cache) + { + ty_generics.push(ty); + } + Some(get_index_type(arg, ty_generics, rgen)) } _ => { // This is not a type parameter. So for example if we have `T, U: Option`, and we're @@ -2297,22 +2231,25 @@ fn simplify_fn_type<'a, 'tcx>( let mut ty_generics = Vec::new(); let mut ty_constraints = Vec::new(); if let Some(arg_generics) = arg.generic_args() { - for ty in arg_generics.into_iter().filter_map(|param| match param { - clean::GenericArg::Type(ty) => Some(ty), - _ => None, - }) { - simplify_fn_type( - self_, - generics, - &ty, - tcx, - recurse + 1, - &mut ty_generics, - rgen, - is_return, - cache, - ); - } + ty_generics = arg_generics + .into_iter() + .filter_map(|param| match param { + clean::GenericArg::Type(ty) => Some(ty), + _ => None, + }) + .filter_map(|ty| { + simplify_fn_type( + self_, + generics, + &ty, + tcx, + recurse + 1, + rgen, + is_return, + cache, + ) + }) + .collect(); for constraint in arg_generics.constraints() { simplify_fn_constraint( self_, @@ -2359,9 +2296,10 @@ fn simplify_fn_type<'a, 'tcx>( // Can't just pass stored_bounds to simplify_fn_type, // because it also accepts rgen as a parameter. // Instead, have it fill in this local, then copy it into the map afterward. - let mut type_bounds = Vec::new(); - for bound in bounds { - if let Some(path) = bound.get_trait_path() { + let type_bounds = bounds + .iter() + .filter_map(|bound| bound.get_trait_path()) + .filter_map(|path| { let ty = Type::Path { path }; simplify_fn_type( self_, @@ -2369,13 +2307,12 @@ fn simplify_fn_type<'a, 'tcx>( &ty, tcx, recurse + 1, - &mut type_bounds, rgen, is_return, cache, - ); - } - } + ) + }) + .collect(); let stored_bounds = &mut rgen .get_mut(&SimplifiedParam::AssociatedType(def_id, name)) .unwrap() @@ -2397,11 +2334,13 @@ fn simplify_fn_type<'a, 'tcx>( } let id = get_index_type_id(arg, rgen); if id.is_some() || !ty_generics.is_empty() { - res.push(RenderType { + Some(RenderType { id, bindings: if ty_constraints.is_empty() { None } else { Some(ty_constraints) }, generics: if ty_generics.is_empty() { None } else { Some(ty_generics) }, - }); + }) + } else { + None } } } @@ -2422,17 +2361,18 @@ fn simplify_fn_constraint<'a>( let ty_constrained_assoc = RenderTypeId::AssociatedType(constraint.assoc.name); for param in &constraint.assoc.args { match param { - clean::GenericArg::Type(arg) => simplify_fn_type( - self_, - generics, - &arg, - tcx, - recurse + 1, - &mut ty_constraints, - rgen, - is_return, - cache, - ), + clean::GenericArg::Type(arg) => { + ty_constraints.extend(simplify_fn_type( + self_, + generics, + &arg, + tcx, + recurse + 1, + rgen, + is_return, + cache, + )); + } clean::GenericArg::Lifetime(_) | clean::GenericArg::Const(_) | clean::GenericArg::Infer => {} @@ -2454,34 +2394,32 @@ fn simplify_fn_constraint<'a>( match &constraint.kind { clean::AssocItemConstraintKind::Equality { term } => { if let clean::Term::Type(arg) = &term { - simplify_fn_type( + ty_constraints.extend(simplify_fn_type( self_, generics, arg, tcx, recurse + 1, - &mut ty_constraints, rgen, is_return, cache, - ); + )); } } clean::AssocItemConstraintKind::Bound { bounds } => { for bound in &bounds[..] { if let Some(path) = bound.get_trait_path() { let ty = Type::Path { path }; - simplify_fn_type( + ty_constraints.extend(simplify_fn_type( self_, generics, &ty, tcx, recurse + 1, - &mut ty_constraints, rgen, is_return, cache, - ); + )); } } } @@ -2537,23 +2475,17 @@ fn get_fn_inputs_and_outputs( (None, &func.generics) }; - let mut param_types = Vec::new(); - for param in decl.inputs.iter() { - simplify_fn_type( - self_, - generics, - ¶m.type_, - tcx, - 0, - &mut param_types, - &mut rgen, - false, - cache, - ); - } + let param_types = decl + .inputs + .iter() + .filter_map(|param| { + simplify_fn_type(self_, generics, ¶m.type_, tcx, 0, &mut rgen, false, cache) + }) + .collect(); - let mut ret_types = Vec::new(); - simplify_fn_type(self_, generics, &decl.output, tcx, 0, &mut ret_types, &mut rgen, true, cache); + let ret_types = simplify_fn_type(self_, generics, &decl.output, tcx, 0, &mut rgen, true, cache) + .into_iter() + .collect(); let mut simplified_params = rgen.into_iter().collect::>(); simplified_params.sort_by_key(|(_, (idx, _))| -idx); From 8c5f7a3b7e06e5116992f488e9751c29b549fb4b Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Thu, 27 Nov 2025 04:08:44 +0000 Subject: [PATCH 194/194] Prepare for merging from rust-lang/rust This updates the rust-version file to 1be6b13be73dc12e98e51b403add4c41a0b77759. --- src/tools/rust-analyzer/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/rust-version b/src/tools/rust-analyzer/rust-version index f545ef4d2b85..bddb68a06b02 100644 --- a/src/tools/rust-analyzer/rust-version +++ b/src/tools/rust-analyzer/rust-version @@ -1 +1 @@ -6159a44067ebce42b38f062cc7df267a1348e092 +1be6b13be73dc12e98e51b403add4c41a0b77759