@@ -120,7 +120,7 @@ impl Cursor {
120
120
for i in 0 ..num {
121
121
args. push ( Cursor { x : clang_Cursor_getArgument ( self . x , i as c_uint ) } ) ;
122
122
}
123
- return args;
123
+ args
124
124
}
125
125
}
126
126
@@ -140,7 +140,7 @@ impl Cursor {
140
140
extern fn visit_children ( cur : CXCursor , parent : CXCursor ,
141
141
data : CXClientData ) -> Enum_CXChildVisitResult {
142
142
let func: & mut Box < CursorVisitor > = unsafe { mem:: transmute ( data) } ;
143
- return ( * func) ( & Cursor { x : cur } , & Cursor { x : parent } ) ;
143
+ ( * func) ( & Cursor { x : cur } , & Cursor { x : parent } )
144
144
}
145
145
146
146
impl PartialEq for Cursor {
@@ -151,7 +151,7 @@ impl PartialEq for Cursor {
151
151
}
152
152
153
153
fn ne ( & self , other : & Cursor ) -> bool {
154
- return !self . eq ( other) ;
154
+ !self . eq ( other)
155
155
}
156
156
}
157
157
@@ -175,7 +175,7 @@ pub struct Type {
175
175
impl Type {
176
176
// common
177
177
pub fn kind ( & self ) -> Enum_CXTypeKind {
178
- return self . x . kind ;
178
+ self . x . kind
179
179
}
180
180
181
181
pub fn declaration ( & self ) -> Cursor {
@@ -245,7 +245,7 @@ impl Type {
245
245
for i in 0 ..num {
246
246
args. push ( Type { x : clang_getArgType ( self . x , i as c_uint ) } ) ;
247
247
}
248
- return args;
248
+ args
249
249
}
250
250
}
251
251
@@ -275,23 +275,22 @@ impl SourceLocation {
275
275
let mut col = 0 ;
276
276
let mut off = 0 ;
277
277
clang_getSpellingLocation ( self . x , & mut file, & mut line, & mut col, & mut off) ;
278
- return ( File { x : file } , line as usize , col as usize , off as usize ) ;
278
+ ( File { x : file } , line as usize , col as usize , off as usize )
279
279
}
280
280
}
281
281
}
282
282
283
283
impl fmt:: Display for SourceLocation {
284
284
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
285
285
let ( file, line, col, _) = self . location ( ) ;
286
- match file. is_null ( ) {
287
- false => {
288
- try!( file. name ( ) . fmt ( f) ) ;
289
- try!( ":" . fmt ( f) ) ;
290
- try!( line. fmt ( f) ) ;
291
- try!( ":" . fmt ( f) ) ;
292
- col. fmt ( f)
293
- } ,
294
- true => "builtin definitions" . fmt ( f)
286
+ if !file. is_null ( ) {
287
+ try!( file. name ( ) . fmt ( f) ) ;
288
+ try!( ":" . fmt ( f) ) ;
289
+ try!( line. fmt ( f) ) ;
290
+ try!( ":" . fmt ( f) ) ;
291
+ col. fmt ( f)
292
+ } else {
293
+ "builtin definitions" . fmt ( f)
295
294
}
296
295
}
297
296
}
@@ -304,7 +303,7 @@ pub struct File {
304
303
impl File {
305
304
pub fn name ( & self ) -> String {
306
305
if self . is_null ( ) {
307
- return "" . to_string ( ) ;
306
+ return "" . to_owned ( ) ;
308
307
}
309
308
unsafe {
310
309
String_ { x : clang_getFileName ( self . x ) } . to_string ( )
@@ -329,7 +328,7 @@ impl fmt::Display for String_ {
329
328
unsafe {
330
329
let c_str = clang_getCString ( self . x ) as * const c_char ;
331
330
let p = c_str as * const _ ;
332
- str:: from_utf8 ( CStr :: from_ptr ( p) . to_bytes ( ) ) . unwrap ( ) . to_string ( ) . fmt ( f)
331
+ str:: from_utf8 ( CStr :: from_ptr ( p) . to_bytes ( ) ) . unwrap ( ) . to_owned ( ) . fmt ( f)
333
332
}
334
333
}
335
334
}
@@ -371,10 +370,10 @@ pub struct TranslationUnit {
371
370
impl TranslationUnit {
372
371
pub fn parse ( ix : & Index , file : & str , cmd_args : & [ String ] ,
373
372
unsaved : & [ UnsavedFile ] , opts : :: libc:: c_uint ) -> TranslationUnit {
374
- let _fname = CString :: new ( file. as_bytes ( ) ) . unwrap ( ) ;
375
- let fname = _fname . as_ptr ( ) ;
376
- let _c_args : Vec < CString > = cmd_args. iter ( ) . map ( |s| CString :: new ( s. as_bytes ( ) ) . unwrap ( ) ) . collect ( ) ;
377
- let c_args: Vec < * const c_char > = _c_args . iter ( ) . map ( |s| s. as_ptr ( ) ) . collect ( ) ;
373
+ let fname = CString :: new ( file. as_bytes ( ) ) . unwrap ( ) ;
374
+ let fname = fname . as_ptr ( ) ;
375
+ let c_args : Vec < CString > = cmd_args. iter ( ) . map ( |s| CString :: new ( s. as_bytes ( ) ) . unwrap ( ) ) . collect ( ) ;
376
+ let c_args: Vec < * const c_char > = c_args . iter ( ) . map ( |s| s. as_ptr ( ) ) . collect ( ) ;
378
377
let mut c_unsaved: Vec < Struct_CXUnsavedFile > = unsaved. iter ( ) . map ( |f| f. x ) . collect ( ) ;
379
378
let tu = unsafe {
380
379
clang_parseTranslationUnit ( ix. x , fname,
@@ -405,7 +404,7 @@ impl TranslationUnit {
405
404
for i in 0 ..num {
406
405
diags. push ( Diagnostic { x : clang_getDiagnostic ( self . x , i as c_uint ) } ) ;
407
406
}
408
- return diags;
407
+ diags
409
408
}
410
409
}
411
410
@@ -443,7 +442,7 @@ impl TranslationUnit {
443
442
}
444
443
clang_disposeTokens ( self . x , token_ptr, num_tokens) ;
445
444
}
446
- return Some ( tokens) ;
445
+ Some ( tokens)
447
446
}
448
447
}
449
448
@@ -744,5 +743,5 @@ pub fn ast_dump(c: &Cursor, depth: isize)-> Enum_CXVisitorResult {
744
743
ast_dump ( s, depth + 1 )
745
744
} ) ;
746
745
print_indent ( depth, ")" ) ;
747
- return CXChildVisit_Continue ;
746
+ CXChildVisit_Continue
748
747
}
0 commit comments