@@ -70,30 +70,39 @@ pub fn macro_registrar(register: |Name, SyntaxExtension|) {
70
70
71
71
//Check if the literal is valid (as LLVM expects),
72
72
//and return a descriptive error if not.
73
- fn hex_float_lit_err ( s : & str ) -> Option < ( uint , ~ str ) > {
73
+ fn hex_float_lit_err ( s : & str ) -> Option < ( uint , StrBuf ) > {
74
74
let mut chars = s. chars ( ) . peekable ( ) ;
75
75
let mut i = 0 ;
76
76
if chars. peek ( ) == Some ( & '-' ) { chars. next ( ) ; i+= 1 }
77
- if chars. next ( ) != Some ( '0' ) { return Some ( ( i, "Expected '0'" . to_owned ( ) ) ) ; } i+=1 ;
78
- if chars. next ( ) != Some ( 'x' ) { return Some ( ( i, "Expected 'x'" . to_owned ( ) ) ) ; } i+=1 ;
77
+ if chars. next ( ) != Some ( '0' ) {
78
+ return Some ( ( i, "Expected '0'" . to_strbuf ( ) ) ) ;
79
+ } i+=1 ;
80
+ if chars. next ( ) != Some ( 'x' ) {
81
+ return Some ( ( i, "Expected 'x'" . to_strbuf ( ) ) ) ;
82
+ } i+=1 ;
79
83
let mut d_len = 0 ;
80
84
for _ in chars. take_while ( |c| c. is_digit_radix ( 16 ) ) { chars. next ( ) ; i+=1 ; d_len += 1 ; }
81
- if chars. next ( ) != Some ( '.' ) { return Some ( ( i, "Expected '.'" . to_owned ( ) ) ) ; } i+=1 ;
85
+ if chars. next ( ) != Some ( '.' ) {
86
+ return Some ( ( i, "Expected '.'" . to_strbuf ( ) ) ) ;
87
+ } i+=1 ;
82
88
let mut f_len = 0 ;
83
89
for _ in chars. take_while ( |c| c. is_digit_radix ( 16 ) ) { chars. next ( ) ; i+=1 ; f_len += 1 ; }
84
90
if d_len == 0 && f_len == 0 {
85
- return Some ( ( i, "Expected digits before or after decimal point" . to_owned ( ) ) ) ;
91
+ return Some ( ( i, "Expected digits before or after decimal \
92
+ point". to_strbuf ( ) ) ) ;
86
93
}
87
- if chars. next ( ) != Some ( 'p' ) { return Some ( ( i, "Expected 'p'" . to_owned ( ) ) ) ; } i+=1 ;
94
+ if chars. next ( ) != Some ( 'p' ) {
95
+ return Some ( ( i, "Expected 'p'" . to_strbuf ( ) ) ) ;
96
+ } i+=1 ;
88
97
if chars. peek ( ) == Some ( & '-' ) { chars. next ( ) ; i+= 1 }
89
98
let mut e_len = 0 ;
90
99
for _ in chars. take_while ( |c| c. is_digit ( ) ) { chars. next ( ) ; i+=1 ; e_len += 1 }
91
100
if e_len == 0 {
92
- return Some ( ( i, "Expected exponent digits" . to_owned ( ) ) ) ;
101
+ return Some ( ( i, "Expected exponent digits" . to_strbuf ( ) ) ) ;
93
102
}
94
103
match chars. next ( ) {
95
104
None => None ,
96
- Some ( _) => Some ( ( i, "Expected end of string" . to_owned ( ) ) )
105
+ Some ( _) => Some ( ( i, "Expected end of string" . to_strbuf ( ) ) )
97
106
}
98
107
}
99
108
0 commit comments