mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 04:57:19 +00:00 
			
		
		
		
	 828bdc2c26
			
		
	
	
		828bdc2c26
		
	
	
	
	
		
			
			Change default panic handler message format.
This changes the default panic hook's message format from:
```
thread '{thread}' panicked at '{message}', {location}
```
to
```
thread '{thread}' panicked at {location}:
{message}
```
This puts the message on its own line without surrounding quotes, making it easiser to read. For example:
Before:
```
thread 'main' panicked at 'env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`', src/main.rs:4:6
```
After:
```
thread 'main' panicked at src/main.rs:4:6:
env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`
```
---
See this PR by `@nyurik,` which does that for only multi-line messages (specifically because of `assert_eq`): https://github.com/rust-lang/rust/pull/111071
This is the change that does that for *all* panic messages.
		
	
			
		
			
				
	
	
		
			22 lines
		
	
	
		
			828 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			828 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| // compile-flags: -Ztreat-err-as-bug=1
 | |
| // failure-status: 101
 | |
| // rustc-env:RUST_BACKTRACE=1
 | |
| // normalize-stderr-test "\nerror: .*unexpectedly panicked.*\n\n" -> ""
 | |
| // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> ""
 | |
| // normalize-stderr-test "note: compiler flags.*\n\n" -> ""
 | |
| // normalize-stderr-test "note: rustc.*running on.*\n\n" -> ""
 | |
| // normalize-stderr-test "thread.*panicked.*:\n.*\n" -> ""
 | |
| // normalize-stderr-test "stack backtrace:\n" -> ""
 | |
| // normalize-stderr-test "\s\d{1,}: .*\n" -> ""
 | |
| // normalize-stderr-test "\s at .*\n" -> ""
 | |
| // normalize-stderr-test ".*note: Some details.*\n" -> ""
 | |
| // normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> ""
 | |
| #![allow(unconditional_panic)]
 | |
| 
 | |
| const X: i32 = 1 / 0; //~ERROR constant
 | |
| 
 | |
| fn main() {
 | |
|     let x: &'static i32 = &X;
 | |
|     println!("x={}", x);
 | |
| }
 |