diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-07-03 05:21:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-03 05:21:36 +0200 |
| commit | 5aa7dd81d80db2a7e58344587a6e6ecbd2690510 (patch) | |
| tree | 2aebb7f3c7b6e3726fdf35e7b6c9f71e70211c71 | |
| parent | 7e600de3c8e03e57fba4099fc8751fe0eb7a81b1 (diff) | |
| parent | 7d35f2f8c0a6be102c90a0130ca784106637f723 (diff) | |
| download | rust-5aa7dd81d80db2a7e58344587a6e6ecbd2690510.tar.gz rust-5aa7dd81d80db2a7e58344587a6e6ecbd2690510.zip | |
Rollup merge of #143325 - Kobzol:bootstrap-interner, r=clubby789
Use non-global interner in `test_string_interning` in bootstrap Just a small cleanup that we found on our GSoC call. CC `@Shourya742`
| -rw-r--r-- | src/bootstrap/src/utils/cache/tests.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/bootstrap/src/utils/cache/tests.rs b/src/bootstrap/src/utils/cache/tests.rs index 8562a35b3e0..fd0a7cccd60 100644 --- a/src/bootstrap/src/utils/cache/tests.rs +++ b/src/bootstrap/src/utils/cache/tests.rs @@ -1,12 +1,13 @@ use std::path::PathBuf; -use crate::utils::cache::{INTERNER, Internable, TyIntern}; +use crate::utils::cache::{INTERNER, Internable, Interner, TyIntern}; #[test] fn test_string_interning() { - let s1 = INTERNER.intern_str("Hello"); - let s2 = INTERNER.intern_str("Hello"); - let s3 = INTERNER.intern_str("world"); + let interner = Interner::default(); + let s1 = interner.intern_str("Hello"); + let s2 = interner.intern_str("Hello"); + let s3 = interner.intern_str("world"); assert_eq!(s1, s2, "Same strings should be interned to the same instance"); assert_ne!(s1, s3, "Different strings should have different interned values"); @@ -14,6 +15,8 @@ fn test_string_interning() { #[test] fn test_interned_equality() { + // Because we compare with &str, and the Deref impl accesses the global + // INTERNER variable, we cannot use a local Interner variable here. let s1 = INTERNER.intern_str("test"); let s2 = INTERNER.intern_str("test"); |
