]> git.proxmox.com Git - rustc.git/blame - src/test/ui/run-pass/issues/issue-2989.rs
New upstream version 1.30.0+dfsg1
[rustc.git] / src / test / ui / run-pass / issues / issue-2989.rs
CommitLineData
223e47cc
LB
1// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
b7449926
XL
11// run-pass
12#![allow(non_camel_case_types)]
13
223e47cc 14trait methods {
1a4d82fc 15 fn to_bytes(&self) -> Vec<u8> ;
223e47cc
LB
16}
17
18impl methods for () {
1a4d82fc
JJ
19 fn to_bytes(&self) -> Vec<u8> {
20 Vec::new()
223e47cc
LB
21 }
22}
23
24// the position of this function is significant! - if it comes before methods
970d7e83 25// then it works, if it comes after it then it doesn't!
1a4d82fc 26fn to_bools(bitv: Storage) -> Vec<bool> {
c34b1796 27 (0..8).map(|i| {
223e47cc
LB
28 let w = i / 64;
29 let b = i % 64;
c34b1796
AL
30 let x = 1 & (bitv.storage[w] >> b);
31 x == 1
1a4d82fc 32 }).collect()
223e47cc
LB
33}
34
1a4d82fc 35struct Storage { storage: Vec<u64> }
223e47cc
LB
36
37pub fn main() {
c30ab7b3
SL
38 let bools = vec![false, false, true, false, false, true, true, false];
39 let bools2 = to_bools(Storage{storage: vec![0b01100100]});
223e47cc 40
c34b1796 41 for i in 0..8 {
1a4d82fc 42 println!("{} => {} vs {}", i, bools[i], bools2[i]);
223e47cc
LB
43 }
44
970d7e83 45 assert_eq!(bools, bools2);
223e47cc 46}