1616//! interface for failure is:
1717//!
1818//! ```ignore
19- //! fn begin_unwind (fmt: &fmt::Arguments, &(&'static str, uint)) -> !;
19+ //! fn fail_impl (fmt: &fmt::Arguments, &(&'static str, uint)) -> !;
2020//! ```
2121//!
2222//! This definition allows for failing with any general message, but it does not
3333use fmt;
3434use intrinsics;
3535
36+ // NOTE: remove after next snapshot
37+ #[ cfg( stage0) ]
3638#[ cold] #[ inline( never) ] // this is the slow path, always
3739#[ lang="fail_" ]
3840fn fail_ ( expr_file_line : & ( & ' static str , & ' static str , uint ) ) -> ! {
3941 let ( expr, file, line) = * expr_file_line;
4042 let ref file_line = ( file, line) ;
4143 format_args ! ( |args| -> ( ) {
42- begin_unwind( args, file_line) ;
44+ fail_fmt( args, file_line) ;
45+ } , "{}" , expr) ;
46+
47+ unsafe { intrinsics:: abort ( ) }
48+ }
49+
50+ #[ cfg( not( stage0) ) ]
51+ #[ cold] #[ inline( never) ] // this is the slow path, always
52+ #[ lang="fail" ]
53+ fn fail ( expr_file_line : & ( & ' static str , & ' static str , uint ) ) -> ! {
54+ let ( expr, file, line) = * expr_file_line;
55+ let ref file_line = ( file, line) ;
56+ format_args ! ( |args| -> ( ) {
57+ fail_fmt( args, file_line) ;
4358 } , "{}" , expr) ;
4459
4560 unsafe { intrinsics:: abort ( ) }
@@ -50,25 +65,33 @@ fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
5065fn fail_bounds_check ( file_line : & ( & ' static str , uint ) ,
5166 index : uint , len : uint ) -> ! {
5267 format_args ! ( |args| -> ( ) {
53- begin_unwind ( args, file_line) ;
68+ fail_fmt ( args, file_line) ;
5469 } , "index out of bounds: the len is {} but the index is {}" , len, index) ;
5570 unsafe { intrinsics:: abort ( ) }
5671}
5772
5873#[ cold] #[ inline( never) ]
59- pub fn begin_unwind_string ( msg : & str , file : & ( & ' static str , uint ) ) -> ! {
60- format_args ! ( |fmt| begin_unwind ( fmt, file) , "{}" , msg)
74+ pub fn fail_str ( msg : & str , file : & ( & ' static str , uint ) ) -> ! {
75+ format_args ! ( |fmt| fail_fmt ( fmt, file) , "{}" , msg)
6176}
6277
6378#[ cold] #[ inline( never) ]
64- pub fn begin_unwind ( fmt : & fmt:: Arguments , file_line : & ( & ' static str , uint ) ) -> ! {
79+ pub fn fail_fmt ( fmt : & fmt:: Arguments , file_line : & ( & ' static str , uint ) ) -> ! {
6580 #[ allow( ctypes) ]
6681 extern {
82+
83+ // NOTE: remove after next snapshot
84+ #[ cfg( stage0) ]
6785 #[ lang = "begin_unwind" ]
68- fn begin_unwind ( fmt : & fmt:: Arguments , file : & ' static str ,
86+ fn fail_impl ( fmt : & fmt:: Arguments , file : & ' static str ,
6987 line : uint ) -> !;
88+
89+ #[ cfg( not( stage0) ) ]
90+ #[ lang = "fail_fmt" ]
91+ fn fail_impl ( fmt : & fmt:: Arguments , file : & ' static str ,
92+ line : uint ) -> !;
93+
7094 }
7195 let ( file, line) = * file_line;
72- unsafe { begin_unwind ( fmt, file, line) }
96+ unsafe { fail_impl ( fmt, file, line) }
7397}
74-
0 commit comments