Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 11 pull requests #56353

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6674db4
Reuse the `P` in `InvocationCollector::fold_{,opt_}expr`.
nnethercote Nov 20, 2018
464c9da
serialize: preallocate VecDeque in Decodable::decode
ljedrz Nov 21, 2018
591607d
String: add a FIXME to from_utf16
ljedrz Nov 21, 2018
af9b057
drop glue takes in mutable references, it should reflect that in its …
RalfJung Nov 22, 2018
e1ca4f6
fix codegen-units tests
RalfJung Nov 22, 2018
d9de72f
miri: restrict fn argument punning to Rust ABI
RalfJung Nov 22, 2018
5c99ae6
Fix ICE with feature self_struct_ctor
estebank Nov 25, 2018
8d76f54
Use opt_def_id instead of having special branch
estebank Nov 25, 2018
057e6d3
Add TryFrom<&[T]> for [T; $N] where T: Copy
SimonSapin Nov 25, 2018
769d711
add test for issue #21335
euclio Nov 14, 2018
d4a6e73
Use sort_by_cached_key when key the function is not trivial/free
ljedrz Nov 9, 2018
be89dff
use top level `fs` functions where appropriate
euclio Nov 16, 2018
71f643e
Remove not used option
yui-knk Nov 28, 2018
2a91bba
Rename conversion util; remove duplicate util in librustc_codegen_llvm.
frewsxcv Nov 29, 2018
0124341
Only consider stem when extension is exe.
davidtwco Nov 29, 2018
a22dd48
Rollup merge of #55821 - ljedrz:cached_key_sorts, r=michaelwoerister
pietroalbini Nov 29, 2018
57d184b
Rollup merge of #56014 - euclio:issue-21335, r=nagisa
pietroalbini Nov 29, 2018
bb1e861
Rollup merge of #56131 - ljedrz:assorted, r=RalfJung
pietroalbini Nov 29, 2018
b04418c
Rollup merge of #56165 - RalfJung:drop-glue-type, r=eddyb,nikomatsakis
pietroalbini Nov 29, 2018
593cc39
Rollup merge of #56205 - estebank:ice-ice-baby, r=nikomatsakis
pietroalbini Nov 29, 2018
a29ae04
Rollup merge of #56216 - SimonSapin:array-tryfrom-slice, r=withoutboats
pietroalbini Nov 29, 2018
e320a6c
Rollup merge of #56258 - euclio:fs-read-write, r=Mark-Simulacrum
pietroalbini Nov 29, 2018
e2bec1a
Rollup merge of #56268 - nnethercote:fold_opt_expr-recycle, r=petroch…
pietroalbini Nov 29, 2018
7afff28
Rollup merge of #56339 - yui-knk:remove_mir_stats_flag, r=alexcrichton
pietroalbini Nov 29, 2018
b3246f2
Rollup merge of #56341 - frewsxcv:frewsxcv-util-cstr, r=Mark-Simulacrum
pietroalbini Nov 29, 2018
6c3a010
Rollup merge of #56349 - davidtwco:issue-55396-inference-extension, r…
pietroalbini Nov 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/librustc_codegen_llvm/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use llvm_util;
use ModuleLlvm;
use rustc_codegen_ssa::{ModuleCodegen, CompiledModule};
use rustc::util::common::time_ext;
use rustc_fs_util::{path2cstr, link_or_copy};
use rustc_fs_util::{path_to_c_string, link_or_copy};
use rustc_data_structures::small_c_str::SmallCStr;
use errors::{self, Handler, FatalError};
use type_::Type;
Expand Down Expand Up @@ -80,7 +80,7 @@ pub fn write_output_file(
output: &Path,
file_type: llvm::FileType) -> Result<(), FatalError> {
unsafe {
let output_c = path2cstr(output);
let output_c = path_to_c_string(output);
let result = llvm::LLVMRustWriteOutputFile(target, pm, m, output_c.as_ptr(), file_type);
if result.into_result().is_err() {
let msg = format!("could not write output to {}", output.display());
Expand Down Expand Up @@ -211,7 +211,7 @@ pub(crate) fn save_temp_bitcode(
let ext = format!("{}.bc", name);
let cgu = Some(&module.name[..]);
let path = cgcx.output_filenames.temp_path_ext(&ext, cgu);
let cstr = path2cstr(&path);
let cstr = path_to_c_string(&path);
let llmod = module.module_llvm.llmod();
llvm::LLVMWriteBitcodeToFile(llmod, cstr.as_ptr());
}
Expand Down Expand Up @@ -324,7 +324,7 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,

if config.emit_no_opt_bc {
let out = cgcx.output_filenames.temp_path_ext("no-opt.bc", module_name);
let out = path2cstr(&out);
let out = path_to_c_string(&out);
llvm::LLVMWriteBitcodeToFile(llmod, out.as_ptr());
}

Expand Down Expand Up @@ -530,7 +530,7 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<LlvmCodegenBackend>,
|| -> Result<(), FatalError> {
if config.emit_ir {
let out = cgcx.output_filenames.temp_path(OutputType::LlvmAssembly, module_name);
let out = path2cstr(&out);
let out = path_to_c_string(&out);

extern "C" fn demangle_callback(input_ptr: *const c_char,
input_len: size_t,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use rustc::ty::layout::{self, Align, HasDataLayout, Integer, IntegerExt, LayoutO
PrimitiveExt, Size, TyLayout};
use rustc::session::config;
use rustc::util::nodemap::FxHashMap;
use rustc_fs_util::path2cstr;
use rustc_fs_util::path_to_c_string;
use rustc_data_structures::small_c_str::SmallCStr;

use libc::{c_uint, c_longlong};
Expand Down Expand Up @@ -892,7 +892,7 @@ pub fn compile_unit_metadata(tcx: TyCtxt,
};

fn path_to_mdstring(llcx: &'ll llvm::Context, path: &Path) -> &'ll Value {
let path_str = path2cstr(path);
let path_str = path_to_c_string(path);
unsafe {
llvm::LLVMMDStringInContext(llcx,
path_str.as_ptr(),
Expand Down
16 changes: 2 additions & 14 deletions src/librustc_codegen_llvm/llvm/archive_ro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

//! A wrapper around LLVM's archive (.a) code

use std::ffi::CString;
use std::path::Path;
use std::slice;
use std::str;
use rustc_fs_util::path_to_c_string;

pub struct ArchiveRO {
pub raw: &'static mut super::Archive,
Expand All @@ -38,24 +38,12 @@ impl ArchiveRO {
/// raised.
pub fn open(dst: &Path) -> Result<ArchiveRO, String> {
return unsafe {
let s = path2cstr(dst);
let s = path_to_c_string(dst);
let ar = super::LLVMRustOpenArchive(s.as_ptr()).ok_or_else(|| {
super::last_error().unwrap_or_else(|| "failed to open archive".to_owned())
})?;
Ok(ArchiveRO { raw: ar })
};

#[cfg(unix)]
fn path2cstr(p: &Path) -> CString {
use std::os::unix::prelude::*;
use std::ffi::OsStr;
let p: &OsStr = p.as_ref();
CString::new(p.as_bytes()).unwrap()
}
#[cfg(windows)]
fn path2cstr(p: &Path) -> CString {
CString::new(p.to_str().unwrap()).unwrap()
}
}

pub fn iter(&self) -> Iter {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_data_structures::owning_ref::OwningRef;
use std::path::Path;
use std::ptr;
use std::slice;
use rustc_fs_util::path2cstr;
use rustc_fs_util::path_to_c_string;

pub use rustc_data_structures::sync::MetadataRef;

Expand Down Expand Up @@ -57,7 +57,7 @@ impl MetadataLoader for LlvmMetadataLoader {
filename: &Path)
-> Result<MetadataRef, String> {
unsafe {
let buf = path2cstr(filename);
let buf = path_to_c_string(filename);
let mb = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf.as_ptr())
.ok_or_else(|| format!("error reading library: '{}'", filename.display()))?;
let of = ObjectFile::new(mb)
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_fs_util/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ pub fn rename_or_copy_remove<P: AsRef<Path>, Q: AsRef<Path>>(p: P,
}

#[cfg(unix)]
pub fn path2cstr(p: &Path) -> CString {
use std::os::unix::prelude::*;
pub fn path_to_c_string(p: &Path) -> CString {
use std::os::unix::ffi::OsStrExt;
use std::ffi::OsStr;
let p: &OsStr = p.as_ref();
CString::new(p.as_bytes()).unwrap()
}
#[cfg(windows)]
pub fn path2cstr(p: &Path) -> CString {
pub fn path_to_c_string(p: &Path) -> CString {
CString::new(p.to_str().unwrap()).unwrap()
}