Merge pull request #21002 from Veykril/veykril/push-nztxvpnntmrx
lib: Bump editions to 2024 and remove legacy files
diff --git a/lib/smol_str/.github/ci.rs b/lib/smol_str/.github/ci.rs
deleted file mode 100644
index c594e89..0000000
--- 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<dyn std::error::Error>;
-type Result<T> = std::result::Result<T, Error>;
-
-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::<Vec<_>>();
- 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<String> {
- 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::<Vec<_>>();
- 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 1c2e347..0000000
--- 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 0c8227b..0000000
--- 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 ee32635..118b259 100644
--- a/lib/smol_str/Cargo.toml
+++ b/lib/smol_str/Cargo.toml
@@ -5,7 +5,7 @@
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/rust-analyzer/tree/master/lib/smol_str"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>", "Lukas Wirth <lukastw97@gmail.com>"]
-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 2643b02..092ee35 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 b92b99a..0000000
--- 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 ebb20d7..527ce85 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 effaba2..a1d2c2f 100644
--- a/lib/smol_str/src/lib.rs
+++ b/lib/smol_str/src/lib.rs
@@ -434,8 +434,7 @@
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 @@
#[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 4538ca8..0000000
--- 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 6936990..0000000
--- 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 7882f7c..f889009 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 <aleksey.kladov@gmail.com>",
@@ -13,7 +13,7 @@
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 @@
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 932be8d0..0000000
--- 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 7f3f757..4cd4161 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 87eb307..0000000
--- 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<dyn std::error::Error>;
-type Result<T> = std::result::Result<T, Error>;
-
-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::<Vec<_>>();
- 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<String> {
- 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::<Vec<_>>();
- 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 88f1338..0000000
--- 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 e3bd43f..0000000
--- 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 6e9dec7..b8dcb4a 100644
--- a/lib/ungrammar/Cargo.toml
+++ b/lib/ungrammar/Cargo.toml
@@ -4,10 +4,10 @@
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 b92b99a..0000000
--- 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 f4c979b..23da09a 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 70fbe1a..2cc5dc5 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 19ca3d8..0fa08bb 100644
--- a/lib/ungrammar/ungrammar2json/Cargo.toml
+++ b/lib/ungrammar/ungrammar2json/Cargo.toml
@@ -5,7 +5,7 @@
license = "MIT OR Apache-2.0"
repository = "https://github.com/matklad/ungrammar"
authors = ["Aleksey Kladov <aleksey.kladov@gmail.com>"]
-edition = "2018"
+edition = "2024"
[dependencies]
write-json = "0.1.1"