Skip to content

Commit

Permalink
Upgrade to 2018 edition (#1769)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio authored May 3, 2020
2 parents c342ddd + aa4440a commit d5cdad2
Show file tree
Hide file tree
Showing 32 changed files with 152 additions and 153 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions src/callbacks.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#![allow(non_upper_case_globals, dead_code)]


use crate::ir::context::BindgenContext;
use cexpr;
use clang_sys::*;
use ir::context::BindgenContext;
use regex;
use std::ffi::{CStr, CString};
use std::fmt;
Expand Down Expand Up @@ -1085,8 +1085,8 @@ impl Type {
pub fn fallible_layout(
&self,
ctx: &BindgenContext,
) -> Result<::ir::layout::Layout, LayoutError> {
use ir::layout::Layout;
) -> Result<crate::ir::layout::Layout, LayoutError> {
use crate::ir::layout::Layout;
let size = self.fallible_size(ctx)?;
let align = self.fallible_align(ctx)?;
Ok(Layout::new(size, align))
Expand Down
12 changes: 6 additions & 6 deletions src/codegen/helpers.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions src/codegen/impl_debug.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/impl_partialeq.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
50 changes: 25 additions & 25 deletions src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,37 @@ 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;

use crate::{Entry, HashMap, HashSet};
use std;
use std::borrow::Cow;
use std::cell::Cell;
Expand All @@ -53,7 +54,6 @@ use std::fmt::Write;
use std::iter;
use std::ops;
use std::str::FromStr;
use {Entry, HashMap, HashSet};

// Name of type defined in constified enum module
pub static CONSTIFIED_ENUM_MODULE_REPR_NAME: &'static str = "Type";
Expand Down Expand Up @@ -483,7 +483,7 @@ impl CodeGenerator for Var {
result: &mut CodegenResult<'a>,
item: &Item,
) {
use ir::var::VarType;
use crate::ir::var::VarType;
debug!("<Var as CodeGenerator>::codegen: item = {:?}", item);
debug_assert!(item.is_enabled_for_codegen(ctx));

Expand Down Expand Up @@ -1310,7 +1310,7 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
F: Extend<proc_macro2::TokenStream>,
M: Extend<proc_macro2::TokenStream>,
{
use ir::ty::RUST_DERIVE_IN_ARRAY_LIMIT;
use crate::ir::ty::RUST_DERIVE_IN_ARRAY_LIMIT;

result.saw_bitfield_unit();

Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/codegen/struct_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
22 changes: 11 additions & 11 deletions src/ir/analysis/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
10 changes: 5 additions & 5 deletions src/ir/analysis/has_destructor.rs
Original file line number Diff line number Diff line change
@@ -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
///
Expand Down
12 changes: 6 additions & 6 deletions src/ir/analysis/has_float.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down
12 changes: 6 additions & 6 deletions src/ir/analysis/has_type_param_in_array.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down
8 changes: 4 additions & 4 deletions src/ir/analysis/has_vtable.rs
Original file line number Diff line number Diff line change
@@ -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 crate::{Entry, HashMap};
use std::cmp;
use std::ops;
use {Entry, HashMap};

/// The result of the `HasVtableAnalysis` for an individual item.
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
Expand Down
8 changes: 4 additions & 4 deletions src/ir/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 crate::HashMap;
use std::fmt;
use std::ops;
use HashMap;

/// An analysis in the monotone framework.
///
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/ir/analysis/sizedness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 crate::{Entry, HashMap};
use std::{cmp, ops};
use {Entry, HashMap};

/// The result of the `Sizedness` analysis for an individual item.
///
Expand Down
12 changes: 6 additions & 6 deletions src/ir/analysis/template_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/ir/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
10 changes: 5 additions & 5 deletions src/ir/comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 crate::HashMap;
use peeking_take_while::PeekableExt;
use std::cmp;
use std::io;
use std::mem;
use HashMap;

/// The kind of compound type.
#[derive(Debug, Copy, Clone, PartialEq)]
Expand Down
Loading

0 comments on commit d5cdad2

Please sign in to comment.