Skip to content

Commit 481d5f2

Browse files
committed
Fix clippy warnings.
1 parent 884ea7b commit 481d5f2

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

bindgen/ir/context.rs

Lines changed: 11 additions & 1 deletion
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;
@@ -1495,6 +1494,10 @@ If you encounter an error missing from this list, please file an issue or a PR!"
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() {
@@ -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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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)