Skip to content

Commit 3d55a27

Browse files
committed
Fix clippy warnings.
1 parent 68ec633 commit 3d55a27

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

bindgen/ir/context.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use crate::codegen::utils::{fnsig_argument_type, fnsig_return_ty_internal};
2626
use crate::codegen::CodegenError;
2727
use crate::BindgenOptions;
2828
use crate::{Entry, HashMap, HashSet};
29-
use clang_sys;
3029
use proc_macro2::{Ident, Span, TokenStream};
3130
use quote::ToTokens;
3231
use std::borrow::Cow;
@@ -1479,22 +1478,26 @@ If you encounter an error missing from this list, please file an issue or a PR!"
14791478
self.root_module
14801479
}
14811480

1482-
/// Resolve a type with the given id.
1481+
/// Resolve a type with the given ID.
14831482
///
14841483
/// Panics if there is no item for the given `TypeId` or if the resolved
14851484
/// item is not a `Type`.
14861485
pub(crate) fn resolve_type(&self, type_id: TypeId) -> &Type {
14871486
self.resolve_item(type_id).kind().expect_type()
14881487
}
14891488

1490-
/// Resolve a function with the given id.
1489+
/// Resolve a function with the given ID.
14911490
///
14921491
/// Panics if there is no item for the given `FunctionId` or if the resolved
14931492
/// item is not a `Function`.
14941493
pub(crate) fn resolve_func(&self, func_id: FunctionId) -> &Function {
14951494
self.resolve_item(func_id).kind().expect_function()
14961495
}
14971496

1497+
/// Resolve a function signature with the given ID.
1498+
///
1499+
/// Panics if there is no type for the given `TypeId` or if the resolved
1500+
/// `Type` is not a function.
14981501
pub(crate) fn resolve_sig(&self, sig_id: TypeId) -> &FunctionSig {
14991502
let signature = self.resolve_type(sig_id).canonical_type(self);
15001503
match *signature.kind() {
@@ -1504,9 +1507,9 @@ If you encounter an error missing from this list, please file an issue or a PR!"
15041507
}
15051508

15061509
/// Resolve the given `ItemId` as a type, or `None` if there is no item with
1507-
/// the given id.
1510+
/// the given ID.
15081511
///
1509-
/// Panics if the id resolves to an item that is not a type.
1512+
/// Panics if the ID resolves to an item that is not a type.
15101513
pub(crate) fn safe_resolve_type(&self, type_id: TypeId) -> Option<&Type> {
15111514
self.resolve_item_fallible(type_id)
15121515
.map(|t| t.kind().expect_type())
@@ -1523,7 +1526,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
15231526

15241527
/// Resolve the given `ItemId` into an `Item`.
15251528
///
1526-
/// Panics if the given id does not resolve to any item.
1529+
/// Panics if the given ID does not resolve to any item.
15271530
pub(crate) fn resolve_item<Id: Into<ItemId>>(&self, item_id: Id) -> &Item {
15281531
let item_id = item_id.into();
15291532
match self.resolve_item_fallible(item_id) {
@@ -2009,32 +2012,39 @@ If you encounter an error missing from this list, please file an issue or a PR!"
20092012
type_id
20102013
}
20112014

2015+
/// Add a function signature in order to look it up when generating macros.
20122016
pub(crate) fn add_function(&mut self, name: &str, sig: Function) {
20132017
self.functions.insert(name.to_owned(), sig);
20142018
}
20152019

2020+
/// Get a function signature by its name.
20162021
pub(crate) fn function(&self, name: &str) -> Option<&Function> {
20172022
self.functions.get(name)
20182023
}
20192024

2025+
/// Add a function-like macro.
20202026
pub(crate) fn add_fn_macro(&mut self, fn_macro: cmacro::FnMacro) {
20212027
self.function_macros
20222028
.insert(fn_macro.name.to_owned(), fn_macro);
20232029
}
20242030

2031+
/// Get a function-like macro by its name.
20252032
pub(crate) fn fn_macro(&self, name: &str) -> Option<&cmacro::FnMacro> {
20262033
self.function_macros.get(name)
20272034
}
20282035

2036+
/// Add a variable-like macro.
20292037
pub(crate) fn add_var_macro(&mut self, var_macro: cmacro::VarMacro) {
20302038
self.variable_macros
20312039
.insert(var_macro.name.to_owned(), var_macro);
20322040
}
20332041

2042+
/// Get a variable-like macro by its name.
20342043
pub(crate) fn var_macro(&self, name: &str) -> Option<&cmacro::VarMacro> {
20352044
self.variable_macros.get(name)
20362045
}
20372046

2047+
/// Get a type by its name.
20382048
pub(crate) fn type_by_name(&self, name: &str) -> Option<&TypeId> {
20392049
self.type_names.get(name)
20402050
}

bindgen/ir/function.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ use crate::callbacks::{ItemInfo, ItemKind};
1010
use crate::clang::{self, Attribute};
1111
use crate::parse::{ClangSubItemParser, ParseError, ParseResult};
1212
use clang_sys::{self, CXCallingConv};
13-
use proc_macro2;
14-
use quote;
1513
use quote::TokenStreamExt;
1614
use std::io;
1715
use std::str::FromStr;

bindgen/ir/item.rs

-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ use super::ty::{Type, TypeKind};
2020
use crate::clang;
2121
use crate::ir::{macro_def::MacroDef, var::Var};
2222
use crate::parse::{ClangSubItemParser, ParseError, ParseResult};
23-
use clang_sys;
2423
use lazycell::LazyCell;
25-
use regex;
2624
use std::cell::Cell;
2725
use std::collections::BTreeSet;
2826
use std::fmt::Write;

bindgen/ir/var.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub(crate) enum VarType {
2121
/// A floating point number.
2222
Float(f64),
2323
/// A character.
24+
#[allow(unused)]
2425
Char(u8),
2526
/// A string, not necessarily well-formed utf-8.
2627
String(Vec<u8>),

0 commit comments

Comments
 (0)