From b612ae9edea26cb8704363c47a66d583b644ad09 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 12 Jun 2014 10:27:44 -0700 Subject: rustc: [T, ..N] and [T, ..N+1] are not the same This commit fixes a bug in the calculation of the hash of a type which didn't factor in the length of a constant-sized vector. As a result of this, a type placed into an Any of a fixed length could be peeled out with any other fixed length in a safe manner. --- src/libcore/any.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libcore') diff --git a/src/libcore/any.rs b/src/libcore/any.rs index ed743f40a4b..2657cd53483 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -263,6 +263,14 @@ mod tests { let s = format!("{}", b); assert_eq!(s.as_slice(), "&Any"); } + + #[test] + fn any_fixed_vec() { + let test = [0u, ..8]; + let test = &test as &Any; + assert!(test.is::<[uint, ..8]>()); + assert!(!test.is::<[uint, ..10]>()); + } } #[cfg(test)] -- cgit 1.4.1-3-g733a5