Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 9 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 7 additions & 2 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 16 additions & 2 deletions
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
}

0 commit comments

Comments
 (0)