Skip to content

Commit 7fa3764

Browse files
committed
.expect("msg") is formatted internally
Thanks to RalfJung rust-lang/rust#122984 (comment)
1 parent 26b4f4a commit 7fa3764

File tree

13 files changed

+54
-0
lines changed

13 files changed

+54
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

rust/05_sandbox/panics/expect_msg/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "expect_msg"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]

rust/05_sandbox/panics/expect_msg/e

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vim src/main.rs

rust/05_sandbox/panics/expect_msg/g

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
export RUST_BACKTRACE=1
4+
cargo clean; cargo run

rust/05_sandbox/panics/expect_msg/gmy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
cargo clean
3+
export RUSTC="$(realpath ./myrust)"
4+
#export RUST_BACKTRACE=1
5+
cargo run ; ec="$?"
6+
echo "exit code: $ec"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
export LD_LIBRARY_PATH="/var/tmp/portage/dev-lang/rust-1.75.0-r1/work/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage1/lib:/var/tmp/portage/dev-lang/rust-1.75.0-r1/work/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib"
4+
export RUSTC="/var/tmp/portage/dev-lang/rust-1.75.0-r1/work/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage1/bin/rustc"
5+
6+
/var/tmp/portage/dev-lang/rust-1.75.0-r1/work/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage1/bin/rustc "$@"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use std::fmt::{Display, self};
2+
3+
struct MyStruct;
4+
5+
impl Display for MyStruct {
6+
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
7+
None::<i32>.expect("oh snap");//FIXME: no message
8+
todo!();//ignore this, it's for return
9+
}
10+
}
11+
12+
fn main() {
13+
//None::<u32>.expect("unexpected None");// correctly shows
14+
let instance = MyStruct;
15+
assert!(false, "oh no, '{}' was unexpected", instance);
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../thread_local/forking_does_what
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../fork/global_count_after_fork_isnt_one
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../global_allocator/overriden_global_allocator
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../signals/sigabrt_catch_attempt

rust/05_sandbox/panics/tests

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../tests

0 commit comments

Comments
 (0)