Skip to content

Commit 9b46704

Browse files
committed
Auto merge of rust-lang#129442 - tgross35:rollup-gmqng7g, r=tgross35
Rollup of 7 pull requests Successful merges: - rust-lang#126985 (Implement `-Z embed-source` (DWARFv5 source code embedding extension)) - rust-lang#128349 (Enable `f16` tests on x86 and x86-64) - rust-lang#128511 (Document WebAssembly target feature expectations) - rust-lang#129263 (Add a missing compatibility note in the 1.80.0 release notes) - rust-lang#129276 (Stabilize feature `char_indices_offset`) - rust-lang#129350 (adapt integer comparison tests for LLVM 20 IR changes) - rust-lang#129408 (Fix handling of macro arguments within the `dropping_copy_types` lint) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b5723af + 4402558 commit 9b46704

File tree

28 files changed

+483
-53
lines changed

28 files changed

+483
-53
lines changed

RELEASES.md

+2
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ Compatibility Notes
143143
- [Turn `proc_macro_back_compat` lint into a hard error.](https://github.com/rust-lang/rust/pull/125596/)
144144
- [Detect unused structs even when implementing private traits](https://github.com/rust-lang/rust/pull/122382/)
145145
- [`std::sync::ReentrantLockGuard<T>` is no longer `Sync` if `T: !Sync`](https://github.com/rust-lang/rust/pull/125527) which means [`std::io::StdoutLock` and `std::io::StderrLock` are no longer Sync](https://github.com/rust-lang/rust/issues/127340)
146+
- [Type inference will fail in some cases due to new implementations of `FromIterator for Box<str>`.](https://github.com/rust-lang/rust/pull/99969/)
147+
Notably, this breaks versions of the `time` crate before 0.3.35, due to no longer inferring the implementation for `Box<[_]>`.
146148

147149
<a id="1.80-Internal-Changes"></a>
148150

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+9
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
629629
};
630630
let hash_value = hex_encode(source_file.src_hash.hash_bytes());
631631

632+
let source =
633+
cx.sess().opts.unstable_opts.embed_source.then_some(()).and(source_file.src.as_ref());
634+
632635
unsafe {
633636
llvm::LLVMRustDIBuilderCreateFile(
634637
DIB(cx),
@@ -639,6 +642,8 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
639642
hash_kind,
640643
hash_value.as_ptr().cast(),
641644
hash_value.len(),
645+
source.map_or(ptr::null(), |x| x.as_ptr().cast()),
646+
source.map_or(0, |x| x.len()),
642647
)
643648
}
644649
}
@@ -659,6 +664,8 @@ pub fn unknown_file_metadata<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll DIFile {
659664
llvm::ChecksumKind::None,
660665
hash_value.as_ptr().cast(),
661666
hash_value.len(),
667+
ptr::null(),
668+
0,
662669
)
663670
})
664671
}
@@ -943,6 +950,8 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
943950
llvm::ChecksumKind::None,
944951
ptr::null(),
945952
0,
953+
ptr::null(),
954+
0,
946955
);
947956

948957
let unit_metadata = llvm::LLVMRustDIBuilderCreateCompileUnit(

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,8 @@ extern "C" {
18601860
CSKind: ChecksumKind,
18611861
Checksum: *const c_char,
18621862
ChecksumLen: size_t,
1863+
Source: *const c_char,
1864+
SourceLen: size_t,
18631865
) -> &'a DIFile;
18641866

18651867
pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(

compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ fn test_unstable_options_tracking_hash() {
774774
tracked!(direct_access_external_data, Some(true));
775775
tracked!(dual_proc_macros, true);
776776
tracked!(dwarf_version, Some(5));
777+
tracked!(embed_source, true);
777778
tracked!(emit_thin_lto, false);
778779
tracked!(export_executable_symbols, true);
779780
tracked!(fewer_names, Some(true));

compiler/rustc_lint/src/drop_forget_useless.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,11 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
151151
&& let Node::Stmt(stmt) = node
152152
&& let StmtKind::Semi(e) = stmt.kind
153153
&& e.hir_id == expr.hir_id
154+
&& let Some(arg_span) = arg.span.find_ancestor_inside(expr.span)
154155
{
155156
UseLetUnderscoreIgnoreSuggestion::Suggestion {
156-
start_span: expr.span.shrink_to_lo().until(arg.span),
157-
end_span: arg.span.shrink_to_hi().until(expr.span.shrink_to_hi()),
157+
start_span: expr.span.shrink_to_lo().until(arg_span),
158+
end_span: arg_span.shrink_to_hi().until(expr.span.shrink_to_hi()),
158159
}
159160
} else {
160161
UseLetUnderscoreIgnoreSuggestion::Note

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -913,14 +913,19 @@ extern "C" LLVMMetadataRef
913913
LLVMRustDIBuilderCreateFile(LLVMRustDIBuilderRef Builder, const char *Filename,
914914
size_t FilenameLen, const char *Directory,
915915
size_t DirectoryLen, LLVMRustChecksumKind CSKind,
916-
const char *Checksum, size_t ChecksumLen) {
916+
const char *Checksum, size_t ChecksumLen,
917+
const char *Source, size_t SourceLen) {
917918

918919
std::optional<DIFile::ChecksumKind> llvmCSKind = fromRust(CSKind);
919920
std::optional<DIFile::ChecksumInfo<StringRef>> CSInfo{};
920921
if (llvmCSKind)
921922
CSInfo.emplace(*llvmCSKind, StringRef{Checksum, ChecksumLen});
923+
std::optional<StringRef> oSource{};
924+
if (Source)
925+
oSource = StringRef(Source, SourceLen);
922926
return wrap(Builder->createFile(StringRef(Filename, FilenameLen),
923-
StringRef(Directory, DirectoryLen), CSInfo));
927+
StringRef(Directory, DirectoryLen), CSInfo,
928+
oSource));
924929
}
925930

926931
extern "C" LLVMMetadataRef

compiler/rustc_session/messages.ftl

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ session_crate_name_empty = crate name must not be empty
1414
1515
session_crate_name_invalid = crate names cannot start with a `-`, but `{$s}` has a leading hyphen
1616
17+
session_embed_source_insufficient_dwarf_version = `-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}
18+
19+
session_embed_source_requires_debug_info = `-Zembed-source=y` requires debug information to be enabled
20+
1721
session_expr_parentheses_needed = parentheses are required to parse this as an expression
1822
1923
session_failed_to_create_profiler = failed to create profiler: {$err}

compiler/rustc_session/src/errors.rs

+10
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ pub(crate) struct UnsupportedDwarfVersion {
165165
pub(crate) dwarf_version: u32,
166166
}
167167

168+
#[derive(Diagnostic)]
169+
#[diag(session_embed_source_insufficient_dwarf_version)]
170+
pub(crate) struct EmbedSourceInsufficientDwarfVersion {
171+
pub(crate) dwarf_version: u32,
172+
}
173+
174+
#[derive(Diagnostic)]
175+
#[diag(session_embed_source_requires_debug_info)]
176+
pub(crate) struct EmbedSourceRequiresDebugInfo;
177+
168178
#[derive(Diagnostic)]
169179
#[diag(session_target_stack_protector_not_supported)]
170180
pub(crate) struct StackProtectorNotSupportedForTarget<'a> {

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,8 @@ options! {
17011701
them only if an error has not been emitted"),
17021702
ehcont_guard: bool = (false, parse_bool, [TRACKED],
17031703
"generate Windows EHCont Guard tables"),
1704+
embed_source: bool = (false, parse_bool, [TRACKED],
1705+
"embed source text in DWARF debug sections (default: no)"),
17041706
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
17051707
"emit a section containing stack size metadata (default: no)"),
17061708
emit_thin_lto: bool = (true, parse_bool, [TRACKED],

compiler/rustc_session/src/session.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ use rustc_target::spec::{
3737
use crate::code_stats::CodeStats;
3838
pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
3939
use crate::config::{
40-
self, CoverageLevel, CrateType, ErrorOutputType, FunctionReturn, Input, InstrumentCoverage,
41-
OptLevel, OutFileName, OutputType, RemapPathScopeComponents, SwitchWithOptPath,
40+
self, CoverageLevel, CrateType, DebugInfo, ErrorOutputType, FunctionReturn, Input,
41+
InstrumentCoverage, OptLevel, OutFileName, OutputType, RemapPathScopeComponents,
42+
SwitchWithOptPath,
4243
};
4344
use crate::parse::{add_feature_diagnostics, ParseSess};
4445
use crate::search_paths::{PathKind, SearchPath};
@@ -1306,6 +1307,19 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
13061307
.emit_err(errors::SplitDebugInfoUnstablePlatform { debuginfo: sess.split_debuginfo() });
13071308
}
13081309

1310+
if sess.opts.unstable_opts.embed_source {
1311+
let dwarf_version =
1312+
sess.opts.unstable_opts.dwarf_version.unwrap_or(sess.target.default_dwarf_version);
1313+
1314+
if dwarf_version < 5 {
1315+
sess.dcx().emit_warn(errors::EmbedSourceInsufficientDwarfVersion { dwarf_version });
1316+
}
1317+
1318+
if sess.opts.debuginfo == DebugInfo::None {
1319+
sess.dcx().emit_warn(errors::EmbedSourceRequiresDebugInfo);
1320+
}
1321+
}
1322+
13091323
if sess.opts.unstable_opts.instrument_xray.is_some() && !sess.target.options.supports_xray {
13101324
sess.dcx().emit_err(errors::InstrumentationNotSupported { us: "XRay".to_string() });
13111325
}

library/core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
#![cfg_attr(bootstrap, feature(offset_of_nested))]
111111
#![feature(array_ptr_get)]
112112
#![feature(asm_experimental_arch)]
113-
#![feature(char_indices_offset)]
114113
#![feature(const_align_of_val)]
115114
#![feature(const_align_of_val_raw)]
116115
#![feature(const_align_offset)]

library/core/src/num/f16.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl f16 {
261261
///
262262
/// ```
263263
/// #![feature(f16)]
264-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
264+
/// # #[cfg(target_arch = "x86_64")] {
265265
///
266266
/// let nan = f16::NAN;
267267
/// let f = 7.0_f16;
@@ -293,7 +293,7 @@ impl f16 {
293293
///
294294
/// ```
295295
/// #![feature(f16)]
296-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
296+
/// # #[cfg(target_arch = "x86_64")] {
297297
///
298298
/// let f = 7.0f16;
299299
/// let inf = f16::INFINITY;
@@ -319,7 +319,7 @@ impl f16 {
319319
///
320320
/// ```
321321
/// #![feature(f16)]
322-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
322+
/// # #[cfg(target_arch = "x86_64")] {
323323
///
324324
/// let f = 7.0f16;
325325
/// let inf: f16 = f16::INFINITY;
@@ -347,7 +347,7 @@ impl f16 {
347347
///
348348
/// ```
349349
/// #![feature(f16)]
350-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
350+
/// # #[cfg(target_arch = "x86_64")] {
351351
///
352352
/// let min = f16::MIN_POSITIVE; // 6.1035e-5
353353
/// let max = f16::MAX;
@@ -377,7 +377,7 @@ impl f16 {
377377
///
378378
/// ```
379379
/// #![feature(f16)]
380-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
380+
/// # #[cfg(target_arch = "x86_64")] {
381381
///
382382
/// let min = f16::MIN_POSITIVE; // 6.1035e-5
383383
/// let max = f16::MAX;
@@ -409,7 +409,7 @@ impl f16 {
409409
///
410410
/// ```
411411
/// #![feature(f16)]
412-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
412+
/// # #[cfg(target_arch = "x86_64")] {
413413
///
414414
/// use std::num::FpCategory;
415415
///
@@ -867,7 +867,7 @@ impl f16 {
867867
///
868868
/// ```
869869
/// #![feature(f16)]
870-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
870+
/// # #[cfg(target_arch = "x86_64")] {
871871
///
872872
/// let value = 4.6_f16;
873873
/// let rounded = unsafe { value.to_int_unchecked::<u16>() };
@@ -910,7 +910,7 @@ impl f16 {
910910
///
911911
/// ```
912912
/// #![feature(f16)]
913-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
913+
/// # #[cfg(target_arch = "x86_64")] {
914914
///
915915
/// # // FIXME(f16_f128): enable this once const casting works
916916
/// # // assert_ne!((1f16).to_bits(), 1f16 as u128); // to_bits() is not casting!
@@ -958,7 +958,7 @@ impl f16 {
958958
///
959959
/// ```
960960
/// #![feature(f16)]
961-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
961+
/// # #[cfg(target_arch = "x86_64")] {
962962
///
963963
/// let v = f16::from_bits(0x4a40);
964964
/// assert_eq!(v, 12.5);
@@ -1071,7 +1071,7 @@ impl f16 {
10711071
///
10721072
/// ```
10731073
/// #![feature(f16)]
1074-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
1074+
/// # #[cfg(target_arch = "x86_64")] {
10751075
///
10761076
/// let value = f16::from_be_bytes([0x4a, 0x40]);
10771077
/// assert_eq!(value, 12.5);
@@ -1094,7 +1094,7 @@ impl f16 {
10941094
///
10951095
/// ```
10961096
/// #![feature(f16)]
1097-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
1097+
/// # #[cfg(target_arch = "x86_64")] {
10981098
///
10991099
/// let value = f16::from_le_bytes([0x40, 0x4a]);
11001100
/// assert_eq!(value, 12.5);
@@ -1124,7 +1124,7 @@ impl f16 {
11241124
///
11251125
/// ```
11261126
/// #![feature(f16)]
1127-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
1127+
/// # #[cfg(target_arch = "x86_64")] {
11281128
///
11291129
/// let value = f16::from_ne_bytes(if cfg!(target_endian = "big") {
11301130
/// [0x4a, 0x40]
@@ -1257,7 +1257,7 @@ impl f16 {
12571257
///
12581258
/// ```
12591259
/// #![feature(f16)]
1260-
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
1260+
/// # #[cfg(target_arch = "x86_64")] {
12611261
///
12621262
/// assert!((-3.0f16).clamp(-2.0, 1.0) == -2.0);
12631263
/// assert!((0.0f16).clamp(-2.0, 1.0) == 0.0);

library/core/src/str/iter.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -241,24 +241,35 @@ impl<'a> CharIndices<'a> {
241241
/// Returns the byte position of the next character, or the length
242242
/// of the underlying string if there are no more characters.
243243
///
244+
/// This means that, when the iterator has not been fully consumed,
245+
/// the returned value will match the index that will be returned
246+
/// by the next call to [`next()`](Self::next).
247+
///
244248
/// # Examples
245249
///
246250
/// ```
247-
/// #![feature(char_indices_offset)]
248251
/// let mut chars = "a楽".char_indices();
249252
///
253+
/// // `next()` has not been called yet, so `offset()` returns the byte
254+
/// // index of the first character of the string, which is always 0.
250255
/// assert_eq!(chars.offset(), 0);
256+
/// // As expected, the first call to `next()` also returns 0 as index.
251257
/// assert_eq!(chars.next(), Some((0, 'a')));
252258
///
259+
/// // `next()` has been called once, so `offset()` returns the byte index
260+
/// // of the second character ...
253261
/// assert_eq!(chars.offset(), 1);
262+
/// // ... which matches the index returned by the next call to `next()`.
254263
/// assert_eq!(chars.next(), Some((1, '楽')));
255264
///
265+
/// // Once the iterator has been consumed, `offset()` returns the length
266+
/// // in bytes of the string.
256267
/// assert_eq!(chars.offset(), 4);
257268
/// assert_eq!(chars.next(), None);
258269
/// ```
259270
#[inline]
260271
#[must_use]
261-
#[unstable(feature = "char_indices_offset", issue = "83871")]
272+
#[stable(feature = "char_indices_offset", since = "CURRENT_RUSTC_VERSION")]
262273
pub fn offset(&self) -> usize {
263274
self.front_offset
264275
}

library/std/build.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ fn main() {
103103
("arm64ec", _) => false,
104104
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
105105
("x86_64", "windows") => false,
106-
// x86 has ABI bugs that show up with optimizations. This should be partially fixed with
107-
// the compiler-builtins update. <https://github.com/rust-lang/rust/issues/123885>
108-
("x86" | "x86_64", _) => false,
109106
// Missing `__gnu_h2f_ieee` and `__gnu_f2h_ieee`
110107
("powerpc" | "powerpc64", _) => false,
111108
// Missing `__gnu_h2f_ieee` and `__gnu_f2h_ieee`
@@ -140,17 +137,17 @@ fn main() {
140137
_ => false,
141138
};
142139

143-
// These are currently empty, but will fill up as some platforms move from completely
144-
// unreliable to reliable basics but unreliable math.
140+
// Configure platforms that have reliable basics but may have unreliable math.
145141

146142
// LLVM is currenlty adding missing routines, <https://github.com/llvm/llvm-project/issues/93566>
147143
let has_reliable_f16_math = has_reliable_f16
148144
&& match (target_arch.as_str(), target_os.as_str()) {
149145
// FIXME: Disabled on Miri as the intrinsics are not implemented yet.
150146
_ if is_miri => false,
151-
// Currently nothing special. Hooray!
152-
// This will change as platforms gain better better support for standard ops but math
153-
// lags behind.
147+
// x86 has a crash for `powi`: <https://github.com/llvm/llvm-project/issues/105747>
148+
("x86" | "x86_64", _) => false,
149+
// Assume that working `f16` means working `f16` math for most platforms, since
150+
// operations just go through `f32`.
154151
_ => true,
155152
};
156153

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
- [wasm32-wasip1](platform-support/wasm32-wasip1.md)
8282
- [wasm32-wasip1-threads](platform-support/wasm32-wasip1-threads.md)
8383
- [wasm32-wasip2](platform-support/wasm32-wasip2.md)
84+
- [wasm32-unknown-unknown](platform-support/wasm32-unknown-unknown.md)
8485
- [wasm64-unknown-unknown](platform-support/wasm64-unknown-unknown.md)
8586
- [\*-win7-windows-msvc](platform-support/win7-windows-msvc.md)
8687
- [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md)

src/doc/rustc/src/platform-support.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ target | std | notes
192192
[`thumbv8m.main-none-eabi`](platform-support/thumbv8m.main-none-eabi.md) | * | Bare Armv8-M Mainline
193193
[`thumbv8m.main-none-eabihf`](platform-support/thumbv8m.main-none-eabi.md) | * | Bare Armv8-M Mainline, hardfloat
194194
`wasm32-unknown-emscripten` | ✓ | WebAssembly via Emscripten
195-
`wasm32-unknown-unknown` | ✓ | WebAssembly
195+
[`wasm32-unknown-unknown`](platform-support/wasm32-unknown-unknown.md) | ✓ | WebAssembly
196196
`wasm32-wasi` | ✓ | WebAssembly with WASI (undergoing a [rename to `wasm32-wasip1`][wasi-rename])
197197
[`wasm32-wasip1`](platform-support/wasm32-wasip1.md) | ✓ | WebAssembly with WASI
198198
[`wasm32-wasip1-threads`](platform-support/wasm32-wasip1-threads.md) | ✓ | WebAssembly with WASI Preview 1 and threads

0 commit comments

Comments
 (0)