Skip to content

Commit 5757ad2

Browse files
authored
Unrolled build for #143325
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`
2 parents 25face9 + 7d35f2f commit 5757ad2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/bootstrap/src/utils/cache/tests.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
use std::path::PathBuf;
22

3-
use crate::utils::cache::{INTERNER, Internable, TyIntern};
3+
use crate::utils::cache::{INTERNER, Internable, Interner, TyIntern};
44

55
#[test]
66
fn test_string_interning() {
7-
let s1 = INTERNER.intern_str("Hello");
8-
let s2 = INTERNER.intern_str("Hello");
9-
let s3 = INTERNER.intern_str("world");
7+
let interner = Interner::default();
8+
let s1 = interner.intern_str("Hello");
9+
let s2 = interner.intern_str("Hello");
10+
let s3 = interner.intern_str("world");
1011

1112
assert_eq!(s1, s2, "Same strings should be interned to the same instance");
1213
assert_ne!(s1, s3, "Different strings should have different interned values");
1314
}
1415

1516
#[test]
1617
fn test_interned_equality() {
18+
// Because we compare with &str, and the Deref impl accesses the global
19+
// INTERNER variable, we cannot use a local Interner variable here.
1720
let s1 = INTERNER.intern_str("test");
1821
let s2 = INTERNER.intern_str("test");
1922

0 commit comments

Comments
 (0)