@@ -69,11 +69,9 @@ pub fn demangle(mut s: &str) -> Demangle {
69
69
let llvm = ".llvm." ;
70
70
if let Some ( i) = s. find ( llvm) {
71
71
let candidate = & s[ i + llvm. len ( ) ..] ;
72
- let all_hex = candidate. chars ( ) . all ( |c| {
73
- match c {
74
- 'A' ... 'F' | '0' ... '9' | '@' => true ,
75
- _ => false ,
76
- }
72
+ let all_hex = candidate. chars ( ) . all ( |c| match c {
73
+ 'A' ...'F' | '0' ...'9' | '@' => true ,
74
+ _ => false ,
77
75
} ) ;
78
76
79
77
if all_hex {
@@ -162,20 +160,18 @@ fn is_symbol_like(s: &str) -> bool {
162
160
// Copied from the documentation of `char::is_ascii_alphanumeric`
163
161
fn is_ascii_alphanumeric ( c : char ) -> bool {
164
162
match c {
165
- '\u{0041}' ... '\u{005A}' |
166
- '\u{0061}' ... '\u{007A}' |
167
- '\u{0030}' ... '\u{0039}' => true ,
163
+ '\u{0041}' ...'\u{005A}' | '\u{0061}' ...'\u{007A}' | '\u{0030}' ...'\u{0039}' => true ,
168
164
_ => false ,
169
165
}
170
166
}
171
167
172
168
// Copied from the documentation of `char::is_ascii_punctuation`
173
169
fn is_ascii_punctuation ( c : char ) -> bool {
174
170
match c {
175
- '\u{0021}' ... '\u{002F}' |
176
- '\u{003A}' ... '\u{0040}' |
177
- '\u{005B}' ... '\u{0060}' |
178
- '\u{007B}' ... '\u{007E}' => true ,
171
+ '\u{0021}' ...'\u{002F}'
172
+ | '\u{003A}' ...'\u{0040}'
173
+ | '\u{005B}' ...'\u{0060}'
174
+ | '\u{007B}' ...'\u{007E}' => true ,
179
175
_ => false ,
180
176
}
181
177
}
@@ -184,12 +180,8 @@ impl<'a> fmt::Display for Demangle<'a> {
184
180
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
185
181
match self . style {
186
182
None => try!( f. write_str ( self . original ) ) ,
187
- Some ( DemangleStyle :: Legacy ( ref d) ) => {
188
- try!( fmt:: Display :: fmt ( d, f) )
189
- }
190
- Some ( DemangleStyle :: V0 ( ref d) ) => {
191
- try!( fmt:: Display :: fmt ( d, f) )
192
- }
183
+ Some ( DemangleStyle :: Legacy ( ref d) ) => try!( fmt:: Display :: fmt ( d, f) ) ,
184
+ Some ( DemangleStyle :: V0 ( ref d) ) => try!( fmt:: Display :: fmt ( d, f) ) ,
193
185
}
194
186
f. write_str ( self . suffix )
195
187
}
@@ -206,23 +198,27 @@ mod tests {
206
198
use std:: prelude:: v1:: * ;
207
199
208
200
macro_rules! t {
209
- ( $a: expr, $b: expr) => ( assert!( ok( $a, $b) ) )
201
+ ( $a: expr, $b: expr) => {
202
+ assert!( ok( $a, $b) )
203
+ } ;
210
204
}
211
205
212
206
macro_rules! t_err {
213
- ( $a: expr) => ( assert!( ok_err( $a) ) )
207
+ ( $a: expr) => {
208
+ assert!( ok_err( $a) )
209
+ } ;
214
210
}
215
211
216
212
macro_rules! t_nohash {
217
- ( $a: expr, $b: expr) => ( {
213
+ ( $a: expr, $b: expr) => { {
218
214
assert_eq!( format!( "{:#}" , super :: demangle( $a) ) , $b) ;
219
- } )
215
+ } } ;
220
216
}
221
217
222
218
fn ok ( sym : & str , expected : & str ) -> bool {
223
219
match super :: try_demangle ( sym) {
224
220
Ok ( s) => {
225
- if s. to_string ( ) == expected {
221
+ if s. to_string ( ) == expected {
226
222
true
227
223
} else {
228
224
println ! ( "\n {}\n !=\n {}\n " , s, expected) ;
@@ -269,10 +265,12 @@ mod tests {
269
265
t ! ( "_ZN12test$BP$test4foobE" , "test*test::foob" ) ;
270
266
}
271
267
272
-
273
268
#[ test]
274
269
fn demangle_osx ( ) {
275
- t ! ( "__ZN5alloc9allocator6Layout9for_value17h02a996811f781011E" , "alloc::allocator::Layout::for_value::h02a996811f781011" ) ;
270
+ t ! (
271
+ "__ZN5alloc9allocator6Layout9for_value17h02a996811f781011E" ,
272
+ "alloc::allocator::Layout::for_value::h02a996811f781011"
273
+ ) ;
276
274
t ! ( "__ZN38_$LT$core..option..Option$LT$T$GT$$GT$6unwrap18_MSG_FILE_LINE_COL17haf7cb8d5824ee659E" , "<core::option::Option<T>>::unwrap::_MSG_FILE_LINE_COL::haf7cb8d5824ee659" ) ;
277
275
t ! ( "__ZN4core5slice89_$LT$impl$u20$core..iter..traits..IntoIterator$u20$for$u20$$RF$$u27$a$u20$$u5b$T$u5d$$GT$9into_iter17h450e234d27262170E" , "core::slice::<impl core::iter::traits::IntoIterator for &'a [T]>::into_iter::h450e234d27262170" ) ;
278
276
}
@@ -293,8 +291,10 @@ mod tests {
293
291
294
292
#[ test]
295
293
fn demangle_trait_impls ( ) {
296
- t ! ( "_ZN71_$LT$Test$u20$$u2b$$u20$$u27$static$u20$as$u20$foo..Bar$LT$Test$GT$$GT$3barE" ,
297
- "<Test + 'static as foo::Bar<Test>>::bar" ) ;
294
+ t ! (
295
+ "_ZN71_$LT$Test$u20$$u2b$$u20$$u27$static$u20$as$u20$foo..Bar$LT$Test$GT$$GT$3barE" ,
296
+ "<Test + 'static as foo::Bar<Test>>::bar"
297
+ ) ;
298
298
}
299
299
300
300
#[ test]
@@ -327,7 +327,10 @@ mod tests {
327
327
// One element, no hash.
328
328
t ! ( "_ZN3fooE.llvm.9D1C9369" , "foo" ) ;
329
329
t ! ( "_ZN3fooE.llvm.9D1C9369@@16" , "foo" ) ;
330
- t_nohash ! ( "_ZN9backtrace3foo17hbb467fcdaea5d79bE.llvm.A5310EB9" , "backtrace::foo" ) ;
330
+ t_nohash ! (
331
+ "_ZN9backtrace3foo17hbb467fcdaea5d79bE.llvm.A5310EB9" ,
332
+ "backtrace::foo"
333
+ ) ;
331
334
}
332
335
333
336
#[ test]
@@ -346,11 +349,14 @@ mod tests {
346
349
super :: demangle ( "_ZN2222222222222222222222EE" ) . to_string ( ) ;
347
350
super :: demangle ( "_ZN5*70527e27.ll34csaғE" ) . to_string ( ) ;
348
351
super :: demangle ( "_ZN5*70527a54.ll34_$b.1E" ) . to_string ( ) ;
349
- super :: demangle ( "\
350
- _ZN5~saäb4e\n \
351
- 2734cOsbE\n \
352
- 5usage20h)3\0 \0 \0 \0 \0 \0 \0 7e2734cOsbE\
353
- ") . to_string ( ) ;
352
+ super :: demangle (
353
+ "\
354
+ _ZN5~saäb4e\n \
355
+ 2734cOsbE\n \
356
+ 5usage20h)3\0 \0 \0 \0 \0 \0 \0 7e2734cOsbE\
357
+ ",
358
+ )
359
+ . to_string ( ) ;
354
360
}
355
361
356
362
#[ test]
0 commit comments