Skip to content

Commit 2888707

Browse files
committed
Auto merge of #3741 - rust-lang:rustup-2024-07-09, r=RalfJung
Automatic Rustup
2 parents 521422a + 7ac5cab commit 2888707

13 files changed

+121
-13
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
51917e2e69702e5752bce6a4f3bfd285d0f4ae39
1+
99b7134389e9766462601a2fc4013840b9d31745

src/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
14551455
ecx: &mut InterpCx<'tcx, Self>,
14561456
frame: Frame<'tcx, Provenance, FrameExtra<'tcx>>,
14571457
unwinding: bool,
1458-
) -> InterpResult<'tcx, StackPopJump> {
1458+
) -> InterpResult<'tcx, ReturnAction> {
14591459
if frame.extra.is_user_relevant {
14601460
// All that we store is whether or not the frame we just removed is local, so now we
14611461
// have no idea where the next topmost local frame is. So we recompute it.

src/shims/panic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
113113
&mut self,
114114
mut extra: FrameExtra<'tcx>,
115115
unwinding: bool,
116-
) -> InterpResult<'tcx, StackPopJump> {
116+
) -> InterpResult<'tcx, ReturnAction> {
117117
let this = self.eval_context_mut();
118118
trace!("handle_stack_pop_unwind(extra = {:?}, unwinding = {})", extra, unwinding);
119119

@@ -150,9 +150,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
150150
)?;
151151

152152
// We pushed a new stack frame, the engine should not do any jumping now!
153-
Ok(StackPopJump::NoJump)
153+
Ok(ReturnAction::NoJump)
154154
} else {
155-
Ok(StackPopJump::Normal)
155+
Ok(ReturnAction::Normal)
156156
}
157157
}
158158

tests/fail/tail_calls/cc-mismatch.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@error-in-other-file: Undefined Behavior: calling a function with calling convention C using calling convention Rust
2+
#![feature(explicit_tail_calls)]
3+
#![allow(incomplete_features)]
4+
5+
fn main() {
6+
let f = unsafe { std::mem::transmute::<extern "C" fn(), fn()>(f) };
7+
become f();
8+
}
9+
10+
extern "C" fn f() {}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: Undefined Behavior: calling a function with calling convention C using calling convention Rust
2+
--> RUSTLIB/core/src/ops/function.rs:LL:CC
3+
|
4+
LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calling a function with calling convention C using calling convention Rust
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at RUSTLIB/core/src/ops/function.rs:LL:CC
11+
= note: inside `std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
12+
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
13+
= note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at RUSTLIB/core/src/ops/function.rs:LL:CC
14+
= note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panicking.rs:LL:CC
15+
= note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at RUSTLIB/std/src/panicking.rs:LL:CC
16+
= note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at RUSTLIB/std/src/panic.rs:LL:CC
17+
= note: inside closure at RUSTLIB/std/src/rt.rs:LL:CC
18+
= note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#2}}, isize>` at RUSTLIB/std/src/panicking.rs:LL:CC
19+
= note: inside `std::panicking::r#try::<isize, {closure@std::rt::lang_start_internal::{closure#2}}>` at RUSTLIB/std/src/panicking.rs:LL:CC
20+
= note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#2}}, isize>` at RUSTLIB/std/src/panic.rs:LL:CC
21+
= note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC
22+
= note: inside `std::rt::lang_start::<()>` at RUSTLIB/std/src/rt.rs:LL:CC
23+
24+
error: aborting due to 1 previous error
25+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(explicit_tail_calls)]
2+
#![allow(incomplete_features)]
3+
4+
fn main() {
5+
// FIXME(explicit_tail_calls):
6+
// the error should point to `become g(x)`,
7+
// but tail calls mess up the backtrace it seems like...
8+
f(0);
9+
//~^ error: Undefined Behavior: calling a function with argument of type i32 passing data of type u32
10+
}
11+
12+
fn f(x: u32) {
13+
let g = unsafe { std::mem::transmute::<fn(i32), fn(u32)>(g) };
14+
become g(x);
15+
}
16+
17+
fn g(_: i32) {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error: Undefined Behavior: calling a function with argument of type i32 passing data of type u32
2+
--> $DIR/signature-mismatch-arg.rs:LL:CC
3+
|
4+
LL | f(0);
5+
| ^^^^ calling a function with argument of type i32 passing data of type u32
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= help: this means these two types are not *guaranteed* to be ABI-compatible across all targets
10+
= help: if you think this code should be accepted anyway, please report an issue with Miri
11+
= note: BACKTRACE:
12+
= note: inside `main` at $DIR/signature-mismatch-arg.rs:LL:CC
13+
14+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
15+
16+
error: aborting due to 1 previous error
17+

tests/pass/intptrcast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn cast_dangling() {
3535
fn format() {
3636
// Pointer string formatting! We can't check the output as it changes when libstd changes,
3737
// but we can make sure Miri does not error.
38-
format!("{:?}", &mut 13 as *mut _);
38+
let _ = format!("{:?}", &mut 13 as *mut _);
3939
}
4040

4141
fn transmute() {
@@ -52,7 +52,7 @@ fn ptr_bitops1() {
5252
let one = bytes.as_ptr().wrapping_offset(1);
5353
let three = bytes.as_ptr().wrapping_offset(3);
5454
let res = (one as usize) | (three as usize);
55-
format!("{}", res);
55+
let _ = format!("{}", res);
5656
}
5757

5858
fn ptr_bitops2() {

tests/pass/packed_struct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn test_derive() {
138138
assert_eq!(x.partial_cmp(&y).unwrap(), x.cmp(&y));
139139
x.hash(&mut DefaultHasher::new());
140140
P::default();
141-
format!("{:?}", x);
141+
let _ = format!("{:?}", x);
142142
}
143143

144144
fn main() {

tests/pass/shims/fs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn test_errors() {
202202
// Opening a non-existing file should fail with a "not found" error.
203203
assert_eq!(ErrorKind::NotFound, File::open(&path).unwrap_err().kind());
204204
// Make sure we can also format this.
205-
format!("{0}: {0:?}", File::open(&path).unwrap_err());
205+
let _ = format!("{0}: {0:?}", File::open(&path).unwrap_err());
206206
// Removing a non-existing file should fail with a "not found" error.
207207
assert_eq!(ErrorKind::NotFound, remove_file(&path).unwrap_err().kind());
208208
// Reading the metadata of a non-existing file should fail with a "not found" error.
@@ -301,5 +301,5 @@ fn test_from_raw_os_error() {
301301
let error = Error::from_raw_os_error(code);
302302
assert!(matches!(error.kind(), ErrorKind::Uncategorized));
303303
// Make sure we can also format this.
304-
format!("{error:?}");
304+
let _ = format!("{error:?}");
305305
}

tests/pass/shims/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ fn main() {
1515
panic!("unsupported OS")
1616
};
1717
let err = io::Error::from_raw_os_error(raw_os_error);
18-
format!("{err}: {err:?}");
18+
let _ = format!("{err}: {err:?}");
1919
}

tests/pass/tail_call.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#![allow(incomplete_features)]
2+
#![feature(explicit_tail_calls)]
3+
4+
fn main() {
5+
assert_eq!(factorial(10), 3_628_800);
6+
assert_eq!(mutually_recursive_identity(1000), 1000);
7+
}
8+
9+
fn factorial(n: u32) -> u32 {
10+
fn factorial_acc(n: u32, acc: u32) -> u32 {
11+
match n {
12+
0 => acc,
13+
_ => become factorial_acc(n - 1, acc * n),
14+
}
15+
}
16+
17+
factorial_acc(n, 1)
18+
}
19+
20+
// this is of course very silly, but we need to demonstrate mutual recursion somehow so...
21+
fn mutually_recursive_identity(x: u32) -> u32 {
22+
fn switch(src: u32, tgt: u32) -> u32 {
23+
match src {
24+
0 => tgt,
25+
_ if src % 7 == 0 => become advance_with_extra_steps(src, tgt),
26+
_ => become advance(src, tgt),
27+
}
28+
}
29+
30+
fn advance(src: u32, tgt: u32) -> u32 {
31+
become switch(src - 1, tgt + 1)
32+
}
33+
34+
fn advance_with_extra_steps(src: u32, tgt: u32) -> u32 {
35+
become advance(src, tgt)
36+
}
37+
38+
switch(x, 0)
39+
}

tests/pass/vecdeque.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ fn main() {
3131
}
3232

3333
// Regression test for Debug impl's
34-
format!("{:?} {:?}", dst, dst.iter());
35-
format!("{:?}", VecDeque::<u32>::new().iter());
34+
let _ = format!("{:?} {:?}", dst, dst.iter());
35+
let _ = format!("{:?}", VecDeque::<u32>::new().iter());
3636

3737
for a in dst {
3838
assert_eq!(*a, 2);

0 commit comments

Comments
 (0)