Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7cf430a

Browse files
committedMar 18, 2025
Remove the regex dependency from coretests
It is only used by a single test, yet would take up unnecessary space once stdlib deps get vendored.
1 parent 493c38b commit 7cf430a

File tree

3 files changed

+11
-46
lines changed

3 files changed

+11
-46
lines changed
 

‎library/Cargo.lock

-26
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ version = "0.0.0"
8585
dependencies = [
8686
"rand",
8787
"rand_xorshift",
88-
"regex",
8988
]
9089

9190
[[package]]
@@ -312,31 +311,6 @@ dependencies = [
312311
"rand_core",
313312
]
314313

315-
[[package]]
316-
name = "regex"
317-
version = "1.11.1"
318-
source = "registry+https://github.com/rust-lang/crates.io-index"
319-
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
320-
dependencies = [
321-
"regex-automata",
322-
"regex-syntax",
323-
]
324-
325-
[[package]]
326-
name = "regex-automata"
327-
version = "0.4.9"
328-
source = "registry+https://github.com/rust-lang/crates.io-index"
329-
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
330-
dependencies = [
331-
"regex-syntax",
332-
]
333-
334-
[[package]]
335-
name = "regex-syntax"
336-
version = "0.8.5"
337-
source = "registry+https://github.com/rust-lang/crates.io-index"
338-
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
339-
340314
[[package]]
341315
name = "rustc-demangle"
342316
version = "0.1.24"

‎library/coretests/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ test = true
2525
[dev-dependencies]
2626
rand = { version = "0.9.0", default-features = false }
2727
rand_xorshift = { version = "0.4.0", default-features = false }
28-
regex = { version = "1.11.1", default-features = false }

‎library/coretests/tests/fmt/mod.rs

+11-19
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,24 @@ fn test_pointer_formats_data_pointer() {
2222
#[test]
2323
fn test_fmt_debug_of_raw_pointers() {
2424
use core::fmt::Debug;
25+
use core::ptr;
2526

26-
fn check_fmt<T: Debug>(t: T, expected: &str) {
27-
use std::sync::LazyLock;
28-
29-
use regex::Regex;
30-
31-
static ADDR_REGEX: LazyLock<Regex> =
32-
LazyLock::new(|| Regex::new(r"0x[0-9a-fA-F]+").unwrap());
33-
27+
fn check_fmt<T: Debug>(t: T, expected1: &str, expected2: &str) {
3428
let formatted = format!("{:?}", t);
35-
let normalized = ADDR_REGEX.replace_all(&formatted, "$$HEX");
36-
37-
assert_eq!(normalized, expected);
29+
assert!(formatted.starts_with(expected1), "{formatted:?} doesn't start with {expected1:?}");
30+
assert!(formatted.contains(expected2), "{formatted:?} doesn't contain {expected2:?}");
3831
}
3932

40-
let plain = &mut 100;
41-
check_fmt(plain as *mut i32, "$HEX");
42-
check_fmt(plain as *const i32, "$HEX");
33+
assert_eq!(format!("{:?}", ptr::without_provenance_mut::<i32>(0x100)), "0x100");
34+
assert_eq!(format!("{:?}", ptr::without_provenance::<i32>(0x100)), "0x100");
4335

44-
let slice = &mut [200, 300, 400][..];
45-
check_fmt(slice as *mut [i32], "Pointer { addr: $HEX, metadata: 3 }");
46-
check_fmt(slice as *const [i32], "Pointer { addr: $HEX, metadata: 3 }");
36+
let slice = ptr::slice_from_raw_parts(ptr::without_provenance::<i32>(0x100), 3);
37+
assert_eq!(format!("{:?}", slice as *mut [i32]), "Pointer { addr: 0x100, metadata: 3 }");
38+
assert_eq!(format!("{:?}", slice as *const [i32]), "Pointer { addr: 0x100, metadata: 3 }");
4739

4840
let vtable = &mut 500 as &mut dyn Debug;
49-
check_fmt(vtable as *mut dyn Debug, "Pointer { addr: $HEX, metadata: DynMetadata($HEX) }");
50-
check_fmt(vtable as *const dyn Debug, "Pointer { addr: $HEX, metadata: DynMetadata($HEX) }");
41+
check_fmt(vtable as *mut dyn Debug, "Pointer { addr: ", ", metadata: DynMetadata(");
42+
check_fmt(vtable as *const dyn Debug, "Pointer { addr: ", ", metadata: DynMetadata(");
5143
}
5244

5345
#[test]

0 commit comments

Comments
 (0)
Failed to load comments.