From 248a10eaf5cc6df2491a6e708524a41503674ffb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 3 Jul 2022 12:28:57 -0400 Subject: [PATCH] reduce regex features to reduce rebuilds --- Cargo.toml | 3 ++- ui_test/Cargo.toml | 3 ++- ui_test/src/comments.rs | 2 +- ui_test/src/rustc_stderr.rs | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f612e7a3e9e..af73a7af31c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,8 @@ libc = "0.2" [dev-dependencies] colored = "2" ui_test = { path = "ui_test" } -regex = "1.5.5" +# Features chosen to match those required by env_logger, to avoid rebuilds +regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] } lazy_static = "1.4.0" [package.metadata.rust-analyzer] diff --git a/ui_test/Cargo.toml b/ui_test/Cargo.toml index 92c00915cbf..dab46c5253c 100644 --- a/ui_test/Cargo.toml +++ b/ui_test/Cargo.toml @@ -8,7 +8,8 @@ edition = "2021" [dependencies] rustc_version = "0.4" colored = "2" -regex = "1.5.5" +# Features chosen to match those required by env_logger, to avoid rebuilds +regex = { version = "1.5.5", default-features = false, features = ["perf", "std"] } pretty_assertions = "1.2.1" crossbeam = "0.8.1" lazy_static = "1.4.0" diff --git a/ui_test/src/comments.rs b/ui_test/src/comments.rs index e7b4968a9ca..3fd65d643a1 100644 --- a/ui_test/src/comments.rs +++ b/ui_test/src/comments.rs @@ -75,7 +75,7 @@ pub(crate) fn parse_file(path: &Path) -> Self { pub(crate) fn parse(path: &Path, content: &str) -> Self { let mut this = Self::default(); let error_pattern_regex = - Regex::new(r"//(\[(?P[^\]]+)\])?~(?P\||[\^]+)?\s*(?PERROR|HELP|WARN|NOTE)?:?(?P.*)") + Regex::new(r"//(\[(?P[^\]]+)\])?~(?P\||[\^]+)? *(?PERROR|HELP|WARN|NOTE)?:?(?P.*)") .unwrap(); // The line that a `|` will refer to diff --git a/ui_test/src/rustc_stderr.rs b/ui_test/src/rustc_stderr.rs index ea32ce4bd29..fc772c84040 100644 --- a/ui_test/src/rustc_stderr.rs +++ b/ui_test/src/rustc_stderr.rs @@ -116,7 +116,7 @@ fn line(&self, file: &Path) -> Option { } pub(crate) fn filter_annotations_from_rendered(rendered: &str) -> std::borrow::Cow<'_, str> { - let annotations = Regex::new(r"\s*//(\[[^\]]\])?~.*").unwrap(); + let annotations = Regex::new(r" *//(\[[^\]]\])?~.*").unwrap(); annotations.replace_all(rendered, "") }