Skip to content

Commit 3a7b960

Browse files
committed
Auto merge of rust-lang#44441 - tamird:cargo-bitflags, r=alexcrichton
Remove rustc_bitflags; use the bitflags crate r? @alexcrichton
2 parents caad256 + 231d9e7 commit 3a7b960

File tree

25 files changed

+193
-650
lines changed

25 files changed

+193
-650
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/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cargo = { path = "tools/cargo" }
6363
# Override rustfmt dependencies both on the repo and the crate (the RLS
6464
# sometimes uses either).
6565
# FIXME should only need the crates.io patch, long term.
66-
[patch.'https://github.com/rust-lang-nursery/rustfmt']
66+
[patch."https://github.com/rust-lang-nursery/rustfmt"]
6767
rustfmt-nightly = { path = "tools/rustfmt" }
6868
[patch.crates-io]
6969
rustfmt-nightly = { path = "tools/rustfmt" }

src/bootstrap/bootstrap.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,6 @@ def build_bootstrap(self):
625625

626626
def build_triple(self):
627627
"""Build triple as in LLVM"""
628-
default_encoding = sys.getdefaultencoding()
629628
config = self.get_toml('build')
630629
if config:
631630
return config
@@ -638,7 +637,7 @@ def update_submodules(self):
638637
return
639638
print('Updating submodules')
640639
default_encoding = sys.getdefaultencoding()
641-
run(["git", "submodule", "-q", "sync"], cwd=self.rust_root)
640+
run(["git", "submodule", "-q", "sync"], cwd=self.rust_root, verbose=self.verbose)
642641
submodules = [s.split(' ', 1)[1] for s in subprocess.check_output(
643642
["git", "config", "--file",
644643
os.path.join(self.rust_root, ".gitmodules"),
@@ -683,7 +682,7 @@ def bootstrap():
683682
try:
684683
with open(args.config or 'config.toml') as config:
685684
build.config_toml = config.read()
686-
except:
685+
except OSError:
687686
pass
688687

689688
if '\nverbose = 2' in build.config_toml:

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
@@ -398,35 +398,35 @@ pub struct CReaderCacheKey {
398398
// check whether the type has various kinds of types in it without
399399
// recursing over the type itself.
400400
bitflags! {
401-
flags TypeFlags: u32 {
402-
const HAS_PARAMS = 1 << 0,
403-
const HAS_SELF = 1 << 1,
404-
const HAS_TY_INFER = 1 << 2,
405-
const HAS_RE_INFER = 1 << 3,
406-
const HAS_RE_SKOL = 1 << 4,
407-
const HAS_RE_EARLY_BOUND = 1 << 5,
408-
const HAS_FREE_REGIONS = 1 << 6,
409-
const HAS_TY_ERR = 1 << 7,
410-
const HAS_PROJECTION = 1 << 8,
401+
pub struct TypeFlags: u32 {
402+
const HAS_PARAMS = 1 << 0;
403+
const HAS_SELF = 1 << 1;
404+
const HAS_TY_INFER = 1 << 2;
405+
const HAS_RE_INFER = 1 << 3;
406+
const HAS_RE_SKOL = 1 << 4;
407+
const HAS_RE_EARLY_BOUND = 1 << 5;
408+
const HAS_FREE_REGIONS = 1 << 6;
409+
const HAS_TY_ERR = 1 << 7;
410+
const HAS_PROJECTION = 1 << 8;
411411

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

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

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

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

427427
const NEEDS_SUBST = TypeFlags::HAS_PARAMS.bits |
428428
TypeFlags::HAS_SELF.bits |
429-
TypeFlags::HAS_RE_EARLY_BOUND.bits,
429+
TypeFlags::HAS_RE_EARLY_BOUND.bits;
430430

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

@@ -1258,13 +1258,13 @@ pub struct Destructor {
12581258
}
12591259

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

@@ -1357,18 +1357,18 @@ pub enum AdtKind { Struct, Union, Enum }
13571357

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

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

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)