Skip to content

Commit

Permalink
Auto merge of #44441 - tamird:cargo-bitflags, r=alexcrichton
Browse files Browse the repository at this point in the history
Remove rustc_bitflags; use the bitflags crate

r? @alexcrichton
  • Loading branch information
bors committed Sep 18, 2017
2 parents caad256 + 231d9e7 commit 3a7b960
Show file tree
Hide file tree
Showing 25 changed files with 193 additions and 650 deletions.
32 changes: 22 additions & 10 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ cargo = { path = "tools/cargo" }
# Override rustfmt dependencies both on the repo and the crate (the RLS
# sometimes uses either).
# FIXME should only need the crates.io patch, long term.
[patch.'https://github.com/rust-lang-nursery/rustfmt']
[patch."https://github.com/rust-lang-nursery/rustfmt"]
rustfmt-nightly = { path = "tools/rustfmt" }
[patch.crates-io]
rustfmt-nightly = { path = "tools/rustfmt" }
5 changes: 2 additions & 3 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ def build_bootstrap(self):

def build_triple(self):
"""Build triple as in LLVM"""
default_encoding = sys.getdefaultencoding()
config = self.get_toml('build')
if config:
return config
Expand All @@ -638,7 +637,7 @@ def update_submodules(self):
return
print('Updating submodules')
default_encoding = sys.getdefaultencoding()
run(["git", "submodule", "-q", "sync"], cwd=self.rust_root)
run(["git", "submodule", "-q", "sync"], cwd=self.rust_root, verbose=self.verbose)
submodules = [s.split(' ', 1)[1] for s in subprocess.check_output(
["git", "config", "--file",
os.path.join(self.rust_root, ".gitmodules"),
Expand Down Expand Up @@ -683,7 +682,7 @@ def bootstrap():
try:
with open(args.config or 'config.toml') as config:
build.config_toml = config.read()
except:
except OSError:
pass

if '\nverbose = 2' in build.config_toml:
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ crate-type = ["dylib"]

[dependencies]
arena = { path = "../libarena" }
bitflags = "1.0"
fmt_macros = { path = "../libfmt_macros" }
graphviz = { path = "../libgraphviz" }
jobserver = "0.1"
log = "0.3"
owning_ref = "0.3.3"
rustc_back = { path = "../librustc_back" }
rustc_bitflags = { path = "../librustc_bitflags" }
rustc_const_math = { path = "../librustc_const_math" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#![recursion_limit="256"]

extern crate arena;
#[macro_use] extern crate bitflags;
extern crate core;
extern crate fmt_macros;
extern crate getopts;
Expand All @@ -56,7 +57,6 @@ extern crate rustc_errors as errors;
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
extern crate syntax_pos;
#[macro_use] #[no_link] extern crate rustc_bitflags;
extern crate jobserver;

extern crate serialize as rustc_serialize; // used by deriving
Expand Down
58 changes: 29 additions & 29 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,35 +398,35 @@ pub struct CReaderCacheKey {
// check whether the type has various kinds of types in it without
// recursing over the type itself.
bitflags! {
flags TypeFlags: u32 {
const HAS_PARAMS = 1 << 0,
const HAS_SELF = 1 << 1,
const HAS_TY_INFER = 1 << 2,
const HAS_RE_INFER = 1 << 3,
const HAS_RE_SKOL = 1 << 4,
const HAS_RE_EARLY_BOUND = 1 << 5,
const HAS_FREE_REGIONS = 1 << 6,
const HAS_TY_ERR = 1 << 7,
const HAS_PROJECTION = 1 << 8,
pub struct TypeFlags: u32 {
const HAS_PARAMS = 1 << 0;
const HAS_SELF = 1 << 1;
const HAS_TY_INFER = 1 << 2;
const HAS_RE_INFER = 1 << 3;
const HAS_RE_SKOL = 1 << 4;
const HAS_RE_EARLY_BOUND = 1 << 5;
const HAS_FREE_REGIONS = 1 << 6;
const HAS_TY_ERR = 1 << 7;
const HAS_PROJECTION = 1 << 8;

// FIXME: Rename this to the actual property since it's used for generators too
const HAS_TY_CLOSURE = 1 << 9,
const HAS_TY_CLOSURE = 1 << 9;

// true if there are "names" of types and regions and so forth
// that are local to a particular fn
const HAS_LOCAL_NAMES = 1 << 10,
const HAS_LOCAL_NAMES = 1 << 10;

// Present if the type belongs in a local type context.
// Only set for TyInfer other than Fresh.
const KEEP_IN_LOCAL_TCX = 1 << 11,
const KEEP_IN_LOCAL_TCX = 1 << 11;

// Is there a projection that does not involve a bound region?
// Currently we can't normalize projections w/ bound regions.
const HAS_NORMALIZABLE_PROJECTION = 1 << 12,
const HAS_NORMALIZABLE_PROJECTION = 1 << 12;

const NEEDS_SUBST = TypeFlags::HAS_PARAMS.bits |
TypeFlags::HAS_SELF.bits |
TypeFlags::HAS_RE_EARLY_BOUND.bits,
TypeFlags::HAS_RE_EARLY_BOUND.bits;

// Flags representing the nominal content of a type,
// computed by FlagsComputation. If you add a new nominal
Expand All @@ -442,7 +442,7 @@ bitflags! {
TypeFlags::HAS_PROJECTION.bits |
TypeFlags::HAS_TY_CLOSURE.bits |
TypeFlags::HAS_LOCAL_NAMES.bits |
TypeFlags::KEEP_IN_LOCAL_TCX.bits,
TypeFlags::KEEP_IN_LOCAL_TCX.bits;
}
}

Expand Down Expand Up @@ -1258,13 +1258,13 @@ pub struct Destructor {
}

bitflags! {
flags AdtFlags: u32 {
const NO_ADT_FLAGS = 0,
const IS_ENUM = 1 << 0,
const IS_PHANTOM_DATA = 1 << 1,
const IS_FUNDAMENTAL = 1 << 2,
const IS_UNION = 1 << 3,
const IS_BOX = 1 << 4,
pub struct AdtFlags: u32 {
const NO_ADT_FLAGS = 0;
const IS_ENUM = 1 << 0;
const IS_PHANTOM_DATA = 1 << 1;
const IS_FUNDAMENTAL = 1 << 2;
const IS_UNION = 1 << 3;
const IS_BOX = 1 << 4;
}
}

Expand Down Expand Up @@ -1357,18 +1357,18 @@ pub enum AdtKind { Struct, Union, Enum }

bitflags! {
#[derive(RustcEncodable, RustcDecodable, Default)]
flags ReprFlags: u8 {
const IS_C = 1 << 0,
const IS_PACKED = 1 << 1,
const IS_SIMD = 1 << 2,
pub struct ReprFlags: u8 {
const IS_C = 1 << 0;
const IS_PACKED = 1 << 1;
const IS_SIMD = 1 << 2;
// Internal only for now. If true, don't reorder fields.
const IS_LINEAR = 1 << 3,
const IS_LINEAR = 1 << 3;

// Any of these flags being set prevent field reordering optimisation.
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits |
ReprFlags::IS_PACKED.bits |
ReprFlags::IS_SIMD.bits |
ReprFlags::IS_LINEAR.bits,
ReprFlags::IS_LINEAR.bits;
}
}

Expand Down
7 changes: 0 additions & 7 deletions src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable};
use ty::{Slice, TyS};
use ty::subst::Kind;

use std::fmt;
use std::iter;
use std::cmp::Ordering;
use syntax::abi;
Expand Down Expand Up @@ -577,12 +576,6 @@ impl<T> Binder<T> {
}
}

impl fmt::Debug for TypeFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:x}", self.bits)
}
}

/// Represents the projection of an associated type. In explicit UFCS
/// form this would be written `<T as Trait<..>>::N`.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_apfloat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ name = "rustc_apfloat"
path = "lib.rs"

[dependencies]
rustc_bitflags = { path = "../librustc_bitflags" }
bitflags = "1.0"
rustc_cratesio_shim = { path = "../librustc_cratesio_shim" }
29 changes: 13 additions & 16 deletions src/librustc_apfloat/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,31 @@
#![cfg_attr(not(stage0), feature(const_min_value))]
#![cfg_attr(not(stage0), feature(const_max_value))]

// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
#[allow(unused_extern_crates)]
extern crate rustc_cratesio_shim;

#[macro_use]
extern crate rustc_bitflags;
extern crate bitflags;

use std::cmp::Ordering;
use std::fmt;
use std::ops::{Neg, Add, Sub, Mul, Div, Rem};
use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, BitOrAssign};
use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign};
use std::str::FromStr;

bitflags! {
/// IEEE-754R 7: Default exception handling.
///
/// UNDERFLOW or OVERFLOW are always returned or-ed with INEXACT.
#[must_use]
#[derive(Debug)]
flags Status: u8 {
const OK = 0x00,
const INVALID_OP = 0x01,
const DIV_BY_ZERO = 0x02,
const OVERFLOW = 0x04,
const UNDERFLOW = 0x08,
const INEXACT = 0x10
}
}

impl BitOrAssign for Status {
fn bitor_assign(&mut self, rhs: Self) {
*self = *self | rhs;
pub struct Status: u8 {
const OK = 0x00;
const INVALID_OP = 0x01;
const DIV_BY_ZERO = 0x02;
const OVERFLOW = 0x04;
const UNDERFLOW = 0x08;
const INEXACT = 0x10;
}
}

Expand Down
9 changes: 0 additions & 9 deletions src/librustc_bitflags/Cargo.toml

This file was deleted.

Loading

0 comments on commit 3a7b960

Please sign in to comment.