You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Code location for assert!(false) is incorrect. #466
[main.assertion.1] line 6 assertion failed: false: FAILURE
Note that the MIR is correct:
> rustc dummy.rs --emit mir
> grep panic dummy.mir
core::panicking::panic(const "assertion failed: false"); // scope 0 at dummy.rs:7:9: 7:24
Root cause:
The assert!() macro is translated to if !cond { begin_panic; }. However, for assert!(false), rustc optimizes the generated code and it only emit a panic statement.
During RMC code generation of panic statements, we assume that if the basic block only has one predecessor, it is an assertion. There are many cases that this is not true. See this code.
Activity
[-]Code location for assert(false) is incorrect.[/-][+]Code location for `assert!(false)` is incorrect.[/+]celinval commentedon Oct 4, 2021
I was wondering if we can leverage the caller location described here: https://rustc-dev-guide.rust-lang.org/backend/implicit-caller-location.html
Fix assert!() and panic!() code generation.
Fix assert!() and panic!() code generation (#687)