From f0607275b42e4959a22479bd28e327b2b54e2123 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 27 Apr 2020 15:37:47 -0400 Subject: [PATCH 1/3] Run `cargo fix --edition` --- src/callbacks.rs | 4 +- src/clang.rs | 6 +-- src/codegen/helpers.rs | 12 +++--- src/codegen/impl_debug.rs | 8 ++-- src/codegen/impl_partialeq.rs | 8 ++-- src/codegen/mod.rs | 50 +++++++++++----------- src/codegen/struct_layout.rs | 8 ++-- src/ir/analysis/derive.rs | 22 +++++----- src/ir/analysis/has_destructor.rs | 10 ++--- src/ir/analysis/has_float.rs | 12 +++--- src/ir/analysis/has_type_param_in_array.rs | 12 +++--- src/ir/analysis/has_vtable.rs | 8 ++-- src/ir/analysis/mod.rs | 8 ++-- src/ir/analysis/sizedness.rs | 10 ++--- src/ir/analysis/template_params.rs | 12 +++--- src/ir/annotations.rs | 2 +- src/ir/comp.rs | 10 ++--- src/ir/context.rs | 10 ++--- src/ir/enum_ty.rs | 10 ++--- src/ir/function.rs | 4 +- src/ir/item.rs | 6 +-- src/ir/layout.rs | 4 +- src/ir/module.rs | 6 +-- src/ir/objc.rs | 2 +- src/ir/template.rs | 4 +- src/ir/ty.rs | 4 +- src/ir/var.rs | 6 +-- src/lib.rs | 18 ++++---- src/main.rs | 2 +- src/parse.rs | 6 +-- tests/tests.rs | 2 +- 31 files changed, 143 insertions(+), 143 deletions(-) diff --git a/src/callbacks.rs b/src/callbacks.rs index 21478e4fe0..1b5445e642 100644 --- a/src/callbacks.rs +++ b/src/callbacks.rs @@ -1,7 +1,7 @@ //! A public API for more fine-grained customization of bindgen behavior. -pub use ir::enum_ty::{EnumVariantCustomBehavior, EnumVariantValue}; -pub use ir::int::IntKind; +pub use crate::ir::enum_ty::{EnumVariantCustomBehavior, EnumVariantValue}; +pub use crate::ir::int::IntKind; use std::fmt; use std::panic::UnwindSafe; diff --git a/src/clang.rs b/src/clang.rs index 4bcc4b4ac4..cae3207eb3 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -6,7 +6,7 @@ use cexpr; use clang_sys::*; -use ir::context::BindgenContext; +use crate::ir::context::BindgenContext; use regex; use std::ffi::{CStr, CString}; use std::fmt; @@ -1085,8 +1085,8 @@ impl Type { pub fn fallible_layout( &self, ctx: &BindgenContext, - ) -> Result<::ir::layout::Layout, LayoutError> { - use ir::layout::Layout; + ) -> Result { + use crate::ir::layout::Layout; let size = self.fallible_size(ctx)?; let align = self.fallible_align(ctx)?; Ok(Layout::new(size, align)) diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs index ec60742c17..b6825f5ed0 100644 --- a/src/codegen/helpers.rs +++ b/src/codegen/helpers.rs @@ -1,7 +1,7 @@ //! Helpers for code generation that don't need macro expansion. -use ir::context::BindgenContext; -use ir::layout::Layout; +use crate::ir::context::BindgenContext; +use crate::ir::layout::Layout; use proc_macro2::{Ident, Span, TokenStream}; use quote::TokenStreamExt; @@ -136,10 +136,10 @@ pub fn bitfield_unit(ctx: &BindgenContext, layout: Layout) -> TokenStream { } pub mod ast_ty { - use ir::context::BindgenContext; - use ir::function::FunctionSig; - use ir::layout::Layout; - use ir::ty::FloatKind; + use crate::ir::context::BindgenContext; + use crate::ir::function::FunctionSig; + use crate::ir::layout::Layout; + use crate::ir::ty::FloatKind; use proc_macro2::{self, TokenStream}; use std::str::FromStr; diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs index eac54fd16b..ed1a5e25ea 100644 --- a/src/codegen/impl_debug.rs +++ b/src/codegen/impl_debug.rs @@ -1,7 +1,7 @@ -use ir::comp::{BitfieldUnit, CompKind, Field, FieldData, FieldMethods}; -use ir::context::BindgenContext; -use ir::item::{HasTypeParamInArray, IsOpaque, Item, ItemCanonicalName}; -use ir::ty::{TypeKind, RUST_DERIVE_IN_ARRAY_LIMIT}; +use crate::ir::comp::{BitfieldUnit, CompKind, Field, FieldData, FieldMethods}; +use crate::ir::context::BindgenContext; +use crate::ir::item::{HasTypeParamInArray, IsOpaque, Item, ItemCanonicalName}; +use crate::ir::ty::{TypeKind, RUST_DERIVE_IN_ARRAY_LIMIT}; use proc_macro2; pub fn gen_debug_impl( diff --git a/src/codegen/impl_partialeq.rs b/src/codegen/impl_partialeq.rs index d73f36bb4e..5f2600e290 100644 --- a/src/codegen/impl_partialeq.rs +++ b/src/codegen/impl_partialeq.rs @@ -1,7 +1,7 @@ -use ir::comp::{CompInfo, CompKind, Field, FieldMethods}; -use ir::context::BindgenContext; -use ir::item::{IsOpaque, Item}; -use ir::ty::{TypeKind, RUST_DERIVE_IN_ARRAY_LIMIT}; +use crate::ir::comp::{CompInfo, CompKind, Field, FieldMethods}; +use crate::ir::context::BindgenContext; +use crate::ir::item::{IsOpaque, Item}; +use crate::ir::ty::{TypeKind, RUST_DERIVE_IN_ARRAY_LIMIT}; use proc_macro2; /// Generate a manual implementation of `PartialEq` trait for the diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 73cc2f2577..cba9d66b05 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -15,32 +15,32 @@ use self::struct_layout::StructLayoutTracker; use super::BindgenOptions; -use ir::analysis::{HasVtable, Sizedness}; -use ir::annotations::FieldAccessorKind; -use ir::comment; -use ir::comp::{ +use crate::ir::analysis::{HasVtable, Sizedness}; +use crate::ir::annotations::FieldAccessorKind; +use crate::ir::comment; +use crate::ir::comp::{ Base, Bitfield, BitfieldUnit, CompInfo, CompKind, Field, FieldData, FieldMethods, Method, MethodKind, }; -use ir::context::{BindgenContext, ItemId}; -use ir::derive::{ +use crate::ir::context::{BindgenContext, ItemId}; +use crate::ir::derive::{ CanDerive, CanDeriveCopy, CanDeriveDebug, CanDeriveDefault, CanDeriveEq, CanDeriveHash, CanDeriveOrd, CanDerivePartialEq, CanDerivePartialOrd, }; -use ir::dot; -use ir::enum_ty::{Enum, EnumVariant, EnumVariantValue}; -use ir::function::{Abi, Function, FunctionKind, FunctionSig, Linkage}; -use ir::int::IntKind; -use ir::item::{IsOpaque, Item, ItemCanonicalName, ItemCanonicalPath}; -use ir::item_kind::ItemKind; -use ir::layout::Layout; -use ir::module::Module; -use ir::objc::{ObjCInterface, ObjCMethod}; -use ir::template::{ +use crate::ir::dot; +use crate::ir::enum_ty::{Enum, EnumVariant, EnumVariantValue}; +use crate::ir::function::{Abi, Function, FunctionKind, FunctionSig, Linkage}; +use crate::ir::int::IntKind; +use crate::ir::item::{IsOpaque, Item, ItemCanonicalName, ItemCanonicalPath}; +use crate::ir::item_kind::ItemKind; +use crate::ir::layout::Layout; +use crate::ir::module::Module; +use crate::ir::objc::{ObjCInterface, ObjCMethod}; +use crate::ir::template::{ AsTemplateParam, TemplateInstantiation, TemplateParameters, }; -use ir::ty::{Type, TypeKind}; -use ir::var::Var; +use crate::ir::ty::{Type, TypeKind}; +use crate::ir::var::Var; use proc_macro2::{self, Ident, Span}; use quote::TokenStreamExt; @@ -53,7 +53,7 @@ use std::fmt::Write; use std::iter; use std::ops; use std::str::FromStr; -use {Entry, HashMap, HashSet}; +use crate::{Entry, HashMap, HashSet}; // Name of type defined in constified enum module pub static CONSTIFIED_ENUM_MODULE_REPR_NAME: &'static str = "Type"; @@ -483,7 +483,7 @@ impl CodeGenerator for Var { result: &mut CodegenResult<'a>, item: &Item, ) { - use ir::var::VarType; + use crate::ir::var::VarType; debug!("::codegen: item = {:?}", item); debug_assert!(item.is_enabled_for_codegen(ctx)); @@ -1310,7 +1310,7 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit { F: Extend, M: Extend, { - use ir::ty::RUST_DERIVE_IN_ARRAY_LIMIT; + use crate::ir::ty::RUST_DERIVE_IN_ARRAY_LIMIT; result.saw_bitfield_unit(); @@ -3855,10 +3855,10 @@ pub(crate) fn codegen( mod utils { use super::{error, ToRustTyOrOpaque}; - use ir::context::BindgenContext; - use ir::function::{Abi, FunctionSig}; - use ir::item::{Item, ItemCanonicalPath}; - use ir::ty::TypeKind; + use crate::ir::context::BindgenContext; + use crate::ir::function::{Abi, FunctionSig}; + use crate::ir::item::{Item, ItemCanonicalPath}; + use crate::ir::ty::TypeKind; use proc_macro2; use std::borrow::Cow; use std::mem; diff --git a/src/codegen/struct_layout.rs b/src/codegen/struct_layout.rs index 6e3f57b26b..900f258617 100644 --- a/src/codegen/struct_layout.rs +++ b/src/codegen/struct_layout.rs @@ -2,10 +2,10 @@ use super::helpers; -use ir::comp::CompInfo; -use ir::context::BindgenContext; -use ir::layout::Layout; -use ir::ty::{Type, TypeKind}; +use crate::ir::comp::CompInfo; +use crate::ir::context::BindgenContext; +use crate::ir::layout::Layout; +use crate::ir::ty::{Type, TypeKind}; use proc_macro2::{self, Ident, Span}; use std::cmp; diff --git a/src/ir/analysis/derive.rs b/src/ir/analysis/derive.rs index f9cc404c03..6858d7f145 100644 --- a/src/ir/analysis/derive.rs +++ b/src/ir/analysis/derive.rs @@ -3,17 +3,17 @@ use std::fmt; use super::{generate_dependencies, ConstrainResult, MonotoneFramework}; -use ir::analysis::has_vtable::HasVtable; -use ir::comp::CompKind; -use ir::context::{BindgenContext, ItemId}; -use ir::derive::CanDerive; -use ir::function::FunctionSig; -use ir::item::{IsOpaque, Item}; -use ir::template::TemplateParameters; -use ir::traversal::{EdgeKind, Trace}; -use ir::ty::RUST_DERIVE_IN_ARRAY_LIMIT; -use ir::ty::{Type, TypeKind}; -use {Entry, HashMap, HashSet}; +use crate::ir::analysis::has_vtable::HasVtable; +use crate::ir::comp::CompKind; +use crate::ir::context::{BindgenContext, ItemId}; +use crate::ir::derive::CanDerive; +use crate::ir::function::FunctionSig; +use crate::ir::item::{IsOpaque, Item}; +use crate::ir::template::TemplateParameters; +use crate::ir::traversal::{EdgeKind, Trace}; +use crate::ir::ty::RUST_DERIVE_IN_ARRAY_LIMIT; +use crate::ir::ty::{Type, TypeKind}; +use crate::{Entry, HashMap, HashSet}; /// Which trait to consider when doing the `CannotDerive` analysis. #[derive(Debug, Copy, Clone)] diff --git a/src/ir/analysis/has_destructor.rs b/src/ir/analysis/has_destructor.rs index 12b6926069..ca4f2532a1 100644 --- a/src/ir/analysis/has_destructor.rs +++ b/src/ir/analysis/has_destructor.rs @@ -1,11 +1,11 @@ //! Determining which types have destructors use super::{generate_dependencies, ConstrainResult, MonotoneFramework}; -use ir::comp::{CompKind, Field, FieldMethods}; -use ir::context::{BindgenContext, ItemId}; -use ir::traversal::EdgeKind; -use ir::ty::TypeKind; -use {HashMap, HashSet}; +use crate::ir::comp::{CompKind, Field, FieldMethods}; +use crate::ir::context::{BindgenContext, ItemId}; +use crate::ir::traversal::EdgeKind; +use crate::ir::ty::TypeKind; +use crate::{HashMap, HashSet}; /// An analysis that finds for each IR item whether it has a destructor or not /// diff --git a/src/ir/analysis/has_float.rs b/src/ir/analysis/has_float.rs index 7c62a9e278..d21e651dfa 100644 --- a/src/ir/analysis/has_float.rs +++ b/src/ir/analysis/has_float.rs @@ -1,12 +1,12 @@ //! Determining which types has float. use super::{generate_dependencies, ConstrainResult, MonotoneFramework}; -use ir::comp::Field; -use ir::comp::FieldMethods; -use ir::context::{BindgenContext, ItemId}; -use ir::traversal::EdgeKind; -use ir::ty::TypeKind; -use {HashMap, HashSet}; +use crate::ir::comp::Field; +use crate::ir::comp::FieldMethods; +use crate::ir::context::{BindgenContext, ItemId}; +use crate::ir::traversal::EdgeKind; +use crate::ir::ty::TypeKind; +use crate::{HashMap, HashSet}; /// An analysis that finds for each IR item whether it has float or not. /// diff --git a/src/ir/analysis/has_type_param_in_array.rs b/src/ir/analysis/has_type_param_in_array.rs index 4217f6f045..ebdb7e3486 100644 --- a/src/ir/analysis/has_type_param_in_array.rs +++ b/src/ir/analysis/has_type_param_in_array.rs @@ -1,12 +1,12 @@ //! Determining which types has typed parameters in array. use super::{generate_dependencies, ConstrainResult, MonotoneFramework}; -use ir::comp::Field; -use ir::comp::FieldMethods; -use ir::context::{BindgenContext, ItemId}; -use ir::traversal::EdgeKind; -use ir::ty::TypeKind; -use {HashMap, HashSet}; +use crate::ir::comp::Field; +use crate::ir::comp::FieldMethods; +use crate::ir::context::{BindgenContext, ItemId}; +use crate::ir::traversal::EdgeKind; +use crate::ir::ty::TypeKind; +use crate::{HashMap, HashSet}; /// An analysis that finds for each IR item whether it has array or not. /// diff --git a/src/ir/analysis/has_vtable.rs b/src/ir/analysis/has_vtable.rs index 026eedd0e0..9e0f9041da 100644 --- a/src/ir/analysis/has_vtable.rs +++ b/src/ir/analysis/has_vtable.rs @@ -1,12 +1,12 @@ //! Determining which types has vtable use super::{generate_dependencies, ConstrainResult, MonotoneFramework}; -use ir::context::{BindgenContext, ItemId}; -use ir::traversal::EdgeKind; -use ir::ty::TypeKind; +use crate::ir::context::{BindgenContext, ItemId}; +use crate::ir::traversal::EdgeKind; +use crate::ir::ty::TypeKind; use std::cmp; use std::ops; -use {Entry, HashMap}; +use crate::{Entry, HashMap}; /// The result of the `HasVtableAnalysis` for an individual item. #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] diff --git a/src/ir/analysis/mod.rs b/src/ir/analysis/mod.rs index a3ba9848d9..4cfc9cb1b6 100644 --- a/src/ir/analysis/mod.rs +++ b/src/ir/analysis/mod.rs @@ -53,12 +53,12 @@ pub use self::has_float::HasFloat; mod sizedness; pub use self::sizedness::{Sizedness, SizednessAnalysis, SizednessResult}; -use ir::context::{BindgenContext, ItemId}; +use crate::ir::context::{BindgenContext, ItemId}; -use ir::traversal::{EdgeKind, Trace}; +use crate::ir::traversal::{EdgeKind, Trace}; use std::fmt; use std::ops; -use HashMap; +use crate::HashMap; /// An analysis in the monotone framework. /// @@ -211,7 +211,7 @@ where #[cfg(test)] mod tests { use super::*; - use {HashMap, HashSet}; + use crate::{HashMap, HashSet}; // Here we find the set of nodes that are reachable from any given // node. This is a lattice mapping nodes to subsets of all nodes. Our join diff --git a/src/ir/analysis/sizedness.rs b/src/ir/analysis/sizedness.rs index 1c9171bd99..72a66d0d4b 100644 --- a/src/ir/analysis/sizedness.rs +++ b/src/ir/analysis/sizedness.rs @@ -3,12 +3,12 @@ use super::{ generate_dependencies, ConstrainResult, HasVtable, MonotoneFramework, }; -use ir::context::{BindgenContext, TypeId}; -use ir::item::IsOpaque; -use ir::traversal::EdgeKind; -use ir::ty::TypeKind; +use crate::ir::context::{BindgenContext, TypeId}; +use crate::ir::item::IsOpaque; +use crate::ir::traversal::EdgeKind; +use crate::ir::ty::TypeKind; use std::{cmp, ops}; -use {Entry, HashMap}; +use crate::{Entry, HashMap}; /// The result of the `Sizedness` analysis for an individual item. /// diff --git a/src/ir/analysis/template_params.rs b/src/ir/analysis/template_params.rs index da392162a1..f0d9b5e87d 100644 --- a/src/ir/analysis/template_params.rs +++ b/src/ir/analysis/template_params.rs @@ -89,12 +89,12 @@ //! See `src/ir/analysis.rs` for more. use super::{ConstrainResult, MonotoneFramework}; -use ir::context::{BindgenContext, ItemId}; -use ir::item::{Item, ItemSet}; -use ir::template::{TemplateInstantiation, TemplateParameters}; -use ir::traversal::{EdgeKind, Trace}; -use ir::ty::TypeKind; -use {HashMap, HashSet}; +use crate::ir::context::{BindgenContext, ItemId}; +use crate::ir::item::{Item, ItemSet}; +use crate::ir::template::{TemplateInstantiation, TemplateParameters}; +use crate::ir::traversal::{EdgeKind, Trace}; +use crate::ir::ty::TypeKind; +use crate::{HashMap, HashSet}; /// An analysis that finds for each IR item its set of template parameters that /// it uses. diff --git a/src/ir/annotations.rs b/src/ir/annotations.rs index 403bffc100..98a0c0428f 100644 --- a/src/ir/annotations.rs +++ b/src/ir/annotations.rs @@ -4,7 +4,7 @@ //! replace other types with, mark as opaque, etc. This module deals with all of //! that stuff. -use clang; +use crate::clang; /// What kind of accessor should we provide for a field? #[derive(Copy, PartialEq, Clone, Debug)] diff --git a/src/ir/comp.rs b/src/ir/comp.rs index a7bfbe30a8..dca9312b73 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -9,15 +9,15 @@ use super::layout::Layout; use super::template::TemplateParameters; use super::traversal::{EdgeKind, Trace, Tracer}; use super::ty::RUST_DERIVE_IN_ARRAY_LIMIT; -use clang; -use codegen::struct_layout::{align_to, bytes_from_bits_pow2}; -use ir::derive::CanDeriveCopy; -use parse::{ClangItemParser, ParseError}; +use crate::clang; +use crate::codegen::struct_layout::{align_to, bytes_from_bits_pow2}; +use crate::ir::derive::CanDeriveCopy; +use crate::parse::{ClangItemParser, ParseError}; use peeking_take_while::PeekableExt; use std::cmp; use std::io; use std::mem; -use HashMap; +use crate::HashMap; /// The kind of compound type. #[derive(Debug, Copy, Clone, PartialEq)] diff --git a/src/ir/context.rs b/src/ir/context.rs index a3601793ae..27eb91d3d5 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -19,19 +19,19 @@ use super::module::{Module, ModuleKind}; use super::template::{TemplateInstantiation, TemplateParameters}; use super::traversal::{self, Edge, ItemTraversal}; use super::ty::{FloatKind, Type, TypeKind}; -use callbacks::ParseCallbacks; +use crate::callbacks::ParseCallbacks; use cexpr; -use clang::{self, Cursor}; +use crate::clang::{self, Cursor}; use clang_sys; -use parse::ClangItemParser; +use crate::parse::ClangItemParser; use proc_macro2::{Ident, Span}; use std::borrow::Cow; use std::cell::Cell; use std::collections::HashMap as StdHashMap; use std::iter::IntoIterator; use std::mem; -use BindgenOptions; -use {Entry, HashMap, HashSet}; +use crate::BindgenOptions; +use crate::{Entry, HashMap, HashSet}; /// An identifier for some kind of IR item. #[derive(Debug, Copy, Clone, Eq, PartialOrd, Ord, Hash)] diff --git a/src/ir/enum_ty.rs b/src/ir/enum_ty.rs index f2013844b2..89b37ae739 100644 --- a/src/ir/enum_ty.rs +++ b/src/ir/enum_ty.rs @@ -4,11 +4,11 @@ use super::super::codegen::EnumVariation; use super::context::{BindgenContext, TypeId}; use super::item::Item; use super::ty::TypeKind; -use clang; -use ir::annotations::Annotations; -use ir::item::ItemCanonicalPath; -use parse::{ClangItemParser, ParseError}; -use regex_set::RegexSet; +use crate::clang; +use crate::ir::annotations::Annotations; +use crate::ir::item::ItemCanonicalPath; +use crate::parse::{ClangItemParser, ParseError}; +use crate::regex_set::RegexSet; /// An enum representing custom handling that can be given to a variant. #[derive(Copy, Clone, Debug, PartialEq, Eq)] diff --git a/src/ir/function.rs b/src/ir/function.rs index 0715ec546c..b22a74271b 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -6,9 +6,9 @@ use super::dot::DotAttributes; use super::item::Item; use super::traversal::{EdgeKind, Trace, Tracer}; use super::ty::TypeKind; -use clang; +use crate::clang; use clang_sys::{self, CXCallingConv}; -use parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; +use crate::parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; use proc_macro2; use quote; use quote::TokenStreamExt; diff --git a/src/ir/item.rs b/src/ir/item.rs index eb5b4d25dc..f4ac648435 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -18,10 +18,10 @@ use super::module::Module; use super::template::{AsTemplateParam, TemplateParameters}; use super::traversal::{EdgeKind, Trace, Tracer}; use super::ty::{Type, TypeKind}; -use clang; +use crate::clang; use clang_sys; use lazycell::LazyCell; -use parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; +use crate::parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; use regex; use std::cell::Cell; use std::collections::BTreeSet; @@ -1296,7 +1296,7 @@ impl ClangItemParser for Item { ctx: &mut BindgenContext, ) -> Result { use clang_sys::*; - use ir::var::Var; + use crate::ir::var::Var; if !cursor.is_valid() { return Err(ParseError::Continue); diff --git a/src/ir/layout.rs b/src/ir/layout.rs index 1c61b2ad2f..28a6604d95 100644 --- a/src/ir/layout.rs +++ b/src/ir/layout.rs @@ -2,8 +2,8 @@ use super::derive::CanDerive; use super::ty::{Type, TypeKind, RUST_DERIVE_IN_ARRAY_LIMIT}; -use clang; -use ir::context::BindgenContext; +use crate::clang; +use crate::ir::context::BindgenContext; use std::cmp; /// A type that represents the struct layout of a type. diff --git a/src/ir/module.rs b/src/ir/module.rs index 7a22106617..13b7c19fff 100644 --- a/src/ir/module.rs +++ b/src/ir/module.rs @@ -3,9 +3,9 @@ use super::context::BindgenContext; use super::dot::DotAttributes; use super::item::ItemSet; -use clang; -use parse::{ClangSubItemParser, ParseError, ParseResult}; -use parse_one; +use crate::clang; +use crate::parse::{ClangSubItemParser, ParseError, ParseResult}; +use crate::parse_one; use std::io; /// Whether this module is inline or not. diff --git a/src/ir/objc.rs b/src/ir/objc.rs index ba650d57eb..5fb645d57f 100644 --- a/src/ir/objc.rs +++ b/src/ir/objc.rs @@ -4,7 +4,7 @@ use super::context::{BindgenContext, ItemId}; use super::function::FunctionSig; use super::traversal::{Trace, Tracer}; use super::ty::TypeKind; -use clang; +use crate::clang; use clang_sys::CXChildVisit_Continue; use clang_sys::CXCursor_ObjCCategoryDecl; use clang_sys::CXCursor_ObjCClassMethodDecl; diff --git a/src/ir/template.rs b/src/ir/template.rs index 30c578ced3..e2900e9579 100644 --- a/src/ir/template.rs +++ b/src/ir/template.rs @@ -30,8 +30,8 @@ use super::context::{BindgenContext, ItemId, TypeId}; use super::item::{IsOpaque, Item, ItemAncestors, ItemCanonicalPath}; use super::traversal::{EdgeKind, Trace, Tracer}; -use clang; -use parse::ClangItemParser; +use crate::clang; +use crate::parse::ClangItemParser; /// Template declaration (and such declaration's template parameters) related /// methods. diff --git a/src/ir/ty.rs b/src/ir/ty.rs index 0144bdbad1..b77b5e75e9 100644 --- a/src/ir/ty.rs +++ b/src/ir/ty.rs @@ -13,8 +13,8 @@ use super::template::{ AsTemplateParam, TemplateInstantiation, TemplateParameters, }; use super::traversal::{EdgeKind, Trace, Tracer}; -use clang::{self, Cursor}; -use parse::{ClangItemParser, ParseError, ParseResult}; +use crate::clang::{self, Cursor}; +use crate::parse::{ClangItemParser, ParseError, ParseResult}; use std::borrow::Cow; use std::io; diff --git a/src/ir/var.rs b/src/ir/var.rs index e55308ce35..e55311f305 100644 --- a/src/ir/var.rs +++ b/src/ir/var.rs @@ -6,10 +6,10 @@ use super::function::cursor_mangling; use super::int::IntKind; use super::item::Item; use super::ty::{FloatKind, TypeKind}; -use callbacks::MacroParsingBehavior; +use crate::callbacks::MacroParsingBehavior; use cexpr; -use clang; -use parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; +use crate::clang; +use crate::parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; use std::io; use std::num::Wrapping; diff --git a/src/lib.rs b/src/lib.rs index 3eda6af9be..158f120133 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,13 +82,13 @@ doc_mod!(ir, ir_docs); doc_mod!(parse, parse_docs); doc_mod!(regex_set, regex_set_docs); -pub use codegen::{AliasVariation, EnumVariation}; -use features::RustFeatures; -pub use features::{RustTarget, LATEST_STABLE_RUST, RUST_TARGET_STRINGS}; -use ir::context::{BindgenContext, ItemId}; -use ir::item::Item; -use parse::{ClangItemParser, ParseError}; -use regex_set::RegexSet; +pub use crate::codegen::{AliasVariation, EnumVariation}; +use crate::features::RustFeatures; +pub use crate::features::{RustTarget, LATEST_STABLE_RUST, RUST_TARGET_STRINGS}; +use crate::ir::context::{BindgenContext, ItemId}; +use crate::ir::item::Item; +use crate::parse::{ClangItemParser, ParseError}; +use crate::regex_set::RegexSet; use std::borrow::Cow; use std::fs::{File, OpenOptions}; @@ -2410,7 +2410,7 @@ impl callbacks::ParseCallbacks for CargoCallbacks { #[test] fn commandline_flag_unit_test_function() { //Test 1 - let bindings = ::builder(); + let bindings = crate::builder(); let command_line_flags = bindings.command_line_flags(); let test_cases = vec![ @@ -2428,7 +2428,7 @@ fn commandline_flag_unit_test_function() { .all(|ref x| command_line_flags.contains(x),)); //Test 2 - let bindings = ::builder() + let bindings = crate::builder() .header("input_header") .whitelist_type("Distinct_Type") .whitelist_function("safe_function"); diff --git a/src/main.rs b/src/main.rs index 9cf030694d..c554ac50e3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ use std::panic; mod log_stubs; mod options; -use options::builder_from_flags; +use crate::options::builder_from_flags; fn clang_version_check() { let version = clang_version(); diff --git a/src/parse.rs b/src/parse.rs index 1a9278b300..f60de43177 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -1,8 +1,8 @@ //! Common traits and types related to parsing our IR from Clang cursors. -use clang; -use ir::context::{BindgenContext, ItemId, TypeId}; -use ir::ty::TypeKind; +use crate::clang; +use crate::ir::context::{BindgenContext, ItemId, TypeId}; +use crate::ir::ty::TypeKind; /// Not so much an error in the traditional sense, but a control flow message /// when walking over Clang's AST with a cursor. diff --git a/tests/tests.rs b/tests/tests.rs index 7095068a11..2b435e457e 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -15,7 +15,7 @@ use std::sync::Once; #[path = "../src/options.rs"] mod options; -use options::builder_from_flags; +use crate::options::builder_from_flags; /// The environment variable that determines if test expectations are overwritten. static OVERWRITE_ENV_VAR: &str = "BINDGEN_OVERWRITE_EXPECTED"; From 2eac7669ecd3ec97331ac7284a2bdcc20bad3352 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 27 Apr 2020 15:38:52 -0400 Subject: [PATCH 2/3] Upgrade to 2018 edition --- Cargo.toml | 1 + src/lib.rs | 10 ---------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6f50a0b0af..ef1d01e320 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ repository = "https://github.com/rust-lang/rust-bindgen" documentation = "https://docs.rs/bindgen" homepage = "https://rust-lang.github.io/rust-bindgen/" version = "0.53.2" +edition = "2018" build = "build.rs" include = [ diff --git a/src/lib.rs b/src/lib.rs index 158f120133..48ceab231b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,23 +17,13 @@ #[macro_use] extern crate bitflags; -extern crate cexpr; #[macro_use] #[allow(unused_extern_crates)] extern crate cfg_if; -extern crate clang_sys; -extern crate lazycell; -extern crate rustc_hash; #[macro_use] extern crate lazy_static; -extern crate peeking_take_while; #[macro_use] extern crate quote; -extern crate proc_macro2; -extern crate regex; -extern crate shlex; -#[cfg(feature = "which-rustfmt")] -extern crate which; #[cfg(feature = "logging")] #[macro_use] From aa4440ac0ec11749621c1397f6a0b9d5f43bc0db Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 27 Apr 2020 18:27:32 -0400 Subject: [PATCH 3/3] Run `cargo fmt` --- src/clang.rs | 2 +- src/codegen/mod.rs | 2 +- src/ir/analysis/has_vtable.rs | 2 +- src/ir/analysis/mod.rs | 2 +- src/ir/analysis/sizedness.rs | 2 +- src/ir/comp.rs | 2 +- src/ir/context.rs | 8 ++++---- src/ir/function.rs | 4 +++- src/ir/item.rs | 6 ++++-- src/ir/var.rs | 6 ++++-- src/lib.rs | 4 +++- 11 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/clang.rs b/src/clang.rs index cae3207eb3..003ed2a68f 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -4,9 +4,9 @@ #![allow(non_upper_case_globals, dead_code)] +use crate::ir::context::BindgenContext; use cexpr; use clang_sys::*; -use crate::ir::context::BindgenContext; use regex; use std::ffi::{CStr, CString}; use std::fmt; diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index cba9d66b05..408d88bfe7 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -45,6 +45,7 @@ use crate::ir::var::Var; use proc_macro2::{self, Ident, Span}; use quote::TokenStreamExt; +use crate::{Entry, HashMap, HashSet}; use std; use std::borrow::Cow; use std::cell::Cell; @@ -53,7 +54,6 @@ use std::fmt::Write; use std::iter; use std::ops; use std::str::FromStr; -use crate::{Entry, HashMap, HashSet}; // Name of type defined in constified enum module pub static CONSTIFIED_ENUM_MODULE_REPR_NAME: &'static str = "Type"; diff --git a/src/ir/analysis/has_vtable.rs b/src/ir/analysis/has_vtable.rs index 9e0f9041da..d2a57d5af0 100644 --- a/src/ir/analysis/has_vtable.rs +++ b/src/ir/analysis/has_vtable.rs @@ -4,9 +4,9 @@ use super::{generate_dependencies, ConstrainResult, MonotoneFramework}; use crate::ir::context::{BindgenContext, ItemId}; use crate::ir::traversal::EdgeKind; use crate::ir::ty::TypeKind; +use crate::{Entry, HashMap}; use std::cmp; use std::ops; -use crate::{Entry, HashMap}; /// The result of the `HasVtableAnalysis` for an individual item. #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] diff --git a/src/ir/analysis/mod.rs b/src/ir/analysis/mod.rs index 4cfc9cb1b6..2cb021f0c7 100644 --- a/src/ir/analysis/mod.rs +++ b/src/ir/analysis/mod.rs @@ -56,9 +56,9 @@ pub use self::sizedness::{Sizedness, SizednessAnalysis, SizednessResult}; use crate::ir::context::{BindgenContext, ItemId}; use crate::ir::traversal::{EdgeKind, Trace}; +use crate::HashMap; use std::fmt; use std::ops; -use crate::HashMap; /// An analysis in the monotone framework. /// diff --git a/src/ir/analysis/sizedness.rs b/src/ir/analysis/sizedness.rs index 72a66d0d4b..d8bced7279 100644 --- a/src/ir/analysis/sizedness.rs +++ b/src/ir/analysis/sizedness.rs @@ -7,8 +7,8 @@ use crate::ir::context::{BindgenContext, TypeId}; use crate::ir::item::IsOpaque; use crate::ir::traversal::EdgeKind; use crate::ir::ty::TypeKind; -use std::{cmp, ops}; use crate::{Entry, HashMap}; +use std::{cmp, ops}; /// The result of the `Sizedness` analysis for an individual item. /// diff --git a/src/ir/comp.rs b/src/ir/comp.rs index dca9312b73..4eeb4745d5 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -13,11 +13,11 @@ use crate::clang; use crate::codegen::struct_layout::{align_to, bytes_from_bits_pow2}; use crate::ir::derive::CanDeriveCopy; use crate::parse::{ClangItemParser, ParseError}; +use crate::HashMap; use peeking_take_while::PeekableExt; use std::cmp; use std::io; use std::mem; -use crate::HashMap; /// The kind of compound type. #[derive(Debug, Copy, Clone, PartialEq)] diff --git a/src/ir/context.rs b/src/ir/context.rs index 27eb91d3d5..8ff102c023 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -20,18 +20,18 @@ use super::template::{TemplateInstantiation, TemplateParameters}; use super::traversal::{self, Edge, ItemTraversal}; use super::ty::{FloatKind, Type, TypeKind}; use crate::callbacks::ParseCallbacks; -use cexpr; use crate::clang::{self, Cursor}; -use clang_sys; use crate::parse::ClangItemParser; +use crate::BindgenOptions; +use crate::{Entry, HashMap, HashSet}; +use cexpr; +use clang_sys; use proc_macro2::{Ident, Span}; use std::borrow::Cow; use std::cell::Cell; use std::collections::HashMap as StdHashMap; use std::iter::IntoIterator; use std::mem; -use crate::BindgenOptions; -use crate::{Entry, HashMap, HashSet}; /// An identifier for some kind of IR item. #[derive(Debug, Copy, Clone, Eq, PartialOrd, Ord, Hash)] diff --git a/src/ir/function.rs b/src/ir/function.rs index b22a74271b..7efeb1b6fd 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -7,8 +7,10 @@ use super::item::Item; use super::traversal::{EdgeKind, Trace, Tracer}; use super::ty::TypeKind; use crate::clang; +use crate::parse::{ + ClangItemParser, ClangSubItemParser, ParseError, ParseResult, +}; use clang_sys::{self, CXCallingConv}; -use crate::parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; use proc_macro2; use quote; use quote::TokenStreamExt; diff --git a/src/ir/item.rs b/src/ir/item.rs index f4ac648435..8e77ad71bd 100644 --- a/src/ir/item.rs +++ b/src/ir/item.rs @@ -19,9 +19,11 @@ use super::template::{AsTemplateParam, TemplateParameters}; use super::traversal::{EdgeKind, Trace, Tracer}; use super::ty::{Type, TypeKind}; use crate::clang; +use crate::parse::{ + ClangItemParser, ClangSubItemParser, ParseError, ParseResult, +}; use clang_sys; use lazycell::LazyCell; -use crate::parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; use regex; use std::cell::Cell; use std::collections::BTreeSet; @@ -1295,8 +1297,8 @@ impl ClangItemParser for Item { parent_id: Option, ctx: &mut BindgenContext, ) -> Result { - use clang_sys::*; use crate::ir::var::Var; + use clang_sys::*; if !cursor.is_valid() { return Err(ParseError::Continue); diff --git a/src/ir/var.rs b/src/ir/var.rs index e55311f305..0f05a3eecf 100644 --- a/src/ir/var.rs +++ b/src/ir/var.rs @@ -7,9 +7,11 @@ use super::int::IntKind; use super::item::Item; use super::ty::{FloatKind, TypeKind}; use crate::callbacks::MacroParsingBehavior; -use cexpr; use crate::clang; -use crate::parse::{ClangItemParser, ClangSubItemParser, ParseError, ParseResult}; +use crate::parse::{ + ClangItemParser, ClangSubItemParser, ParseError, ParseResult, +}; +use cexpr; use std::io; use std::num::Wrapping; diff --git a/src/lib.rs b/src/lib.rs index 48ceab231b..6847dc7737 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,7 +74,9 @@ doc_mod!(regex_set, regex_set_docs); pub use crate::codegen::{AliasVariation, EnumVariation}; use crate::features::RustFeatures; -pub use crate::features::{RustTarget, LATEST_STABLE_RUST, RUST_TARGET_STRINGS}; +pub use crate::features::{ + RustTarget, LATEST_STABLE_RUST, RUST_TARGET_STRINGS, +}; use crate::ir::context::{BindgenContext, ItemId}; use crate::ir::item::Item; use crate::parse::{ClangItemParser, ParseError};