diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-12 09:14:44 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-12 09:14:44 +0530 |
| commit | cc6ef80fa4b04ad8247091c19b2c380c7fc5306a (patch) | |
| tree | 76dee933ea471c59e338c5c8263215e560a65620 /src/test | |
| parent | e4e5640a6e189004c81417902a94242074acf530 (diff) | |
| parent | a83db812385f9bf281078c7c8ede44f6863f2966 (diff) | |
| download | rust-cc6ef80fa4b04ad8247091c19b2c380c7fc5306a.tar.gz rust-cc6ef80fa4b04ad8247091c19b2c380c7fc5306a.zip | |
Rollup merge of #23275 - aochagavia:constants, r=eddyb
Fixes #23260 r? @eddyb
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/repeat_count.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/issue-19244.rs | 29 |
2 files changed, 26 insertions, 5 deletions
diff --git a/src/test/compile-fail/repeat_count.rs b/src/test/compile-fail/repeat_count.rs index 9b3e2668042..12158141220 100644 --- a/src/test/compile-fail/repeat_count.rs +++ b/src/test/compile-fail/repeat_count.rs @@ -19,7 +19,7 @@ fn main() { //~| found `()` //~| expected usize //~| found () -//~| ERROR expected constant integer for repeat count, found non-constant expression +//~| ERROR expected positive integer for repeat count, found tuple let c = [0; true]; //~^ ERROR mismatched types //~| expected `usize` diff --git a/src/test/run-pass/issue-19244.rs b/src/test/run-pass/issue-19244.rs index 9af4d30c4f6..35e053110df 100644 --- a/src/test/run-pass/issue-19244.rs +++ b/src/test/run-pass/issue-19244.rs @@ -8,14 +8,35 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct MyStruct { field: uint } +struct MyStruct { field: usize } +struct Nested { nested: MyStruct } +struct Mix2 { nested: ((usize,),) } + const STRUCT: MyStruct = MyStruct { field: 42 }; -const TUP: (uint,) = (43,); +const TUP: (usize,) = (43,); +const NESTED_S: Nested = Nested { nested: MyStruct { field: 5 } }; +const NESTED_T: ((usize,),) = ((4,),); +const MIX_1: ((Nested,),) = ((Nested { nested: MyStruct { field: 3 } },),); +const MIX_2: Mix2 = Mix2 { nested: ((2,),) }; +const INSTANT_1: usize = (MyStruct { field: 1 }).field; +const INSTANT_2: usize = (0,).0; fn main() { let a = [0; STRUCT.field]; let b = [0; TUP.0]; + let c = [0; NESTED_S.nested.field]; + let d = [0; (NESTED_T.0).0]; + let e = [0; (MIX_1.0).0.nested.field]; + let f = [0; (MIX_2.nested.0).0]; + let g = [0; INSTANT_1]; + let h = [0; INSTANT_2]; - assert!(a.len() == 42); - assert!(b.len() == 43); + assert_eq!(a.len(), 42); + assert_eq!(b.len(), 43); + assert_eq!(c.len(), 5); + assert_eq!(d.len(), 4); + assert_eq!(e.len(), 3); + assert_eq!(f.len(), 2); + assert_eq!(g.len(), 1); + assert_eq!(h.len(), 0); } |
