@@ -34,26 +34,55 @@ use fmt;
34
34
35
35
#[ cold] #[ inline( never) ] // this is the slow path, always
36
36
#[ lang="panic" ]
37
- pub fn panic ( expr_file_line : & ( & ' static str , & ' static str , uint ) ) -> ! {
37
+ #[ cfg( stage0) ]
38
+ pub fn panic ( expr_file_line : & ( & ' static str , & ' static str , usize ) ) -> ! {
39
+ let ( expr, file, line) = * expr_file_line;
40
+ panic_fmt ( format_args ! ( "{}" , expr) , & ( file, line) )
41
+ }
42
+ #[ cold] #[ inline( never) ] // this is the slow path, always
43
+ #[ lang="panic" ]
44
+ #[ cfg( not( stage0) ) ]
45
+ pub fn panic ( expr_file_line : & ( & ' static str , & ' static str , u32 ) ) -> ! {
38
46
let ( expr, file, line) = * expr_file_line;
39
47
panic_fmt ( format_args ! ( "{}" , expr) , & ( file, line) )
40
48
}
41
49
42
50
#[ cold] #[ inline( never) ]
43
51
#[ lang="panic_bounds_check" ]
44
- fn panic_bounds_check ( file_line : & ( & ' static str , uint ) ,
45
- index : uint , len : uint ) -> ! {
52
+ #[ cfg( stage0) ]
53
+ fn panic_bounds_check ( file_line : & ( & ' static str , usize ) ,
54
+ index : usize , len : usize ) -> ! {
55
+ panic_fmt ( format_args ! ( "index out of bounds: the len is {} but the index is {}" ,
56
+ len, index) , file_line)
57
+ }
58
+ #[ cold] #[ inline( never) ]
59
+ #[ lang="panic_bounds_check" ]
60
+ #[ cfg( not( stage0) ) ]
61
+ fn panic_bounds_check ( file_line : & ( & ' static str , u32 ) ,
62
+ index : usize , len : usize ) -> ! {
46
63
panic_fmt ( format_args ! ( "index out of bounds: the len is {} but the index is {}" ,
47
64
len, index) , file_line)
48
65
}
49
66
50
67
#[ cold] #[ inline( never) ]
51
- pub fn panic_fmt ( fmt : fmt:: Arguments , file_line : & ( & ' static str , uint ) ) -> ! {
68
+ #[ cfg( stage0) ]
69
+ pub fn panic_fmt ( fmt : fmt:: Arguments , file_line : & ( & ' static str , usize ) ) -> ! {
70
+ #[ allow( improper_ctypes) ]
71
+ extern {
72
+ #[ lang = "panic_fmt" ]
73
+ fn panic_impl ( fmt : fmt:: Arguments , file : & ' static str , line : uint ) -> !;
74
+ }
75
+ let ( file, line) = * file_line;
76
+ unsafe { panic_impl ( fmt, file, line as uint ) }
77
+ }
78
+ #[ cold] #[ inline( never) ]
79
+ #[ cfg( not( stage0) ) ]
80
+ pub fn panic_fmt ( fmt : fmt:: Arguments , file_line : & ( & ' static str , u32 ) ) -> ! {
52
81
#[ allow( improper_ctypes) ]
53
82
extern {
54
83
#[ lang = "panic_fmt" ]
55
84
fn panic_impl ( fmt : fmt:: Arguments , file : & ' static str , line : uint ) -> !;
56
85
}
57
86
let ( file, line) = * file_line;
58
- unsafe { panic_impl ( fmt, file, line) }
87
+ unsafe { panic_impl ( fmt, file, line as uint ) }
59
88
}
0 commit comments