Skip to content

Commit 231d9e7

Browse files
committed
Remove rustc_bitflags; use the bitflags crate
1 parent e788fa7 commit 231d9e7

File tree

23 files changed

+190
-646
lines changed

23 files changed

+190
-646
lines changed

src/Cargo.lock

+22-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/librustc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ crate-type = ["dylib"]
1010

1111
[dependencies]
1212
arena = { path = "../libarena" }
13+
bitflags = "1.0"
1314
fmt_macros = { path = "../libfmt_macros" }
1415
graphviz = { path = "../libgraphviz" }
1516
jobserver = "0.1"
1617
log = "0.3"
1718
owning_ref = "0.3.3"
1819
rustc_back = { path = "../librustc_back" }
19-
rustc_bitflags = { path = "../librustc_bitflags" }
2020
rustc_const_math = { path = "../librustc_const_math" }
2121
rustc_data_structures = { path = "../librustc_data_structures" }
2222
rustc_errors = { path = "../librustc_errors" }

src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#![recursion_limit="256"]
4242

4343
extern crate arena;
44+
#[macro_use] extern crate bitflags;
4445
extern crate core;
4546
extern crate fmt_macros;
4647
extern crate getopts;
@@ -56,7 +57,6 @@ extern crate rustc_errors as errors;
5657
#[macro_use] extern crate log;
5758
#[macro_use] extern crate syntax;
5859
extern crate syntax_pos;
59-
#[macro_use] #[no_link] extern crate rustc_bitflags;
6060
extern crate jobserver;
6161

6262
extern crate serialize as rustc_serialize; // used by deriving

src/librustc/ty/mod.rs

+29-29
Original file line numberDiff line numberDiff line change
@@ -399,35 +399,35 @@ pub struct CReaderCacheKey {
399399
// check whether the type has various kinds of types in it without
400400
// recursing over the type itself.
401401
bitflags! {
402-
flags TypeFlags: u32 {
403-
const HAS_PARAMS = 1 << 0,
404-
const HAS_SELF = 1 << 1,
405-
const HAS_TY_INFER = 1 << 2,
406-
const HAS_RE_INFER = 1 << 3,
407-
const HAS_RE_SKOL = 1 << 4,
408-
const HAS_RE_EARLY_BOUND = 1 << 5,
409-
const HAS_FREE_REGIONS = 1 << 6,
410-
const HAS_TY_ERR = 1 << 7,
411-
const HAS_PROJECTION = 1 << 8,
402+
pub struct TypeFlags: u32 {
403+
const HAS_PARAMS = 1 << 0;
404+
const HAS_SELF = 1 << 1;
405+
const HAS_TY_INFER = 1 << 2;
406+
const HAS_RE_INFER = 1 << 3;
407+
const HAS_RE_SKOL = 1 << 4;
408+
const HAS_RE_EARLY_BOUND = 1 << 5;
409+
const HAS_FREE_REGIONS = 1 << 6;
410+
const HAS_TY_ERR = 1 << 7;
411+
const HAS_PROJECTION = 1 << 8;
412412

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

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

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

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

428428
const NEEDS_SUBST = TypeFlags::HAS_PARAMS.bits |
429429
TypeFlags::HAS_SELF.bits |
430-
TypeFlags::HAS_RE_EARLY_BOUND.bits,
430+
TypeFlags::HAS_RE_EARLY_BOUND.bits;
431431

432432
// Flags representing the nominal content of a type,
433433
// computed by FlagsComputation. If you add a new nominal
@@ -443,7 +443,7 @@ bitflags! {
443443
TypeFlags::HAS_PROJECTION.bits |
444444
TypeFlags::HAS_TY_CLOSURE.bits |
445445
TypeFlags::HAS_LOCAL_NAMES.bits |
446-
TypeFlags::KEEP_IN_LOCAL_TCX.bits,
446+
TypeFlags::KEEP_IN_LOCAL_TCX.bits;
447447
}
448448
}
449449

@@ -1259,13 +1259,13 @@ pub struct Destructor {
12591259
}
12601260

12611261
bitflags! {
1262-
flags AdtFlags: u32 {
1263-
const NO_ADT_FLAGS = 0,
1264-
const IS_ENUM = 1 << 0,
1265-
const IS_PHANTOM_DATA = 1 << 1,
1266-
const IS_FUNDAMENTAL = 1 << 2,
1267-
const IS_UNION = 1 << 3,
1268-
const IS_BOX = 1 << 4,
1262+
pub struct AdtFlags: u32 {
1263+
const NO_ADT_FLAGS = 0;
1264+
const IS_ENUM = 1 << 0;
1265+
const IS_PHANTOM_DATA = 1 << 1;
1266+
const IS_FUNDAMENTAL = 1 << 2;
1267+
const IS_UNION = 1 << 3;
1268+
const IS_BOX = 1 << 4;
12691269
}
12701270
}
12711271

@@ -1358,18 +1358,18 @@ pub enum AdtKind { Struct, Union, Enum }
13581358

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

13681368
// Any of these flags being set prevent field reordering optimisation.
13691369
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits |
13701370
ReprFlags::IS_PACKED.bits |
13711371
ReprFlags::IS_SIMD.bits |
1372-
ReprFlags::IS_LINEAR.bits,
1372+
ReprFlags::IS_LINEAR.bits;
13731373
}
13741374
}
13751375

src/librustc/ty/sty.rs

-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable};
1919
use ty::{Slice, TyS};
2020
use ty::subst::Kind;
2121

22-
use std::fmt;
2322
use std::iter;
2423
use std::cmp::Ordering;
2524
use syntax::abi;
@@ -577,12 +576,6 @@ impl<T> Binder<T> {
577576
}
578577
}
579578

580-
impl fmt::Debug for TypeFlags {
581-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
582-
write!(f, "{:x}", self.bits)
583-
}
584-
}
585-
586579
/// Represents the projection of an associated type. In explicit UFCS
587580
/// form this would be written `<T as Trait<..>>::N`.
588581
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]

src/librustc_apfloat/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ name = "rustc_apfloat"
88
path = "lib.rs"
99

1010
[dependencies]
11-
rustc_bitflags = { path = "../librustc_bitflags" }
11+
bitflags = "1.0"
12+
rustc_cratesio_shim = { path = "../librustc_cratesio_shim" }

src/librustc_apfloat/lib.rs

+13-16
Original file line numberDiff line numberDiff line change
@@ -53,34 +53,31 @@
5353
#![cfg_attr(not(stage0), feature(const_min_value))]
5454
#![cfg_attr(not(stage0), feature(const_max_value))]
5555

56+
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
57+
#[allow(unused_extern_crates)]
58+
extern crate rustc_cratesio_shim;
59+
5660
#[macro_use]
57-
extern crate rustc_bitflags;
61+
extern crate bitflags;
5862

5963
use std::cmp::Ordering;
6064
use std::fmt;
6165
use std::ops::{Neg, Add, Sub, Mul, Div, Rem};
62-
use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, BitOrAssign};
66+
use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign};
6367
use std::str::FromStr;
6468

6569
bitflags! {
6670
/// IEEE-754R 7: Default exception handling.
6771
///
6872
/// UNDERFLOW or OVERFLOW are always returned or-ed with INEXACT.
6973
#[must_use]
70-
#[derive(Debug)]
71-
flags Status: u8 {
72-
const OK = 0x00,
73-
const INVALID_OP = 0x01,
74-
const DIV_BY_ZERO = 0x02,
75-
const OVERFLOW = 0x04,
76-
const UNDERFLOW = 0x08,
77-
const INEXACT = 0x10
78-
}
79-
}
80-
81-
impl BitOrAssign for Status {
82-
fn bitor_assign(&mut self, rhs: Self) {
83-
*self = *self | rhs;
74+
pub struct Status: u8 {
75+
const OK = 0x00;
76+
const INVALID_OP = 0x01;
77+
const DIV_BY_ZERO = 0x02;
78+
const OVERFLOW = 0x04;
79+
const UNDERFLOW = 0x08;
80+
const INEXACT = 0x10;
8481
}
8582
}
8683

src/librustc_bitflags/Cargo.toml

-9
This file was deleted.

0 commit comments

Comments
 (0)