Skip to content

Commit

Permalink
Fix inconsistent_struct_constructor and ptr_as_ptr lints
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Jan 9, 2025
1 parent 59a43e1 commit 3716c80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ explicit_into_iter_loop = "allow"
flat_map_option = "allow"
ignored_unit_patterns = "allow"
implicit_hasher = "allow"
inconsistent_struct_constructor = "allow"
items_after_statements = "allow"
maybe_infinite_iter = "allow"
missing_errors_doc = "allow"
missing_panics_doc = "allow"
module_name_repetitions = "allow"
must_use_candidate = "allow"
ptr_as_ptr = "allow"
redundant_closure_for_method_calls = "allow"
return_self_not_must_use = "allow"
#should_panic_without_expect = "allow"
Expand Down
12 changes: 5 additions & 7 deletions bindgen/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,9 +1045,7 @@ pub(crate) struct ClangToken {
impl ClangToken {
/// Get the token spelling, without being converted to utf-8.
pub(crate) fn spelling(&self) -> &[u8] {
let c_str = unsafe {
CStr::from_ptr(clang_getCString(self.spelling) as *const _)
};
let c_str = unsafe { CStr::from_ptr(clang_getCString(self.spelling)) };
c_str.to_bytes()
}

Expand Down Expand Up @@ -1098,9 +1096,9 @@ impl Iterator for ClangTokenIterator<'_> {
let spelling = clang_getTokenSpelling(self.tu, *raw);
let extent = clang_getTokenExtent(self.tu, *raw);
Some(ClangToken {
kind,
extent,
spelling,
extent,
kind,
})
}
}
Expand All @@ -1124,7 +1122,7 @@ extern "C" fn visit_children<Visitor>(
where
Visitor: FnMut(Cursor) -> CXChildVisitResult,
{
let func: &mut Visitor = unsafe { &mut *(data as *mut Visitor) };
let func: &mut Visitor = unsafe { &mut *data.cast::<Visitor>() };
let child = Cursor { x: cur };

(*func)(child)
Expand Down Expand Up @@ -1763,7 +1761,7 @@ fn cxstring_to_string_leaky(s: CXString) -> String {
if s.data.is_null() {
return String::new();
}
let c_str = unsafe { CStr::from_ptr(clang_getCString(s) as *const _) };
let c_str = unsafe { CStr::from_ptr(clang_getCString(s)) };
c_str.to_string_lossy().into_owned()
}

Expand Down

0 comments on commit 3716c80

Please sign in to comment.