Skip to content

Commit 490e4d3

Browse files
authored
Merge pull request #4145 from rust-lang/rustup-2025-01-23
Automatic Rustup
2 parents 32c567c + db4bd29 commit 490e4d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+113
-162
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
01706e1a34c87656fcbfce198608f4cd2ac6461a
1+
3cd8fcbf87bd28a1f31be000ca906fb66f4d451d

src/bin/miri.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use std::sync::atomic::{AtomicI32, Ordering};
3333
use std::sync::{Arc, Once};
3434

3535
use miri::{
36-
BacktraceStyle, BorrowTrackerMethod, MiriConfig, ProvenanceMode, RetagFields, ValidationMode,
36+
BacktraceStyle, BorrowTrackerMethod, MiriConfig, MiriEntryFnType, ProvenanceMode, RetagFields,
37+
ValidationMode,
3738
};
3839
use rustc_abi::ExternAbi;
3940
use rustc_data_structures::sync;
@@ -51,7 +52,7 @@ use rustc_middle::query::LocalCrate;
5152
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
5253
use rustc_middle::ty::{self, Ty, TyCtxt};
5354
use rustc_middle::util::Providers;
54-
use rustc_session::config::{CrateType, EntryFnType, ErrorOutputType, OptLevel};
55+
use rustc_session::config::{CrateType, ErrorOutputType, OptLevel};
5556
use rustc_session::search_paths::PathKind;
5657
use rustc_session::{CtfeBacktrace, EarlyDiagCtxt};
5758
use rustc_span::def_id::DefId;
@@ -73,9 +74,9 @@ impl MiriCompilerCalls {
7374
}
7475
}
7576

76-
fn entry_fn(tcx: TyCtxt<'_>) -> (DefId, EntryFnType) {
77-
if let Some(entry_def) = tcx.entry_fn(()) {
78-
return entry_def;
77+
fn entry_fn(tcx: TyCtxt<'_>) -> (DefId, MiriEntryFnType) {
78+
if let Some((def_id, entry_type)) = tcx.entry_fn(()) {
79+
return (def_id, MiriEntryFnType::Rustc(entry_type));
7980
}
8081
// Look for a symbol in the local crate named `miri_start`, and treat that as the entry point.
8182
let sym = tcx.exported_symbols(LOCAL_CRATE).iter().find_map(|(sym, _)| {
@@ -102,7 +103,7 @@ fn entry_fn(tcx: TyCtxt<'_>) -> (DefId, EntryFnType) {
102103
.is_ok();
103104

104105
if correct_func_sig {
105-
(*id, EntryFnType::Start)
106+
(*id, MiriEntryFnType::MiriStart)
106107
} else {
107108
tcx.dcx().fatal(
108109
"`miri_start` must have the following signature:\n\

src/eval.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ use crate::diagnostics::report_leaks;
1919
use crate::shims::tls;
2020
use crate::*;
2121

22+
#[derive(Copy, Clone, Debug)]
23+
pub enum MiriEntryFnType {
24+
MiriStart,
25+
Rustc(EntryFnType),
26+
}
27+
2228
/// When the main thread would exit, we will yield to any other thread that is ready to execute.
2329
/// But we must only do that a finite number of times, or a background thread running `loop {}`
2430
/// will hang the program.
@@ -272,7 +278,7 @@ impl<'tcx> MainThreadState<'tcx> {
272278
pub fn create_ecx<'tcx>(
273279
tcx: TyCtxt<'tcx>,
274280
entry_id: DefId,
275-
entry_type: EntryFnType,
281+
entry_type: MiriEntryFnType,
276282
config: &MiriConfig,
277283
) -> InterpResult<'tcx, InterpCx<'tcx, MiriMachine<'tcx>>> {
278284
let typing_env = ty::TypingEnv::fully_monomorphized();
@@ -300,7 +306,7 @@ pub fn create_ecx<'tcx>(
300306
// Setup first stack frame.
301307
let entry_instance = ty::Instance::mono(tcx, entry_id);
302308

303-
// First argument is constructed later, because it's skipped if the entry function uses #[start].
309+
// First argument is constructed later, because it's skipped for `miri_start.`
304310

305311
// Second argument (argc): length of `config.args`.
306312
let argc =
@@ -373,11 +379,9 @@ pub fn create_ecx<'tcx>(
373379
// Call start function.
374380

375381
match entry_type {
376-
EntryFnType::Main { .. } => {
382+
MiriEntryFnType::Rustc(EntryFnType::Main { .. }) => {
377383
let start_id = tcx.lang_items().start_fn().unwrap_or_else(|| {
378-
tcx.dcx().fatal(
379-
"could not find start function. Make sure the entry point is marked with `#[start]`."
380-
);
384+
tcx.dcx().fatal("could not find start lang item");
381385
});
382386
let main_ret_ty = tcx.fn_sig(entry_id).no_bound_vars().unwrap().output();
383387
let main_ret_ty = main_ret_ty.no_bound_vars().unwrap();
@@ -413,7 +417,7 @@ pub fn create_ecx<'tcx>(
413417
StackPopCleanup::Root { cleanup: true },
414418
)?;
415419
}
416-
EntryFnType::Start => {
420+
MiriEntryFnType::MiriStart => {
417421
ecx.call_function(
418422
entry_instance,
419423
ExternAbi::Rust,
@@ -434,7 +438,7 @@ pub fn create_ecx<'tcx>(
434438
pub fn eval_entry<'tcx>(
435439
tcx: TyCtxt<'tcx>,
436440
entry_id: DefId,
437-
entry_type: EntryFnType,
441+
entry_type: MiriEntryFnType,
438442
config: MiriConfig,
439443
) -> Option<i32> {
440444
// Copy setting before we move `config`.

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ pub use crate::diagnostics::{
135135
EvalContextExt as _, NonHaltingDiagnostic, TerminationInfo, report_error,
136136
};
137137
pub use crate::eval::{
138-
AlignmentCheck, BacktraceStyle, IsolatedOp, MiriConfig, RejectOpWith, ValidationMode,
139-
create_ecx, eval_entry,
138+
AlignmentCheck, BacktraceStyle, IsolatedOp, MiriConfig, MiriEntryFnType, RejectOpWith,
139+
ValidationMode, create_ecx, eval_entry,
140140
};
141141
pub use crate::helpers::{AccessKind, EvalContextExt as _};
142142
pub use crate::intrinsics::EvalContextExt as _;

test-cargo-miri/no-std-smoke/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copied from tests/pass/no-std.rs
22

3-
#![feature(start)]
43
#![no_std]
4+
#![no_main]
55

66
// Plumbing to let us use `writeln!` to host stdout:
77

@@ -22,8 +22,8 @@ impl Write for Host {
2222
}
2323
}
2424

25-
#[start]
26-
fn start(_: isize, _: *const *const u8) -> isize {
25+
#[no_mangle]
26+
fn miri_start(_: isize, _: *const *const u8) -> isize {
2727
writeln!(Host, "hello, world!").unwrap();
2828
0
2929
}

tests/fail/alloc/alloc_error_handler_custom.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//@compile-flags: -Cpanic=abort
2-
#![feature(start, core_intrinsics)]
2+
#![feature(core_intrinsics)]
33
#![feature(alloc_error_handler)]
44
#![feature(allocator_api)]
55
#![no_std]
6+
#![no_main]
67

78
extern crate alloc;
89

@@ -43,7 +44,7 @@ mod plumbing {
4344
static GLOBAL: NoAlloc = NoAlloc;
4445
}
4546

46-
#[start]
47-
fn start(_: isize, _: *const *const u8) -> isize {
47+
#[no_mangle]
48+
fn miri_start(_argc: isize, _argv: *const *const u8) -> isize {
4849
handle_alloc_error(Layout::for_value(&0));
4950
}

tests/fail/alloc/alloc_error_handler_custom.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | fn alloc_error_handler(layout: Layout) -> ! {
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717
= note: inside `alloc::alloc::handle_alloc_error::rt_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC
1818
= note: inside `alloc::alloc::handle_alloc_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC
19-
note: inside `start`
19+
note: inside `miri_start`
2020
--> tests/fail/alloc/alloc_error_handler_custom.rs:LL:CC
2121
|
2222
LL | handle_alloc_error(Layout::for_value(&0));

tests/fail/alloc/alloc_error_handler_no_std.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//@compile-flags: -Cpanic=abort
2-
#![feature(start, core_intrinsics)]
2+
#![feature(core_intrinsics)]
33
#![feature(alloc_error_handler)]
44
#![feature(allocator_api)]
55
#![no_std]
6+
#![no_main]
67

78
extern crate alloc;
89

@@ -41,7 +42,7 @@ mod plumbing {
4142
static GLOBAL: NoAlloc = NoAlloc;
4243
}
4344

44-
#[start]
45-
fn start(_: isize, _: *const *const u8) -> isize {
45+
#[no_mangle]
46+
fn miri_start(_argc: isize, _argv: *const *const u8) -> isize {
4647
handle_alloc_error(Layout::for_value(&0));
4748
}

tests/fail/alloc/alloc_error_handler_no_std.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LL | core::intrinsics::abort();
1212
= note: inside `alloc::alloc::__alloc_error_handler::__rdl_oom` at RUSTLIB/alloc/src/alloc.rs:LL:CC
1313
= note: inside `alloc::alloc::handle_alloc_error::rt_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC
1414
= note: inside `alloc::alloc::handle_alloc_error` at RUSTLIB/alloc/src/alloc.rs:LL:CC
15-
note: inside `start`
15+
note: inside `miri_start`
1616
--> tests/fail/alloc/alloc_error_handler_no_std.rs:LL:CC
1717
|
1818
LL | handle_alloc_error(Layout::for_value(&0));

tests/fail/alloc/no_global_allocator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
//@normalize-stderr-test: "OS `.*`" -> "$$OS"
33
// Make sure we pretend the allocation symbols don't exist when there is no allocator
44

5-
#![feature(start)]
65
#![no_std]
6+
#![no_main]
77

88
extern "Rust" {
99
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
1010
}
1111

12-
#[start]
13-
fn start(_: isize, _: *const *const u8) -> isize {
12+
#[no_mangle]
13+
fn miri_start(_argc: isize, _argv: *const *const u8) -> isize {
1414
unsafe {
1515
__rust_alloc(1, 1); //~ERROR: unsupported operation: can't call foreign function `__rust_alloc`
1616
}

0 commit comments

Comments
 (0)