Skip to content

Commit 5597df2

Browse files
committed
Fix a lot of unused_qualifications lints
1 parent 061cc5e commit 5597df2

File tree

16 files changed

+62
-75
lines changed

16 files changed

+62
-75
lines changed

bindgen-integration/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fn setup_macro_test() {
183183
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
184184
let out_rust_file = out_path.join("test.rs");
185185
let out_rust_file_relative = out_rust_file
186-
.strip_prefix(std::env::current_dir().unwrap().parent().unwrap())
186+
.strip_prefix(env::current_dir().unwrap().parent().unwrap())
187187
.unwrap();
188188
let out_dep_file = out_path.join("test.d");
189189

bindgen-tests/tests/tests.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ include!(concat!(env!("OUT_DIR"), "/tests.rs"));
371371
#[test]
372372
#[cfg_attr(target_os = "windows", ignore)]
373373
fn test_clang_env_args() {
374-
std::env::set_var(
374+
env::set_var(
375375
"BINDGEN_EXTRA_CLANG_ARGS",
376376
"-D_ENV_ONE=1 -D_ENV_TWO=\"2 -DNOT_THREE=1\"",
377377
);
@@ -653,8 +653,8 @@ fn emit_depfile() {
653653
builder.into_builder(check_roundtrip).unwrap();
654654
let _bindings = builder.generate().unwrap();
655655

656-
let observed = std::fs::read_to_string(observed_depfile).unwrap();
657-
let expected = std::fs::read_to_string(expected_depfile).unwrap();
656+
let observed = fs::read_to_string(observed_depfile).unwrap();
657+
let expected = fs::read_to_string(expected_depfile).unwrap();
658658
assert_eq!(observed.trim(), expected.trim());
659659
}
660660

@@ -694,7 +694,7 @@ fn dump_preprocessed_input() {
694694
);
695695
}
696696

697-
fn build_flags_output_helper(builder: &bindgen::Builder) {
697+
fn build_flags_output_helper(builder: &Builder) {
698698
let mut command_line_flags = builder.command_line_flags();
699699
command_line_flags.insert(0, "bindgen".to_string());
700700

@@ -712,7 +712,7 @@ fn build_flags_output_helper(builder: &bindgen::Builder) {
712712

713713
#[test]
714714
fn commandline_multiple_headers() {
715-
let bindings = bindgen::Builder::default()
715+
let bindings = Builder::default()
716716
.header("tests/headers/char.h")
717717
.header("tests/headers/func_ptr.h")
718718
.header("tests/headers/16-byte-alignment.h");

bindgen/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ fn main() {
2020
println!("cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS");
2121
println!(
2222
"cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_{}",
23-
std::env::var("TARGET").unwrap()
23+
env::var("TARGET").unwrap()
2424
);
2525
println!(
2626
"cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_{}",
27-
std::env::var("TARGET").unwrap().replace('-', "_")
27+
env::var("TARGET").unwrap().replace('-', "_")
2828
);
2929
}

bindgen/clang.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -961,13 +961,11 @@ impl Cursor {
961961
///
962962
/// Returns None if the cursor does not include a file, otherwise the file's full name
963963
pub(crate) fn get_included_file_name(&self) -> Option<String> {
964-
let file = unsafe { clang_sys::clang_getIncludedFile(self.x) };
964+
let file = unsafe { clang_getIncludedFile(self.x) };
965965
if file.is_null() {
966966
None
967967
} else {
968-
Some(unsafe {
969-
cxstring_into_string(clang_sys::clang_getFileName(file))
970-
})
968+
Some(unsafe { cxstring_into_string(clang_getFileName(file)) })
971969
}
972970
}
973971

bindgen/codegen/dyngen.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(crate) struct DynamicItems {
1414
/// ...
1515
/// }
1616
/// ```
17-
struct_members: Vec<proc_macro2::TokenStream>,
17+
struct_members: Vec<TokenStream>,
1818

1919
/// Tracks the tokens that will appear inside the library struct's implementation, e.g.:
2020
///
@@ -26,7 +26,7 @@ pub(crate) struct DynamicItems {
2626
/// }
2727
/// }
2828
/// ```
29-
struct_implementation: Vec<proc_macro2::TokenStream>,
29+
struct_implementation: Vec<TokenStream>,
3030

3131
/// Tracks the initialization of the fields inside the `::new` constructor of the library
3232
/// struct, e.g.:
@@ -45,7 +45,7 @@ pub(crate) struct DynamicItems {
4545
/// ...
4646
/// }
4747
/// ```
48-
constructor_inits: Vec<proc_macro2::TokenStream>,
48+
constructor_inits: Vec<TokenStream>,
4949

5050
/// Tracks the information that is passed to the library struct at the end of the `::new`
5151
/// constructor, e.g.:
@@ -65,7 +65,7 @@ pub(crate) struct DynamicItems {
6565
/// }
6666
/// }
6767
/// ```
68-
init_fields: Vec<proc_macro2::TokenStream>,
68+
init_fields: Vec<TokenStream>,
6969
}
7070

7171
impl DynamicItems {
@@ -77,7 +77,7 @@ impl DynamicItems {
7777
&self,
7878
lib_ident: Ident,
7979
ctx: &BindgenContext,
80-
) -> proc_macro2::TokenStream {
80+
) -> TokenStream {
8181
let struct_members = &self.struct_members;
8282
let constructor_inits = &self.constructor_inits;
8383
let init_fields = &self.init_fields;
@@ -134,11 +134,11 @@ impl DynamicItems {
134134
abi: ClangAbi,
135135
is_variadic: bool,
136136
is_required: bool,
137-
args: Vec<proc_macro2::TokenStream>,
138-
args_identifiers: Vec<proc_macro2::TokenStream>,
139-
ret: proc_macro2::TokenStream,
140-
ret_ty: proc_macro2::TokenStream,
141-
attributes: Vec<proc_macro2::TokenStream>,
137+
args: Vec<TokenStream>,
138+
args_identifiers: Vec<TokenStream>,
139+
ret: TokenStream,
140+
ret_ty: TokenStream,
141+
attributes: Vec<TokenStream>,
142142
ctx: &BindgenContext,
143143
) {
144144
if !is_variadic {

bindgen/codegen/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,7 +3180,7 @@ impl fmt::Display for EnumVariation {
31803180
}
31813181
}
31823182

3183-
impl std::str::FromStr for EnumVariation {
3183+
impl FromStr for EnumVariation {
31843184
type Err = std::io::Error;
31853185

31863186
/// Create a `EnumVariation` from a string.
@@ -3886,7 +3886,7 @@ impl fmt::Display for MacroTypeVariation {
38863886
}
38873887
}
38883888

3889-
impl std::str::FromStr for MacroTypeVariation {
3889+
impl FromStr for MacroTypeVariation {
38903890
type Err = std::io::Error;
38913891

38923892
/// Create a `MacroTypeVariation` from a string.
@@ -3929,7 +3929,7 @@ impl fmt::Display for AliasVariation {
39293929
}
39303930
}
39313931

3932-
impl std::str::FromStr for AliasVariation {
3932+
impl FromStr for AliasVariation {
39333933
type Err = std::io::Error;
39343934

39353935
/// Create an `AliasVariation` from a string.
@@ -3978,7 +3978,7 @@ impl Default for NonCopyUnionStyle {
39783978
}
39793979
}
39803980

3981-
impl std::str::FromStr for NonCopyUnionStyle {
3981+
impl FromStr for NonCopyUnionStyle {
39823982
type Err = std::io::Error;
39833983

39843984
fn from_str(s: &str) -> Result<Self, Self::Err> {
@@ -4096,7 +4096,7 @@ where
40964096
if let Ok(layout) = self.try_get_layout(ctx, extra) {
40974097
Ok(helpers::blob(layout))
40984098
} else {
4099-
Err(error::Error::NoLayoutForOpaqueBlob)
4099+
Err(Error::NoLayoutForOpaqueBlob)
41004100
}
41014101
})
41024102
}
@@ -4207,7 +4207,7 @@ impl TryToOpaque for Type {
42074207
ctx: &BindgenContext,
42084208
_: &Item,
42094209
) -> error::Result<Layout> {
4210-
self.layout(ctx).ok_or(error::Error::NoLayoutForOpaqueBlob)
4210+
self.layout(ctx).ok_or(Error::NoLayoutForOpaqueBlob)
42114211
}
42124212
}
42134213

@@ -4365,7 +4365,7 @@ impl TryToOpaque for TemplateInstantiation {
43654365
) -> error::Result<Layout> {
43664366
item.expect_type()
43674367
.layout(ctx)
4368-
.ok_or(error::Error::NoLayoutForOpaqueBlob)
4368+
.ok_or(Error::NoLayoutForOpaqueBlob)
43694369
}
43704370
}
43714371

@@ -4378,7 +4378,7 @@ impl TryToRustTy for TemplateInstantiation {
43784378
item: &Item,
43794379
) -> error::Result<syn::Type> {
43804380
if self.is_opaque(ctx, item) {
4381-
return Err(error::Error::InstantiationOfOpaqueType);
4381+
return Err(Error::InstantiationOfOpaqueType);
43824382
}
43834383

43844384
let def = self
@@ -4400,7 +4400,7 @@ impl TryToRustTy for TemplateInstantiation {
44004400
// template specialization, and we've hit an instantiation of
44014401
// that partial specialization.
44024402
extra_assert!(def.is_opaque(ctx, &()));
4403-
return Err(error::Error::InstantiationOfOpaqueType);
4403+
return Err(Error::InstantiationOfOpaqueType);
44044404
}
44054405

44064406
// TODO: If the definition type is a template class/struct
@@ -4452,7 +4452,7 @@ impl TryToRustTy for FunctionSig {
44524452
syn::parse_quote! { unsafe extern #abi fn ( #( #arguments ),* ) #ret },
44534453
),
44544454
Err(err) => {
4455-
if matches!(err, error::Error::UnsupportedAbi(_)) {
4455+
if matches!(err, Error::UnsupportedAbi(_)) {
44564456
unsupported_abi_diagnostic(
44574457
self.name(),
44584458
self.is_variadic(),
@@ -4568,7 +4568,7 @@ impl CodeGenerator for Function {
45684568

45694569
let abi = match signature.abi(ctx, Some(name)) {
45704570
Err(err) => {
4571-
if matches!(err, error::Error::UnsupportedAbi(_)) {
4571+
if matches!(err, Error::UnsupportedAbi(_)) {
45724572
unsupported_abi_diagnostic(
45734573
name,
45744574
signature.is_variadic(),
@@ -4709,7 +4709,7 @@ fn unsupported_abi_diagnostic(
47094709
variadic: bool,
47104710
location: Option<&crate::clang::SourceLocation>,
47114711
ctx: &BindgenContext,
4712-
error: &error::Error,
4712+
error: &Error,
47134713
) {
47144714
warn!(
47154715
"Skipping {}function `{fn_name}` because the {error}",
@@ -5676,7 +5676,7 @@ pub(crate) mod utils {
56765676

56775677
pub(crate) fn fnsig_arguments_iter<
56785678
'a,
5679-
I: Iterator<Item = &'a (Option<String>, crate::ir::context::TypeId)>,
5679+
I: Iterator<Item = &'a (Option<String>, TypeId)>,
56805680
>(
56815681
ctx: &BindgenContext,
56825682
args_iter: I,

bindgen/ir/comment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum Kind {
1313

1414
/// Preprocesses a C/C++ comment so that it is a valid Rust comment.
1515
pub(crate) fn preprocess(comment: &str) -> String {
16-
match self::kind(comment) {
16+
match kind(comment) {
1717
Some(Kind::SingleLines) => preprocess_single_lines(comment),
1818
Some(Kind::MultiLine) => preprocess_multi_line(comment),
1919
None => comment.to_owned(),

bindgen/ir/comp.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,8 +1473,7 @@ impl CompInfo {
14731473
ty: type_id,
14741474
kind,
14751475
field_name,
1476-
is_pub: cur.access_specifier() ==
1477-
clang_sys::CX_CXXPublic,
1476+
is_pub: cur.access_specifier() == CX_CXXPublic,
14781477
});
14791478
}
14801479
CXCursor_Constructor | CXCursor_Destructor |

bindgen/ir/context.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ pub(crate) struct BindgenContext {
319319

320320
/// Maps from a cursor to the item ID of the named template type parameter
321321
/// for that cursor.
322-
type_params: HashMap<clang::Cursor, TypeId>,
322+
type_params: HashMap<Cursor, TypeId>,
323323

324324
/// A cursor to module map. Similar reason than above.
325325
modules: HashMap<Cursor, ModuleId>,
@@ -336,7 +336,7 @@ pub(crate) struct BindgenContext {
336336
/// This is used to handle the cases where the semantic and the lexical
337337
/// parents of the cursor differ, like when a nested class is defined
338338
/// outside of the parent class.
339-
semantic_parents: HashMap<clang::Cursor, ItemId>,
339+
semantic_parents: HashMap<Cursor, ItemId>,
340340

341341
/// A stack with the current type declarations and types we're parsing. This
342342
/// is needed to avoid infinite recursion when parsing a type like:
@@ -810,11 +810,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
810810
}
811811

812812
/// Add a new named template type parameter to this context's item set.
813-
pub(crate) fn add_type_param(
814-
&mut self,
815-
item: Item,
816-
definition: clang::Cursor,
817-
) {
813+
pub(crate) fn add_type_param(&mut self, item: Item, definition: Cursor) {
818814
debug!("BindgenContext::add_type_param: item = {item:?}; definition = {definition:?}");
819815

820816
assert!(
@@ -846,10 +842,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
846842

847843
/// Get the named type defined at the given cursor location, if we've
848844
/// already added one.
849-
pub(crate) fn get_type_param(
850-
&self,
851-
definition: &clang::Cursor,
852-
) -> Option<TypeId> {
845+
pub(crate) fn get_type_param(&self, definition: &Cursor) -> Option<TypeId> {
853846
assert_eq!(
854847
definition.kind(),
855848
clang_sys::CXCursor_TemplateTypeParameter
@@ -923,7 +916,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
923916
/// Gather all the unresolved type references.
924917
fn collect_typerefs(
925918
&mut self,
926-
) -> Vec<(ItemId, clang::Type, clang::Cursor, Option<ItemId>)> {
919+
) -> Vec<(ItemId, clang::Type, Cursor, Option<ItemId>)> {
927920
debug_assert!(!self.collected_typerefs);
928921
self.collected_typerefs = true;
929922
let mut typerefs = vec![];
@@ -1517,7 +1510,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
15171510
/// not sure it's worth it.
15181511
pub(crate) fn add_semantic_parent(
15191512
&mut self,
1520-
definition: clang::Cursor,
1513+
definition: Cursor,
15211514
parent_id: ItemId,
15221515
) {
15231516
self.semantic_parents.insert(definition, parent_id);
@@ -1526,7 +1519,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
15261519
/// Returns a known semantic parent for a given definition.
15271520
pub(crate) fn known_semantic_parent(
15281521
&self,
1529-
definition: clang::Cursor,
1522+
definition: Cursor,
15301523
) -> Option<ItemId> {
15311524
self.semantic_parents.get(&definition).copied()
15321525
}
@@ -1631,7 +1624,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
16311624
with_id: ItemId,
16321625
template: TypeId,
16331626
ty: &clang::Type,
1634-
location: clang::Cursor,
1627+
location: Cursor,
16351628
) -> Option<TypeId> {
16361629
let num_expected_args =
16371630
self.resolve_type(template).num_self_template_params(self);
@@ -1856,7 +1849,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
18561849
with_id: ItemId,
18571850
parent_id: Option<ItemId>,
18581851
ty: &clang::Type,
1859-
location: Option<clang::Cursor>,
1852+
location: Option<Cursor>,
18601853
) -> Option<TypeId> {
18611854
use clang_sys::{CXCursor_TypeAliasTemplateDecl, CXCursor_TypeRef};
18621855
debug!("builtin_or_resolved_ty: {ty:?}, {location:?}, {with_id:?}, {parent_id:?}");
@@ -2227,7 +2220,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
22272220
/// namespace.
22282221
fn tokenize_namespace(
22292222
&self,
2230-
cursor: &clang::Cursor,
2223+
cursor: &Cursor,
22312224
) -> (Option<String>, ModuleKind) {
22322225
assert_eq!(
22332226
cursor.kind(),
@@ -2306,7 +2299,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
23062299

23072300
/// Given a CXCursor_Namespace cursor, return the item ID of the
23082301
/// corresponding module, or create one on the fly.
2309-
pub(crate) fn module(&mut self, cursor: clang::Cursor) -> ModuleId {
2302+
pub(crate) fn module(&mut self, cursor: Cursor) -> ModuleId {
23102303
use clang_sys::*;
23112304
assert_eq!(cursor.kind(), CXCursor_Namespace, "Be a nice person");
23122305
let cursor = cursor.canonical();

bindgen/ir/dot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(crate) trait DotAttributes {
1717
out: &mut W,
1818
) -> io::Result<()>
1919
where
20-
W: io::Write;
20+
W: Write;
2121
}
2222

2323
/// Write a graphviz dot file containing our IR.

bindgen/ir/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,8 +1563,8 @@ impl Item {
15631563
\tlocation = {location:?}",
15641564
);
15651565

1566-
if ty.kind() == clang_sys::CXType_Unexposed ||
1567-
location.cur_type().kind() == clang_sys::CXType_Unexposed
1566+
if ty.kind() == CXType_Unexposed ||
1567+
location.cur_type().kind() == CXType_Unexposed
15681568
{
15691569
if ty.is_associated_type() ||
15701570
location.cur_type().is_associated_type()

0 commit comments

Comments
 (0)