Skip to content

Commit 26b2b8d

Browse files
committed
Auto merge of rust-lang#130179 - workingjubilee:rollup-l78cv44, r=workingjubilee
Rollup of 11 pull requests Successful merges: - rust-lang#128316 (Stabilize most of `io_error_more`) - rust-lang#129473 (use `download-ci-llvm=true` in the default compiler config) - rust-lang#129529 (Add test to build crates used by r-a on stable) - rust-lang#129981 (Remove `serialized_bitcode` from `LtoModuleCodegen`.) - rust-lang#130094 (Inform the solver if evaluation is concurrent) - rust-lang#130132 ([illumos] enable SIGSEGV handler to detect stack overflows) - rust-lang#130146 (bootstrap `naked_asm!` for `compiler-builtins`) - rust-lang#130149 (Helper function for formatting with `LifetimeSuggestionPosition`) - rust-lang#130152 (adapt a test for llvm 20) - rust-lang#130162 (bump download-ci-llvm-stamp) - rust-lang#130164 (move some const fn out of the const_ptr_as_ref feature) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 304b7f8 + 9749a98 commit 26b2b8d

File tree

34 files changed

+265
-100
lines changed

34 files changed

+265
-100
lines changed

compiler/rustc_builtin_macros/src/asm.rs

+38
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,44 @@ pub(super) fn expand_asm<'cx>(
812812
})
813813
}
814814

815+
pub(super) fn expand_naked_asm<'cx>(
816+
ecx: &'cx mut ExtCtxt<'_>,
817+
sp: Span,
818+
tts: TokenStream,
819+
) -> MacroExpanderResult<'cx> {
820+
ExpandResult::Ready(match parse_args(ecx, sp, tts, false) {
821+
Ok(args) => {
822+
let ExpandResult::Ready(mac) = expand_preparsed_asm(ecx, args) else {
823+
return ExpandResult::Retry(());
824+
};
825+
let expr = match mac {
826+
Ok(mut inline_asm) => {
827+
// for future compatibility, we always set the NORETURN option.
828+
//
829+
// When we turn `asm!` into `naked_asm!` with this implementation, we can drop
830+
// the `options(noreturn)`, which makes the upgrade smooth when `naked_asm!`
831+
// starts disallowing the `noreturn` option in the future
832+
inline_asm.options |= ast::InlineAsmOptions::NORETURN;
833+
834+
P(ast::Expr {
835+
id: ast::DUMMY_NODE_ID,
836+
kind: ast::ExprKind::InlineAsm(P(inline_asm)),
837+
span: sp,
838+
attrs: ast::AttrVec::new(),
839+
tokens: None,
840+
})
841+
}
842+
Err(guar) => DummyResult::raw_expr(sp, Some(guar)),
843+
};
844+
MacEager::expr(expr)
845+
}
846+
Err(err) => {
847+
let guar = err.emit();
848+
DummyResult::any(sp, guar)
849+
}
850+
})
851+
}
852+
815853
pub(super) fn expand_global_asm<'cx>(
816854
ecx: &'cx mut ExtCtxt<'_>,
817855
sp: Span,

compiler/rustc_builtin_macros/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
9494
line: source_util::expand_line,
9595
log_syntax: log_syntax::expand_log_syntax,
9696
module_path: source_util::expand_mod,
97+
naked_asm: asm::expand_naked_asm,
9798
option_env: env::expand_option_env,
9899
pattern_type: pattern_type::expand,
99100
std_panic: edition_panic::expand_panic,

compiler/rustc_codegen_gcc/src/back/lto.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ fn fat_lto(
272272
}*/
273273
}
274274
};
275-
let mut serialized_bitcode = Vec::new();
276275
{
277276
info!("using {:?} as a base module", module.name);
278277

@@ -317,7 +316,6 @@ fn fat_lto(
317316
unimplemented!("from uncompressed file")
318317
}
319318
}
320-
serialized_bitcode.push(bc_decoded);
321319
}
322320
save_temp_bitcode(cgcx, &module, "lto.input");
323321

@@ -337,7 +335,7 @@ fn fat_lto(
337335
// of now.
338336
module.module_llvm.temp_dir = Some(tmp_path);
339337

340-
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: serialized_bitcode })
338+
Ok(LtoModuleCodegen::Fat(module))
341339
}
342340

343341
pub struct ModuleBuffer(PathBuf);

compiler/rustc_codegen_llvm/src/back/lto.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ fn fat_lto(
314314
}
315315
}
316316
};
317-
let mut serialized_bitcode = Vec::new();
318317
{
319318
let (llcx, llmod) = {
320319
let llvm = &module.module_llvm;
@@ -342,9 +341,7 @@ fn fat_lto(
342341
serialized_modules.sort_by(|module1, module2| module1.1.cmp(&module2.1));
343342

344343
// For all serialized bitcode files we parse them and link them in as we did
345-
// above, this is all mostly handled in C++. Like above, though, we don't
346-
// know much about the memory management here so we err on the side of being
347-
// save and persist everything with the original module.
344+
// above, this is all mostly handled in C++.
348345
let mut linker = Linker::new(llmod);
349346
for (bc_decoded, name) in serialized_modules {
350347
let _timer = cgcx
@@ -355,7 +352,6 @@ fn fat_lto(
355352
info!("linking {:?}", name);
356353
let data = bc_decoded.data();
357354
linker.add(data).map_err(|()| write::llvm_err(dcx, LlvmError::LoadBitcode { name }))?;
358-
serialized_bitcode.push(bc_decoded);
359355
}
360356
drop(linker);
361357
save_temp_bitcode(cgcx, &module, "lto.input");
@@ -372,7 +368,7 @@ fn fat_lto(
372368
}
373369
}
374370

375-
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: serialized_bitcode })
371+
Ok(LtoModuleCodegen::Fat(module))
376372
}
377373

378374
pub(crate) struct Linker<'a>(&'a mut llvm::Linker<'a>);

compiler/rustc_codegen_ssa/src/back/lto.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,14 @@ pub struct ThinShared<B: WriteBackendMethods> {
4141
}
4242

4343
pub enum LtoModuleCodegen<B: WriteBackendMethods> {
44-
Fat {
45-
module: ModuleCodegen<B::Module>,
46-
_serialized_bitcode: Vec<SerializedModule<B::ModuleBuffer>>,
47-
},
48-
44+
Fat(ModuleCodegen<B::Module>),
4945
Thin(ThinModule<B>),
5046
}
5147

5248
impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
5349
pub fn name(&self) -> &str {
5450
match *self {
55-
LtoModuleCodegen::Fat { .. } => "everything",
51+
LtoModuleCodegen::Fat(_) => "everything",
5652
LtoModuleCodegen::Thin(ref m) => m.name(),
5753
}
5854
}
@@ -68,7 +64,7 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
6864
cgcx: &CodegenContext<B>,
6965
) -> Result<ModuleCodegen<B::Module>, FatalError> {
7066
match self {
71-
LtoModuleCodegen::Fat { mut module, .. } => {
67+
LtoModuleCodegen::Fat(mut module) => {
7268
B::optimize_fat(cgcx, &mut module)?;
7369
Ok(module)
7470
}
@@ -81,7 +77,7 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
8177
pub fn cost(&self) -> u64 {
8278
match *self {
8379
// Only one module with fat LTO, so the cost doesn't matter.
84-
LtoModuleCodegen::Fat { .. } => 0,
80+
LtoModuleCodegen::Fat(_) => 0,
8581
LtoModuleCodegen::Thin(ref m) => m.cost(),
8682
}
8783
}

compiler/rustc_hir/src/hir.rs

+13
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ impl Lifetime {
168168
(LifetimeSuggestionPosition::Normal, self.ident.span)
169169
}
170170
}
171+
172+
pub fn suggestion(&self, new_lifetime: &str) -> (Span, String) {
173+
debug_assert!(new_lifetime.starts_with('\''));
174+
let (pos, span) = self.suggestion_position();
175+
let code = match pos {
176+
LifetimeSuggestionPosition::Normal => format!("{new_lifetime}"),
177+
LifetimeSuggestionPosition::Ampersand => format!("{new_lifetime} "),
178+
LifetimeSuggestionPosition::ElidedPath => format!("<{new_lifetime}>"),
179+
LifetimeSuggestionPosition::ElidedPathArgument => format!("{new_lifetime}, "),
180+
LifetimeSuggestionPosition::ObjectDefault => format!("+ {new_lifetime}"),
181+
};
182+
(span, code)
183+
}
171184
}
172185

173186
/// A `Path` is essentially Rust's notion of a name; for instance,

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -1191,23 +1191,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
11911191
(generics.span, "<'a>".to_owned())
11921192
};
11931193

1194-
let lifetime_sugg = match lifetime_ref.suggestion_position() {
1195-
(hir::LifetimeSuggestionPosition::Normal, span) => {
1196-
(span, "'a".to_owned())
1197-
}
1198-
(hir::LifetimeSuggestionPosition::Ampersand, span) => {
1199-
(span, "'a ".to_owned())
1200-
}
1201-
(hir::LifetimeSuggestionPosition::ElidedPath, span) => {
1202-
(span, "<'a>".to_owned())
1203-
}
1204-
(hir::LifetimeSuggestionPosition::ElidedPathArgument, span) => {
1205-
(span, "'a, ".to_owned())
1206-
}
1207-
(hir::LifetimeSuggestionPosition::ObjectDefault, span) => {
1208-
(span, "+ 'a".to_owned())
1209-
}
1210-
};
1194+
let lifetime_sugg = lifetime_ref.suggestion("'a");
12111195
let suggestions = vec![lifetime_sugg, new_param_sugg];
12121196

12131197
diag.span_label(

compiler/rustc_middle/src/ty/context.rs

+4
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
181181
}
182182
}
183183

184+
fn evaluation_is_concurrent(&self) -> bool {
185+
self.sess.threads() > 1
186+
}
187+
184188
fn expand_abstract_consts<T: TypeFoldable<TyCtxt<'tcx>>>(self, t: T) -> T {
185189
self.expand_abstract_consts(t)
186190
}

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,7 @@ symbols! {
12551255
mut_preserve_binding_mode_2024,
12561256
mut_ref,
12571257
naked,
1258+
naked_asm,
12581259
naked_functions,
12591260
name,
12601261
names,

compiler/rustc_trait_selection/src/error_reporting/infer/region.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -852,18 +852,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
852852
impl<'hir, 'tcx> hir::intravisit::Visitor<'hir> for LifetimeReplaceVisitor<'tcx, '_> {
853853
fn visit_lifetime(&mut self, lt: &'hir hir::Lifetime) {
854854
if lt.res == self.needle {
855-
let (pos, span) = lt.suggestion_position();
856-
let new_lt = &self.new_lt;
857-
let sugg = match pos {
858-
hir::LifetimeSuggestionPosition::Normal => format!("{new_lt}"),
859-
hir::LifetimeSuggestionPosition::Ampersand => format!("{new_lt} "),
860-
hir::LifetimeSuggestionPosition::ElidedPath => format!("<{new_lt}>"),
861-
hir::LifetimeSuggestionPosition::ElidedPathArgument => {
862-
format!("{new_lt}, ")
863-
}
864-
hir::LifetimeSuggestionPosition::ObjectDefault => format!("+ {new_lt}"),
865-
};
866-
self.add_lt_suggs.push((span, sugg));
855+
self.add_lt_suggs.push(lt.suggestion(self.new_lt));
867856
}
868857
}
869858

compiler/rustc_type_ir/src/elaborate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ pub fn supertrait_def_ids<I: Interner>(
237237
cx: I,
238238
trait_def_id: I::DefId,
239239
) -> impl Iterator<Item = I::DefId> {
240-
let mut set: HashSet<I::DefId> = HashSet::default();
240+
let mut set = HashSet::default();
241241
let mut stack = vec![trait_def_id];
242242

243243
set.insert(trait_def_id);

compiler/rustc_type_ir/src/interner.rs

+5
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ pub trait Interner:
137137
f: impl FnOnce(&mut search_graph::GlobalCache<Self>) -> R,
138138
) -> R;
139139

140+
fn evaluation_is_concurrent(&self) -> bool;
141+
140142
fn expand_abstract_consts<T: TypeFoldable<Self>>(self, t: T) -> T;
141143

142144
type GenericsOf: GenericsOf<Self>;
@@ -404,4 +406,7 @@ impl<I: Interner> search_graph::Cx for I {
404406
) -> R {
405407
I::with_global_cache(self, mode, f)
406408
}
409+
fn evaluation_is_concurrent(&self) -> bool {
410+
self.evaluation_is_concurrent()
411+
}
407412
}

compiler/rustc_type_ir/src/search_graph/global_cache.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,28 @@ impl<X: Cx> GlobalCache<X> {
4444
cx: X,
4545
input: X::Input,
4646

47-
result: X::Result,
47+
origin_result: X::Result,
4848
dep_node: X::DepNodeIndex,
4949

5050
additional_depth: usize,
5151
encountered_overflow: bool,
5252
nested_goals: NestedGoals<X>,
5353
) {
54-
let result = cx.mk_tracked(result, dep_node);
54+
let result = cx.mk_tracked(origin_result, dep_node);
5555
let entry = self.map.entry(input).or_default();
5656
if encountered_overflow {
5757
let with_overflow = WithOverflow { nested_goals, result };
5858
let prev = entry.with_overflow.insert(additional_depth, with_overflow);
59-
assert!(prev.is_none());
59+
if let Some(prev) = &prev {
60+
assert!(cx.evaluation_is_concurrent());
61+
assert_eq!(cx.get_tracked(&prev.result), origin_result);
62+
}
6063
} else {
6164
let prev = entry.success.replace(Success { additional_depth, nested_goals, result });
62-
assert!(prev.is_none());
65+
if let Some(prev) = &prev {
66+
assert!(cx.evaluation_is_concurrent());
67+
assert_eq!(cx.get_tracked(&prev.result), origin_result);
68+
}
6369
}
6470
}
6571

compiler/rustc_type_ir/src/search_graph/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub trait Cx: Copy {
5353
mode: SolverMode,
5454
f: impl FnOnce(&mut GlobalCache<Self>) -> R,
5555
) -> R;
56+
57+
fn evaluation_is_concurrent(&self) -> bool;
5658
}
5759

5860
pub trait Delegate {

config.example.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
# Unless you're developing for a target where Rust CI doesn't build a compiler
4343
# toolchain or changing LLVM locally, you probably want to leave this enabled.
4444
#
45+
# Set this to `true` to download if CI llvm available otherwise it builds
46+
# from `src/llvm-project`.
47+
#
4548
# Set this to `"if-unchanged"` to download only if the llvm-project has not
4649
# been modified. You can also use this if you are unsure whether you're on a
4750
# tier 1 target. All tier 1 targets are currently supported.
@@ -236,7 +239,7 @@
236239
# Instead of downloading the src/stage0 version of cargo-clippy specified,
237240
# use this cargo-clippy binary instead as the stage0 snapshot cargo-clippy.
238241
#
239-
# Note that this option should be used with the same toolchain as the `rustc` option above.
242+
# Note that this option should be used with the same toolchain as the `rustc` option above.
240243
# Otherwise, clippy is likely to fail due to a toolchain conflict.
241244
#cargo-clippy = "/path/to/cargo-clippy"
242245

library/core/src/arch.rs

+14
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
1717
/* compiler built-in */
1818
}
1919

20+
/// Inline assembly used in combination with `#[naked]` functions.
21+
///
22+
/// Refer to [Rust By Example] for a usage guide and the [reference] for
23+
/// detailed information about the syntax and available options.
24+
///
25+
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
26+
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
27+
#[unstable(feature = "naked_functions", issue = "90957")]
28+
#[rustc_builtin_macro]
29+
#[cfg(not(bootstrap))]
30+
pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) {
31+
/* compiler built-in */
32+
}
33+
2034
/// Module-level inline assembly.
2135
///
2236
/// Refer to [Rust By Example] for a usage guide and the [reference] for

library/core/src/ptr/const_ptr.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<T: ?Sized> *const T {
270270
/// }
271271
/// ```
272272
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
273-
#[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")]
273+
#[rustc_const_unstable(feature = "const_ptr_is_null", issue = "74939")]
274274
#[inline]
275275
pub const unsafe fn as_ref<'a>(self) -> Option<&'a T> {
276276
// SAFETY: the caller must guarantee that `self` is valid
@@ -302,7 +302,7 @@ impl<T: ?Sized> *const T {
302302
/// ```
303303
// FIXME: mention it in the docs for `as_ref` and `as_uninit_ref` once stabilized.
304304
#[unstable(feature = "ptr_as_ref_unchecked", issue = "122034")]
305-
#[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")]
305+
#[rustc_const_unstable(feature = "ptr_as_ref_unchecked", issue = "122034")]
306306
#[inline]
307307
#[must_use]
308308
pub const unsafe fn as_ref_unchecked<'a>(self) -> &'a T {
@@ -336,7 +336,7 @@ impl<T: ?Sized> *const T {
336336
/// ```
337337
#[inline]
338338
#[unstable(feature = "ptr_as_uninit", issue = "75402")]
339-
#[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")]
339+
#[rustc_const_unstable(feature = "ptr_as_uninit", issue = "75402")]
340340
pub const unsafe fn as_uninit_ref<'a>(self) -> Option<&'a MaybeUninit<T>>
341341
where
342342
T: Sized,
@@ -1664,7 +1664,7 @@ impl<T> *const [T] {
16641664
/// [allocated object]: crate::ptr#allocated-object
16651665
#[inline]
16661666
#[unstable(feature = "ptr_as_uninit", issue = "75402")]
1667-
#[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")]
1667+
#[rustc_const_unstable(feature = "ptr_as_uninit", issue = "75402")]
16681668
pub const unsafe fn as_uninit_slice<'a>(self) -> Option<&'a [MaybeUninit<T>]> {
16691669
if self.is_null() {
16701670
None

0 commit comments

Comments
 (0)