Skip to content

Commit 2effeef

Browse files
nyurikemilio
authored andcommitted
Fix inconsistent_struct_constructor and ptr_as_ptr lints
1 parent 493fba9 commit 2effeef

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,13 @@ explicit_into_iter_loop = "allow"
6363
flat_map_option = "allow"
6464
ignored_unit_patterns = "allow"
6565
implicit_hasher = "allow"
66-
inconsistent_struct_constructor = "allow"
6766
items_after_statements = "allow"
6867
match_same_arms = "allow"
6968
maybe_infinite_iter = "allow"
7069
missing_errors_doc = "allow"
7170
missing_panics_doc = "allow"
7271
module_name_repetitions = "allow"
7372
must_use_candidate = "allow"
74-
ptr_as_ptr = "allow"
7573
redundant_closure_for_method_calls = "allow"
7674
return_self_not_must_use = "allow"
7775
similar_names = "allow"

bindgen/clang.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1045,9 +1045,7 @@ pub(crate) struct ClangToken {
10451045
impl ClangToken {
10461046
/// Get the token spelling, without being converted to utf-8.
10471047
pub(crate) fn spelling(&self) -> &[u8] {
1048-
let c_str = unsafe {
1049-
CStr::from_ptr(clang_getCString(self.spelling) as *const _)
1050-
};
1048+
let c_str = unsafe { CStr::from_ptr(clang_getCString(self.spelling)) };
10511049
c_str.to_bytes()
10521050
}
10531051

@@ -1098,9 +1096,9 @@ impl Iterator for ClangTokenIterator<'_> {
10981096
let spelling = clang_getTokenSpelling(self.tu, *raw);
10991097
let extent = clang_getTokenExtent(self.tu, *raw);
11001098
Some(ClangToken {
1101-
kind,
1102-
extent,
11031099
spelling,
1100+
extent,
1101+
kind,
11041102
})
11051103
}
11061104
}
@@ -1124,7 +1122,7 @@ extern "C" fn visit_children<Visitor>(
11241122
where
11251123
Visitor: FnMut(Cursor) -> CXChildVisitResult,
11261124
{
1127-
let func: &mut Visitor = unsafe { &mut *(data as *mut Visitor) };
1125+
let func: &mut Visitor = unsafe { &mut *data.cast::<Visitor>() };
11281126
let child = Cursor { x: cur };
11291127

11301128
(*func)(child)
@@ -1763,7 +1761,7 @@ fn cxstring_to_string_leaky(s: CXString) -> String {
17631761
if s.data.is_null() {
17641762
return String::new();
17651763
}
1766-
let c_str = unsafe { CStr::from_ptr(clang_getCString(s) as *const _) };
1764+
let c_str = unsafe { CStr::from_ptr(clang_getCString(s)) };
17671765
c_str.to_string_lossy().into_owned()
17681766
}
17691767

0 commit comments

Comments
 (0)