From d6bb8fee0b3f010902d8297f16589467d82e4e4f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 13 Mar 2023 08:47:14 -0400 Subject: [PATCH] Upgrade to bitflags 2.0 This version of bitflags now requires us to explicitly list the traits that we want to derive for our bit-flags structs. --- Cargo.lock | 32 +++++++++++++++----------- crates/tor-cell/Cargo.toml | 2 +- crates/tor-cell/src/relaycell/msg.rs | 1 + crates/tor-netdir/Cargo.toml | 2 +- crates/tor-netdir/src/weight.rs | 3 ++- crates/tor-netdoc/Cargo.toml | 2 +- crates/tor-netdoc/src/doc/netstatus.rs | 1 + 7 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0c8a93063..18868f0f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -532,6 +532,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f6e5df9abedba5099a01a6567c6086a6fbcff57af07c360d356737f9e0c644" + [[package]] name = "blanket" version = "0.2.0" @@ -661,7 +667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_lex", "indexmap", "strsim", @@ -1728,7 +1734,7 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" dependencies = [ - "bitflags", + "bitflags 1.3.2", "inotify-sys", "libc", ] @@ -1834,7 +1840,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8367585489f01bc55dd27404dcf56b95e6da061a256a666ab23be9ba96a2e587" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", ] @@ -2056,7 +2062,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "static_assertions", @@ -2078,7 +2084,7 @@ version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58ea850aa68a06e48fdb069c0ec44d0d64c8dbffa49bf3b6f7f0a901fdea1ba9" dependencies = [ - "bitflags", + "bitflags 1.3.2", "filetime", "inotify", "kqueue", @@ -2235,7 +2241,7 @@ version = "0.10.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "foreign-types", "libc", @@ -2627,7 +2633,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -2752,7 +2758,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -2782,7 +2788,7 @@ version = "0.36.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -2905,7 +2911,7 @@ version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -3643,7 +3649,7 @@ name = "tor-cell" version = "0.9.0" dependencies = [ "arrayref", - "bitflags", + "bitflags 2.0.0", "bytes", "caret", "derive_more", @@ -4097,7 +4103,7 @@ dependencies = [ name = "tor-netdir" version = "0.8.0" dependencies = [ - "bitflags", + "bitflags 2.0.0", "derive_builder_fork_arti", "derive_more", "digest 0.10.6", @@ -4136,7 +4142,7 @@ version = "0.6.2" dependencies = [ "arrayref", "base64ct", - "bitflags", + "bitflags 2.0.0", "cipher", "derive_more", "digest 0.10.6", diff --git a/crates/tor-cell/Cargo.toml b/crates/tor-cell/Cargo.toml index 7925a4688..06acf43ce 100644 --- a/crates/tor-cell/Cargo.toml +++ b/crates/tor-cell/Cargo.toml @@ -26,7 +26,7 @@ testing = ["experimental-udp"] [dependencies] arrayref = "0.3" -bitflags = "1" +bitflags = "2" bytes = "1" caret = { path = "../caret", version = "0.3.0" } derive_more = "0.99.3" diff --git a/crates/tor-cell/src/relaycell/msg.rs b/crates/tor-cell/src/relaycell/msg.rs index 2a311c9ed..333a3c39d 100644 --- a/crates/tor-cell/src/relaycell/msg.rs +++ b/crates/tor-cell/src/relaycell/msg.rs @@ -119,6 +119,7 @@ bitflags! { /// /// For historical reasons, these flags are constructed so that 0 /// is a reasonable default for all of them. + #[derive(Clone, Copy, Debug)] pub struct BeginFlags : u32 { /// The client would accept a connection to an IPv6 address. const IPV6_OKAY = (1<<0); diff --git a/crates/tor-netdir/Cargo.toml b/crates/tor-netdir/Cargo.toml index bde482e0c..0bc637fb3 100644 --- a/crates/tor-netdir/Cargo.toml +++ b/crates/tor-netdir/Cargo.toml @@ -30,7 +30,7 @@ hs-common = ["digest", "time", "tor-hscrypto"] testing = ["hex", "tor-netdoc/build_docs"] [dependencies] -bitflags = "1" +bitflags = "2" derive_builder = { version = "0.11.2", package = "derive_builder_fork_arti" } derive_more = "0.99.3" digest = { version = "0.10.0", optional = true } diff --git a/crates/tor-netdir/src/weight.rs b/crates/tor-netdir/src/weight.rs index e3f1b7bb1..03928f138 100644 --- a/crates/tor-netdir/src/weight.rs +++ b/crates/tor-netdir/src/weight.rs @@ -165,6 +165,7 @@ bitflags! { /// /// Relays can have or lack the Guard flag, the Exit flag, and the /// V2Dir flag. All together, this makes 8 kinds of relays. + #[derive(Clone, Copy, Debug, Eq, PartialEq)] struct WeightKind: u8 { /// Flag in weightkind for Guard relays. const GUARD = 1 << 0; @@ -192,7 +193,7 @@ impl WeightKind { } /// Return the index to use for this kind of a relay within a WeightSet. fn idx(self) -> usize { - self.bits as usize + self.bits() as usize } } diff --git a/crates/tor-netdoc/Cargo.toml b/crates/tor-netdoc/Cargo.toml index 8e919d34f..4ad93c115 100644 --- a/crates/tor-netdoc/Cargo.toml +++ b/crates/tor-netdoc/Cargo.toml @@ -62,7 +62,7 @@ dangerous-expose-struct-fields = ["visible", "visibility"] [dependencies] arrayref = "0.3" base64ct = { version = "1.5.1", features = ["alloc"] } -bitflags = "1" +bitflags = "2" cipher = { version = "0.4.1", features = ["zeroize"] } derive_more = "0.99.3" digest = "0.10.0" diff --git a/crates/tor-netdoc/src/doc/netstatus.rs b/crates/tor-netdoc/src/doc/netstatus.rs index d9b4e6d1b..aeddaf651 100644 --- a/crates/tor-netdoc/src/doc/netstatus.rs +++ b/crates/tor-netdoc/src/doc/netstatus.rs @@ -444,6 +444,7 @@ bitflags! { /// they are not listed in this type. /// /// The bit values used to represent the flags have no meaning. + #[derive(Clone, Copy, Debug)] pub struct RelayFlags: u16 { /// Is this a directory authority? const AUTHORITY = (1<<0);