2016-07-28 19:58:32 -05:00
|
|
|
// Test what happens we save incremental compilation state that makes
|
|
|
|
// use of foreign items. This used to ICE (#34991).
|
|
|
|
//@ revisions: rpass1
|
|
|
|
|
|
|
|
use std::ffi::CString;
|
|
|
|
|
|
|
|
mod mlibc {
|
2020-09-01 16:12:52 -05:00
|
|
|
extern "C" {
|
2024-04-19 17:36:54 -05:00
|
|
|
// strlen is provided either by an external library or compiler-builtins as a fallback
|
|
|
|
pub fn strlen(x: *const std::ffi::c_char) -> usize;
|
2016-07-28 19:58:32 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-19 17:36:54 -05:00
|
|
|
fn strlen(s: String) -> usize {
|
2016-07-28 19:58:32 -05:00
|
|
|
let c = CString::new(s).unwrap();
|
2024-04-19 17:36:54 -05:00
|
|
|
unsafe { mlibc::strlen(c.as_ptr()) }
|
2016-07-28 19:58:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
2024-04-19 17:36:54 -05:00
|
|
|
assert_eq!(strlen("1024".to_string()), strlen("2048".to_string()));
|
2016-07-28 19:58:32 -05:00
|
|
|
}
|