librustc_trans: remove unnecessary as_slice
calls
This commit is contained in:
parent
7d8eabb226
commit
8bb5ef9df5
src
librustc_driver
librustc_trans
@ -378,13 +378,13 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
|
||||
// Don't handle -W help here, because we might first load plugins.
|
||||
|
||||
let r = matches.opt_strs("Z");
|
||||
if r.iter().any(|x| x.as_slice() == "help") {
|
||||
if r.iter().any(|x| *x == "help") {
|
||||
describe_debug_flags();
|
||||
return None;
|
||||
}
|
||||
|
||||
let cg_flags = matches.opt_strs("C");
|
||||
if cg_flags.iter().any(|x| x.as_slice() == "help") {
|
||||
if cg_flags.iter().any(|x| *x == "help") {
|
||||
describe_codegen_flags();
|
||||
return None;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ pub fn find_crate_name(sess: Option<&Session>,
|
||||
if let Some(sess) = sess {
|
||||
if let Some(ref s) = sess.opts.crate_name {
|
||||
if let Some((attr, ref name)) = attr_crate_name {
|
||||
if s.as_slice() != name.get() {
|
||||
if *s != name.get() {
|
||||
let msg = format!("--crate-name and #[crate_name] are \
|
||||
required to match, but `{}` != `{}`",
|
||||
s, name);
|
||||
@ -249,7 +249,7 @@ pub fn sanitize(s: &str) -> String {
|
||||
let mut tstr = String::new();
|
||||
for c in c.escape_unicode() { tstr.push(c) }
|
||||
result.push('$');
|
||||
result.push_str(tstr.as_slice().slice_from(1));
|
||||
result.push_str(tstr.slice_from(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -669,7 +669,7 @@ fn link_rlib<'a>(sess: &'a Session,
|
||||
fn write_rlib_bytecode_object_v1<T: Writer>(writer: &mut T,
|
||||
bc_data_deflated: &[u8])
|
||||
-> ::std::io::IoResult<()> {
|
||||
let bc_data_deflated_size: u64 = bc_data_deflated.as_slice().len() as u64;
|
||||
let bc_data_deflated_size: u64 = bc_data_deflated.len() as u64;
|
||||
|
||||
try! { writer.write(RLIB_BYTECODE_OBJECT_MAGIC) };
|
||||
try! { writer.write_le_u32(1) };
|
||||
@ -910,10 +910,10 @@ fn link_args(cmd: &mut Command,
|
||||
let args = sess.opts.cg.link_args.as_ref().unwrap_or(&empty_vec);
|
||||
let mut args = args.iter().chain(used_link_args.iter());
|
||||
if !dylib
|
||||
&& (t.options.relocation_model.as_slice() == "pic"
|
||||
|| sess.opts.cg.relocation_model.as_ref()
|
||||
.unwrap_or(&empty_str).as_slice() == "pic")
|
||||
&& !args.any(|x| x.as_slice() == "-static") {
|
||||
&& (t.options.relocation_model == "pic"
|
||||
|| *sess.opts.cg.relocation_model.as_ref()
|
||||
.unwrap_or(&empty_str) == "pic")
|
||||
&& !args.any(|x| *x == "-static") {
|
||||
cmd.arg("-pie");
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
|
||||
|
||||
// Internalize everything but the reachable symbols of the current module
|
||||
let cstrs: Vec<::std::c_str::CString> =
|
||||
reachable.iter().map(|s| s.as_slice().to_c_str()).collect();
|
||||
reachable.iter().map(|s| s.to_c_str()).collect();
|
||||
let arr: Vec<*const i8> = cstrs.iter().map(|c| c.as_ptr()).collect();
|
||||
let ptr = arr.as_ptr();
|
||||
unsafe {
|
||||
|
@ -363,7 +363,7 @@ unsafe extern "C" fn diagnostic_handler(info: DiagnosticInfoRef, user: *mut c_vo
|
||||
let pass_name = pass_name.as_str().expect("got a non-UTF8 pass name from LLVM");
|
||||
let enabled = match cgcx.remark {
|
||||
AllPasses => true,
|
||||
SomePasses(ref v) => v.iter().any(|s| s.as_slice() == pass_name),
|
||||
SomePasses(ref v) => v.iter().any(|s| *s == pass_name),
|
||||
};
|
||||
|
||||
if enabled {
|
||||
@ -421,7 +421,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
|
||||
// If we're verifying or linting, add them to the function pass
|
||||
// manager.
|
||||
let addpass = |pass: &str| {
|
||||
pass.as_slice().with_c_str(|s| llvm::LLVMRustAddPass(fpm, s))
|
||||
pass.with_c_str(|s| llvm::LLVMRustAddPass(fpm, s))
|
||||
};
|
||||
if !config.no_verify { assert!(addpass("verify")); }
|
||||
|
||||
@ -433,7 +433,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
|
||||
}
|
||||
|
||||
for pass in config.passes.iter() {
|
||||
pass.as_slice().with_c_str(|s| {
|
||||
pass.with_c_str(|s| {
|
||||
if !llvm::LLVMRustAddPass(mpm, s) {
|
||||
cgcx.handler.warn(format!("unknown pass {}, ignoring",
|
||||
*pass).as_slice());
|
||||
|
@ -163,7 +163,7 @@ impl<'a> FmtStrs<'a> {
|
||||
let values = values.iter().map(|s| {
|
||||
// Never take more than 1020 chars
|
||||
if s.len() > 1020 {
|
||||
s.as_slice().slice_to(1020)
|
||||
s.slice_to(1020)
|
||||
} else {
|
||||
s.as_slice()
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
|
||||
};
|
||||
|
||||
let r = ia.asm.get().with_c_str(|a| {
|
||||
constraints.as_slice().with_c_str(|c| {
|
||||
constraints.with_c_str(|c| {
|
||||
InlineAsmCall(bcx,
|
||||
a,
|
||||
c,
|
||||
|
@ -2739,7 +2739,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
|
||||
format!("Illegal null byte in export_name \
|
||||
value: `{}`", sym).as_slice());
|
||||
}
|
||||
let g = sym.as_slice().with_c_str(|buf| {
|
||||
let g = sym.with_c_str(|buf| {
|
||||
llvm::LLVMAddGlobal(ccx.llmod(), llty, buf)
|
||||
});
|
||||
|
||||
|
@ -774,7 +774,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
let comment_text = format!("{} {}", "#",
|
||||
sanitized.replace("\n", "\n\t# "));
|
||||
self.count_insn("inlineasm");
|
||||
let asm = comment_text.as_slice().with_c_str(|c| {
|
||||
let asm = comment_text.with_c_str(|c| {
|
||||
unsafe {
|
||||
llvm::LLVMConstInlineAsm(Type::func(&[], &Type::void(self.ccx)).to_ref(),
|
||||
c, noname(), False, False)
|
||||
|
@ -222,14 +222,12 @@ unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextR
|
||||
sess.target
|
||||
.target
|
||||
.data_layout
|
||||
.as_slice()
|
||||
.with_c_str(|buf| {
|
||||
llvm::LLVMSetDataLayout(llmod, buf);
|
||||
});
|
||||
sess.target
|
||||
.target
|
||||
.llvm_target
|
||||
.as_slice()
|
||||
.with_c_str(|buf| {
|
||||
llvm::LLVMRustSetNormalizedTarget(llmod, buf);
|
||||
});
|
||||
|
@ -824,8 +824,8 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
||||
namespace_node.mangled_name_of_contained_item(var_name.as_slice());
|
||||
let var_scope = namespace_node.scope;
|
||||
|
||||
var_name.as_slice().with_c_str(|var_name| {
|
||||
linkage_name.as_slice().with_c_str(|linkage_name| {
|
||||
var_name.with_c_str(|var_name| {
|
||||
linkage_name.with_c_str(|linkage_name| {
|
||||
unsafe {
|
||||
llvm::LLVMDIBuilderCreateStaticVariable(DIB(cx),
|
||||
var_scope,
|
||||
@ -1323,7 +1323,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let containing_scope = namespace_node.scope;
|
||||
(linkage_name, containing_scope)
|
||||
} else {
|
||||
(function_name.as_slice().to_string(), file_metadata)
|
||||
(function_name.clone(), file_metadata)
|
||||
};
|
||||
|
||||
// Clang sets this parameter to the opening brace of the function's block,
|
||||
@ -1332,8 +1332,8 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
|
||||
let is_local_to_unit = is_node_local_to_unit(cx, fn_ast_id);
|
||||
|
||||
let fn_metadata = function_name.as_slice().with_c_str(|function_name| {
|
||||
linkage_name.as_slice().with_c_str(|linkage_name| {
|
||||
let fn_metadata = function_name.with_c_str(|function_name| {
|
||||
linkage_name.with_c_str(|linkage_name| {
|
||||
unsafe {
|
||||
llvm::LLVMDIBuilderCreateFunction(
|
||||
DIB(cx),
|
||||
@ -1554,7 +1554,7 @@ fn compile_unit_metadata(cx: &CrateContext) {
|
||||
path_bytes.insert(1, prefix[1]);
|
||||
}
|
||||
|
||||
path_bytes.as_slice().to_c_str()
|
||||
path_bytes.to_c_str()
|
||||
}
|
||||
_ => fallback_path(cx)
|
||||
}
|
||||
@ -1589,7 +1589,7 @@ fn compile_unit_metadata(cx: &CrateContext) {
|
||||
});
|
||||
|
||||
fn fallback_path(cx: &CrateContext) -> CString {
|
||||
cx.link_meta().crate_name.as_slice().to_c_str()
|
||||
cx.link_meta().crate_name.to_c_str()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1796,7 +1796,7 @@ fn pointer_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
let pointer_llvm_type = type_of::type_of(cx, pointer_type);
|
||||
let (pointer_size, pointer_align) = size_and_align_of(cx, pointer_llvm_type);
|
||||
let name = compute_debuginfo_type_name(cx, pointer_type, false);
|
||||
let ptr_metadata = name.as_slice().with_c_str(|name| {
|
||||
let ptr_metadata = name.with_c_str(|name| {
|
||||
unsafe {
|
||||
llvm::LLVMDIBuilderCreatePointerType(
|
||||
DIB(cx),
|
||||
@ -2488,8 +2488,8 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
.borrow()
|
||||
.get_unique_type_id_as_string(unique_type_id);
|
||||
|
||||
let enum_metadata = enum_name.as_slice().with_c_str(|enum_name| {
|
||||
unique_type_id_str.as_slice().with_c_str(|unique_type_id_str| {
|
||||
let enum_metadata = enum_name.with_c_str(|enum_name| {
|
||||
unique_type_id_str.with_c_str(|unique_type_id_str| {
|
||||
unsafe {
|
||||
llvm::LLVMDIBuilderCreateUnionType(
|
||||
DIB(cx),
|
||||
@ -2616,7 +2616,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
|
||||
ComputedMemberOffset => machine::llelement_offset(cx, composite_llvm_type, i)
|
||||
};
|
||||
|
||||
member_description.name.as_slice().with_c_str(|member_name| {
|
||||
member_description.name.with_c_str(|member_name| {
|
||||
unsafe {
|
||||
llvm::LLVMDIBuilderCreateMemberType(
|
||||
DIB(cx),
|
||||
@ -2656,7 +2656,7 @@ fn create_struct_stub(cx: &CrateContext,
|
||||
.get_unique_type_id_as_string(unique_type_id);
|
||||
let metadata_stub = unsafe {
|
||||
struct_type_name.with_c_str(|name| {
|
||||
unique_type_id_str.as_slice().with_c_str(|unique_type_id| {
|
||||
unique_type_id_str.with_c_str(|unique_type_id| {
|
||||
// LLVMDIBuilderCreateStructType() wants an empty array. A null
|
||||
// pointer will lead to hard to trace and debug LLVM assertions
|
||||
// later on in llvm/lib/IR/Value.cpp.
|
||||
|
@ -496,7 +496,7 @@ pub fn declare_tydesc<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>)
|
||||
let llalign = llalign_of(ccx, llty);
|
||||
let name = mangle_internal_name_by_type_and_seq(ccx, t, "tydesc");
|
||||
debug!("+++ declare_tydesc {} {}", ppaux::ty_to_string(ccx.tcx(), t), name);
|
||||
let gvar = name.as_slice().with_c_str(|buf| {
|
||||
let gvar = name.with_c_str(|buf| {
|
||||
unsafe {
|
||||
llvm::LLVMAddGlobal(ccx.llmod(), ccx.tydesc_type().to_ref(), buf)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user