]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/foreign.rs
Rollup merge of #56425 - scottmcm:redo-vec-set_len-docs, r=Centril
[rust.git] / src / test / incremental / foreign.rs
1 // Test what happens we save incremental compilation state that makes
2 // use of foreign items. This used to ICE (#34991).
3
4 // revisions: rpass1
5
6 #![feature(rustc_private)]
7
8 extern crate libc;
9
10 use std::ffi::CString;
11
12 mod mlibc {
13     use libc::{c_char, c_long, c_longlong};
14
15     extern {
16         pub fn atol(x: *const c_char) -> c_long;
17         pub fn atoll(x: *const c_char) -> c_longlong;
18     }
19 }
20
21 fn atol(s: String) -> isize {
22     let c = CString::new(s).unwrap();
23     unsafe { mlibc::atol(c.as_ptr()) as isize }
24 }
25
26 fn atoll(s: String) -> i64 {
27     let c = CString::new(s).unwrap();
28     unsafe { mlibc::atoll(c.as_ptr()) as i64 }
29 }
30
31 pub fn main() {
32     assert_eq!(atol("1024".to_string()) * 10, atol("10240".to_string()));
33     assert_eq!((atoll("11111111111111111".to_string()) * 10),
34              atoll("111111111111111110".to_string()));
35 }