From d1d3354829972a90711999e171b571b9e2960a5b Mon Sep 17 00:00:00 2001 From: Narfinger Date: Wed, 26 Aug 2026 10:59:46 +0200 Subject: [PATCH 01/11] update docs to be more precise Signed-off-by: Narfinger --- library/core/src/str/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 79f4f29da2d43..e0e44cc906360 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -2917,7 +2917,7 @@ impl str { /// Converts this string to its ASCII upper case equivalent in-place. /// /// ASCII letters 'a' to 'z' are mapped to 'A' to 'Z', - /// but non-ASCII letters are unchanged. + /// but all other characters are unchanged. /// /// To return a new uppercased value without modifying the existing one, use /// [`to_ascii_uppercase()`]. @@ -2945,7 +2945,7 @@ impl str { /// Converts this string to its ASCII lower case equivalent in-place. /// /// ASCII letters 'A' to 'Z' are mapped to 'a' to 'z', - /// but non-ASCII letters are unchanged. + /// but all other characters are unchanged. /// /// To return a new lowercased value without modifying the existing one, use /// [`to_ascii_lowercase()`]. From 167c7bde3f0ce438db1ff569a21349c416c86937 Mon Sep 17 00:00:00 2001 From: beetrees Date: Tue, 25 Aug 2026 18:26:24 +0100 Subject: [PATCH 02/11] Add Natvis visualiser and debuginfo tests for `f128` --- .../src/debuginfo/metadata.rs | 101 ++++++++-------- src/etc/lldb_lookup.py | 17 +++ src/etc/lldb_providers.py | 6 + src/etc/natvis/intrinsic.natvis | 112 ++++++++++++++++++ .../debuginfo/basic-types-globals-metadata.rs | 11 +- tests/debuginfo/basic-types-globals.rs | 24 +++- tests/debuginfo/basic-types-metadata.rs | 5 +- tests/debuginfo/basic-types-mut-globals.rs | 96 +++++++++++++-- tests/debuginfo/basic-types/main.rs | 13 +- tests/debuginfo/borrowed-basic.rs | 17 ++- tests/debuginfo/borrowed-unique-basic.rs | 17 ++- tests/debuginfo/f128-natvis.rs | 92 ++++++++++++++ tests/debuginfo/reference-debuginfo.rs | 18 ++- 13 files changed, 449 insertions(+), 80 deletions(-) create mode 100644 tests/debuginfo/f128-natvis.rs diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 54bdfb5f442d9..53fe51e382e4e 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use std::{assert_matches, iter, ptr}; use libc::{c_longlong, c_uint}; -use rustc_abi::{Align, Layout, NumScalableVectors, Size}; +use rustc_abi::{Align, Endian, Layout, NumScalableVectors, Size}; use rustc_codegen_ssa::debuginfo::type_names::{VTableNameKind, cpp_like_debuginfo}; use rustc_codegen_ssa::traits::*; use rustc_hir::def::{CtorKind, DefKind}; @@ -20,7 +20,7 @@ use rustc_middle::ty::{ use rustc_session::config::{self, DebugInfo, Lto}; use rustc_span::{DUMMY_SP, FileName, RemapPathScopeComponents, SourceFile, Span, Symbol, hygiene}; use rustc_symbol_mangling::typeid_for_trait_ref; -use rustc_target::spec::{Arch, DebuginfoKind}; +use rustc_target::spec::{Arch, DebuginfoKind, HasTargetSpec}; use smallvec::smallvec; use tracing::{debug, instrument}; @@ -692,33 +692,22 @@ impl MsvcBasicName for ty::UintTy { } } -impl MsvcBasicName for ty::FloatTy { - fn msvc_basic_name(self) -> &'static str { - // FIXME(f128): `f128` has no MSVC representation. We could improve the debuginfo. - // See: - match self { - ty::FloatTy::F16 => { - bug!("`f16` should have been handled in `build_basic_type_di_node`") - } - ty::FloatTy::F32 => "float", - ty::FloatTy::F64 => "double", - ty::FloatTy::F128 => "fp128", - } - } -} - -fn build_cpp_f16_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) -> DINodeCreationResult<'ll> { - // MSVC has no native support for `f16`. Instead, emit `struct f16 { bits: u16 }` to allow the - // `f16`'s value to be displayed using a Natvis visualiser in `intrinsic.natvis`. - let float_ty = cx.tcx.types.f16; - let bits_ty = cx.tcx.types.u16; - let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers { - match float_ty.kind() { - ty::Adt(def, _) => Some(file_metadata_from_def_id(cx, Some(def.did()))), - _ => None, - } +/// `float_ty` must be a [`ty::Float`] and `bits_ty` must be a [`ty::Uint`]. +/// `cx.size_of(bits_ty) * bits_names.len()` must equal `cx.size_of(float_ty)`. +fn build_cpp_float_struct_di_node<'ll, 'tcx>( + cx: &CodegenCx<'ll, 'tcx>, + float_ty: Ty<'tcx>, + bits_ty: Ty<'tcx>, + bits_names: &[&str], +) -> DINodeCreationResult<'ll> { + debug_assert!(matches!(bits_ty.kind(), ty::Uint(_))); + debug_assert_eq!(cx.size_of(bits_ty) * (bits_names.len() as u64), cx.size_of(float_ty)); + // MSVC has no native support for `f16` or `f128`. Instead, emit a struct containing the bits as + // field(s) to allow the value to be displayed using a Natvis visualiser in `intrinsic.natvis`. + let name = if let ty::Float(f) = float_ty.kind() { + f.name_str() } else { - None + bug!("{float_ty:?} was not a float"); }; type_map::build_type_with_children( cx, @@ -726,32 +715,33 @@ fn build_cpp_f16_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) -> DINodeCreation cx, Stub::Struct, UniqueTypeId::for_ty(cx.tcx, float_ty), - "f16", - def_location, + name, + None, cx.size_and_align_of(float_ty), NO_SCOPE_METADATA, DIFlags::FlagZero, ), // Fields: |cx, float_di_node| { - let def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers { - match bits_ty.kind() { - ty::Adt(def, _) => Some(def.did()), - _ => None, - } - } else { - None - }; - smallvec![build_field_di_node( - cx, - float_di_node, - "bits", - cx.layout_of(bits_ty), - Size::ZERO, - DIFlags::FlagZero, - type_di_node(cx, bits_ty), - def_id, - )] + let bits_layout = cx.layout_of(bits_ty); + let bits_node = type_di_node(cx, bits_ty); + bits_names + .iter() + .copied() + .enumerate() + .map(|(i, field_name)| { + build_field_di_node( + cx, + float_di_node, + field_name, + bits_layout, + bits_layout.size * (i as u64), + DIFlags::FlagZero, + bits_node, + None, + ) + }) + .collect() }, NO_GENERICS, ) @@ -783,9 +773,20 @@ fn build_basic_type_di_node<'ll, 'tcx>( ty::Int(int_ty) if cpp_like_debuginfo => (int_ty.msvc_basic_name(), DW_ATE_signed), ty::Uint(uint_ty) if cpp_like_debuginfo => (uint_ty.msvc_basic_name(), DW_ATE_unsigned), ty::Float(ty::FloatTy::F16) if cpp_like_debuginfo => { - return build_cpp_f16_di_node(cx); + return build_cpp_float_struct_di_node(cx, t, cx.tcx.types.u16, &["bits"]); + } + ty::Float(ty::FloatTy::F128) if cpp_like_debuginfo => { + // All MSVC architectures are little endian. + assert_eq!(cx.target_spec().endian, Endian::Little); + return build_cpp_float_struct_di_node( + cx, + t, + cx.tcx.types.u64, + &["low_bits", "high_bits"], + ); } - ty::Float(float_ty) if cpp_like_debuginfo => (float_ty.msvc_basic_name(), DW_ATE_float), + ty::Float(ty::FloatTy::F32) if cpp_like_debuginfo => ("float", DW_ATE_float), + ty::Float(ty::FloatTy::F64) if cpp_like_debuginfo => ("double", DW_ATE_float), ty::Int(int_ty) => (int_ty.name_str(), DW_ATE_signed), ty::Uint(uint_ty) => (uint_ty.name_str(), DW_ATE_unsigned), ty::Float(float_ty) => (float_ty.name_str(), DW_ATE_float), diff --git a/src/etc/lldb_lookup.py b/src/etc/lldb_lookup.py index 365816dc8489a..94ed47af1891f 100644 --- a/src/etc/lldb_lookup.py +++ b/src/etc/lldb_lookup.py @@ -40,6 +40,7 @@ ClangEncodedEnumSummaryProvider, StructSummaryProvider, f16SummaryProvider, + f128SummaryProvider, # re-exports get_template_args as get_template_args, resolve_msvc_template_arg as resolve_msvc_template_arg, @@ -181,6 +182,17 @@ def register_providers_compatibility(): DEFAULT_TYPE_OPTIONS | lldb.eTypeOptionHideChildren, ) + if LLDBFeature.Float128 in FEATURE_FLAGS: + # Force f128 summary on windows-msvc since most Windows debuggers don't support PDB f128 + register_summary( + f128SummaryProvider, + lldb.SBTypeNameSpecifier( + MOD_PREFIX + is_msvc_f128.__name__, + lldb.eFormatterMatchCallback, + ), + DEFAULT_TYPE_OPTIONS | lldb.eTypeOptionHideChildren, + ) + # Tuple-structs register_synth( TupleSyntheticProvider, @@ -501,6 +513,11 @@ def is_msvc_f16(type: lldb.SBType, _dict: LLDBOpaque) -> bool: return type.GetName() == "f16" and type.IsAggregateType() +def is_msvc_f128(type: lldb.SBType, _dict: LLDBOpaque) -> bool: + # Most Windows debuggers don't support PDB f128. + return type.GetName() == "f128" and type.IsAggregateType() + + def classify_rust_type(type: lldb.SBType, is_msvc: bool) -> RustType: if type.IsPointerType(): return RustType.Indirection diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 2791dae3600b0..a3a424ac1abce 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -542,6 +542,12 @@ def f16SummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: ) +def f128SummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: + from lldb import eBasicTypeFloat128 + + return valobj.Cast(valobj.GetTarget().GetBasicType(eBasicTypeFloat128)).GetValue() + + def sequence_formatter(output: str, valobj: SBValue, _dict: LLDBOpaque): length: int = valobj.GetNumChildren() diff --git a/src/etc/natvis/intrinsic.natvis b/src/etc/natvis/intrinsic.natvis index 49e0ce319efac..ac9bf1c427957 100644 --- a/src/etc/natvis/intrinsic.natvis +++ b/src/etc/natvis/intrinsic.natvis @@ -59,6 +59,118 @@ {(float) (sign() * (raw_significand() + 1.0) * two_pow_exponent())} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {sign()}inf + NaN + + {sign()}0x0p+0 + + {sign()}0x1{subnormal_hex()}p{-16382 - subnormal_shift(),d} + {sign()}0x1{normal_hex()}p{normal_exponent_sign()}{normal_exponent(),d} + + + "0x" + hex128(high_bits, low_bits, 128) + + () diff --git a/tests/debuginfo/basic-types-globals-metadata.rs b/tests/debuginfo/basic-types-globals-metadata.rs index 3f1d9fd5de278..306c8978a508e 100644 --- a/tests/debuginfo/basic-types-globals-metadata.rs +++ b/tests/debuginfo/basic-types-globals-metadata.rs @@ -33,11 +33,13 @@ //@ gdb-check:type = f32 //@ gdb-command:whatis basic_types_globals_metadata::F64 //@ gdb-check:type = f64 +//@ gdb-command:whatis basic_types_globals_metadata::F128 +//@ gdb-check:type = f128 //@ gdb-command:continue #![allow(unused_variables)] #![allow(dead_code)] -#![feature(f16)] +#![feature(f16, f128)] // N.B. These are `mut` only so they don't constant fold away. static mut B: bool = false; @@ -55,13 +57,14 @@ static mut U64: u64 = 64; static mut F16: f16 = 1.5; static mut F32: f32 = 2.5; static mut F64: f64 = 3.5; +static mut F128: f128 = 4.5; fn main() { _zzz(); // #break - let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64) }; - // FIXME: Including f16 and f32 in the same tuple emits `__gnu_h2f_ieee`, which - // does not exist on some targets like PowerPC. + let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64, F128) }; + // FIXME(f16): Including f16 and f32 in the same tuple emits `__gnu_h2f_ieee`, which + // does not exist on some targets like PowerPC (fixed in llvm22). // See https://github.com/llvm/llvm-project/issues/97981 and // https://github.com/rust-lang/compiler-builtins/issues/655 let b = unsafe { F16 }; diff --git a/tests/debuginfo/basic-types-globals.rs b/tests/debuginfo/basic-types-globals.rs index 044b757aaf470..3bc9d3becdade 100644 --- a/tests/debuginfo/basic-types-globals.rs +++ b/tests/debuginfo/basic-types-globals.rs @@ -1,11 +1,20 @@ -//@ revisions: lto no-lto +//@ revisions: lto no-lto lto-apple no-lto-apple //@ compile-flags:-g --crate-name=basic_types_globals //@ disable-gdb-pretty-printers +// FIXME(f128): Merge `-apple` revisions once Apple releases Xcode with LLVM 22. +//@ [lto] ignore-apple +//@ [no-lto] ignore-apple +//@ [lto-apple] only-apple +//@ [no-lto-apple] only-apple //@ [lto] compile-flags:-C lto //@ [lto] no-prefer-dynamic +//@ [lto-apple] compile-flags:-C lto +//@ [lto-apple] no-prefer-dynamic //@ ignore-backends: gcc +// `f128` support was added to `lldb` in version 22. +//@ min-llvm-lldb-version: 22 //@ lldb-command:run //@ lldb-command:v basic_types_globals::B @@ -38,6 +47,9 @@ //@ lldb-check:[...]basic_types_globals::F32 = 2.5 //@ lldb-command:v basic_types_globals::F64 //@ lldb-check:[...]basic_types_globals::F64 = 3.5 +//@ lldb-command:v basic_types_globals::F128 +//@[no-lto] lldb-check:[...]basic_types_globals::F128 = 4.5 +//@[lto] lldb-check:[...]basic_types_globals::F128 = 4.5 //@ gdb-command:run //@ gdb-command:print B @@ -70,10 +82,11 @@ //@ gdb-check:$14 = 2.5 //@ gdb-command:print F64 //@ gdb-check:$15 = 3.5 +// FIXME(f128): gdb doesn't support Rust `f128` yet. //@ gdb-command:continue #![allow(unused_variables)] -#![feature(f16)] +#![feature(f16, f128)] // N.B. These are `mut` only so they don't constant fold away. static mut B: bool = false; @@ -91,13 +104,14 @@ static mut U64: u64 = 64; static mut F16: f16 = 1.5; static mut F32: f32 = 2.5; static mut F64: f64 = 3.5; +static mut F128: f128 = 4.5; fn main() { _zzz(); // #break - let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64) }; - // FIXME: Including f16 and f32 in the same tuple emits `__gnu_h2f_ieee`, which - // does not exist on some targets like PowerPC. + let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64, F128) }; + // FIXME(f16): Including f16 and f32 in the same tuple emits `__gnu_h2f_ieee`, which + // does not exist on some targets like PowerPC (fixed in llvm22). // See https://github.com/llvm/llvm-project/issues/97981 and // https://github.com/rust-lang/compiler-builtins/issues/655 let b = unsafe { F16 }; diff --git a/tests/debuginfo/basic-types-metadata.rs b/tests/debuginfo/basic-types-metadata.rs index d3a3d03ef7424..39fa9150214b5 100644 --- a/tests/debuginfo/basic-types-metadata.rs +++ b/tests/debuginfo/basic-types-metadata.rs @@ -35,6 +35,8 @@ //@ gdb-check:type = f32 //@ gdb-command:whatis f64 //@ gdb-check:type = f64 +//@ gdb-command:whatis f128 +//@ gdb-check:type = f128 //@ gdb-command:whatis fnptr //@ gdb-check:type = *mut fn () //@ gdb-command:info functions _yyy @@ -54,7 +56,7 @@ //@ gdb-command:continue #![allow(unused_variables)] -#![feature(f16)] +#![feature(f16, f128)] fn main() { let unit: () = (); @@ -73,6 +75,7 @@ fn main() { let f16: f16 = 1.5; let f32: f32 = 2.5; let f64: f64 = 3.5; + let f128: f128 = 4.5; let fnptr : fn() = _zzz; let closure_0 = || {}; let closure_1 = || { b; }; diff --git a/tests/debuginfo/basic-types-mut-globals.rs b/tests/debuginfo/basic-types-mut-globals.rs index c3cc7be549d47..3f59da2a5d2e0 100644 --- a/tests/debuginfo/basic-types-mut-globals.rs +++ b/tests/debuginfo/basic-types-mut-globals.rs @@ -1,13 +1,14 @@ -// Caveats - gdb prints any 8-bit value (meaning rust I8 and u8 values) -// as its numerical value along with its associated ASCII char, there -// doesn't seem to be any way around this. Also, gdb doesn't know -// about UTF-32 character encoding and will print a rust char as only -// its numerical value. - -//@ compile-flags:-g +//@ compile-flags:-g --crate-name=basic_types_mut_globals //@ disable-gdb-pretty-printers //@ ignore-backends: gcc +// FIXME(f128): Merge `apple` revision once Apple releases Xcode with LLVM 22. +//@ revisions: not-apple apple +//@[not-apple] ignore-apple +//@[apple] only-apple +// `f128` support was added to `lldb` in version 22. +//@ min-llvm-lldb-version: 22 + //@ gdb-command:run // Check initializers @@ -41,6 +42,7 @@ //@ gdb-check:$14 = 2.5 //@ gdb-command:print F64 //@ gdb-check:$15 = 3.5 +// FIXME(f128): gdb doesn't support Rust `f128` yet. //@ gdb-command:continue // Check new values @@ -50,7 +52,7 @@ //@ gdb-check:$17 = 2 //@ gdb-command:print C //@ gdb-check:$18 = 102 'f' -//@ gdb-command:print/d I8 +//@ gdb-command:print I8 //@ gdb-check:$19 = 78 //@ gdb-command:print I16 //@ gdb-check:$20 = -26 @@ -60,7 +62,7 @@ //@ gdb-check:$22 = -54 //@ gdb-command:print U //@ gdb-check:$23 = 5 -//@ gdb-command:print/d U8 +//@ gdb-command:print U8 //@ gdb-check:$24 = 20 //@ gdb-command:print U16 //@ gdb-check:$25 = 32 @@ -74,9 +76,81 @@ //@ gdb-check:$29 = 5.75 //@ gdb-command:print F64 //@ gdb-check:$30 = 9.25 +// FIXME(f128): gdb doesn't support Rust `f128` yet. + +//@ lldb-command:run + +// Check initializers +//@ lldb-command:v basic_types_mut_globals::B +//@ lldb-check:[...]basic_types_mut_globals::B = false +//@ lldb-command:v basic_types_mut_globals::I +//@ lldb-check:[...]basic_types_mut_globals::I = -1 +//@ lldb-command:v basic_types_mut_globals::C +//@ lldb-check:[...]basic_types_mut_globals::C = U+0x00000061 U'a' +//@ lldb-command:v/d basic_types_mut_globals::I8 +//@ lldb-check:[...]basic_types_mut_globals::I8 = 68 +//@ lldb-command:v basic_types_mut_globals::I16 +//@ lldb-check:[...]basic_types_mut_globals::I16 = -16 +//@ lldb-command:v basic_types_mut_globals::I32 +//@ lldb-check:[...]basic_types_mut_globals::I32 = -32 +//@ lldb-command:v basic_types_mut_globals::I64 +//@ lldb-check:[...]basic_types_mut_globals::I64 = -64 +//@ lldb-command:v basic_types_mut_globals::U +//@ lldb-check:[...]basic_types_mut_globals::U = 1 +//@ lldb-command:v/d basic_types_mut_globals::U8 +//@ lldb-check:[...]basic_types_mut_globals::U8 = 100 +//@ lldb-command:v basic_types_mut_globals::U16 +//@ lldb-check:[...]basic_types_mut_globals::U16 = 16 +//@ lldb-command:v basic_types_mut_globals::U32 +//@ lldb-check:[...]basic_types_mut_globals::U32 = 32 +//@ lldb-command:v basic_types_mut_globals::U64 +//@ lldb-check:[...]basic_types_mut_globals::U64 = 64 +//@ lldb-command:v basic_types_mut_globals::F16 +//@ lldb-check:[...]basic_types_mut_globals::F16 = 1.5 +//@ lldb-command:v basic_types_mut_globals::F32 +//@ lldb-check:[...]basic_types_mut_globals::F32 = 2.5 +//@ lldb-command:v basic_types_mut_globals::F64 +//@ lldb-check:[...]basic_types_mut_globals::F64 = 3.5 +//@ lldb-command:v basic_types_mut_globals::F128 +//@[not-apple] lldb-check:[...]basic_types_mut_globals::F128 = 4.5 +//@ lldb-command:continue + +// Check new values +//@ lldb-command:v basic_types_mut_globals::B +//@ lldb-check:[...]basic_types_mut_globals::B = true +//@ lldb-command:v basic_types_mut_globals::I +//@ lldb-check:[...]basic_types_mut_globals::I = 2 +//@ lldb-command:v basic_types_mut_globals::C +//@ lldb-check:[...]basic_types_mut_globals::C = U+0x00000066 U'f' +//@ lldb-command:v/d basic_types_mut_globals::I8 +//@ lldb-check:[...]basic_types_mut_globals::I8 = 78 +//@ lldb-command:v basic_types_mut_globals::I16 +//@ lldb-check:[...]basic_types_mut_globals::I16 = -26 +//@ lldb-command:v basic_types_mut_globals::I32 +//@ lldb-check:[...]basic_types_mut_globals::I32 = -12 +//@ lldb-command:v basic_types_mut_globals::I64 +//@ lldb-check:[...]basic_types_mut_globals::I64 = -54 +//@ lldb-command:v basic_types_mut_globals::U +//@ lldb-check:[...]basic_types_mut_globals::U = 5 +//@ lldb-command:v/d basic_types_mut_globals::U8 +//@ lldb-check:[...]basic_types_mut_globals::U8 = 20 +//@ lldb-command:v basic_types_mut_globals::U16 +//@ lldb-check:[...]basic_types_mut_globals::U16 = 32 +//@ lldb-command:v basic_types_mut_globals::U32 +//@ lldb-check:[...]basic_types_mut_globals::U32 = 16 +//@ lldb-command:v basic_types_mut_globals::U64 +//@ lldb-check:[...]basic_types_mut_globals::U64 = 128 +//@ lldb-command:v basic_types_mut_globals::F16 +//@ lldb-check:[...]basic_types_mut_globals::F16 = 2.25 +//@ lldb-command:v basic_types_mut_globals::F32 +//@ lldb-check:[...]basic_types_mut_globals::F32 = 5.75 +//@ lldb-command:v basic_types_mut_globals::F64 +//@ lldb-check:[...]basic_types_mut_globals::F64 = 9.25 +//@ lldb-command:v basic_types_mut_globals::F128 +//@[not-apple] lldb-check:[...]basic_types_mut_globals::F128 = 12.75 #![allow(unused_variables)] -#![feature(f16)] +#![feature(f16, f128)] static mut B: bool = false; static mut I: isize = -1; @@ -93,6 +167,7 @@ static mut U64: u64 = 64; static mut F16: f16 = 1.5; static mut F32: f32 = 2.5; static mut F64: f64 = 3.5; +static mut F128: f128 = 4.5; fn main() { _zzz(); // #break @@ -113,6 +188,7 @@ fn main() { F16 = 2.25; F32 = 5.75; F64 = 9.25; + F128 = 12.75; } _zzz(); // #break diff --git a/tests/debuginfo/basic-types/main.rs b/tests/debuginfo/basic-types/main.rs index 9f61862c0dfd8..d01e51036f201 100644 --- a/tests/debuginfo/basic-types/main.rs +++ b/tests/debuginfo/basic-types/main.rs @@ -1,9 +1,3 @@ -// Caveats - gdb prints any 8-bit value (meaning rust i8 and u8 values) -// as its numerical value along with its associated ASCII char, there -// doesn't seem to be any way around this. Also, gdb doesn't know -// about UTF-32 character encoding and will print a rust char as only -// its numerical value. - //@ compile-flags:-g //@ disable-gdb-pretty-printers //@ ignore-backends: gcc @@ -32,6 +26,7 @@ //@ gdb-repr:f16 //@ gdb-repr:f32 //@ gdb-repr:f64 +// FIXME(f128): gdb doesn't support Rust `f128` yet. //@ gdb-repr:s // === LLDB TESTS ================================================================================== @@ -85,13 +80,16 @@ //@ cdb-check:f32 : 2.500000 [Type: float] //@ cdb-command:dx f64 //@ cdb-check:f64 : 3.500000 [Type: double] +//@ cdb-command:dx f128 +//@ cdb-check:f128 : 0x1.2p+2 [Type: f128] +//@ cdb-check:bits : 0x40012000000000000000000000000000 //@ 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$] #![allow(unused_variables)] -#![feature(f16)] +#![feature(f16, f128)] fn main() { let b: bool = false; @@ -109,6 +107,7 @@ fn main() { let f16: f16 = 1.5; let f32: f32 = 2.5; let f64: f64 = 3.5; + let f128: f128 = 4.5; let s: &str = "Hello, World!"; _zzz(); // #break } diff --git a/tests/debuginfo/borrowed-basic.rs b/tests/debuginfo/borrowed-basic.rs index f7b7d2cbd810c..2872bc65fac3f 100644 --- a/tests/debuginfo/borrowed-basic.rs +++ b/tests/debuginfo/borrowed-basic.rs @@ -2,6 +2,13 @@ //@ disable-gdb-pretty-printers //@ ignore-backends: gcc +// FIXME(f128): Merge `apple` revision once Apple releases Xcode with LLVM 22. +//@ revisions: not-apple apple +//@[not-apple] ignore-apple +//@[apple] only-apple +// `f128` support was added to `lldb` in version 22. +//@ min-llvm-lldb-version: 22 + // === GDB TESTS =================================================================================== //@ gdb-command:run @@ -50,6 +57,8 @@ //@ gdb-command:print *f64_ref //@ gdb-check:$15 = 3.5 +// FIXME(f128): gdb doesn't support Rust `f128` yet. + // === LLDB TESTS ================================================================================== @@ -99,8 +108,11 @@ //@ lldb-command:v *f64_ref //@ lldb-check:[...] 3.5 +//@ lldb-command:v *f128_ref +//@[not-apple] lldb-check:[...] 4.5 + #![allow(unused_variables)] -#![feature(f16)] +#![feature(f16, f128)] fn main() { let bool_val: bool = true; @@ -148,6 +160,9 @@ fn main() { let f64_val: f64 = 3.5; let f64_ref: &f64 = &f64_val; + let f128_val: f128 = 4.5; + let f128_ref: &f128 = &f128_val; + zzz(); // #break } diff --git a/tests/debuginfo/borrowed-unique-basic.rs b/tests/debuginfo/borrowed-unique-basic.rs index 17939239c0dea..0d1fdec0f58d1 100644 --- a/tests/debuginfo/borrowed-unique-basic.rs +++ b/tests/debuginfo/borrowed-unique-basic.rs @@ -2,6 +2,13 @@ //@ disable-gdb-pretty-printers //@ ignore-backends: gcc +// FIXME(f128): Merge `apple` revision once Apple releases Xcode with LLVM 22. +//@ revisions: not-apple apple +//@[not-apple] ignore-apple +//@[apple] only-apple +// `f128` support was added to `lldb` in version 22. +//@ min-llvm-lldb-version: 22 + // === GDB TESTS =================================================================================== //@ gdb-command:run @@ -51,6 +58,8 @@ //@ gdb-command:print *f64_ref //@ gdb-check:$15 = 3.5 +// FIXME(f128): gdb doesn't support Rust `f128` yet. + // === LLDB TESTS ================================================================================== @@ -102,8 +111,11 @@ //@ lldb-command:v *f64_ref //@ lldb-check:[...] 3.5 +//@ lldb-command:v *f128_ref +//@[not-apple] lldb-check:[...] 4.5 + #![allow(unused_variables)] -#![feature(f16)] +#![feature(f16, f128)] fn main() { let bool_box: Box = Box::new(true); @@ -151,6 +163,9 @@ fn main() { let f64_box: Box = Box::new(3.5); let f64_ref: &f64 = &*f64_box; + let f128_box: Box = Box::new(4.5); + let f128_ref: &f128 = &*f128_box; + zzz(); // #break } diff --git a/tests/debuginfo/f128-natvis.rs b/tests/debuginfo/f128-natvis.rs new file mode 100644 index 0000000000000..5f91014cfe5db --- /dev/null +++ b/tests/debuginfo/f128-natvis.rs @@ -0,0 +1,92 @@ +//@ compile-flags: -g +//@ only-msvc + +// This tests the `f128` Natvis visualiser. +//@ cdb-command:g +//@ cdb-command:dx v0_0 +//@ cdb-check:v0_0 : 0x0p+0 [Type: f128] +//@ cdb-check:bits : 0x00000000000000000000000000000000 +//@ cdb-command:dx neg_0_0 +//@ cdb-check:neg_0_0 : -0x0p+0 [Type: f128] +//@ cdb-check:bits : 0x80000000000000000000000000000000 +//@ cdb-command:dx v1_0 +//@ cdb-check:v1_0 : 0x1p+0 [Type: f128] +//@ cdb-check:bits : 0x3fff0000000000000000000000000000 +//@ cdb-command:dx v1_5 +//@ cdb-check:v1_5 : 0x1.8p+0 [Type: f128] +//@ cdb-check:bits : 0x3fff8000000000000000000000000000 +//@ cdb-command:dx v72_3 +//@ cdb-check:v72_3 : 0x1.2133333333333333333333333333p+6 [Type: f128] +//@ cdb-check:bits : 0x40052133333333333333333333333333 +//@ cdb-command:dx neg_0_126 +//@ cdb-check:neg_0_126 : -0x1.020c49ba5e353f7ced916872b021p-3 [Type: f128] +//@ cdb-check:bits : 0xbffc020c49ba5e353f7ced916872b021 +//@ cdb-command:dx v0_00003 +//@ cdb-check:v0_00003 : 0x1.f75104d551d68c692f6e82949a56p-16 [Type: f128] +//@ cdb-check:bits : 0x3feff75104d551d68c692f6e82949a56 +//@ cdb-command:dx neg_0_00004 +//@ cdb-check:neg_0_00004 : -0x1.4f8b588e368f08461f9f01b866e4p-15 [Type: f128] +//@ cdb-check:bits : 0xbff04f8b588e368f08461f9f01b866e4 +//@ cdb-command:dx very_small +//@ cdb-check:very_small : 0x1p-16494 [Type: f128] +//@ cdb-check:bits : 0x00000000000000000000000000000001 +//@ cdb-command:dx not_quite_as_small +//@ cdb-check:not_quite_as_small : 0x1.8p-16385 [Type: f128] +//@ cdb-check:bits : 0x00003000000000000000000000000000 +//@ cdb-command:dx smallest_pos_normal +//@ cdb-check:smallest_pos_normal : 0x1p-16382 [Type: f128] +//@ cdb-check:bits : 0x00010000000000000000000000000000 +//@ cdb-command:dx smallest_subnormal +//@ cdb-check:smallest_subnormal : -0x1.fffffffffffffffffffffffffffep-16383 [Type: f128] +//@ cdb-check:bits : 0x8000ffffffffffffffffffffffffffff +//@ cdb-command:dx just_above +//@ cdb-check:just_above : -0x1.ffffffffffffffffffffffffff8p-1 [Type: f128] +//@ cdb-check:bits : 0xbffeffffffffffffffffffffffffff80 +//@ cdb-command:dx max +//@ cdb-check:max : 0x1.ffffffffffffffffffffffffffffp+16383 [Type: f128] +//@ cdb-check:bits : 0x7ffeffffffffffffffffffffffffffff +//@ cdb-command:dx min +//@ cdb-check:min : -0x1.ffffffffffffffffffffffffffffp+16383 [Type: f128] +//@ cdb-check:bits : 0xfffeffffffffffffffffffffffffffff +//@ cdb-command:dx inf +//@ cdb-check:inf : inf [Type: f128] +//@ cdb-check:bits : 0x7fff0000000000000000000000000000 +//@ cdb-command:dx neg_inf +//@ cdb-check:neg_inf : -inf [Type: f128] +//@ cdb-check:bits : 0xffff0000000000000000000000000000 +//@ cdb-command:dx nan +//@ cdb-check:nan : NaN [Type: f128] +//@ cdb-check:bits : 0x7fff8000000000000000000000000000 +//@ cdb-command:dx other_nan +//@ cdb-check:other_nan : NaN [Type: f128] +//@ cdb-check:bits : 0xffff123456789abcdef123456789abcd + +#![feature(f128)] + +fn main() { + let v0_0 = 0.0_f128; + let neg_0_0 = -0.0_f128; + let v1_0 = 1.0_f128; + let v1_5 = 1.5_f128; + let v72_3 = 72.3_f128; + let neg_0_126 = -0.126_f128; + let v0_00003 = 0.00003_f128; + let neg_0_00004 = -0.00004_f128; + let very_small = 0.0_f128.next_up(); + let not_quite_as_small = const { f128::MIN_POSITIVE / 8.0 + f128::MIN_POSITIVE / 16.0 }; + let smallest_pos_normal = f128::MIN_POSITIVE; + let smallest_subnormal = (-f128::MIN_POSITIVE).next_up(); + let just_above = const { -1.0 + f128::EPSILON * 64.0 }; + let max = f128::MAX; + let min = f128::MIN; + let inf = f128::INFINITY; + let neg_inf = f128::NEG_INFINITY; + let nan = f128::NAN; + let other_nan = f128::from_bits(0xffff_1234_5678_9abc_def1_2345_6789_abcd); + + _zzz(); // #break +} + +fn _zzz() { + () +} diff --git a/tests/debuginfo/reference-debuginfo.rs b/tests/debuginfo/reference-debuginfo.rs index 518e1dac2885e..495dde379da7e 100644 --- a/tests/debuginfo/reference-debuginfo.rs +++ b/tests/debuginfo/reference-debuginfo.rs @@ -2,10 +2,18 @@ // That pass replaces debuginfo for `a => _x` where `_x = &b` to be `a => &b`, // and leaves codegen to create a ladder of allocations so as `*a == b`. // +// FIXME: Currently emits warning: MIR pass `ConstDebugInfo` is unknown and will be ignored //@ compile-flags:-g -Zmir-enable-passes=+ReferencePropagation,-ConstDebugInfo //@ disable-gdb-pretty-printers //@ ignore-backends: gcc +// FIXME(f128): Merge `apple` revision once Apple releases Xcode with LLVM 22. +//@ revisions: not-apple apple +//@[not-apple] ignore-apple +//@[apple] only-apple +// `f128` support was added to `lldb` in version 22. +//@ min-llvm-lldb-version: 22 + // === GDB TESTS =================================================================================== //@ gdb-command:run @@ -54,6 +62,8 @@ //@ gdb-command:print *f64_ref //@ gdb-check:$15 = 3.5 +// FIXME(f128): gdb doesn't support Rust `f128` yet. + //@ gdb-command:print *f64_double_ref //@ gdb-check:$16 = 3.5 @@ -106,11 +116,14 @@ //@ lldb-command:v *f64_ref //@ lldb-check:[...] 3.5 +//@ lldb-command:v *f128_ref +//@[not-apple] lldb-check:[...] 4.5 + //@ lldb-command:v *f64_double_ref //@ lldb-check:[...] 3.5 #![allow(unused_variables)] -#![feature(f16)] +#![feature(f16, f128)] fn main() { let bool_val: bool = true; @@ -159,6 +172,9 @@ fn main() { let f64_ref: &f64 = &f64_val; let f64_double_ref: &f64 = &f64_ref; + let f128_val: f128 = 4.5; + let f128_ref: &f128 = &f128_val; + zzz(); // #break } From 8c7d8ed8cf8dc84d26ac6c7eb5b8fbc100b1b126 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Tue, 15 Sep 2026 18:58:58 +0900 Subject: [PATCH 03/11] docs(num): add documentation for `NonZero::from_str` --- library/core/src/num/nonzero.rs | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 5d8dee0b9378a..5e90b5b9943c5 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -1414,6 +1414,44 @@ macro_rules! nonzero_integer { #[stable(feature = "nonzero_parse", since = "1.35.0")] impl FromStr for NonZero<$Int> { type Err = ParseIntError; + + /// Parses a non-zero integer from a string slice with decimal digits. + /// + /// The characters are expected to be an optional + #[doc = sign_dependent_expr!{ + $signedness ? + if signed { + " `+` or `-` " + } + if unsigned { + " `+` " + } + }] + /// sign followed by only digits. Leading and trailing non-digit characters (including + /// whitespace) represent an error. Underscores (which are accepted in Rust literals) + /// also represent an error. + /// + /// # Examples + /// + /// ``` + /// # use std::num::NonZero; + /// use std::str::FromStr; + /// # + /// # fn main() { test().unwrap(); } + /// # fn test() -> Option<()> { + #[doc = concat!("assert_eq!(NonZero::<", stringify!($Int), ">::from_str(\"+10\"), Ok(NonZero::new(10)?));")] + /// # Some(()) + /// # } + /// ``` + /// + /// Trailing space returns error: + /// + /// ``` + /// # use std::num::NonZero; + /// # use std::str::FromStr; + /// # + #[doc = concat!("assert!(NonZero::<", stringify!($Int), ">::from_str(\"1 \").is_err());")] + /// ``` fn from_str(src: &str) -> Result { Self::from_str_radix(src, 10) } From 7e6b378c4179786187b977e2664d8a68a85afef4 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Thu, 17 Sep 2026 08:21:35 +0900 Subject: [PATCH 04/11] style(num): unhide imported items --- library/core/src/num/nonzero.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 5e90b5b9943c5..0563c225f7e0b 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -1434,22 +1434,18 @@ macro_rules! nonzero_integer { /// # Examples /// /// ``` - /// # use std::num::NonZero; + /// use std::num::NonZero; /// use std::str::FromStr; - /// # - /// # fn main() { test().unwrap(); } - /// # fn test() -> Option<()> { - #[doc = concat!("assert_eq!(NonZero::<", stringify!($Int), ">::from_str(\"+10\"), Ok(NonZero::new(10)?));")] - /// # Some(()) - /// # } + /// + #[doc = concat!("assert_eq!(NonZero::<", stringify!($Int), ">::from_str(\"+10\"), Ok(NonZero::new(10).unwrap()));")] /// ``` /// /// Trailing space returns error: /// /// ``` - /// # use std::num::NonZero; - /// # use std::str::FromStr; - /// # + /// use std::num::NonZero; + /// use std::str::FromStr; + /// #[doc = concat!("assert!(NonZero::<", stringify!($Int), ">::from_str(\"1 \").is_err());")] /// ``` fn from_str(src: &str) -> Result { From 8730acb9e97759559c0984af1311a2d55d860b92 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 17 Sep 2026 16:42:50 +0200 Subject: [PATCH 05/11] Move more `rustdoc-html` tests in the right location --- .../{ => codeblock}/slice-links.link_box_generic.html | 0 tests/rustdoc-html/{ => codeblock}/slice-links.link_box_u32.html | 0 .../{ => codeblock}/slice-links.link_slice_generic.html | 0 .../rustdoc-html/{ => codeblock}/slice-links.link_slice_u32.html | 0 tests/rustdoc-html/{ => codeblock}/slice-links.rs | 0 tests/rustdoc-html/{ => codeblock}/tuples.link1_i32.html | 0 tests/rustdoc-html/{ => codeblock}/tuples.link1_t.html | 0 tests/rustdoc-html/{ => codeblock}/tuples.link2_i32.html | 0 tests/rustdoc-html/{ => codeblock}/tuples.link2_t.html | 0 tests/rustdoc-html/{ => codeblock}/tuples.link2_tu.html | 0 tests/rustdoc-html/{ => codeblock}/tuples.link_unit.html | 0 tests/rustdoc-html/{ => codeblock}/tuples.rs | 0 tests/rustdoc-html/{ => deref}/deref-mut-35169-2.rs | 0 tests/rustdoc-html/{ => deref}/deref-mut-35169.rs | 0 .../rustdoc-html/{ => jump-to-def}/link-on-path-with-generics.rs | 0 tests/rustdoc-html/{ => reexport}/attributes-inlining-108281.rs | 0 .../{ => reexport}/attributes-re-export-2021-edition.rs | 0 tests/rustdoc-html/{ => reexport}/attributes-re-export.rs | 0 tests/rustdoc-html/{ => reexport}/glob-shadowing.rs | 0 tests/rustdoc-html/{ => reexport}/namespaces.rs | 0 tests/rustdoc-html/{ => sidebar}/logo-class-default.rs | 0 tests/rustdoc-html/{ => sidebar}/logo-class-rust.rs | 0 tests/rustdoc-html/{ => sidebar}/logo-class.rs | 0 23 files changed, 0 insertions(+), 0 deletions(-) rename tests/rustdoc-html/{ => codeblock}/slice-links.link_box_generic.html (100%) rename tests/rustdoc-html/{ => codeblock}/slice-links.link_box_u32.html (100%) rename tests/rustdoc-html/{ => codeblock}/slice-links.link_slice_generic.html (100%) rename tests/rustdoc-html/{ => codeblock}/slice-links.link_slice_u32.html (100%) rename tests/rustdoc-html/{ => codeblock}/slice-links.rs (100%) rename tests/rustdoc-html/{ => codeblock}/tuples.link1_i32.html (100%) rename tests/rustdoc-html/{ => codeblock}/tuples.link1_t.html (100%) rename tests/rustdoc-html/{ => codeblock}/tuples.link2_i32.html (100%) rename tests/rustdoc-html/{ => codeblock}/tuples.link2_t.html (100%) rename tests/rustdoc-html/{ => codeblock}/tuples.link2_tu.html (100%) rename tests/rustdoc-html/{ => codeblock}/tuples.link_unit.html (100%) rename tests/rustdoc-html/{ => codeblock}/tuples.rs (100%) rename tests/rustdoc-html/{ => deref}/deref-mut-35169-2.rs (100%) rename tests/rustdoc-html/{ => deref}/deref-mut-35169.rs (100%) rename tests/rustdoc-html/{ => jump-to-def}/link-on-path-with-generics.rs (100%) rename tests/rustdoc-html/{ => reexport}/attributes-inlining-108281.rs (100%) rename tests/rustdoc-html/{ => reexport}/attributes-re-export-2021-edition.rs (100%) rename tests/rustdoc-html/{ => reexport}/attributes-re-export.rs (100%) rename tests/rustdoc-html/{ => reexport}/glob-shadowing.rs (100%) rename tests/rustdoc-html/{ => reexport}/namespaces.rs (100%) rename tests/rustdoc-html/{ => sidebar}/logo-class-default.rs (100%) rename tests/rustdoc-html/{ => sidebar}/logo-class-rust.rs (100%) rename tests/rustdoc-html/{ => sidebar}/logo-class.rs (100%) diff --git a/tests/rustdoc-html/slice-links.link_box_generic.html b/tests/rustdoc-html/codeblock/slice-links.link_box_generic.html similarity index 100% rename from tests/rustdoc-html/slice-links.link_box_generic.html rename to tests/rustdoc-html/codeblock/slice-links.link_box_generic.html diff --git a/tests/rustdoc-html/slice-links.link_box_u32.html b/tests/rustdoc-html/codeblock/slice-links.link_box_u32.html similarity index 100% rename from tests/rustdoc-html/slice-links.link_box_u32.html rename to tests/rustdoc-html/codeblock/slice-links.link_box_u32.html diff --git a/tests/rustdoc-html/slice-links.link_slice_generic.html b/tests/rustdoc-html/codeblock/slice-links.link_slice_generic.html similarity index 100% rename from tests/rustdoc-html/slice-links.link_slice_generic.html rename to tests/rustdoc-html/codeblock/slice-links.link_slice_generic.html diff --git a/tests/rustdoc-html/slice-links.link_slice_u32.html b/tests/rustdoc-html/codeblock/slice-links.link_slice_u32.html similarity index 100% rename from tests/rustdoc-html/slice-links.link_slice_u32.html rename to tests/rustdoc-html/codeblock/slice-links.link_slice_u32.html diff --git a/tests/rustdoc-html/slice-links.rs b/tests/rustdoc-html/codeblock/slice-links.rs similarity index 100% rename from tests/rustdoc-html/slice-links.rs rename to tests/rustdoc-html/codeblock/slice-links.rs diff --git a/tests/rustdoc-html/tuples.link1_i32.html b/tests/rustdoc-html/codeblock/tuples.link1_i32.html similarity index 100% rename from tests/rustdoc-html/tuples.link1_i32.html rename to tests/rustdoc-html/codeblock/tuples.link1_i32.html diff --git a/tests/rustdoc-html/tuples.link1_t.html b/tests/rustdoc-html/codeblock/tuples.link1_t.html similarity index 100% rename from tests/rustdoc-html/tuples.link1_t.html rename to tests/rustdoc-html/codeblock/tuples.link1_t.html diff --git a/tests/rustdoc-html/tuples.link2_i32.html b/tests/rustdoc-html/codeblock/tuples.link2_i32.html similarity index 100% rename from tests/rustdoc-html/tuples.link2_i32.html rename to tests/rustdoc-html/codeblock/tuples.link2_i32.html diff --git a/tests/rustdoc-html/tuples.link2_t.html b/tests/rustdoc-html/codeblock/tuples.link2_t.html similarity index 100% rename from tests/rustdoc-html/tuples.link2_t.html rename to tests/rustdoc-html/codeblock/tuples.link2_t.html diff --git a/tests/rustdoc-html/tuples.link2_tu.html b/tests/rustdoc-html/codeblock/tuples.link2_tu.html similarity index 100% rename from tests/rustdoc-html/tuples.link2_tu.html rename to tests/rustdoc-html/codeblock/tuples.link2_tu.html diff --git a/tests/rustdoc-html/tuples.link_unit.html b/tests/rustdoc-html/codeblock/tuples.link_unit.html similarity index 100% rename from tests/rustdoc-html/tuples.link_unit.html rename to tests/rustdoc-html/codeblock/tuples.link_unit.html diff --git a/tests/rustdoc-html/tuples.rs b/tests/rustdoc-html/codeblock/tuples.rs similarity index 100% rename from tests/rustdoc-html/tuples.rs rename to tests/rustdoc-html/codeblock/tuples.rs diff --git a/tests/rustdoc-html/deref-mut-35169-2.rs b/tests/rustdoc-html/deref/deref-mut-35169-2.rs similarity index 100% rename from tests/rustdoc-html/deref-mut-35169-2.rs rename to tests/rustdoc-html/deref/deref-mut-35169-2.rs diff --git a/tests/rustdoc-html/deref-mut-35169.rs b/tests/rustdoc-html/deref/deref-mut-35169.rs similarity index 100% rename from tests/rustdoc-html/deref-mut-35169.rs rename to tests/rustdoc-html/deref/deref-mut-35169.rs diff --git a/tests/rustdoc-html/link-on-path-with-generics.rs b/tests/rustdoc-html/jump-to-def/link-on-path-with-generics.rs similarity index 100% rename from tests/rustdoc-html/link-on-path-with-generics.rs rename to tests/rustdoc-html/jump-to-def/link-on-path-with-generics.rs diff --git a/tests/rustdoc-html/attributes-inlining-108281.rs b/tests/rustdoc-html/reexport/attributes-inlining-108281.rs similarity index 100% rename from tests/rustdoc-html/attributes-inlining-108281.rs rename to tests/rustdoc-html/reexport/attributes-inlining-108281.rs diff --git a/tests/rustdoc-html/attributes-re-export-2021-edition.rs b/tests/rustdoc-html/reexport/attributes-re-export-2021-edition.rs similarity index 100% rename from tests/rustdoc-html/attributes-re-export-2021-edition.rs rename to tests/rustdoc-html/reexport/attributes-re-export-2021-edition.rs diff --git a/tests/rustdoc-html/attributes-re-export.rs b/tests/rustdoc-html/reexport/attributes-re-export.rs similarity index 100% rename from tests/rustdoc-html/attributes-re-export.rs rename to tests/rustdoc-html/reexport/attributes-re-export.rs diff --git a/tests/rustdoc-html/glob-shadowing.rs b/tests/rustdoc-html/reexport/glob-shadowing.rs similarity index 100% rename from tests/rustdoc-html/glob-shadowing.rs rename to tests/rustdoc-html/reexport/glob-shadowing.rs diff --git a/tests/rustdoc-html/namespaces.rs b/tests/rustdoc-html/reexport/namespaces.rs similarity index 100% rename from tests/rustdoc-html/namespaces.rs rename to tests/rustdoc-html/reexport/namespaces.rs diff --git a/tests/rustdoc-html/logo-class-default.rs b/tests/rustdoc-html/sidebar/logo-class-default.rs similarity index 100% rename from tests/rustdoc-html/logo-class-default.rs rename to tests/rustdoc-html/sidebar/logo-class-default.rs diff --git a/tests/rustdoc-html/logo-class-rust.rs b/tests/rustdoc-html/sidebar/logo-class-rust.rs similarity index 100% rename from tests/rustdoc-html/logo-class-rust.rs rename to tests/rustdoc-html/sidebar/logo-class-rust.rs diff --git a/tests/rustdoc-html/logo-class.rs b/tests/rustdoc-html/sidebar/logo-class.rs similarity index 100% rename from tests/rustdoc-html/logo-class.rs rename to tests/rustdoc-html/sidebar/logo-class.rs From cba39542c8b67e0434720f2247208aeba2d88141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Thu, 17 Sep 2026 16:32:29 +0200 Subject: [PATCH 06/11] fix and clean up variance recording in liveness --- .../src/type_check/liveness/trace.rs | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs index 61aa30aa3917c..7a7ddba6fb127 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs @@ -553,8 +553,17 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> { /// points `live_at`. fn add_use_live_facts_for(&mut self, value: Ty<'tcx>, live_at: &IntervalSet) { debug!("add_use_live_facts_for(value={:?})", value); - Self::record_region_variance(self.typeck, value.into()); Self::make_all_regions_live(self.location_map, self.typeck, value.into(), live_at); + + // When using `-Zpolonius=next`, we also record the variance of regions in this live type. + if let Some(polonius_context) = self.typeck.polonius_context.as_mut() { + record_live_region_variance( + self.typeck.infcx.tcx, + &mut polonius_context.live_region_variances, + self.typeck.universal_regions, + value, + ); + } } /// Some variable with type `live_ty` is "drop live" at `location` @@ -595,9 +604,6 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> { } } - // Since the entire dropped local is live, record the variance of its regions. - Self::record_region_variance(self.typeck, dropped_ty.into()); - // All things in the `outlives` array may be touched by // the destructor and must be live at this point. for &kind in &drop_data.dropck_result.kinds { @@ -610,19 +616,16 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> { self.typeck.polonius_facts, ); } - } - /// `live_kind` is the type of a (use- or drop-) live local. - /// Record the variance of any region(s) appearing in it for Polonius. Does - /// nothing if Polonius is not active. - fn record_region_variance(typeck: &mut TypeChecker<'_, 'tcx>, live_kind: GenericArg<'tcx>) { - // When using `-Zpolonius=next`, we record the variance of each live region. - if let Some(polonius_context) = typeck.polonius_context.as_mut() { + // For polonius: since the local is drop live, record the variance of the regions in its + // type, not the ones in the type's live components seen in the dropck results above. See + // issue #160670. + if let Some(polonius_context) = self.typeck.polonius_context.as_mut() { record_live_region_variance( - typeck.infcx.tcx, + self.typeck.infcx.tcx, &mut polonius_context.live_region_variances, - typeck.universal_regions, - live_kind, + self.typeck.universal_regions, + dropped_ty, ); } } @@ -647,7 +650,6 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> { typeck.constraints.liveness_constraints.add_points(live_region_vid, live_at); }, }); - Self::record_region_variance(typeck, value); } } From 8a699c74c88df4ff32424508038946bc91098ee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Thu, 17 Sep 2026 16:41:55 +0200 Subject: [PATCH 07/11] simplify `make_all_regions_live` there's no need to wrap the value at runtime to visit it --- compiler/rustc_borrowck/src/type_check/liveness/trace.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs index 7a7ddba6fb127..90126866cd500 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs @@ -6,7 +6,7 @@ use rustc_infer::infer::canonical::QueryRegionConstraints; use rustc_infer::traits::TraitErrors; use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location}; use rustc_middle::traits::query::DropckOutlivesResult; -use rustc_middle::ty::{GenericArg, Ty, TypeVisitable, TypeVisitableExt}; +use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt}; use rustc_mir_dataflow::impls::MaybeInitializedPlaces; use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex}; use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex}; @@ -553,7 +553,7 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> { /// points `live_at`. fn add_use_live_facts_for(&mut self, value: Ty<'tcx>, live_at: &IntervalSet) { debug!("add_use_live_facts_for(value={:?})", value); - Self::make_all_regions_live(self.location_map, self.typeck, value.into(), live_at); + Self::make_all_regions_live(self.location_map, self.typeck, value, live_at); // When using `-Zpolonius=next`, we also record the variance of regions in this live type. if let Some(polonius_context) = self.typeck.polonius_context.as_mut() { @@ -633,7 +633,7 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> { fn make_all_regions_live( location_map: &DenseLocationMap, typeck: &mut TypeChecker<'_, 'tcx>, - value: GenericArg<'tcx>, + value: impl TypeVisitable>, live_at: &IntervalSet, ) { debug!("make_all_regions_live(value={:?})", value); From 942dcc900f8d2d426d56e5e5ae287f9f57b6c866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Thu, 17 Sep 2026 17:50:58 +0200 Subject: [PATCH 08/11] add quick links --- .../dump/polonius-mir-dump.template.html | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_borrowck/src/polonius/dump/polonius-mir-dump.template.html b/compiler/rustc_borrowck/src/polonius/dump/polonius-mir-dump.template.html index e2b9b412963a2..ecde6fb0a2ef7 100644 --- a/compiler/rustc_borrowck/src/polonius/dump/polonius-mir-dump.template.html +++ b/compiler/rustc_borrowck/src/polonius/dump/polonius-mir-dump.template.html @@ -30,38 +30,49 @@ - + + + +
Raw MIR dump
$SECTION_MIR
-
+
Polonius constraint graph
$SECTION_POLONIUS_CONSTRAINTS
-
+
Loan Traces
$SECTION_POLONIUS_REACHABILITY
-
+
Control-flow graph
$SECTION_CFG
-
+
NLL regions
$SECTION_NLL_CONSTRAINTS
-
+
NLL SCCs
$SECTION_NLL_SCCS
From ada6d898469f72e93c257a69e9f8a67a462818eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Thu, 17 Sep 2026 18:06:21 +0200 Subject: [PATCH 09/11] more visual improvements - fix margins - ensure the MIR code wraps instead of needing scrollbars - defocus the trace suffixes --- compiler/rustc_borrowck/src/polonius/dump.rs | 2 ++ .../dump/polonius-mir-dump.template.html | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_borrowck/src/polonius/dump.rs b/compiler/rustc_borrowck/src/polonius/dump.rs index e0f4c9ff98eca..0c63b00ce5461 100644 --- a/compiler/rustc_borrowck/src/polonius/dump.rs +++ b/compiler/rustc_borrowck/src/polonius/dump.rs @@ -543,6 +543,7 @@ fn emit_loan_reachability( // It's useful to know whether the region we're reaching is live at this point. let node_liveness = if liveness.is_live_at(node.region, location) { "live" } else { "not live" }; + writeln!(out, "")?; writeln!( out, "/ at {:?}: '{} is {}", @@ -550,6 +551,7 @@ fn emit_loan_reachability( node.region.index(), node_liveness, )?; + writeln!(out, "")?; writeln!(out, "")?; } writeln!(out, "")?; diff --git a/compiler/rustc_borrowck/src/polonius/dump/polonius-mir-dump.template.html b/compiler/rustc_borrowck/src/polonius/dump/polonius-mir-dump.template.html index ecde6fb0a2ef7..c83d4b9b856cf 100644 --- a/compiler/rustc_borrowck/src/polonius/dump/polonius-mir-dump.template.html +++ b/compiler/rustc_borrowck/src/polonius/dump/polonius-mir-dump.template.html @@ -3,8 +3,9 @@ Polonius MIR dump From 2605c8d41fb913749f239f221eda182c3ccb2151 Mon Sep 17 00:00:00 2001 From: ltdk Date: Thu, 17 Sep 2026 17:49:14 -0400 Subject: [PATCH 10/11] Use niche length type for strlen to guarantee isize::MAX bound --- library/core/src/ffi/c_str.rs | 21 ++++++++++++++------- library/core/src/num/niche_types.rs | 2 ++ tests/codegen-llvm/cstr-len-plus-one.rs | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 tests/codegen-llvm/cstr-len-plus-one.rs diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index e5b1f8088a5bf..c851b56c20bc8 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -6,6 +6,7 @@ use crate::ffi::c_char; use crate::intrinsics::const_eval_select; use crate::iter::FusedIterator; use crate::marker::PhantomData; +use crate::num::niche_types::UsizeNoHighBitMinusOne; use crate::ptr::NonNull; use crate::slice::memchr; use crate::{fmt, ops, range, slice, str}; @@ -262,7 +263,12 @@ impl CStr { // means the call to `from_bytes_with_nul_unchecked` is correct. // // The cast from c_char to u8 is ok because a c_char is always one byte. - unsafe { Self::from_bytes_with_nul_unchecked(slice::from_raw_parts(ptr.cast(), len + 1)) } + unsafe { + Self::from_bytes_with_nul_unchecked(slice::from_raw_parts( + ptr.cast(), + len.as_inner() + 1, + )) + } } /// Creates a C string wrapper from a byte slice with any number of nuls. @@ -750,9 +756,9 @@ const impl AsRef for CStr { #[inline] #[unstable(feature = "cstr_internals", issue = "none")] #[rustc_allow_const_fn_unstable(const_eval_select)] -const unsafe fn strlen(ptr: *const c_char) -> usize { +const unsafe fn strlen(ptr: *const c_char) -> UsizeNoHighBitMinusOne { const_eval_select!( - @capture { s: *const c_char = ptr } -> usize: + @capture { s: *const c_char = ptr } -> UsizeNoHighBitMinusOne: if const { let mut len = 0; @@ -761,15 +767,16 @@ const unsafe fn strlen(ptr: *const c_char) -> usize { len += 1; } - len + UsizeNoHighBitMinusOne::new(len).unwrap() } else { unsafe extern "C" { /// Provided by libc or compiler_builtins. fn strlen(s: *const c_char) -> usize; } - // SAFETY: Outer caller has provided a pointer to a valid C string. - unsafe { strlen(s) } + // SAFETY: Outer caller has provided a pointer to a valid C string, + // and its length is within bounds. + unsafe { UsizeNoHighBitMinusOne::new_unchecked(strlen(s)) } } ) } @@ -841,7 +848,7 @@ impl Iterator for Bytes<'_> { #[inline] fn count(self) -> usize { // SAFETY: We always hold a valid pointer to a C string - unsafe { strlen(self.ptr.as_ptr().cast()) } + unsafe { strlen(self.ptr.as_ptr().cast()) }.as_inner() } } diff --git a/library/core/src/num/niche_types.rs b/library/core/src/num/niche_types.rs index df1cdf0e65fa1..37037d8145fb0 100644 --- a/library/core/src/num/niche_types.rs +++ b/library/core/src/num/niche_types.rs @@ -111,6 +111,7 @@ const impl Default for Nanoseconds { } const HALF_USIZE: usize = usize::MAX >> 1; +const HALF_USIZE_MINUS_ONE: usize = HALF_USIZE - 1; define_valid_range_type! { pub struct NonZeroU8Inner(u8 is 1..); @@ -126,6 +127,7 @@ define_valid_range_type! { pub struct NonZeroI128Inner(i128 is ..0 | 1..); pub struct UsizeNoHighBit(usize is 0..=HALF_USIZE); + pub struct UsizeNoHighBitMinusOne(usize is 0..=HALF_USIZE_MINUS_ONE); pub struct NonZeroUsizeInner(usize is 1..); pub struct NonZeroIsizeInner(isize is ..0 | 1..); diff --git a/tests/codegen-llvm/cstr-len-plus-one.rs b/tests/codegen-llvm/cstr-len-plus-one.rs new file mode 100644 index 0000000000000..056f59070df09 --- /dev/null +++ b/tests/codegen-llvm/cstr-len-plus-one.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -Copt-level=3 -Cpanic=abort + +#![crate_type = "lib"] +#![feature(cstr_bytes)] + +use std::ffi::CStr; + +// A `CStr`'s length always fits in an isize after the NUL bit is accounted for + +// CHECK-LABEL: @cstr_len_plus_one +#[no_mangle] +pub fn cstr_len_plus_one(s: &CStr) -> bool { + // CHECK: ret i1 true + s.bytes().count() + 1 <= isize::MAX as usize +} From bc03591ff8195d268e61ab41f7683fd6c0b8aaa5 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 3 Sep 2026 20:52:20 +0200 Subject: [PATCH 11/11] Add mentions to sync back `RELEASES.md` to the `main` branch --- triagebot.toml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/triagebot.toml b/triagebot.toml index 3995949e5aacf..33fe1b076f639 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -1544,6 +1544,14 @@ cc = ["@mejrs"] message = "Some changes occurred to diagnostic attributes." cc = ["@mejrs"] +[mentions."RELEASES.md"] +message = """ +`RELEASES.md` was changed. Upon merging, each section will be automatically synced with its \ +corresponding GitHub releases, but **only from the `main` branch**. + +If it's not already the case, make sure to also merge the changes in the `main` branch. +""" + # Content-based mentions [mentions."miri"]