Skip to content

Commit 1c77f73

Browse files
committed
Auto merge of rust-lang#123708 - matthiaskrgr:rollup-uf9w1e9, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#121884 (Port exit-code run-make test to use rust) - rust-lang#122200 (Unconditionally show update nightly hint on ICE) - rust-lang#123568 (Clean up tests/ui by removing `does-nothing.rs`) - rust-lang#123609 (Don't use bytepos offsets when computing semicolon span for removal) - rust-lang#123612 (Set target-abi module flag for RISC-V targets) - rust-lang#123633 (Store all args in the unsupported Command implementation) - rust-lang#123668 (async closure coroutine by move body MirPass refactoring) Failed merges: - rust-lang#123701 (Only assert for child/parent projection compatibility AFTER checking that theyre coming from the same place) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 93c131e + df068db commit 1c77f73

File tree

36 files changed

+491
-203
lines changed

36 files changed

+491
-203
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl<'a> AstValidator<'a> {
346346
in_impl: matches!(parent, TraitOrTraitImpl::TraitImpl { .. }),
347347
const_context_label: parent_constness,
348348
remove_const_sugg: (
349-
self.session.source_map().span_extend_while(span, |c| c == ' ').unwrap_or(span),
349+
self.session.source_map().span_extend_while_whitespace(span),
350350
match parent_constness {
351351
Some(_) => rustc_errors::Applicability::MachineApplicable,
352352
None => rustc_errors::Applicability::MaybeIncorrect,

compiler/rustc_codegen_llvm/src/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ pub(crate) fn run_pass_manager(
608608
"LTOPostLink".as_ptr().cast(),
609609
11,
610610
) {
611-
llvm::LLVMRustAddModuleFlag(
611+
llvm::LLVMRustAddModuleFlagU32(
612612
module.module_llvm.llmod(),
613613
llvm::LLVMModFlagBehavior::Error,
614614
c"LTOPostLink".as_ptr().cast(),

compiler/rustc_codegen_llvm/src/context.rs

+31-15
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,13 @@ pub unsafe fn create_module<'ll>(
180180
// to ensure intrinsic calls don't use it.
181181
if !sess.needs_plt() {
182182
let avoid_plt = c"RtLibUseGOT".as_ptr().cast();
183-
llvm::LLVMRustAddModuleFlag(llmod, llvm::LLVMModFlagBehavior::Warning, avoid_plt, 1);
183+
llvm::LLVMRustAddModuleFlagU32(llmod, llvm::LLVMModFlagBehavior::Warning, avoid_plt, 1);
184184
}
185185

186186
// Enable canonical jump tables if CFI is enabled. (See https://reviews.llvm.org/D65629.)
187187
if sess.is_sanitizer_cfi_canonical_jump_tables_enabled() && sess.is_sanitizer_cfi_enabled() {
188188
let canonical_jump_tables = c"CFI Canonical Jump Tables".as_ptr().cast();
189-
llvm::LLVMRustAddModuleFlag(
189+
llvm::LLVMRustAddModuleFlagU32(
190190
llmod,
191191
llvm::LLVMModFlagBehavior::Override,
192192
canonical_jump_tables,
@@ -197,7 +197,7 @@ pub unsafe fn create_module<'ll>(
197197
// Enable LTO unit splitting if specified or if CFI is enabled. (See https://reviews.llvm.org/D53891.)
198198
if sess.is_split_lto_unit_enabled() || sess.is_sanitizer_cfi_enabled() {
199199
let enable_split_lto_unit = c"EnableSplitLTOUnit".as_ptr().cast();
200-
llvm::LLVMRustAddModuleFlag(
200+
llvm::LLVMRustAddModuleFlagU32(
201201
llmod,
202202
llvm::LLVMModFlagBehavior::Override,
203203
enable_split_lto_unit,
@@ -208,7 +208,7 @@ pub unsafe fn create_module<'ll>(
208208
// Add "kcfi" module flag if KCFI is enabled. (See https://reviews.llvm.org/D119296.)
209209
if sess.is_sanitizer_kcfi_enabled() {
210210
let kcfi = c"kcfi".as_ptr().cast();
211-
llvm::LLVMRustAddModuleFlag(llmod, llvm::LLVMModFlagBehavior::Override, kcfi, 1);
211+
llvm::LLVMRustAddModuleFlagU32(llmod, llvm::LLVMModFlagBehavior::Override, kcfi, 1);
212212
}
213213

214214
// Control Flow Guard is currently only supported by the MSVC linker on Windows.
@@ -217,7 +217,7 @@ pub unsafe fn create_module<'ll>(
217217
CFGuard::Disabled => {}
218218
CFGuard::NoChecks => {
219219
// Set `cfguard=1` module flag to emit metadata only.
220-
llvm::LLVMRustAddModuleFlag(
220+
llvm::LLVMRustAddModuleFlagU32(
221221
llmod,
222222
llvm::LLVMModFlagBehavior::Warning,
223223
c"cfguard".as_ptr() as *const _,
@@ -226,7 +226,7 @@ pub unsafe fn create_module<'ll>(
226226
}
227227
CFGuard::Checks => {
228228
// Set `cfguard=2` module flag to emit metadata and checks.
229-
llvm::LLVMRustAddModuleFlag(
229+
llvm::LLVMRustAddModuleFlagU32(
230230
llmod,
231231
llvm::LLVMModFlagBehavior::Warning,
232232
c"cfguard".as_ptr() as *const _,
@@ -238,26 +238,26 @@ pub unsafe fn create_module<'ll>(
238238

239239
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
240240
if sess.target.arch == "aarch64" {
241-
llvm::LLVMRustAddModuleFlag(
241+
llvm::LLVMRustAddModuleFlagU32(
242242
llmod,
243243
llvm::LLVMModFlagBehavior::Min,
244244
c"branch-target-enforcement".as_ptr().cast(),
245245
bti.into(),
246246
);
247-
llvm::LLVMRustAddModuleFlag(
247+
llvm::LLVMRustAddModuleFlagU32(
248248
llmod,
249249
llvm::LLVMModFlagBehavior::Min,
250250
c"sign-return-address".as_ptr().cast(),
251251
pac_ret.is_some().into(),
252252
);
253253
let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
254-
llvm::LLVMRustAddModuleFlag(
254+
llvm::LLVMRustAddModuleFlagU32(
255255
llmod,
256256
llvm::LLVMModFlagBehavior::Min,
257257
c"sign-return-address-all".as_ptr().cast(),
258258
pac_opts.leaf.into(),
259259
);
260-
llvm::LLVMRustAddModuleFlag(
260+
llvm::LLVMRustAddModuleFlagU32(
261261
llmod,
262262
llvm::LLVMModFlagBehavior::Min,
263263
c"sign-return-address-with-bkey".as_ptr().cast(),
@@ -273,15 +273,15 @@ pub unsafe fn create_module<'ll>(
273273

274274
// Pass on the control-flow protection flags to LLVM (equivalent to `-fcf-protection` in Clang).
275275
if let CFProtection::Branch | CFProtection::Full = sess.opts.unstable_opts.cf_protection {
276-
llvm::LLVMRustAddModuleFlag(
276+
llvm::LLVMRustAddModuleFlagU32(
277277
llmod,
278278
llvm::LLVMModFlagBehavior::Override,
279279
c"cf-protection-branch".as_ptr().cast(),
280280
1,
281281
)
282282
}
283283
if let CFProtection::Return | CFProtection::Full = sess.opts.unstable_opts.cf_protection {
284-
llvm::LLVMRustAddModuleFlag(
284+
llvm::LLVMRustAddModuleFlagU32(
285285
llmod,
286286
llvm::LLVMModFlagBehavior::Override,
287287
c"cf-protection-return".as_ptr().cast(),
@@ -290,7 +290,7 @@ pub unsafe fn create_module<'ll>(
290290
}
291291

292292
if sess.opts.unstable_opts.virtual_function_elimination {
293-
llvm::LLVMRustAddModuleFlag(
293+
llvm::LLVMRustAddModuleFlagU32(
294294
llmod,
295295
llvm::LLVMModFlagBehavior::Error,
296296
c"Virtual Function Elim".as_ptr().cast(),
@@ -300,7 +300,7 @@ pub unsafe fn create_module<'ll>(
300300

301301
// Set module flag to enable Windows EHCont Guard (/guard:ehcont).
302302
if sess.opts.unstable_opts.ehcont_guard {
303-
llvm::LLVMRustAddModuleFlag(
303+
llvm::LLVMRustAddModuleFlagU32(
304304
llmod,
305305
llvm::LLVMModFlagBehavior::Warning,
306306
c"ehcontguard".as_ptr() as *const _,
@@ -326,6 +326,22 @@ pub unsafe fn create_module<'ll>(
326326
llvm::LLVMMDNodeInContext(llcx, &name_metadata, 1),
327327
);
328328

329+
// Emit RISC-V specific target-abi metadata
330+
// to workaround lld as the LTO plugin not
331+
// correctly setting target-abi for the LTO object
332+
// FIXME: https://github.com/llvm/llvm-project/issues/50591
333+
// If llvm_abiname is empty, emit nothing.
334+
let llvm_abiname = &sess.target.options.llvm_abiname;
335+
if matches!(sess.target.arch.as_ref(), "riscv32" | "riscv64") && !llvm_abiname.is_empty() {
336+
llvm::LLVMRustAddModuleFlagString(
337+
llmod,
338+
llvm::LLVMModFlagBehavior::Error,
339+
c"target-abi".as_ptr(),
340+
llvm_abiname.as_ptr().cast(),
341+
llvm_abiname.len(),
342+
);
343+
}
344+
329345
// Add module flags specified via -Z llvm_module_flag
330346
for (key, value, behavior) in &sess.opts.unstable_opts.llvm_module_flag {
331347
let key = format!("{key}\0");
@@ -341,7 +357,7 @@ pub unsafe fn create_module<'ll>(
341357
// We already checked this during option parsing
342358
_ => unreachable!(),
343359
};
344-
llvm::LLVMRustAddModuleFlag(llmod, behavior, key.as_ptr().cast(), *value)
360+
llvm::LLVMRustAddModuleFlagU32(llmod, behavior, key.as_ptr().cast(), *value)
345361
}
346362

347363
llmod

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
110110
.unstable_opts
111111
.dwarf_version
112112
.unwrap_or(sess.target.default_dwarf_version);
113-
llvm::LLVMRustAddModuleFlag(
113+
llvm::LLVMRustAddModuleFlagU32(
114114
self.llmod,
115115
llvm::LLVMModFlagBehavior::Warning,
116116
c"Dwarf Version".as_ptr().cast(),
117117
dwarf_version,
118118
);
119119
} else {
120120
// Indicate that we want CodeView debug information on MSVC
121-
llvm::LLVMRustAddModuleFlag(
121+
llvm::LLVMRustAddModuleFlagU32(
122122
self.llmod,
123123
llvm::LLVMModFlagBehavior::Warning,
124124
c"CodeView".as_ptr().cast(),
@@ -127,7 +127,7 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
127127
}
128128

129129
// Prevent bitcode readers from deleting the debug info.
130-
llvm::LLVMRustAddModuleFlag(
130+
llvm::LLVMRustAddModuleFlagU32(
131131
self.llmod,
132132
llvm::LLVMModFlagBehavior::Warning,
133133
c"Debug Info Version".as_ptr().cast(),

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1801,12 +1801,21 @@ extern "C" {
18011801
///
18021802
/// In order for Rust-C LTO to work, module flags must be compatible with Clang. What
18031803
/// "compatible" means depends on the merge behaviors involved.
1804-
pub fn LLVMRustAddModuleFlag(
1804+
pub fn LLVMRustAddModuleFlagU32(
18051805
M: &Module,
18061806
merge_behavior: LLVMModFlagBehavior,
18071807
name: *const c_char,
18081808
value: u32,
18091809
);
1810+
1811+
pub fn LLVMRustAddModuleFlagString(
1812+
M: &Module,
1813+
merge_behavior: LLVMModFlagBehavior,
1814+
name: *const c_char,
1815+
value: *const c_char,
1816+
value_len: size_t,
1817+
);
1818+
18101819
pub fn LLVMRustHasModuleFlag(M: &Module, name: *const c_char, len: size_t) -> bool;
18111820

18121821
pub fn LLVMRustDIBuilderCreate(M: &Module) -> &mut DIBuilder<'_>;

compiler/rustc_driver_impl/messages.ftl

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
driver_impl_ice = the compiler unexpectedly panicked. this is a bug.
22
driver_impl_ice_bug_report = we would appreciate a bug report: {$bug_report_url}
33
driver_impl_ice_bug_report_internal_feature = using internal features is not supported and expected to cause internal compiler errors when used incorrectly
4-
driver_impl_ice_bug_report_outdated =
5-
it seems that this compiler `{$version}` is outdated, a newer nightly should have been released in the meantime
6-
.update = please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
7-
.url = if the problem still persists, we would appreciate a bug report: {$bug_report_url}
4+
driver_impl_ice_bug_report_update_note = please make sure that you have updated to the latest nightly
85
driver_impl_ice_exclude_cargo_defaults = some of the compiler flags provided by cargo are hidden
96
107
driver_impl_ice_flags = compiler flags: {$flags}

compiler/rustc_driver_impl/src/lib.rs

+8-30
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ use std::str;
6161
use std::sync::atomic::{AtomicBool, Ordering};
6262
use std::sync::{Arc, OnceLock};
6363
use std::time::{Instant, SystemTime};
64-
use time::{Date, OffsetDateTime, Time};
64+
use time::OffsetDateTime;
6565

6666
#[allow(unused_macros)]
6767
macro do_not_use_print($($t:tt)*) {
@@ -1385,9 +1385,6 @@ pub fn install_ice_hook(
13851385
using_internal_features
13861386
}
13871387

1388-
const DATE_FORMAT: &[time::format_description::FormatItem<'static>] =
1389-
&time::macros::format_description!("[year]-[month]-[day]");
1390-
13911388
/// Prints the ICE message, including query stack, but without backtrace.
13921389
///
13931390
/// The message will point the user at `bug_report_url` to report the ICE.
@@ -1416,33 +1413,14 @@ fn report_ice(
14161413
dcx.emit_err(session_diagnostics::Ice);
14171414
}
14181415

1419-
use time::ext::NumericalDuration;
1420-
1421-
// Try to hint user to update nightly if applicable when reporting an ICE.
1422-
// Attempt to calculate when current version was released, and add 12 hours
1423-
// as buffer. If the current version's release timestamp is older than
1424-
// the system's current time + 24 hours + 12 hours buffer if we're on
1425-
// nightly.
1426-
if let Some("nightly") = option_env!("CFG_RELEASE_CHANNEL")
1427-
&& let Some(version) = option_env!("CFG_VERSION")
1428-
&& let Some(ver_date_str) = option_env!("CFG_VER_DATE")
1429-
&& let Ok(ver_date) = Date::parse(&ver_date_str, DATE_FORMAT)
1430-
&& let ver_datetime = OffsetDateTime::new_utc(ver_date, Time::MIDNIGHT)
1431-
&& let system_datetime = OffsetDateTime::from(SystemTime::now())
1432-
&& system_datetime.checked_sub(36.hours()).is_some_and(|d| d > ver_datetime)
1433-
&& !using_internal_features.load(std::sync::atomic::Ordering::Relaxed)
1434-
{
1435-
dcx.emit_note(session_diagnostics::IceBugReportOutdated {
1436-
version,
1437-
bug_report_url,
1438-
note_update: (),
1439-
note_url: (),
1440-
});
1416+
if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
1417+
dcx.emit_note(session_diagnostics::IceBugReportInternalFeature);
14411418
} else {
1442-
if using_internal_features.load(std::sync::atomic::Ordering::Relaxed) {
1443-
dcx.emit_note(session_diagnostics::IceBugReportInternalFeature);
1444-
} else {
1445-
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });
1419+
dcx.emit_note(session_diagnostics::IceBugReport { bug_report_url });
1420+
1421+
// Only emit update nightly hint for users on nightly builds.
1422+
if rustc_feature::UnstableFeatures::from_environment(None).is_nightly_build() {
1423+
dcx.emit_note(session_diagnostics::UpdateNightlyNote);
14461424
}
14471425
}
14481426

compiler/rustc_driver_impl/src/session_diagnostics.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,12 @@ pub(crate) struct IceBugReport<'a> {
4343
}
4444

4545
#[derive(Diagnostic)]
46-
#[diag(driver_impl_ice_bug_report_internal_feature)]
47-
pub(crate) struct IceBugReportInternalFeature;
46+
#[diag(driver_impl_ice_bug_report_update_note)]
47+
pub(crate) struct UpdateNightlyNote;
4848

4949
#[derive(Diagnostic)]
50-
#[diag(driver_impl_ice_bug_report_outdated)]
51-
pub(crate) struct IceBugReportOutdated<'a> {
52-
pub version: &'a str,
53-
pub bug_report_url: &'a str,
54-
#[note(driver_impl_update)]
55-
pub note_update: (),
56-
#[note(driver_impl_url)]
57-
pub note_url: (),
58-
}
50+
#[diag(driver_impl_ice_bug_report_internal_feature)]
51+
pub(crate) struct IceBugReportInternalFeature;
5952

6053
#[derive(Diagnostic)]
6154
#[diag(driver_impl_ice_version)]

compiler/rustc_hir_typeck/src/expr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2023,8 +2023,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20232023
.tcx
20242024
.sess
20252025
.source_map()
2026-
.span_extend_while(range_start.span, |c| c.is_whitespace())
2027-
.unwrap_or(range_start.span)
2026+
.span_extend_while_whitespace(range_start.span)
20282027
.shrink_to_hi()
20292028
.to(range_end.span);
20302029

compiler/rustc_infer/src/infer/error_reporting/suggest.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::traits::{
1515
};
1616
use rustc_middle::ty::print::with_no_trimmed_paths;
1717
use rustc_middle::ty::{self as ty, GenericArgKind, IsSuggestable, Ty, TypeVisitableExt};
18-
use rustc_span::{sym, BytePos, Span};
18+
use rustc_span::{sym, Span};
1919

2020
use crate::errors::{
2121
ConsiderAddingAwait, FnConsiderCasting, FnItemsAreDistinct, FnUniqTypes,
@@ -763,8 +763,14 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
763763
let mac_call = rustc_span::source_map::original_sp(last_stmt.span, blk.span);
764764
self.tcx.sess.source_map().mac_call_stmt_semi_span(mac_call)?
765765
} else {
766-
last_stmt.span.with_lo(last_stmt.span.hi() - BytePos(1))
766+
self.tcx
767+
.sess
768+
.source_map()
769+
.span_extend_while_whitespace(last_expr.span)
770+
.shrink_to_hi()
771+
.with_hi(last_stmt.span.hi())
767772
};
773+
768774
Some((span, needs_box))
769775
}
770776

@@ -867,10 +873,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
867873
format!(" {ident} ")
868874
};
869875
let left_span = sm.span_through_char(blk.span, '{').shrink_to_hi();
870-
(
871-
sm.span_extend_while(left_span, |c| c.is_whitespace()).unwrap_or(left_span),
872-
sugg,
873-
)
876+
(sm.span_extend_while_whitespace(left_span), sugg)
874877
};
875878
Some(SuggestRemoveSemiOrReturnBinding::Add { sp: span, code: sugg, ident: *ident })
876879
}

compiler/rustc_lint/src/context/diagnostics.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,7 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiag, diag: &mut Di
215215
if let Some(deletion_span) = deletion_span {
216216
let msg = "elide the single-use lifetime";
217217
let (use_span, replace_lt) = if elide {
218-
let use_span = sess
219-
.source_map()
220-
.span_extend_while(use_span, char::is_whitespace)
221-
.unwrap_or(use_span);
218+
let use_span = sess.source_map().span_extend_while_whitespace(use_span);
222219
(use_span, String::new())
223220
} else {
224221
(use_span, "'_".to_owned())

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -817,14 +817,24 @@ extern "C" uint32_t LLVMRustVersionMinor() { return LLVM_VERSION_MINOR; }
817817

818818
extern "C" uint32_t LLVMRustVersionMajor() { return LLVM_VERSION_MAJOR; }
819819

820-
extern "C" void LLVMRustAddModuleFlag(
820+
extern "C" void LLVMRustAddModuleFlagU32(
821821
LLVMModuleRef M,
822822
Module::ModFlagBehavior MergeBehavior,
823823
const char *Name,
824824
uint32_t Value) {
825825
unwrap(M)->addModuleFlag(MergeBehavior, Name, Value);
826826
}
827827

828+
extern "C" void LLVMRustAddModuleFlagString(
829+
LLVMModuleRef M,
830+
Module::ModFlagBehavior MergeBehavior,
831+
const char *Name,
832+
const char *Value,
833+
size_t ValueLen) {
834+
unwrap(M)->addModuleFlag(MergeBehavior, Name,
835+
MDString::get(unwrap(M)->getContext(), StringRef(Value, ValueLen)));
836+
}
837+
828838
extern "C" bool LLVMRustHasModuleFlag(LLVMModuleRef M, const char *Name,
829839
size_t Len) {
830840
return unwrap(M)->getModuleFlag(StringRef(Name, Len)) != nullptr;

0 commit comments

Comments
 (0)