From 8d3c1a123d7f00518796224448f2d294471cb7ae Mon Sep 17 00:00:00 2001 From: Casper Meijn Date: Thu, 29 Feb 2024 11:34:05 +0100 Subject: [PATCH] chore: Replace once_cell dependency by std lib LazyLock is introduced in rust 1.80 --- .github/workflows/ci.yml | 2 +- Cargo.toml | 2 +- prost-build/Cargo.toml | 1 - prost-build/src/ast.rs | 9 +++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7095968c4..443472939 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: env: PROTOC_VERSION: 3.20.3 - clippy_rust_version: 1.79 + clippy_rust_version: 1.80 jobs: # Depends on all actions that are required for a "successful" CI run. diff --git a/Cargo.toml b/Cargo.toml index 8e65e3bd3..87592679b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ authors = [ ] license = "Apache-2.0" repository = "https://github.com/tokio-rs/prost" -rust-version = "1.70" +rust-version = "1.80" edition = "2021" [profile.bench] diff --git a/prost-build/Cargo.toml b/prost-build/Cargo.toml index 0dc342cbc..6428153bf 100644 --- a/prost-build/Cargo.toml +++ b/prost-build/Cargo.toml @@ -24,7 +24,6 @@ petgraph = { version = "0.6", default-features = false } prost = { version = "0.13.1", path = "../prost", default-features = false } prost-types = { version = "0.13.1", path = "../prost-types", default-features = false } tempfile = "3" -once_cell = "1.17.1" regex = { version = "1.8.1", default-features = false, features = ["std", "unicode-bool"] } # feature: format diff --git a/prost-build/src/ast.rs b/prost-build/src/ast.rs index 9a6a0de99..07c6394ad 100644 --- a/prost-build/src/ast.rs +++ b/prost-build/src/ast.rs @@ -1,8 +1,8 @@ -use once_cell::sync::Lazy; use prost_types::source_code_info::Location; #[cfg(feature = "cleanup-markdown")] use pulldown_cmark::{CodeBlockKind, Event, Options, Parser, Tag}; use regex::Regex; +use std::sync::LazyLock; /// Comments on a Protobuf item. #[derive(Debug, Default, Clone)] @@ -110,9 +110,10 @@ impl Comments { /// - escape urls as /// - escape `[` & `]` if not already escaped and not followed by a parenthesis or bracket fn sanitize_line(line: &str) -> String { - static RULE_URL: Lazy = Lazy::new(|| Regex::new(r"https?://[^\s)]+").unwrap()); - static RULE_BRACKETS: Lazy = - Lazy::new(|| Regex::new(r"(^|[^\]\\])\[(([^\]]*[^\\])?)\]([^(\[]|$)").unwrap()); + static RULE_URL: LazyLock = + LazyLock::new(|| Regex::new(r"https?://[^\s)]+").unwrap()); + static RULE_BRACKETS: LazyLock = + LazyLock::new(|| Regex::new(r"(^|[^\]\\])\[(([^\]]*[^\\])?)\]([^(\[]|$)").unwrap()); let mut s = RULE_URL.replace_all(line, r"<$0>").to_string(); s = RULE_BRACKETS.replace_all(&s, r"$1\[$2\]$4").to_string();