rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.27k stars 12.71k forks source link

Suggest powershell syntax for setting RUST_BACKTRACE in the panic result on Windows #98379

Open kaleidawave opened 2 years ago

kaleidawave commented 2 years ago

Currently on Windows when a program panics and the default panic handler is run one of the lines it prints is: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

The problem is this is not the syntax that powershell (which I think is the default and largest shell used on Windows) uses to set environment variables.

I think note: `RUST_BACKTRACE=1` (or PowerShell `$env:RUST_BACKTRACE=1`) environment variable to display a backtrace would be more correct and better for beginners.

Should be pretty simple change adding a different cfg! branch for following code https://github.com/rust-lang/rust/blob/352e621368c31d7b4a6362e081586cdb931ba020/library/std/src/sys_common/backtrace.rs#L104-L110

gimbling-away commented 2 years ago

Powershell isn't only available on Windows, so checking the shell rather than the OS would be better. And on Windows, there is also cmd.exe, so the suggestion might be invalid for some people.

gimbling-away commented 2 years ago

@rustbot claim