16
16
//! interface for failure is:
17
17
//!
18
18
//! ```ignore
19
- //! fn begin_unwind (fmt: &fmt::Arguments, &(&'static str, uint)) -> !;
19
+ //! fn fail_impl (fmt: &fmt::Arguments, &(&'static str, uint)) -> !;
20
20
//! ```
21
21
//!
22
22
//! This definition allows for failing with any general message, but it does not
33
33
use fmt;
34
34
use intrinsics;
35
35
36
+ // NOTE: remove after next snapshot
37
+ #[ cfg( stage0) ]
36
38
#[ cold] #[ inline( never) ] // this is the slow path, always
37
39
#[ lang="fail_" ]
38
40
fn fail_ ( expr_file_line : & ( & ' static str , & ' static str , uint ) ) -> ! {
39
41
let ( expr, file, line) = * expr_file_line;
40
42
let ref file_line = ( file, line) ;
41
43
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) ;
43
58
} , "{}" , expr) ;
44
59
45
60
unsafe { intrinsics:: abort ( ) }
@@ -50,25 +65,33 @@ fn fail_(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
50
65
fn fail_bounds_check ( file_line : & ( & ' static str , uint ) ,
51
66
index : uint , len : uint ) -> ! {
52
67
format_args ! ( |args| -> ( ) {
53
- begin_unwind ( args, file_line) ;
68
+ fail_fmt ( args, file_line) ;
54
69
} , "index out of bounds: the len is {} but the index is {}" , len, index) ;
55
70
unsafe { intrinsics:: abort ( ) }
56
71
}
57
72
58
73
#[ 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)
61
76
}
62
77
63
78
#[ 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 ) ) -> ! {
65
80
#[ allow( ctypes) ]
66
81
extern {
82
+
83
+ // NOTE: remove after next snapshot
84
+ #[ cfg( stage0) ]
67
85
#[ lang = "begin_unwind" ]
68
- fn begin_unwind ( fmt : & fmt:: Arguments , file : & ' static str ,
86
+ fn fail_impl ( fmt : & fmt:: Arguments , file : & ' static str ,
69
87
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
+
70
94
}
71
95
let ( file, line) = * file_line;
72
- unsafe { begin_unwind ( fmt, file, line) }
96
+ unsafe { fail_impl ( fmt, file, line) }
73
97
}
74
-
0 commit comments