From 688177ff6a67b526dc4815ed8710e3dfe5612bca Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 8 Feb 2024 19:20:08 +0100 Subject: [PATCH] Use Rust 1.76 (#9897) --- Cargo.lock | 1 - .../src/printer/line_suffixes.rs | 3 +-- crates/ruff_python_ast/Cargo.toml | 1 - crates/ruff_python_ast/src/nodes.rs | 26 +++++++++++-------- crates/ruff_python_parser/src/parser.rs | 16 +++++------- rust-toolchain.toml | 2 +- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0042513438..3bd7b3b79e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2277,7 +2277,6 @@ dependencies = [ "rustc-hash", "serde", "smallvec", - "static_assertions", ] [[package]] diff --git a/crates/ruff_formatter/src/printer/line_suffixes.rs b/crates/ruff_formatter/src/printer/line_suffixes.rs index a17857cd47..309499d9a7 100644 --- a/crates/ruff_formatter/src/printer/line_suffixes.rs +++ b/crates/ruff_formatter/src/printer/line_suffixes.rs @@ -21,8 +21,7 @@ impl<'a> LineSuffixes<'a> { /// Takes all the pending line suffixes. pub(super) fn take_pending<'l>( &'l mut self, - ) -> impl Iterator> + DoubleEndedIterator + 'l + ExactSizeIterator - { + ) -> impl DoubleEndedIterator> + 'l + ExactSizeIterator { self.suffixes.drain(..) } diff --git a/crates/ruff_python_ast/Cargo.toml b/crates/ruff_python_ast/Cargo.toml index b61435355f..b0b9eec038 100644 --- a/crates/ruff_python_ast/Cargo.toml +++ b/crates/ruff_python_ast/Cargo.toml @@ -25,7 +25,6 @@ once_cell = { workspace = true } rustc-hash = { workspace = true } serde = { workspace = true, optional = true } smallvec = { workspace = true } -static_assertions = { workspace = true } [dev-dependencies] insta = { workspace = true } diff --git a/crates/ruff_python_ast/src/nodes.rs b/crates/ruff_python_ast/src/nodes.rs index 58d9656607..6057d3d64a 100644 --- a/crates/ruff_python_ast/src/nodes.rs +++ b/crates/ruff_python_ast/src/nodes.rs @@ -3880,18 +3880,22 @@ impl Ranged for crate::nodes::ParameterWithDefault { } } -#[cfg(target_pointer_width = "64")] -mod size_assertions { - use static_assertions::assert_eq_size; - +#[cfg(test)] +mod tests { #[allow(clippy::wildcard_imports)] use super::*; - assert_eq_size!(Stmt, [u8; 144]); - assert_eq_size!(StmtFunctionDef, [u8; 144]); - assert_eq_size!(StmtClassDef, [u8; 104]); - assert_eq_size!(StmtTry, [u8; 112]); - assert_eq_size!(Expr, [u8; 80]); - assert_eq_size!(Pattern, [u8; 96]); - assert_eq_size!(Mod, [u8; 32]); + #[test] + #[cfg(target_pointer_width = "64")] + fn size() { + assert!(std::mem::size_of::() <= 144); + assert!(std::mem::size_of::() <= 144); + assert!(std::mem::size_of::() <= 104); + assert!(std::mem::size_of::() <= 112); + // 80 for Rustc < 1.76 + assert!(matches!(std::mem::size_of::(), 72 | 80)); + // 96 for Rustc < 1.76 + assert!(matches!(std::mem::size_of::(), 88 | 96)); + assert!(std::mem::size_of::() <= 32); + } } diff --git a/crates/ruff_python_parser/src/parser.rs b/crates/ruff_python_parser/src/parser.rs index c0f6c7d18d..2eb0b4bd61 100644 --- a/crates/ruff_python_parser/src/parser.rs +++ b/crates/ruff_python_parser/src/parser.rs @@ -560,21 +560,19 @@ impl From for ParenthesizedExpr { } } -#[cfg(target_pointer_width = "64")] -mod size_assertions { - use static_assertions::assert_eq_size; - - use crate::parser::ParenthesizedExpr; - - assert_eq_size!(ParenthesizedExpr, [u8; 88]); -} - #[cfg(test)] mod tests { use insta::assert_debug_snapshot; use super::*; + #[cfg(target_pointer_width = "64")] + #[test] + fn size_assertions() { + // 80 with Rustc >= 1.76, 88 with Rustc < 1.76 + assert!(matches!(std::mem::size_of::(), 80 | 88)); + } + #[test] fn test_parse_empty() { let parse_ast = parse_suite("").unwrap(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6d833ff506..83a52c3838 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.75" +channel = "1.76"