From c012ee9a481c83e0114ba87547d6dac72461739c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 9 Nov 2025 13:28:46 +0100 Subject: [PATCH] lib: Bump editions to 2024 and remove legacy files --- lib/smol_str/.github/ci.rs | 127 ------------------------ lib/smol_str/.github/workflows/ci.yaml | 36 ------- lib/smol_str/.gitignore | 4 - lib/smol_str/Cargo.toml | 2 +- lib/smol_str/benches/bench.rs | 4 +- lib/smol_str/bors.toml | 2 - lib/smol_str/src/borsh.rs | 4 +- lib/smol_str/src/lib.rs | 39 ++++---- lib/text-size/.github/workflows/ci.yaml | 54 ---------- lib/text-size/.gitignore | 3 - lib/text-size/Cargo.toml | 7 +- lib/text-size/bors.toml | 6 -- lib/text-size/src/serde_impls.rs | 2 +- lib/ungrammar/.github/ci.rs | 114 --------------------- lib/ungrammar/.github/workflows/ci.yaml | 36 ------- lib/ungrammar/.gitignore | 3 - lib/ungrammar/Cargo.toml | 8 +- lib/ungrammar/bors.toml | 2 - lib/ungrammar/src/lexer.rs | 2 +- lib/ungrammar/src/parser.rs | 4 +- lib/ungrammar/ungrammar2json/Cargo.toml | 2 +- 21 files changed, 38 insertions(+), 423 deletions(-) delete mode 100644 lib/smol_str/.github/ci.rs delete mode 100644 lib/smol_str/.github/workflows/ci.yaml delete mode 100644 lib/smol_str/.gitignore delete mode 100644 lib/smol_str/bors.toml delete mode 100644 lib/text-size/.github/workflows/ci.yaml delete mode 100644 lib/text-size/.gitignore delete mode 100644 lib/text-size/bors.toml delete mode 100644 lib/ungrammar/.github/ci.rs delete mode 100644 lib/ungrammar/.github/workflows/ci.yaml delete mode 100644 lib/ungrammar/.gitignore delete mode 100644 lib/ungrammar/bors.toml diff --git a/lib/smol_str/.github/ci.rs b/lib/smol_str/.github/ci.rs deleted file mode 100644 index c594e8973c83..000000000000 --- a/lib/smol_str/.github/ci.rs +++ /dev/null @@ -1,127 +0,0 @@ -use std::{ - env, fs, - process::{self, Command, ExitStatus, Stdio}, - time::Instant, -}; - -type Error = Box; -type Result = std::result::Result; - -fn main() { - if let Err(err) = try_main() { - eprintln!("{}", err); - process::exit(1); - } -} - -fn try_main() -> Result<()> { - let cwd = env::current_dir()?; - let cargo_toml = cwd.join("Cargo.toml"); - assert!( - cargo_toml.exists(), - "Cargo.toml not found, cwd: {}", - cwd.display() - ); - - { - let _s = Section::new("BUILD_NO_DEFAULT_FEATURES"); - shell("cargo test --all-features --workspace --no-run --no-default-features")?; - } - - { - let _s = Section::new("BUILD"); - shell("cargo test --all-features --workspace --no-run")?; - } - - { - let _s = Section::new("TEST"); - shell("cargo test --all-features --workspace")?; - shell("cargo test --no-default-features --workspace")?; - } - - { - let _s = Section::new("TEST_BENCHES"); - shell("cargo test --benches --all-features")?; - } - - let current_branch = shell_output("git branch --show-current")?; - if ¤t_branch == "master" { - let _s = Section::new("PUBLISH"); - let manifest = fs::read_to_string(&cargo_toml)?; - let version = get_field(&manifest, "version")?; - let tag = format!("v{}", version); - let tags = shell_output("git tag --list")?; - - if !tags.contains(&tag) { - let token = env::var("CRATES_IO_TOKEN").unwrap(); - shell(&format!("git tag v{}", version))?; - shell(&format!("cargo publish --token {}", token))?; - shell("git push --tags")?; - } - } - Ok(()) -} - -fn get_field<'a>(text: &'a str, name: &str) -> Result<&'a str> { - for line in text.lines() { - let words = line.split_ascii_whitespace().collect::>(); - match words.as_slice() { - [n, "=", v, ..] if n.trim() == name => { - assert!(v.starts_with('"') && v.ends_with('"')); - return Ok(&v[1..v.len() - 1]); - } - _ => (), - } - } - Err(format!("can't find `{}` in\n----\n{}\n----\n", name, text))? -} - -fn shell(cmd: &str) -> Result<()> { - let status = command(cmd).status()?; - check_status(status) -} - -fn shell_output(cmd: &str) -> Result { - let output = command(cmd).stderr(Stdio::inherit()).output()?; - check_status(output.status)?; - let res = String::from_utf8(output.stdout)?; - let res = res.trim().to_string(); - println!("{}", res); - Ok(res) -} - -fn command(cmd: &str) -> Command { - eprintln!("> {}", cmd); - let words = cmd.split_ascii_whitespace().collect::>(); - let (cmd, args) = words.split_first().unwrap(); - let mut res = Command::new(cmd); - res.args(args); - res -} - -fn check_status(status: ExitStatus) -> Result<()> { - if !status.success() { - Err(format!("$status: {}", status))?; - } - Ok(()) -} - -struct Section { - name: &'static str, - start: Instant, -} - -impl Section { - fn new(name: &'static str) -> Section { - println!("::group::{}", name); - let start = Instant::now(); - Section { name, start } - } -} - -impl Drop for Section { - fn drop(&mut self) { - eprintln!("{}: {:.2?}", self.name, self.start.elapsed()); - println!("::endgroup::"); - } -} diff --git a/lib/smol_str/.github/workflows/ci.yaml b/lib/smol_str/.github/workflows/ci.yaml deleted file mode 100644 index 1c2e347374ae..000000000000 --- a/lib/smol_str/.github/workflows/ci.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: CI -on: - pull_request: - push: - branches: - - master - - staging - - trying - -env: - CARGO_INCREMENTAL: 0 - CARGO_NET_RETRY: 10 - CI: 1 - RUST_BACKTRACE: short - RUSTFLAGS: -D warnings - RUSTUP_MAX_RETRIES: 10 - -jobs: - rust: - name: Rust - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Install Rust toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - cache: false - - - run: rustc ./.github/ci.rs && ./ci - env: - CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} diff --git a/lib/smol_str/.gitignore b/lib/smol_str/.gitignore deleted file mode 100644 index 0c8227b253a5..000000000000 --- a/lib/smol_str/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target -/ci -/.vscode -Cargo.lock diff --git a/lib/smol_str/Cargo.toml b/lib/smol_str/Cargo.toml index ee3263594a3b..118b25993ffe 100644 --- a/lib/smol_str/Cargo.toml +++ b/lib/smol_str/Cargo.toml @@ -5,7 +5,7 @@ description = "small-string optimized string type with O(1) clone" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/rust-analyzer/tree/master/lib/smol_str" authors = ["Aleksey Kladov ", "Lukas Wirth "] -edition = "2021" +edition = "2024" rust-version = "1.89" [package.metadata.docs.rs] diff --git a/lib/smol_str/benches/bench.rs b/lib/smol_str/benches/bench.rs index 2643b025575d..092ee3598095 100644 --- a/lib/smol_str/benches/bench.rs +++ b/lib/smol_str/benches/bench.rs @@ -1,6 +1,6 @@ -use criterion::{criterion_group, criterion_main, Criterion}; +use criterion::{Criterion, criterion_group, criterion_main}; use rand::distr::{Alphanumeric, SampleString}; -use smol_str::{format_smolstr, SmolStr, StrExt, ToSmolStr}; +use smol_str::{SmolStr, StrExt, ToSmolStr, format_smolstr}; use std::hint::black_box; /// 12: small (inline) diff --git a/lib/smol_str/bors.toml b/lib/smol_str/bors.toml deleted file mode 100644 index b92b99ac3020..000000000000 --- a/lib/smol_str/bors.toml +++ /dev/null @@ -1,2 +0,0 @@ -status = [ "Rust" ] -delete_merged_branches = true diff --git a/lib/smol_str/src/borsh.rs b/lib/smol_str/src/borsh.rs index ebb20d71a005..527ce85a1746 100644 --- a/lib/smol_str/src/borsh.rs +++ b/lib/smol_str/src/borsh.rs @@ -1,8 +1,8 @@ -use crate::{Repr, SmolStr, INLINE_CAP}; +use crate::{INLINE_CAP, Repr, SmolStr}; use alloc::string::{String, ToString}; use borsh::{ - io::{Error, ErrorKind, Read, Write}, BorshDeserialize, BorshSerialize, + io::{Error, ErrorKind, Read, Write}, }; use core::mem::transmute; diff --git a/lib/smol_str/src/lib.rs b/lib/smol_str/src/lib.rs index effaba211df9..a1d2c2f06744 100644 --- a/lib/smol_str/src/lib.rs +++ b/lib/smol_str/src/lib.rs @@ -434,8 +434,7 @@ impl FromStr for SmolStr { const INLINE_CAP: usize = InlineSize::_V23 as usize; const N_NEWLINES: usize = 32; const N_SPACES: usize = 128; -const WS: &str = - "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "; +const WS: &str = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "; const _: () = { assert!(WS.len() == N_NEWLINES + N_SPACES); assert!(WS.as_bytes()[N_NEWLINES - 1] == b'\n'); @@ -690,24 +689,24 @@ impl StrExt for str { #[inline] fn replacen_smolstr(&self, from: &str, to: &str, mut count: usize) -> SmolStr { // Fast path for replacing a single ASCII character with another inline. - if let [from_u8] = from.as_bytes() { - if let [to_u8] = to.as_bytes() { - return if self.len() <= count { - // SAFETY: `from_u8` & `to_u8` are ascii - unsafe { replacen_1_ascii(self, |b| if b == from_u8 { *to_u8 } else { *b }) } - } else { - unsafe { - replacen_1_ascii(self, |b| { - if b == from_u8 && count != 0 { - count -= 1; - *to_u8 - } else { - *b - } - }) - } - }; - } + if let [from_u8] = from.as_bytes() + && let [to_u8] = to.as_bytes() + { + return if self.len() <= count { + // SAFETY: `from_u8` & `to_u8` are ascii + unsafe { replacen_1_ascii(self, |b| if b == from_u8 { *to_u8 } else { *b }) } + } else { + unsafe { + replacen_1_ascii(self, |b| { + if b == from_u8 && count != 0 { + count -= 1; + *to_u8 + } else { + *b + } + }) + } + }; } let mut result = SmolStrBuilder::new(); diff --git a/lib/text-size/.github/workflows/ci.yaml b/lib/text-size/.github/workflows/ci.yaml deleted file mode 100644 index 4538ca8479d9..000000000000 --- a/lib/text-size/.github/workflows/ci.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: CI -on: - pull_request: - push: - branches: - - master - - staging - - trying - -env: - RUSTFLAGS: -D warnings - RUSTUP_MAX_RETRIES: 10 - CARGO_NET_RETRY: 10 - -jobs: - rust: - name: Rust - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - - - name: Test - run: cargo test --all-features - - rustdoc: - name: Docs - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - profile: minimal - override: true - - - name: Rustdoc - run: cargo rustdoc --all-features -- -D warnings diff --git a/lib/text-size/.gitignore b/lib/text-size/.gitignore deleted file mode 100644 index 693699042b1a..000000000000 --- a/lib/text-size/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target -**/*.rs.bk -Cargo.lock diff --git a/lib/text-size/Cargo.toml b/lib/text-size/Cargo.toml index 7882f7cc3526..f889009b0b29 100644 --- a/lib/text-size/Cargo.toml +++ b/lib/text-size/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "text-size" version = "1.1.1" -edition = "2018" +edition = "2024" authors = [ "Aleksey Kladov ", @@ -13,7 +13,7 @@ repository = "https://github.com/rust-analyzer/text-size" documentation = "https://docs.rs/text-size" [dependencies] -serde = { version = "1.0", optional = true, default_features = false } +serde = { version = "1.0", optional = true, default-features = false } [dev-dependencies] serde_test = "1.0" @@ -23,3 +23,6 @@ static_assertions = "1.1" name = "serde" path = "tests/serde.rs" required-features = ["serde"] + +[lints] +workspace = true diff --git a/lib/text-size/bors.toml b/lib/text-size/bors.toml deleted file mode 100644 index 932be8d0909c..000000000000 --- a/lib/text-size/bors.toml +++ /dev/null @@ -1,6 +0,0 @@ -status = [ - "Rust (ubuntu-latest)", - "Rust (windows-latest)", - "Rust (macos-latest)", -] -delete_merged_branches = true diff --git a/lib/text-size/src/serde_impls.rs b/lib/text-size/src/serde_impls.rs index 7f3f75751041..4cd41618c2d7 100644 --- a/lib/text-size/src/serde_impls.rs +++ b/lib/text-size/src/serde_impls.rs @@ -1,6 +1,6 @@ use { crate::{TextRange, TextSize}, - serde::{de, Deserialize, Deserializer, Serialize, Serializer}, + serde::{Deserialize, Deserializer, Serialize, Serializer, de}, }; impl Serialize for TextSize { diff --git a/lib/ungrammar/.github/ci.rs b/lib/ungrammar/.github/ci.rs deleted file mode 100644 index 87eb307d633d..000000000000 --- a/lib/ungrammar/.github/ci.rs +++ /dev/null @@ -1,114 +0,0 @@ -use std::{ - env, fs, - process::{self, Command, ExitStatus, Stdio}, - time::Instant, -}; - -type Error = Box; -type Result = std::result::Result; - -fn main() { - if let Err(err) = try_main() { - eprintln!("{}", err); - process::exit(1); - } -} - -fn try_main() -> Result<()> { - let cwd = env::current_dir()?; - let cargo_toml = cwd.join("Cargo.toml"); - assert!( - cargo_toml.exists(), - "Cargo.toml not found, cwd: {}", - cwd.display() - ); - - { - let _s = Section::new("BUILD"); - shell("cargo test --workspace --no-run")?; - } - - { - let _s = Section::new("TEST"); - shell("cargo test --workspace")?; - } - - let current_branch = shell_output("git branch --show-current")?; - if ¤t_branch == "master" { - let _s = Section::new("PUBLISH"); - let manifest = fs::read_to_string(&cargo_toml)?; - let version = get_field(&manifest, "version")?; - let tag = format!("v{}", version); - let tags = shell_output("git tag --list")?; - - if !tags.contains(&tag) { - let token = env::var("CRATES_IO_TOKEN").unwrap(); - shell(&format!("git tag v{}", version))?; - shell(&format!("cargo publish --token {}", token))?; - shell("git push --tags")?; - } - } - Ok(()) -} - -fn get_field<'a>(text: &'a str, name: &str) -> Result<&'a str> { - for line in text.lines() { - let words = line.split_ascii_whitespace().collect::>(); - match words.as_slice() { - [n, "=", v, ..] if n.trim() == name => { - assert!(v.starts_with('"') && v.ends_with('"')); - return Ok(&v[1..v.len() - 1]); - } - _ => (), - } - } - Err(format!("can't find `{}` in\n----\n{}\n----\n", name, text))? -} - -fn shell(cmd: &str) -> Result<()> { - let status = command(cmd).status()?; - check_status(status) -} - -fn shell_output(cmd: &str) -> Result { - let output = command(cmd).stderr(Stdio::inherit()).output()?; - check_status(output.status)?; - let res = String::from_utf8(output.stdout)?; - Ok(res.trim().to_string()) -} - -fn command(cmd: &str) -> Command { - eprintln!("> {}", cmd); - let words = cmd.split_ascii_whitespace().collect::>(); - let (cmd, args) = words.split_first().unwrap(); - let mut res = Command::new(cmd); - res.args(args); - res -} - -fn check_status(status: ExitStatus) -> Result<()> { - if !status.success() { - Err(format!("$status: {}", status))?; - } - Ok(()) -} - -struct Section { - name: &'static str, - start: Instant, -} - -impl Section { - fn new(name: &'static str) -> Section { - println!("::group::{}", name); - let start = Instant::now(); - Section { name, start } - } -} - -impl Drop for Section { - fn drop(&mut self) { - eprintln!("{}: {:.2?}", self.name, self.start.elapsed()); - println!("::endgroup::"); - } -} diff --git a/lib/ungrammar/.github/workflows/ci.yaml b/lib/ungrammar/.github/workflows/ci.yaml deleted file mode 100644 index 88f133867e71..000000000000 --- a/lib/ungrammar/.github/workflows/ci.yaml +++ /dev/null @@ -1,36 +0,0 @@ -name: CI -on: - pull_request: - push: - branches: - - master - - staging - - trying - -env: - CARGO_INCREMENTAL: 0 - CARGO_NET_RETRY: 10 - CI: 1 - RUST_BACKTRACE: short - RUSTFLAGS: -D warnings - RUSTUP_MAX_RETRIES: 10 - -jobs: - rust: - name: Rust - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - override: true - - - run: rustc ./.github/ci.rs && ./ci - env: - CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} diff --git a/lib/ungrammar/.gitignore b/lib/ungrammar/.gitignore deleted file mode 100644 index e3bd43f693fa..000000000000 --- a/lib/ungrammar/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/ci -/Cargo.lock -/target diff --git a/lib/ungrammar/Cargo.toml b/lib/ungrammar/Cargo.toml index 6e9dec7d6b27..b8dcb4abf7d3 100644 --- a/lib/ungrammar/Cargo.toml +++ b/lib/ungrammar/Cargo.toml @@ -4,10 +4,10 @@ description = "A DSL for describing concrete syntax trees" version = "1.16.1" license = "MIT OR Apache-2.0" repository = "https://github.com/rust-analyzer/ungrammar" -edition = "2018" - -exclude = ["/bors.toml", "/.github"] - +edition = "2024" [dependencies] # nope + +[lints] +workspace = true diff --git a/lib/ungrammar/bors.toml b/lib/ungrammar/bors.toml deleted file mode 100644 index b92b99ac3020..000000000000 --- a/lib/ungrammar/bors.toml +++ /dev/null @@ -1,2 +0,0 @@ -status = [ "Rust" ] -delete_merged_branches = true diff --git a/lib/ungrammar/src/lexer.rs b/lib/ungrammar/src/lexer.rs index f4c979b5bdc7..23da09abb2a1 100644 --- a/lib/ungrammar/src/lexer.rs +++ b/lib/ungrammar/src/lexer.rs @@ -1,5 +1,5 @@ //! Simple hand-written ungrammar lexer -use crate::error::{bail, Result}; +use crate::error::{Result, bail}; #[derive(Debug, Eq, PartialEq)] pub(crate) enum TokenKind { diff --git a/lib/ungrammar/src/parser.rs b/lib/ungrammar/src/parser.rs index 70fbe1ac0b66..2cc5dc54df6e 100644 --- a/lib/ungrammar/src/parser.rs +++ b/lib/ungrammar/src/parser.rs @@ -3,9 +3,9 @@ use std::collections::HashMap; use crate::{ - error::{bail, format_err, Result}, - lexer::{self, TokenKind}, Grammar, Node, NodeData, Rule, Token, TokenData, + error::{Result, bail, format_err}, + lexer::{self, TokenKind}, }; macro_rules! bail { diff --git a/lib/ungrammar/ungrammar2json/Cargo.toml b/lib/ungrammar/ungrammar2json/Cargo.toml index 19ca3d832430..0fa08bbbd048 100644 --- a/lib/ungrammar/ungrammar2json/Cargo.toml +++ b/lib/ungrammar/ungrammar2json/Cargo.toml @@ -5,7 +5,7 @@ version = "1.0.0" license = "MIT OR Apache-2.0" repository = "https://github.com/matklad/ungrammar" authors = ["Aleksey Kladov "] -edition = "2018" +edition = "2024" [dependencies] write-json = "0.1.1"