Closed
Description
Rationale
- You get better errors on account of the
fail!()
expansion evaluatingfile!()
andline!()
in the caller rather than inside theunreachable
function. - You don't need to import something to get it, which means people are more likely to use unreachable!() when that is semantically what is intended, which makes the intent of code (and the errors in case of incorrectness of the unreachable assertion) much more obvious (at present it's distinctly easier to simply write
fail!()
).
Demonstration
With a function
fn main() {
::std::util::unreachable();
}
task <unnamed> failed at 'internal error: entered unreachable code', /home/chris/vc/rust/src/libstd/util.rs:132
With a macro
fn main() {
unreachable!();
}
task <unnamed> failed at 'internal error: entered unreachable code', myfile.rs:2
Metadata
Metadata
Assignees
Labels
No labels