Skip to content

Commit

Permalink
Auto merge of rust-lang#129442 - tgross35:rollup-gmqng7g, r=tgross35
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 23, 2024
2 parents b5723af + 4402558 commit 9b46704
Show file tree
Hide file tree
Showing 28 changed files with 483 additions and 53 deletions.
2 changes: 2 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ Compatibility Notes
- [Turn `proc_macro_back_compat` lint into a hard error.](https://github.com/rust-lang/rust/pull/125596/)
- [Detect unused structs even when implementing private traits](https://github.com/rust-lang/rust/pull/122382/)
- [`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)
- [Type inference will fail in some cases due to new implementations of `FromIterator for Box<str>`.](https://github.com/rust-lang/rust/pull/99969/)
Notably, this breaks versions of the `time` crate before 0.3.35, due to no longer inferring the implementation for `Box<[_]>`.

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

Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
};
let hash_value = hex_encode(source_file.src_hash.hash_bytes());

let source =
cx.sess().opts.unstable_opts.embed_source.then_some(()).and(source_file.src.as_ref());

unsafe {
llvm::LLVMRustDIBuilderCreateFile(
DIB(cx),
Expand All @@ -639,6 +642,8 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
hash_kind,
hash_value.as_ptr().cast(),
hash_value.len(),
source.map_or(ptr::null(), |x| x.as_ptr().cast()),
source.map_or(0, |x| x.len()),
)
}
}
Expand All @@ -659,6 +664,8 @@ pub fn unknown_file_metadata<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll DIFile {
llvm::ChecksumKind::None,
hash_value.as_ptr().cast(),
hash_value.len(),
ptr::null(),
0,
)
})
}
Expand Down Expand Up @@ -943,6 +950,8 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
llvm::ChecksumKind::None,
ptr::null(),
0,
ptr::null(),
0,
);

let unit_metadata = llvm::LLVMRustDIBuilderCreateCompileUnit(
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,8 @@ extern "C" {
CSKind: ChecksumKind,
Checksum: *const c_char,
ChecksumLen: size_t,
Source: *const c_char,
SourceLen: size_t,
) -> &'a DIFile;

pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(direct_access_external_data, Some(true));
tracked!(dual_proc_macros, true);
tracked!(dwarf_version, Some(5));
tracked!(embed_source, true);
tracked!(emit_thin_lto, false);
tracked!(export_executable_symbols, true);
tracked!(fewer_names, Some(true));
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_lint/src/drop_forget_useless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,11 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
&& let Node::Stmt(stmt) = node
&& let StmtKind::Semi(e) = stmt.kind
&& e.hir_id == expr.hir_id
&& let Some(arg_span) = arg.span.find_ancestor_inside(expr.span)
{
UseLetUnderscoreIgnoreSuggestion::Suggestion {
start_span: expr.span.shrink_to_lo().until(arg.span),
end_span: arg.span.shrink_to_hi().until(expr.span.shrink_to_hi()),
start_span: expr.span.shrink_to_lo().until(arg_span),
end_span: arg_span.shrink_to_hi().until(expr.span.shrink_to_hi()),
}
} else {
UseLetUnderscoreIgnoreSuggestion::Note
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,14 +913,19 @@ extern "C" LLVMMetadataRef
LLVMRustDIBuilderCreateFile(LLVMRustDIBuilderRef Builder, const char *Filename,
size_t FilenameLen, const char *Directory,
size_t DirectoryLen, LLVMRustChecksumKind CSKind,
const char *Checksum, size_t ChecksumLen) {
const char *Checksum, size_t ChecksumLen,
const char *Source, size_t SourceLen) {

std::optional<DIFile::ChecksumKind> llvmCSKind = fromRust(CSKind);
std::optional<DIFile::ChecksumInfo<StringRef>> CSInfo{};
if (llvmCSKind)
CSInfo.emplace(*llvmCSKind, StringRef{Checksum, ChecksumLen});
std::optional<StringRef> oSource{};
if (Source)
oSource = StringRef(Source, SourceLen);
return wrap(Builder->createFile(StringRef(Filename, FilenameLen),
StringRef(Directory, DirectoryLen), CSInfo));
StringRef(Directory, DirectoryLen), CSInfo,
oSource));
}

extern "C" LLVMMetadataRef
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_session/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ session_crate_name_empty = crate name must not be empty
session_crate_name_invalid = crate names cannot start with a `-`, but `{$s}` has a leading hyphen
session_embed_source_insufficient_dwarf_version = `-Zembed-source=y` requires at least `-Z dwarf-version=5` but DWARF version is {$dwarf_version}
session_embed_source_requires_debug_info = `-Zembed-source=y` requires debug information to be enabled
session_expr_parentheses_needed = parentheses are required to parse this as an expression
session_failed_to_create_profiler = failed to create profiler: {$err}
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_session/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ pub(crate) struct UnsupportedDwarfVersion {
pub(crate) dwarf_version: u32,
}

#[derive(Diagnostic)]
#[diag(session_embed_source_insufficient_dwarf_version)]
pub(crate) struct EmbedSourceInsufficientDwarfVersion {
pub(crate) dwarf_version: u32,
}

#[derive(Diagnostic)]
#[diag(session_embed_source_requires_debug_info)]
pub(crate) struct EmbedSourceRequiresDebugInfo;

#[derive(Diagnostic)]
#[diag(session_target_stack_protector_not_supported)]
pub(crate) struct StackProtectorNotSupportedForTarget<'a> {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,8 @@ options! {
them only if an error has not been emitted"),
ehcont_guard: bool = (false, parse_bool, [TRACKED],
"generate Windows EHCont Guard tables"),
embed_source: bool = (false, parse_bool, [TRACKED],
"embed source text in DWARF debug sections (default: no)"),
emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED],
"emit a section containing stack size metadata (default: no)"),
emit_thin_lto: bool = (true, parse_bool, [TRACKED],
Expand Down
18 changes: 16 additions & 2 deletions compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ use rustc_target::spec::{
use crate::code_stats::CodeStats;
pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
use crate::config::{
self, CoverageLevel, CrateType, ErrorOutputType, FunctionReturn, Input, InstrumentCoverage,
OptLevel, OutFileName, OutputType, RemapPathScopeComponents, SwitchWithOptPath,
self, CoverageLevel, CrateType, DebugInfo, ErrorOutputType, FunctionReturn, Input,
InstrumentCoverage, OptLevel, OutFileName, OutputType, RemapPathScopeComponents,
SwitchWithOptPath,
};
use crate::parse::{add_feature_diagnostics, ParseSess};
use crate::search_paths::{PathKind, SearchPath};
Expand Down Expand Up @@ -1306,6 +1307,19 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
.emit_err(errors::SplitDebugInfoUnstablePlatform { debuginfo: sess.split_debuginfo() });
}

if sess.opts.unstable_opts.embed_source {
let dwarf_version =
sess.opts.unstable_opts.dwarf_version.unwrap_or(sess.target.default_dwarf_version);

if dwarf_version < 5 {
sess.dcx().emit_warn(errors::EmbedSourceInsufficientDwarfVersion { dwarf_version });
}

if sess.opts.debuginfo == DebugInfo::None {
sess.dcx().emit_warn(errors::EmbedSourceRequiresDebugInfo);
}
}

if sess.opts.unstable_opts.instrument_xray.is_some() && !sess.target.options.supports_xray {
sess.dcx().emit_err(errors::InstrumentationNotSupported { us: "XRay".to_string() });
}
Expand Down
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
#![cfg_attr(bootstrap, feature(offset_of_nested))]
#![feature(array_ptr_get)]
#![feature(asm_experimental_arch)]
#![feature(char_indices_offset)]
#![feature(const_align_of_val)]
#![feature(const_align_of_val_raw)]
#![feature(const_align_offset)]
Expand Down
26 changes: 13 additions & 13 deletions library/core/src/num/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// let nan = f16::NAN;
/// let f = 7.0_f16;
Expand Down Expand Up @@ -293,7 +293,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// let f = 7.0f16;
/// let inf = f16::INFINITY;
Expand All @@ -319,7 +319,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// let f = 7.0f16;
/// let inf: f16 = f16::INFINITY;
Expand Down Expand Up @@ -347,7 +347,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// let min = f16::MIN_POSITIVE; // 6.1035e-5
/// let max = f16::MAX;
Expand Down Expand Up @@ -377,7 +377,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// let min = f16::MIN_POSITIVE; // 6.1035e-5
/// let max = f16::MAX;
Expand Down Expand Up @@ -409,7 +409,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// use std::num::FpCategory;
///
Expand Down Expand Up @@ -867,7 +867,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// let value = 4.6_f16;
/// let rounded = unsafe { value.to_int_unchecked::<u16>() };
Expand Down Expand Up @@ -910,7 +910,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// # // FIXME(f16_f128): enable this once const casting works
/// # // assert_ne!((1f16).to_bits(), 1f16 as u128); // to_bits() is not casting!
Expand Down Expand Up @@ -958,7 +958,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// let v = f16::from_bits(0x4a40);
/// assert_eq!(v, 12.5);
Expand Down Expand Up @@ -1071,7 +1071,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// let value = f16::from_be_bytes([0x4a, 0x40]);
/// assert_eq!(value, 12.5);
Expand All @@ -1094,7 +1094,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// let value = f16::from_le_bytes([0x40, 0x4a]);
/// assert_eq!(value, 12.5);
Expand Down Expand Up @@ -1124,7 +1124,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// let value = f16::from_ne_bytes(if cfg!(target_endian = "big") {
/// [0x4a, 0x40]
Expand Down Expand Up @@ -1257,7 +1257,7 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
/// # #[cfg(target_arch = "aarch64")] { // FIXME(f16_F128): rust-lang/rust#123885
/// # #[cfg(target_arch = "x86_64")] {
///
/// assert!((-3.0f16).clamp(-2.0, 1.0) == -2.0);
/// assert!((0.0f16).clamp(-2.0, 1.0) == 0.0);
Expand Down
15 changes: 13 additions & 2 deletions library/core/src/str/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,24 +241,35 @@ impl<'a> CharIndices<'a> {
/// Returns the byte position of the next character, or the length
/// of the underlying string if there are no more characters.
///
/// This means that, when the iterator has not been fully consumed,
/// the returned value will match the index that will be returned
/// by the next call to [`next()`](Self::next).
///
/// # Examples
///
/// ```
/// #![feature(char_indices_offset)]
/// let mut chars = "a楽".char_indices();
///
/// // `next()` has not been called yet, so `offset()` returns the byte
/// // index of the first character of the string, which is always 0.
/// assert_eq!(chars.offset(), 0);
/// // As expected, the first call to `next()` also returns 0 as index.
/// assert_eq!(chars.next(), Some((0, 'a')));
///
/// // `next()` has been called once, so `offset()` returns the byte index
/// // of the second character ...
/// assert_eq!(chars.offset(), 1);
/// // ... which matches the index returned by the next call to `next()`.
/// assert_eq!(chars.next(), Some((1, '楽')));
///
/// // Once the iterator has been consumed, `offset()` returns the length
/// // in bytes of the string.
/// assert_eq!(chars.offset(), 4);
/// assert_eq!(chars.next(), None);
/// ```
#[inline]
#[must_use]
#[unstable(feature = "char_indices_offset", issue = "83871")]
#[stable(feature = "char_indices_offset", since = "CURRENT_RUSTC_VERSION")]
pub fn offset(&self) -> usize {
self.front_offset
}
Expand Down
13 changes: 5 additions & 8 deletions library/std/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ fn main() {
("arm64ec", _) => false,
// MinGW ABI bugs <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054>
("x86_64", "windows") => false,
// x86 has ABI bugs that show up with optimizations. This should be partially fixed with
// the compiler-builtins update. <https://github.com/rust-lang/rust/issues/123885>
("x86" | "x86_64", _) => false,
// Missing `__gnu_h2f_ieee` and `__gnu_f2h_ieee`
("powerpc" | "powerpc64", _) => false,
// Missing `__gnu_h2f_ieee` and `__gnu_f2h_ieee`
Expand Down Expand Up @@ -140,17 +137,17 @@ fn main() {
_ => false,
};

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

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

Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
- [wasm32-wasip1](platform-support/wasm32-wasip1.md)
- [wasm32-wasip1-threads](platform-support/wasm32-wasip1-threads.md)
- [wasm32-wasip2](platform-support/wasm32-wasip2.md)
- [wasm32-unknown-unknown](platform-support/wasm32-unknown-unknown.md)
- [wasm64-unknown-unknown](platform-support/wasm64-unknown-unknown.md)
- [\*-win7-windows-msvc](platform-support/win7-windows-msvc.md)
- [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md)
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ target | std | notes
[`thumbv8m.main-none-eabi`](platform-support/thumbv8m.main-none-eabi.md) | * | Bare Armv8-M Mainline
[`thumbv8m.main-none-eabihf`](platform-support/thumbv8m.main-none-eabi.md) | * | Bare Armv8-M Mainline, hardfloat
`wasm32-unknown-emscripten` | ✓ | WebAssembly via Emscripten
`wasm32-unknown-unknown` | ✓ | WebAssembly
[`wasm32-unknown-unknown`](platform-support/wasm32-unknown-unknown.md) | ✓ | WebAssembly
`wasm32-wasi` | ✓ | WebAssembly with WASI (undergoing a [rename to `wasm32-wasip1`][wasi-rename])
[`wasm32-wasip1`](platform-support/wasm32-wasip1.md) | ✓ | WebAssembly with WASI
[`wasm32-wasip1-threads`](platform-support/wasm32-wasip1-threads.md) | ✓ | WebAssembly with WASI Preview 1 and threads
Expand Down
Loading

0 comments on commit 9b46704

Please sign in to comment.