Skip to content

a few lints, and avoid compiler warning #3001

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

Merged
merged 2 commits into from
Nov 29, 2024
Merged
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
11 changes: 4 additions & 7 deletions bindgen-tests/tests/quickchecking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
//! use quickcheck::{Arbitrary, Gen};
//! use quickchecking::fuzzers;
//!
//! fn main() {
//! let generate_range: usize = 10; // Determines things like the length of
//! // arbitrary vectors generated.
//! let header = fuzzers::HeaderC::arbitrary(
//! &mut Gen::new(generate_range));
//! println!("{}", header);
//! }
//! let generate_range: usize = 10; // Determines things like the length of
//! // arbitrary vectors generated.
//! let header = fuzzers::HeaderC::arbitrary(&mut Gen::new(generate_range));
//! println!("{}", header);
//! ```
#![deny(missing_docs)]

Expand Down
4 changes: 2 additions & 2 deletions bindgen/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ impl<'a> RawTokens<'a> {
}
}

impl<'a> Drop for RawTokens<'a> {
impl Drop for RawTokens<'_> {
fn drop(&mut self) {
if !self.tokens.is_null() {
unsafe {
Expand Down Expand Up @@ -1090,7 +1090,7 @@ pub(crate) struct ClangTokenIterator<'a> {
raw: slice::Iter<'a, CXToken>,
}

impl<'a> Iterator for ClangTokenIterator<'a> {
impl Iterator for ClangTokenIterator<'_> {
type Item = ClangToken;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
4 changes: 2 additions & 2 deletions bindgen/codegen/impl_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(crate) trait ImplDebug<'a> {
) -> Option<(String, Vec<proc_macro2::TokenStream>)>;
}

impl<'a> ImplDebug<'a> for FieldData {
impl ImplDebug<'_> for FieldData {
type Extra = ();

fn impl_debug(
Expand All @@ -80,7 +80,7 @@ impl<'a> ImplDebug<'a> for FieldData {
}
}

impl<'a> ImplDebug<'a> for BitfieldUnit {
impl ImplDebug<'_> for BitfieldUnit {
type Extra = ();

fn impl_debug(
Expand Down
18 changes: 9 additions & 9 deletions bindgen/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,15 @@ impl<'a> CodegenResult<'a> {
}
}

impl<'a> ops::Deref for CodegenResult<'a> {
impl ops::Deref for CodegenResult<'_> {
type Target = Vec<proc_macro2::TokenStream>;

fn deref(&self) -> &Self::Target {
&self.items
}
}

impl<'a> ops::DerefMut for CodegenResult<'a> {
impl ops::DerefMut for CodegenResult<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.items
}
Expand Down Expand Up @@ -727,7 +727,7 @@ impl CodeGenerator for Var {
if let Some(cstr) = cstr {
let cstr_ty = quote! { ::#prefix::ffi::CStr };
if rust_features.literal_cstr {
let cstr = proc_macro2::Literal::c_string(&cstr);
let cstr = proc_macro2::Literal::c_string(cstr);
result.push(quote! {
#(#attrs)*
pub const #canonical_ident: &#cstr_ty = #cstr;
Expand Down Expand Up @@ -1165,7 +1165,7 @@ impl<'a> Vtable<'a> {
}
}

impl<'a> CodeGenerator for Vtable<'a> {
impl CodeGenerator for Vtable<'_> {
type Extra = Item;
type Return = ();

Expand Down Expand Up @@ -1243,13 +1243,13 @@ impl<'a> CodeGenerator for Vtable<'a> {
}
}

impl<'a> ItemCanonicalName for Vtable<'a> {
impl ItemCanonicalName for Vtable<'_> {
fn canonical_name(&self, ctx: &BindgenContext) -> String {
format!("{}__bindgen_vtable", self.item_id.canonical_name(ctx))
}
}

impl<'a> TryToRustTy for Vtable<'a> {
impl TryToRustTy for Vtable<'_> {
type Extra = ();

fn try_to_rust_ty(
Expand Down Expand Up @@ -1375,7 +1375,7 @@ trait FieldCodegen<'a> {
M: Extend<proc_macro2::TokenStream>;
}

impl<'a> FieldCodegen<'a> for Field {
impl FieldCodegen<'_> for Field {
type Extra = ();

fn codegen<F, M>(
Expand Down Expand Up @@ -1453,7 +1453,7 @@ fn wrap_union_field_if_needed(
}
}

impl<'a> FieldCodegen<'a> for FieldData {
impl FieldCodegen<'_> for FieldData {
type Extra = ();

fn codegen<F, M>(
Expand Down Expand Up @@ -1713,7 +1713,7 @@ fn compute_visibility(
})
}

impl<'a> FieldCodegen<'a> for BitfieldUnit {
impl FieldCodegen<'_> for BitfieldUnit {
type Extra = ();

fn codegen<F, M>(
Expand Down
2 changes: 1 addition & 1 deletion bindgen/codegen/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl<'a> CSerialize<'a> for Function {
}
}

impl<'a> CSerialize<'a> for TypeId {
impl CSerialize<'_> for TypeId {
type Extra = ();

fn serialize<W: Write>(
Expand Down
6 changes: 2 additions & 4 deletions bindgen/ir/analysis/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn consider_edge_default(kind: EdgeKind) -> bool {
}
}

impl<'ctx> CannotDerive<'ctx> {
impl CannotDerive<'_> {
fn insert<Id: Into<ItemId>>(
&mut self,
id: Id,
Expand Down Expand Up @@ -217,9 +217,7 @@ impl<'ctx> CannotDerive<'ctx> {
TypeKind::Reference(..) |
TypeKind::ObjCInterface(..) |
TypeKind::ObjCId |
TypeKind::ObjCSel => {
return self.derive_trait.can_derive_simple(ty.kind());
}
TypeKind::ObjCSel => self.derive_trait.can_derive_simple(ty.kind()),
TypeKind::Pointer(inner) => {
let inner_type =
self.ctx.resolve_type(inner).canonical_type(self.ctx);
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/has_destructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub(crate) struct HasDestructorAnalysis<'ctx> {
dependencies: HashMap<ItemId, Vec<ItemId>>,
}

impl<'ctx> HasDestructorAnalysis<'ctx> {
impl HasDestructorAnalysis<'_> {
fn consider_edge(kind: EdgeKind) -> bool {
// These are the only edges that can affect whether a type has a
// destructor or not.
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/has_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub(crate) struct HasFloat<'ctx> {
dependencies: HashMap<ItemId, Vec<ItemId>>,
}

impl<'ctx> HasFloat<'ctx> {
impl HasFloat<'_> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
EdgeKind::BaseMember |
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/has_type_param_in_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub(crate) struct HasTypeParameterInArray<'ctx> {
dependencies: HashMap<ItemId, Vec<ItemId>>,
}

impl<'ctx> HasTypeParameterInArray<'ctx> {
impl HasTypeParameterInArray<'_> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// These are the only edges that can affect whether a type has type parameter
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/has_vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub(crate) struct HasVtableAnalysis<'ctx> {
dependencies: HashMap<ItemId, Vec<ItemId>>,
}

impl<'ctx> HasVtableAnalysis<'ctx> {
impl HasVtableAnalysis<'_> {
fn consider_edge(kind: EdgeKind) -> bool {
// These are the only edges that can affect whether a type has a
// vtable or not.
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ mod tests {
type Extra = &'a Graph;
type Output = HashMap<Node, HashSet<Node>>;

fn new(graph: &'a Graph) -> ReachableFrom {
fn new(graph: &'a Graph) -> Self {
let reversed = graph.reverse();
ReachableFrom {
reachable: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/sizedness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub(crate) struct SizednessAnalysis<'ctx> {
sized: HashMap<TypeId, SizednessResult>,
}

impl<'ctx> SizednessAnalysis<'ctx> {
impl SizednessAnalysis<'_> {
fn consider_edge(kind: EdgeKind) -> bool {
// These are the only edges that can affect whether a type is
// zero-sized or not.
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/analysis/template_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub(crate) struct UsedTemplateParameters<'ctx> {
allowlisted_items: HashSet<ItemId>,
}

impl<'ctx> UsedTemplateParameters<'ctx> {
impl UsedTemplateParameters<'_> {
fn consider_edge(kind: EdgeKind) -> bool {
match kind {
// For each of these kinds of edges, if the referent uses a template
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ struct AllowlistedItemsTraversal<'ctx> {
traversal: ItemTraversal<'ctx, ItemSet, Vec<ItemId>>,
}

impl<'ctx> Iterator for AllowlistedItemsTraversal<'ctx> {
impl Iterator for AllowlistedItemsTraversal<'_> {
type Item = ItemId;

fn next(&mut self) -> Option<ItemId> {
Expand Down
2 changes: 1 addition & 1 deletion bindgen/ir/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl<'a> ItemAncestorsIter<'a> {
}
}

impl<'a> Iterator for ItemAncestorsIter<'a> {
impl Iterator for ItemAncestorsIter<'_> {
type Item = ItemId;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion bindgen/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a> Timer<'a> {
}
}

impl<'a> Drop for Timer<'a> {
impl Drop for Timer<'_> {
fn drop(&mut self) {
self.print_elapsed();
}
Expand Down
Loading