]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_llvm/lib.rs
Fix weird implicit dependency between rustllvm and rustc_codegen_llvm
[rust.git] / src / librustc_llvm / lib.rs
index dea7e6ae0a2abf85088602bf6eafbc3e01b7b700..9c8943a9559a32724ed5ec1fa78566a455f1ae47 100644 (file)
@@ -1,4 +1,3 @@
-#![deny(rust_2018_idioms)]
 #![feature(nll)]
 #![feature(static_nobundle)]
 
@@ -6,6 +5,26 @@
 
 // NOTE: This crate only exists to allow linking on mingw targets.
 
+use std::cell::RefCell;
+use std::slice;
+use libc::{c_char, size_t};
+
+
+#[repr(C)]
+pub struct RustString {
+    pub bytes: RefCell<Vec<u8>>,
+}
+
+/// Appending to a Rust string -- used by RawRustStringOstream.
+#[no_mangle]
+pub unsafe extern "C" fn LLVMRustStringWriteImpl(sr: &RustString,
+                                                 ptr: *const c_char,
+                                                 size: size_t) {
+    let slice = slice::from_raw_parts(ptr as *const u8, size as usize);
+
+    sr.bytes.borrow_mut().extend_from_slice(slice);
+}
+
 /// Initialize targets enabled by the build script via `cfg(llvm_component = "...")`.
 /// N.B., this function can't be moved to `rustc_codegen_llvm` because of the `cfg`s.
 pub fn initialize_available_targets() {