These are chat archives for rust-lang/rust

30th
Dec 2016
Note that this function may not catch all panics in Rust. A panic in Rust is not always implemented via unwinding, but can be implemented by aborting the process as well
What are those panics that might abort the process?
Aleksey Kladov
@matklad
Dec 30 2016 12:03
@matanelevi you can configure panic strategy during compilation. The default is to unwind the stack, but it may be set to aborting the process without unwinding, or to the infinite loop.
Andrey Lesnikov
@ozkriff
Dec 30 2016 12:03
Aleksey Kladov
@matklad
Dec 30 2016 12:04
That is, panic type is configured when compiling the final binary, I don't think you can usually have both aborting and unwinding panics in the same binary.
Matanel Levi
@matanelevi
Dec 30 2016 12:05
@matklad @ozkriff Cool, so if this isn't set, all panics are unwinding panics? so catch_unwind would caught all panics?
Aleksey Kladov
@matklad
Dec 30 2016 12:06
Yep, but there are some cases where Rust would just abort without panicking (panic in destructor during another panic causes abort IIRC, and OOM can lead to abort sometime I believe).
Matanel Levi
@matanelevi
Dec 30 2016 12:08
@matklad Where it is documented? :D
Aleksey Kladov
@matklad
Dec 30 2016 12:08
Not sure about OOM, I've read it in some thread about handling OOMs in Rust...
Matanel Levi
@matanelevi
Dec 30 2016 12:10
@matklad thanks!
Aleksey Kladov
@matklad
Dec 30 2016 12:10
Here perhaps? https://github.com/rust-lang/rust/issues/27700#issuecomment-244504584 (an interesting comment anyways!)
Matanel Levi
@matanelevi
Dec 30 2016 18:50
A question about println!(..) - how rustc knows where it's definition comes from?
Aleksey Kladov
@matklad
Dec 30 2016 19:21
and is #[macto_export]ed from std
In Rust, macros use completely different resolution rules than the rest of the language: basically, macro is available in all code that textually follows the macro definion. Macros don't use modules either: there's just one global macro namespace.
So, because those macros are defined in std, and std is implicitly injected in the root module of your crate, all the code in your crate can use println!