]> git.proxmox.com Git - rustc.git/blame - src/test/ui/issues/issue-2989.rs
New upstream version 1.49.0+dfsg1
[rustc.git] / src / test / ui / issues / issue-2989.rs
CommitLineData
b7449926
XL
1// run-pass
2#![allow(non_camel_case_types)]
3
223e47cc 4trait methods {
1a4d82fc 5 fn to_bytes(&self) -> Vec<u8> ;
223e47cc
LB
6}
7
8impl methods for () {
1a4d82fc
JJ
9 fn to_bytes(&self) -> Vec<u8> {
10 Vec::new()
223e47cc
LB
11 }
12}
13
14// the position of this function is significant! - if it comes before methods
970d7e83 15// then it works, if it comes after it then it doesn't!
1a4d82fc 16fn to_bools(bitv: Storage) -> Vec<bool> {
c34b1796 17 (0..8).map(|i| {
223e47cc
LB
18 let w = i / 64;
19 let b = i % 64;
c34b1796
AL
20 let x = 1 & (bitv.storage[w] >> b);
21 x == 1
1a4d82fc 22 }).collect()
223e47cc
LB
23}
24
1a4d82fc 25struct Storage { storage: Vec<u64> }
223e47cc
LB
26
27pub fn main() {
c30ab7b3
SL
28 let bools = vec![false, false, true, false, false, true, true, false];
29 let bools2 = to_bools(Storage{storage: vec![0b01100100]});
223e47cc 30
c34b1796 31 for i in 0..8 {
1a4d82fc 32 println!("{} => {} vs {}", i, bools[i], bools2[i]);
223e47cc
LB
33 }
34
970d7e83 35 assert_eq!(bools, bools2);
223e47cc 36}