Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent_struct_constructor and ptr_as_ptr lints #3079

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading