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

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

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)