hyperium / h2

HTTP 2.0 client & server implementation for Rust.
MIT License
1.35k stars 269 forks source link

Replace deprecated compare_and_swap #510

Closed kornelski closed 3 years ago

kornelski commented 3 years ago

Deprecation warning elevated to an error is breaking a PR unrelated to these functions #509

kornelski commented 3 years ago

rustfmt is ridiculous. Sorry, I'm not going to change well-formatted code to appease a poor tool.

-        let prev = self.0.state.compare_exchange(
-            USER_STATE_PENDING_PONG,  // current
-            USER_STATE_RECEIVED_PONG, // new
-            Ordering::AcqRel,
-            Ordering::Acquire,
-        ).unwrap_or_else(|v| v);
+        let prev = self
+            .0
+            .state
+            .compare_exchange(
+                USER_STATE_PENDING_PONG,  // current
+                USER_STATE_RECEIVED_PONG, // new
+                Ordering::AcqRel,
+                Ordering::Acquire,
+            )
+            .unwrap_or_else(|v| v);
carllerche commented 3 years ago

Maybe file a bug with rustfmt then?

kornelski commented 3 years ago

I did, and I lost that argument.

Unconditional replacement of all author's line wrapping decisions with rustfmt's heuristics is an intentional design principle of rustfmt, so from rustfmt's perspective it's not a bug, but a feature. Plus rustfmt's formatting is declared stable, so these things are not up for discussion any more.

And this annoys me to no end, so I just don't contribute to projects that use rustfmt :(