Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5a345b3

Browse files
committed
Auto merge of rust-lang#119446 - Nilstrieb:bitflags2.0-hell, r=compiler-errors
Update to bitflags 2 in the compiler This involves lots of breaking changes. There are two big changes that force changes. The first is that the bitflag types now don't automatically implement normal derive traits, so we need to derive them manually. Additionally, bitflags now have a hidden inner type by default, which breaks our custom derives. The bitflags docs recommend using the impl form in these cases, which I did. r? compiler
2 parents a2541e8 + ffafcd8 commit 5a345b3

File tree

32 files changed

+132
-139
lines changed

32 files changed

+132
-139
lines changed

Cargo.lock

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
285285

286286
[[package]]
287287
name = "bitflags"
288-
version = "2.4.0"
288+
version = "2.4.1"
289289
source = "registry+https://github.com/rust-lang/crates.io-index"
290-
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
290+
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
291291

292292
[[package]]
293293
name = "block-buffer"
@@ -3370,7 +3370,7 @@ dependencies = [
33703370
name = "rustc_abi"
33713371
version = "0.0.0"
33723372
dependencies = [
3373-
"bitflags 1.3.2",
3373+
"bitflags 2.4.1",
33743374
"rand",
33753375
"rand_xoshiro",
33763376
"rustc_data_structures",
@@ -3401,7 +3401,7 @@ dependencies = [
34013401
name = "rustc_ast"
34023402
version = "0.0.0"
34033403
dependencies = [
3404-
"bitflags 1.3.2",
3404+
"bitflags 2.4.1",
34053405
"memchr",
34063406
"rustc_data_structures",
34073407
"rustc_index",
@@ -3552,7 +3552,7 @@ dependencies = [
35523552
name = "rustc_codegen_llvm"
35533553
version = "0.0.0"
35543554
dependencies = [
3555-
"bitflags 1.3.2",
3555+
"bitflags 2.4.1",
35563556
"itertools",
35573557
"libc",
35583558
"measureme",
@@ -3587,7 +3587,7 @@ name = "rustc_codegen_ssa"
35873587
version = "0.0.0"
35883588
dependencies = [
35893589
"ar_archive_writer",
3590-
"bitflags 1.3.2",
3590+
"bitflags 2.4.1",
35913591
"cc",
35923592
"itertools",
35933593
"jobserver",
@@ -3654,7 +3654,7 @@ name = "rustc_data_structures"
36543654
version = "0.0.0"
36553655
dependencies = [
36563656
"arrayvec",
3657-
"bitflags 1.3.2",
3657+
"bitflags 2.4.1",
36583658
"elsa",
36593659
"ena",
36603660
"indexmap",
@@ -4121,7 +4121,7 @@ dependencies = [
41214121
name = "rustc_metadata"
41224122
version = "0.0.0"
41234123
dependencies = [
4124-
"bitflags 1.3.2",
4124+
"bitflags 2.4.1",
41254125
"libloading 0.7.4",
41264126
"odht",
41274127
"rustc_ast",
@@ -4151,7 +4151,7 @@ dependencies = [
41514151
name = "rustc_middle"
41524152
version = "0.0.0"
41534153
dependencies = [
4154-
"bitflags 1.3.2",
4154+
"bitflags 2.4.1",
41554155
"derive_more",
41564156
"either",
41574157
"field-offset",
@@ -4286,7 +4286,7 @@ dependencies = [
42864286
name = "rustc_parse"
42874287
version = "0.0.0"
42884288
dependencies = [
4289-
"bitflags 1.3.2",
4289+
"bitflags 2.4.1",
42904290
"rustc_ast",
42914291
"rustc_ast_pretty",
42924292
"rustc_data_structures",
@@ -4424,7 +4424,7 @@ dependencies = [
44244424
name = "rustc_resolve"
44254425
version = "0.0.0"
44264426
dependencies = [
4427-
"bitflags 1.3.2",
4427+
"bitflags 2.4.1",
44284428
"pulldown-cmark",
44294429
"rustc_arena",
44304430
"rustc_ast",
@@ -4463,7 +4463,7 @@ dependencies = [
44634463
name = "rustc_session"
44644464
version = "0.0.0"
44654465
dependencies = [
4466-
"bitflags 1.3.2",
4466+
"bitflags 2.4.1",
44674467
"getopts",
44684468
"libc",
44694469
"rustc_ast",
@@ -4521,7 +4521,7 @@ dependencies = [
45214521
name = "rustc_symbol_mangling"
45224522
version = "0.0.0"
45234523
dependencies = [
4524-
"bitflags 1.3.2",
4524+
"bitflags 2.4.1",
45254525
"punycode",
45264526
"rustc-demangle",
45274527
"rustc_data_structures",
@@ -4539,7 +4539,7 @@ dependencies = [
45394539
name = "rustc_target"
45404540
version = "0.0.0"
45414541
dependencies = [
4542-
"bitflags 1.3.2",
4542+
"bitflags 2.4.1",
45434543
"object",
45444544
"rustc_abi",
45454545
"rustc_data_structures",
@@ -4638,7 +4638,7 @@ dependencies = [
46384638
name = "rustc_type_ir"
46394639
version = "0.0.0"
46404640
dependencies = [
4641-
"bitflags 1.3.2",
4641+
"bitflags 2.4.1",
46424642
"derivative",
46434643
"rustc_data_structures",
46444644
"rustc_index",
@@ -4768,7 +4768,7 @@ version = "0.38.19"
47684768
source = "registry+https://github.com/rust-lang/crates.io-index"
47694769
checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed"
47704770
dependencies = [
4771-
"bitflags 2.4.0",
4771+
"bitflags 2.4.1",
47724772
"errno",
47734773
"libc",
47744774
"linux-raw-sys",

compiler/rustc_abi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
bitflags = "1.2.1"
8+
bitflags = "2.4.1"
99
rand = { version = "0.8.4", default-features = false, optional = true }
1010
rand_xoshiro = { version = "0.6.0", optional = true }
1111
rustc_data_structures = { path = "../rustc_data_structures", optional = true }

compiler/rustc_abi/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ pub use layout::LayoutCalculator;
2929
/// instead of implementing everything in `rustc_middle`.
3030
pub trait HashStableContext {}
3131

32+
#[derive(Clone, Copy, PartialEq, Eq, Default)]
33+
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_Generic))]
34+
pub struct ReprFlags(u8);
35+
3236
bitflags! {
33-
#[derive(Default)]
34-
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_Generic))]
35-
pub struct ReprFlags: u8 {
37+
impl ReprFlags: u8 {
3638
const IS_C = 1 << 0;
3739
const IS_SIMD = 1 << 1;
3840
const IS_TRANSPARENT = 1 << 2;
@@ -42,11 +44,12 @@ bitflags! {
4244
// the seed stored in `ReprOptions.layout_seed`
4345
const RANDOMIZE_LAYOUT = 1 << 4;
4446
// Any of these flags being set prevent field reordering optimisation.
45-
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits
46-
| ReprFlags::IS_SIMD.bits
47-
| ReprFlags::IS_LINEAR.bits;
47+
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits()
48+
| ReprFlags::IS_SIMD.bits()
49+
| ReprFlags::IS_LINEAR.bits();
4850
}
4951
}
52+
rustc_data_structures::external_bitflags_debug! { ReprFlags }
5053

5154
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
5255
#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_Generic))]

compiler/rustc_ast/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
bitflags = "1.2.1"
8+
bitflags = "2.4.1"
99
memchr = "2.5.0"
1010
rustc_data_structures = { path = "../rustc_data_structures" }
1111
rustc_index = { path = "../rustc_index" }

compiler/rustc_ast/src/ast.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,9 +2171,10 @@ pub enum InlineAsmRegOrRegClass {
21712171
RegClass(Symbol),
21722172
}
21732173

2174+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
2175+
pub struct InlineAsmOptions(u16);
21742176
bitflags::bitflags! {
2175-
#[derive(Encodable, Decodable, HashStable_Generic)]
2176-
pub struct InlineAsmOptions: u16 {
2177+
impl InlineAsmOptions: u16 {
21772178
const PURE = 1 << 0;
21782179
const NOMEM = 1 << 1;
21792180
const READONLY = 1 << 2;
@@ -2186,6 +2187,12 @@ bitflags::bitflags! {
21862187
}
21872188
}
21882189

2190+
impl std::fmt::Debug for InlineAsmOptions {
2191+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2192+
bitflags::parser::to_writer(self, f)
2193+
}
2194+
}
2195+
21892196
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Hash, HashStable_Generic)]
21902197
pub enum InlineAsmTemplatePiece {
21912198
String(String),

compiler/rustc_codegen_llvm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test = false
88

99
[dependencies]
1010
# tidy-alphabetical-start
11-
bitflags = "1.0"
11+
bitflags = "2.4.1"
1212
itertools = "0.11"
1313
libc = "0.2"
1414
measureme = "10.0.0"

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ pub mod debuginfo {
722722
// These values **must** match with LLVMRustDIFlags!!
723723
bitflags! {
724724
#[repr(transparent)]
725-
#[derive(Default)]
725+
#[derive(Clone, Copy, Default)]
726726
pub struct DIFlags: u32 {
727727
const FlagZero = 0;
728728
const FlagPrivate = 1;
@@ -751,7 +751,7 @@ pub mod debuginfo {
751751
// These values **must** match with LLVMRustDISPFlags!!
752752
bitflags! {
753753
#[repr(transparent)]
754-
#[derive(Default)]
754+
#[derive(Clone, Copy, Default)]
755755
pub struct DISPFlags: u32 {
756756
const SPFlagZero = 0;
757757
const SPFlagVirtual = 1;

compiler/rustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
ar_archive_writer = "0.1.5"
9-
bitflags = "1.2.1"
9+
bitflags = "2.4.1"
1010
cc = "1.0.69"
1111
itertools = "0.11"
1212
jobserver = "0.1.27"

compiler/rustc_codegen_ssa/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ pub enum ModuleKind {
110110
}
111111

112112
bitflags::bitflags! {
113+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
113114
pub struct MemFlags: u8 {
114115
const VOLATILE = 1 << 0;
115116
const NONTEMPORAL = 1 << 1;

compiler/rustc_data_structures/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
arrayvec = { version = "0.7", default-features = false }
9-
bitflags = "1.2.1"
9+
bitflags = "2.4.1"
1010
elsa = "=1.7.1"
1111
ena = "0.14.2"
1212
indexmap = { version = "2.0.0" }

0 commit comments

Comments
 (0)