Skip to content

Commit bfcc9e1

Browse files
committed
Merge pull request rust-lang#252 from mcarton/clippy
Cleanup some warnings from Clippy
2 parents 4caeda4 + 05922aa commit bfcc9e1

File tree

7 files changed

+222
-226
lines changed

7 files changed

+222
-226
lines changed

src/clang.rs

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl Cursor {
120120
for i in 0..num {
121121
args.push(Cursor { x: clang_Cursor_getArgument(self.x, i as c_uint) });
122122
}
123-
return args;
123+
args
124124
}
125125
}
126126

@@ -140,7 +140,7 @@ impl Cursor {
140140
extern fn visit_children(cur: CXCursor, parent: CXCursor,
141141
data: CXClientData) -> Enum_CXChildVisitResult {
142142
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 })
144144
}
145145

146146
impl PartialEq for Cursor {
@@ -151,7 +151,7 @@ impl PartialEq for Cursor {
151151
}
152152

153153
fn ne(&self, other: &Cursor) -> bool {
154-
return !self.eq(other);
154+
!self.eq(other)
155155
}
156156
}
157157

@@ -175,7 +175,7 @@ pub struct Type {
175175
impl Type {
176176
// common
177177
pub fn kind(&self) -> Enum_CXTypeKind {
178-
return self.x.kind;
178+
self.x.kind
179179
}
180180

181181
pub fn declaration(&self) -> Cursor {
@@ -245,7 +245,7 @@ impl Type {
245245
for i in 0..num {
246246
args.push(Type { x: clang_getArgType(self.x, i as c_uint) });
247247
}
248-
return args;
248+
args
249249
}
250250
}
251251

@@ -275,23 +275,22 @@ impl SourceLocation {
275275
let mut col = 0;
276276
let mut off = 0;
277277
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)
279279
}
280280
}
281281
}
282282

283283
impl fmt::Display for SourceLocation {
284284
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
285285
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)
295294
}
296295
}
297296
}
@@ -304,7 +303,7 @@ pub struct File {
304303
impl File {
305304
pub fn name(&self) -> String {
306305
if self.is_null() {
307-
return "".to_string();
306+
return "".to_owned();
308307
}
309308
unsafe {
310309
String_ { x: clang_getFileName(self.x) }.to_string()
@@ -329,7 +328,7 @@ impl fmt::Display for String_ {
329328
unsafe {
330329
let c_str = clang_getCString(self.x) as *const c_char;
331330
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)
333332
}
334333
}
335334
}
@@ -371,10 +370,10 @@ pub struct TranslationUnit {
371370
impl TranslationUnit {
372371
pub fn parse(ix: &Index, file: &str, cmd_args: &[String],
373372
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();
378377
let mut c_unsaved: Vec<Struct_CXUnsavedFile> = unsaved.iter().map(|f| f.x).collect();
379378
let tu = unsafe {
380379
clang_parseTranslationUnit(ix.x, fname,
@@ -405,7 +404,7 @@ impl TranslationUnit {
405404
for i in 0..num {
406405
diags.push(Diagnostic { x: clang_getDiagnostic(self.x, i as c_uint) });
407406
}
408-
return diags;
407+
diags
409408
}
410409
}
411410

@@ -443,7 +442,7 @@ impl TranslationUnit {
443442
}
444443
clang_disposeTokens(self.x, token_ptr, num_tokens);
445444
}
446-
return Some(tokens);
445+
Some(tokens)
447446
}
448447
}
449448

@@ -744,5 +743,5 @@ pub fn ast_dump(c: &Cursor, depth: isize)-> Enum_CXVisitorResult {
744743
ast_dump(s, depth + 1)
745744
});
746745
print_indent(depth, ")");
747-
return CXChildVisit_Continue;
746+
CXChildVisit_Continue
748747
}

src/clangll.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![allow(unused_attributes)]
66
#![allow(non_snake_case)]
77
#![allow(non_upper_case_globals)]
8-
#![allow(raw_pointer_derive)]
98

109
pub type ptrdiff_t = ::libc::c_long;
1110
pub type size_t = ::libc::c_ulong;

0 commit comments

Comments
 (0)